[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Improve format input



commit 2f224dd348e4175e2dd0912bc04657c8a400ef05
Author: Sambuddha Basu <sambuddhabasu1@xxxxxxxxx>
Date:   Sun Jun 26 01:18:17 2016 -0700

    Improve format input
---
 nyx/panel/interpreter.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/nyx/panel/interpreter.py b/nyx/panel/interpreter.py
index c60b3f8..0937808 100644
--- a/nyx/panel/interpreter.py
+++ b/nyx/panel/interpreter.py
@@ -38,12 +38,20 @@ def ansi_to_output(line, attrs):
 
 
 def format_input(user_input):
-  user_input = user_input.split(' ', 1)
-  cmd = user_input[0].upper()
-  output = [(PROMPT, GREEN, BOLD), (cmd, GREEN, BOLD)]
-
-  if len(user_input) > 1:
-    output.append((' ' + user_input[1], CYAN, BOLD))
+  output = [(PROMPT, GREEN, BOLD)]
+
+  if ' ' in user_input:
+    cmd, arg = user_input.split(' ', 1)
+  else:
+    cmd, arg = user_input, ''
+
+  if cmd.startswith('/'):
+    output.append((user_input, MAGENTA, BOLD))
+  else:
+    cmd = cmd.upper()
+    output.append((cmd + ' ', GREEN, BOLD))
+    if arg:
+      output.append((arg, CYAN, BOLD))
 
   return output
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits