示例#1
0
def display_suggestion(msg):
    global old_matches
    matches = []
    if not msg or not msg.strip():
        if old_matches != matches:
            W.gotoxy(0, C.height - 2)
            W.clreol()
            old_matches = matches
        return
    msg = msg.split()[0]
    for command in commands:
        if command.command.startswith(msg) and not command.hide:
            matches.append(command)
    if matches:
        #limit our match count
        matches = matches[:5]
        if old_matches != matches:
            old_matches = matches
            W.gotoxy(0, C.height - 2)
            W.clreol()
        
            targetwidth = C.width / len(matches)
            W.textcolor(W.DARKGREY)
            for command in matches:
                W.cputs(('%s (%s)' % (command.command, format_time(command.time, command.time_variable))).center(targetwidth))
    return matches
示例#2
0
    def _erase(self):
	self.written_x = 0
	sys.stdout.write ("\r")
	if self.OS != 'nt':
	    sys.stdout.write ("\x1b[0K")
	else:
	    WConio.clreol()
示例#3
0
 def _erase(self):
     self.written_x = 0
     sys.stdout.write("\r")
     if self.OS != 'nt':
         sys.stdout.write("\x1b[0K")
     else:
         WConio.clreol()
示例#4
0
def restore():
    '''
        Keep the terminal usable.
        Always performed on exit.
    '''
    W.clreol()
    W.textattr(defaultcolor)
    W.setcursortype(1)
示例#5
0
文件: conio.py 项目: chyser/bin
 def status(self, y, s):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     wc.gotoxy(0, y)
     wc.movetext(0, y, self.ex, self.ey -1, 0, y+1)
     wc.gotoxy(0, y)
     wc.textbackground(7)
     wc.textcolor(15)
     wc.clreol()
     wc.cputs(s)
示例#6
0
文件: conio.py 项目: chyser/bin
 def status(self, y, s):
     #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     wc.gotoxy(0, y)
     wc.movetext(0, y, self.ex, self.ey - 1, 0, y + 1)
     wc.gotoxy(0, y)
     wc.textbackground(7)
     wc.textcolor(15)
     wc.clreol()
     wc.cputs(s)
示例#7
0
def limpialinea():
	sys.stdout.write ("\r")
	if OS!='nt':
		sys.stdout.write ("\x1b[0K")
	else:
		WConio.clreol()
示例#8
0
文件: common.py 项目: 3riatarka/wfuzz
 def delete_line(self):
     if os.name != 'nt':
         sys.stdout.write("\r" + Term.delete)
     else:
         WConio.clreol()
示例#9
0
def get_input():
    buf = []
    while True:
        msg = ''.join(buf)
        matches = display_suggestion(msg)

        W.gotoxy(0, C.height - 1)
        W.clreol()
        W.textcolor(W.GREEN)
        W.cputs(game.state.current_node.command_prompt + '$ '),
        W.textcolor(W.LIGHTGREEN)
        W.cputs(msg)

        if matches and len(matches) == 1:
            #show the argument help text
            match = matches[0]
            x = W.wherex()
            W.textcolor(W.DARKGREY)
            splitted = match.arguments.split()
            splitted = splitted[max(0, len(msg.split())-2):]
            W.cputs('  ' + ' '.join(splitted))
            W.textcolor(W.LIGHTGREEN)
            W.gotoxy(x, C.height - 1)
        else:
            match = None
        
        #Read input
        W.setcursortype(1)
        (chn, chs) = W.getch()
        W.setcursortype(0)

        #figure out if we're done
        if chs == '\r':
            #enter, exit
            break

        if chn == 8: 
            #backspace
            if len(buf):
                buf.pop()
            else:
                MessageBeep()
            continue
        if chn == 3:
            log.debug('took a ctrl-c')
            game.fire('specialkey', 'ctrlc')
            break

        if chn == 0 or chn == 224:
            #special keys come in two parts
            (chn2, _) = W.getch()
            if chn2 in W.__keydict:
                game.fire('specialkey', W.__keydict[chn2])
            continue

        if len(buf) >= C.width:
            #way too long now
            break
        
        if chs not in string.printable:
            #dont care
            continue

        buf.append(chs)
    return buf, match
示例#10
0
def limpialinea():
    sys.stdout.write("\r")
    if OS != 'nt':
        sys.stdout.write("\x1b[0K")
    else:
        WConio.clreol()
示例#11
0
文件: main.py 项目: jtruscott/ld21
logger.addHandler(hdlr) 
logger.setLevel(logging.DEBUG)

import sys
import os
if 'nt' not in os.name:
    import XConio
    import curses
    import game
    game.start = curses.wrapper(game.start)
import WConio as W
defaultcolor = W.gettextinfo()[4]

import game
try:
    game.start()
except game.GameShutdown:
    W.textmode()
    pass
except KeyboardInterrupt:
    W.textmode()
    raise
except:
    raise
finally:
    logger.debug("Shutting down")
    logging.shutdown()
    W.clreol()
    W.textattr(defaultcolor)
    W.setcursortype(1)
示例#12
0
 def delete_line(self):
     if os.name != 'nt':
         sys.stdout.write("\r" + Term.delete)
     else:
         WConio.clreol()
示例#13
0
文件: otto.py 项目: marcgalang/otto
def clearLines():
	for i in range (21,24):
		WConio.gotoxy(0,i)
		WConio.clreol()