File: promptWidget.template

package info (click to toggle)
dotfile 1%3A2.4-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,472 kB
  • ctags: 523
  • sloc: tcl: 14,072; sh: 918; makefile: 177; lisp: 18; ansic: 7
file content (247 lines) | stat: -rw-r--r-- 8,625 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
### Copyright (C) 1996,97 Per Zacho
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

proc promptWidget {default texthelp} {

    ### Time ###
    FillOutElm time -text "Current time"\
	    -show {print "<23:59:59>"}\
	    -save {print "\\t"}\
	    -help "Print the current time in 24 hour format. Time is only updated when a"\
	    "new prompt is issued."

    ### Date ###
    FillOutElm date -text "Current date"\
	    -show {print "<Wed July 17>"}\
	    -save {print "\\d"}\
	    -help "Print the date as \"Weekday Month Date\". Date is only updated when a"\
	    "new prompt is issued."

    ### Shell ###
    FillOutElm shell -text "Name of shell"\
	    -show {print "<bash>"}\
	    -save {print "\\s"}\
	    -help "Print the name of shell--usually \"bash\". The name is extracted from the"\
	    "basename (the portion following the final slash) of \$0 (the commandline which"\
	    "invoked the shell)."

    ### User ###
    FillOutElm user -text "Username"\
	    -show {print "<user>"}\
	    -save {print "\\u"}\
	    -help "Print the name of current user."

    ### Host ###
    FillOutElm host -text "Hostname"\
	    -show {print "<host>"}\
	    -save {print "\\h"}\
	    -help "Print the name of host."

    ### Directory ###
    Radio dirType -text "How much directory information to print?"\
	    -entryhelp {"entire directory" "Print the entire working directory."\
	    "basename of directory" "Print only the trailing part of current working directory."}\
	    -help "You can specify how much directory information to include when prompting."\
	    "Basename of directory is the portion following the final slash.\n"\
	    "Example: the basename of \"/usr/local/lib\" is \"lib\"."

    FillOutElm dir -text "Current working directory"\
	    -entries dirType\
	    -show {if {$dirType(index)} {print "<lib>"} {print "</usr/local/lib>"}}\
	    -save {if {$dirType(index)} {print "\\W"} {print "\\w"}}\
	    -help "Print the entire or basename of current working directory."

    ### History ###
    FillOutElm hist -text "History number"\
	    -show {print "<hist\#>"}\
	    -save {print "\\!"}\
	    -help "Print the history number of the command."

    ### Command ###
    FillOutElm comm -text "Command number"\
	    -show {print "<command\#>"}\
	    -save {print "\\\#"}\
	    -help "Print the command number of the command."

    ### Super user ###
    FillOutElm supusr -text "Super user char"\
	    -show {print "<\$>"}\
	    -save {print "\\$"}\
	    -help "Print a \$ for an ordinary user and a \# for a super user (root)."

    ### Newline ###
    FillOutElm newline -text "Newline"\
	    -show {print "\266"}\
	    -save {print "\\n"}\
	    -help "Force following information to wrap onto a new line."

    ### Special char ###
    Label label1 -text "Print a special character"\
	    -help "You can specify a character to display by its octal number."

    CheckBox backsl -text "Print a backslash"\
	    -default 0

    Entry specharEnt -text "Character number (octal)"\
	    -width 4\
	    -default "000"\
	    -help "Enter the octal number of character to display."\
	    "Remember to add prefix zeros if necessary."

    FillOutElm spechar -text "Special character"\
	    -entries label1 backsl specharEnt\
	    -show {if {$backsl} {print "<\\>"} {print "<\\$specharEnt>"}}\
	    -save {if {$backsl} {print "\\\\"} {print "\\$specharEnt"}}\
	    -change {if {$backsl} {Disable specharEnt} {Enable specharEnt}}\
	    -pageEnd {if {[string length $specharEnt] != 3 && [expr $backsl == 0]} {error "The octal number has an illegal size. It must be three ciffers wide."}}\
	    -help "Enter the octal number of character."\
	    "Remember to add prefix zeros if necessary."

    ### Colors ###
    set colorlistFG {"current color" "black" "darkgray" "red" "light red" "green" "light green"\
	    "brown" "yellow" "blue" "light blue" "purple" "light purple" "cyan" "light cyan"\
	    "light gray" "white"}

    set colorlistBG {"current color" "black" "red" "green" "brown" "blue" "purple" "cyan" "gray"}
    
    Header header1 -text "Colors"\
	    -background gray

    CheckBox defaultCol -text "Change to default colors and attributes"\
	    -default 1\
	    -help "Change to the default color settings."

    Line line1

    Label label2 -text "Character attributes"\
	    -anchor center

    CheckBox underline -text "Underlined"\
	    -help "Apply underline to characters."\
	    -anchor center\
	    -pack:fill x

    CheckBox flashing -text "Flashing (blinking)"\
	    -help "Make characters flash."\
	    -anchor center\
	    -pack:fill x

    Frame frame1 -entries {underline flashing}\
	    -orient left


    Line line2

    Menu foreground -text "Foreground color"\
	    -entries $colorlistFG\
	    -help "Choose which color for text (foreground)."\
	    -width 10\
	    -defaultIndex 15

    Menu background -text "Background color"\
	    -entries $colorlistBG\
	    -help "Choose which color to use under characters (background)."\
	    -width 10\
	    -defaultIndex 1

    Frame frame2 -entries {foreground background}\
	    -orient left

    FillOutElm colors -text "Colors"\
	    -entries {header1 defaultCol line1 label2 frame1 line2 frame2}\
	    -init {Disable label2; Disable frame1; Disable frame2}\
	    -change {if {$defaultCol} {Disable label2; Disable frame1; Disable frame2} {Enable label2; Enable frame1; Enable frame2}}\
	    -show {
	      set temp ""
	      if {$defaultCol} {
	        append temp "color default"
	      } {
	        if {$underline} {
		  append temp "underline,"
	        }
	        if {$flashing} {
		  append temp "flashing,"
	        }
	        if {$foreground(index)} {
		  append temp "fg:$foreground(name),"
	        }
	        if {$background(index)} {
		  append temp "bg:$background(name)"
	        }
	      }
	      set temp [string trim $temp ","]
	      if {$temp != ""} {
	        print "<$temp>"
                }
	    }\
	    -save {
	      set ansicodeFG {"current color" "30" "1;30" "31" "1;31" "32" "1;32" "33" "1;33"\
		      "34" "1;34" "35" "1;35" "36" "1;36" "37" "1;37"}
	      set ansicodeBG {"current color" "40" "41" "42" "43" "44" "45" "46" "47"}
	      set temp ""
	      if {$defaultCol} {
	        append temp "0"
	      } {
	        if {$underline} {
		  append temp "4;"
	        }
	        if {$flashing} {
		  append temp "5;"
	        }
	        if {$foreground(index)} {
		  append temp "[lindex $ansicodeFG $foreground(index)];"
	        }
	        if {$background(index)} {
		  append temp "[lindex $ansicodeBG $background(index)]"
	        }
	      }
	      set temp [string trim $temp ";"]
	      if {$temp != ""} {
		  print "\\\[\\033\[${temp}m\\\]"
                }
	    }\
	    -help "Choose colors for prompt. Not all terminals support colors--to make use"\
	    "of this option, you must choose a terminal that is ISO6429 (VT100/ANSI) compatible."

    ### TTY codes ###
    Entry extra -text "Non-printing characters"\
	    -help "Codes to send to the TTY. These codes could alter screen colors, clear rest"\
	    "of the commandline, or the entire screen. Codes here depend on what kind of"\
	    "terminal you use--most common is the VT100 or compatible."

    FillOutElm ttycode -text "Non-printing characters"\
	    -entries extra\
	    -help "Codes to send to the TTY. These codes could alter screen colors, clear rest"\
	    "of the commandline, or the entire screen. Codes here depend on what kind of"\
	    "terminal you use--most common is the VT100 or compatible."

    ### FillOut ###
    set help [lindex $texthelp 1]
    set text [lindex $texthelp 0]
    set elem {time date shell user host dir hist comm supusr newline spechar colors ttycode}

    Header head1 -text $text\
	    -background gray\
	    -help "Setup of $text."
    
    FillOut prompt -text ""\
	    -entries $elem\
	    -default $default\
	    -listbox:width 50\
	    -listbox:height [llength $elem]\
	    -help [join $help]\
	    -packFrame:anchor center
}