本文整理汇总了Python中readline.redisplay函数的典型用法代码示例。如果您正苦于以下问题:Python redisplay函数的具体用法?Python redisplay怎么用?Python redisplay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redisplay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_printer
def _run_printer(self):
"""A thread to print messages to the command line."""
while(True):
# See if we have anything to print
loop = True
printed = False
self.output_lock.acquire()
while(loop):
try:
msg = self.print_queue.get_nowait()
print msg
printed = True
except Queue.Empty:
loop = False
if printed:
readline.redisplay()
self.output_lock.release()
# Reprint the prompt and the user's current input if necessary
if printed:
self.readline_lock.acquire()
readline.redisplay()
self.readline_lock.release()
# See if we need to terminate
if self.print_terminate.isSet():
return
# Wait until we have something to print again
self.print_event.wait()
self.print_event.clear()
示例2: display
def display(self, msg, modifier=None):
if not type(msg) is unicode:
# force output unicode string to output
# Python will hopefully handle output printing
msg=obj2utf8(msg)
if msg:
if modifier=="error":
self.stdout.write(PupyCmd.format_error(msg))
elif modifier=="success":
self.stdout.write(PupyCmd.format_success(msg))
elif modifier=="info":
self.stdout.write(PupyCmd.format_info(msg))
elif modifier=="srvinfo":
buf_bkp=readline.get_line_buffer()
#nG move cursor to column n
#nE move cursor ro the beginning of n lines down
#nK Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.
self.stdout.write("\x1b[0G"+PupyCmd.format_srvinfo(msg)+"\x1b[0E")
self.stdout.write("\x1b[2K")#clear line
self.stdout.write(self.raw_prompt+buf_bkp)#"\x1b[2K")
try:
readline.redisplay()
except Exception:
pass
elif modifier=="warning":
self.stdout.write(PupyCmd.format_warning(msg))
else:
self.stdout.write(PupyCmd.format_log(msg))
示例3: pre_input_hook
def pre_input_hook():
readline.insert_text(display.display(
thing, shortid=False, colored=False))
readline.redisplay()
# Unset the hook again
readline.set_pre_input_hook(None)
示例4: newEmitFn
def newEmitFn(*args, **kwargs):
oldEmitFn(*args, **kwargs)
global _previousReadlineBufferContents
b = readline.get_line_buffer()
if b != _previousReadlineBufferContents:
readline.redisplay()
_previousReadlineBufferContents = b
示例5: display_hook
def display_hook(prompt, session, context, matches, longest_match_len):
# type: (str, ShellSession, BundleContext, List[str], int) -> None
"""
Displays the available services matches and the service details
:param prompt: Shell prompt string
:param session: Current shell session (for display)
:param context: BundleContext of the shell
:param matches: List of words matching the substitution
:param longest_match_len: Length of the largest match
"""
# Prepare a line pattern for each match (-1 for the trailing space)
match_pattern = "{{0: <{}}} from {{1}}".format(longest_match_len - 1)
# Sort matching names
matches = sorted(match for match in matches)
# Print the match and the associated name
session.write_line()
with use_ipopo(context) as ipopo:
for factory_name in matches:
# Remove the spaces added for the completion
factory_name = factory_name.strip()
bnd = ipopo.get_factory_bundle(factory_name)
session.write_line(
match_pattern, factory_name, bnd.get_symbolic_name()
)
# Print the prompt, then current line
session.write(prompt)
session.write_line_no_feed(readline.get_line_buffer())
readline.redisplay()
示例6: redisplay
def redisplay ( self ):
if util.isPlatformWindows ():
import pyreadline
Readline ().redisplay ()
else:
import readline
readline.redisplay ()
示例7: recv
def recv(h):
while True:
msg = yield h.recv()
if msg.frm and msg.body:
# msg.frm.partition('/')[0]
print '< %s'%(msg.body.cdata,)
if readline:
readline.redisplay()
示例8: printf
def printf(self, string):
#readline.set_startup_hook(lambda: readline.insert_text("{0}".format(str)) or readline.redisplay())
self.stdout.write(str("\n{0}\n".format(string))+"\n")
self.stdout.flush()
#readline.parse_and_bind('\C-M')
readline.insert_text("oi\n")
#readline.parse_and_bind('\\n')
readline.redisplay()
示例9: sighandler
def sighandler(signum, frame):
'''Clean and tidy shutdown when killed.'''
if po.opts.debug: ps_lib.msg('debug', 'Signal %s received.' % signum)
#print 'removing:', readline.remove_history_item(readline.get_current_history_length()-1)
# how to clear the line buffer? there doesn't seem to be a function to do it.
print
readline.redisplay()
if signum == signal.SIGINT: sigintreceived = True
示例10: pre_input_hook
def pre_input_hook(self):
"""If a line buffer has been filled then inject it into the readline
buffer for the user to edit."""
if self.line_buffer:
readline.insert_text(
self.line_buffer.decode(ex_config.FILE_ENCODING).rstrip('\n'))
readline.redisplay()
self.line_buffer = None
示例11: match_display_hook
def match_display_hook(substitution, matches, longest_match_length):
## Unused args are ok. pylint: disable=W0613
""" Cleaner display for line completion """
print '\n--- possible matches ---'
for match in matches:
print match
#print self.prompt.rstrip(),
print '------------------------'
print readline.get_line_buffer(),
readline.redisplay()
示例12: color_print
def color_print(message, printed_color="\033[37m"):
"""Formats a message with a specific color (as Display.color)"""
line_buffer = readline.get_line_buffer()
preface = len(line_buffer) * "\b \b"
print(
"{0}{1}{2}{3}\n{4}".format(preface, printed_color, message, Display.color.end, line_buffer),
end="",
flush=True,
)
readline.redisplay()
示例13: main
def main():
global server
global commandLine
host = None
port = None
if len(sys.argv[1:]) == 1:
host = socket.gethostname()
port = sys.argv[1]
if len(sys.argv[1:]) == 2:
host = sys.argv[1]
port = sys.argv[2]
if host and port:
print 'Starting Crossfire client on ' + host + ':' + port
client = CrossfireClient(host, int(port))
commandLine = CommandLine()
try:
client.start()
commandLine.start()
print "Sending version command...\n"
command = Command("", "version")
client.sendPacket(command)
print "Listing contexts...\n"
command = Command("", "listcontexts")
client.sendPacket(command)
while True:
packet = client.getPacket()
if packet:
print
json.dump(packet, sys.stdout, sort_keys=True, indent=2)
print "\n" + COMMAND_PROMPT,
readline.redisplay()
if 'event' in packet and packet['event'] == "closed":
client.restart()
command = commandLine.getCommand()
if command:
print "\nSending command => " + command.command
client.sendPacket(command)
except (KeyboardInterrupt):
pass
else:
print 'No host and/or port specified.'
print 'Usage: $> python crossfire_test_client.py [<host>] <port>'
quit()
示例14: complete
def complete(self, text, state):
if not text:
readline.insert_text(' ')
if TabCompleter.uses_editline:
# It won't move the cursor for us, apparently
sys.stdout.write('\x1b[4C')
readline.redisplay()
sys.stdout.flush()
return None
else:
return rlcompleter.Completer.complete(self, text, state)
示例15: readline_display_matches_hook
def readline_display_matches_hook(self, substitution, matches, longest_match_length):
self.logger.debug('Readline display matches hook:\n substitution=%s, matches=%s longtest_match_length=%s' % \
(substitution, matches, longest_match_length))
print
for match in matches:
print match
print "%s%s" % (self.prompt, readline.get_line_buffer()),
readline.redisplay()