本文整理汇总了Python中GNUScreen.gen_layout_info方法的典型用法代码示例。如果您正苦于以下问题:Python GNUScreen.gen_layout_info方法的具体用法?Python GNUScreen.gen_layout_info怎么用?Python GNUScreen.gen_layout_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GNUScreen
的用法示例。
在下文中一共展示了GNUScreen.gen_layout_info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __save_layouts
# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_layout_info [as 别名]
def __save_layouts(self):
(homelayout, homelayoutname) = self.get_layout_number()
findir = sc.datadir
if homelayout == -1:
sys.stderr.write("No layouts to save.\n")
return False
path_layout = os.path.join(findir, "load_layout")
oflayout = open(path_layout, "w")
ex_lay = []
for lay in sc.gen_layout_info(self, sc.dumpscreen_layout_info(self)):
try:
num = lay[0]
title = lay[1]
except:
title = ""
if self.excluded_layouts and (num in self.excluded_layouts or title in self.excluded_layouts):
ex_lay.append(lay)
else:
sys.stdout.write("%s(%s); " % (num, title))
oflayout.write(
"""layout select %s
layout dump \"%s\"
dumpscreen layout \"%s\"
"""
% (num, os.path.join(findir, "layout_" + num), os.path.join(findir, "winlayout_" + num))
)
oflayout.write("layout select %s\n" % homelayout)
oflayout.close()
self.source(path_layout)
util.remove(path_layout)
linkify(findir, "layout_" + homelayout, "last_layout")
if ex_lay:
sys.stdout.write(
"""
Excluded layouts: %s"""
% str(ex_lay)
)
out("")
return True
示例2: run
# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_layout_info [as 别名]
def run(session, requirecleanup_win, requirecleanup_lay, curwin, curlay,
height, select_other = False):
global lock_and_com_file, mru_file
lltmpdir = os.path.join(tmpdir, '___layoutlist')
try:
os.makedirs(lltmpdir)
except:
pass
signal.signal(signal.SIGINT, handler)
session = session.split('.', 1)[0]
ret = 0
ss = ScreenSaver(session)
wnum = os.getenv('WINDOW')
if requirecleanup_lay:
lnum = ss.get_layout_number()[0]
else:
lnum = None
mru_file = os.path.join(lltmpdir, '%s_MRU' % session)
if select_other:
mru_layouts = pickle.load(open(mru_file, 'r'))
num, title = mru_layouts[1]
tmp = mru_layouts[0]
mru_layouts[0] = mru_layouts[1]
mru_layouts[1] = tmp
ss.command_at(False, 'eval "layout select %s" "layout title"' %
num)
pickle.dump(mru_layouts, open(mru_file, 'w'))
return ret
if NO_END:
lock_and_com_file = os.path.join(lltmpdir, '%s' %
session)
f = open(lock_and_com_file, 'w')
f.write(str(os.getpid()) + '\n')
if requirecleanup_win and not requirecleanup_lay:
f.write(wnum + '\n')
else:
f.write('-1\n')
if requirecleanup_lay:
f.write(lnum + '\n')
else:
f.write('-1\n')
f.close()
try:
try:
layinfo = list(sc.gen_layout_info(ss, sc.dumpscreen_layout_info(ss)))
finally:
sc.cleanup()
except:
sys.stderr.write('Layouts dumping error.\n')
return 1
screen = curses.initscr()
(laytable, pos_start) = create_table(ss, screen, curlay, layinfo,
lnum, height)
try:
curses.start_color()
except:
curses.endwin()
sys.stderr.write('start_color() failed!\n')
return 1
curses.noecho()
#screen.notimeout(1)
try:
choice = menu_table(
ss,
screen,
lnum,
curwin,
curlay,
layinfo,
laytable,
pos_start[0],
pos_start[1],
height,
)
if requirecleanup_lay and choice == lnum:
choice = curlay
except Exception:
import traceback
traceback.print_exc(file=sys.stderr)
choice = curlay
ret = 1
curses.endwin()
if NO_END:
from util import remove
remove(lock_and_com_file)
if requirecleanup_lay:
ss.command_at(False,
'eval "layout select %s" "layout remove %s" "at \"%s\#\" kill" "layout title"' %
(choice, lnum, wnum))
elif requirecleanup_win:
ss.command_at(False,
'eval "select %s" "layout select %s" "at \"%s\#\" kill" "layout title"' %
(curwin, choice, wnum))
#.........这里部分代码省略.........
示例3: menu_table
# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import gen_layout_info [as 别名]
#.........这里部分代码省略.........
x = screen.getch()
# layout list refresh ^C ^L ^R
if x in (-1, 12, 18) or x in (ord('r'), ord('R')) and not searching_title and \
not searching_num:
if laytable_c:
current_view = 'n'
pos_x = pos_x_c
pos_y = pos_y_c
pos_x_c = pos_y_c = layinfo_c = laytable_c = None
(y, x) = screen.getmaxyx()
searching_title = False
searching_num = False
try:
try:
try:
if NO_END:
f = open(lock_and_com_file, 'r')
from string import strip as str_strip
#pid,cwin,clay,MAXTITLELEN,height = map( str_strip,f.readlines() )
nd = map(str_strip, f.readlines())
curwin = nd[3]
sel_num = curlay = nd[4]
MAXTITLELEN = int(nd[5])
height = int(nd[6])
f.close()
screen.erase()
mru_add(curlay)
except:
pass
layinfo = list(sc.gen_layout_info(ss, sc.dumpscreen_layout_info(ss)))
(laytable, pos_start) = create_table(ss, screen,
curlay, layinfo, tmplay, height)
errormsg = 'Refreshed'
finally:
sc.cleanup()
except:
errormsg = 'Layouts dumping error.'
elif searching_title and x == ord('\n'):
searching_title = False
n_search_title = search_title
findNext = True
elif x == 27:
# Escape key
searching_num = False
searching_title = False
search_num = None
search_title = None
errormsg = 'Canceled'
n_search_title = search_title
elif x == curses.KEY_BACKSPACE:
try:
if len(search_num) == 0:
raise Exception
search_num = search_num[:-1]
except:
searching_num = False
pass
try:
if len(search_title) == 0:
raise Exception