def _choose_icons(self, icon_dir, icon_option, icon_def):

        import cudax_lib as appx

        dir = os.path.join(app_path(APP_DIR_DATA), icon_dir)
        dirs = sorted(os.listdir(dir))
        if not dirs: return

        s = appx.get_opt(icon_option, icon_def, appx.CONFIG_LEV_USER)
        try:
            index = dirs.index(s)
        except:
            index = -1

        res = dlg_menu(DMENU_LIST, dirs, focused=index)
        if res is None: return

        s = dirs[res]
        appx.set_opt(icon_option, s, appx.CONFIG_LEV_USER)
        s_now = appx.get_opt(icon_option)
        if s != s_now:
            msg_box(_('Error writing option to user.json\nGot value "{}"').format(s_now), MB_OK+MB_ICONERROR)
        else:
            msg_box(_('Changed option in user.json, restart app to see effect'), MB_OK+MB_ICONINFO)
Ejemplo n.º 2
0
    def dlg_config(self):
        save_bd_col = apx.get_opt('comment_save_column'         , False)
        at_min_bd   = apx.get_opt('comment_equal_column'        , False)
        bUseFLn     = apx.get_opt('comment_full_line_if_no_sel' , True)
        bSkip       = apx.get_opt('comment_move_down'           , True)

        save_s      = _('(Line commands) Try to keep text position after (un)commenting')
        save_h      = _('Try to replace only blank(s) to keep text positions:'
                        '\rUncommented lines:'
                        '\r····foo1'
                        '\r····foo2'
                        '\rCommented lines:'
                        '\r#···foo1'
                        '\r···#foo2'
                        )
        vert_s      = _('(Line "at non-space") If selected few lines, insert comment at maximal common indent')
        vert_h      = _('Use max same column to comment:'
                        '\rUncommented lines:'
                        '\r··foo1'
                        '\r····foo2'
                        '\r······foo3'
                        '\rCommented lines:'
                        '\r·#foo1'
                        '\r·#··foo2'
                        '\r·#····foo3'
                        )
        full_s      = _('(Stream) Comment full line if no selection')
        down_s      = _('(All) Move caret to next line')
        aid,vals,chds   = dlg_wrapper(_('Config commenting commands'), 610, 135,     #NOTE: dlg-cmnt
             [dict(cid='save',tp='ch'   ,t=5    ,l=5    ,w=600      ,cap=save_s ,hint=save_h) #
             ,dict(cid='vert',tp='ch'   ,t=5+25 ,l=5    ,w=600      ,cap=vert_s ,hint=vert_h) #
             ,dict(cid='full',tp='ch'   ,t=5+50 ,l=5    ,w=600      ,cap=full_s             ) #
             ,dict(cid='down',tp='ch'   ,t=5+75 ,l=5    ,w=600      ,cap=down_s             ) #
             ,dict(cid='!'   ,tp='bt'   ,t=105  ,l=610-165-5,w=80   ,cap=_('OK'),props='1'                                                          ) #     default
             ,dict(cid='-'   ,tp='bt'   ,t=105  ,l=610 -80-5,w=80   ,cap=_('Cancel')                                                                )
             ], dict(save=save_bd_col
                    ,vert=at_min_bd
                    ,full=bUseFLn
                    ,down=bSkip
             ), focus_cid='save')
        if aid is None or aid=='-': return
        if vals['save'] != save_bd_col: apx.set_opt('comment_save_column'       , vals['save'])
        if vals['vert'] != at_min_bd:   apx.set_opt('comment_equal_column'      , vals['vert'])
        if vals['full'] != bUseFLn:     apx.set_opt('comment_full_line_if_no_sel',vals['full'])
        if vals['down'] != bSkip:       apx.set_opt('comment_move_down'         , vals['down'])
Ejemplo n.º 3
0
    def dlg_config(self):
        DLG_W,  \
        DLG_H   = 400, 95
        lxrs_l  = apx.get_enabled_lexers()
        
        sgns_h  = _('Space delimeted list.\rThe first word will be inserted by command.')
        dfcm_h  = _('Default comment sign.\rIt is used when lexer has no line comment or file has no lexer.')
        cnts    =[dict(           tp='lb'   ,tid='sgns' ,l=GAP          ,w=130          ,cap=_('&Bookmark signs:')  ,hint=sgns_h    ) # &b
                 ,dict(cid='sgns',tp='ed'   ,t=GAP      ,l=130          ,w=DLG_W-130-GAP                                            ) #  
                 ,dict(           tp='lb'   ,tid='dfcm' ,l=GAP          ,w=130          ,cap=_('&Comment sign:')    ,hint=dfcm_h    ) # &c 
                 ,dict(cid='dfcm',tp='ed'   ,t=35       ,l=130          ,w=DLG_W-130-GAP                                            ) #  
                 ,dict(cid='wrap',tp='ch'   ,tid='!'    ,l=GAP          ,w=120          ,cap=_('&Wrap for next/prev')               ) # &w
#                ,dict(cid='help',tp='bt'   ,t=DLG_H-60 ,l=DLG_W-GAP-80 ,w=80           ,cap=_('Help')                              ) #  
                 ,dict(cid='!'   ,tp='bt'   ,t=DLG_H-30 ,l=DLG_W-GAP-165,w=80           ,cap=_('Save')          ,props='1'          ) #     default
                 ,dict(cid='-'   ,tp='bt'   ,t=DLG_H-30 ,l=DLG_W-GAP-80 ,w=80           ,cap=_('Close')                             ) #  
                ]#NOTE: cfg
        focused = 'sgns'
        while True:
            act_cid, vals, chds = dlg_wrapper(_('In-text bookmarks'), DLG_W, DLG_H, cnts
                , dict(sgns=' '.join(self.bm_signs)
                      ,dfcm=         self.unlxr_cmnt
                      ,wrap=         self.wrap
                      ), focus_cid=focused)
            if act_cid is None or act_cid=='-':    return#while True
            focused = chds[0] if 1==len(chds) else focused
            if act_cid=='!':
                if not vals['sgns'].strip():
                    app.msg_status(_('Need Bookmark sign'))
                    focused = 'sgns'
                    continue#while
                if not vals['dfcm'].strip():
                    app.msg_status(_('Need Comment sign'))
                    focused = 'dfcm'
                    continue#while
                if  self.bm_signs  != vals['sgns'].split():
                    self.bm_signs   = vals['sgns'].split()
                    apx.set_opt('intextbookmk_signs', self.bm_signs)
                if  self.unlxr_cmnt!= vals['dfcm'].strip():
                    self.unlxr_cmnt = vals['dfcm'].strip()
                    apx.set_opt('intextbookmk_no_lexer_comment', self.unlxr_cmnt)
                if  self.wrap      != vals['wrap']:
                    self.wrap       = vals['wrap']
                    apx.set_opt('intextbookmk_wrap', self.wrap)
                break#while
