Skip to content

Commit 524e795

Browse files
committed
Add clearScreen method
1 parent 0d5d083 commit 524e795

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Properties you can pass to the console element
6969
| log | (...messages: any)=>void | Log messages to the console. If string, print the value, otherwise, print the JSON value of the message.
7070
| logX | (type: string, ...messages: any)=>void | Log messages of a particular type to the console. The messages will be given the class `react-console-message-{type}`.
7171
| return | ()=>void | Signal the current command has finished and a new prompt should be displayed.
72+
| clearScreen | ()=>void | Clear the visible log in the console. Does not clear command history.
7273

7374

7475
## Awknoledgements

src/react-console.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ export default class extends React.Component<ConsoleProps,ConsoleState> {
248248
70: this.forwardChar,
249249
// C-b
250250
66: this.backwardChar,
251-
// C-l TODO
252-
//76: this.clearScreen,
251+
// C-l
252+
76: this.clearScreen,
253253
// C-p
254254
80: this.previousHistory,
255255
// C-n
@@ -588,6 +588,9 @@ export default class extends React.Component<ConsoleProps,ConsoleState> {
588588
}, this.scrollToBottom);
589589
}
590590
}
591+
clearScreen = () => {
592+
this.setState({ log: [] });
593+
}
591594
nonIncrementalReverseSearchHistory = () => {
592595
// TODO
593596
}

0 commit comments

Comments
 (0)