how to enable the numeric keypad in xshell? - terminal

The numeric keypad seems to be not working in X shell terminal application.
How to enable the numeric keypad.
In google, i found to change the mode to ansi instead of Xterm. But some functionality were missing in ansi.

Set the following settings in X shell
In properties of the given shell:
Go to
TERMINAL -> VT MODES -> INITIAL NUMERIC KEYPAD MODE
and select option
-> SET TO NORMAL
Now your numeric keypad will work as usual.

Related

Mac generating ∆˚¬ characters instead of executing VSCode shortcuts that involve alt / option key

Problem
When I type alt+j, I always get the character ∆, even if I've assigned alt+j to a keyboard shortcut within VSCode.
The same is true for any other alphanumeric keys, but non-character-generating keys work fine with alt, like alt+upArrow.
Therefore, I can't use the alt key as a modifier for many keyboard shortcuts.
I realize this is normal MacOS behavior for text input, but I'm wondering:
Question
Can VSCode override / takes-precedence-over the OS, so that I can use the alt key for keyboard shortcuts?
Tried so far
I've searched for settings within VSCode and MacOS, but haven't found anything obvious. I've also edited keybindings.json, to no effect.
Solved this as follows with no complicated keybinding file changes:
⟶ System preferences
⟶ Keyboard
⟶ Input Sources Tab
⟶ + at bottom left
⟶ add and select Unicode Hex Input from panel on right
 ✓  Mac no longer prints anything on alt+letter|number
 ✓  enter unicode characters via alt+[code]
 ✅ Keyboard shortcuts are assignable to alt key!
“terminal.integrated.macOptionIsMeta”: true
Source

<tab> v. TAB in emacs

