package chamo

  1. Overview
  2. Docs
On This Page
  1. Global variables
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Chamo.CommandsSource

Commands management

Sourcetype command = string array -> unit Lwt.t
Sourcetype command_desc = {
  1. com_name : string;
  2. com_args : string array;
  3. com_more_args : string option;
  4. com_f : command;
}
Sourceval register : ?table:(string, command_desc) Hashtbl.t -> ?replace:bool -> command_desc -> unit

register command registers the given command. Optional arguments:

  • table can be used to specify a different command table than the default one.
  • replace is false by default and means that when registering a command, if a command with the same name is alerady register, a Failure exception is raised. If set to true, the given command replaces the previous one (if any).
Sourceval register_before : ?table:(string, command_desc) Hashtbl.t -> command_desc -> unit

register_before command replace the previous command with the same name (if any) by a function calling the given command (with the same name) then the function assciated to the previous command. The same arguments are passed to the two functions. If the first command fails, the second is not called. If there is no previous command registered with the same name, the function is similar to register.

Sourceval register_after : ?table:(string, command_desc) Hashtbl.t -> command_desc -> unit

Same as register_before but the function of the given command is called after the previous command registered with the same name (if any).

Sourceval get_com : ?table:(string, command_desc) Hashtbl.t -> string -> command_desc

Get the command with the given name.

  • parameter table

    can be used to specify an alternative command table.

  • raises Not_found

    if the command was not found.

Sourceval get_com_or_fail : ?table:(string, command_desc) Hashtbl.t -> string -> command_desc

Same as get_com but raise a Failure exception with a comprehensive message when the command is not found.

Sourceval string_to_argv : string -> string array
Sourceval argv_to_string : string array -> string
Sourceval launch_command : ?history:bool -> ?table:(string, command_desc) Hashtbl.t -> string -> string array -> unit Lwt.t
Sourceval async_launch_command : ?history:bool -> ?table:(string, command_desc) Hashtbl.t -> string -> string array -> unit
Sourceval same_previous_command : unit -> bool

Return true if is currently executed command is the same as the previous command one. This can be used in commands to have a different behaviour when the same command is triggered mutliple time.

Sourceval ask_launch_command : ?history:bool -> ?table:(string, command_desc) Hashtbl.t -> ?width:int -> string -> string array -> unit
Sourceval eval_command : ?history:bool -> ?table:(string, command_desc) Hashtbl.t -> string -> unit Lwt.t
Sourceval async_command : ?history:bool -> ?table:(string, command_desc) Hashtbl.t -> string -> unit
Sourceval available_command_names : ?table:(string, command_desc) Hashtbl.t -> unit -> string list
Sourceval unit_com : string -> (unit -> unit) -> command_desc

Create a simple command with a function taking no argument.

Sourceval unit_com_lwt : string -> (unit -> unit Lwt.t) -> command_desc

Create a simple lwtized command with a function taking no argument.

Sourceval create_com : string -> ?more:string -> string array -> command -> command_desc

Convenient function to create a command.

Global variables

Sourceval set_global : string -> string -> unit

set_global name value associates the given value to the given name.

Sourceval get_global : string -> string

get_global name returns the value associatd to name.

  • raises Not_found

    if the variable has no value.

Sourceval safe_get_global : string -> string

safe_get_global name works as get_global but returns an empty string "" if no value is associated to the given name.

Sourceval trees_for_window : (Stk.Key.keystate list * string) list -> Stk.Wkey.handler_tree list

trees_for_window bindings adds the given bindings to the ones of the windows (that is window_key_bindings#get) and return a handler tree to set has handler tree of a window. See the Stk.Wkey library for details about using such trees.

Sourceval create_add_binding_commands : (Stk.Key.keystate list * string) list Ocf.conf_option -> string -> (Stk.Key.keystate list -> string -> unit) * (string -> string -> unit)

create_add_bindings_commands option name return two functions to add key bindings to the given option, given a key state as OCaml value of as a string. It also create and register a add_<name>_key_binding command which can be used to add a key binding to the given option.

Sourceval add_window_key_binding : Stk.Key.keystate list -> string -> unit

These two functions add a key binding to the window_key_bindings option. The first takes a Stk.Key.keystatelist and the command name, while the second one takes a string representing a Stk.Key.keystatelist and a command name.

Sourceval add_window_key_binding_string : string -> string -> unit