package chamo

  1. Overview
  2. Docs

The sourceview view, to edit any text file.

val get_att : string -> (string * string) list -> string option

get_att name pairs return the value associated to the given name in the given list of pairs, or None if no value is associated to the name.

val get_att_f : ?default:'a -> (string -> 'a) -> string -> (string * string) list -> 'a option

Same as get_att but apply the given function on the value associated to the name.

  • parameter default

    can be used to set a default value to return when no value is associated to the given name.

val lang_of_filename : string -> string option

Return the language associated to the given filename, according to the Sourceview_rc.filename_language_patterns option.

val utf8_of_filename : ?full:bool -> string -> string

Return an UTF-8 string from the given filename.

  • parameter full

    can be used to get the complete filename true instead of the basename false. Default is false.

type location =
  1. | Linechar of int * int
  2. | Linechars of int * int * int
  3. | Char of int
  4. | Chars of int * int
val location_of_string : string -> location option

Parse a location string. Can be of form n to indicate character number n, or l,c to indicate line l, character c.

val string_of_location : location -> string

Create a string to represent the given location.

val string_of_line_char : (int * int) -> string

Create a string to represent the given (line, character) location.

val open_buffers_file : string ref

The name of the file where to load and store the list of open buffers.

val read_open_buffers_file : string -> (string * (string * string) list) list
val write_open_buffers_file : string -> < filename : string ; attributes : (string * string) list.. > list -> unit
val buffer_name_history : string list ref

The history of buffers. First element is the most recently used. The list contains the names of buffers.

val remove_buffer_from_history : string -> unit
val make_buffer_first_in_history : string -> unit
val pastable_history : Minibuffer.minibuffer_history

An history of pastable text, usable in a minibuffer.

module B = Stk.Textbuffer
class my_buffer : Stk.Textbuffer.t -> object ... end

Modes

class type mode = object ... end
val register_mode : ?replace:bool -> mode -> unit

Register a mode.

  • parameter replace

    can be used to indicate that if there is already a mode with the same name, it should be replaced. Default is false.

  • raises Failure

    if a mode with the same name already exists.

val get_mode : string -> mode

Get the mode with the given name.

  • raises Not_found

    if no such mode was registered.

val available_mode_names : unit -> string list

The list of registered modes.

Buffered files

Buffered files are buffered associated to a file.

class buffered_file : ?attributes:(string * string) list -> ?xmls:Xml.t list -> ?loc:(int * int) -> name: string -> filename:string -> my_buffer -> object ... end

Sourceview views

TODO: methods acting on buffer contents should be moved to buffered_file or my_buffer classes.

class sourceview : ?attributes:(string * string) list -> ?xmls:Xml.t list -> View.topwin -> ( 'a -> unit) -> ('a -> 'b) -> (buffered_file -> View.topwin -> View.gui_view) -> (string -> string -> unit) -> buffered_file -> object ... end

Associating buffered_files and modes

val mode_name_of_filename : string -> string option

Use the Sourceview_rc.filename_mode_patterns option to get the associated mode name from the given filename.

val mode_of_filename : string -> mode option

Get the mode to use from the given filename, using mode_name_of_filename.

Management of views

val views : sourceview list ref
val buffers : buffered_file list ref
val active_sourceview : sourceview option ref
val set_active_sourceview : sourceview -> unit
val get_fresh_buffer_name : string -> string
val create_buffer : ?attributes:(string * string) list -> ?xmls:Xml.t list -> string -> buffered_file
val get_buffer : ?attributes:(string * string) list -> ?xmls:Xml.t list -> string -> buffered_file
val get_buffer_by_name : string -> buffered_file
val remove_buffer : buffered_file -> unit
val on_view_destroy : sourceview -> unit
val create_view : ?attributes:(string * string) list -> ?xmls:Xml.t list -> View.topwin -> buffered_file -> sourceview
val file_rename : string -> string -> unit
val open_file : View.topwin -> View.gui_view -> ?attributes:(string * string) list -> ?xmls:Xml.t list -> string -> [> `New_view of View.gui_view | `Use_view of View.gui_view ]

Commands

val register_com : prefix:string -> string -> string array -> ?more:string -> (sourceview -> string array -> unit) -> unit

register_com ~prefix name args ?more f creates and register a command with name prefix_name, arguments names args and command body f.

  • parameter f

    takes the active sourceview and the regular command arguments.

  • parameter more

    can be used to describe the remaining parameters of the command.

val register_com_lwt : prefix:string -> string -> string array -> ?more:string -> (sourceview -> string array -> unit Lwt.t) -> unit

Same as register_com but does not add a Lwt.return to the given function.

val switch_to_buffer : sourceview -> string -> unit
val candidate_buffers : unit -> string list
val switch_buffer_history : Minibuffer.minibuffer_history
val switch_buffer : sourceview -> string array -> unit Lwt.t
val destroy_buffer : sourceview -> 'a -> unit Lwt.t
val paste : sourceview -> string array -> unit
val copy : sourceview -> string array -> unit
val cut : sourceview -> string array -> unit
val beginning_of_line : sourceview -> string array -> unit
val end_of_line : sourceview -> string array -> unit
val undo : sourceview -> string array -> unit
val redo : sourceview -> string array -> unit
val forward_word : sourceview -> string array -> unit
val backward_word : sourceview -> string array -> unit
val forward_line : sourceview -> string array -> unit
val backward_line : sourceview -> string array -> unit
val forward_char : sourceview -> string array -> unit
val backward_char : sourceview -> string array -> unit
val kill_line : sourceview -> string array -> unit
val kill_word : sourceview -> string array -> unit
val backward_kill_word : sourceview -> string array -> unit
val delete_char : sourceview -> string array -> unit
val backward_delete_char : sourceview -> string array -> unit
val transpose_chars : sourceview -> string array -> unit
val transpose_lines : sourceview -> string array -> unit
val transpose_words : sourceview -> string array -> unit
val yank_choose : sourceview -> string array -> unit
val insert : sourceview -> string array -> unit
val goto_line : sourceview -> string array -> unit Lwt.t
val goto_char : sourceview -> string array -> unit Lwt.t
val force_save : sourceview -> string array -> unit Lwt.t
val syntax_mode_history : Minibuffer.minibuffer_history
val set_syntax_mode : sourceview -> string array -> unit Lwt.t
val popup_syntax_mode_choice : sourceview -> string array -> unit
val set_encoding : sourceview -> string array -> unit Lwt.t
val set_mode : sourceview -> string array -> unit Lwt.t
val popup_mode_choice : sourceview -> string array -> unit
val switch_line_numbers : sourceview -> string array -> unit
val switch_line_markers : sourceview -> string array -> unit
val set_wrap_mode : sourceview -> string array -> unit Lwt.t
OCaml

Innovation. Community. Security.