当前位置: 首页>>代码示例>>Python>>正文


Python GNUScreen.layout_end方法代码示例

本文整理汇总了Python中GNUScreen.layout_end方法的典型用法代码示例。如果您正苦于以下问题:Python GNUScreen.layout_end方法的具体用法?Python GNUScreen.layout_end怎么用?Python GNUScreen.layout_end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GNUScreen的用法示例。


在下文中一共展示了GNUScreen.layout_end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: nest_layout

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import layout_end [as 别名]
def nest_layout(session, src_layuot, dst_layout):
    src_dumpfile = os.path.join(tmpdir_source, 'nest_layout-dump-%d' % os.getpid())

    if not os.path.exists(tmpdir_source):
        os.makedirs(tmpdir_source)

    scs = ScreenSaver(session)

    print('layouts src: %s dst: %s' % (src_layout, dst_layout))

    regions_file_dst = regions_file = sc.dumpscreen_layout(scs.pid)
    regions_dst = sc.get_regions(regions_file)

    dst_focusminsize = "%s %s" % (regions_dst.focusminsize_x, regions_dst.focusminsize_y)
    dst_rsize = (int(regions_dst.regions[regions_dst.focus_offset][1]),
                int(regions_dst.regions[regions_dst.focus_offset][2]))
    dst_term_size = (int(regions_dst.term_size_x),
                    int(regions_dst.term_size_y))
    scs.layout('select %s' % src_layout, False)

    scs.layout('dump %s' % src_dumpfile, False)

    regions_file_src = sc.dumpscreen_layout(scs.pid)
    regions_src = sc.get_regions(regions_file_src)

    src_term_size = (int(regions_src.term_size_x), int(regions_src.term_size_y))

    print ('dst_rsize: %s' % str(dst_rsize))
    print ('src_term_size: %s' % str(src_term_size))

    scs.layout('select %s' % dst_layout, False)
    
    regions_new = sc.Regions()
    regions_new.focus_offset =  regions_dst.focus_offset + regions_src.focus_offset
    regions_new.term_size_x = regions_dst.term_size_x
    regions_new.term_size_y = regions_dst.term_size_y
    regions_new.focusminsize_x = regions_dst.focusminsize_x
    regions_new.focusminsize_y = regions_dst.focusminsize_y
    regions_new.regions = regions_dst.regions[:regions_dst.focus_offset]

    for (window, sizex, sizey) in regions_src.regions:
        print('SRC REGION' + str((window,sizex,sizey)))
        x = (int(sizex) * dst_rsize[0]) / src_term_size[0]
        y = (int(sizey) * dst_rsize[1]) / src_term_size[1]
        print( '%s * %d / %d = %d' % (sizex, dst_rsize[0], src_term_size[0], x))
        print( '%s * %d / %d = %d' % (sizey, dst_rsize[1], src_term_size[0], y))
        regions_new.regions.append((window, str(x), str(y)))

    regions_new.regions = regions_new.regions + regions_dst.regions[regions_dst.focus_offset+1:]
    
    print('destination regions: '+ str(regions_dst.regions))
    print('source regions: ' + str(regions_src.regions))
    print('new regions: ' + str(regions_new.regions))

    sc.layout_begin(session)
    sc.layout_load_dump(open(src_dumpfile, 'r'))
    sc.layout_load_regions(regions_new, None, dst_term_size[0], dst_term_size[1])
    sc.layout_end()

    remove(src_dumpfile)
    remove(regions_file_dst)
    remove(regions_file_src)
    sc.cleanup()
开发者ID:chronidev,项目名称:screen-session,代码行数:65,代码来源:nest_layout.py

