Emacs fun in ruby ncurses library
For all those situations where numeric arguments or numeric prefixes to methods cannot be specified by typing a number (typically editable components), we have 2 ways of specifying, copied shamefully from emacs.
C-u – each press of C-u multiplies a “multiplier” by 4. So you get 4 16 64.
To go execute C-n 16 times, one can do:
C-u C-u C-n.
C-u 16 C-n
After C-u enter numbers, and end with key binding.
You can terminate a number with a second C-u as
C-u 16 C-u 0. This is required if the command itself is numeric. Here 0 is a command.
3. Use the key
M-9to specify numeric argument. For larger numbers pressing M (alt) is not required. Example,
M-1 6 M-n, executes M-n 16 times. Perhaps, emacs people use the C-u when the command is invokes by Control, and M-1 when invoked by Meta. I don’t know. I just know that we’ve got to make this ncurses widget library as powerful as possible. And key-bindings are an important way.
If my explanation did not make sense, you can read this page. Note, i’ve not implemented negative arguments (yet).
WARNING ! Since I am catching C-u globally, therefore C-u is no longer used as undo in
Textarea. I’ve used
C-_ for undo.