1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/stone/stone_gui_text.sh
3 # Copyright (C) 2004 - 2023 The T2 SDE Project
4 # Copyright (C) 1998 - 2003 ROCK Linux Project
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 # Use: gui_menu "ID" "Title" "Text" "Action" [ "Text" "Action" [ .. ] ]
16 echo ; echo "+---" ; echo "$2" |
fold -s -w70 |
sed 's,^,| ,'
17 echo "+---" ; echo ; shift ; shift ; local nr
=1 xnr
=1 y
in
19 while [ $# -ge 2 ] ; do
23 echo " $1" ; shift ; shift
25 echo " - $1" ; shift ; shift
28 printf '%5d. %s\n' "$nr" "$1"
29 eval "local action_$nr=\"\$y\""
30 (( nr
++ )) ; shift ; shift
33 if [ $
(( $xnr % 20 )) -eq 0 -a $# -gt 4 ]; then
34 echo ; echo -n ">> " ; read in ||
return 1
40 if [ -z "$in" ]; then echo ; echo -n "> " ; read in; fi
41 in="action_$in" ; [ -z "${!in}" ] && return 1
42 eval "${!in}" ; return 0
45 # Use: gui_input "Text" "Default" "VarName"
48 echo ; echo "+---" ; echo "$1" |
fold -s -w66 |
sed 's,^,| ,'
49 echo "+---" ; echo ; echo -n "[ $2 ] > " ; local tmp
50 read tmp
&& [ -z "$tmp" ] && tmp
="$2" ; eval "$3=\"\$tmp\""
53 # Use: gui_yesno "Text"
55 # [returns 0 if yes, 1 if no]
57 local input y
="[y]" n
=" n "
59 echo ; echo "+---"; echo "$1" |
fold -s -w66 |
sed 's,^,| ,'
66 if [ "$input" = "" ]; then break
67 elif [ "$input" = "y" ]; then y
="[y]"; n
=" n "
68 elif [ "$input" = "n" ]; then y
=" y "; n
="[n]"
72 [ "$y" = "[y]" ] && return 0
76 # Use: gui_message "Text"
79 echo ; echo "+---" ; echo "$1" |
fold -s -w66 |
sed 's,^,| ,'
80 echo "+---" ; echo ; echo "== Press ENTER to continue ==" ; read
83 # Use: gui_edit "Text" "File"
87 for x
in $EDITOR vi nvi emacs xemacs pico
; do
88 if type -p $x > /dev
/null
89 then xx
=$x ; break; fi
94 gui_message
"Cannot find any editor. Make sure \$EDITOR is set."
98 # Use: gui_cmd "Title" "Command"
102 read -p "Press ENTER to continue."