ó ur™Vc@sádZddlZddlZddlZddlZddlZddljZddlmZddl m Z ddl m Z ddl mZmZddlmZddlmZdd lmZd e fd „ƒYZdS( s6 Display individual help screen or help topics screen iÿÿÿÿN(t_(tAction(t BaseScreen(tconvert_paragrapht textwidth(tListItem(t ScrollWindow(t WindowAreat HelpScreencBseeZdZd„Zd„Zd„Zd„Zd d„Zd„Z d„Z d d„Z d „Z RS( s…Show localized help file pertaining to last traversed screen or help topics list from which to choose a desired help topic. cCsútt|ƒj|ƒytjtjdƒ|_Wn<tjk rptjj dƒtjtjdƒ|_nXtjj d|jƒ||_ ||_ ||_ d|_d|_g|_d|_t|_d|_d|_tjƒdk|_dS(Nts<System configured with invalid locale(5), falling back to C.tCs locale=%siti386(tsuperRt__init__tlocalet setlocalet LC_MESSAGEStErrort terminaluitLOGGERtwarningtdebugt help_headert help_indextintrotNonetscreent screen_lastt help_infot help_dicttFalsettopicst scroll_regiont cur_help_idxtplatformt processortis_x86(tselftmain_winRRR((shelp_screen.pyR 3s$          cCs£i|_g|_x^|D]V}|jdr|jj|j}|j|j|<|jj|d|jfƒqqWtj j d|jƒtj j d|jƒdS(s‰Setup the help_dict and help_info structures help_dict contains: key: screen name tuple: (,
) tuple: (,
) help_info contains tuples: (tuple of screen names, format of text) it sself.help_dict=%ssself.help_info=%sN( RRt help_datat __class__t__name__tinstancetappendt help_formatRRR(R%tscreensRtkey((shelp_screen.pytsetup_help_dataLs    $cCs¹tjjd|jjƒ|j|jj_t t j |jj j|j ƒ}||jj |j<|j|jjkr–|jj j|jjjdƒn|jj j|jj jdƒdS(s²Remove the continue key for help screen and Help key for help topics screen. Redirect F2_Continue to display the selected topic, when at the topics list s!in set_actions self.class_name=%sN(RRRR)R*RR&t help_actionttextRtcursestKEY_F2tcontinue_actiontactionsR/RtpopR(R%t help_continue((shelp_screen.pyt set_actionses     "c Cs|jj|jƒd}||jj|j|dd|jdƒ7}|d7}tdt|j ƒdd|ddƒ}t j j dt|j ƒƒ|j|d|_|j|_t|d|jƒ|_t j j d t|j ƒƒxÔt|j ƒD]Ã\}}|d}|j |dd}||}t|jt|ƒdƒ}ttd||dƒd|jd |ƒ} t j j d |jƒ|j|dkr÷t j j d |ƒ||_q÷q÷Wt j j d | jjƒŒ|jj|jƒ|jj|jƒdS(sDisplay the help topics screen.itmax_xtscrollable_linesty_loctx_locislines=%stwindowsrange=%sR2sself.screen_last=%ssSet cur_help_idx = %ssbeg_y=%d, beg_x=%dN(R&tset_header_textRt center_wint add_paragraphRt win_size_xRtlenRRRRRt win_size_ytlinestcolumnsRR t enumeratetminRRRR!R>tgetbegyxtactivate_object( R%R<tareatidxtinfot topic_formatt topic_titlet help_topicthilitet list_item((shelp_screen.pytdisplay_help_topics‚s6     cCs\tjjd|jjƒ|jj}|j|d|_tjjd|jƒt|_|S(sœCalled when user presses F2 on help topics screen. Results in show being called again to display single file help of chosen topic. scontinue_action:%siscontinue_action self.screen=%s( RRRR t active_objectRRRR(R%tdummyt cur_topic((shelp_screen.pyR5¨s    cCsid}tjjd|jƒ|j|jkrr|tdƒ|j|jdf}|j|j|jdƒ}n(|tdƒtdƒf}tdƒ}|jj|ƒt ||j dƒ}tjjd t |ƒ|ƒt d dd dd t |ƒdƒ}|j d|_|j |_t|d |jƒ|_|jj|d|jdƒ|jj|jƒdS(s#Display the single file help screens%s: %ssself.screen is =%stHelpiis Not Availables%Help for this screen is not availableis help_text #lines=%d, text is %sR=R<R;R>tstart_xiN(RRRRRRt get_help_textR&R?RRBRCRRDRERFRR@R RAR=RJ(R%Rt help_textRK((shelp_screen.pyt display_help¶s&     cCs–tjjd|jƒ|j|jjkrGtjjdƒt|_n+t|_|j|_ tjjd|j ƒ|jrˆ|j ƒn |j ƒdS(s?Display the screen, either the single file help or help topics.sin show self.screen=%sssetting self topics to true:ssetting self.screen_last to %sN( RRRRR)R*tTrueRRRRSR[(R%((shelp_screen.pyt_showÐs       cCsô|s dSd}y­xJ|jƒD]<}||}tjjd|ƒtj|tjƒr Pq q Wtjjd|ƒt|ƒ;}t j dƒ|ƒ}|j ƒ}tjjd|ƒWdQXWn0t k rïtjjd|ƒt dƒ}nX|S( sÿ Get the localized help text for the filename passed in. First check locid directory. If not there, strip off dot extension (fr_FR.UTF-8 becomes fr_FR). If not there, truncate to 2 chars (fr). If not there, use C. R sAccessing help file %ssOpening help file %ssUTF-8sDone reading help file %sNsUnable to open help file %ss%Help for this screen is not available(Rt _get_locidsRRRtostaccesstR_OKtopentcodecst getreadertreadtIOErrorR(R%tfilenamet help_filetlocidt full_pathRZ((shelp_screen.pyRYãs$   cCsx|j}|g}d|krA|jdƒd}|j|ƒnt|ƒdkrg|j|d ƒn|jdƒ|S(s×Generate a list of possible locales - folders to check for help screen text in. Used by get_help_text() in conjunction with a screen's indicated help text file path. The list will include one or more of: * The current locale (e.g., "en_US.UTF-8") * The current locale, stripped of encoding (e.g., "en_US") * The current language, stripped of locale (e.g., "en") * The default locale ("C") t.iiR (RtsplitR,RC(R%Rtlocids((shelp_screen.pyR^ÿs    N( R*t __module__t__doc__R R0R9RSRR5R[R]RYR^(((shelp_screen.pyR-s    &    (RoRcR3RR_R"tsolaris_install.terminaluiRRt!solaris_install.terminalui.actionRt&solaris_install.terminalui.base_screenRtsolaris_install.terminalui.i18nRRt$solaris_install.terminalui.list_itemRt(solaris_install.terminalui.scroll_windowRt&solaris_install.terminalui.window_areaRR(((shelp_screen.pyts