Пример #1
0
    def config(self):

        ct.ini_write(fn_config, "op", "color_comma", option_color_comma)
        ct.ini_write(fn_config, "op", "colors_fixed", option_colors_fixed)
        ct.ini_write(fn_config, "op", "colors_themed", option_colors_themed)
        ct.ini_write(fn_config, "op", "use_theme_colors", bool_to_str(option_use_theme_colors))
        ct.ini_write(fn_config, "op", "separator", option_separator)
        ct.file_open(fn_config)
Пример #2
0
	def compact_to_tab(self):
		plain_rpt	= get_str_report()
		if False:pass
		elif app_name=='CudaText':
			app.file_open('')
			ed.set_text_all(plain_rpt)
		elif app_name=='SynWrite':
			pass
Пример #3
0
 def goto_file(self, filename, row, col=0):
     """open definition file and mark line"""
     if not os.path.isfile(filename):
         return
     ct.file_open(filename)
     ct.ed.set_prop(ct.PROP_LINE_TOP, str(max(0, row - 5)))  # 5 = Offset
     ct.ed.set_caret(col, row - 1)
     ct.msg_status('Goto "%s", Line %d' % (filename, row))
     return True
Пример #4
0
	def compact_to_tab(self):
		if app_name=='CudaText' and app.app_api_version()<'1.0.212':     # depr PROC_GET_COMMAND, PROC_GET_COMMAND_PLUGIN
			app.msg_box(_('Plugin needs newer app version'), app.MB_OK)
			return
		plain_rpt	= get_str_report()
		if False:pass
		elif app_name=='CudaText':
			app.file_open('')
			ed.set_text_all(plain_rpt)
		elif app_name=='SynWrite':
			pass
Пример #5
0
	def compact_to_tab(self):
		if app_name=='CudaText' and app.app_api_version()<'1.0.212':     # depr PROC_GET_COMMAND, PROC_GET_COMMAND_PLUGIN
			app.msg_box('Plugin needs newer app version', app.MB_OK)
			return
		plain_rpt	= get_str_report()
		if False:pass
		elif app_name=='CudaText':
			app.file_open('')
			ed.set_text_all(plain_rpt)
		elif app_name=='SynWrite':
			pass
Пример #6
0
 def save_and_open(path):
     fvdata['fv_tab']    = tabs
     fvdata['fv_files']  = files
     fvdata['fv_projs']  = projs
     fvdata['fv_fold' ]  = fold 
     fvdata['fv_last' ]  = last 
     save_fav_data(fvdata)
     if os.path.isdir( path):
         path= app.dlg_file(True, '', path, '')
         if not path:    return False
     app.file_open(path)
     return True
Пример #7
0
def goto_file(filename, num_line, num_col):
    if not os.path.isfile(filename):
        return
    filename = str(filename)

    ct.file_open(filename, options="/nohistory")

    # needed because edaction_show_pos don't scroll w/o it
    ct.app_idle(False)
    ct.ed.action(ct.EDACTION_SHOW_POS, (num_col, num_line), (0, LINE_GOTO_OFFSET))
    ct.ed.set_caret(num_col, num_line, options=ct.CARET_OPTION_UNFOLD)

    ct.msg_status('Go to file: '+filename)
Пример #8
0
    def do_rprt(self, aid, ag, data=''):
        m,M         = self,self.__class__
        if False:pass
        elif aid=='trpt':
            # Compact report to tab
            app.file_open('')
            ed.set_text_all(get_str_report())

        elif aid=='hrpt':
            # Full report to HTML
            htm_file = os.path.join(tempfile.gettempdir(), '{}_keymapping.html'.format(app_name))
            do_report(htm_file)
            webbrowser.open_new_tab('file://'+htm_file)
            app.msg_status(_('Opened browser with file ')+htm_file)
        return []
Пример #9
0
    def do_rprt(self, aid, ag):
        m,M         = self,CfgKeysDlg
        if False:pass
        elif aid=='trpt':
            # Compact report to tab
            app.file_open('')
            ed.set_text_all(get_str_report())

        elif aid=='hrpt':
            # Full report to HTML
            htm_file = os.path.join(tempfile.gettempdir(), '{}_keymapping.html'.format(app_name))
            do_report(htm_file)
            webbrowser.open_new_tab('file://'+htm_file)
            app.msg_status(_('Opened browser with file ')+htm_file)
        return []
