From 524e79552ce84f24e018712d81bf054ec986e6d8 Mon Sep 17 00:00:00 2001 From: Spencer Nowak Date: Mon, 22 May 2017 12:43:36 -0400 Subject: [PATCH] Add clearScreen method --- README.md | 1 + src/react-console.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a7a467..8c1a7e8 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Properties you can pass to the console element | log | (...messages: any)=>void | Log messages to the console. If string, print the value, otherwise, print the JSON value of the message. | 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}`. | return | ()=>void | Signal the current command has finished and a new prompt should be displayed. +| clearScreen | ()=>void | Clear the visible log in the console. Does not clear command history. ## Awknoledgements diff --git a/src/react-console.tsx b/src/react-console.tsx index e4d076d..d2bb870 100644 --- a/src/react-console.tsx +++ b/src/react-console.tsx @@ -248,8 +248,8 @@ export default class extends React.Component { 70: this.forwardChar, // C-b 66: this.backwardChar, - // C-l TODO - //76: this.clearScreen, + // C-l + 76: this.clearScreen, // C-p 80: this.previousHistory, // C-n @@ -588,6 +588,9 @@ export default class extends React.Component { }, this.scrollToBottom); } } + clearScreen = () => { + this.setState({ log: [] }); + } nonIncrementalReverseSearchHistory = () => { // TODO }