Commit 3d5768f7 authored by Guido van Rossum's avatar Guido van Rossum

Add a primitive way to show the full message.

parent b98b6471
...@@ -231,6 +231,7 @@ class Indexer: ...@@ -231,6 +231,7 @@ class Indexer:
pass pass
text = "" text = ""
top = 0 top = 0
results = []
while 1: while 1:
try: try:
line = raw_input("Query: ") line = raw_input("Query: ")
...@@ -238,6 +239,9 @@ class Indexer: ...@@ -238,6 +239,9 @@ class Indexer:
print "\nBye." print "\nBye."
break break
line = line.strip() line = line.strip()
if line.startswith("/"):
self.specialcommand(line, results, top - nbest)
continue
if line: if line:
text = line text = line
top = 0 top = 0
...@@ -251,7 +255,6 @@ class Indexer: ...@@ -251,7 +255,6 @@ class Indexer:
except: except:
reportexc() reportexc()
text = "" text = ""
top = 0
continue continue
if len(results) <= top: if len(results) <= top:
if not n: if not n:
...@@ -259,13 +262,38 @@ class Indexer: ...@@ -259,13 +262,38 @@ class Indexer:
else: else:
print "No more hits for %r." % text print "No more hits for %r." % text
text = "" text = ""
top = 0
continue continue
print "[Results %d-%d from %d" % (top+1, min(n, top+nbest), n), print "[Results %d-%d from %d" % (top+1, min(n, top+nbest), n),
print "for query %s]" % repr(text) print "for query %s]" % repr(text)
self.formatresults(text, results, maxlines, top, top+nbest) self.formatresults(text, results, maxlines, top, top+nbest)
top += nbest top += nbest
def specialcommand(self, line, results, first):
assert line.startswith("/")
line = line[1:]
if not line:
n = first
else:
try:
n = int(line) - 1
except:
print "Huh?"
return
if n < 0 or n >= len(results):
print "Out of range"
return
docid, score = results[n]
path = self.docpaths[docid]
i = path.rfind("/")
assert i > 0
folder = path[:i]
n = path[i+1:]
cmd = "show +%s %s" % (folder, n)
if os.getenv("DISPLAY"):
os.system("xterm -e %s &" % cmd)
else:
os.system(cmd)
def query(self, text, nbest=NBEST, maxlines=MAXLINES): def query(self, text, nbest=NBEST, maxlines=MAXLINES):
results, n = self.timequery(text, nbest) results, n = self.timequery(text, nbest)
if not n: if not n:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment