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


Python GNUScreen.dumpscreen_layout方法代码示例

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


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

示例1: prepare_windows

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import dumpscreen_layout [as 别名]
def prepare_windows(scs):
    global focusminsize
    regions = None
    regions = sc.get_regions(sc.dumpscreen_layout(scs.pid))
    sc.cleanup()
    focusminsize = "%s %s" % (regions.focusminsize_x, regions.focusminsize_x)
    regions_c = len(regions.regions)
    focus_offset = regions.focus_offset
    scs.focusminsize('0 0')
    this_win_history = []
    cmd = ''
    f = open(sourcefile, 'w')
    for i in range(0, regions_c):
        f.write("""screen -t scs-regions-helper %s %s %s %d
focus
""" %
                (subprogram, subprogram_args, inputfile, i))
    f.flush()
    f.close
    scs.source(sourcefile, "screen-session regions")
    remove(sourcefile)

    regions_n = []
    regions_n = sc.get_regions(sc.dumpscreen_layout(scs.pid))
    sc.cleanup()

    for r in (regions.regions)[focus_offset:]:
        this_win_history.append(r[0])
    for r in (regions.regions)[:focus_offset]:
        this_win_history.append(r[0])

    new_windows = []
    for r in (regions_n.regions)[focus_offset:]:
        new_windows.append(r[0])
    for r in (regions_n.regions)[:focus_offset]:
        new_windows.append(r[0])

    return (this_win_history, new_windows, regions_c)
开发者ID:chronidev,项目名称:screen-session,代码行数:40,代码来源:regions.py

示例2: nest_layout

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import dumpscreen_layout [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


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