Пример #10
0
 def do_code(self, aid, ag):
     m,M         = self,CfgKeysDlg
     
     lwks_n  = ag.cval('lwks')
     if lwks_n==-1:                      return [] #continue#while
     m.cmd_id  = m.fl_Is[lwks_n]
     pass;                  #LOG and log('m.fl_Is={}',(m.fl_Is))
     pass;                  #LOG and log('lwks_n,m.cmd_id={}',(lwks_n,m.cmd_id))
     if False:pass
     elif aid=='cpnm':
         cmd_nkk = m.id2nkks[m.cmd_id]
         app.app_proc(app.PROC_SET_CLIP, cmd_nkk[0])
     
     elif aid=='open':
         pass;               LOG and log('m.cmd_id={}',(m.cmd_id))
         if type(m.cmd_id)!=str:         return [] #continue#while
         plug_mdl,   \
         plug_mth    = m.cmd_id.split(',')[0:2]
         plug_mth    = 'def '+ plug_mth + '(self):'
         plug_dir    = app.app_path(app.APP_DIR_PY)+os.sep+plug_mdl
         plug_py     = plug_dir+os.sep+'__init__.py'
         plug_body   = open(plug_py, encoding='UTF-8').read()
         pass;               LOG and log('plug_mdl,plug_mth,plug_dir,plug_py={}',(plug_mdl,plug_mth,plug_dir,plug_py))
         mch         = re.search(r'from\s+\.(\w+)\s+import\s+Command', plug_body)
         if mch:
             # from .other_py import Command
             plug_py = plug_dir+os.sep+mch.group(1)+'.py'
             pass;           LOG and log('plug_py={}',(plug_py))
             plug_body=open(plug_py, encoding='UTF-8').read()
         if plug_mth not in plug_body:   return [] #continue#while
         # Open
         app.file_open(plug_py)
         # Locate
         user_opt= app.app_proc(app.PROC_GET_FINDER_PROP, '') \
                     if app.app_api_version()>='1.0.248' else \
                   app.app_proc(app.PROC_GET_FIND_OPTIONS, '')   # Deprecated
         ed.cmd(cmds.cmd_FinderAction, chr(1).join([]
             +['findnext']
             +[plug_mth]
             +['']
             +['fa']
         ))
         if app.app_api_version()>='1.0.248':
             app.app_proc(app.PROC_SET_FINDER_PROP, user_opt)
         else:
             app.app_proc(app.PROC_SET_FIND_OPTIONS, user_opt)   # Deprecated
         return None #break#while
     return []
Пример #11
0
 def do_code(self, aid, ag, data=''):
     m,M         = self,self.__class__
     
     lwks_n  = ag.cval('lwks')
     if lwks_n==-1:                      return [] #continue#while
     m.cmd_id  = m.fl_Is[lwks_n]
     pass;                  #LOG and log('m.fl_Is={}',(m.fl_Is))
     pass;                  #LOG and log('lwks_n,m.cmd_id={}',(lwks_n,m.cmd_id))
     if False:pass
     elif aid=='cpnm':
         cmd_nkk = m.id2nkks[m.cmd_id]
         app.app_proc(app.PROC_SET_CLIP, cmd_nkk[0])
     
     elif aid=='open':
         pass;               LOG and log('m.cmd_id={}',(m.cmd_id))
         if type(m.cmd_id)!=str:         return [] #continue#while
         plug_mdl,   \
         plug_mth    = m.cmd_id.split(',')[0:2]
         plug_mth    = 'def '+ plug_mth + '(self):'
         plug_dir    = app.app_path(app.APP_DIR_PY)+os.sep+plug_mdl
         plug_py     = plug_dir+os.sep+'__init__.py'
         plug_body   = open(plug_py, encoding='UTF-8').read()
         pass;               LOG and log('plug_mdl,plug_mth,plug_dir,plug_py={}',(plug_mdl,plug_mth,plug_dir,plug_py))
         mch         = re.search(r'from\s+\.(\w+)\s+import\s+Command', plug_body)
         if mch:
             # from .other_py import Command
             plug_py = plug_dir+os.sep+mch.group(1)+'.py'
             pass;           LOG and log('plug_py={}',(plug_py))
             plug_body=open(plug_py, encoding='UTF-8').read()
         if plug_mth not in plug_body:   return [] #continue#while
         # Open
         app.file_open(plug_py)
         # Locate
         user_opt= app.app_proc(app.PROC_GET_FINDER_PROP, '') \
                     if app.app_api_version()>='1.0.248' else \
                   app.app_proc(app.PROC_GET_FIND_OPTIONS, '')   # Deprecated
         ed.cmd(cmds.cmd_FinderAction, chr(1).join([]
             +['findnext']
             +[plug_mth]
             +['']
             +['fa']
         ))
         if app.app_api_version()>='1.0.248':
             app.app_proc(app.PROC_SET_FINDER_PROP, user_opt)
         else:
             app.app_proc(app.PROC_SET_FIND_OPTIONS, user_opt)   # Deprecated
         return None #break#while
     return []
