Shift+F4 doesn't work in Midnight Commander

494 views
Skip to first unread message

vlkv

unread,
Nov 16, 2010, 12:45:07 PM11/16/10
to terminator-users
Hi everybody!
I start using terminator a few days ago, and I like its features very
much!

But Shift+F4 doesn't work in Midnight Commander. Also in mc I cannot
switch keyboard layout between
english and russian languages. Can somebody tell me how to resolve
this?

Thanks in advance.

Ben Longbons

unread,
Nov 16, 2010, 4:35:51 PM11/16/10
to terminator-users
The first problem is undoubtedly hard-coded input (since terminfo
doesn't provide a practical way to get it), which we get wrong:

xterm generates ESC [ 1 ; 2 S
terminator generates ESC O 1 ; 2 S
ESC O is SS3 and should be followed only by a single character.

For the second, if I understand the question correctly, it relates to
charsets, and Terminator always uses UTF-8, so it is language-neutral.
Exactly what do you intend to accomplish by switching keyboard layouts?

Elliott Hughes

unread,
Nov 16, 2010, 10:17:21 PM11/16/10
to terminator-users


On Nov 16, 1:35 pm, Ben Longbons <brlongb...@gmail.com> wrote:
> The first problem is undoubtedly hard-coded input (since terminfo
> doesn't provide a practical way to get it), which we get wrong:
>
> xterm generates ESC [ 1 ; 2 S
> terminator generates ESC O 1 ; 2 S
> ESC O is SS3 and should be followed only by a single character.

Ben provided a patch to fix this, committed as r1627, so tomorrow
morning [California time] Terminator should produce the right
sequences. mc(1) doesn't work for me, though, even though it does
under xterm(1), though my use of an Apple keyboard (where you use
shift-fn-f1 to get f1, et cetera) might have something to do with
that.

--elliott

Martin Dorey

unread,
Nov 17, 2010, 11:02:45 AM11/17/10
to terminat...@googlegroups.com, vit...@gmail.com
For me, mc doesn't seem to do anything sensible with the shifted function keys, even under xterm. Perhaps the OP had taught it about xterm's sequences and bound them to something useful. A quick browse of the help suggested that it has UI for that. If so, that should now work for us too. Well, the nightly build isn't done yet, but it will work in an hour and a half.

I think the OP's second issue is more likely to do with our use of key_pressed instead of key_typed than it is to do with charsets, but only the OP can tell us. Adding him explicitly, as milkman googlegroups has long since dropped him.
--
You received this message because you are subscribed to the Google Groups "terminator-users" group.
To post to this group, send email to terminat...@googlegroups.com.
To unsubscribe from this group, send email to terminator-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/terminator-users?hl=en.

vlkv

unread,
Nov 17, 2010, 12:40:27 PM11/17/10
to terminator-users
Sorry for the second problem. Yesterday I couldn't switch keyboard
layout from english to russian to type russian text (but in other
applications I could). But now it works, so this problem I think not
related to terminator.

vlkv

unread,
Nov 17, 2010, 4:03:32 PM11/17/10
to terminator-users
Oh, no! The second problem has returned back... After some
experimentng I've discovered how to reproduce this bug.
If in terminator preferences option "Use Alt key as meta key (for
Emacs)" is unchecked, then there is no problem in switching keyboard
layouts.
When I press capslock key I switch (toggle) between english and
russian layouts of my keyboard. But, in this mode I cannot use Alt+i
keyboard shortcut in Midnight Commander (very usefull shortcut for me
also). Alt+i instead of syncronizing current working directory on both
mc panels, invokes "Show info" terminator dialog (because this is a
terminator shortcut also).

So I went to the preferences dialog, checked up option "Use Alt key as
meta key (for Emacs)" and restarted terminator. After this I can use
Alt+i shortcut in mc and it works and syncronizes working directories
in both panels. But this time, I cannot switch my keyboard layouts
with capslock key!

For keyboard layout switching I use xkb, here is fragment of my
xorg.conf:

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us,ru"
Option "XkbVariant" ","
Option "XkbOptions"
"grp:caps_toggle,grp_led:scroll"
EndSection

Maybe the easiest thing that can be done here is to change terminator
shortcut for "Show info" from Alt+i to something else, how do you
think?

Thank you very much for your feedback :)

Ben Longbons

unread,
Nov 17, 2010, 7:39:35 PM11/17/10
to terminator-users
When the "use alt as meta" option is unchecked (should be called
"altSendsEscape", since the meta bit is something else, but that's not
your problem), you can't use the alt key at all in applications. So
changing that wouldn't help.
Also, you don't need to restart terminator for options to take effect.

I really don't understand how checking that box can prevent the layout
from switching, since the layout is handled by Xlib.
However, I can reproduce (setxkbmap -option -option layout:us,ru -
option grp:caps_toggle) (the first -option clears current options - if
anyone else tries this, make sure you know what your old settings
were, first!):
* If terminator is started with altSendsEscape off, then pressing
ISO_Next_Group toggles between us and russian.
* If at any point altSendsEscape is turned on, then regardless of
which group is active, terminator gets latin characters.

Note that the Java Key Event tester works just fine, although
ISO_Next_Group is not a recognized "keycode" (really, a keysym): 0x0.
http://download.oracle.com/javase/tutorialJWS/uiswing/events/ex6/KeyEventDemo.jnlp

So the question, is, what are we doing any differently?

Ben Longbons

unread,
Nov 17, 2010, 8:02:52 PM11/17/10
to terminator-users
> ISO_Next_Group is not a recognized "keycode" (really, a keysym): 0x0.http://download.oracle.com/javase/tutorialJWS/uiswing/events/ex6/KeyE...
>
> So the question, is, what are we doing any differently?

From TerminalView.java
public void optionsDidChange() {
TerminatorPreferences preferences =
Terminator.getPreferences();
if
(preferences.getBoolean(TerminatorPreferences.USE_ALT_AS_META)) {
// If we want to handle key events when alt is down, we
need to turn off input methods.
enableInputMethods(false);
}

setFont(preferences.getFont(TerminatorPreferences.FONT));
sizeChanged();
}
This looks suspicious. In particular, there is no corresponding
enableInputMethods(true). Why do we need this?

Martin Dorey

unread,
Nov 17, 2010, 8:15:42 PM11/17/10
to terminat...@googlegroups.com

> there is no corresponding enableInputMethods(true).

 

That seems like ill behavior.

 

> Why do we need this?

 

The history doesn't expand on the code-comment that you've already quoted.  It arrived here:

 

Differences between revisions 1142 and 1143:

 

2006-11-10 14:24:03 -0800 enh (1143)

 

src/terminator/view/JTerminalPane.java: in the last couple of weeks, Jonathan Shea and Seth Green have both asked us to support meta, for the benefit of emacs(1). Handling the key events is simple, but we also need to turn input methods on or off, depending on whether the alt key is being used as meta.

 

src/terminator/Options.java: ...which means a new option...

 

src/terminator/Terminator.java: ...a more general scheme for updating windows when options change (previously they were just repainted)...

 

src/terminator/TerminatorFrame.java: ...and an expedient hack of replacing the menu bar when the modifier keys change. I tried fixing the menu in place, but that was difficult and messy.

 

 

---------------------------------------------------

--

Ben Longbons

unread,
Nov 17, 2010, 9:02:06 PM11/17/10
to terminator-users
On my system, I still get alt as escape prefix with that call removed,
and can even combine it with keys from the other layout.
E.g. in russian layout, alt-a yields ESC ф.
So just removing that call will be the best thing.
1. Everything works for me, a typical linux user, which is probably
most of our user base.
2. A quick check on a windows box with the key event demo shows that
we still get keytyped events when input methods are enabled and alt is
down. Only the numpad keys get consumed, and that's fine since the
numbers across the stop still work.
3. A comment elsewhere indicates that disabling input methods doesn't
work on Mac anyway.
4. In the case that any platform behaves otherwise, it is better to
fail to send ESC as the alt prefix than to fail to handle multilingual
text.

I'm not submitting a patch for this since I've already already
modified this function in my big patch, so it would collide, and you
DO NOT want to have to patch that file manually. Just apply it
already, I didn't break anything!

Also, is there ever any plan to implement a meta-bit à la xterm? It
introduces ambiguity by using characters in the U+0080-U+00FF range,
but even with the fact that the keys don't have correlation to the
pure-ascii, it could be useful as another way to type them, and it
seems to me that it's better to support more than to support less.
Plus, it is the only kind of meta that applications like nethack
support.

Martin Dorey

unread,
Nov 17, 2010, 9:28:16 PM11/17/10
to terminat...@googlegroups.com
> we still get keytyped events when input methods are enabled and alt is
> down.

I also seem to get keyPressed events, even without that enableInputMethods(false), on Linux. Perhaps it was something that got changed in JRE6, though a quick google didn't turn up anything.

> it is better to fail to send ESC as the alt prefix than to fail to handle
> multilingual text.

Unless you're a monolingual emacs user.

-----Original Message-----
From: terminat...@googlegroups.com [mailto:terminat...@googlegroups.com] On Behalf Of Ben Longbons

Elliott Hughes

unread,
Nov 17, 2010, 11:13:54 PM11/17/10
to terminat...@googlegroups.com
afair, i only added that when i was trying to get Mac OS to work,
because it seemed from the documentation like something we ought to be
doing. as you know, Mac OS and alt never panned out anyway, so i see
no reason to keep this if it's not helping the other platforms.

of course, you know what my memory's like...

--elliott

--
Elliott Hughes - http://www.jessies.org/~enh/

Martin Dorey

unread,
Nov 17, 2010, 11:30:08 PM11/17/10
to terminat...@googlegroups.com
Righto. So we should take it out and see if anyone screams. I'd do it but I don't want to cause Ben grief. That said, I haven't looked at his big patch.

----- Original Message -----
From: terminat...@googlegroups.com <terminat...@googlegroups.com>

Elliott Hughes

unread,
Nov 18, 2010, 12:18:16 AM11/18/10
to terminat...@googlegroups.com
yeah, me neither, and i'm afraid i'm not likely to have time until the
weekend again. sounds great though ;-)

--elliott

Ben Longbons

unread,
Nov 21, 2010, 5:19:21 PM11/21/10
to terminat...@googlegroups.com
On Wed, Nov 17, 2010 at 20:30, Martin Dorey <mdo...@bluearc.com> wrote:
Righto.  So we should take it out and see if anyone screams.  I'd do it but I don't want to cause Ben grief.

Not my grief, but whoever applies the patch.
And I just noticed, it's not actually my current patch that changes that function, but the already-applied BCE patch.
Therefore, the attached patch can be applied before or after my big one without any fuss. 
terminator-alt-input.diff

Elliott Hughes

unread,
Nov 28, 2010, 9:06:33 PM11/28/10
to terminator-users
(for the record, Martin committed this as r1628.)

--elliott
>  terminator-alt-input.diff
> < 1KViewDownload

Martin Dorey

unread,
Nov 28, 2010, 9:09:28 PM11/28/10
to terminat...@googlegroups.com, vlkv (vitvlkv@gmail.com)
(Thanks. Making sure vlkv sees it.)

-----Original Message-----
From: terminat...@googlegroups.com [mailto:terminat...@googlegroups.com] On Behalf Of Elliott Hughes
Sent: Sunday, November 28, 2010 18:07
To: terminator-users
Subject: [terminator-users] Re: Alt as meta disables multilayout input (was: Shift+F4 doesn't work in Midnight Commander)

--elliott

--

vlkv

unread,
Nov 29, 2010, 6:43:52 AM11/29/10
to terminator-users
On Nov 29, 5:09 am, Martin Dorey <mdo...@bluearc.com> wrote:
> (Thanks.  Making sure vlkv sees it.)

Thank you very much for your help. I've checked out r1628 and I can
change russian and english layouts regardless of "Use alt key as meta
key (for Emacs)" option.

But Shift+F4 in MC (create new file and start edit it) seems still not
working. Maybe I've missed some patch to apply?.. But I can live
without this shortcut though ("touch <filename>" does almost the same
thing).

Thank you!

Martin Dorey

unread,
Nov 29, 2010, 7:55:30 PM11/29/10
to terminat...@googlegroups.com, vlkv (vitvlkv@gmail.com)
Adding vlkv, for whom the patched Terminator doesn't work in this respect. Expecting that to be down to some hard-coded check for TERM=xterm in the mc source, I tried that. No joy. Then I tried Debian Lenny's xterm itself and Shift-F4 doesn't work for me there either, producing "1;2S" in the prompt at the bottom.

-----Original Message-----
From: terminat...@googlegroups.com [mailto:terminat...@googlegroups.com] On Behalf Of Elliott Hughes
Sent: Tuesday, November 16, 2010 19:17
To: terminator-users

--elliott

--

Reply all
Reply to author
Forward
0 new messages