-
Notifications
You must be signed in to change notification settings - Fork 18
terminal.q
This library can track changes to the current terminal window that kdb+ is running in and adjust the kdb console size (system "c"
) to match it.
The adjustment can be done manually (via .terminal.setToCurrentSize
) or automatically via the .z.pi
event hander.
Automatic update of the kdb+ console size to the current terminal window is configured by .terminal.cfg.trackSizeChange
.
If enabled, and the current terminal is interactive, the .z.pi
event handler function will be set.
Any existing .z.pi
function will be kept and wrapped by .terminal.i.trackHandler
. If no existing .z.pi
function exists, a default .terminal.cfg.defaultZPi
function will be used instead.
This function changes the kdb+ console size to match the current terminal window size.
/ With TRACE logging enabled
q)\c
25 80i
q).terminal.setToCurrentSize[]
2020.05.16 20:00:24.128 DEBUG pid-1218 jas 0 Running system command: "stty size"
2020.05.16 20:00:24.140 TRACE pid-1218 jas 0 Console size change [ Old: 25 80i ] [ New: 84 157 ]
q)\c
84 157i
This function returns true if the current kdb process is running interactively, false otherwise.
/ Interactive session with "rlwrap $QHOME/l64/q src/require.q"
q).require.init[]; .require.lib`terminal
...
q).terminal.isInteractive[]
Running system command: "stty size"
Running system command: "tty --quiet; echo $?"
Current kdb process terminal state [ Interactive: yes ]
1b
# Non-interactive session
> echo '.require.init[]; .require.lib`terminal; -1 .Q.s .terminal.isInteractive[];' | $QHOME/l64/q src/require.q
...
Running system command: "tty --quiet; echo $?"
Current kdb process terminal state [ Interactive: no ]
0b
Copyright (C) Sport Trades Ltd 2017 - 2020, John Keys and Jaskirat Rajasansir 2020 - 2024