Пример #12
0
def _file_open(op_file):
    if not app.file_open(op_file):
        return None
    for h in app.ed_handles(): 
        op_ed   = app.Editor(h)
        if os.path.samefile(op_file, op_ed.get_filename()):
            return op_ed
    return None
Пример #13
0
    def plain_tasks_new(self):

        lexname = ct.ed.get_prop(ct.PROP_LEXER_FILE)
        if lexname != MYLEXER:
            ct.file_open('')
            ct.ed.insert(0, 0, self.cfg.task_bullet_open + ' ')
            ct.ed.set_caret(2, 0)
            ct.ed.set_prop(ct.PROP_LEXER_FILE, MYLEXER)
            return

        first, last = self.get_selection_rows()

        for n in range(first, last + 1):
            line = ct.ed.get_text_line(n)
            indent = get_indent(line)
            if any([
                    self.parser.isitem(line),
                    self.parser.isheader(line),
                    self.parser.isseparator(line)
            ]):
                if n == last:
                    offset = ''
                    if self.parser.isheader(line) or self.parser.isseparator(
                            line):
                        offset = self.indent()
                    if self.cfg.add_created_tag:
                        created_tag = self.cfg.space_before_tag + self.make_tag_with_date(
                            '@created')
                    else:
                        created_tag = ''

                    new_line = ''.join([
                        line[:indent], offset, self.cfg.task_bullet_open, ' ',
                        created_tag
                    ])
                    ct.ed.insert(len(line), n, '\n' + new_line)
                    ct.ed.set_caret(len(new_line) - len(created_tag), n + 1)
            else:
                ct.ed.insert(indent, n, self.cfg.task_bullet_open + ' ')
                if n == last:
                    ct.ed.set_caret(len(ct.ed.get_text_line(n)), n)
Пример #14
0
    def set_files(self, *files):
        for f in files:
            for h in ct.ed_handles():
                e = ct.Editor(h)
                file_name = e.get_filename()
                if file_name == f:
                    if e.get_prop(ct.PROP_MODIFIED):
                        text = 'First you must save file:\n' + \
                                file_name + \
                               '\nYES: save and continue\n' + \
                               "NO: don't save (changes will be lost)"
                        mb = ct.msg_box(text,
                                        ct.MB_YESNOCANCEL + ct.MB_ICONQUESTION)
                        if mb == ct.ID_YES:
                            e.save(file_name)
                        elif mb == ct.ID_NO:
                            e.set_prop(ct.PROP_MODIFIED, False)
                        else:
                            return
                    e.focus()
                    e.cmd(ct_cmd.cmd_FileClose)

                    ct.app_idle(True)  # better close file
                    sleep(0.3)
                    ct.app_idle(True)  # better close file
                    break

        ct.file_open(files, options='/nohistory')

        # if file was in group-2, and now group-2 is empty, set "one group" mode
        if ct.app_proc(ct.PROC_GET_GROUPING,
                       '') in [ct.GROUPS_2VERT, ct.GROUPS_2HORZ]:
            e = ct.ed_group(1)  # Editor obj in group-2
            if not e:
                ct.app_proc(ct.PROC_SET_GROUPING, ct.GROUPS_ONE)

        self.refresh()
Пример #15
0
    def config(self):

        if os.path.isfile(ini):
            app.file_open(ini)
 def config(self):
   do_save_ops()
   if os.path.isfile(fn_ini):
     app.file_open(fn_ini)
   else:
     app.msg_status('Config file not found')
Пример #17
0
 def config(self):
     ct.ini_write(cfg_file, cfg_section, cfg_opt_menu_w, str(opt_menu_w))
     ct.ini_write(cfg_file, cfg_section, cfg_opt_menu_h, str(opt_menu_h))
     ct.file_open(cfg_file)