From 1f751a45a4c7b92bae3c34b9e85c9353ea7e4f29 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 29 Jan 2009 13:12:12 +0100 Subject: [PATCH] * screen-profiles-helper: add support for keybinding selection, LP: #321735 * debian/install, keybindings/none: install an empty set of keybindings for the "none" selection * profiles/common: strip out the automatic loading of the common keybindings now that each user sets this in their local * profiles/generate-profiles, profiles/profile.skel: drop the grep of the caption, put it the skeleton --- debian/changelog | 3 +- debian/install | 1 + keybindings/none | 1 + profiles/common | 7 ++-- profiles/generate-profiles | 1 - profiles/profile.skel | 4 +++ screen-profiles-helper | 70 +++++++++++++++++++++++++------------- 7 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 keybindings/none diff --git a/debian/changelog b/debian/changelog index 244bd38f..63dc0ae9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,8 +22,9 @@ screen-profiles (1.18) UNRELEASED; urgency=low * select-screen-profile & screen: move the environment sanitation code to the screen script, such that it is executed each time screen is run, rather than on screen profile selection only + * screen-profiles-helper: add support for keybinding selection, LP: #321735 - -- Dustin Kirkland Wed, 28 Jan 2009 19:00:19 -0500 + -- Dustin Kirkland Thu, 29 Jan 2009 12:35:44 +0100 screen-profiles (1.17-0ubuntu1) jaunty; urgency=low diff --git a/debian/install b/debian/install index 0b92dac4..abdc885a 100644 --- a/debian/install +++ b/debian/install @@ -16,6 +16,7 @@ profiles/fedora-dark usr/share/screen-profiles/profiles/misc profiles/redhat-light usr/share/screen-profiles/profiles/misc profiles/redhat-dark usr/share/screen-profiles/profiles/misc keybindings/common usr/share/screen-profiles/keybindings +keybindings/none usr/share/screen-profiles/keybindings windows/common usr/share/screen-profiles/windows screen usr/bin select-screen-profile usr/bin diff --git a/keybindings/none b/keybindings/none new file mode 100644 index 00000000..a9a29e93 --- /dev/null +++ b/keybindings/none @@ -0,0 +1 @@ +# This is intended to be a completely empty set of keybindings diff --git a/profiles/common b/profiles/common index 7fb825df..bd96ed38 100644 --- a/profiles/common +++ b/profiles/common @@ -47,11 +47,8 @@ caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%?" termcapinfo xterm* ti@:te@ defscrollback 10000 -# Default keybindings -source /usr/share/screen-profiles/keybindings/common - -# Additional, user-defined/overriding keybindings should be placed -# in each user's ~/.screenrc-keybindings +# The selected keybinding set, plus any additional user-defined/overriding +# keybindings should be placed in each user's ~/.screenrc-keybindings source ~/.screenrc-keybindings # Default windows diff --git a/profiles/generate-profiles b/profiles/generate-profiles index 1235092c..89fbb770 100755 --- a/profiles/generate-profiles +++ b/profiles/generate-profiles @@ -9,7 +9,6 @@ for i in $(ls profiles/logos); do sed -i "s/__LOGO__/$logo/" profiles/$i-light echo "Generating profile: $i-dark" cp profiles/$i-light profiles/$i-dark - grep "^caption " profiles/common >> profiles/$i-dark sed -i "s/ Wk/ Kw/g" profiles/$i-dark sed -i "s/kW/wK/g" profiles/$i-dark done diff --git a/profiles/profile.skel b/profiles/profile.skel index 4e161fc1..a74cb3aa 100644 --- a/profiles/profile.skel +++ b/profiles/profile.skel @@ -21,6 +21,10 @@ source /usr/share/screen-profiles/profiles/common +# Window tabs, second to last line +caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%?" + +# Status string, last line hardstatus string '__LOGO__%{=b Wk} %100` %{= Wk} %= %{=b bW}%102`%{= Wk} %{=b rW}%101`%{= Wk} %{= Yk}%106`%{= Wk} %{= Wk}%104`%{=b cW}%103`%{= Wk} %{=b gW}%105`,%107`%{= Wk} %Y-%m-%d %0c:%s' # NOTE: There is an arbitrary limit of being able to change colors 16 times diff --git a/screen-profiles-helper b/screen-profiles-helper index 4a24b53d..06da4359 100755 --- a/screen-profiles-helper +++ b/screen-profiles-helper @@ -68,13 +68,14 @@ def menu(screen, size, isInstalled): installtext=_("Install screen by default at login") - li = Listbox(height = 6, width = 60, returnExit = 1) + li = Listbox(height = 7, width = 60, returnExit = 1) li.append(_("Help"), 1) li.append(_("Change screen profile"), 2) - li.append(_("Change escape sequence"), 3) - li.append(_("Create new window(s)"), 4) - li.append(_("Manage default windows"), 5) - li.append(installtext, 6) + li.append(_("Change keybinding set"), 3) + li.append(_("Change escape sequence"), 4) + li.append(_("Create new window(s)"), 5) + li.append(_("Manage default windows"), 6) + li.append(installtext, 7) bb = ButtonBar(screen, ((_("Ok"), "ok"), (_("Exit"), "exit")), compact = 1) g = GridForm(screen, _("Screen Profiles Menu"), 1, 2) @@ -170,7 +171,26 @@ def profile(screen, size): return 0 return 100 - + +def keybindings(screen, size): + li = Listbox(height = 6, width = 60, returnExit = 1) + for choice in commands.getoutput('ls '+SHARE+'/keybindings').splitlines(): + li.append(choice, choice) + bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel")), compact = 1) + g = GridForm(screen, _("Which set of keybindings would you like to use?"), 1, 2) + g.add(li, 0, 0, padding=(4,2,4,2)) + g.add(bb, 0, 1, padding=(1,1,0,0)) + if bb.buttonPressed(g.runOnce()) != "cancel": + switch_keybindings(li.current()) + button = messagebox(screen, 60, 2, _("Message"), _("Restart screen to apply the new keybindings"), \ + buttons=((_("Ok"),"ok"), (_("Exit"), "exit")) ) + if button == "exit": + return 0 + return 100 + +def switch_keybindings(set): + commands.getoutput("sed -i -e 's:^source .*$:source "+SHARE+"/keybindings/"+set+":' "+HOME+"/.screenrc-keybindings") + def newwindow(screen, size): title=Entry(8, text="bash", returnExit=1) titlel=Label(_("Title: ")) @@ -190,7 +210,7 @@ def newwindow(screen, size): for cur in cmd: r.append(cur[0], count) count=count+1 - + cb=Checkbox(_("Add to default windows")) bb = ButtonBar(screen, ((_("Create"), "create"), (_("Cancel"), "cancel")), compact = 1) @@ -219,18 +239,18 @@ def newwindow(screen, size): appendwindow(win) return 100 - + def appendwindow(win): f=open(HOME+'/.screenrc-windows', 'a') try: f.write(win+"\n") - + except IOError: return None finally: f.close() - + def readwindows(): f=open(HOME+'/.screenrc-windows', 'r') try: @@ -238,7 +258,7 @@ def readwindows(): for line in f.readlines(): if line.startswith("# "): # this is a comment - window=[-1, line] + window=[-1, line] elif line.startswith("#"): # this is an inactive window window=[0, line.lstrip("#")] @@ -253,7 +273,7 @@ def readwindows(): finally: f.close() - + def writewindows(winlist): f=open(HOME+'/.screenrc-windows', 'w') try: @@ -270,10 +290,10 @@ def writewindows(winlist): finally: f.close() - + def defaultwindows(screen, size): winlist=readwindows() - + rl=Label(_("Windows:")) r=CheckboxTree(10, scroll=1) count=0 @@ -281,25 +301,25 @@ def defaultwindows(screen, size): if win[0] != -1: r.append(win[1],count,selected=win[0]) count=count+1 - + bb = ButtonBar(screen, ((_("Save"), "save"), (_("Cancel"), "cancel")), compact = 1) - + g = GridForm(screen, _("Select window(s) to create by default:"), 2, 4 ) g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4,0,0,1)) g.add(r, 1, 0) g.add(bb, 1, 1, padding=(4,1,0,0)) - + if bb.buttonPressed(g.runOnce()) != "cancel": count=0 for win in winlist: if win[0] != -1: win[0] = r.getEntryValue(count)[1] count=count+1 - + writewindows(winlist) - + return 100 - + def install(screen, size, isInstalled): if not isInstalled: out = commands.getoutput("bash /usr/share/screen-profiles/screen-launcher-install") @@ -430,13 +450,15 @@ def main(): tag = help(screen, size, config) elif tag == 2: tag = profile(screen, size) - elif tag == 3: + elif tag == 3: + tag = keybindings(screen, size) + elif tag == 4: tag = chgesc(screen, size) - elif tag == 4: - tag = newwindow(screen, size) elif tag == 5: - tag = defaultwindows(screen, size) + tag = newwindow(screen, size) elif tag == 6: + tag = defaultwindows(screen, size) + elif tag == 7: tag = install(screen, size, isInstalled) isInstalled=(tag == 100)