[Lldb-commits] [lldb] r192814 - lui: enable tab completion in command window

Sriram Murali sriram87 at gmail.com
Wed Oct 16 10:08:55 PDT 2013


Author: sriram87
Date: Wed Oct 16 12:08:55 2013
New Revision: 192814

URL: http://llvm.org/viewvc/llvm-project?rev=192814&view=rev
Log:
lui: enable tab completion in command window


Modified:
    lldb/trunk/utils/lui/commandwin.py

Modified: lldb/trunk/utils/lui/commandwin.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/lui/commandwin.py?rev=192814&r1=192813&r2=192814&view=diff
==============================================================================
--- lldb/trunk/utils/lui/commandwin.py (original)
+++ lldb/trunk/utils/lui/commandwin.py Wed Oct 16 12:08:55 2013
@@ -10,6 +10,7 @@
 import cui
 import curses
 import lldb
+from itertools import islice
 
 class History(object):
   def __init__(self):
@@ -52,7 +53,7 @@ class CommandWin(cui.TitledWin):
   def __init__(self, driver, x, y, w, h):
     super(CommandWin, self).__init__(x, y, w, h, "Commands")
     self.command = ""
-
+    self.data = ""
     driver.setSize(w, h)
 
     self.win.scrollok(1)
@@ -63,7 +64,23 @@ class CommandWin(cui.TitledWin):
     def enterCallback(content):
       self.handleCommand(content)
     def tabCompleteCallback(content):
-      pass # TODO: implement
+      self.data = content
+      matches = lldb.SBStringList()
+      commandinterpreter = self.getCommandInterpreter()
+      commandinterpreter.HandleCompletion(self.data, self.el.index, 0, -1, matches)
+      if matches.GetSize() == 2:
+        self.el.content += matches.GetStringAtIndex(0)
+        self.el.index = len(self.el.content)
+        self.el.draw()
+      else:
+        self.win.move(self.el.starty, self.el.startx)
+        self.win.scroll(1)
+        self.win.addstr("Available Completions:")
+        self.win.scroll(1)
+        for m in islice(matches, 1, None):
+          self.win.addstr(self.win.getyx()[0], 0, m)
+          self.win.scroll(1)
+        self.el.draw()
 
     self.startline = self.win.getmaxyx()[0]-2
 
@@ -100,3 +117,5 @@ class CommandWin(cui.TitledWin):
         return
       self.el.handleEvent(event)
 
+  def getCommandInterpreter(self):
+    return self.driver.getCommandInterpreter()





More information about the lldb-commits mailing list