Files
RedBear-OS/recipes/shells/zsh/source/Functions/Zle/read-from-minibuffer
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

61 lines
1.3 KiB
Plaintext

emulate -L zsh
setopt extendedglob
local opt keys
integer stat
while getopts "k:" opt; do
case $opt in
# Read the given number of keys. This is a bit
# ropey for more than a single key.
(k)
keys=$OPTARG
;;
(*)
return 1
;;
esac
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
local readprompt="$1" lbuf_init="$2" rbuf_init="$3"
integer savelim=$UNDO_LIMIT_NO changeno=$UNDO_CHANGE_NO
{
# Use anonymous function to make sure special values get restored,
# even if this function is called as a widget.
# local +h ensures special parameters stay special.
() {
local pretext="$PREDISPLAY$LBUFFER$RBUFFER$POSTDISPLAY
"
local +h LBUFFER="$lbuf_init"
local +h RBUFFER="$rbuf_init"
local +h PREDISPLAY="$pretext${readprompt:-? }"
local +h POSTDISPLAY=
local +h -a region_highlight
region_highlight=("P${#pretext} ${#PREDISPLAY} bold")
if [[ -n $keys ]]; then
zle -R
read -k $keys
stat=$?
else
local NUMERIC
unset NUMERIC
zle split-undo
UNDO_LIMIT_NO=$UNDO_CHANGE_NO
zle recursive-edit -K main
stat=$?
(( stat )) || REPLY=$BUFFER
fi
}
} always {
# This removes the edits relating to the read from the undo history.
# These aren't useful once we get back to the main editing buffer.
zle undo $changeno
UNDO_LIMIT_NO=savelim
}
return $stat