Ejemplo n.º 4
0
def dlg_valign_consts():
    pass;                      #log('ok')
    UP      = '/\\'
    UP      = '↑↑'
#   UP      = 'ΛΛΛ'
    DN      = '\\/'
    DN      = '↓↓'
#   DN      = 'VVV'
    DLG_W,  \
    DLG_H   = 335, 280
    fits    = dict(
               _sp1=fit_top_by_env('check')
              ,_sp2=fit_top_by_env('edit')
              ,_sp3=fit_top_by_env('button')
              ,_sp4=fit_top_by_env('combo_ro')
              ,_sp5=fit_top_by_env('combo')
              ,_sp6=fit_top_by_env('checkbutton')
              ,_sp7=fit_top_by_env('linklabel')
              ,_sp8=fit_top_by_env('spinedit')
              )
    vals    = dict(
               ch1 =False
              ,ed2 ='=======?'
              ,cbo4=0
              ,cb5 ='=======?'
              ,chb6=0
              ,sp8 =4444444
              )
    focused = '-'
    while True:
        aid, vals, fid, chds = dlg_wrapper(_('Adjust vertical alignments')   ,DLG_W, DLG_H, 
            [dict(cid='lb1'     ,tp='lb'    ,t= 10              ,l=  5  ,w=100  ,cap='==============='                          )
            ,dict(cid='ch1'     ,tp='ch'    ,t= 10+fits['_sp1'] ,l=115  ,w=100  ,cap='=======?'             ,hint=fits['_sp1']  )
            ,dict(cid='up1'     ,tp='bt'    ,t= 10-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn1'     ,tp='bt'    ,t= 10-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='lb2'     ,tp='lb'    ,t= 40              ,l=  5  ,w=100  ,cap='==============='                          )
            ,dict(cid='ed2'     ,tp='ed'    ,t= 40+fits['_sp2'] ,l=115  ,w=100                              ,hint=fits['_sp2']  )
            ,dict(cid='up2'     ,tp='bt'    ,t= 40-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn2'     ,tp='bt'    ,t= 40-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='lb3'     ,tp='lb'    ,t= 70              ,l=  5  ,w=100  ,cap='==============='                          )
            ,dict(cid='bt3'     ,tp='bt'    ,t= 70+fits['_sp3'] ,l=115  ,w=100  ,cap='=======?'             ,hint=fits['_sp3']  )
            ,dict(cid='up3'     ,tp='bt'    ,t= 70-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn3'     ,tp='bt'    ,t= 70-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='lb4'     ,tp='lb'    ,t=100              ,l=  5  ,w=100  ,cap='==============='                          )
            ,dict(cid='cbo4'    ,tp='cb-ro' ,t=100+fits['_sp4'] ,l=115  ,w=100  ,items=['=======?']         ,hint=fits['_sp4']  )
            ,dict(cid='up4'     ,tp='bt'    ,t=100-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn4'     ,tp='bt'    ,t=100-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='lb5'     ,tp='lb'    ,t=130              ,l=  5  ,w=100  ,cap='==============='                          )
            ,dict(cid='cb5'     ,tp='cb'    ,t=130+fits['_sp5'] ,l=115  ,w=100  ,items=['=======?']         ,hint=fits['_sp5']  )
            ,dict(cid='up5'     ,tp='bt'    ,t=130-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn5'     ,tp='bt'    ,t=130-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='lb6'     ,tp='lb'    ,t=160              ,l=  5  ,w=100  ,cap='==============='                          )
            ,dict(cid='chb6'    ,tp='ch-bt' ,t=160+fits['_sp6'] ,l=115  ,w=100  ,cap='=======?'             ,hint=fits['_sp6']  )
            ,dict(cid='up6'     ,tp='bt'    ,t=160-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn6'     ,tp='bt'    ,t=160-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='lb7'     ,tp='lb'    ,t=190              ,l=  5  ,w=100  ,cap='==============='                          )
            ,dict(cid='chb7'    ,tp='ln-lb' ,t=190+fits['_sp7'] ,l=115  ,w=100  ,cap='=======?',props='-'   ,hint=fits['_sp7']  )
            ,dict(cid='up7'     ,tp='bt'    ,t=190-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn7'     ,tp='bt'    ,t=190-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='lb8'     ,tp='lb'    ,t=220              ,l=  5  ,w=100  ,cap='4444444444444444'                         )
            ,dict(cid='sp8'     ,tp='sp-ed' ,t=220+fits['_sp8'] ,l=115  ,w=100  ,props='0,4444444,1'        ,hint=fits['_sp8']  )
            ,dict(cid='up8'     ,tp='bt'    ,t=220-3            ,l=230  ,w=50   ,cap=UP                                         )
            ,dict(cid='dn8'     ,tp='bt'    ,t=220-3            ,l=280  ,w=50   ,cap=DN                                         )
                
            ,dict(cid='save'    ,tp='bt'    ,t=DLG_H-30         ,l=115  ,w=100  ,cap=_('&Save')
                                                                                ,hint=_('Apply the fittings to controls of all dialogs.'
                                                                                        '\rCtrl+Click  - Show data to mail report.'))
            ,dict(cid='-'       ,tp='bt'    ,t=DLG_H-30         ,l=230  ,w=100  ,cap=_('Cancel')        )
            ], vals, focus_cid=focused)
        if aid is None or aid=='-':    return#while True
        scam        = app.app_proc(app.PROC_GET_KEYSTATE, '') if app.app_api_version()>='1.0.143' else ''
        aid_m       = scam + '/' + aid if scam and scam!='a' else aid   # smth == a/smth
        focused = chds[0] if 1==len(chds) else focused
        if aid[:2]=='up' or aid[:2]=='dn':
            pos = aid[2]
            fits['_sp'+pos] = fits['_sp'+pos] + (-1 if aid[:2]=='up' else 1)
            
        if aid_m=='save':
            ctrls   = ['check'
                      ,'edit'
                      ,'button'   
                      ,'combo_ro' 
                      ,'combo'    
                      ,'checkbutton'
                      ,'linklabel'
                      ,'spinedit'
                      ]
            for ic, nc in enumerate(ctrls):
                fit = fits['_sp'+str(1+ic)]
                if fit==fit_top_by_env(nc): continue#for ic, nc
                apx.set_opt('dlg_wrapper_fit_va_for_'+nc, fit)
               #for ic, nc
            fit_top_by_env__clear()
            break#while
            
        if aid_m=='c/save': # Report
            rpt = 'env:'+get_desktop_environment()
            rpt+= c13+'check:'      +str(fits['_sp1'])
            rpt+= c13+'edit:'       +str(fits['_sp2'])
            rpt+= c13+'button:'     +str(fits['_sp3'])
            rpt+= c13+'combo_ro:'   +str(fits['_sp4'])
            rpt+= c13+'combo:'      +str(fits['_sp5'])
            rpt+= c13+'checkbutton:'+str(fits['_sp6'])
            rpt+= c13+'linklabel:'  +str(fits['_sp7'])
            rpt+= c13+'spinedit:'   +str(fits['_sp8'])
            aid_r, *_t = dlg_wrapper(_('Report'), 230,310,
                 [dict(cid='rprt',tp='me'    ,t=5   ,l=5 ,h=200 ,w=220)
                 ,dict(           tp='lb'    ,t=215 ,l=5        ,w=220  ,cap=_('Send the report to the address'))
                 ,dict(cid='mail',tp='ed'    ,t=235 ,l=5        ,w=220)
                 ,dict(           tp='lb'    ,t=265 ,l=5        ,w=150  ,cap=_('or post it on'))
                 ,dict(cid='gith',tp='ln-lb' ,t=265 ,l=155      ,w=70   ,cap='GitHub',props='https://github.com/kvichans/cuda_fit_v_alignments/issues')
                 ,dict(cid='-'   ,tp='bt'    ,t=280 ,l=205-80   ,w=80   ,cap=_('Close'))
                 ], dict(rprt=rpt
                        ,mail='*****@*****.**'), focus_cid='rprt')
Ejemplo n.º 5
0
    def do_setv(self, aid, ag, data):
        M,m = self.__class__,self
        pass;                  #LOG and log('aid,m.cur_op={}',(aid,m.cur_op))
        if not m.cur_op:   return []
        #m.col_ws= [ci['wd'] for ci in m.ag.cattr('lvls', 'cols')]

        cur_val = data

        trg     = 'lexer '+m.lexr+'.json' if m.for_ulf=='l' else 'user.join'
        key4v   = m.for_ulf+'val'
        op      = m.cur_op
        oi      = m.opts_full[op]
        frm     = oi['frm']

        dval    = oi.get( 'def')
        uval    = oi.get('uval')
        lval    = oi.get('lval')
        fval    = oi.get('fval')
        ulfvl   = oi.get(key4v ) #fval if m.for_ulf=='f' else lval if m.for_ulf=='l' else uval
        jval    = oi['jlvl']    if m.for_ulf=='l' else \
                  oi['juvl']    if m.for_ulf=='u' else \
                  oi['jfvl']

        # Get new value
        newv    = None
        erpt_s  = ''
        if False:pass

        elif aid=='setd'  and  m.for_ulf=='f'  and  op in apx.OPT2PROP:
            # Remove from file - set over def/user/lex val
            newv    = oi.get('lval', oi.get('uval', oi.get('def')))
            if newv==ulfvl:
                #m.stbr_act(M.STBR_MSG, _('No need changes'))
                return []
            erpt_s  = 'reset-f'
            m.ed.set_prop(apx.OPT2PROP[op], newv)

        elif aid=='setd'  and  ulfvl is not None  and  m.for_ulf!='f':
            # Remove from user/lexer
            newv= None

        elif aid=='setv':                   # Add/Set opt for user/lexer/file
            # Enter from edit. Need parse some string
            #newv    = m.ag.cval('eded')
            newv    = cur_val
            try:
                newv    =   int(newv)   if frm=='int'   else \
                          float(newv)   if frm=='float' else \
                                newv
            except Exception as ex:
                app.msg_box(f(_('Incorrect value. It\'s needed in format: {}'), frm)
                           , app.MB_OK+app.MB_ICONWARNING)
                return d(form=d(fid='eded'))
            if frm=='#rgb' or frm=='#rgb-e' and newv:       # Testing new val
                try:
                    apx.html_color_to_int(newv)
                except Exception as ex:
                    app.msg_box(f(_('Incorrect value. It\'s needed in format: {}'), '#RGB or #RRGGBB')
                               , app.MB_OK+app.MB_ICONWARNING)
                    return d(form=d(fid='eded'))


        ### Use new value to change env
        if newv is not None and newv==ulfvl:
            #m.stbr_act(M.STBR_MSG, _('No need changes'))
            return []

        if m.for_ulf=='f' and newv is not None and op in apx.OPT2PROP:
            # Change for file
            erpt_s  = 'set-f'
            ed.set_prop(apx.OPT2PROP[op], newv)

        if m.for_ulf!='f':
            # Change target file
            pass;              #LOG and log('?? do_erpt',())
            erpt_s  =('reset-u' if newv  is None and m.for_ulf=='u' else
                      'reset-l' if newv  is None and m.for_ulf=='l' else
                      'add-u'   if ulfvl is None and m.for_ulf=='u' else
                      'add-l'   if ulfvl is None and m.for_ulf=='l' else
                      'set-u'   if                   m.for_ulf=='u' else
                      'set-l'   if                   m.for_ulf=='l' else '')
            pass;              #LOG and log('?? set_opt',())
            apx.set_opt(op
                       ,newv
                       ,apx.CONFIG_LEV_LEX  if m.for_ulf=='l' else apx.CONFIG_LEV_USER
                       ,ed_cfg  =None
                       ,lexer   =m.lexr     if m.for_ulf=='l' else None
                       ,user_json=m.how.get('stor_json', 'user.json')
                       )

            if not m.apply_one:
                pass;          #LOG and log('?? OpsReloadAndApply',())
                ed.cmd(cmds.cmd_OpsReloadAndApply)
            else:
                m.apply_need    = True

        # Use new value to change dlg data
        pass;                  #LOG and log('?? oi={}',(oi))
        pass;                  #LOG and log('?? m.opts_full={}',pf(m.opts_full))
        if False:pass
        elif aid=='setd':
            oi.pop(key4v, None)     if m.for_ulf!='f' else 0
        else:
            pass;              #LOG and log('key4v, newv={}',(key4v, newv))
            oi[key4v] = newv
        pass;                  #LOG and log('oi={}',(oi))
        upd_cald_vals(m.opts_full)
        pass;                  #LOG and log('oi={}',(oi))

        jnewv   = oi['jlvl']   if m.for_ulf=='l' else oi['juvl']    if m.for_ulf=='u' else oi['jfvl']
        #m.do_erpt(erpt_s, jnewv, jval)
        pass;                  #LOG and log('ok oi={}',(oi))
        pass;                  #LOG and log('ok m.opts_full={}',pf(m.opts_full))

        pass;                  #LOG and log('?? get_cnts',())

        if m.for_ulf!='f' and m.auto4file and op in apx.OPT2PROP:
            # Change FILE to over  (("over" - override?))
            newv    = oi.get('lval', oi.get('uval', oi.get('def')))
            if newv!=oi.get('fval'):
                erpt_s      = 'reset-f'
                m.ed.set_prop(apx.OPT2PROP[op], newv)
                oi['fval']  = newv
                jval        = oi['jfvl']
                upd_cald_vals(m.opts_full)
                jnewv       = oi['jfvl']
                #m.do_erpt('auset-f', jnewv, jval)

        pass;                  #LOG and log('m.get_vals(lvls-cur)={}',(m.get_vals('lvls-cur')))
Ejemplo n.º 6
0
def make_plugin_group(regex, name):

    apx.set_opt('plugin_groups/' + regex, name)
Ejemplo n.º 7
0
    def dlg_config(self):
        DLG_W,  \
        DLG_H   = 430, 330
        minl_h = _(
            'Mininal characters in selection or previous string to start completion'
        )
        kill_c = _('Delete tail of base word after &caret')
        kill_h = _(
            'If [x] then "ab¦cd" will be completed to "ab¦123", "ab¦ABC".'
            '\rIf [ ] then "ab¦cd" will be completed to "ab¦cd123", "ab¦cdABC".'
        )
        incs_h = _('What characters will be included to completion variant.'
                   '\rLetters and digits always are included.')
        pair_c = _('&Expands to include both pair-chars')
        pair_h = _('Example: "·" is space.'
                   '\rVariants for "fun":'
                   '\r   function'
                   '\r   fun="a·b"'
                   '\r   fun(·1,·2·)'
                   '\r   fun(·1,·m()·)')
        sngl_c = _(
            'Do&nt show list with single variant. Directly use the variant.')
        vals = dict(minl=self.min_len,
                    kill=self.kill,
                    near=self.near,
                    sngl=self.sngl,
                    wdcs=self.wdsgns,
                    excs=self.exsgns,
                    exal=self.exall,
                    pair=self.expair)
        focused = 'wdcs'
        while True:
            cnts = [
                dict(tp='lb', t=5, l=5, w=130, cap=_('Word-like variant:'))  #
                ,
                dict(tp='lb',
                     tid='wdcs',
                     l=40,
                     w=130,
                     cap=_('Contains e&xtra chars:'),
                     hint=incs_h)  # &x
                ,
                dict(cid='wdcs', tp='ed', t=25, l=180, w=DLG_W - 180 - 5)  #
                ,
                dict(tp='--', t=50)  #
                ,
                dict(tp='lb',
                     t=65,
                     l=5,
                     w=130,
                     cap=_('Expession-like variant:'))  #
                ,
                dict(tp='lb',
                     tid='excs',
                     l=40,
                     w=130,
                     cap=_('Contains extra &signs:'),
                     hint=incs_h)  # &s
                ,
                dict(cid='excs',
                     tp='ed',
                     t=85,
                     l=180,
                     w=DLG_W - 180 - 5,
                     en=not vals['exal'])  #
                ,
                dict(cid='exal',
                     tp='ch',
                     t=110,
                     l=180,
                     w=130,
                     cap=_('An&y non-spaces'),
                     act=1)  # &y
                ,
                dict(cid='pair',
                     tp='ch',
                     t=135,
                     l=40,
                     w=290,
                     cap=pair_c,
                     hint=pair_h)  # &e
                ,
                dict(tp='--', t=165)  #
                ,
                dict(tp='lb',
                     tid='minl',
                     l=5,
                     w=180,
                     cap=_('&Minimal base length (2-5):'),
                     hint=minl_h)  # &m
                ,
                dict(cid='minl',
                     tp='sp-ed',
                     t=180,
                     l=180,
                     w=DLG_W - 180 - 5,
                     props='2,5,1')  #  
                ,
                dict(cid='kill',
                     tp='ch',
                     t=210,
                     l=5,
                     w=290,
                     cap=kill_c,
                     hint=kill_h)  # &c
                ,
                dict(cid='near',
                     tp='ch',
                     t=240,
                     l=5,
                     w=290,
                     cap=_('Start with variant from nea&rest line'))  # &r
                ,
                dict(cid='sngl', tp='ch', t=270, l=5, w=290, cap=sngl_c)  # &n
                ,
                dict(cid='dflt',
                     tp='bt',
                     t=DLG_H - 30,
                     l=5,
                     w=130,
                     cap=_('&Default values'))  # &d
                ,
                dict(cid='!',
                     tp='bt',
                     t=DLG_H - 30,
                     l=DLG_W - 180,
                     w=80,
                     cap=_('Save'),
                     props='1')  #    default
                ,
                dict(cid='-',
                     tp='bt',
                     t=DLG_H - 30,
                     l=DLG_W - 85,
                     w=80,
                     cap=_('Cancel'))  #  
            ]  #NOTE: cfg
            aid, vals, chds = dlg_wrapper(_('Configure "In-text completion"'),
                                          DLG_W,
                                          DLG_H,
                                          cnts,
                                          vals,
                                          focus_cid=focused)
            if aid is None or aid == '-': return  #while True
            focused = 'excs' \
                        if aid=='exal' and not vals['exal'] else \
                      chds[0] \
                        if 1==len(chds) else \
                      focused
            if aid == 'dflt':
                vals['minl'] = DEF_MIN_LEN
                vals['kill'] = DEF_KILL
                vals['sngl'] = DEF_SNGL
                vals['near'] = DEF_NEAR
                vals['wdcs'] = DEF_WDSGNS
                vals['excs'] = DEF_EXSGNS
                vals['exal'] = DEF_EXALL
                vals['pair'] = DEF_EXPAIR

            if aid == '!':
                if vals['minl'] != self.min_len:
                    apx.set_opt('intextcomp_min_len', max(2, vals['minl']))
                if vals['kill'] != self.kill:
                    apx.set_opt('intextcomp_kill', vals['kill'])
                if vals['sngl'] != self.sngl:
                    apx.set_opt('intextcomp_sngl', vals['sngl'])
                if vals['near'] != self.near:
                    apx.set_opt('intextcomp_near', vals['near'])

                if vals['wdcs'] != self.wdsgns:
                    apx.set_opt('intextcomp_word_signs', vals['wdcs'])

                if vals['excs'] != self.exsgns:
                    apx.set_opt('intextcomp_expr_signs', vals['excs'])
                if vals['exal'] != self.exall:
                    apx.set_opt('intextcomp_expr_all', vals['exal'])
                if vals['pair'] != self.expair:
                    apx.set_opt('intextcomp_expr_pair', vals['pair'])

                self._prep_const()
                break  #while
Ejemplo n.º 8
0
 def dlg_config(self):
     DLG_W,  \
     DLG_H   = 430, 330
     minl_h  = _('Mininal characters in selection or previous string to start completion')
     kill_c  = _('Delete tail of base word after &caret')
     kill_h  = _(  'If [x] then "ab¦cd" will be completed to "ab¦123", "ab¦ABC".'
                 '\rIf [ ] then "ab¦cd" will be completed to "ab¦cd123", "ab¦cdABC".'
                 )
     incs_h  = _('What characters will be included to completion variant.'
                 '\rLetters and digits always are included.')
     pair_c  = _('&Expands to include both pair-chars')
     pair_h  = _('Example: "·" is space.'
                 '\rVariants for "fun":'
                 '\r   function'
                 '\r   fun="a·b"'
                 '\r   fun(·1,·2·)'
                 '\r   fun(·1,·m()·)'
                 )
     sngl_c  = _('Do&nt show list with single variant. Directly use the variant.')
     vals    = dict(minl=self.min_len
                   ,kill=self.kill
                   ,near=self.near
                   ,sngl=self.sngl
                   ,wdcs=self.wdsgns
                   ,excs=self.exsgns
                   ,exal=self.exall
                   ,pair=self.expair
                   )
     focused = 'wdcs'
     while True:
         cnts    =[dict(           tp='lb'   ,t=5        ,l=5        ,w=130        ,cap=_('Word-like variant:')                          ) #
                  ,dict(           tp='lb'   ,tid='wdcs' ,l=40       ,w=130        ,cap=_('Contains e&xtra chars:')          ,hint=incs_h) # &x
                  ,dict(cid='wdcs',tp='ed'   ,t=25       ,l=180      ,w=DLG_W-180-5                                                      ) #
                  
                  ,dict(           tp='--'   ,t=50                                                                                       ) #
                  ,dict(           tp='lb'   ,t=65       ,l=5        ,w=130        ,cap=_('Expession-like variant:')                     ) #
                  ,dict(           tp='lb'   ,tid='excs' ,l=40       ,w=130        ,cap=_('Contains extra &signs:')          ,hint=incs_h) # &s
                  ,dict(cid='excs',tp='ed'   ,t=85       ,l=180      ,w=DLG_W-180-5                                  ,en=not vals['exal']) #
                  ,dict(cid='exal',tp='ch'   ,t=110      ,l=180      ,w=130        ,cap=_('An&y non-spaces')         ,act=1              ) # &y
                  ,dict(cid='pair',tp='ch'   ,t=135      ,l=40       ,w=290        ,cap=pair_c                               ,hint=pair_h) # &e
                  
                  ,dict(           tp='--'   ,t=165                                                                                      ) #
                  ,dict(           tp='lb'   ,tid='minl' ,l=5        ,w=180        ,cap=_('&Minimal base length (2-5):')     ,hint=minl_h) # &m
                  ,dict(cid='minl',tp='sp-ed',t=180      ,l=180      ,w=DLG_W-180-5                                  ,props='2,5,1'      ) #  
                  ,dict(cid='kill',tp='ch'   ,t=210      ,l=5        ,w=290        ,cap=kill_c                               ,hint=kill_h) # &c
                  ,dict(cid='near',tp='ch'   ,t=240      ,l=5        ,w=290        ,cap=_('Start with variant from nea&rest line')       ) # &r
                  ,dict(cid='sngl',tp='ch'   ,t=270      ,l=5        ,w=290        ,cap=sngl_c                                           ) # &n
                  ,dict(cid='dflt',tp='bt'   ,t=DLG_H-30 ,l=5        ,w=130        ,cap=_('&Default values')                             ) # &d
                  ,dict(cid='!'   ,tp='bt'   ,t=DLG_H-30 ,l=DLG_W-180,w=80         ,cap=_('Save')                    ,props='1'          ) #    default
                  ,dict(cid='-'   ,tp='bt'   ,t=DLG_H-30 ,l=DLG_W-85 ,w=80         ,cap=_('Cancel')                                      ) #  
                 ]#NOTE: cfg
         aid, vals, chds = dlg_wrapper(_('Configure "In-text completion"'), DLG_W, DLG_H, cnts, vals, focus_cid=focused)
         if aid is None or aid=='-':    return#while True
         focused = 'excs' \
                     if aid=='exal' and not vals['exal'] else \
                   chds[0] \
                     if 1==len(chds) else \
                   focused
         if aid=='dflt':
             vals['minl']= DEF_MIN_LEN
             vals['kill']= DEF_KILL
             vals['sngl']= DEF_SNGL
             vals['near']= DEF_NEAR
             vals['wdcs']= DEF_WDSGNS
             vals['excs']= DEF_EXSGNS
             vals['exal']= DEF_EXALL
             vals['pair']= DEF_EXPAIR
         
         if aid=='!':
             if vals['minl']!=self.min_len:
                 apx.set_opt('intextcomp_min_len', max(2, vals['minl']))
             if vals['kill']!=self.kill:
                 apx.set_opt('intextcomp_kill', vals['kill'])
             if vals['sngl']!=self.sngl:
                 apx.set_opt('intextcomp_sngl', vals['sngl'])
             if vals['near']!=self.near:
                 apx.set_opt('intextcomp_near', vals['near'])
             
             if vals['wdcs']!=self.wdsgns:
                 apx.set_opt('intextcomp_word_signs', vals['wdcs'])
             
             if vals['excs']!=self.exsgns:
                 apx.set_opt('intextcomp_expr_signs', vals['excs'])
             if vals['exal']!=self.exall:
                 apx.set_opt('intextcomp_expr_all',   vals['exal'])
             if vals['pair']!=self.expair:
                 apx.set_opt('intextcomp_expr_pair',  vals['pair'])
             
             self._prep_const()
             break#while
Ejemplo n.º 9
0
    def dlg_valign_consts(self):
        pass;                   LOG and log('ok')
        DLG_W,  \
        DLG_H   = 310, 310
        vals    = dict(
#                  _sp1=top_plus_for_os('check'         , 'label')
#                 ,_sp2=top_plus_for_os('edit'          , 'label')
#                 ,_sp3=top_plus_for_os('button'        , 'label')
#                 ,_sp4=top_plus_for_os('combo_ro'      , 'label')
#                 ,_sp5=top_plus_for_os('combo'         , 'label')
#                 ,_sp6=top_plus_for_os('checkbutton'   , 'label')
#                 ,_sp7=top_plus_for_os('linklabel'     , 'label')
#                 ,_sp8=top_plus_for_os('spinedit'      , 'label')
                   _sp1=fit_top_by_env('check')
                  ,_sp2=fit_top_by_env('edit')
                  ,_sp3=fit_top_by_env('button')
                  ,_sp4=fit_top_by_env('combo_ro')
                  ,_sp5=fit_top_by_env('combo')
                  ,_sp6=fit_top_by_env('checkbutton')
                  ,_sp7=fit_top_by_env('linklabel')
                  ,_sp8=fit_top_by_env('spinedit')
                  ,ch1 =False
                  ,ed2 ='====fit'
                  ,cbo4=0
                  ,cb5 ='====fit'
                  ,chb6=0
                  ,sp8 =4444444
                  )
        focused = '_sp1'
        while True:
            aid, vals, chds = dlg_wrapper(_('V-Alignment Fitting: env='+get_desktop_environment())   ,DLG_W, DLG_H, 
                [dict(cid='_sp1'    ,tp='sp-ed' ,t=  5              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb1'     ,tp='lb'    ,t=  5              ,l=60   ,w=100  ,cap='base:=========='  )
                ,dict(cid='ch1'     ,tp='ch'    ,t=  5+vals['_sp1'] ,l=170  ,w=100  ,cap='====fit'          )
                
                ,dict(cid='_sp2'    ,tp='sp-ed' ,t= 35              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb2'     ,tp='lb'    ,t= 35              ,l=60   ,w=100  ,cap='base:=========='  )
                ,dict(cid='ed2'     ,tp='ed'    ,t= 35+vals['_sp2'] ,l=170  ,w=100                          )
                
                ,dict(cid='_sp3'    ,tp='sp-ed' ,t= 65              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb3'     ,tp='lb'    ,t= 65              ,l=60   ,w=100  ,cap='base:=========='  )
                ,dict(cid='bt3'     ,tp='bt'    ,t= 65+vals['_sp3'] ,l=170  ,w=100  ,cap='========fit'      )
                
                ,dict(cid='_sp4'    ,tp='sp-ed' ,t= 95              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb4'     ,tp='lb'    ,t= 95              ,l=60   ,w=100  ,cap='base:=========='  )
                ,dict(cid='cbo4'    ,tp='cb-ro' ,t= 95+vals['_sp4'] ,l=170  ,w=100  ,items=['====fit']      )
                
                ,dict(cid='_sp5'    ,tp='sp-ed' ,t=125              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb5'     ,tp='lb'    ,t=125              ,l=60   ,w=100  ,cap='base:=========='  )
                ,dict(cid='cb5'     ,tp='cb'    ,t=125+vals['_sp5'] ,l=170  ,w=100  ,items=['====fit']      )
                
                ,dict(cid='_sp6'    ,tp='sp-ed' ,t=155              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb6'     ,tp='lb'    ,t=155              ,l=60   ,w=100  ,cap='base:=========='  )
                ,dict(cid='chb6'    ,tp='ch-bt' ,t=155+vals['_sp6'] ,l=170  ,w=100  ,cap='========fit'      )
                
                ,dict(cid='_sp7'    ,tp='sp-ed' ,t=185              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb7'     ,tp='lb'    ,t=185              ,l=60   ,w=100  ,cap='base:=========='  )
                ,dict(cid='chb7'    ,tp='ln-lb' ,t=185+vals['_sp7'] ,l=170  ,w=100  ,cap='========fit',props='ya.ru')
                
                ,dict(cid='_sp8'    ,tp='sp-ed' ,t=215              ,l=5    ,w=40   ,props='10,-10,-1'      )
                ,dict(cid='lb8'     ,tp='lb'    ,t=215              ,l=60   ,w=100  ,cap='base:44444444444' )
                ,dict(cid='sp8'     ,tp='sp-ed' ,t=215+vals['_sp8'] ,l=170  ,w=100  ,props='0,4444444,1'    )
                
                ,dict(cid='apply'   ,tp='bt'    ,t=DLG_H-60         ,l=5    ,w=80   ,cap=_('Re&Align') ,props='1'
                                                                                    ,hint=_('Apply fittings to controls of this dialog'))
                ,dict(cid='rprt'    ,tp='bt'    ,t=DLG_H-30         ,l=5    ,w=80   ,cap=_('&Report')
                                                                                    ,hint=_('Show data to change default fittings'))
                ,dict(cid='save'    ,tp='bt'    ,t=DLG_H-30     ,l=DLG_W-170,w=80   ,cap=_('&Save')
                                                                                    ,hint=_('Apply fittings to controls of all dialogs'))
                ,dict(cid='-'       ,tp='bt'    ,t=DLG_H-30     ,l=DLG_W-85 ,w=80   ,cap=_('Cancel')    )
                ], vals, focus_cid=focused)
            if aid is None or aid=='-':    return#while True
            focused = chds[0] if 1==len(chds) else focused
            if aid=='save':
                ctrls   = ['check'
                          ,'edit'
                          ,'button'   
                          ,'combo_ro' 
                          ,'combo'    
                          ,'checkbutton'
                          ,'linklabel'
                          ,'spinedit'
                          ]
                for ic, nc in enumerate(ctrls):
                    fit = vals['_sp'+str(1+ic)]
                    if fit==fit_top_by_env(nc): continue#for ic, nc
                    apx.set_opt('dlg_wrapper_fit_va_for_'+nc, fit)
                   #for ic, nc
                fit_top_by_env__clear()
#               app.msg_box(_('Need restart CudaText to use saved values'))
            
            if aid=='rprt':
                rpt = 'env:'+get_desktop_environment()
                rpt+= c13+'check:'+str(vals['_sp1'])
                rpt+= c13+'edit:'+str(vals['_sp2'])
                rpt+= c13+'button:'+str(vals['_sp3'])
                rpt+= c13+'combo_ro:'+str(vals['_sp4'])
                rpt+= c13+'combo:'+str(vals['_sp5'])
                rpt+= c13+'checkbutton:'+str(vals['_sp6'])
                rpt+= c13+'linklabel:'+str(vals['_sp7'])
                rpt+= c13+'spinedit:'+str(vals['_sp8'])
                aid_r, vals_r, chds_r = dlg_wrapper(_('Report'), 210,290,     #NOTE: dlg-hlp
                     [dict(cid='rprt',tp='me'    ,t=5   ,l=5 ,h=200 ,w=200)
                     ,dict(           tp='lb'    ,t=215 ,l=5        ,w=200, cap=_('Send the report to addres'))
                     ,dict(cid='mail',tp='ed'    ,t=235 ,l=5        ,w=200)
                     ,dict(cid='-'   ,tp='bt'    ,t=260 ,l=205-80   ,w=80   ,cap=_('Close'))
                     ], dict(rprt=rpt
                            ,mail='*****@*****.**'), focus_cid='rprt')
Ejemplo n.º 10
0
    def dlg_config(self):
        DLG_W,  \
        DLG_H   = 400, 95+30
        lxrs_l = apx.get_enabled_lexers()

        sgns_h = _(
            'Space delimeted list.\rThe first word will be inserted by command.'
        )
        dfcm_h = _(
            'Default comment sign.\rIt is used when lexer has no line comment or file has no lexer.'
        )
        cnts = [
            dict(tp='lb',
                 tid='sgns',
                 l=GAP,
                 w=130,
                 cap=_('&Bookmark signs:'),
                 hint=sgns_h)  # &b
            ,
            dict(cid='sgns', tp='ed', t=GAP, l=130, w=DLG_W - 130 - GAP)  #  
            ,
            dict(tp='lb',
                 tid='dfcm',
                 l=GAP,
                 w=130,
                 cap=_('&Comment sign:'),
                 hint=dfcm_h)  # &c 
            ,
            dict(cid='dfcm', tp='ed', t=35, l=130, w=DLG_W - 130 - GAP)  #  
            ,
            dict(cid='walt',
                 tp='ch',
                 t=70,
                 l=GAP,
                 w=120,
                 cap=_('Compac&t list'))  # &t
            #                ,dict(cid='help',tp='bt'   ,t=DLG_H-60 ,l=DLG_W-GAP-80 ,w=80           ,cap=_('Help')                              ) #
            ,
            dict(cid='wrap',
                 tp='ch',
                 tid='!',
                 l=GAP,
                 w=120,
                 cap=_('&Wrap for next/prev'))  # &w
            ,
            dict(cid='!',
                 tp='bt',
                 t=DLG_H - 30,
                 l=DLG_W - GAP - 165,
                 w=80,
                 cap=_('Save'),
                 props='1')  #     default
            ,
            dict(cid='-',
                 tp='bt',
                 t=DLG_H - 30,
                 l=DLG_W - GAP - 80,
                 w=80,
                 cap=_('Close'))  #  
        ]  #NOTE: cfg
        focused = 'sgns'
        while True:
            act_cid, vals, chds = dlg_wrapper(_('In-text bookmarks'),
                                              DLG_W,
                                              DLG_H,
                                              cnts,
                                              dict(sgns=' '.join(
                                                  self.bm_signs),
                                                   dfcm=self.unlxr_cmnt,
                                                   wrap=self.wrap,
                                                   walt=self.show_wo_alt),
                                              focus_cid=focused)
            if act_cid is None or act_cid == '-': return  #while True
            focused = chds[0] if 1 == len(chds) else focused
            if act_cid == '!':
                if not vals['sgns'].strip():
                    app.msg_status(_('Need Bookmark sign'))
                    focused = 'sgns'
                    continue  #while
                if not vals['dfcm'].strip():
                    app.msg_status(_('Need Comment sign'))
                    focused = 'dfcm'
                    continue  #while
                if self.bm_signs != vals['sgns'].split():
                    self.bm_signs = vals['sgns'].split()
                    apx.set_opt('intextbookmk_signs', self.bm_signs)
                if self.unlxr_cmnt != vals['dfcm'].strip():
                    self.unlxr_cmnt = vals['dfcm'].strip()
                    apx.set_opt('intextbookmk_no_lexer_comment',
                                self.unlxr_cmnt)
                if self.wrap != vals['wrap']:
                    self.wrap = vals['wrap']
                    apx.set_opt('intextbookmk_wrap', self.wrap)
                if self.show_wo_alt != vals['walt']:
                    self.show_wo_alt = vals['walt']
                    apx.set_opt('intextbookmk_compact_show', self.show_wo_alt)
                break  #while
Ejemplo n.º 11
0
    def dlg_config(self):
        save_bd_col = apx.get_opt('comment_save_column', False)
        at_min_bd = apx.get_opt('comment_equal_column', False)
        move_down = apx.get_opt('comment_move_down', True)
        skip_blank = apx.get_opt('comment_skip_blank', False)
        by_1st = apx.get_opt('comment_toggle_by_nonempty', False)

        save_s = _(
            '(Line commands) Try to keep text position after (un)commenting')
        save_h = _('Try to replace only blank(s) to keep text positions:'
                   '\rUncommented lines:'
                   '\r····foo1'
                   '\r····foo2'
                   '\rCommented lines:'
                   '\r#···foo1'
                   '\r···#foo2')
        vert_s = _(
            '(Line "at non-space") If selected few lines, insert comment at maximal common indent'
        )
        vert_h = _('Use maximal common column of first non-blank char:'
                   '\rUncommented lines:'
                   '\r··foo1'
                   '\r····foo2'
                   '\r······foo3'
                   '\rCommented lines:'
                   '\r··#foo1'
                   '\r··#··foo2'
                   '\r··#····foo3')
        down_s = _('(All) Move caret to next line')
        skip_s = _('(Line commands) Skip blank lines')
        by1st_s = _(
            '"Toggle line comment" detects action by first non-blank line')

        aid, vals, chds = dlg_wrapper(
            _('Configure commenting commands'),
            610,
            160,
            [
                dict(cid='save',
                     tp='ch',
                     t=5,
                     l=5,
                     w=600,
                     cap=save_s,
                     hint=save_h)  #
                ,
                dict(cid='vert',
                     tp='ch',
                     t=5 + 25,
                     l=5,
                     w=600,
                     cap=vert_s,
                     hint=vert_h)  #
                ,
                dict(cid='down', tp='ch', t=5 + 50, l=5, w=600, cap=down_s)  #
                ,
                dict(cid='skip', tp='ch', t=5 + 75, l=5, w=600, cap=skip_s)  #
                ,
                dict(cid='by1st', tp='ch', t=5 + 100, l=5, w=600,
                     cap=by1st_s)  #
                ,
                dict(cid='!',
                     tp='bt',
                     t=130,
                     l=610 - 165 - 5,
                     w=80,
                     cap=_('OK'),
                     ex0='1')  # default
                ,
                dict(cid='-',
                     tp='bt',
                     t=130,
                     l=610 - 80 - 5,
                     w=80,
                     cap=_('Cancel'))
            ],
            dict(save=save_bd_col,
                 vert=at_min_bd,
                 down=move_down,
                 skip=skip_blank,
                 by1st=by_1st),
            focus_cid='save')
        if aid is None or aid == '-': return
        if vals['save'] != save_bd_col:
            apx.set_opt('comment_save_column', vals['save'])
        if vals['vert'] != at_min_bd:
            apx.set_opt('comment_equal_column', vals['vert'])
        if vals['down'] != move_down:
            apx.set_opt('comment_move_down', vals['down'])
        if vals['skip'] != skip_blank:
            apx.set_opt('comment_skip_blank', vals['skip'])
        if vals['by1st'] != by_1st:
            apx.set_opt('comment_toggle_by_nonempty', vals['by1st'])