I'm using emacs 24.3 in the OS X terminal, and have run into something strange.
In markdown-mode.el, the tab key is bound to a specific function in the keymap via (define-key map (kbd "<tab>") 'markdown-cycle), but for some reason this wasn't registering for me (though other parts of the keymap were working fine).
What fixed this was changing <tab> to TAB in the above. Is this something wonky in the OS X terminal? Is there a way to fix this; I feel like this shouldn't occur.
I believe markdown-mode should be using TAB, not <tab>.
As far as I can tell, <tab> is the Tab key on the keyboard, and TAB is control-I, or ascii character 9 (written \t or \x09). The Tab key doesn't have an ascii value.
In GUI Emacs, Emacs sees that you pressed the Tab key (<tab>) and converts it to C-i (TAB) by default. Emacs can distinguish Tab and C-i, but converts Tab to C-i unless you specifically bind <tab> to something else (which markdown-mode does).
In the terminal, the terminal converts the Tab key to C-i (ascii 9), and Emacs sees only C-i. Emacs can't distinguish the two because they both show up as C-i.
The same thing happens with <return> vs RET (C-m, ascii 13).
Using TAB with define-key should automatically bind whatever event your keyboard sends for the key labeled "Tab", whether it is the ASCII TAB character, also known as C-i (Control + i) or something else -- including what Emacs writes as the pseudo-function key <tab>.
This might not work automatically in all cases. If it does not work for your particular keyboard then use C-h k and hit your Tab key, to find out what it is bound to. Whatever Emacs tells you is the key sequence, try binding that. For example, if it tells you that the key sequence is <foobar> then use (kbd "<foobar>").
But in most cases, all you need to do is use (kbd "TAB") (or "\C-i" or [control ?i]).

Terminfo smkx and Application Cursor Keys vs Application keypad

XTerm Control Sequences specifies the following key sequences:
CSI ? 1 h → Application Cursor Keys (DECCKM)
CSI ? 1 l → Normal Cursor Mode (DECOM)
CSI ? 66 h → Application keypad (DECNKM)
CSI ? 66 l → Numeric keypad (DECNKM)
and the Terminfo Source Format has the following entry:
Variable: keypad_xmit
Capname: smkx
Termcap: ks
Description: Put terminal in "keypad-transmit" mode
But the terminfo for xterm actually says smkx=\E[?1h\E=, which seems mixed up to me (smkx should affect the keypad, not the cursor keys, right?). What am I missing here?
The line
CSI ? 1 h → Normal Cursor Mode (DECOM)
probably should read
CSI ? 1 l → Normal Cursor Keys (DECCKM)
There are two escape sequences in each of smkx and rmkx because these capabilities are used in curses, i.e., for the keypad function.
The manual page for ncurses (like others) does not say so explicitly, but the function applies to all of the special keys on the keyboard which have the ability to switch between normal and application mode. This is a well-known feature of smkx and rmkx, as for example in the xterm FAQ Why can't I use the cursor keys in (whatever) shell?.
Special keys on the keyboard may include these (depending on the type of terminal):
numeric keypad (on the extreme right of a PC keyboard)
editing keypad (6 keys between the main keyboard and the numeric keyboard)
cursor keys
function keys (commonly at the top of a PC keyboard)
The VT100 (which does not have function keys or editing keypad) has separate escape sequences for the other two categories. In VT220 (emulated by xterm), the editing keypad's normal/application mode is an extension of the VT100 DECCKM, (documented in XTerm Control Sequences). DEC did not define a corresponding feature for function keys; however if there were some terminal which supported this capability it would probably be used in smkx and rmkx.
It looks like you are missing the \E= at the end of smkx.
ESC = Application Keypad (DECKPAM).
ESC > Normal Keypad (DECKPNM).
are listed on the XTerm Control Sequences page as well and you would expect them to affect the keypad.
I found a related question here: keyboard transmit mode in vt100 terminal emulator.

Getting "complete" and "menu-complete" to work together

I found out that the Bash shell supports a type of autocompletion that is different from the "traditional" autocompletion, where all possibilities get listed on the following line.
With the "traditional" autocompletion, if I type ch and then press the Tab key, I get something like:
$ ch
chacl chgrp chmod chown chvt
But if I add the following line to my /etc/inputrc (which remaps the Tab key to the built-in menu-complete function):
Tab: menu-complete
then the behavior of the shell changes: the word to be completed is replaced "inline" with a single match from the list of possible completions, and if I press the Tab key again, the word gets replaced with the next match.
I found this useful, but I still wanted to keep the traditional autocompletion and have it bound to the key combination Ctrl + Tab. So I added the following line to my /etc/inputrc file, according to what the readline library documentation suggests:
Ctrl-Tab: complete
However, adding this line only seems to make both Tab and Ctrl-Tab call the traditional complete function.
Does anyone know what I am doing wrong?
Thanks in advance!
To start with, I'm not a massive expert in this area, but I think I can answer your question. First of all, while you are using Bash, Bash is a shell which interprets keyboard commands that it receives from a terminal / console. While you are informing Bash how to react to specific key combinations in the inputrc file, your Terminal determines precisely which character is 'sent' to the Shell before the inputrc file even enters the equation.
Unfortunately, on my system (granted, it's OSX - but I don't think this is strange behaviour when compared to Linux), both Tab and Ctrl-Tab send the same keyboard input to the shell. Infact, both Tab and Ctrl-Tab send a Ctrl-I command to the shell, and indeed, if I enter Ctrl-I when using the terminal, it performs the completion as if I hit Tab.
The software (installed on most Linux systems by default), showkey will tell you what keys the shell is receiving when you press specific keyboard inputs as you push them.
Anyway, my suggestion to you is to use Shift-Tab, which does appear to send it's own key-code to the shell. Shift-Tab on my computer shows up (using showkey) as '<ESC>[Z', which I think is pretty standard across the board. As such, your inputrc file with the following bindings should allow you to use shift-tab instead of ctrl-tab to achieve what you desire:
Tab: menu-complete
"\e[Z": complete
The \e in the second binding represents the escape character, and the [Z are simply the characters as shown using showkey. You can get a similar effect on OSX by simply using cat, running cat from within a terminal and pressing Shift-Tab will show you "^[[Z", where ^[ represents the escape character and the other characters are as before.
I know this doesn't resolve your question precisely, but as I don't think you are able to use Ctrl-Tab as a key combination, without re-mapping Ctrl-Tab to another keybinding within your terminal (more likely to be easier if you are using a GUI terminal), this is likely as close as you can get without significant effort!
I have ShiftTab bound to menu-complete-backward, so it goes back one step if I skipped the right completion, and I've mapped Ctrlq to complete, so if there are several possible completions I hit Ctrlq to list them without having to cycle through them.
# Make Tab cycle between possible completions
# Cycle forward: Tab
# Cycle backward: Shift-Tab
TAB: menu-complete
"\e[Z": menu-complete-backward
# Make C-q display the list of possible completions
Control-q: complete
# Display the list of matches when no further completion is possible
set show-all-if-unmodified on
Edit: Ctrlq is bound to quoted-insert by default, that is, it tells the shell to take the next key literally. quoted-insert is also bound to Ctrlv, so you don't lose that functionality if you rebind Ctrlq. Anyway, I've found that AltESC also works, by default, for showing the possible completions (as far as I can tell it is equivalent to TAB); note that it may be seized by Gnome, then either double press ESC or rebind "Switch windows directly" in Settings → Devices → Keyboard → Navigation.
The following should achieve what you're looking for (if I understand correctly!)
In your .inputrc
# display all possible matches for an ambiguous pattern at first tab
set show-all-if-ambiguous on
# next tab(s) will cycle through matches
TAB: menu-complete
# shift tab cycles backward
"\e[Z": menu-complete-backward
Where to start, if you can or cant do this is dependent your keyboard and your drivers and there isn't one catch all answer. Each key press and release generates a sequenced key pair (key down and release) (scancode) these codes are then translated by the kernel into keycodes for example on my laptop keyboard 0x3a 0xba are translated to keycode 15 (down and up) these are then translated into actions such as return letter c a / you can assign actions to keysyms using the keycode/hex/binary/octal notation which codes match which letters is determined by the kernel translation table which is fairly standardized, however the first part signal that's translated to keycodes is different for most keyboards.
Continuing with the earlier example for me shift tab (and alt and control and any combination) produce keycode 15 however in hex it produces 0x2a 0x2a 0x2a 0x2a 0x2a 0x2a 0x2a 0x2a 0x2a 0x2a 0x2a and this is because shift alt and control are special keys (modifiers) these multiply out against the keycodes and fill out the dumpkeys table the kernel is limited to the number of assignments as well this is determined by your choice of keymap and shares resources with your terminal colors (if your char set its defined above the threshold it limits your terminal color scope). And this all goes out the window if your in an xserver and has a whole new system. Most of these things can be changed,modified and manipulated by the user and programs installed. My point to all this is to emphasize that there is no catch all for the mapping of the tab key and its going to vary keyboard drivers to kbd drivers (now if you find a solution that happens to work for you excellent :)) but chances are it won't be portable and might not work if you change keyboards and might not translate between xserver and tui. What i recommend is learning the steps to modify your kbd on the go.
will give you the decimal octal hex notation for a key press on the same line
--full-table -1 >> keytable
will give you a documented with your full list of keycode->keysym pairing in a format that will give you a better picture of your layout and from there you can either use loadkey to change a keys value or ad an entry in .inputrc or your main rc file. You can also create a custom key.map file.
Further escape sequence translation is determined by the "$TERM" variable and each virtual terminal emulator can be different
infocmp "$TERM"
will give you a list of your terminal escape sequences
Resources:
https://man7.org/linux/man-pages/man4/console_codes.4.html
https://www.gnu.org/software/screen/manual/html_node/Input-Translation.html
http://kbd-project.org/docs/scancodes/scancodes.html
https://www.vt100.net/
So to sum up.
Your keyboard drivers
Your kemap choice
Your virtual terminal emulator
and your kernel
form the backbone of remapping dificult keys (tab/s-tab/a-tab)
I'm not sure Ctrl-Tab is a real character; my terminal, for instance, ignores the combination. I think the only way to use Ctrl-Tab is to use your terminal emulator to map it to some otherwise unused escape sequence, then bind that sequence to complete.

How to not get special characters in place of meta key combinations for VIM on OS X

On OS X, at any program, when I type option-p I get π, option-P I get ∏ and there's a bunch of alt/option bindings that just return greek and other special characters.
Is there a way to disable that?
Currently I'm using the Auto Pairs VIM plugin and it has the following default mappings:
<M-p> : Toggle Autopairs (g:AutoPairsShortcutToggle)
<M-e> : Fast Wrap (g:AutoPairsShortcutFastWrap)
<M-n> : Jump to next closed pair (g:AutoPairsShortcutJump)
<M-b> : BackInsert (g:AutoPairsShortcutBackInsert)
It seems I can't use these and other meta key based VIM mappings while this special input is turned on.
EDIT
From this cnet article, in truth I need to know how to disable that special input shown at the bottom of the page.
Use the macmeta setting: :set macmeta
From :help 'macmeta'
'macmeta' Use option (alt) as meta key. When on, option-key presses are not interpreted, thus enabling bindings to <M-..>. When off, option-key presses are interpreted by the selected input method and inserted as text.
Obviously this is a MacVim-only setting.
In Terminal.app Settings there's a setting for "Use option as meta key", under the Keyboard tab which disables e.g. Option-p printing π. You may need to start a new terminal window to see the effect. But for some reason even after disabling this I'm having trouble setting mappings for <M-p>, but mappings using Ctrl-v and inserting the character literally do work.
Well, it seems that with MacVim, in my .vimrc I can just map these special characters and it will work both at GUI and at Terminal.
Since they are generated by the corresponding meta key combinations, it'll look just as a meta key mapping.
EDIT
Some special characters are accents and it may not work well for them.
I've done this at my .vimrc:
if has("gui_macvim")
let g:AutoPairsShortcutToggle = 'π' " <m-p>
let g:AutoPairsShortcutFastWrap = '∑' " <m-w>
let g:AutoPairsShortcutJump = '∆' " <m-j>
let g:AutoPairsShortcutBackInsert = '∫' " <m-b>
endif
has("gui_macvim") is true both at GUI as at Terminal, when running MacVim.

Resources