##// END OF EJS Templates
zmqterminal frontend now uses IPythonInputSplitter, and non-ascii characters work.
zmqterminal frontend now uses IPythonInputSplitter, and non-ascii characters work.

File last commit:

r5592:2ebf9e34
r5593:b0e2b84d
Show More
completer.py
52 lines | 1.8 KiB | text/x-python | PythonLexer
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 # -*- coding: utf-8 -*-
import readline
import time
import sys
stdout = sys.stdout
class ClientCompleter2p(object):
"""Client-side completion machinery.
How it works: self.complete will be called multiple times, with
state=0,1,2,... When state=0 it should compute ALL the completion matches,
and then return them for each value of state."""
Omar Andres Zapata Mesa
tab completion is not working yet, unknow error
r5585 def __init__(self,client, km):
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 self.km = km
self.matches = []
Omar Andres Zapata Mesa
tab completion is not working yet, unknow error
r5585 self.client = client
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584
def complete_request(self,text):
Omar Andres Zapata Mesa
tab completion is not working yet, unknow error
r5585 line = readline.get_line_buffer()
#msg_id = self.km.xreq_channel.complete(text=text,line=line)#this method is not working, the code not continue
Thomas Kluyver
Replace tabs with spaces
r5591 msg = self.km.session.send(self.km.xreq_channel.socket,
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 'complete_request',
dict(text=text, line=line))
Omar Andres Zapata Mesa
tab completion is not working yet, unknow error
r5585 # send completion request to kernel
# Give the kernel up to 0.5s to respond
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 msg_matches = None
for i in range(5):
Thomas Kluyver
Replace tabs with spaces
r5591 if self.km.xreq_channel.was_called():
msg_xreq = self.km.xreq_channel.get_msg()
if msg["header"]['session'] == msg_xreq["parent_header"]['session'] :
if msg_xreq["content"]["status"] == 'ok' :
if msg_xreq["msg_type"] == "complete_reply" :
msg_matches = msg_xreq["content"]["matches"]
#break
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 time.sleep(0.1)
return msg_matches
def complete(self, text, state):
if state == 0 :
Thomas Kluyver
Replace tabs with spaces
r5591 self.matches = self.complete_request(text)
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584 if self.matches is None:
self.matches = []
print('WARNING: Kernel timeout on tab completion.')
Omar Andres Zapata Mesa
tab completion is not working yet, unknow error
r5585 #print self.matches
Thomas Kluyver
Replace tabs with spaces
r5591 try:
return self.matches[state]
except IndexError:
return None
Thomas Kluyver
Make readline tab-completion work in two-process terminal frontend.
r5586
Omar Andres Zapata Mesa
-mworking in tab-completion
r5584