Commit 031e994

Richard Luby <richluby@gmail.com>
2016-11-17 09:49:06
added clear screen command
buffer can get super large and hard to scroll through after repeated commands or long tests. clear deletes the buffer
1 parent c686b04
Changed files (1)
command.go
@@ -39,7 +39,25 @@ var commandArray = []Command{Command{Command: "exit",
 			Value:       "anonymous",
 			Usage:       ""}},
 		Description: "Set the user name to utilize during this session. If not set, anonymous will be used.",
-		Run:         setUserName}}
+		Run:         setUserName},
+	Command{
+		Command:     "clear",
+		Description: "Clear the screen of all content. No scrollback will be available.",
+		Run:         clearScreen}}
+
+// clearScreen clears the screen of all content in the main
+// window
+func clearScreen(command Command) error {
+	if ApplicationView.MainGui != nil {
+		if view, err := ApplicationView.MainGui.View(ApplicationView.MAIN_WINDOW_NAME); err != nil {
+			return fmt.Errorf("Error clearing screen: %+v", err)
+		} else {
+			view.Clear()
+			return nil
+		}
+	}
+	return fmt.Errorf("No application window.")
+}
 
 // sets the user name for this session
 func setUserName(command Command) error {