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

  • mods
    Type: table
    The table of modifier keys.
  • remove_shift
    Type: boolean
    Optional
    Default: false
    Remove the shift key from the modifier table.

Return Values

  • string
    A string of key names, separated by hyphens (-).

lousy.bind.key (mods, key, desc, func, opts)

Create a new key binding.

Parameters

  • mods
    Type: table
    The table of modifier keys.
  • key
    Type: string
    The key name.
  • desc
    Type: string
    Optional
    Default: nil
    A description for this key binding.
  • func
    Type: function
    The callback function for this key binding.
  • opts
    Type: table
    Optional
    Default: {}
    The table of key binding options.

Return Values

  • table
    A table representing the new key binding.

lousy.bind.but (mods, button, desc, func, opts)

Create a new button binding.

Parameters

  • mods
    Type: table
    The table of modifier keys.
  • button
    Type: string
    The button name.
  • desc
    Type: string
    Optional
    A description for this button binding.
  • func
    Type: function
    The callback function for this button binding.
  • opts
    Type: table
    Optional
    The table of button binding options.

Return Values

  • table
    A table representing the new button binding.

lousy.bind.buf (pattern, desc, func, opts)

Create a new buffer binding.

Parameters

  • pattern
    Type: string
    The text pattern to match.
  • desc
    Type: string
    Optional
    A description for this buffer binding.
  • func
    Type: function
    The callback function for this buffer binding.
  • opts
    Type: table
    Optional
    The table of buffer binding options.

Return Values

  • table
    A table representing the new buffer binding.

lousy.bind.cmd (cmds, desc, func, opts)

Create a new command binding.

Parameters

  • cmds
    Type: string or table
    One or more text patterns to match.
  • desc
    Type: string
    Optional
    A description for this buffer binding.
  • func
    Type: function
    The callback function for this buffer binding.
  • opts
    Type: table
    Optional
    The table of buffer binding options.

Return Values

  • table
    A table representing the new buffer binding.

lousy.bind.any (desc, func, opts)

Create a binding which is always called.

Parameters

  • desc
    Type: string
    Optional
    A description for this binding.
  • func
    Type: function
    The callback function for this binding.
  • opts
    Type: table
    Optional
    The table of binding options.

Return Values

  • table
    A 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

  • object
    Type: any type
    An object passed through to any 'any' bindings called.
  • binds
    Type: table
    A table of bindings to search.
  • args
    Type: table
    A 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

  • object
    Type: any type
    An object passed through to any key bindings called.
  • binds
    Type: table
    A table of bindings to search.
  • mods
    Type: table
    The table of modifier keys.
  • key
    Type: string
    The key name.
  • args
    Type: table
    A 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

  • object
    Type: any type
    An object passed through to any key bindings called.
  • binds
    Type: table
    A table of bindings to search.
  • mods
    Type: table
    The table of modifier keys.
  • button
    Type: string
    The button name.
  • args
    Type: table
    A 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

  • object
    Type: any type
    The first argument of the bind callback function.
  • binds
    Type: table
    The table of binds in which to check for a match.
  • buffer
    Type: string
    The buffer string to match.
  • args
    Type: table
    The 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

  • object
    Type: any type
    The first argument of the bind callback function.
  • binds
    Type: table
    The table of binds in which to check for a match.
  • buffer
    Type: string
    The buffer string to match.
  • args
    Type: table
    The 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

  • object
    Type: any type
    The first argument of the bind callback function.
  • binds
    Type: table
    The table of binds in which to check for a match.
  • mods
    Type: {string}
    The modifiers to match.
  • key
    Type: string
    The key name to match.
  • args
    Type: table
    The 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.
  • string
    The 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

  • b
    Type: table
    The binding.

Return Values

  • string
    The binding description string.

Fields

lousy.bind.ignore_mask

Type: any type
Read-write
Set of modifiers to ignore.

lousy.bind.map

Type: any type
Read-write
A table that contains mappings for key names.

Attribution

Authors

  • Mason Larobina

Copyright