#define toupper(c) ((c)-'a'+'A')
* Variables controlled by command line options.
public int quiet
; /* Should we suppress the audible bell? */
public int how_search
; /* Where should forward searches start? */
public int top_scroll
; /* Repaint screen from top?
(alternative is scroll from bottom) */
public int pr_type
; /* Type of prompt (short, medium, long) */
public int bs_mode
; /* How to process backspaces */
public int know_dumb
; /* Don't complain about dumb terminals */
public int quit_at_eof
; /* Quit after hitting end of file twice */
public int squeeze
; /* Squeeze multiple blank lines into one */
public int tabstop
; /* Tab settings */
public int back_scroll
; /* Repaint screen on backwards movement */
public int forw_scroll
; /* Repaint screen on forward movement */
public int twiddle
; /* Display "~" for lines after EOF */
public int caseless
; /* Do "caseless" searches */
public int linenums
; /* Use line numbers */
public int cbufs
; /* Current number of buffers */
public int autobuf
; /* Automatically allocate buffers as needed */
public int nohelp
; /* Disable the HELP command */
public int ctldisp
; /* Send control chars to screen untranslated */
public int force_open
; /* Open the file even if not regular file */
public int swindow
; /* Size of scrolling window */
public int jump_sline
; /* Screen line of "jump target" */
public int chopline
; /* Truncate displayed lines at screen width */
public int output_mode
; /* Which screen output method */
public int refresh_on_quit
; /* Repaint screen on quit, if possible */
* Table of all options and their semantics.
static struct option option
[] =
{ 'a', BOOL
, 0, &how_search
, NULL
,
"Search includes displayed screen",
"Search skips displayed screen",
{ 'b', NUMBER
, 10, &cbufs
, opt_b
,
{ 'B', BOOL
, 1, &autobuf
, NULL
,
"Don't automatically allocate buffers",
"Automatically allocate buffers when needed",
{ 'c', TRIPLE
, 0, &top_scroll
, NULL
,
"Repaint by scrolling from bottom of screen",
"Repaint by clearing each line",
"Repaint by painting from top of screen"
{ 'd', BOOL
|NO_TOGGLE
, 0, &know_dumb
, NULL
,
"Assume intelligent terminal",
{ 'e', TRIPLE
, 0, &quit_at_eof
, NULL
,
"Don't quit at end-of-file",
"Quit immediately at end-of-file"
{ 'f', BOOL
, 0, &force_open
, NULL
,
"Open only regular files",
"Open even non-regular files",
{ 'h', NUMBER
, -1, &back_scroll
, NULL
,
"Backwards scroll limit: ",
"Backwards scroll limit is %d lines",
{ 'H', BOOL
|NO_TOGGLE
, 0, &nohelp
, NULL
,
"Don't allow help command",
{ 'i', BOOL
, 0, &caseless
, NULL
,
"Case is significant in searches",
"Ignore case in searches",
{ 'j', NUMBER
, 1, &jump_sline
, NULL
,
"Position target at screen line %d",
{ 'k', STRING
|NO_TOGGLE
, 0, NULL
, opt_k
,
{ 'l', STRING
, 0, NULL
, opt_l
,
{ 'L', STRING
, 0, NULL
, opt__L
,
{ 'm', TRIPLE
, 0, &pr_type
, NULL
,
{ 'n', TRIPLE
|REPAINT
, 1, &linenums
, NULL
,
"Don't use line numbers",
"Constantly display line numbers"
{ 'o', STRING
, 0, NULL
, opt_o
,
{ 'O', STRING
, 0, NULL
, opt__O
,
{ 'p', STRING
|NO_TOGGLE
, 0, NULL
, opt_p
,
{ 'P', STRING
, 0, NULL
, opt__P
,
{ 'q', TRIPLE
, 0, &quiet
, NULL
,
"Ring the bell for errors AND at eof/bof",
"Ring the bell for errors but not at eof/bof",
{ 'r', BOOL
|REPAINT
, 1, &ctldisp
, NULL
,
"Display control characters directly",
"Display control characters as ^X",
{ 'R', BOOL
|REPAINT
, 0, &refresh_on_quit
, NULL
,
"Don't repaint screen on quit",
"Repaint screen on quit",
{ 's', BOOL
|REPAINT
, 0, &squeeze
, NULL
,
"Display all blank lines",
"Squeeze multiple blank lines",
{ 'S', BOOL
|REPAINT
, 0, &chopline
, NULL
,
{ 't', STRING
, 0, NULL
, opt_t
,
{ 'T', STRING
, 0, NULL
, opt__T
,
"tags file: ", NULL
, NULL
{ 'u', TRIPLE
|REPAINT
, 0, &bs_mode
, NULL
,
"Display underlined text in underline mode",
"Backspaces cause overstrike",
{ 'v', TRIPLE
|NO_TOGGLE
, 0, &output_mode
, opt_v
,
"Output is to standard output, using ansi screen control",
"Output is to video BIOS",
"Output is directly to memory mapped video"
{ 'w', BOOL
|REPAINT
, 1, &twiddle
, NULL
,
"Display nothing for lines after end-of-file",
"Display ~ for lines after end-of-file",
#define W_FLAGS STRING|NO_TOGGLE
{ 'W', W_FLAGS
, 0, NULL
, opt_W
,
"window boundaries: ", NULL
, NULL
{ 'x', NUMBER
|REPAINT
, 8, &tabstop
, NULL
,
"Tab stops every %d spaces",
{ 'y', NUMBER
, -1, &forw_scroll
, NULL
,
"Forward scroll limit: ",
"Forward scroll limit is %d lines",
{ 'z', NUMBER
, -1, &swindow
, NULL
,
"Scroll window size is %d lines",
{ '?', NOVAR
, 0, NULL
, opt_query
,
* Initialize each option to its default value.
register struct option
*o
;
for (o
= option
; o
->oletter
!= '\0'; o
++)
* Set each variable to its default.
*(o
->ovar
) = o
->odefault
;
* Find an option in the option table.
register struct option
*o
;
for (o
= option
; o
->oletter
!= '\0'; o
++)
if ((o
->otype
& TRIPLE
) && toupper(o
->oletter
) == c
)