You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/08/03 14:54:58 UTC

[plc4x] branch develop updated: feat(plc4xbrowser): add clear command

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new a1e8b24f6 feat(plc4xbrowser): add clear command
a1e8b24f6 is described below

commit a1e8b24f635521589425894a71d4aad24468f04f
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Aug 3 16:54:51 2022 +0200

    feat(plc4xbrowser): add clear command
---
 plc4go/tools/plc4xbrowser/commands.go | 10 ++++++++++
 plc4go/tools/plc4xbrowser/config.go   |  2 ++
 plc4go/tools/plc4xbrowser/main.go     | 12 ++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/plc4go/tools/plc4xbrowser/commands.go b/plc4go/tools/plc4xbrowser/commands.go
index f6cb468a4..07aef6c90 100644
--- a/plc4go/tools/plc4xbrowser/commands.go
+++ b/plc4go/tools/plc4xbrowser/commands.go
@@ -347,6 +347,16 @@ var rootCommand = Command{
 				return nil
 			},
 		},
+		{
+			Name:        "clear",
+			Description: "clear all outputs",
+			action: func(_ Command, _ string) error {
+				messageOutputClear()
+				consoleOutputClear()
+				commandOutputClear()
+				return nil
+			},
+		},
 	},
 }
 
diff --git a/plc4go/tools/plc4xbrowser/config.go b/plc4go/tools/plc4xbrowser/config.go
index 915843999..aba7a12d9 100644
--- a/plc4go/tools/plc4xbrowser/config.go
+++ b/plc4go/tools/plc4xbrowser/config.go
@@ -115,6 +115,8 @@ func addHost(host string) {
 
 func addCommand(command string) {
 	switch command {
+	case "clear":
+		return
 	case "history":
 		return
 	}
diff --git a/plc4go/tools/plc4xbrowser/main.go b/plc4go/tools/plc4xbrowser/main.go
index e3e392917..283afc0bd 100644
--- a/plc4go/tools/plc4xbrowser/main.go
+++ b/plc4go/tools/plc4xbrowser/main.go
@@ -43,11 +43,14 @@ var connectionsChanged func()
 
 var messagesReceived int
 var messageOutput io.Writer
+var messageOutputClear func()
 
 var consoleOutput io.Writer
+var consoleOutputClear func()
 
 var commandsExecuted int
 var commandOutput io.Writer
+var commandOutputClear func()
 
 type inputMode int
 
@@ -215,6 +218,9 @@ func buildCommandArea(newPrimitive func(text string) tview.Primitive, applicatio
 				application.Draw()
 			})
 		commandOutput = enteredCommandsView
+		commandOutputClear = func() {
+			enteredCommandsView.SetText("")
+		}
 
 		commandArea.AddItem(enteredCommandsView, 1, 0, 1, 1, 0, 0, false)
 
@@ -300,6 +306,9 @@ func buildOutputArea(newPrimitive func(text string) tview.Primitive, application
 					application.Draw()
 				})
 			messageOutput = outputView
+			messageOutputClear = func() {
+				outputView.SetText("")
+			}
 
 			outputView.SetDoneFunc(func(key tcell.Key) {
 				currentSelection := outputView.GetHighlights()
@@ -332,6 +341,9 @@ func buildOutputArea(newPrimitive func(text string) tview.Primitive, application
 					application.Draw()
 				})
 			consoleOutput = consoleView
+			consoleOutputClear = func() {
+				consoleView.SetText("")
+			}
 
 			consoleView.SetBorder(false)
 			outputArea.AddItem(consoleView, 2, 0, 1, 1, 0, 0, false)