llembas-term / linux (push) Canceled after 0s
The rename. Commands llembas-term, -gui, -mux-server, -setup; package llembas-term (Replaces, Conflicts and Provides llembas-tty, so installing it removes the old one); directories llembas-term; application id eu.llembas.term; the variables a pane sees LLEMBAS_TERM…; the status record llembas-term-status=1, the input mark llembas-term-input=1, the user variable llembas_term_status; the shell integration llembas-term.sh; the workflow llembas-term.yml; every changed upstream block is marked "LLeMbas TERM:". The terminal needs the engine's terminal contract 4 and says so in words with an older CLI. Carried over from the earlier name: the variables LLEMBAS_TTY… of a terminal that started this one are dropped; a configuration file of the old name is read where it is while there is none of the new, with a warning; command-history and settings-chosen are copied once into a data directory that does not exist yet (llembas-line::migrate); the set-up program prints the new line for an rc file that has the old one. Keys. Ctrl+Tab on the ask line switches the mode (the next tab anywhere else); Ctrl+Shift+M and Ctrl+Alt+M open the lists of chat and autocomplete models, also over the ask line, which then says the choice. In a pane where LLeMbas IDE says it is in front (user variable llembas_ide=1) the chords both have are sent on to it as the keyboard protocol's bytes and the terminal does nothing of its own; the terminal's palette is also on Ctrl+Shift+Alt+P. The built-in configuration honours the kitty keyboard protocol for a program that asks for it. CI: the .deb is installed over the released llembas-tty 1.0.0-beta.5; keys are pressed in a real window on Xvfb (not a gate). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
132 lines
5.5 KiB
Bash
Executable File
132 lines
5.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# The keys LLeMbas IDE has too, pressed for real: the built terminal in a window on a display
|
|
# of its own (Xvfb), a small program in its pane that says what LLeMbas IDE says and keeps the
|
|
# bytes it is sent, and keys pressed by xdotool.
|
|
#
|
|
# llembas/tests/keys-gui.sh <dir with llembas-term-gui>
|
|
#
|
|
# Three windows, one after the other:
|
|
# 1. a pane that says llembas_ide=1: chords the terminal itself has (the ask key, the mode
|
|
# key, the palette, the autocomplete-model key) arrive in the pane, each as the bytes the
|
|
# keyboard protocol has for it, and the terminal does nothing of its own;
|
|
# 2. the same pane after it asked for the keyboard protocol (as Neovim does): a chord the
|
|
# terminal has nothing on arrives told apart as well, by the terminal's own encoder;
|
|
# 3. a pane that says nothing: the ask key is the terminal's (what is typed next goes to
|
|
# the ask line, not to the pane), and an ordinary key arrives as the one byte it always was.
|
|
#
|
|
# Needs Xvfb and xdotool, and a software OpenGL for the window. Where the window cannot be
|
|
# made at all, that is said and the test stops with status 2: nothing was proven either way.
|
|
set -uo pipefail
|
|
BIN="$(cd "${1:?usage: keys-gui.sh <dir with the binaries>}" && pwd)"
|
|
|
|
work="$(mktemp -d)"
|
|
xvfb=""
|
|
term=""
|
|
failed=0
|
|
# shellcheck disable=SC2317 # reached through the trap
|
|
cleanup() {
|
|
if [ -n "$term" ]; then kill "$term" 2>/dev/null; wait "$term" 2>/dev/null; fi
|
|
if [ -n "$xvfb" ]; then kill "$xvfb" 2>/dev/null; wait "$xvfb" 2>/dev/null; fi
|
|
rm -rf "${work:?}"
|
|
}
|
|
trap cleanup EXIT
|
|
mkdir -p "$work/home" "$work/run" "$work/cfg"
|
|
chmod 700 "$work/run"
|
|
|
|
say() { [ -z "${GITHUB_ACTIONS:-}" ] || printf '::%s title=keys-gui::%s\n' "$1" "$(printf '%s' "$2" | head -c 900 | tr '\n\r' ' ' | sed 's/%/%25/g')"; }
|
|
ok() { echo "ok $1"; }
|
|
bad() { echo "FAIL $1"; say error "$1"; failed=1; }
|
|
unproven() { echo "SKIP $1"; say warning "not proven: $1"; exit 2; }
|
|
|
|
command -v Xvfb >/dev/null 2>&1 || unproven "no Xvfb here"
|
|
command -v xdotool >/dev/null 2>&1 || unproven "no xdotool here"
|
|
|
|
display=":97"
|
|
Xvfb "$display" -screen 0 1280x800x24 -nolisten tcp >"$work/xvfb.txt" 2>&1 &
|
|
xvfb=$!
|
|
for _ in $(seq 40); do
|
|
DISPLAY="$display" xdotool getdisplaygeometry >/dev/null 2>&1 && break
|
|
kill -0 "$xvfb" 2>/dev/null || unproven "Xvfb did not start: $(tail -c 300 "$work/xvfb.txt")"
|
|
sleep 0.25
|
|
done
|
|
|
|
xdo() { DISPLAY="$display" xdotool "$@"; }
|
|
|
|
# window <name> <what the program prints before it listens>: start the terminal with the
|
|
# program in its pane; the bytes the pane is sent are kept in $work/<name>.bytes.
|
|
window() {
|
|
local name="$1" intro="$2" wid=""
|
|
cat >"$work/$name.sh" <<PROGRAM
|
|
#!/bin/sh
|
|
printf '$intro'
|
|
stty raw -echo
|
|
: > "$work/$name.ready"
|
|
exec cat > "$work/$name.bytes"
|
|
PROGRAM
|
|
chmod +x "$work/$name.sh"
|
|
(exec env -i PATH=/usr/bin:/bin HOME="$work/home" XDG_RUNTIME_DIR="$work/run" XDG_CONFIG_HOME="$work/cfg" \
|
|
DISPLAY="$display" LIBGL_ALWAYS_SOFTWARE=1 \
|
|
"$BIN/llembas-term-gui" --config 'front_end="Software"' start --always-new-process -- "$work/$name.sh") >"$work/$name.txt" 2>&1 &
|
|
term=$!
|
|
for _ in $(seq 80); do
|
|
[ -e "$work/$name.ready" ] && wid="$(xdo search --class eu.llembas.term 2>/dev/null | tail -n1)" && [ -n "$wid" ] && break
|
|
kill -0 "$term" 2>/dev/null || break
|
|
sleep 0.25
|
|
done
|
|
if [ -z "$wid" ] || [ ! -e "$work/$name.ready" ]; then
|
|
unproven "the window could not be made here: $(tail -c 500 "$work/$name.txt")"
|
|
fi
|
|
xdo windowfocus --sync "$wid" 2>/dev/null || xdo windowfocus "$wid" 2>/dev/null
|
|
sleep 1.5
|
|
}
|
|
|
|
close_window() {
|
|
if [ -n "$term" ]; then kill "$term" 2>/dev/null; wait "$term" 2>/dev/null; fi
|
|
term=""
|
|
}
|
|
|
|
press() { xdo key --delay 60 "$@"; sleep 0.6; }
|
|
bytes() { od -An -tx1 "$work/$1.bytes" 2>/dev/null | tr -d ' \n'; }
|
|
expect() { # what, got, wanted
|
|
if [ "$2" = "$3" ]; then ok "$1"; else bad "$1: got [$2], wanted [$3]"; fi
|
|
}
|
|
|
|
ok "the window is found by its class, eu.llembas.term (checked at each window below)"
|
|
|
|
# 1. LLeMbas IDE in front. OSC 1337 SetUserVar=llembas_ide=<base64 of 1>.
|
|
window ide '\033]1337;SetUserVar=llembas_ide=MQ==\007'
|
|
press ctrl+shift+a
|
|
expect "IDE pane, Ctrl+Shift+A: CSI 97;6u" "$(bytes ide)" "1b5b39373b3675"
|
|
press ctrl+Tab
|
|
press ctrl+shift+p
|
|
press ctrl+alt+m
|
|
expect "IDE pane, then Ctrl+Tab, Ctrl+Shift+P, Ctrl+Alt+M: CSI 9;5u, CSI 112;6u, CSI 109;7u" "$(bytes ide)" \
|
|
"1b5b39373b36751b5b393b35751b5b3131323b36751b5b3130393b3775"
|
|
close_window
|
|
|
|
# 2. The same, and the program asked for the keyboard protocol (CSI > 1 u), as Neovim does.
|
|
window kitty '\033]1337;SetUserVar=llembas_ide=MQ==\007\033[>1u'
|
|
press ctrl+alt+shift+y
|
|
expect "a program that asked for the protocol, Ctrl+Alt+Shift+Y (no key of the terminal): CSI 121;8u" "$(bytes kitty)" "1b5b3132313b3875"
|
|
press ctrl+shift+a
|
|
expect "and Ctrl+Shift+A after it, the same form" "$(bytes kitty)" "1b5b3132313b38751b5b39373b3675"
|
|
close_window
|
|
|
|
# 3. Any other pane: the terminal's own keys, and an ordinary key as it always was.
|
|
window plain ''
|
|
press b
|
|
expect "a pane that says nothing, the key b: the one byte" "$(bytes plain)" "62"
|
|
press ctrl+shift+a
|
|
press x
|
|
expect "Ctrl+Shift+A there is the terminal's: what is typed next goes to the ask line, not the pane" "$(bytes plain)" "62"
|
|
press Escape
|
|
press c
|
|
expect "and after Escape the pane has its keys again" "$(bytes plain)" "6263"
|
|
close_window
|
|
|
|
if [ "$failed" -eq 0 ]; then
|
|
echo "keys-gui: all passed"
|
|
say notice "all passed: keys pressed in a real window reach an IDE pane as CSI u bytes, the protocol's encoder serves a program that asks, and any other pane is as before"
|
|
fi
|
|
exit "$failed"
|