From 55328d6b0676d54b4a790f8c129565406d6e465b Mon Sep 17 00:00:00 2001 From: LtWorf Date: Mon, 21 Jun 2010 17:57:15 +0000 Subject: [PATCH] - Working completion git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@234 014f5005-505e-4b48-8d0a-63407b615a7c --- relational_readline/linegui.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/relational_readline/linegui.py b/relational_readline/linegui.py index 780a06a..a3fd15b 100644 --- a/relational_readline/linegui.py +++ b/relational_readline/linegui.py @@ -47,26 +47,30 @@ class SimpleCompleter(object): pass def complete(self, text, state): - #print test, state - response = None if state == 0: # This is the first time for this text, so build a match list. if text: - self.matches = [s + + self.matches =[s for s in self.options if s and s.startswith(text)] #Add the completion for files here try: - listf=os.listdir(os.path.dirname(text)) + d=os.path.dirname(text) + listf=os.listdir(d) + + d+="/" except: + d="" listf=os.listdir('.') for i in listf: + i=(d+i).replace('//','/') if i.startswith(text): if os.path.isdir(i): - i+="/" + i=i+"/" self.matches.append(i) logging.debug('%s matches: %s', repr(text), self.matches) @@ -88,7 +92,6 @@ class SimpleCompleter(object): relations={} completer=SimpleCompleter(['LIST','LOAD ','UNLOAD ','HELP ','QUIT','SAVE ','_PRODUCT ','_UNION ','_INTERSECTION ','_DIFFERENCE ','_JOIN ','_LJOIN ','_RJOIN ','_FJOIN ','_PROJECTION ','_RENAME_TO ','_SELECTION ','_RENAME ']) - def load_relation(filename,defname=None): if not os.path.isfile(filename): print >> sys.stderr, "%s is not a file" % filename @@ -239,6 +242,8 @@ def main(files=[]): readline.parse_and_bind('tab: complete') readline.parse_and_bind('set editing-mode emacs') + readline.set_completer_delims(" ") + while True: try: