package wax-lib

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wax_utils.ColorsSource

Sourcetype flag =
  1. | Never
  2. | Always
  3. | Auto

Determines whether color output should be used.

Sourceval should_use_color : color:flag -> out_channel:out_channel option -> bool

should_use_color ~color ~out_channel checks if ANSI color codes should be emitted based on the color flag and the out_channel. If Auto, it checks for `NO_COLOR` environment variable, `TERM` environment variable, and if out_channel is a TTY.

Sourceval update_flag : color:flag -> flag

update_flag ~color ~out_channel checks if ANSI color codes should be emitted based on the color flag and stdout. If Auto, it checks for `NO_COLOR` environment variable, `TERM` environment variable, and if stdout is a TTY.

Sourcemodule Ansi : sig ... end

ANSI escape codes for basic text formatting and colors.

Sourcetype style =
  1. | Keyword
    (*

    For language keywords (e.g., `func`, `let`, `if` in Wax; `module`, `func`, `(type ...)` in Wasm).

    *)
  2. | Instruction
    (*

    For Wasm instructions (e.g., `i32.add`, `call $func`).

    *)
  3. | Attribute
    (*

    For attributes (e.g., `offset=4`, `align=2` in Wasm; Rust-like attributes like `#derive(...)`).

    *)
  4. | Type
    (*

    For type names (e.g., `i32`, `f64`, `funcref`).

    *)
  5. | Identifier
    (*

    For variable, function, or type identifiers.

    *)
  6. | Constant
    (*

    For numeric or boolean literals (e.g., `123`, `0.5`, `true`).

    *)
  7. | String
    (*

    For string literals.

    *)
  8. | Operator
    (*

    For operators (e.g., `+`, `-`, `=`, `!`).

    *)
  9. | Annotation
    (*

    For annotations (e.g., `(@custom)` in Wasm; Rust macros like `vec!`).

    *)
  10. | Comment
    (*

    For comments in the code.

    *)
  11. | Punctuation
    (*

    For structural punctuation (e.g., (, ), :, ;, ,).

    *)

style represents a semantic category for syntax highlighting.

Sourcetype theme = {
  1. keyword : string;
  2. instruction : string;
  3. attribute : string;
  4. type_ : string;
  5. identifier : string;
  6. constant : string;
  7. string : string;
  8. operator : string;
  9. annotation : string;
  10. comment : string;
  11. punctuation : string;
  12. reset : string;
}

theme defines the ANSI escape codes for each syntax style.

Sourceval escape_sequence : theme -> style -> string

escape_sequence theme style returns the ANSI escape code for the given style from the provided theme.

Sourceval wax_theme : theme

The Wax source palette: used by Wax_lang.Output to render Wax source, and by diagnostics to colour a Wax AST fragment embedded in a message.

Sourceval wat_theme : theme

The WebAssembly-text source palette: used by Wax_wasm.Output to render WAT source, and by diagnostics to colour a WAT AST fragment embedded in a message (e.g. types in red rather than the Wax cyan).

Sourceval no_color : theme

A theme that produces no color output, used when coloring is disabled.