Frama-C API - Rich_text

Text with Tags

type message

Message with tags

val size : message -> int
val char_at : message -> int -> char
val string : message -> string
val substring : message -> int -> int -> string
val tags_at : message -> int -> (Stdlib.Format.stag * int * int) list

Returns the list of tags at the given position. Inner tags come first, outer tags last.

val visit : ?output:(string -> int -> int -> unit) -> ?open_tag:(Stdlib.Format.stag -> int -> int -> unit) -> ?close_tag:(Stdlib.Format.stag -> int -> int -> unit) -> message -> unit

Visit the message, with depth-first recursion on tags. All methods are called with text or tag, position and length.

val pretty : ?vbox:int -> Stdlib.Format.formatter -> message -> unit

Pretty-print the message onto the given formatter, with the tags. The original message has been already laidout with respect to horizontal and vertical boxes, and this layout will be output as-it-is into the formatter.

Here, you have two different strategies to render the message properly. If ~vbox is specified, a vertical box is opened around the message, and newlines are emitted with a "@\n" and the given indentation. Otherwise, no box is used and newlines are emitted as "\n", which only makes sense if there is no current indentation in the output formatter.

Message Buffer

type buffer

Buffer for creating messages.

The buffer grows on demand, but is protected against huge mesages. Maximal size is around 2 billions ASCII characters, which sould be enough to store more than 25kloc source text.

val create : ?indent:int -> ?margin:int -> unit -> buffer

Create a buffer.

The right-margin is set to ~margin and maximum indentation to ~indent. Default values are those of Format.make_formatter, which are ~indent:68 and ~margin:78 in OCaml 4.05.

val message : buffer -> message

Buffer contents, with its formatting tags.

val add_char : buffer -> char -> unit


val add_string : buffer -> string -> unit


val add_substring : buffer -> string -> int -> int -> unit


val formatter : buffer -> Stdlib.Format.formatter
val bprintf : buffer -> ('a, Stdlib.Format.formatter, unit) Stdlib.format -> 'a
val kprintf : (Stdlib.Format.formatter -> 'a) -> buffer -> ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'b
val contents : buffer -> string

Similar to Buffer.contents

val sub : buffer -> int -> int -> string

Similar to Buffer.sub

val range : buffer -> int -> int -> string

Sub-string with range. range b p q is sub b p (q+1-p)

val trim : buffer -> int * int

Range of non-blank leading and trailing characters.

val shrink : buffer -> unit

Resize the buffer to roughly fit its actual content.


val to_string : ?indent:int -> ?margin:int -> ?trim:bool -> (Stdlib.Format.formatter -> 'a -> unit) -> 'a -> string

Dump the formatter into a string. Defaults are ~indent:20, ~margin:40 and ~trim:true.