__init__.py000064400000003431147204465610006667 0ustar00"""curses The main package for curses support for Python. Normally used by importing the package, and perhaps a particular module inside it. import curses from curses import textpad curses.initscr() ... """ __revision__ = "$Id$" from _curses import * from curses.wrapper import wrapper import os as _os import sys as _sys # Some constants, most notably the ACS_* ones, are only added to the C # _curses module's dictionary after initscr() is called. (Some # versions of SGI's curses don't define values for those constants # until initscr() has been called.) This wrapper function calls the # underlying C initscr(), and then copies the constants from the # _curses module to the curses package's dictionary. Don't do 'from # curses import *' if you'll be needing the ACS_* constants. def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called. def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key() try: has_key except NameError: from has_key import has_key __init__.pyc000064400000003021147204465610007025 0ustar00 |fc@sdZdZddlTddlmZddlZddlZdZ dZ ye Wn!e k r{ddl m Z nXdS( scurses The main package for curses support for Python. Normally used by importing the package, and perhaps a particular module inside it. import curses from curses import textpad curses.initscr() ... s$Id$i(t*(twrapperNcCsddl}ddl}tdtjjdddtjj|j }xO|j j D]>\}}|dd!dks|d kr_t |||q_q_W|S( NittermtTERMtunknowntfdiitACS_tLINEStCOLS(RR( t_cursestcursest setuptermt_ostenvirontgett_syst __stdout__tfilenotinitscrt__dict__titemstsetattr(R R tstdscrtkeytvalue((s'/usr/lib64/python2.7/curses/__init__.pyRs cCsdddl}ddl}|j}t|drB|j|_nt|dr`|j|_n|S(NitCOLORSt COLOR_PAIRS(R R t start_colorthasattrRR(R R tretval((s'/usr/lib64/python2.7/curses/__init__.pyR-s (thas_key( t__doc__t __revision__R tcurses.wrapperRtosR tsysRRRRt NameError(((s'/usr/lib64/python2.7/curses/__init__.pyt s     __init__.pyo000064400000003021147204465610007041 0ustar00 |fc@sdZdZddlTddlmZddlZddlZdZ dZ ye Wn!e k r{ddl m Z nXdS( scurses The main package for curses support for Python. Normally used by importing the package, and perhaps a particular module inside it. import curses from curses import textpad curses.initscr() ... s$Id$i(t*(twrapperNcCsddl}ddl}tdtjjdddtjj|j }xO|j j D]>\}}|dd!dks|d kr_t |||q_q_W|S( NittermtTERMtunknowntfdiitACS_tLINEStCOLS(RR( t_cursestcursest setuptermt_ostenvirontgett_syst __stdout__tfilenotinitscrt__dict__titemstsetattr(R R tstdscrtkeytvalue((s'/usr/lib64/python2.7/curses/__init__.pyRs cCsdddl}ddl}|j}t|drB|j|_nt|dr`|j|_n|S(NitCOLORSt COLOR_PAIRS(R R t start_colorthasattrRR(R R tretval((s'/usr/lib64/python2.7/curses/__init__.pyR-s (thas_key( t__doc__t __revision__R tcurses.wrapperRtosR tsysRRRRt NameError(((s'/usr/lib64/python2.7/curses/__init__.pyt s     ascii.py000064400000004763147204465610006231 0ustar00"""Constants and membership tests for ASCII characters""" NUL = 0x00 # ^@ SOH = 0x01 # ^A STX = 0x02 # ^B ETX = 0x03 # ^C EOT = 0x04 # ^D ENQ = 0x05 # ^E ACK = 0x06 # ^F BEL = 0x07 # ^G BS = 0x08 # ^H TAB = 0x09 # ^I HT = 0x09 # ^I LF = 0x0a # ^J NL = 0x0a # ^J VT = 0x0b # ^K FF = 0x0c # ^L CR = 0x0d # ^M SO = 0x0e # ^N SI = 0x0f # ^O DLE = 0x10 # ^P DC1 = 0x11 # ^Q DC2 = 0x12 # ^R DC3 = 0x13 # ^S DC4 = 0x14 # ^T NAK = 0x15 # ^U SYN = 0x16 # ^V ETB = 0x17 # ^W CAN = 0x18 # ^X EM = 0x19 # ^Y SUB = 0x1a # ^Z ESC = 0x1b # ^[ FS = 0x1c # ^\ GS = 0x1d # ^] RS = 0x1e # ^^ US = 0x1f # ^_ SP = 0x20 # space DEL = 0x7f # delete controlnames = [ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", "SP" ] def _ctoi(c): if type(c) == type(""): return ord(c) else: return c def isalnum(c): return isalpha(c) or isdigit(c) def isalpha(c): return isupper(c) or islower(c) def isascii(c): return 0 <= _ctoi(c) <= 127 # ? def isblank(c): return _ctoi(c) in (9, 32) def iscntrl(c): return 0 <= _ctoi(c) <= 31 or _ctoi(c) == 127 def isdigit(c): return 48 <= _ctoi(c) <= 57 def isgraph(c): return 33 <= _ctoi(c) <= 126 def islower(c): return 97 <= _ctoi(c) <= 122 def isprint(c): return 32 <= _ctoi(c) <= 126 def ispunct(c): return isgraph(c) and not isalnum(c) def isspace(c): return _ctoi(c) in (9, 10, 11, 12, 13, 32) def isupper(c): return 65 <= _ctoi(c) <= 90 def isxdigit(c): return isdigit(c) or \ (65 <= _ctoi(c) <= 70) or (97 <= _ctoi(c) <= 102) def isctrl(c): return 0 <= _ctoi(c) < 32 def ismeta(c): return _ctoi(c) > 127 def ascii(c): if type(c) == type(""): return chr(_ctoi(c) & 0x7f) else: return _ctoi(c) & 0x7f def ctrl(c): if type(c) == type(""): return chr(_ctoi(c) & 0x1f) else: return _ctoi(c) & 0x1f def alt(c): if type(c) == type(""): return chr(_ctoi(c) | 0x80) else: return _ctoi(c) | 0x80 def unctrl(c): bits = _ctoi(c) if bits == 0x7f: rep = "^?" elif isprint(bits & 0x7f): rep = chr(bits & 0x7f) else: rep = "^" + chr(((bits & 0x7f) | 0x20) + 0x20) if bits & 0x80: return "!" + rep return rep ascii.pyc000064400000012017147204465610006363 0ustar00 |fc!@sdZdZdZdZdZdZdZdZdZd Z d Z d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCg!Z%dDZ&dEZ'dFZ(dGZ)dHZ*dIZ+dJZ,dKZ-dLZ.dMZ/dNZ0dOZ1dPZ2dQZ3dRZ4dSZ5dTZ6dUZ7dVZ8dWZ9dXS(Ys3Constants and membership tests for ASCII charactersiiiiiiiiii i i i i iiiiiiiiiiiiiiiiiii itNULtSOHtSTXtETXtEOTtENQtACKtBELtBStHTtLFtVTtFFtCRtSOtSItDLEtDC1tDC2tDC3tDC4tNAKtSYNtETBtCANtEMtSUBtESCtFStGStRStUStSPcCs*t|tdkr"t|S|SdS(Nt(ttypetord(tc((s$/usr/lib64/python2.7/curses/ascii.pyt_ctoi0s cCst|pt|S(N(tisalphatisdigit(R$((s$/usr/lib64/python2.7/curses/ascii.pytisalnum6R!cCst|pt|S(N(tisuppertislower(R$((s$/usr/lib64/python2.7/curses/ascii.pyR&7R!cCsdt|kodkSS(Nii(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisascii8R!cCst|dkS(Ni i (i i (R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisblank9R!cCs2dt|kodknp1t|dkS(Niii(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytiscntrl:R!cCsdt|kodkSS(Ni0i9(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pyR';R!cCsdt|kodkSS(Ni!i~(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisgraph<R!cCsdt|kodkSS(Niaiz(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pyR*=R!cCsdt|kodkSS(Ni i~(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisprint>R!cCst|ot| S(N(R.R((R$((s$/usr/lib64/python2.7/curses/ascii.pytispunct?R!cCst|dkS(Ni i i i i i (i i i i i i (R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisspace@R!cCsdt|kodkSS(NiAiZ(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pyR)AR!cCsLt|pKdt|ko)dknpKdt|koIdkSS(NiAiFiaif(R'R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisxdigitBs cCsdt|kodkSS(Nii (R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisctrlDR!cCst|dkS(Ni(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytismetaER!cCs>t|tdkr,tt|d@St|d@SdS(NR!i(R"tchrR%(R$((s$/usr/lib64/python2.7/curses/ascii.pytasciiGscCs>t|tdkr,tt|d@St|d@SdS(NR!i(R"R5R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytctrlMscCs>t|tdkr,tt|dBSt|dBSdS(NR!i(R"R5R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytaltSscCsvt|}|dkr!d}n?t|d@rDt|d@}ndt|d@dBd}|d@rrd|S|S(Nis^?t^i it!(R%R/R5(R$tbitstrep((s$/usr/lib64/python2.7/curses/ascii.pytunctrlYs    N(:t__doc__RRRRRRRRRtTABR R tNLR R R RRRRRRRRRRRRRRRRRRR tDELt controlnamesR%R(R&R+R,R-R'R.R*R/R0R1R)R2R3R4R6R7R8R=(((s$/usr/lib64/python2.7/curses/ascii.pytsz                    ascii.pyo000064400000012017147204465610006377 0ustar00 |fc!@sdZdZdZdZdZdZdZdZdZd Z d Z d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCg!Z%dDZ&dEZ'dFZ(dGZ)dHZ*dIZ+dJZ,dKZ-dLZ.dMZ/dNZ0dOZ1dPZ2dQZ3dRZ4dSZ5dTZ6dUZ7dVZ8dWZ9dXS(Ys3Constants and membership tests for ASCII charactersiiiiiiiiii i i i i iiiiiiiiiiiiiiiiiii itNULtSOHtSTXtETXtEOTtENQtACKtBELtBStHTtLFtVTtFFtCRtSOtSItDLEtDC1tDC2tDC3tDC4tNAKtSYNtETBtCANtEMtSUBtESCtFStGStRStUStSPcCs*t|tdkr"t|S|SdS(Nt(ttypetord(tc((s$/usr/lib64/python2.7/curses/ascii.pyt_ctoi0s cCst|pt|S(N(tisalphatisdigit(R$((s$/usr/lib64/python2.7/curses/ascii.pytisalnum6R!cCst|pt|S(N(tisuppertislower(R$((s$/usr/lib64/python2.7/curses/ascii.pyR&7R!cCsdt|kodkSS(Nii(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisascii8R!cCst|dkS(Ni i (i i (R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisblank9R!cCs2dt|kodknp1t|dkS(Niii(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytiscntrl:R!cCsdt|kodkSS(Ni0i9(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pyR';R!cCsdt|kodkSS(Ni!i~(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisgraph<R!cCsdt|kodkSS(Niaiz(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pyR*=R!cCsdt|kodkSS(Ni i~(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisprint>R!cCst|ot| S(N(R.R((R$((s$/usr/lib64/python2.7/curses/ascii.pytispunct?R!cCst|dkS(Ni i i i i i (i i i i i i (R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisspace@R!cCsdt|kodkSS(NiAiZ(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pyR)AR!cCsLt|pKdt|ko)dknpKdt|koIdkSS(NiAiFiaif(R'R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisxdigitBs cCsdt|kodkSS(Nii (R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytisctrlDR!cCst|dkS(Ni(R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytismetaER!cCs>t|tdkr,tt|d@St|d@SdS(NR!i(R"tchrR%(R$((s$/usr/lib64/python2.7/curses/ascii.pytasciiGscCs>t|tdkr,tt|d@St|d@SdS(NR!i(R"R5R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytctrlMscCs>t|tdkr,tt|dBSt|dBSdS(NR!i(R"R5R%(R$((s$/usr/lib64/python2.7/curses/ascii.pytaltSscCsvt|}|dkr!d}n?t|d@rDt|d@}ndt|d@dBd}|d@rrd|S|S(Nis^?t^i it!(R%R/R5(R$tbitstrep((s$/usr/lib64/python2.7/curses/ascii.pytunctrlYs    N(:t__doc__RRRRRRRRRtTABR R tNLR R R RRRRRRRRRRRRRRRRRRR tDELt controlnamesR%R(R&R+R,R-R'R.R*R/R0R1R)R2R3R4R6R7R8R=(((s$/usr/lib64/python2.7/curses/ascii.pytsz                    has_key.py000064400000013001147204465610006545 0ustar00 # # Emulation of has_key() function for platforms that don't use ncurses # import _curses # Table mapping curses keys to the terminfo capability name _capability_names = { _curses.KEY_A1: 'ka1', _curses.KEY_A3: 'ka3', _curses.KEY_B2: 'kb2', _curses.KEY_BACKSPACE: 'kbs', _curses.KEY_BEG: 'kbeg', _curses.KEY_BTAB: 'kcbt', _curses.KEY_C1: 'kc1', _curses.KEY_C3: 'kc3', _curses.KEY_CANCEL: 'kcan', _curses.KEY_CATAB: 'ktbc', _curses.KEY_CLEAR: 'kclr', _curses.KEY_CLOSE: 'kclo', _curses.KEY_COMMAND: 'kcmd', _curses.KEY_COPY: 'kcpy', _curses.KEY_CREATE: 'kcrt', _curses.KEY_CTAB: 'kctab', _curses.KEY_DC: 'kdch1', _curses.KEY_DL: 'kdl1', _curses.KEY_DOWN: 'kcud1', _curses.KEY_EIC: 'krmir', _curses.KEY_END: 'kend', _curses.KEY_ENTER: 'kent', _curses.KEY_EOL: 'kel', _curses.KEY_EOS: 'ked', _curses.KEY_EXIT: 'kext', _curses.KEY_F0: 'kf0', _curses.KEY_F1: 'kf1', _curses.KEY_F10: 'kf10', _curses.KEY_F11: 'kf11', _curses.KEY_F12: 'kf12', _curses.KEY_F13: 'kf13', _curses.KEY_F14: 'kf14', _curses.KEY_F15: 'kf15', _curses.KEY_F16: 'kf16', _curses.KEY_F17: 'kf17', _curses.KEY_F18: 'kf18', _curses.KEY_F19: 'kf19', _curses.KEY_F2: 'kf2', _curses.KEY_F20: 'kf20', _curses.KEY_F21: 'kf21', _curses.KEY_F22: 'kf22', _curses.KEY_F23: 'kf23', _curses.KEY_F24: 'kf24', _curses.KEY_F25: 'kf25', _curses.KEY_F26: 'kf26', _curses.KEY_F27: 'kf27', _curses.KEY_F28: 'kf28', _curses.KEY_F29: 'kf29', _curses.KEY_F3: 'kf3', _curses.KEY_F30: 'kf30', _curses.KEY_F31: 'kf31', _curses.KEY_F32: 'kf32', _curses.KEY_F33: 'kf33', _curses.KEY_F34: 'kf34', _curses.KEY_F35: 'kf35', _curses.KEY_F36: 'kf36', _curses.KEY_F37: 'kf37', _curses.KEY_F38: 'kf38', _curses.KEY_F39: 'kf39', _curses.KEY_F4: 'kf4', _curses.KEY_F40: 'kf40', _curses.KEY_F41: 'kf41', _curses.KEY_F42: 'kf42', _curses.KEY_F43: 'kf43', _curses.KEY_F44: 'kf44', _curses.KEY_F45: 'kf45', _curses.KEY_F46: 'kf46', _curses.KEY_F47: 'kf47', _curses.KEY_F48: 'kf48', _curses.KEY_F49: 'kf49', _curses.KEY_F5: 'kf5', _curses.KEY_F50: 'kf50', _curses.KEY_F51: 'kf51', _curses.KEY_F52: 'kf52', _curses.KEY_F53: 'kf53', _curses.KEY_F54: 'kf54', _curses.KEY_F55: 'kf55', _curses.KEY_F56: 'kf56', _curses.KEY_F57: 'kf57', _curses.KEY_F58: 'kf58', _curses.KEY_F59: 'kf59', _curses.KEY_F6: 'kf6', _curses.KEY_F60: 'kf60', _curses.KEY_F61: 'kf61', _curses.KEY_F62: 'kf62', _curses.KEY_F63: 'kf63', _curses.KEY_F7: 'kf7', _curses.KEY_F8: 'kf8', _curses.KEY_F9: 'kf9', _curses.KEY_FIND: 'kfnd', _curses.KEY_HELP: 'khlp', _curses.KEY_HOME: 'khome', _curses.KEY_IC: 'kich1', _curses.KEY_IL: 'kil1', _curses.KEY_LEFT: 'kcub1', _curses.KEY_LL: 'kll', _curses.KEY_MARK: 'kmrk', _curses.KEY_MESSAGE: 'kmsg', _curses.KEY_MOVE: 'kmov', _curses.KEY_NEXT: 'knxt', _curses.KEY_NPAGE: 'knp', _curses.KEY_OPEN: 'kopn', _curses.KEY_OPTIONS: 'kopt', _curses.KEY_PPAGE: 'kpp', _curses.KEY_PREVIOUS: 'kprv', _curses.KEY_PRINT: 'kprt', _curses.KEY_REDO: 'krdo', _curses.KEY_REFERENCE: 'kref', _curses.KEY_REFRESH: 'krfr', _curses.KEY_REPLACE: 'krpl', _curses.KEY_RESTART: 'krst', _curses.KEY_RESUME: 'kres', _curses.KEY_RIGHT: 'kcuf1', _curses.KEY_SAVE: 'ksav', _curses.KEY_SBEG: 'kBEG', _curses.KEY_SCANCEL: 'kCAN', _curses.KEY_SCOMMAND: 'kCMD', _curses.KEY_SCOPY: 'kCPY', _curses.KEY_SCREATE: 'kCRT', _curses.KEY_SDC: 'kDC', _curses.KEY_SDL: 'kDL', _curses.KEY_SELECT: 'kslt', _curses.KEY_SEND: 'kEND', _curses.KEY_SEOL: 'kEOL', _curses.KEY_SEXIT: 'kEXT', _curses.KEY_SF: 'kind', _curses.KEY_SFIND: 'kFND', _curses.KEY_SHELP: 'kHLP', _curses.KEY_SHOME: 'kHOM', _curses.KEY_SIC: 'kIC', _curses.KEY_SLEFT: 'kLFT', _curses.KEY_SMESSAGE: 'kMSG', _curses.KEY_SMOVE: 'kMOV', _curses.KEY_SNEXT: 'kNXT', _curses.KEY_SOPTIONS: 'kOPT', _curses.KEY_SPREVIOUS: 'kPRV', _curses.KEY_SPRINT: 'kPRT', _curses.KEY_SR: 'kri', _curses.KEY_SREDO: 'kRDO', _curses.KEY_SREPLACE: 'kRPL', _curses.KEY_SRIGHT: 'kRIT', _curses.KEY_SRSUME: 'kRES', _curses.KEY_SSAVE: 'kSAV', _curses.KEY_SSUSPEND: 'kSPD', _curses.KEY_STAB: 'khts', _curses.KEY_SUNDO: 'kUND', _curses.KEY_SUSPEND: 'kspd', _curses.KEY_UNDO: 'kund', _curses.KEY_UP: 'kcuu1' } def has_key(ch): if isinstance(ch, str): ch = ord(ch) # Figure out the correct capability name for the keycode. capability_name = _capability_names.get(ch) if capability_name is None: return False #Check the current terminal description for that capability; #if present, return true, else return false. if _curses.tigetstr( capability_name ): return True else: return False if __name__ == '__main__': # Compare the output of this implementation and the ncurses has_key, # on platforms where has_key is already available try: L = [] _curses.initscr() for key in _capability_names.keys(): system = _curses.has_key(key) python = has_key(key) if system != python: L.append( 'Mismatch for key %s, system=%i, Python=%i' % (_curses.keyname( key ), system, python) ) finally: _curses.endwin() for i in L: print i has_key.pyc000064400000013464147204465610006725 0ustar00 |fc@sddlZidej6dej6dej6dej6dej6dej6dej6d ej6d ej 6d ej 6d ej 6d ej 6dej 6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6d ej6d!ej 6d"ej!6d#ej"6d$ej#6d%ej$6d&ej%6d'ej&6d(ej'6d)ej(6d*ej)6d+ej*6d,ej+6d-ej,6d.ej-6d/ej.6d0ej/6d1ej06d2ej16d3ej26d4ej36d5ej46d6ej56d7ej66d8ej76d9ej86d:ej96d;ej:6d<ej;6d=ej<6d>ej=6d?ej>6d@ej?6dAej@6dBejA6dCejB6dDejC6dEejD6dFejE6dGejF6dHejG6dIejH6dJejI6dKejJ6dLejK6dMejL6dNejM6dOejN6dPejO6dQejP6dRejQ6dSejR6dTejS6dUejT6dVejU6dWejV6dXejW6dYejX6dZejY6d[ejZ6d\ej[6d]ej\6d^ej]6d_ej^6d`ej_6daej`6dbeja6dcejb6ddejc6deejd6dfeje6dgejf6dhejg6diejh6djeji6dkejj6dlejk6dmejl6dnejm6doejn6dpejo6dqejp6drejq6dsejr6dtejs6duejt6dveju6dwejv6dxejw6dyejx6dzejy6d{ejz6d|ej{6d}ej|6d~ej}6dej~6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6ZdZedkrzxgZejxaejD]SZejeZeeZeekrejdejeeefqqWWdejxeD] ZeGHqWXndS(iNtka1tka3tkb2tkbstkbegtkcbttkc1tkc3tkcantktbctkclrtkclotkcmdtkcpytkcrttkctabtkdch1tkdl1tkcud1tkrmirtkendtkenttkeltkedtkexttkf0tkf1tkf10tkf11tkf12tkf13tkf14tkf15tkf16tkf17tkf18tkf19tkf2tkf20tkf21tkf22tkf23tkf24tkf25tkf26tkf27tkf28tkf29tkf3tkf30tkf31tkf32tkf33tkf34tkf35tkf36tkf37tkf38tkf39tkf4tkf40tkf41tkf42tkf43tkf44tkf45tkf46tkf47tkf48tkf49tkf5tkf50tkf51tkf52tkf53tkf54tkf55tkf56tkf57tkf58tkf59tkf6tkf60tkf61tkf62tkf63tkf7tkf8tkf9tkfndtkhlptkhometkich1tkil1tkcub1tklltkmrktkmsgtkmovtknxttknptkopntkopttkpptkprvtkprttkrdotkreftkrfrtkrpltkrsttkrestkcuf1tksavtkBEGtkCANtkCMDtkCPYtkCRTtkDCtkDLtkslttkENDtkEOLtkEXTtkindtkFNDtkHLPtkHOMtkICtkLFTtkMSGtkMOVtkNXTtkOPTtkPRVtkPRTtkritkRDOtkRPLtkRITtkREStkSAVtkSPDtkhtstkUNDtkspdtkundtkcuu1cCsXt|trt|}ntj|}|dkr=tStj|rPt StSdS(N( t isinstancetstrtordt_capability_namestgettNonetFalset_cursesttigetstrtTrue(tchtcapability_name((s&/usr/lib64/python2.7/curses/has_key.pythas_keys t__main__s)Mismatch for key %s, system=%i, Python=%i(RtKEY_A1tKEY_A3tKEY_B2t KEY_BACKSPACEtKEY_BEGtKEY_BTABtKEY_C1tKEY_C3t KEY_CANCELt KEY_CATABt KEY_CLEARt KEY_CLOSEt KEY_COMMANDtKEY_COPYt KEY_CREATEtKEY_CTABtKEY_DCtKEY_DLtKEY_DOWNtKEY_EICtKEY_ENDt KEY_ENTERtKEY_EOLtKEY_EOStKEY_EXITtKEY_F0tKEY_F1tKEY_F10tKEY_F11tKEY_F12tKEY_F13tKEY_F14tKEY_F15tKEY_F16tKEY_F17tKEY_F18tKEY_F19tKEY_F2tKEY_F20tKEY_F21tKEY_F22tKEY_F23tKEY_F24tKEY_F25tKEY_F26tKEY_F27tKEY_F28tKEY_F29tKEY_F3tKEY_F30tKEY_F31tKEY_F32tKEY_F33tKEY_F34tKEY_F35tKEY_F36tKEY_F37tKEY_F38tKEY_F39tKEY_F4tKEY_F40tKEY_F41tKEY_F42tKEY_F43tKEY_F44tKEY_F45tKEY_F46tKEY_F47tKEY_F48tKEY_F49tKEY_F5tKEY_F50tKEY_F51tKEY_F52tKEY_F53tKEY_F54tKEY_F55tKEY_F56tKEY_F57tKEY_F58tKEY_F59tKEY_F6tKEY_F60tKEY_F61tKEY_F62tKEY_F63tKEY_F7tKEY_F8tKEY_F9tKEY_FINDtKEY_HELPtKEY_HOMEtKEY_ICtKEY_ILtKEY_LEFTtKEY_LLtKEY_MARKt KEY_MESSAGEtKEY_MOVEtKEY_NEXTt KEY_NPAGEtKEY_OPENt KEY_OPTIONSt KEY_PPAGEt KEY_PREVIOUSt KEY_PRINTtKEY_REDOt KEY_REFERENCEt KEY_REFRESHt KEY_REPLACEt KEY_RESTARTt KEY_RESUMEt KEY_RIGHTtKEY_SAVEtKEY_SBEGt KEY_SCANCELt KEY_SCOMMANDt KEY_SCOPYt KEY_SCREATEtKEY_SDCtKEY_SDLt KEY_SELECTtKEY_SENDtKEY_SEOLt KEY_SEXITtKEY_SFt KEY_SFINDt KEY_SHELPt KEY_SHOMEtKEY_SICt KEY_SLEFTt KEY_SMESSAGEt KEY_SMOVEt KEY_SNEXTt KEY_SOPTIONSt KEY_SPREVIOUSt KEY_SPRINTtKEY_SRt KEY_SREDOt KEY_SREPLACEt KEY_SRIGHTt KEY_SRSUMEt KEY_SSAVEt KEY_SSUSPENDtKEY_STABt KEY_SUNDOt KEY_SUSPENDtKEY_UNDOtKEY_UPRRt__name__tLtinitscrtkeystkeytsystemtpythontappendtkeynametendwinti(((s&/usr/lib64/python2.7/curses/has_key.pytsH                                                                                                                                                            %  has_key.pyo000064400000013464147204465610006741 0ustar00 |fc@sddlZidej6dej6dej6dej6dej6dej6dej6d ej6d ej 6d ej 6d ej 6d ej 6dej 6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6d ej6d!ej 6d"ej!6d#ej"6d$ej#6d%ej$6d&ej%6d'ej&6d(ej'6d)ej(6d*ej)6d+ej*6d,ej+6d-ej,6d.ej-6d/ej.6d0ej/6d1ej06d2ej16d3ej26d4ej36d5ej46d6ej56d7ej66d8ej76d9ej86d:ej96d;ej:6d<ej;6d=ej<6d>ej=6d?ej>6d@ej?6dAej@6dBejA6dCejB6dDejC6dEejD6dFejE6dGejF6dHejG6dIejH6dJejI6dKejJ6dLejK6dMejL6dNejM6dOejN6dPejO6dQejP6dRejQ6dSejR6dTejS6dUejT6dVejU6dWejV6dXejW6dYejX6dZejY6d[ejZ6d\ej[6d]ej\6d^ej]6d_ej^6d`ej_6daej`6dbeja6dcejb6ddejc6deejd6dfeje6dgejf6dhejg6diejh6djeji6dkejj6dlejk6dmejl6dnejm6doejn6dpejo6dqejp6drejq6dsejr6dtejs6duejt6dveju6dwejv6dxejw6dyejx6dzejy6d{ejz6d|ej{6d}ej|6d~ej}6dej~6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6dej6ZdZedkrzxgZejxaejD]SZejeZeeZeekrejdejeeefqqWWdejxeD] ZeGHqWXndS(iNtka1tka3tkb2tkbstkbegtkcbttkc1tkc3tkcantktbctkclrtkclotkcmdtkcpytkcrttkctabtkdch1tkdl1tkcud1tkrmirtkendtkenttkeltkedtkexttkf0tkf1tkf10tkf11tkf12tkf13tkf14tkf15tkf16tkf17tkf18tkf19tkf2tkf20tkf21tkf22tkf23tkf24tkf25tkf26tkf27tkf28tkf29tkf3tkf30tkf31tkf32tkf33tkf34tkf35tkf36tkf37tkf38tkf39tkf4tkf40tkf41tkf42tkf43tkf44tkf45tkf46tkf47tkf48tkf49tkf5tkf50tkf51tkf52tkf53tkf54tkf55tkf56tkf57tkf58tkf59tkf6tkf60tkf61tkf62tkf63tkf7tkf8tkf9tkfndtkhlptkhometkich1tkil1tkcub1tklltkmrktkmsgtkmovtknxttknptkopntkopttkpptkprvtkprttkrdotkreftkrfrtkrpltkrsttkrestkcuf1tksavtkBEGtkCANtkCMDtkCPYtkCRTtkDCtkDLtkslttkENDtkEOLtkEXTtkindtkFNDtkHLPtkHOMtkICtkLFTtkMSGtkMOVtkNXTtkOPTtkPRVtkPRTtkritkRDOtkRPLtkRITtkREStkSAVtkSPDtkhtstkUNDtkspdtkundtkcuu1cCsXt|trt|}ntj|}|dkr=tStj|rPt StSdS(N( t isinstancetstrtordt_capability_namestgettNonetFalset_cursesttigetstrtTrue(tchtcapability_name((s&/usr/lib64/python2.7/curses/has_key.pythas_keys t__main__s)Mismatch for key %s, system=%i, Python=%i(RtKEY_A1tKEY_A3tKEY_B2t KEY_BACKSPACEtKEY_BEGtKEY_BTABtKEY_C1tKEY_C3t KEY_CANCELt KEY_CATABt KEY_CLEARt KEY_CLOSEt KEY_COMMANDtKEY_COPYt KEY_CREATEtKEY_CTABtKEY_DCtKEY_DLtKEY_DOWNtKEY_EICtKEY_ENDt KEY_ENTERtKEY_EOLtKEY_EOStKEY_EXITtKEY_F0tKEY_F1tKEY_F10tKEY_F11tKEY_F12tKEY_F13tKEY_F14tKEY_F15tKEY_F16tKEY_F17tKEY_F18tKEY_F19tKEY_F2tKEY_F20tKEY_F21tKEY_F22tKEY_F23tKEY_F24tKEY_F25tKEY_F26tKEY_F27tKEY_F28tKEY_F29tKEY_F3tKEY_F30tKEY_F31tKEY_F32tKEY_F33tKEY_F34tKEY_F35tKEY_F36tKEY_F37tKEY_F38tKEY_F39tKEY_F4tKEY_F40tKEY_F41tKEY_F42tKEY_F43tKEY_F44tKEY_F45tKEY_F46tKEY_F47tKEY_F48tKEY_F49tKEY_F5tKEY_F50tKEY_F51tKEY_F52tKEY_F53tKEY_F54tKEY_F55tKEY_F56tKEY_F57tKEY_F58tKEY_F59tKEY_F6tKEY_F60tKEY_F61tKEY_F62tKEY_F63tKEY_F7tKEY_F8tKEY_F9tKEY_FINDtKEY_HELPtKEY_HOMEtKEY_ICtKEY_ILtKEY_LEFTtKEY_LLtKEY_MARKt KEY_MESSAGEtKEY_MOVEtKEY_NEXTt KEY_NPAGEtKEY_OPENt KEY_OPTIONSt KEY_PPAGEt KEY_PREVIOUSt KEY_PRINTtKEY_REDOt KEY_REFERENCEt KEY_REFRESHt KEY_REPLACEt KEY_RESTARTt KEY_RESUMEt KEY_RIGHTtKEY_SAVEtKEY_SBEGt KEY_SCANCELt KEY_SCOMMANDt KEY_SCOPYt KEY_SCREATEtKEY_SDCtKEY_SDLt KEY_SELECTtKEY_SENDtKEY_SEOLt KEY_SEXITtKEY_SFt KEY_SFINDt KEY_SHELPt KEY_SHOMEtKEY_SICt KEY_SLEFTt KEY_SMESSAGEt KEY_SMOVEt KEY_SNEXTt KEY_SOPTIONSt KEY_SPREVIOUSt KEY_SPRINTtKEY_SRt KEY_SREDOt KEY_SREPLACEt KEY_SRIGHTt KEY_SRSUMEt KEY_SSAVEt KEY_SSUSPENDtKEY_STABt KEY_SUNDOt KEY_SUSPENDtKEY_UNDOtKEY_UPRRt__name__tLtinitscrtkeystkeytsystemtpythontappendtkeynametendwinti(((s&/usr/lib64/python2.7/curses/has_key.pytsH                                                                                                                                                            %  panel.py000064400000000156147204465610006230 0ustar00"""curses.panel Module for using panels with curses. """ __revision__ = "$Id$" from _curses_panel import * panel.pyc000064400000000425147204465610006372 0ustar00 |fc@sdZdZddlTdS(s3curses.panel Module for using panels with curses. s$Id$i(t*N(t__doc__t __revision__t _curses_panel(((s$/usr/lib64/python2.7/curses/panel.pytspanel.pyo000064400000000425147204465610006406 0ustar00 |fc@sdZdZddlTdS(s3curses.panel Module for using panels with curses. s$Id$i(t*N(t__doc__t __revision__t _curses_panel(((s$/usr/lib64/python2.7/curses/panel.pytstextpad.py000064400000016750147204465610006611 0ustar00"""Simple textbox editing widget with Emacs-like keybindings.""" import curses import curses.ascii def rectangle(win, uly, ulx, lry, lrx): """Draw a rectangle with corners at the provided upper-left and lower-right coordinates. """ win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER) win.addch(uly, lrx, curses.ACS_URCORNER) win.addch(lry, lrx, curses.ACS_LRCORNER) win.addch(lry, ulx, curses.ACS_LLCORNER) class Textbox: """Editing widget using the interior of a window object. Supports the following Emacs-like key bindings: Ctrl-A Go to left edge of window. Ctrl-B Cursor left, wrapping to previous line if appropriate. Ctrl-D Delete character under cursor. Ctrl-E Go to right edge (stripspaces off) or end of line (stripspaces on). Ctrl-F Cursor right, wrapping to next line when appropriate. Ctrl-G Terminate, returning the window contents. Ctrl-H Delete character backward. Ctrl-J Terminate if the window is 1 line, otherwise insert newline. Ctrl-K If line is blank, delete it, otherwise clear to end of line. Ctrl-L Refresh screen. Ctrl-N Cursor down; move down one line. Ctrl-O Insert a blank line at cursor location. Ctrl-P Cursor up; move up one line. Move operations do nothing if the cursor is at an edge where the movement is not possible. The following synonyms are supported where possible: KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N KEY_BACKSPACE = Ctrl-h """ def __init__(self, win, insert_mode=False): self.win = win self.insert_mode = insert_mode self._update_max_yx() self.stripspaces = 1 self.lastcmd = None win.keypad(1) def _update_max_yx(self): maxy, maxx = self.win.getmaxyx() self.maxy = maxy - 1 self.maxx = maxx - 1 def _end_of_line(self, y): """Go to the location of the first blank on the given line, returning the index of the last non-blank character.""" self._update_max_yx() last = self.maxx while True: if curses.ascii.ascii(self.win.inch(y, last)) != curses.ascii.SP: last = min(self.maxx, last+1) break elif last == 0: break last = last - 1 return last def _insert_printable_char(self, ch): self._update_max_yx() (y, x) = self.win.getyx() backyx = None while y < self.maxy or x < self.maxx: if self.insert_mode: oldch = self.win.inch() # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the window. try: self.win.addch(ch) except curses.error: pass if not self.insert_mode or not curses.ascii.isprint(oldch): break ch = oldch (y, x) = self.win.getyx() # Remember where to put the cursor back since we are in insert_mode if backyx is None: backyx = y, x if backyx is not None: self.win.move(*backyx) def do_command(self, ch): "Process a single editing command." self._update_max_yx() (y, x) = self.win.getyx() self.lastcmd = ch if curses.ascii.isprint(ch): if y < self.maxy or x < self.maxx: self._insert_printable_char(ch) elif ch == curses.ascii.SOH: # ^a self.win.move(y, 0) elif ch in (curses.ascii.STX,curses.KEY_LEFT, curses.ascii.BS,curses.KEY_BACKSPACE): if x > 0: self.win.move(y, x-1) elif y == 0: pass elif self.stripspaces: self.win.move(y-1, self._end_of_line(y-1)) else: self.win.move(y-1, self.maxx) if ch in (curses.ascii.BS, curses.KEY_BACKSPACE): self.win.delch() elif ch == curses.ascii.EOT: # ^d self.win.delch() elif ch == curses.ascii.ENQ: # ^e if self.stripspaces: self.win.move(y, self._end_of_line(y)) else: self.win.move(y, self.maxx) elif ch in (curses.ascii.ACK, curses.KEY_RIGHT): # ^f if x < self.maxx: self.win.move(y, x+1) elif y == self.maxy: pass else: self.win.move(y+1, 0) elif ch == curses.ascii.BEL: # ^g return 0 elif ch == curses.ascii.NL: # ^j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) elif ch == curses.ascii.VT: # ^k if x == 0 and self._end_of_line(y) == 0: self.win.deleteln() else: # first undo the effect of self._end_of_line self.win.move(y, x) self.win.clrtoeol() elif ch == curses.ascii.FF: # ^l self.win.refresh() elif ch in (curses.ascii.SO, curses.KEY_DOWN): # ^n if y < self.maxy: self.win.move(y+1, x) if x > self._end_of_line(y+1): self.win.move(y+1, self._end_of_line(y+1)) elif ch == curses.ascii.SI: # ^o self.win.insertln() elif ch in (curses.ascii.DLE, curses.KEY_UP): # ^p if y > 0: self.win.move(y-1, x) if x > self._end_of_line(y-1): self.win.move(y-1, self._end_of_line(y-1)) return 1 def gather(self): "Collect and return the contents of the window." result = "" self._update_max_yx() for y in range(self.maxy+1): self.win.move(y, 0) stop = self._end_of_line(y) if stop == 0 and self.stripspaces: continue for x in range(self.maxx+1): if self.stripspaces and x > stop: break result = result + chr(curses.ascii.ascii(self.win.inch(y, x))) if self.maxy > 0: result = result + "\n" return result def edit(self, validate=None): "Edit in the widget window and collect the results." while 1: ch = self.win.getch() if validate: ch = validate(ch) if not ch: continue if not self.do_command(ch): break self.win.refresh() return self.gather() if __name__ == '__main__': def test_editbox(stdscr): ncols, nlines = 9, 4 uly, ulx = 15, 20 stdscr.addstr(uly-2, ulx, "Use Ctrl-G to end editing.") win = curses.newwin(nlines, ncols, uly, ulx) rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols) stdscr.refresh() return Textbox(win).edit() str = curses.wrapper(test_editbox) print 'Contents of text box:', repr(str) textpad.pyc000064400000015757147204465610006762 0ustar00 |fc@stdZddlZddlZdZdd dYZedkrpdZejeZdGe eGHndS( s:Simple textbox editing widget with Emacs-like keybindings.iNcCs|j|d|tj||d|j||dtj||d|j||dtj||d|j|d|tj||d|j||tj|j||tj|j||tj|j||tj dS(s^Draw a rectangle with corners at the provided upper-left and lower-right coordinates. iN( tvlinetcursest ACS_VLINEthlinet ACS_HLINEtaddcht ACS_ULCORNERt ACS_URCORNERt ACS_LRCORNERt ACS_LLCORNER(twintulytulxtlrytlrx((s&/usr/lib64/python2.7/curses/textpad.pyt rectangles%%%%tTextboxcBsSeZdZedZdZdZdZdZdZ ddZ RS( sdEditing widget using the interior of a window object. Supports the following Emacs-like key bindings: Ctrl-A Go to left edge of window. Ctrl-B Cursor left, wrapping to previous line if appropriate. Ctrl-D Delete character under cursor. Ctrl-E Go to right edge (stripspaces off) or end of line (stripspaces on). Ctrl-F Cursor right, wrapping to next line when appropriate. Ctrl-G Terminate, returning the window contents. Ctrl-H Delete character backward. Ctrl-J Terminate if the window is 1 line, otherwise insert newline. Ctrl-K If line is blank, delete it, otherwise clear to end of line. Ctrl-L Refresh screen. Ctrl-N Cursor down; move down one line. Ctrl-O Insert a blank line at cursor location. Ctrl-P Cursor up; move up one line. Move operations do nothing if the cursor is at an edge where the movement is not possible. The following synonyms are supported where possible: KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N KEY_BACKSPACE = Ctrl-h cCs?||_||_|jd|_d|_|jddS(Ni(R t insert_modet_update_max_yxt stripspacestNonetlastcmdtkeypad(tselfR R((s&/usr/lib64/python2.7/curses/textpad.pyt__init__+s      cCs3|jj\}}|d|_|d|_dS(Ni(R tgetmaxyxtmaxytmaxx(RRR((s&/usr/lib64/python2.7/curses/textpad.pyR3s cCs|j|j}xktrtjj|jj||tjjkrct|j|d}Pn|dkrsPn|d}qW|S(suGo to the location of the first blank on the given line, returning the index of the last non-blank character.ii( RRtTrueRtasciiR tinchtSPtmin(Rtytlast((s&/usr/lib64/python2.7/curses/textpad.pyt _end_of_line8s   - cCs |j|jj\}}d}x||jksF||jkr|jra|jj}ny|jj|Wnt j k rnX|j st j j | rPn|}|jj\}}|dkr(||f}q(q(W|dk r|jj |ndS(N(RR tgetyxRRRRRRRterrorRtisprinttmove(RtchR!txtbackyxtoldch((s&/usr/lib64/python2.7/curses/textpad.pyt_insert_printable_charFs$ !   cCso|j|jj\}}||_tjj|rk||jksX||jkrk|j |qkn|tjj kr|jj |dn|tjj tj tjjtjfkrj|dkr|jj ||dnY|dkrnJ|jr"|jj |d|j|dn|jj |d|j|tjjtjfkrk|jjqkn|tjjkr|jjn|tjjkr|jr|jj ||j|qk|jj ||jn|tjjtjfkrO||jkr#|jj ||dqk||jkr5qk|jj |ddn|tjjkredS|tjjkr|jdkrdS||jkrk|jj |ddqkn|tjjkr|dkr|j|dkr|jjqk|jj |||jjnO|tjjkr>|jjn-|tjjtjfkr||jkrk|jj |d|||j|dkr|jj |d|j|dqqkn|tjj kr|jj!n|tjj"tj#fkrk|dkrk|jj |d|||j|dkrh|jj |d|j|dqhqkndS(s!Process a single editing command.ii($RR R$RRRR&RRR,tSOHR'tSTXtKEY_LEFTtBSt KEY_BACKSPACERR#tdelchtEOTtENQtACKt KEY_RIGHTtBELtNLtVTtdeletelntclrtoeoltFFtrefreshtSOtKEY_DOWNtSItinsertlntDLEtKEY_UP(RR(R!R)((s&/usr/lib64/python2.7/curses/textpad.pyt do_command_sr  *   ' !- -cCsd}|jxt|jdD]}|jj|d|j|}|dkrg|jrgq$nx_t|jdD]J}|jr||krPn|tt j j |jj ||}q{W|jdkr$|d}q$q$W|S(s.Collect and return the contents of the window.tiis ( RtrangeRR R'R#RRtchrRRR(RtresultR!tstopR)((s&/usr/lib64/python2.7/curses/textpad.pytgathers /cCsaxT|jj}|r'||}n|s3qn|j|sFPn|jjqW|jS(s2Edit in the widget window and collect the results.(R tgetchRDR=RJ(RtvalidateR(((s&/usr/lib64/python2.7/curses/textpad.pyteditsN( t__name__t __module__t__doc__tFalseRRR#R,RDRJRRM(((s&/usr/lib64/python2.7/curses/textpad.pyRs     A t__main__cCsd\}}d \}}|j|d|dtj||||}t||d|d|||||jt|jS( Ni iiiisUse Ctrl-G to end editing.i(i i(ii(taddstrRtnewwinRR=RRM(tstdscrtncolstnlinesR R R ((s&/usr/lib64/python2.7/curses/textpad.pyt test_editboxs  & sContents of text box:(( RPRt curses.asciiRRRNRXtwrappertstrtrepr(((s&/usr/lib64/python2.7/curses/textpad.pyts     textpad.pyo000064400000015757147204465610006776 0ustar00 |fc@stdZddlZddlZdZdd dYZedkrpdZejeZdGe eGHndS( s:Simple textbox editing widget with Emacs-like keybindings.iNcCs|j|d|tj||d|j||dtj||d|j||dtj||d|j|d|tj||d|j||tj|j||tj|j||tj|j||tj dS(s^Draw a rectangle with corners at the provided upper-left and lower-right coordinates. iN( tvlinetcursest ACS_VLINEthlinet ACS_HLINEtaddcht ACS_ULCORNERt ACS_URCORNERt ACS_LRCORNERt ACS_LLCORNER(twintulytulxtlrytlrx((s&/usr/lib64/python2.7/curses/textpad.pyt rectangles%%%%tTextboxcBsSeZdZedZdZdZdZdZdZ ddZ RS( sdEditing widget using the interior of a window object. Supports the following Emacs-like key bindings: Ctrl-A Go to left edge of window. Ctrl-B Cursor left, wrapping to previous line if appropriate. Ctrl-D Delete character under cursor. Ctrl-E Go to right edge (stripspaces off) or end of line (stripspaces on). Ctrl-F Cursor right, wrapping to next line when appropriate. Ctrl-G Terminate, returning the window contents. Ctrl-H Delete character backward. Ctrl-J Terminate if the window is 1 line, otherwise insert newline. Ctrl-K If line is blank, delete it, otherwise clear to end of line. Ctrl-L Refresh screen. Ctrl-N Cursor down; move down one line. Ctrl-O Insert a blank line at cursor location. Ctrl-P Cursor up; move up one line. Move operations do nothing if the cursor is at an edge where the movement is not possible. The following synonyms are supported where possible: KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N KEY_BACKSPACE = Ctrl-h cCs?||_||_|jd|_d|_|jddS(Ni(R t insert_modet_update_max_yxt stripspacestNonetlastcmdtkeypad(tselfR R((s&/usr/lib64/python2.7/curses/textpad.pyt__init__+s      cCs3|jj\}}|d|_|d|_dS(Ni(R tgetmaxyxtmaxytmaxx(RRR((s&/usr/lib64/python2.7/curses/textpad.pyR3s cCs|j|j}xktrtjj|jj||tjjkrct|j|d}Pn|dkrsPn|d}qW|S(suGo to the location of the first blank on the given line, returning the index of the last non-blank character.ii( RRtTrueRtasciiR tinchtSPtmin(Rtytlast((s&/usr/lib64/python2.7/curses/textpad.pyt _end_of_line8s   - cCs |j|jj\}}d}x||jksF||jkr|jra|jj}ny|jj|Wnt j k rnX|j st j j | rPn|}|jj\}}|dkr(||f}q(q(W|dk r|jj |ndS(N(RR tgetyxRRRRRRRterrorRtisprinttmove(RtchR!txtbackyxtoldch((s&/usr/lib64/python2.7/curses/textpad.pyt_insert_printable_charFs$ !   cCso|j|jj\}}||_tjj|rk||jksX||jkrk|j |qkn|tjj kr|jj |dn|tjj tj tjjtjfkrj|dkr|jj ||dnY|dkrnJ|jr"|jj |d|j|dn|jj |d|j|tjjtjfkrk|jjqkn|tjjkr|jjn|tjjkr|jr|jj ||j|qk|jj ||jn|tjjtjfkrO||jkr#|jj ||dqk||jkr5qk|jj |ddn|tjjkredS|tjjkr|jdkrdS||jkrk|jj |ddqkn|tjjkr|dkr|j|dkr|jjqk|jj |||jjnO|tjjkr>|jjn-|tjjtjfkr||jkrk|jj |d|||j|dkr|jj |d|j|dqqkn|tjj kr|jj!n|tjj"tj#fkrk|dkrk|jj |d|||j|dkrh|jj |d|j|dqhqkndS(s!Process a single editing command.ii($RR R$RRRR&RRR,tSOHR'tSTXtKEY_LEFTtBSt KEY_BACKSPACERR#tdelchtEOTtENQtACKt KEY_RIGHTtBELtNLtVTtdeletelntclrtoeoltFFtrefreshtSOtKEY_DOWNtSItinsertlntDLEtKEY_UP(RR(R!R)((s&/usr/lib64/python2.7/curses/textpad.pyt do_command_sr  *   ' !- -cCsd}|jxt|jdD]}|jj|d|j|}|dkrg|jrgq$nx_t|jdD]J}|jr||krPn|tt j j |jj ||}q{W|jdkr$|d}q$q$W|S(s.Collect and return the contents of the window.tiis ( RtrangeRR R'R#RRtchrRRR(RtresultR!tstopR)((s&/usr/lib64/python2.7/curses/textpad.pytgathers /cCsaxT|jj}|r'||}n|s3qn|j|sFPn|jjqW|jS(s2Edit in the widget window and collect the results.(R tgetchRDR=RJ(RtvalidateR(((s&/usr/lib64/python2.7/curses/textpad.pyteditsN( t__name__t __module__t__doc__tFalseRRR#R,RDRJRRM(((s&/usr/lib64/python2.7/curses/textpad.pyRs     A t__main__cCsd\}}d \}}|j|d|dtj||||}t||d|d|||||jt|jS( Ni iiiisUse Ctrl-G to end editing.i(i i(ii(taddstrRtnewwinRR=RRM(tstdscrtncolstnlinesR R R ((s&/usr/lib64/python2.7/curses/textpad.pyt test_editboxs  & sContents of text box:(( RPRt curses.asciiRRRNRXtwrappertstrtrepr(((s&/usr/lib64/python2.7/curses/textpad.pyts     wrapper.py000064400000003221147204465610006605 0ustar00"""curses.wrapper Contains one function, wrapper(), which runs another function which should be the rest of your curses-based application. If the application raises an exception, wrapper() will restore the terminal to a sane state so you can read the resulting traceback. """ import curses def wrapper(func, *args, **kwds): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). """ try: # Initialize curses stdscr = curses.initscr() # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input curses.noecho() curses.cbreak() # In keypad mode, escape sequences for special keys # (like the cursor keys) will be interpreted and # a special value like curses.KEY_LEFT will be returned stdscr.keypad(1) # Start color, too. Harmless if the terminal doesn't have # color; user can test with has_color() later on. The try/catch # works around a minor bit of over-conscientiousness in the curses # module -- the error return from C start_color() is ignorable. try: curses.start_color() except: pass return func(stdscr, *args, **kwds) finally: # Set everything back to normal if 'stdscr' in locals(): stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin() wrapper.pyc000064400000002302147204465610006747 0ustar00 |fc@sdZddlZdZdS(scurses.wrapper Contains one function, wrapper(), which runs another function which should be the rest of your curses-based application. If the application raises an exception, wrapper() will restore the terminal to a sane state so you can read the resulting traceback. iNcOszYtj}tjtj|jdytjWnnX||||SWddtkr|jdtjtjtj nXdS(sWrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). iNtstdscri( tcursestinitscrtnoechotcbreaktkeypadt start_colortlocalstechotnocbreaktendwin(tfunctargstkwdsR((s&/usr/lib64/python2.7/curses/wrapper.pytwrapper s       (t__doc__RR(((s&/usr/lib64/python2.7/curses/wrapper.pyts wrapper.pyo000064400000002302147204465610006763 0ustar00 |fc@sdZddlZdZdS(scurses.wrapper Contains one function, wrapper(), which runs another function which should be the rest of your curses-based application. If the application raises an exception, wrapper() will restore the terminal to a sane state so you can read the resulting traceback. iNcOszYtj}tjtj|jdytjWnnX||||SWddtkr|jdtjtjtj nXdS(sWrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). iNtstdscri( tcursestinitscrtnoechotcbreaktkeypadt start_colortlocalstechotnocbreaktendwin(tfunctargstkwdsR((s&/usr/lib64/python2.7/curses/wrapper.pytwrapper s       (t__doc__RR(((s&/usr/lib64/python2.7/curses/wrapper.pyts