Module lousy.bind
lousy.bind library
Key, buffer and command binding functions.
Functions
lousy.bind.parse_mods (mods, remove_shift)
Parse a table of modifier keys into a string.
Parameters
-
modsType: tableThe table of modifier keys.
-
remove_shiftType: booleanOptionalDefault:
false
Remove the shift key from the modifier table.
Return Values
-
stringA string of key names, separated by hyphens (-).
lousy.bind.key (mods, key, desc, func, opts)
Create a new key binding.
Parameters
-
modsType: tableThe table of modifier keys.
-
keyType: stringThe key name.
-
descType: stringOptionalDefault:
nil
A description for this key binding. -
funcType: functionThe callback function for this key binding.
-
optsType: tableOptionalDefault:
{}
The table of key binding options.
Return Values
-
tableA table representing the new key binding.
lousy.bind.but (mods, button, desc, func, opts)
Create a new button binding.
Parameters
-
modsType: tableThe table of modifier keys.
-
buttonType: stringThe button name.
-
descType: stringOptionalA description for this button binding.
-
funcType: functionThe callback function for this button binding.
-
optsType: tableOptionalThe table of button binding options.
Return Values
-
tableA table representing the new button binding.
lousy.bind.buf (pattern, desc, func, opts)
Create a new buffer binding.
Parameters
-
patternType: stringThe text pattern to match.
-
descType: stringOptionalA description for this buffer binding.
-
funcType: functionThe callback function for this buffer binding.
-
optsType: tableOptionalThe table of buffer binding options.
Return Values
-
tableA table representing the new buffer binding.
lousy.bind.cmd (cmds, desc, func, opts)
Create a new command binding.
Parameters
-
cmdsType: string or tableOne or more text patterns to match.
-
descType: stringOptionalA description for this buffer binding.
-
funcType: functionThe callback function for this buffer binding.
-
optsType: tableOptionalThe table of buffer binding options.
Return Values
-
tableA table representing the new buffer binding.
lousy.bind.any (desc, func, opts)
Create a binding which is always called.
Parameters
-
descType: stringOptionalA description for this binding.
-
funcType: functionThe callback function for this binding.
-
optsType: tableOptionalThe table of binding options.
Return Values
-
tableA table representing the new binding.
lousy.bind.match_any (object, binds, args)
Match any 'any' bindings in a given table of bindings.
The bindings' callback functions are called in the order that they
occur in the given table of bindings. If any callback function
returns a value other than false
, then matching stops and this
function immediately returns true
. Otherwise, if the callback
returns false
, matching continues.
Parameters
-
objectType: any typeAn object passed through to any 'any' bindings called.
-
bindsType: tableA table of bindings to search.
-
argsType: tableA table of arguments passed through to any 'any' bindings called.
Return Values
-
boolean
true
if an 'any' binding was ran successfully.
lousy.bind.match_key (object, binds, mods, key, args)
Match any key binding in a given table of bindings.
The bindings' callback functions are called in the order that they
occur in the given table of bindings. If any callback function
returns a value other than false
, then matching stops and this
function immediately returns true
. Otherwise, if the callback
returns false
, matching continues.
Parameters
-
objectType: any typeAn object passed through to any key bindings called.
-
bindsType: tableA table of bindings to search.
-
modsType: tableThe table of modifier keys.
-
keyType: stringThe key name.
-
argsType: tableA table of arguments passed through to any key bindings called.
Return Values
-
boolean
true
if a key binding was ran successfully.
lousy.bind.match_but (object, binds, mods, button, args)
Match any button binding in a given table of bindings.
The bindings' callback functions are called in the order that they
occur in the given table of bindings. If any callback function
returns a value other than false
, then matching stops and this
function immediately returns true
. Otherwise, if the callback
returns false
, matching continues.
Parameters
-
objectType: any typeAn object passed through to any key bindings called.
-
bindsType: tableA table of bindings to search.
-
modsType: tableThe table of modifier keys.
-
buttonType: stringThe button name.
-
argsType: tableA table of arguments passed through to any button bindings called.
Return Values
-
boolean
true
if a key binding was ran successfully.
lousy.bind.match_buf (object, binds, buffer, args)
Try and match a buffer binding in a given table of bindings and call that bindings callback function.
Parameters
-
objectType: any typeThe first argument of the bind callback function.
-
bindsType: tableThe table of binds in which to check for a match.
-
bufferType: stringThe buffer string to match.
-
argsType: tableThe bind options/state/metadata table which is applied over the opts table given when the bind was created.
Return Values
-
boolean
true
if a binding was matched and called. -
boolean
true
if a partial match exists.
lousy.bind.match_cmd (object, binds, buffer, args)
Try and match a command or buffer binding in a given table of bindings and call that bindings callback function.
Parameters
-
objectType: any typeThe first argument of the bind callback function.
-
bindsType: tableThe table of binds in which to check for a match.
-
bufferType: stringThe buffer string to match.
-
argsType: tableThe bind options/state/metadata table which is applied over the opts table given when the bind was created.
Return Values
-
boolean
true
if either type of binding was matched and called.
lousy.bind.hit (object, binds, mods, key, args)
Attempt to match either a key or buffer binding and execute it. This function is also responsible for performing operations on the buffer when necessary and the buffer is enabled.
Parameters
-
objectType: any typeThe first argument of the bind callback function.
-
bindsType: tableThe table of binds in which to check for a match.
-
modsType: {string}The modifiers to match.
-
keyType: stringThe key name to match.
-
argsType: tableThe bind options/state/metadata table which is applied over the opts table given when the bind was created.
Return Values
-
boolean
true
if a key or buffer binding was matched or if a key was added to the buffer. -
stringThe new buffer truncated to 10 characters (if you need more buffer then use the input bar for whatever you are doing). If no buffer binding could be matched, the returned buffer will be the empty string.
lousy.bind.bind_to_string (b)
Produce a string describing the action that triggers a given binding.
For example, a binding for the down-arrow key would produce "<Down>"
.
Parameters
-
bType: tableThe binding.
Return Values
-
stringThe binding description string.
Fields
lousy.bind.ignore_mask
lousy.bind.map
Attribution
Authors
Copyright
- 2010 Mason Larobina