You are not logged in.

#1 2014-12-07 18:25:29

porphyry5
Member
Registered: 2014-06-04
Posts: 88

[SOLVED] Prevent typing accented characters with Alt+ and Ctrl+Alt+

Bash provides the ability to type accented (8 bit ascii) characters using Alt+ and Ctrl+Alt+ combinations.  In a terminal this behavior seems disabled by default, but in an xterm that default behavior is over-ridden.  In a tty, pressing Alt+g produces no result, in an xterm it produces the response '\303', and in MC running in an xterm it produces an accented character.  How do I disable that behavior by the X system or xterm, as I use these key combinations extensively in MC, and cannot conveniently use it with the X system.

For reference:

 ~ $ setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc104
layout:     us
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)
geometry:   pc(pc104)
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+inet(evdev)"     };
        xkb_geometry  { include "pc(pc104)"     };
};
~ $ 

Last edited by porphyry5 (2014-12-09 18:39:13)

Offline

#2 2014-12-07 19:53:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Prevent typing accented characters with Alt+ and Ctrl+Alt+

Your analysis seems flawed.  This behavior is not provided by bash and is not disabled by the tty.  This behavior must be added by something else you have running.  Alt-g produces nothing for me in tty, urxvt, or mc.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-12-07 20:25:17

porphyry5
Member
Registered: 2014-06-04
Posts: 88

Re: [SOLVED] Prevent typing accented characters with Alt+ and Ctrl+Alt+

Trilby wrote:

Your analysis seems flawed.  This behavior is not provided by bash and is not disabled by the tty.  This behavior must be added by something else you have running.  Alt-g produces nothing for me in tty, urxvt, or mc.

Thank you for the information, that would leave only fluxbox as the source of this behavior.

Offline

#4 2014-12-07 23:11:59

starbreaker
Member
From: Harrisburg, PA
Registered: 2014-11-30
Posts: 48
Website

Re: [SOLVED] Prevent typing accented characters with Alt+ and Ctrl+Alt+

@porphyry5, have you altered /etc/inputrc on your system, or created a custom ~/.inputrc file? If so, can you please create Gists containing the contents of these files and share them in a reply?


Matthew Graybosch
matthewgraybosch.com (personal) | starbreakerseries.com (my epic SF series)
"I ain't got a drinking problem. I got a doing stupid shit when I'm drunk problem." --Edmund Cohen

Offline

#5 2014-12-09 01:57:55

vadmium
Member
Registered: 2010-11-02
Posts: 63

Re: [SOLVED] Prevent typing accented characters with Alt+ and Ctrl+Alt+

In my experience with xterm, by default when you use the Alt key it produced a character with 128 (so-called ASCII high bit) added. For instance Alt + lowercase g gives me a lowercase cedilla, ç. The ASCII code for g in octal is \147; the Latin-1 code for ç would be \347, but when encoded in UTF-8 this becomes \303\247, so perhaps that is where you got the \303 value from.

If you want xterm to behave a bit more like other terminals, from memory I think you can create or extend an

~/.Xresources

file with the following line:

xterm*metaSendsEscape: true

This is taken from an old config I have at https://github.com/vadmium/etc/blob/master/Xresources, not used in years. The Alt key on PCs maps to xterm’s idea of the “Meta” key, and this setting makes xterm behave like most other terminals (e.g. VTE-based, like Sakura or Gnome Terminal) and just send the escape code for Alt+g: \033\147.

Offline

#6 2014-12-09 02:03:12

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Prevent typing accented characters with Alt+ and Ctrl+Alt+

The above sounds right - I just checked urxvt's man page and found the boolean resource option "meta8".  When I set this to true, alt+g produces a 'ç'.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2014-12-09 18:36:27

porphyry5
Member
Registered: 2014-06-04
Posts: 88

Re: [SOLVED] Prevent typing accented characters with Alt+ and Ctrl+Alt+

Thank you all for your help, and particularly @vadmium, who provided the clincher.  I have two identical laptops, with near identical content apart from /home.  Both have identical /etc/inputrc and non-existent  ~/.inputrc files, and both had identical ~/.Xdefaults files.  Yesterday I thought I had the problem licked when I added the line

xterm*eightBitInput: False 

to that file on laptop #1 and the problem instantly vanished.  Flushed with success and that glorious euphoria that fills one after chancing upon the solution to a problem, I did the same to laptop #2.

And nothing changed... well, except my sense of euphoria, replaced by my more usual sense of the perfidy of computers.

This morning I added vadmium's suggestion

xterm*metaSendsEscape: true 

to laptop #2, and it too performed as hoped.  So I removed

xterm*eightBitInput: False 

from laptop #2, and it still works just fine.  Why it should be that laptop #1 works with

xterm*eightBitInput: False 

while laptop #2 only works with

xterm*metaSendsEscape: true 

is beyond me, but it sure reminds me why I love the command line, quick, easy and simple.

Offline

Board footer

Powered by FluxBB