ó o©¿Uc@shddlZddlZddlmZddlmZmZddlmZdefd„ƒYZ dS(iÿÿÿÿN(tTextbox(tisprinttctrl(t InnerWindowt InputWindowcBs\eZdZd ded d d„Zd„Zd„Zd„Zd„Z d„Z d„Z RS( sóInputWindow represent editable text areas on the screen At any time, the text of the object can be accessed by referencing an InputWindow's 'text' parameter (edit_field.text). Note that this returns a list of character codes. tc Cs±|dkr|j}n|j}|j}d|_tt|ƒj||||||ƒ||_t dƒ|_ d|_ t |j ƒ|_t|j_|j|ƒg|_dS(süUnlike InnerWindow, this constructor WILL NOT TAKE curses.window objects for the window parameter - they must be InnerWindows. In general, specifying a specific color_theme is unnecessary, unless this instance requires a theme other than that of the rest of the program window (required): A parent InnerWindow area (required): Describes the area within the parent window to be used. area.lines is overridden to 1. text (optional): The text in this field, before it is edited by the user. Defaults to empty string. masked (optional): If True, then this field will display bullets when the user types into it, instead of echo'ing the text color_theme (optional): The color_theme for this edit field. By default the parent window's theme is used. color_theme.edit_field is used as the background color; color_theme.highlight_edit is the background when this InputWindow is active. it*iN(tNonet color_themet edit_fieldthighlight_edittlinestsuperRt__init__tmaskedtordt masked_chartold_cursor_stateRtwindowttextboxtTruet stripspacestset_textt text_buff( tselftareaRttextRRtat_indextcolorthighlight_color((sinput_window.pyR )s          cCsGg|_x-|D]%}|jj|jt|ƒƒƒqW|jƒdS(N(RRt do_commandt handle_inputRt no_ut_refresh(RRtchar((sinput_window.pyRUs  #cCsg|_|jjttdƒƒƒ|jjttdƒƒƒx-|D]%}|jj|jt|ƒƒƒqHW|jƒdS(Ntatk(RRRRRRR (RRR!((sinput_window.pytset_repo[s   #cCs´|j|ƒ}|ttjtjƒksH|tjksH|tjkrntjdƒ||_ t t dƒƒSd|_ t |ƒrT|jjt|ƒƒ|jj|ƒ|jƒs<t|jƒdkr<|jjƒt|jƒ}|j|d }|j|j|dƒt|jƒ}||j|d|_q<n|jr°|j}q°n\|tjks{|t t dƒƒkr°t|jƒdkr°|jjƒ|jjƒq°n|S(NsGot special key, breakingtgii1tH(ttranslate_inputtrangetcursestKEY_F0tKEY_F10tKEY_UPtKEY_DOWNtloggingtdebugtinputRRRRRtappendtchrRtis_validtlentpopR$RRt KEY_BACKSPACE(RR0tlengtht temp_buff((sinput_window.pyRcs2       ' cCsìytjdƒ|_Wn!tjk r9tjdƒnXytj|ƒWntk r^nX|jj t t dƒƒƒ|jj |j ƒytj|jƒ|_Wn!tjk rÊtjdƒnXtjdt|jƒƒ|jS(Nis%Got curses.error when enabling cursortes&Got curses.error when reverting cursors Returning: (R)tcurs_setRterrorR.R/tungetcht TypeErrorRRRRteditRtstrR0(RR0((sinput_window.pytprocess€s  cCs6|ttjtjƒks*||jkr.tStSdS(s•Check to see if this is a keystroke that should break us out of adding input to the Textbox and return control to the parent window N(R(R)R*R+tkey_dictRtFalse(Rt input_key((sinput_window.pytis_special_char–scCs&|jjƒd}t|jƒ|kS(Ni(RtgetmaxyxR4R(Rt win_size_x((sinput_window.pyR3¡sN( t__name__t __module__t__doc__RRBR RR$RR@RDR3(((sinput_window.pyR!s +     ( R.R)tcurses.textpadRt curses.asciiRRt inner_windowRR(((sinput_window.pyts