ó ur™Vc@sgdZddlZddlZddljZddlmZddlmZdefd„ƒYZdS(sF UI component allowing subwindows that scroll. Similar to InnerWindow iÿÿÿÿN(tLOG_LEVEL_INPUT(t InnerWindowt ScrollWindowcBsueZdZiddidd6fej6ddidd6fej6ddidd6fej6ddidd6fej6Zd „Z d „Z e d „Z d „Z d „Zeee ƒZd„Zd„ZeeeƒZd„Zd„Zddd„Zd„Zddddd„Zd„Zd„Zd„Zd„Zd„Zd„Zde e d„Z de e d„Z!RS(sIA ScrollWindow is an InnerWindow that can scroll Note: When adding objects to this window, remember that the left 2 columns are reserved for the scroll bar. ARROW_DICT entry tuples consist of: (offset to scroll, method to check if at end of scroll region, parameters to pass to scroll method) it at_bottomtlinesiÿÿÿÿtat_toptat_lefttcolumnstat_rightcCs9|jjƒx|jD]}|jƒqW|jƒdS(szMark this ScrollWindow and its children so that they get completely repainted on the next screen update. N(twindowttouchwint more_windowst no_ut_refresh(tselftwin((sscroll_window.pyt redrawwin9s cCsó|jrdtjjd|jƒ|jj|jj|jj|jj |jj ƒ|_|j |_ n!t j |jj|jjƒ|_|jjdƒ|jjdƒ|jjd8_|jj |jj|j_|jj |jj|j_dS(s2Initialize a curses.pad object of appropriate sizes_init_win area = (%s)iiN(tis_padt terminaluitLOGGERtdebugtareaR tsubwinRRty_loctx_loctpadtcursestnewpadtscrollable_linestscrollable_columnstkeypadtleaveokt lower_right_yt lower_right_x(R tparent((sscroll_window.pyt _init_winDs   cKsd|_d|_d|_t|_|j|jkrL|j|j|_n|j|jkrt|j|j|_n|jdk|_ |jdk|_ t t |ƒj ||t|_||_|j|jtj<|j|jtj<|j|jtj<|j|jtj<|rv|j|jd<|j|jd<|j|jtj<|jjtjtttjƒ|jƒƒntƒ|_ d|_!dS(sžScrollWindow Constructor. See also InnerWindow.__init__ area (required) - For ScrollWindows, area.scrollable_lines and area.scrollable_columns indicates the height or width of the scrollable area, respectively. The other parameters indicate the width and size of the visible portion of the window. All other parameters are used as in InnerWindow.__init__ iii i-tN(ii("tbottomtrightt current_linetTruet_redraw_scroll_barRRRRt_use_vert_scroll_bart_use_horiz_scroll_bartsuperRt__init__RRt on_arrow_keytkey_dictRtKEY_UPtKEY_DOWNtKEY_LEFTt KEY_RIGHTt on_letter_keyt KEY_BACKSPACEtupdatetdicttfromkeystmaptordtstringt lowercaset spell_dictt spell_str(R Rtenable_spelldicttkwargs((sscroll_window.pyR,Ws2       cCs||_t|_dS(s–Setter for self.use_vert_scroll_bar. Triggers a redraw of the scroll bar on next call to _update_scroll_bar (called via no_ut_refresh)N(R)R'R((R tuse_vert_scroll_bar((sscroll_window.pytset_use_vert_scroll_bar€s cCs|jS(s#Getter for self.use_vert_scroll_bar(R)(R ((sscroll_window.pytget_use_vert_scroll_bar‡scCs||_t|_dS(s£Setter for self.use_horiz_scroll_bar. Triggers a redraw of the horizontal scroll bar on next call to _update_scroll_bar (called via no_ut_refresh)N(R*R'R((R tuse_horiz_scroll_bar((sscroll_window.pytset_use_horiz_scroll_barŽs cCs|jS(s$Getter for self.use_horiz_scroll_bar(R*(R ((sscroll_window.pytget_use_horiz_scroll_bar•scCs©|jr |jjddtjƒ|jjddtj|jjdƒ|jj|jjdtj|jj |jjƒ|jj|jj ddtjƒn"|jjddt j |jj ƒ|j rœt jjd|jj|jjƒ|jj|jjdtjƒ|jj|jjdtj|jjdƒ|jj|jj|jjtj|jj|jjƒ|jj|jj|jjdtjƒnt|_dS(sInitialize the scroll bariis2_init_scroll_bar scrollablecolumns=%s, columns=%sN(R@R taddchRt ACS_HLINEtvlinet ACS_VLINERRRRt BKGD_CHARRCRRRRRthlinetFalseR((R ((sscroll_window.pyt_init_scroll_barœs, &       cCsë|jr&tjjdƒ|jƒn|jrütjjtdƒ|jj |j dddt j |j jdƒ|jƒr‹t j}n t j}|jj|j dd|ƒ|jƒrÉt j}n t j}|jj|j d|j jd|ƒn|jrçtjjtdƒ|jj|j j|j ddt j|j jdƒ|jƒrgt j }n t j}|jj|j j|j d|ƒ|jƒr«t j }n t j}|jj|j j|j d|j j|dƒndS(s%Update the scroll bar after scrollingsredraw scroll bar -> init'ings$use_vert_scroll_bar True -> updatingiis%use_horiz_scroll_bar True -> updatingN(R(RRRRMR@tlogRR RHR&RRIRRRRGt ACS_UARROWRFRt ACS_DARROWRCRKRRt ACS_LARROWRt ACS_RARROW(R tchar((sscroll_window.pyt_update_scroll_barºs<           *      #   cCsÅ|dks|dkr*|j\}}n|jƒ|jj|jd|jd|jj||jj||jj ||jj |ƒx5|j D]*}|j |jj||jj|ƒq“WdS(s]The refresh method for ScrollWindows updates the visible portion of the pad iiN( tNonet latest_yxRTR t noutrefreshR&RRRRR tobjectst deep_refresh(R tabs_ytabs_xtobj((sscroll_window.pyR às     cCs6||f|_|j||ƒtj|||ƒdS(sjRefresh the actual physical location on the screen of the part of the pad that's visible N(RVR RRY(R RR((sscroll_window.pyRYóscCss|dk r%||jdf|_n|dk r[|jd|}||jdf|_ng|dk r€|jd|f|_nB|dk r¶|jd|}|jd|f|_n tdƒ‚|jd|jdkrü|jd|jdf|_n|jd|jdkr6|jd|jdf|_ntd|jdƒtd|jdƒf|_|jƒdS(slScroll the visible region downward by 'lines'. 'lines' may be negative. Alternatively, scroll directly to 'scroll_to_line' -OR- Scroll the visible region to the right by 'columns'. 'columns' may be negative. Alternatively, scroll directly to 'scroll_to_column' Code only supports scrolling in one direction. iisaMissing keyword arg (requires either 'lines', 'scroll_to_line', 'columns', or 'scroll_to_columns)N(RUR&t ValueErrorR$R%tmaxR (R Rtscroll_to_lineRtscroll_to_columnt current_yt current_x((sscroll_window.pytscrollýs$       cCsƒ|tjkrd|_dS|jt|ƒ7_xKt|jƒD]6}|j|jƒrA|j|j|dt ƒdSqAW|SdS(sWActivate the object whose first letter corresponds to the key pressed R#t force_to_topN( RR4R=RUtchrtsortedR<t startswithtactivate_object_forceR'(R t input_keytentry((sscroll_window.pyR3s cCsd|_tj|d}t|tj|dƒ}|jdk rÃy|j|j|ƒdSWqtk r¿|ƒrštj j dtj|dƒ|Stj|d}|j |dSqXnP|ƒrñtj j t dtj|dƒ|Stj|d}|j |dSdS(s‡Activate the next/previous object, or, for pure text windows, simply scroll down/up one line or right/left one column R#iis!%s returned true, returning inputisAlready %s, returning inputN(R=Rt ARROW_DICTtgetattrt active_objectRUtactivate_objectt IndexErrorRRRRcRNR(R Ritoffsettat_endptt param_dict((sscroll_window.pyR-4s.         cCs|jd|jdkS(s?Returns True if this ScrollWindow can't scroll down any furtherii(R&R$(R ((sscroll_window.pyRascCs|jddkS(s=Returns True if this ScrollWindow can't scroll up any furtheri(R&(R ((sscroll_window.pyRescCs|jddkS(s?Returns True if this ScrollWindow can't scroll left any furtherii(R&(R ((sscroll_window.pyRiscCs|jd|jdkS(s@Returns True if this ScrollWindow can't scroll right any furtheri(R&R%(R ((sscroll_window.pyRmsicCs |jd|d|d|ƒdS(s5Activate the given object, without forcing to the toptindextloopRdN(Rh(R RsRttjump((sscroll_window.pyRnqscCse|jƒ}tt|ƒj|d|d|ƒ|jƒjj}tjjd||j ƒ|r‚tjjdƒ|j d|ƒnß||j dkrÑ|j dƒ||j dkratt|ƒj|ƒqan||j d|jj krQtjjd||jj ƒ|j d ƒ||j d|jj kratt|ƒj|ƒqantjjd ƒd S( sdActivate the given object, if it is in the visible region. If it's not, scroll one line - if it is then in the visible region, activate it, otherwise, do nothing. If force_to_top is True, scroll immediately to this object, placing it as close to the top of the visible region as possible, and activate it. RtRus active_y_loc=%s, current_line=%ssscroll_to_line=active_y_locR_iiÿÿÿÿsscroll to (down) %sis not scrollingN( tget_active_objectR+RRnRRRRRR&RcR(R RsRtRdtold_objt active_y_loc((sscroll_window.pyRhus(      N("t__name__t __module__t__doc__RR0R/R1R2RkRR"RLR,RARBtpropertyR@RDRERCRMRTRUR RYRcR3R-RRRRRnRh(((sscroll_window.pyR's>   )        &   -    ( R{RR:tsolaris_install.terminaluiRRt'solaris_install.terminalui.inner_windowRR(((sscroll_window.pyts