示例2: map

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import layout_end [as 别名]
            elif targ < 0:
                ld = layhist.undo[abs(targ)-1][1]
            else:
                ld = layhist.current[0]
        except IndexError:
            ld = layhist.current[0]
            targ = 0

        cur = layhist.current[0]
        term_x, term_y = map(int, ss.dinfo()[0:2])
        lay_f = sc.layout_begin(session)
        lay_f.write('only\n')
        sc.layout_load_dump(open(os.path.join(ld, layout_dump), 'r'))
        sc.layout_load_regions(sc.get_regions(os.path.join(ld, layout_regions)),
                None, term_x, term_y)
        sc.layout_end()

        os.rename(ld, os.path.join(tdir, os.path.basename(ld)))
        if targ > 0:
            ss.Xecho('layout redo ( %d left )' % (len(layhist.redo) - 1))
            os.rename(cur, os.path.join(tdir_u,
                os.path.basename(cur)))
        elif targ < 0:
            ss.Xecho('layout undo ( %d left )' % (len(layhist.undo) - 1))
            os.rename(cur, os.path.join(tdir_r,
                os.path.basename(cur)))
        else:
            ss.Xecho('layout current ( undo: %d redo: %d )' %
                    (len(layhist.undo), len(layhist.redo)))

    elif mode == 'history':
开发者ID:chronidev,项目名称:screen-session,代码行数:33,代码来源:layout.py

示例3: __load_layouts

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import layout_end [as 别名]
    def __load_layouts(self):
        cdinfo = map(int, self.dinfo()[0:2])
        out("Terminal size: %s %s" % (cdinfo[0], cdinfo[1]))
        homewindow = self.homewindow
        (homelayout, homelayoutname) = self.get_layout_number()
        layout_trans = {}
        layout_c = len(glob.glob(os.path.join(self.basedir, self.savedir, "winlayout_*")))
        if layout_c > 0:
            self.__layouts_loaded = True
        lc = 0
        layout_file = sc.layout_begin(self.pid)
        while lc < layout_c:
            filename = None
            try:
                filename = glob.glob(os.path.join(self.basedir, self.savedir, "layout_%d" % lc))[0]
                layoutnumber = filename.rsplit("_", 1)[1]
                (head, tail) = os.path.split(filename)

                # the winlayout_NUM files contain "dumpscreen layout" output
                # (see GNUScreen.Regions class)

                filename2 = os.path.join(head, "win" + tail)
                regions = sc.get_regions(filename2)
                status = self.get_layout_new(regions.title)
                if not status:
                    sys.stderr.write(
                        "\nMaximum number of layouts reached. Ignoring layout %s (%s).\n"
                        % (layoutnumber, regions.title)
                    )
                    break
                else:
                    if self.exact:
                        self.layout("number %s" % layoutnumber, False)
                        currentlayout = layoutnumber
                    else:
                        currentlayout = self.get_layout_number()[0]
                    layout_trans[layoutnumber] = currentlayout

                    sc.layout_select_layout(currentlayout)
                    # source the output produced by "layout dump"
                    sc.layout_load_dump(open(filename, "r"))

                    regions_size = []
                    winlist = []

                    for (window, sizex, sizey) in regions.regions:
                        winlist.append(window)
                        regions_size.append((sizex, sizey))
                    sc.layout_load_regions(regions, self.__wins_trans, cdinfo[0], cdinfo[1])
                    # sys.stdout.write(" %s (%s);" % (layoutnumber, regions.title))
            except:
                # import traceback
                # traceback.print_exc(file=sys.stderr)
                # raise
                layout_c += 1
                if layout_c > 2000:
                    sys.stderr.write("\nErrors during layouts loading.\n")
                    break
            lc += 1
        out("")
        if not lc == 0:

            # select last layout

            lastname = None
            lastid_l = None

            if homelayout != -1:
                out("Returning homelayout %s" % homelayout)
                layout_file.write("layout select %s" % homelayout)
            else:
                sys.stderr.write("No homelayout - unable to return.\n")

            if os.path.exists(os.path.join(self.basedir, self.savedir, "last_layout")) and len(layout_trans) > 0:
                last = os.readlink(os.path.join(self.basedir, self.savedir, "last_layout"))
                (lasthead, lasttail) = os.path.split(last)
                last = lasttail.split("_", 2)
                lastid_l = last[1]
                try:
                    out("Selecting last layout: %s (%s)" % (layout_trans[lastid_l], lastid_l))
                    layout_file.write("layout select %s" % layout_trans[lastid_l])
                    # ^^ layout numbering may change, use layout_trans={}
                except:
                    sys.stderr.write("Unable to select last layout %s\n" % lastid_l)
        else:
            self.enable_layout = False
        sc.layout_end()
开发者ID:rlabok,项目名称:screen-session,代码行数:89,代码来源:ScreenSaver.py


注:本文中的GNUScreen.layout_end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。