pq.q

The session itself: version, open connections, terminal size and colour support, and the standard-library load sequence. Nothing here is loaded at start-up: the first reference to any .pq name loads this file, whose first line - .pq.load_natives`pq, the one .pq member that exists before it runs - binds the C functions it calls. The console's syntax colours are .pq.hl.

Examples

.pq.version
select handle, alias from .pq.conns[]

Entity Summary

EntitiesShort Description
.pq.cancolor[]Whether stdout should carry ANSI colour: PEACHQ_COLORS=0/1 overrides everything, then NO_COLOR (off), FORCE_COLOR (on), else a tty whose TERM is not dumb.
.pq.conns[]Every open connection, one row each.
.pq.dr[verb]Print a verb's domain and range grid in the layout the KX reference pages use, probed by casting a sample of every type: a lower-case letter is an atom result, upper-case a list, "." an error.
.pq.hlThe console's syntax colours, role to colour, read by the highlighter at each redraw.
.pq.load[files]Load standard-library files not already loaded; \l pq/.q and \l pq always reload.
.pq.summary[t]One line of facts about a table, one per column in column order: numeric columns as min-max, booleans as the share true, everything else as a distinct count (`all distinct` when every row differs; a temporal column that repeats shows its range), with a null count where there are nulls.
.pq.termsize[]The live terminal size, with the 25/80 fallback and [10,2000] clamp that \c 0N uses.
.pq.versionThe peachq version string.

Entity Details

.pq.cancolor[]

Whether stdout should carry ANSI colour: PEACHQ_COLORS=0/1 overrides everything, then NO_COLOR (off), FORCE_COLOR (on), else a tty whose TERM is not dumb.

Return: boolean

Examples

.pq.cancolor[]

.pq.conns[]

Every open connection, one row each. The single-letter columns p f z n m are the -38! names so kdb code ports.

Columns:
  • alias - the :pq: alias, when the connection opened with one
  • handle - what hclose takes: the alias symbol of a :pq: provider, else the fd int

Examples

.pq.conns[]

.pq.dr[verb]

Print a verb's domain and range grid in the layout the KX reference pages use, probed by casting a sample of every type: a lower-case letter is an atom result, upper-case a list, "." an error. After KX's tools.q (qdocs/docs/docs/tools.q, CC BY 4.0).

Parameters:
  • verb - a symbol or char naming a verb in .Q.ops[], or a function

Examples

.pq.dr `neg
.pq.dr "+"

.pq.hl

The console's syntax colours, role to colour, read by the highlighter at each redraw. Roles: kw keywords, str strings, esc string escapes, cmt comments, sym symbols, num numbers, tmp temporals and typed nulls, op verbs and adverbs, sys system names, cmd \ commands, match the bracket or quote pair at the cursor. A colour is an int 0-255 (a 256-colour foreground) or a string of digits and ; used as the SGR parameters. A role left out, or given anything else, keeps its default; with colour off (.pq.cancolor) nothing is coloured. Amend in place (.pq.hl[`kw]:141) or set it in QINIT; loading this file again resets it. The defaults mirror the C table in src/qlang/repl/q_highlight.c - change both together.

.pq.load[files]

Load standard-library files not already loaded; \l pq/.q and \l pq always reload.

Return: (symbol list) the files this call loaded
Parameters:
  • files - (symbol|symbol list) the files to load; [] for every library file

Examples

.pq.load`regexp

.pq.summary[t]

One line of facts about a table, one per column in column order: numeric columns as min-max, booleans as the share true, everything else as a distinct count (`all distinct` when every row differs; a temporal column that repeats shows its range), with a null count where there are nulls. The same facts the console digest prints under a clipped table, so the two never disagree.

Return: string, `-1`-ready
Parameters:
  • t - (table) a table or keyed table

Examples

.pq.summary ([]a:1 2 3;b:`x`y`x)

.pq.termsize[]

The live terminal size, with the 25/80 fallback and [10,2000] clamp that \c 0N uses.

Return: (rows;cols)

Examples

.pq.termsize[]