1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 # T2 SDE: package/*/stone/stone_gui_text.sh
5 # Copyright (C) 2004 - 2021 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 # Use: gui_menu "ID" "Title" "Text" "Action" [ "Text" "Action" [ .. ] ]
19 echo ; echo "+---" ; echo "$2" |
fold -s -w70 |
sed 's,^,| ,'
20 echo "+---" ; echo ; shift ; shift ; local nr
=1 xnr
=1 y
in
22 while [ $# -ge 2 ] ; do
26 echo " $1" ; shift ; shift
28 echo " - $1" ; shift ; shift
31 printf '%5d. %s\n' "$nr" "$1"
32 eval "local action_$nr=\"\$y\""
33 (( nr
++ )) ; shift ; shift
36 if [ $
(( $xnr % 20 )) -eq 0 -a $# -gt 4 ] ; then
37 echo ; echo -n ">> " ; read in ||
return 1
43 if [ -z "$in" ] ; then echo ; echo -n "> " ; read in ; fi
44 in="action_$in" ; [ -z "${!in}" ] && return 1
45 eval "${!in}" ; return 0
48 # Use: gui_input "Text" "Default" "VarName"
51 echo ; echo "+---" ; echo "$1" |
fold -s -w66 |
sed 's,^,| ,'
52 echo "+---" ; echo ; echo -n "[ $2 ] > " ; local tmp
53 read tmp
&& [ -z "$tmp" ] && tmp
="$2" ; eval "$3=\"\$tmp\""
56 # Use: gui_yesno "Text"
58 # [returns 0 if yes, 1 if no]
60 local input y
="[y]" n
=" n "
62 echo ; echo "+---"; echo "$1" |
fold -s -w66 |
sed 's,^,| ,'
69 if [ "$input" = "" ]; then break
70 elif [ "$input" = "y" ]; then y
="[y]"; n
=" n "
71 elif [ "$input" = "n" ]; then y
=" y "; n
="[n]"
75 [ "$input" = "[y]" ] && return 0
79 # Use: gui_message "Text"
82 echo ; echo "+---" ; echo "$1" |
fold -s -w66 |
sed 's,^,| ,'
83 echo "+---" ; echo ; echo "== Press ENTER to continue ==" ; read
86 # Use: gui_edit "Text" "File"
90 for x
in $EDITOR vi nvi emacs xemacs pico
; do
91 if type -p $x > /dev
/null
92 then xx
=$x ; break ; fi
97 gui_message
"Cannot find any editor. Make sure \$EDITOR is set."
101 # Use: gui_cmd "Title" "Command"
105 read -p "Press ENTER to continue."