2012-07-23 21:31:53 +00:00
|
|
|
/*
|
2016-01-04 00:22:34 +00:00
|
|
|
* Copyright (C) 1984-2015 Mark Nudelman
|
2012-07-23 21:31:53 +00:00
|
|
|
*
|
|
|
|
* You may distribute under the terms of either the GNU General Public
|
|
|
|
* License or the Less License, as specified in the README file.
|
|
|
|
*
|
|
|
|
* For more information, see the README file.
|
|
|
|
*/
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The option table.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "less.h"
|
|
|
|
#include "option.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 quit_if_one_screen; /* Quit if EOF on first screen */
|
|
|
|
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 caseless; /* Do "caseless" searches */
|
|
|
|
public int linenums; /* Use line numbers */
|
|
|
|
public int autobuf; /* Automatically allocate buffers as needed */
|
2004-04-17 07:16:34 +00:00
|
|
|
public int bufspace; /* Max buffer space per file (K) */
|
2000-05-22 09:53:22 +00:00
|
|
|
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" */
|
2007-06-04 01:42:54 +00:00
|
|
|
public long jump_sline_fraction = -1;
|
2009-07-27 07:05:08 +00:00
|
|
|
public long shift_count_fraction = -1;
|
2000-05-22 09:53:22 +00:00
|
|
|
public int chopline; /* Truncate displayed lines at screen width */
|
|
|
|
public int no_init; /* Disable sending ti/te termcap strings */
|
2002-01-07 20:29:38 +00:00
|
|
|
public int no_keypad; /* Disable sending ks/ke termcap strings */
|
2000-05-22 09:53:22 +00:00
|
|
|
public int twiddle; /* Show tildes after EOF */
|
|
|
|
public int show_attn; /* Hilite first unread line */
|
2000-07-14 09:51:40 +00:00
|
|
|
public int shift_count; /* Number of positions to shift horizontally */
|
|
|
|
public int status_col; /* Display a status column */
|
2004-04-17 07:16:34 +00:00
|
|
|
public int use_lessopen; /* Use the LESSOPEN filter */
|
2006-08-20 15:49:51 +00:00
|
|
|
public int quit_on_intr; /* Quit on interrupt */
|
2007-11-16 22:22:17 +00:00
|
|
|
public int follow_mode; /* F cmd Follows file desc or file name? */
|
|
|
|
public int oldbot; /* Old bottom of screen behavior {{REMOVE}} */
|
2013-05-13 05:27:43 +00:00
|
|
|
public int opt_use_backslash; /* Use backslash escaping in option parsing */
|
2000-05-22 09:53:22 +00:00
|
|
|
#if HILITE_SEARCH
|
|
|
|
public int hilite_search; /* Highlight matched search patterns? */
|
|
|
|
#endif
|
|
|
|
|
2006-08-20 15:49:51 +00:00
|
|
|
public int less_is_more = 0; /* Make compatible with POSIX more */
|
|
|
|
|
2000-05-22 09:53:22 +00:00
|
|
|
/*
|
|
|
|
* Long option names.
|
|
|
|
*/
|
|
|
|
static struct optname a_optname = { "search-skip-screen", NULL };
|
|
|
|
static struct optname b_optname = { "buffers", NULL };
|
|
|
|
static struct optname B__optname = { "auto-buffers", NULL };
|
|
|
|
static struct optname c_optname = { "clear-screen", NULL };
|
|
|
|
static struct optname d_optname = { "dumb", NULL };
|
|
|
|
#if MSDOS_COMPILER
|
|
|
|
static struct optname D__optname = { "color", NULL };
|
|
|
|
#endif
|
|
|
|
static struct optname e_optname = { "quit-at-eof", NULL };
|
|
|
|
static struct optname f_optname = { "force", NULL };
|
|
|
|
static struct optname F__optname = { "quit-if-one-screen", NULL };
|
|
|
|
#if HILITE_SEARCH
|
|
|
|
static struct optname g_optname = { "hilite-search", NULL };
|
|
|
|
#endif
|
|
|
|
static struct optname h_optname = { "max-back-scroll", NULL };
|
|
|
|
static struct optname i_optname = { "ignore-case", NULL };
|
|
|
|
static struct optname j_optname = { "jump-target", NULL };
|
2000-07-14 09:51:40 +00:00
|
|
|
static struct optname J__optname = { "status-column", NULL };
|
2000-05-22 09:53:22 +00:00
|
|
|
#if USERFILE
|
|
|
|
static struct optname k_optname = { "lesskey-file", NULL };
|
|
|
|
#endif
|
2006-08-20 15:49:51 +00:00
|
|
|
static struct optname K__optname = { "quit-on-intr", NULL };
|
2004-04-17 07:16:34 +00:00
|
|
|
static struct optname L__optname = { "no-lessopen", NULL };
|
2000-05-22 09:53:22 +00:00
|
|
|
static struct optname m_optname = { "long-prompt", NULL };
|
|
|
|
static struct optname n_optname = { "line-numbers", NULL };
|
|
|
|
#if LOGFILE
|
|
|
|
static struct optname o_optname = { "log-file", NULL };
|
|
|
|
static struct optname O__optname = { "LOG-FILE", NULL };
|
|
|
|
#endif
|
|
|
|
static struct optname p_optname = { "pattern", NULL };
|
|
|
|
static struct optname P__optname = { "prompt", NULL };
|
|
|
|
static struct optname q2_optname = { "silent", NULL };
|
|
|
|
static struct optname q_optname = { "quiet", &q2_optname };
|
|
|
|
static struct optname r_optname = { "raw-control-chars", NULL };
|
|
|
|
static struct optname s_optname = { "squeeze-blank-lines", NULL };
|
|
|
|
static struct optname S__optname = { "chop-long-lines", NULL };
|
|
|
|
#if TAGS
|
|
|
|
static struct optname t_optname = { "tag", NULL };
|
|
|
|
static struct optname T__optname = { "tag-file", NULL };
|
|
|
|
#endif
|
|
|
|
static struct optname u_optname = { "underline-special", NULL };
|
|
|
|
static struct optname V__optname = { "version", NULL };
|
|
|
|
static struct optname w_optname = { "hilite-unread", NULL };
|
|
|
|
static struct optname x_optname = { "tabs", NULL };
|
|
|
|
static struct optname X__optname = { "no-init", NULL };
|
|
|
|
static struct optname y_optname = { "max-forw-scroll", NULL };
|
|
|
|
static struct optname z_optname = { "window", NULL };
|
|
|
|
static struct optname quote_optname = { "quotes", NULL };
|
|
|
|
static struct optname tilde_optname = { "tilde", NULL };
|
|
|
|
static struct optname query_optname = { "help", NULL };
|
2000-07-14 09:51:40 +00:00
|
|
|
static struct optname pound_optname = { "shift", NULL };
|
2002-01-07 20:29:38 +00:00
|
|
|
static struct optname keypad_optname = { "no-keypad", NULL };
|
2007-06-04 01:42:54 +00:00
|
|
|
static struct optname oldbot_optname = { "old-bot", NULL };
|
2007-11-16 22:22:17 +00:00
|
|
|
static struct optname follow_optname = { "follow-name", NULL };
|
2013-05-13 05:27:43 +00:00
|
|
|
static struct optname use_backslash_optname = { "use-backslash", NULL };
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Table of all options and their semantics.
|
2002-01-07 20:29:38 +00:00
|
|
|
*
|
|
|
|
* For BOOL and TRIPLE options, odesc[0], odesc[1], odesc[2] are
|
|
|
|
* the description of the option when set to 0, 1 or 2, respectively.
|
|
|
|
* For NUMBER options, odesc[0] is the prompt to use when entering
|
|
|
|
* a new value, and odesc[1] is the description, which should contain
|
|
|
|
* one %d which is replaced by the value of the number.
|
|
|
|
* For STRING options, odesc[0] is the prompt to use when entering
|
|
|
|
* a new value, and odesc[1], if not NULL, is the set of characters
|
|
|
|
* that are valid in the string.
|
2000-05-22 09:53:22 +00:00
|
|
|
*/
|
2004-04-17 07:16:34 +00:00
|
|
|
static struct loption option[] =
|
2000-05-22 09:53:22 +00:00
|
|
|
{
|
|
|
|
{ 'a', &a_optname,
|
2011-05-09 18:30:23 +00:00
|
|
|
TRIPLE, OPT_ONPLUS, &how_search, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Search includes displayed screen",
|
|
|
|
"Search skips displayed screen",
|
2011-05-09 18:30:23 +00:00
|
|
|
"Search includes all of displayed screen"
|
2004-04-17 07:16:34 +00:00
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ 'b', &b_optname,
|
2004-04-17 07:16:34 +00:00
|
|
|
NUMBER|INIT_HANDLER, 64, &bufspace, opt_b,
|
|
|
|
{
|
|
|
|
"Max buffer space per file (K): ",
|
|
|
|
"Max buffer space per file: %dK",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'B', &B__optname,
|
|
|
|
BOOL, OPT_ON, &autobuf, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't automatically allocate buffers",
|
|
|
|
"Automatically allocate buffers when needed",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'c', &c_optname,
|
|
|
|
TRIPLE, OPT_OFF, &top_scroll, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Repaint by scrolling from bottom of screen",
|
2007-06-04 01:42:54 +00:00
|
|
|
"Repaint by painting from top of screen",
|
2004-04-17 07:16:34 +00:00
|
|
|
"Repaint by painting from top of screen"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'd', &d_optname,
|
|
|
|
BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Assume intelligent terminal",
|
|
|
|
"Assume dumb terminal",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#if MSDOS_COMPILER
|
|
|
|
{ 'D', &D__optname,
|
|
|
|
STRING|REPAINT|NO_QUERY, 0, NULL, opt_D,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"color desc: ",
|
|
|
|
"Ddknsu0123456789.",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{ 'e', &e_optname,
|
|
|
|
TRIPLE, OPT_OFF, &quit_at_eof, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't quit at end-of-file",
|
|
|
|
"Quit at end-of-file",
|
|
|
|
"Quit immediately at end-of-file"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'f', &f_optname,
|
|
|
|
BOOL, OPT_OFF, &force_open, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Open only regular files",
|
|
|
|
"Open even non-regular files",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'F', &F__optname,
|
|
|
|
BOOL, OPT_OFF, &quit_if_one_screen, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't quit if end-of-file on first screen",
|
|
|
|
"Quit if end-of-file on first screen",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#if HILITE_SEARCH
|
|
|
|
{ 'g', &g_optname,
|
|
|
|
TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't highlight search matches",
|
|
|
|
"Highlight matches for previous search only",
|
|
|
|
"Highlight all matches for previous search pattern",
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{ 'h', &h_optname,
|
|
|
|
NUMBER, -1, &back_scroll, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Backwards scroll limit: ",
|
|
|
|
"Backwards scroll limit is %d lines",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'i', &i_optname,
|
|
|
|
TRIPLE|HL_REPAINT, OPT_OFF, &caseless, opt_i,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Case is significant in searches",
|
|
|
|
"Ignore case in searches",
|
|
|
|
"Ignore case in searches and in patterns"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'j', &j_optname,
|
2007-06-04 01:42:54 +00:00
|
|
|
STRING, 0, NULL, opt_j,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Target line: ",
|
2011-05-09 18:30:23 +00:00
|
|
|
"0123456789.-",
|
2004-04-17 07:16:34 +00:00
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
2000-07-14 09:51:40 +00:00
|
|
|
{ 'J', &J__optname,
|
|
|
|
BOOL|REPAINT, OPT_OFF, &status_col, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't display a status column",
|
|
|
|
"Display a status column",
|
|
|
|
NULL
|
|
|
|
}
|
2000-07-14 09:51:40 +00:00
|
|
|
},
|
2000-05-22 09:53:22 +00:00
|
|
|
#if USERFILE
|
|
|
|
{ 'k', &k_optname,
|
|
|
|
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ NULL, NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#endif
|
2006-08-20 15:49:51 +00:00
|
|
|
{ 'K', &K__optname,
|
|
|
|
BOOL, OPT_OFF, &quit_on_intr, NULL,
|
|
|
|
{
|
|
|
|
"Interrupt (ctrl-C) returns to prompt",
|
|
|
|
"Interrupt (ctrl-C) exits less",
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
},
|
2004-04-17 07:16:34 +00:00
|
|
|
{ 'L', &L__optname,
|
|
|
|
BOOL, OPT_ON, &use_lessopen, NULL,
|
|
|
|
{
|
|
|
|
"Don't use the LESSOPEN filter",
|
|
|
|
"Use the LESSOPEN filter",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'm', &m_optname,
|
|
|
|
TRIPLE, OPT_OFF, &pr_type, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Short prompt",
|
|
|
|
"Medium prompt",
|
|
|
|
"Long prompt"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'n', &n_optname,
|
|
|
|
TRIPLE|REPAINT, OPT_ON, &linenums, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't use line numbers",
|
|
|
|
"Use line numbers",
|
|
|
|
"Constantly display line numbers"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#if LOGFILE
|
|
|
|
{ 'o', &o_optname,
|
|
|
|
STRING, 0, NULL, opt_o,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ "log file: ", NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'O', &O__optname,
|
|
|
|
STRING, 0, NULL, opt__O,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ "Log file: ", NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{ 'p', &p_optname,
|
|
|
|
STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ NULL, NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'P', &P__optname,
|
|
|
|
STRING, 0, NULL, opt__P,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ "prompt: ", NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'q', &q_optname,
|
|
|
|
TRIPLE, OPT_OFF, &quiet, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Ring the bell for errors AND at eof/bof",
|
|
|
|
"Ring the bell for errors but not at eof/bof",
|
|
|
|
"Never ring the bell"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'r', &r_optname,
|
|
|
|
TRIPLE|REPAINT, OPT_OFF, &ctldisp, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Display control characters as ^X",
|
|
|
|
"Display control characters directly",
|
|
|
|
"Display control characters directly, processing ANSI sequences"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 's', &s_optname,
|
|
|
|
BOOL|REPAINT, OPT_OFF, &squeeze, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Display all blank lines",
|
|
|
|
"Squeeze multiple blank lines",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'S', &S__optname,
|
|
|
|
BOOL|REPAINT, OPT_OFF, &chopline, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Fold long lines",
|
|
|
|
"Chop long lines",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#if TAGS
|
|
|
|
{ 't', &t_optname,
|
|
|
|
STRING|NO_QUERY, 0, NULL, opt_t,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ "tag: ", NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'T', &T__optname,
|
|
|
|
STRING, 0, NULL, opt__T,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ "tags file: ", NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{ 'u', &u_optname,
|
|
|
|
TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Display underlined text in underline mode",
|
|
|
|
"Backspaces cause overstrike",
|
|
|
|
"Print backspace as ^H"
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'V', &V__optname,
|
|
|
|
NOVAR, 0, NULL, opt__V,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ NULL, NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'w', &w_optname,
|
|
|
|
TRIPLE|REPAINT, OPT_OFF, &show_attn, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't highlight first unread line",
|
|
|
|
"Highlight first unread line after forward-screen",
|
|
|
|
"Highlight first unread line after any forward movement",
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'x', &x_optname,
|
2002-01-07 20:29:38 +00:00
|
|
|
STRING|REPAINT, 0, NULL, opt_x,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Tab stops: ",
|
|
|
|
"0123456789,",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'X', &X__optname,
|
|
|
|
BOOL|NO_TOGGLE, OPT_OFF, &no_init, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Send init/deinit strings to terminal",
|
|
|
|
"Don't use init/deinit strings",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'y', &y_optname,
|
|
|
|
NUMBER, -1, &forw_scroll, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Forward scroll limit: ",
|
|
|
|
"Forward scroll limit is %d lines",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ 'z', &z_optname,
|
|
|
|
NUMBER, -1, &swindow, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Scroll window size: ",
|
|
|
|
"Scroll window size is %d lines",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ '"', "e_optname,
|
|
|
|
STRING, 0, NULL, opt_quote,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ "quotes: ", NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ '~', &tilde_optname,
|
|
|
|
BOOL|REPAINT, OPT_ON, &twiddle, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Don't show tildes after end of file",
|
|
|
|
"Show tildes after end of file",
|
|
|
|
NULL
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
|
|
|
{ '?', &query_optname,
|
|
|
|
NOVAR, 0, NULL, opt_query,
|
2004-04-17 07:16:34 +00:00
|
|
|
{ NULL, NULL, NULL }
|
2000-05-22 09:53:22 +00:00
|
|
|
},
|
2000-07-14 09:51:40 +00:00
|
|
|
{ '#', £_optname,
|
2009-07-27 07:05:08 +00:00
|
|
|
STRING, 0, NULL, opt_shift,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Horizontal shift: ",
|
2009-07-27 07:05:08 +00:00
|
|
|
"0123456789.",
|
2004-04-17 07:16:34 +00:00
|
|
|
NULL
|
|
|
|
}
|
2000-07-14 09:51:40 +00:00
|
|
|
},
|
2011-05-09 18:30:23 +00:00
|
|
|
{ OLETTER_NONE, &keypad_optname,
|
2002-01-07 20:29:38 +00:00
|
|
|
BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL,
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
|
|
|
"Use keypad mode",
|
|
|
|
"Don't use keypad mode",
|
|
|
|
NULL
|
|
|
|
}
|
2002-01-07 20:29:38 +00:00
|
|
|
},
|
2011-05-09 18:30:23 +00:00
|
|
|
{ OLETTER_NONE, &oldbot_optname,
|
2007-06-04 01:42:54 +00:00
|
|
|
BOOL, OPT_OFF, &oldbot, NULL,
|
|
|
|
{
|
|
|
|
"Use new bottom of screen behavior",
|
|
|
|
"Use old bottom of screen behavior",
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
},
|
2011-05-09 18:30:23 +00:00
|
|
|
{ OLETTER_NONE, &follow_optname,
|
2007-11-16 22:22:17 +00:00
|
|
|
BOOL, FOLLOW_DESC, &follow_mode, NULL,
|
|
|
|
{
|
2011-05-09 18:30:23 +00:00
|
|
|
"F command follows file descriptor",
|
|
|
|
"F command follows file name",
|
2007-11-16 22:22:17 +00:00
|
|
|
NULL
|
|
|
|
}
|
|
|
|
},
|
2013-05-13 05:27:43 +00:00
|
|
|
{ OLETTER_NONE, &use_backslash_optname,
|
|
|
|
BOOL, OPT_OFF, &opt_use_backslash, NULL,
|
|
|
|
{
|
|
|
|
"Use backslash escaping in command line parameters",
|
|
|
|
"Don't use backslash escaping in command line parameters",
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
},
|
2004-04-17 07:16:34 +00:00
|
|
|
{ '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } }
|
2000-05-22 09:53:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize each option to its default value.
|
|
|
|
*/
|
|
|
|
public void
|
2017-03-31 21:29:43 +00:00
|
|
|
init_option(void)
|
2000-05-22 09:53:22 +00:00
|
|
|
{
|
2017-03-31 21:29:43 +00:00
|
|
|
struct loption *o;
|
2006-08-20 15:49:51 +00:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = lgetenv("LESS_IS_MORE");
|
|
|
|
if (p != NULL && *p != '\0')
|
|
|
|
less_is_more = 1;
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
for (o = option; o->oletter != '\0'; o++)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Set each variable to its default.
|
|
|
|
*/
|
|
|
|
if (o->ovar != NULL)
|
|
|
|
*(o->ovar) = o->odefault;
|
2004-04-17 07:16:34 +00:00
|
|
|
if (o->otype & INIT_HANDLER)
|
|
|
|
(*(o->ofunc))(INIT, (char *) NULL);
|
2000-05-22 09:53:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find an option in the option table, given its option letter.
|
|
|
|
*/
|
2004-04-17 07:16:34 +00:00
|
|
|
public struct loption *
|
2017-03-31 21:29:43 +00:00
|
|
|
findopt(int c)
|
2000-05-22 09:53:22 +00:00
|
|
|
{
|
2017-03-31 21:29:43 +00:00
|
|
|
struct loption *o;
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
for (o = option; o->oletter != '\0'; o++)
|
|
|
|
{
|
|
|
|
if (o->oletter == c)
|
|
|
|
return (o);
|
2006-08-20 15:49:51 +00:00
|
|
|
if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c)
|
2000-05-22 09:53:22 +00:00
|
|
|
return (o);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2004-04-17 07:16:34 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
2017-03-31 21:29:43 +00:00
|
|
|
is_optchar(char c)
|
2004-04-17 07:16:34 +00:00
|
|
|
{
|
2006-08-20 15:49:51 +00:00
|
|
|
if (ASCII_IS_UPPER(c))
|
2004-04-17 07:16:34 +00:00
|
|
|
return 1;
|
2006-08-20 15:49:51 +00:00
|
|
|
if (ASCII_IS_LOWER(c))
|
2004-04-17 07:16:34 +00:00
|
|
|
return 1;
|
|
|
|
if (c == '-')
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-22 09:53:22 +00:00
|
|
|
/*
|
|
|
|
* Find an option in the option table, given its option name.
|
|
|
|
* p_optname is the (possibly partial) name to look for, and
|
|
|
|
* is updated to point after the matched name.
|
|
|
|
* p_oname if non-NULL is set to point to the full option name.
|
|
|
|
*/
|
2004-04-17 07:16:34 +00:00
|
|
|
public struct loption *
|
2017-03-31 21:29:43 +00:00
|
|
|
findopt_name(char **p_optname, char **p_oname, int *p_err)
|
2000-05-22 09:53:22 +00:00
|
|
|
{
|
|
|
|
char *optname = *p_optname;
|
2017-03-31 21:29:43 +00:00
|
|
|
struct loption *o;
|
|
|
|
struct optname *oname;
|
|
|
|
int len;
|
2000-05-22 09:53:22 +00:00
|
|
|
int uppercase;
|
2004-04-17 07:16:34 +00:00
|
|
|
struct loption *maxo = NULL;
|
2000-05-22 09:53:22 +00:00
|
|
|
struct optname *maxoname = NULL;
|
|
|
|
int maxlen = 0;
|
|
|
|
int ambig = 0;
|
|
|
|
int exact = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check all options.
|
|
|
|
*/
|
|
|
|
for (o = option; o->oletter != '\0'; o++)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Check all names for this option.
|
|
|
|
*/
|
|
|
|
for (oname = o->onames; oname != NULL; oname = oname->onext)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Try normal match first (uppercase == 0),
|
|
|
|
* then, then if it's a TRIPLE option,
|
|
|
|
* try uppercase match (uppercase == 1).
|
|
|
|
*/
|
|
|
|
for (uppercase = 0; uppercase <= 1; uppercase++)
|
|
|
|
{
|
|
|
|
len = sprefix(optname, oname->oname, uppercase);
|
2004-04-17 07:16:34 +00:00
|
|
|
if (len <= 0 || is_optchar(optname[len]))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We didn't use all of the option name.
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
2000-05-22 09:53:22 +00:00
|
|
|
if (!exact && len == maxlen)
|
|
|
|
/*
|
|
|
|
* Already had a partial match,
|
|
|
|
* and now there's another one that
|
|
|
|
* matches the same length.
|
|
|
|
*/
|
|
|
|
ambig = 1;
|
|
|
|
else if (len > maxlen)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Found a better match than
|
|
|
|
* the one we had.
|
|
|
|
*/
|
|
|
|
maxo = o;
|
|
|
|
maxoname = oname;
|
|
|
|
maxlen = len;
|
|
|
|
ambig = 0;
|
2002-01-07 20:29:38 +00:00
|
|
|
exact = (len == (int)strlen(oname->oname));
|
2000-05-22 09:53:22 +00:00
|
|
|
}
|
|
|
|
if (!(o->otype & TRIPLE))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ambig)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Name matched more than one option.
|
|
|
|
*/
|
|
|
|
if (p_err != NULL)
|
|
|
|
*p_err = OPT_AMBIG;
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
*p_optname = optname + maxlen;
|
|
|
|
if (p_oname != NULL)
|
2004-04-17 07:16:34 +00:00
|
|
|
*p_oname = maxoname == NULL ? NULL : maxoname->oname;
|
2000-05-22 09:53:22 +00:00
|
|
|
return (maxo);
|
|
|
|
}
|