3 \éã@sRddlZddlZdd„ZGdd„dƒZedkrNdd„ZejeƒZed e eƒƒdS) éNcCs¼|j|d|tj||dƒ|j||dtj||dƒ|j||dtj||dƒ|j|d|tj||dƒ|j||tjƒ|j||tjƒ|j||tjƒ|j||tj ƒdS)Né) ZvlineÚcursesZ ACS_VLINEZhlineZ ACS_HLINEÚaddchZ ACS_ULCORNERZ ACS_URCORNERZ ACS_LRCORNERZ ACS_LLCORNER)ÚwinÚulyÚulxZlryZlrx©rú&/usr/lib64/python3.6/curses/textpad.pyÚ rectanglesr c@sHeZdZddd„Zdd„Zdd„Zdd „Zd d „Zd d „Zddd„Z dS)ÚTextboxFcCs.||_||_|jƒd|_d|_|jdƒdS)Nr)rÚ insert_modeÚ_update_max_yxÚ stripspacesÚlastcmdZkeypad)Úselfrr rrr Ú__init__+s zTextbox.__init__cCs&|jjƒ\}}|d|_|d|_dS)Nr)rZgetmaxyxÚmaxyÚmaxx)rrrrrr r 3s zTextbox._update_max_yxcCs\|jƒ|j}xHtjj|jj||ƒƒtjjkrBt|j|dƒ}Pn |dkrLP|d}qW|S)Nrr)r rrÚasciirÚinchZSPÚmin)rÚyZlastrrr Ú _end_of_line8s zTextbox._end_of_linec Cs¾|jƒ|jjƒ\}}d}xŠ||jks0||jkr¤|jr@|jjƒ}y|jj|ƒWntj k rfYnX|j s~tj j |ƒ r€P|}|jjƒ\}}|dkr||f}qW|dk rº|jj |ŽdS)N) r rÚgetyxrrr rrrÚerrorrÚisprintÚmove)rÚchrÚxZbackyxZoldchrrr Ú_insert_printable_charFs$  zTextbox._insert_printable_charcCsV|jƒ|jjƒ\}}||_tjj|ƒrJ||jks<||jkrF|j |ƒn|tjj krh|jj |dƒnê|tjj tj tjjtjfkr|dkr¢|jj ||dƒnB|dkr¬n8|jrÐ|jj |d|j|dƒƒn|jj |d|jƒ|tjjtjfkrR|jjƒnL|tjjkr"|jjƒn0|tjjkrb|jrN|jj ||j|ƒƒn|jj ||jƒnð|tjjtjfkrº||jkr–|jj ||dƒn ||jkr¤n|jj |ddƒn˜|tjjkrÌdS|tjjkr |jdkrêdS||jkrR|jj |ddƒnF|tjjkrZ|dkr@|j|ƒdkr@|jjƒn|jj ||ƒ|jjƒnø|tjjkrt|jjƒnÞ|tjjtjfkrØ||jkrR|jj |d|ƒ||j|dƒkrR|jj |d|j|dƒƒnz|tjj krò|jj!ƒn`|tjj"tj#fkrR|dkrR|jj |d|ƒ||j|dƒkrR|jj |d|j|dƒƒdS)Nrr)$r rrrrrrrrrZSOHrZSTXZKEY_LEFTZBSZ KEY_BACKSPACErrZdelchZEOTZENQZACKZ KEY_RIGHTZBELÚNLZVTZdeletelnZclrtoeolZFFÚrefreshÚSOZKEY_DOWNZSIZinsertlnZDLEZKEY_UP)rrrrrrr Ú do_command_sr            zTextbox.do_commandcCs¨d}|jƒx–t|jdƒD]„}|jj|dƒ|j|ƒ}|dkrH|jrHqxDt|jdƒD]2}|jrl||krlP|tt j j |jj ||ƒƒƒ}qXW|jdkr|d}qW|S)NÚrrÚ ) r ÚrangerrrrrrÚchrrrr)rÚresultrÚstoprrrr Úgather s "  zTextbox.gatherNcCs@x6|jjƒ}|r||ƒ}|sq|j|ƒs*P|jjƒqW|jƒS)N)rZgetchr#r!r*)rZvalidaterrrr Úedit±s  z Textbox.edit)F)N) Ú__name__Ú __module__Ú __qualname__rr rrr#r*r+rrrr r s Ar Ú__main__cCsfd\}}d \}}|j|d|dƒtj||||ƒ}t||d|d||||ƒ|jƒt|ƒjƒS) Né éééézUse Ctrl-G to end editing.r)r0r1)r2r3)ZaddstrrZnewwinr r!r r+)ZstdscrZncolsZnlinesrrrrrr Ú test_editbox¿s r5zContents of text box:) rZ curses.asciir r r,r5ÚwrapperÚstrÚprintÚreprrrrr Ús ,