Exemple #1
0
def close_tab_from_other_group(what_grp='next'):
    if app.app_api_version() < '1.0.139': return app.msg_status(NEED_UPDATE)
    grps = apx.get_groups_count()
    if 1 == grps: return
    me_grp = ed.get_prop(app.PROP_INDEX_GROUP)
    cl_grp  = (me_grp+1)%grps \
                if what_grp=='next' else \
              (me_grp-1)%grps
    if not [
            h for h in app.ed_handles()
            if app.Editor(h).get_prop(app.PROP_INDEX_GROUP) == cl_grp
    ]:
        return app.msg_status(_('No files in group'))
    cl_ed = app.ed_group(cl_grp)
    cl_ed.focus()
    cl_ed.cmd(cmds.cmd_FileClose)
    me_ed = app.ed_group(me_grp)
    me_ed.focus()
Exemple #2
0
def _activate_tab_other_group(what_tab='next', what_grp='next'):
    grps = apx.get_groups_count()
    if 1 == grps: return
    me_grp = ed.get_prop(app.PROP_INDEX_GROUP)
    op_grp  = (me_grp+1)%grps \
                if what_grp=='next' else \
              (me_grp-1)%grps
    op_hs = [
        h for h in app.ed_handles()
        if app.Editor(h).get_prop(app.PROP_INDEX_GROUP) == op_grp
    ]
    if len(op_hs) < 2: return
    op_ed = app.ed_group(op_grp)
    op_ind = op_ed.get_prop(app.PROP_INDEX_TAB)
    op_ind  = (op_ind+1)%len(op_hs)     if what_tab=='next' else \
              (op_ind-1)%len(op_hs)     if what_tab=='prev' else \
              0                         if what_tab=='frst' else \
              len(op_hs)-1              if what_tab=='last' else \
              op_ind
    app.Editor(op_hs[op_ind]).focus()
    me_ed = app.ed_group(me_grp)
    me_ed.focus()
Exemple #3
0
    def run(self):
        global file_history
        self.ready = False
        open_files = []

        for h in ct.ed_handles():
            f = ct.Editor(h).get_filename()
            if os.path.isfile(f):
                open_files.append(f)

        items = "\t".join(open_files + file_history.items)

        self.f1 = ct.ed.get_filename()
        self.f2 = ''

        if ct.app_proc(ct.PROC_GET_GROUPING, '') == ct.GROUPS_ONE:

            # if 2 files opened in group-1, suggest these 2 files
            hh = ct.ed_handles()
            if len(hh) == 2:
                name1 = ct.Editor(hh[0]).get_filename()
                name2 = ct.Editor(hh[1]).get_filename()
                if name1 and name2:
                    self.f1 = name1
                    self.f2 = name2

        else:
            e1 = ct.ed_group(0)
            e2 = ct.ed_group(1)
            if e1 and e2:
                self.f1 = e1.get_filename()
                self.f2 = e2.get_filename()

        dlg = self.dialog(items)
        ct.dlg_proc(dlg, ct.DLG_SHOW_MODAL)
        ct.dlg_proc(dlg, ct.DLG_FREE)
        if self.ready:
            return (self.f1, self.f2)
    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()
Exemple #5
0
def get_visible_eds():
    for i in range(8):
        ed = ct.ed_group(i)
        if ed:
            yield ed
Exemple #6
0
def is_ed_visible(ed):
    gr_ed = ct.ed_group(ed.get_prop(ct.PROP_INDEX_GROUP))
    return ed == gr_ed