Meta key support

4 views
Skip to first unread message

satya

unread,
Oct 21, 2008, 6:27:46 PM10/21/08
to leo-editor
Hi,

I am just getting started on learning Leo.

I have a keyboard with a real Meta key on a Linux system. I have bound
a lot of window-manager functions to the Alt key. Leo seemed to have
only the ability to support Alt, but not Meta. I naiively added Meta
wherever Alt was mentioned in leoKeys.py (patch attached). The result
seems to work. Please see if this is something you would like to
include in the official version.

Thanks,
Satya


=== modified file 'leo/core/leoKeys.py'
--- leo/core/leoKeys.py 2008-10-05 02:37:18 +0000
+++ leo/core/leoKeys.py 2008-10-21 22:02:34 +0000
@@ -2455,6 +2455,7 @@
#@+node:ekr.20061031131434.106:<< define specialKeysyms >>
specialKeysyms = (
'Alt_L','Alt_R',
+ 'Meta_L','Meta_R',
'Caps_Lock','Control_L','Control_R',
'Num_Lock',
'Shift_L','Shift_R',
@@ -2859,6 +2860,7 @@
sep = '-' * n1
for prefix in (
'Alt+Ctrl+Shift', 'Alt+Shift', 'Alt+Ctrl', 'Alt
+Key','Alt',
+ 'Meta+Ctrl+Shift', 'Meta+Shift', 'Meta+Ctrl', 'Meta
+Key','Meta',
'Ctrl+Shift', 'Ctrl', 'Shift',
):
data2 = []
@@ -3267,6 +3269,7 @@

special_keys = (
'Alt_L','Alt_R',
+ 'Meta_L','Meta_R',
'Caps_Lock','Control_L','Control_R',
'Num_Lock',
'Shift_L','Shift_R',
@@ -4394,7 +4397,7 @@

k = self ; shortcut = shortcut or ''

- for s in ('Alt','Ctrl','Command'):
+ for s in ('Alt','Ctrl','Command', 'Meta'):
if shortcut.find(s) != -1:
return False
else:
@@ -4428,6 +4431,7 @@
cmd = s2.find("cmd") >= 0 or s2.find("command") >= 0
ctrl = s2.find("control") >= 0 or s2.find("ctrl") >= 0
alt = s2.find("alt") >= 0
+ meta = s2.find("meta") >= 0
shift = s2.find("shift") >= 0 or s2.find("shft") >= 0
#@-node:ekr.20061031131434.185:<< define cmd, ctrl, alt,
shift >>
#@nl
@@ -4487,6 +4491,7 @@
#@+node:ekr.20061031131434.189:<< compute shortcut >>
table = (
(alt, 'Alt+'),
+ (meta, 'Meta+'),
(ctrl,'Ctrl+'),
(cmd, 'Command+'),
(shift,'Shift+'),
@@ -4512,6 +4517,7 @@

for a,b in (
('Alt+','Alt-'),
+ ('Meta+','Meta-'),
('Ctrl-','Control-'),
('Ctrl+','Control-'), # New in Leo 4.5.
('Shift+','Shift-'),
@@ -4826,6 +4832,7 @@
k.updateLabel(event)
elif stroke == '<Key>' and keysym in (
'Alt_L','Alt_R',
+ 'Meta_L','Meta_R',
'Control_L','Control_R',
'Shift_L','Shift_R',
):

Edward K. Ream

unread,
Oct 22, 2008, 9:04:01 AM10/22/08
to leo-e...@googlegroups.com
On Tue, Oct 21, 2008 at 5:27 PM, satya <quf...@gmail.com> wrote:

> only the ability to support Alt, but not Meta. I naively added Meta wherever Alt was mentioned in leoKeys.py (patch attached). The result seems to work. Please see if this is something you would like to include in the official version.

Thanks for this. Yes, I'll add it soon.

BTW, I often use the "naive" approach you used. Many times it works
without "true" understanding of the code. For example, much (not
all!) of the qt plugin work involves running code and fixing whatever
crashes show up :-)

Edward

Edward K. Ream

unread,
Oct 22, 2008, 9:26:08 AM10/22/08
to leo-editor
On Oct 22, 8:04 am, "Edward K. Ream" <edream...@gmail.com> wrote:
> On Tue, Oct 21, 2008 at 5:27 PM, satya <quf...@gmail.com> wrote:
> > only the ability to support Alt, but not Meta. I naively added Meta wherever Alt was mentioned in leoKeys.py (patch attached). The result seems to work. Please see if this is something you would like to include in the official version.
>
> Thanks for this.  Yes, I'll add it soon

Your patches are on the trunk at rev 1230. All unit tests pass, but I
manually patched the code. Feel free to make any changes/corrections
to the trunk using bzr.

Edward

satya

unread,
Oct 22, 2008, 11:29:34 AM10/22/08
to leo-editor
Edward,

Thank you for lightning speed support.

I am still rather new to bzr, so didn't feel comfortable pushing it
that way. If I find anything else that I want, I'll be sure to check
into that.

Satya

Edward K. Ream

unread,
Oct 22, 2008, 11:38:47 AM10/22/08
to leo-e...@googlegroups.com
On Wed, Oct 22, 2008 at 10:29 AM, satya <quf...@gmail.com> wrote:

> Thank you for lightning speed support.

Patches always get my attention.

Edward

Reply all
Reply to author
Forward
0 new messages