Modes permits to locally configure key bindings and default font.
See also C-mode §5.28 page and french mode
§5.19 page
.
Returns the name of the current window mode in a new allocated string.
Be careful, the string is allocated each time the function is called, use free() to release it.
void create_mode(char * name)
void create_mode(char * name, char * suffixes)
void create_mode(char * name, char * suffixes, char * fontname)
Creates a new mode named name if it does not already exist. This mode will be created with default mode bindings. If suffixes is valuated, the next file having one of these suffixes will be loaded in name mode. This also goes for fontname.
suffixes is one or a sequence of words beginning by a dot,
and separated by a space. For instance the Cmode
associated suffixes are defined with ".h .c .C .H .sc"
.
create_mode("secret-mode", ".dontreadme", "5x8");
void set_mode_suffixes(char * modename, char * suffixes)
Changes the suffixes associated to the mode modename.
void set_mode_font(char * modename, char * fontname)
Changes the font associated to the mode modename.
void set_mode(char * modename)
Changes the current window mode to modename.
void key_def(char * modename, char * keys, char * funcname)
Changes or creates the given mode key binding keys if
funcname is not 0, else removes key binding keys.
The specified key binding can be (?
is any character
except ^
):
"?"
for instance }
blinks the current
{
in Cmode,
"^?"
to bind a control key (except ^
x),
for instance "^i"
re-indents the current line in
Cmode(of course, in this case you can also give
"\t"
),
"^[?"
to bind an escape key sequence,
"^x?"
to bind an ctrl-x key sequence
"^x^?"
to bind an ctrl-x ctrl-key
sequence.
"^[^?"
to bind an escape ctrl-key
sequence.
Furthermore:
`^^'
appoints the `^'
character
`^'
and `^@'
appoint the null character
(code 0).
It is also possible to bind keysym keys (`k'
is the
keysym name):
"k"
to bind a keysym
"^[k"
to bind an escape keysym
"^xk"
to bind an ctrl-x keysym
where `k'
is one of (case is not significant)
Multikey, Home, Left, Up, Right,
Down, Prior, Next, End, Begin,
Select, Print, Execute, Insert,
Undo, Redo, Menu, Find, Cancel,
Help, Break, Modeswitch,
scriptswitch, NumLock, KPSpace,
KPTab, KPEnter, KPF1,
KPF2, KPF3, KPF4,
KPEqual, KPMultiply, KPSeparator,
KPAdd, KPSubtract, KPDecimal,
KPDivide, KP0, KP1,
KP2, KP3, KP4, KP5,
KP6, KP7, KP8, KP9,
F1, F10, F11, F12, F13, F14,
F15, F16, F17, F18, F19,
F2, F20, F21, F22, F23, F24,
F25, F26, F27, F28, F29, F3,
F30, F31, F32, F33, F34,
F35, F4, F5, F6, F7, F8,
F9, L1, L10, L2, L3, L4,
L5, L6, L7, L8, L9, R1,
R10, R11, R12, R13, R14,
R15, R2, R3, R4, R5, R6,
R7, R8, R9.
The KP names refer to the keypad numbers and
functions. Sometimes a key can have several names.
funcname is the name of the function you want to be called when you hit the keys sequence in the mode modename. The name appoints a function (built-in or not, taking no arguments) or must be one of the following: setmark, abort, return, delete, tab, killline, cursordown, cursorup, openspace, undo, redo, nextpage, killregion, pasteregion, evalregion, firstpage, lastpage, previouspage, copyregion, deletewindow, gotomark, backwardsearch, forwardsearch, globalreplace, writefile, killcurrentbuffer, queryreplace, savefile, readfile, insertfile, exchangecursormark, listopenfile, gotoline, and evalexpression.
These functions are the functions called by the default key bindings, contrarily to functions they take no argument but asks for them if necessary. For instance the gotoline() function take one argument, but a key binding with "gotoline" prompts the line number in the mini-buffer. The killcurrentbuffer() function empties a buffer without confirmation if the buffer is modified, but a key binding with "killcurrentbuffer" asks if the buffer must be saved or not.