]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/miscellany/less-177/opttbl.c
8 #define toupper(c) ((c)-'a'+'A')
11 * Variables controlled by command line options.
13 public int quiet
; /* Should we suppress the audible bell? */
14 public int how_search
; /* Where should forward searches start? */
15 public int top_scroll
; /* Repaint screen from top?
16 (alternative is scroll from bottom) */
17 public int pr_type
; /* Type of prompt (short, medium, long) */
18 public int bs_mode
; /* How to process backspaces */
19 public int know_dumb
; /* Don't complain about dumb terminals */
20 public int quit_at_eof
; /* Quit after hitting end of file twice */
21 public int squeeze
; /* Squeeze multiple blank lines into one */
22 public int tabstop
; /* Tab settings */
23 public int back_scroll
; /* Repaint screen on backwards movement */
24 public int forw_scroll
; /* Repaint screen on forward movement */
25 public int twiddle
; /* Display "~" for lines after EOF */
26 public int caseless
; /* Do "caseless" searches */
27 public int linenums
; /* Use line numbers */
28 public int cbufs
; /* Current number of buffers */
29 public int autobuf
; /* Automatically allocate buffers as needed */
30 public int nohelp
; /* Disable the HELP command */
31 public int ctldisp
; /* Send control chars to screen untranslated */
32 public int force_open
; /* Open the file even if not regular file */
33 public int swindow
; /* Size of scrolling window */
34 public int jump_sline
; /* Screen line of "jump target" */
35 public int chopline
; /* Truncate displayed lines at screen width */
37 public int output_mode
; /* Which screen output method */
38 public int refresh_on_quit
; /* Repaint screen on quit, if possible */
42 * Table of all options and their semantics.
44 static struct option option
[] =
46 { 'a', BOOL
, 0, &how_search
, NULL
,
47 "Search includes displayed screen",
48 "Search skips displayed screen",
51 { 'b', NUMBER
, 10, &cbufs
, opt_b
,
56 { 'B', BOOL
, 1, &autobuf
, NULL
,
57 "Don't automatically allocate buffers",
58 "Automatically allocate buffers when needed",
61 { 'c', TRIPLE
, 0, &top_scroll
, NULL
,
62 "Repaint by scrolling from bottom of screen",
63 "Repaint by clearing each line",
64 "Repaint by painting from top of screen"
66 { 'd', BOOL
|NO_TOGGLE
, 0, &know_dumb
, NULL
,
67 "Assume intelligent terminal",
68 "Assume dumb terminal",
71 { 'e', TRIPLE
, 0, &quit_at_eof
, NULL
,
72 "Don't quit at end-of-file",
73 "Quit at end-of-file",
74 "Quit immediately at end-of-file"
76 { 'f', BOOL
, 0, &force_open
, NULL
,
77 "Open only regular files",
78 "Open even non-regular files",
81 { 'h', NUMBER
, -1, &back_scroll
, NULL
,
82 "Backwards scroll limit: ",
83 "Backwards scroll limit is %d lines",
86 { 'H', BOOL
|NO_TOGGLE
, 0, &nohelp
, NULL
,
88 "Don't allow help command",
91 { 'i', BOOL
, 0, &caseless
, NULL
,
92 "Case is significant in searches",
93 "Ignore case in searches",
96 { 'j', NUMBER
, 1, &jump_sline
, NULL
,
98 "Position target at screen line %d",
102 { 'k', STRING
|NO_TOGGLE
, 0, NULL
, opt_k
,
107 { 'l', STRING
, 0, NULL
, opt_l
,
110 { 'L', STRING
, 0, NULL
, opt__L
,
114 { 'm', TRIPLE
, 0, &pr_type
, NULL
,
119 { 'n', TRIPLE
|REPAINT
, 1, &linenums
, NULL
,
120 "Don't use line numbers",
122 "Constantly display line numbers"
125 { 'o', STRING
, 0, NULL
, opt_o
,
126 "log file: ", NULL
, NULL
128 { 'O', STRING
, 0, NULL
, opt__O
,
129 "Log file: ", NULL
, NULL
132 { 'p', STRING
|NO_TOGGLE
, 0, NULL
, opt_p
,
135 { 'P', STRING
, 0, NULL
, opt__P
,
136 "prompt: ", NULL
, NULL
138 { 'q', TRIPLE
, 0, &quiet
, NULL
,
139 "Ring the bell for errors AND at eof/bof",
140 "Ring the bell for errors but not at eof/bof",
141 "Never ring the bell"
143 { 'r', BOOL
|REPAINT
, 1, &ctldisp
, NULL
,
144 "Display control characters directly",
145 "Display control characters as ^X",
149 { 'R', BOOL
|REPAINT
, 0, &refresh_on_quit
, NULL
,
150 "Don't repaint screen on quit",
151 "Repaint screen on quit",
155 { 's', BOOL
|REPAINT
, 0, &squeeze
, NULL
,
156 "Display all blank lines",
157 "Squeeze multiple blank lines",
160 { 'S', BOOL
|REPAINT
, 0, &chopline
, NULL
,
166 { 't', STRING
, 0, NULL
, opt_t
,
169 { 'T', STRING
, 0, NULL
, opt__T
,
170 "tags file: ", NULL
, NULL
173 { 'u', TRIPLE
|REPAINT
, 0, &bs_mode
, NULL
,
174 "Display underlined text in underline mode",
175 "Backspaces cause overstrike",
176 "Print backspace as ^H"
179 { 'v', TRIPLE
|NO_TOGGLE
, 0, &output_mode
, opt_v
,
180 "Output is to standard output, using ansi screen control",
181 "Output is to video BIOS",
182 "Output is directly to memory mapped video"
185 { 'w', BOOL
|REPAINT
, 1, &twiddle
, NULL
,
186 "Display nothing for lines after end-of-file",
187 "Display ~ for lines after end-of-file",
192 #define W_FLAGS STRING
194 #define W_FLAGS STRING|NO_TOGGLE
196 { 'W', W_FLAGS
, 0, NULL
, opt_W
,
197 "window boundaries: ", NULL
, NULL
201 { 'x', NUMBER
|REPAINT
, 8, &tabstop
, NULL
,
203 "Tab stops every %d spaces",
206 { 'y', NUMBER
, -1, &forw_scroll
, NULL
,
207 "Forward scroll limit: ",
208 "Forward scroll limit is %d lines",
211 { 'z', NUMBER
, -1, &swindow
, NULL
,
212 "Scroll window size: ",
213 "Scroll window size is %d lines",
216 { '?', NOVAR
, 0, NULL
, opt_query
,
224 * Initialize each option to its default value.
229 register struct option
*o
;
231 for (o
= option
; o
->oletter
!= '\0'; o
++)
234 * Set each variable to its default.
237 *(o
->ovar
) = o
->odefault
;
242 * Find an option in the option table.
244 public struct option
*
248 register struct option
*o
;
250 for (o
= option
; o
->oletter
!= '\0'; o
++)
254 if ((o
->otype
& TRIPLE
) && toupper(o
->oletter
) == c
)