Changeset View
Changeset View
Standalone View
Standalone View
contrib/less/optfunc.c
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
#if LOGFILE | #if LOGFILE | ||||
/* | /* | ||||
* Handler for -o option. | * Handler for -o option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt_o(type, s) | opt_o(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
PARG parg; | PARG parg; | ||||
if (secure) | if (secure) | ||||
{ | { | ||||
error("log file support is not available", NULL_PARG); | error("log file support is not available", NULL_PARG); | ||||
return; | return; | ||||
} | } | ||||
Show All 31 Lines | case QUERY: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Handler for -O option. | * Handler for -O option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt__O(type, s) | opt__O(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
force_logfile = TRUE; | force_logfile = TRUE; | ||||
opt_o(type, s); | opt_o(type, s); | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* Handlers for -j option. | * Handlers for -j option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt_j(type, s) | opt_j(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
PARG parg; | PARG parg; | ||||
char buf[16]; | char buf[16]; | ||||
int len; | int len; | ||||
int err; | int err; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
Show All 35 Lines | if (jump_sline_fraction < 0) | ||||
parg.p_string = buf; | parg.p_string = buf; | ||||
error("Position target at screen position %s", &parg); | error("Position target at screen position %s", &parg); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
public void | public void | ||||
calc_jump_sline() | calc_jump_sline(void) | ||||
{ | { | ||||
if (jump_sline_fraction < 0) | if (jump_sline_fraction < 0) | ||||
return; | return; | ||||
jump_sline = sc_height * jump_sline_fraction / NUM_FRAC_DENOM; | jump_sline = sc_height * jump_sline_fraction / NUM_FRAC_DENOM; | ||||
} | } | ||||
/* | /* | ||||
* Handlers for -# option. | * Handlers for -# option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt_shift(type, s) | opt_shift(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
PARG parg; | PARG parg; | ||||
char buf[16]; | char buf[16]; | ||||
int len; | int len; | ||||
int err; | int err; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
Show All 34 Lines | if (shift_count_fraction < 0) | ||||
buf[len] = '\0'; | buf[len] = '\0'; | ||||
parg.p_string = buf; | parg.p_string = buf; | ||||
error("Horizontal shift %s of screen width", &parg); | error("Horizontal shift %s of screen width", &parg); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
public void | public void | ||||
calc_shift_count() | calc_shift_count(void) | ||||
{ | { | ||||
if (shift_count_fraction < 0) | if (shift_count_fraction < 0) | ||||
return; | return; | ||||
shift_count = sc_width * shift_count_fraction / NUM_FRAC_DENOM; | shift_count = sc_width * shift_count_fraction / NUM_FRAC_DENOM; | ||||
} | } | ||||
#if USERFILE | #if USERFILE | ||||
public void | public void | ||||
opt_k(type, s) | opt_k(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
PARG parg; | PARG parg; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
if (lesskey(s, 0)) | if (lesskey(s, 0)) | ||||
{ | { | ||||
parg.p_string = s; | parg.p_string = s; | ||||
error("Cannot use lesskey file \"%s\"", &parg); | error("Cannot use lesskey file \"%s\"", &parg); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
#if TAGS | #if TAGS | ||||
/* | /* | ||||
* Handler for -t option. | * Handler for -t option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt_t(type, s) | opt_t(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
IFILE save_ifile; | IFILE save_ifile; | ||||
POSITION pos; | POSITION pos; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
tagoption = save(s); | tagoption = save(s); | ||||
Show All 22 Lines | case TOGGLE: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Handler for -T option. | * Handler for -T option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt__T(type, s) | opt__T(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
PARG parg; | PARG parg; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
tags = save(s); | tags = save(s); | ||||
break; | break; | ||||
Show All 10 Lines | opt__T(int type, char *s) | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* Handler for -p option. | * Handler for -p option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt_p(type, s) | opt_p(int type, char *s) | ||||
int type; | |||||
register char *s; | |||||
{ | { | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
/* | /* | ||||
* Unget a command for the specified string. | * Unget a command for the specified string. | ||||
*/ | */ | ||||
if (less_is_more) | if (less_is_more) | ||||
Show All 17 Lines | case INIT: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Handler for -P option. | * Handler for -P option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt__P(type, s) | opt__P(int type, char *s) | ||||
int type; | |||||
register char *s; | |||||
{ | { | ||||
register char **proto; | char **proto; | ||||
PARG parg; | PARG parg; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
case TOGGLE: | case TOGGLE: | ||||
/* | /* | ||||
* Figure out which prototype string should be changed. | * Figure out which prototype string should be changed. | ||||
Show All 18 Lines | opt__P(int type, char *s) | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Handler for the -b option. | * Handler for the -b option. | ||||
*/ | */ | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
public void | public void | ||||
opt_b(type, s) | opt_b(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
case TOGGLE: | case TOGGLE: | ||||
/* | /* | ||||
* Set the new number of buffers. | * Set the new number of buffers. | ||||
*/ | */ | ||||
ch_setbufspace(bufspace); | ch_setbufspace(bufspace); | ||||
break; | break; | ||||
case QUERY: | case QUERY: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Handler for the -i option. | * Handler for the -i option. | ||||
*/ | */ | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
public void | public void | ||||
opt_i(type, s) | opt_i(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case TOGGLE: | case TOGGLE: | ||||
chg_caseless(); | chg_caseless(); | ||||
break; | break; | ||||
case QUERY: | case QUERY: | ||||
case INIT: | case INIT: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Handler for the -V option. | * Handler for the -V option. | ||||
*/ | */ | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
public void | public void | ||||
opt__V(type, s) | opt__V(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case TOGGLE: | case TOGGLE: | ||||
case QUERY: | case QUERY: | ||||
dispversion(); | dispversion(); | ||||
break; | break; | ||||
case INIT: | case INIT: | ||||
Show All 36 Lines | #endif | ||||
} | } | ||||
} | } | ||||
#if MSDOS_COMPILER | #if MSDOS_COMPILER | ||||
/* | /* | ||||
* Parse an MSDOS color descriptor. | * Parse an MSDOS color descriptor. | ||||
*/ | */ | ||||
static void | static void | ||||
colordesc(s, fg_color, bg_color) | colordesc(char *s, int *fg_color, int *bg_color) | ||||
char *s; | |||||
int *fg_color; | |||||
int *bg_color; | |||||
{ | { | ||||
int fg, bg; | int fg, bg; | ||||
int err; | int err; | ||||
fg = getnum(&s, "D", &err); | fg = getnum(&s, "D", &err); | ||||
if (err) | if (err) | ||||
{ | { | ||||
error("Missing fg color in -D", NULL_PARG); | error("Missing fg color in -D", NULL_PARG); | ||||
Show All 17 Lines | colordesc(char *s, int *fg_color, int *bg_color) | ||||
*bg_color = bg; | *bg_color = bg; | ||||
} | } | ||||
/* | /* | ||||
* Handler for the -D option. | * Handler for the -D option. | ||||
*/ | */ | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
public void | public void | ||||
opt_D(type, s) | opt_D(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
case TOGGLE: | case TOGGLE: | ||||
switch (*s++) | switch (*s++) | ||||
{ | { | ||||
case 'n': | case 'n': | ||||
Show All 26 Lines | opt_D(int type, char *s) | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* Handler for the -x option. | * Handler for the -x option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt_x(type, s) | opt_x(int type, char *s) | ||||
int type; | |||||
register char *s; | |||||
{ | { | ||||
extern int tabstops[]; | extern int tabstops[]; | ||||
extern int ntabstops; | extern int ntabstops; | ||||
extern int tabdefault; | extern int tabdefault; | ||||
char msg[60+(4*TABSTOP_MAX)]; | char msg[60+(4*TABSTOP_MAX)]; | ||||
int i; | int i; | ||||
PARG p; | PARG p; | ||||
Show All 39 Lines | opt_x(int type, char *s) | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Handler for the -" option. | * Handler for the -" option. | ||||
*/ | */ | ||||
public void | public void | ||||
opt_quote(type, s) | opt_quote(int type, char *s) | ||||
int type; | |||||
register char *s; | |||||
{ | { | ||||
char buf[3]; | char buf[3]; | ||||
PARG parg; | PARG parg; | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case INIT: | case INIT: | ||||
case TOGGLE: | case TOGGLE: | ||||
Show All 24 Lines | |||||
} | } | ||||
/* | /* | ||||
* "-?" means display a help message. | * "-?" means display a help message. | ||||
* If from the command line, exit immediately. | * If from the command line, exit immediately. | ||||
*/ | */ | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
public void | public void | ||||
opt_query(type, s) | opt_query(int type, char *s) | ||||
int type; | |||||
char *s; | |||||
{ | { | ||||
switch (type) | switch (type) | ||||
{ | { | ||||
case QUERY: | case QUERY: | ||||
case TOGGLE: | case TOGGLE: | ||||
error("Use \"h\" for help", NULL_PARG); | error("Use \"h\" for help", NULL_PARG); | ||||
break; | break; | ||||
case INIT: | case INIT: | ||||
dohelp = 1; | dohelp = 1; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Get the "screen window" size. | * Get the "screen window" size. | ||||
*/ | */ | ||||
public int | public int | ||||
get_swindow() | get_swindow(void) | ||||
{ | { | ||||
if (swindow > 0) | if (swindow > 0) | ||||
return (swindow); | return (swindow); | ||||
return (sc_height + swindow); | return (sc_height + swindow); | ||||
} | } | ||||