On this page:
char-ascii/  c
code-param/  c
code-param-list/  c
code-param-separator
code-param->string
code-param-list->string

1 Common Predicates🔗ℹ

 (require ansi-terminal) package: ansi-terminal

Many control codes accept parameters which are either numeric values or ASCII characters. The following predicates are used for parameter checking.

value

char-ascii/c : flat-contract?

Ensures a character is in the range of the 7-bit ASCII character set.

value

code-param/c : flat-contract?

Ensures a numeric value in the range of an 8-bit unsigned byte.

value

code-param-list/c : contract?

Ensures either a single code-param/c value or a list of code-param/c values.

This value is the separator character used to print a list of parameters with code-param-list->string.

procedure

(code-param->string val)  string?

  val : code-param/c
Convert a single code-param/c to a string.

Examples:
> (code-param->string 22)

"22"

> (code-param->string 7)

"7"

> (code-param->string (char->integer #\λ))

code-param->string: contract violation

  expected: (<=/c 127)

  given: 955

  in: an and/c case of

      the 1st argument of

      (->

       (and/c

        natural-number/c

        (>=/c 0)

        (<=/c 127))

       string?)

  contract from: <pkgs>/ansi-terminal/main.rkt

  blaming: top-level

   (assuming the contract is correct)

  at: <pkgs>/ansi-terminal/main.rkt:11:24

procedure

(code-param-list->string val)  string?

  val : (or/c code-param/c code-param-list/c)
Convert a code-param-list/c to a string.

Examples:
> (code-param-list->string '(22 34))

"22;34"

> (code-param-list->string '(41))

"41"

> (code-param-list->string 46)

"46"

> (code-param-list->string (char->integer #\λ))

code-param-list->string: contract violation

  expected: (or/c (and/c natural-number/c (>=/c 0) (<=/c

127)) (listof (and/c natural-number/c (>=/c 0) (<=/c 127))))

  given: 955

  in: the 1st argument of

      (->

       (or/c

        (and/c

         natural-number/c

         (>=/c 0)

         (<=/c 127))

        (listof

         (and/c

          natural-number/c

          (>=/c 0)

          (<=/c 127))))

       string?)

  contract from: <pkgs>/ansi-terminal/main.rkt

  blaming: top-level

   (assuming the contract is correct)

  at: <pkgs>/ansi-terminal/main.rkt:12:24