version 1.1.1.3, 2011/09/16 17:47:07 |
version 1.1.1.4, 2014/04/25 13:33:51 |
|
|
/* |
/* |
* Copyright (C) 1984-2011 Mark Nudelman |
* Copyright (C) 1984-2012 Mark Nudelman |
* |
* |
* You may distribute under the terms of either the GNU General Public |
* You may distribute under the terms of either the GNU General Public |
* License or the Less License, as specified in the README file. |
* License or the Less License, as specified in the README file. |
* |
* |
* For more information about less, or for information on how to |
* For more information, see the README file. |
* contact the author, see the README file. |
|
*/ |
*/ |
|
|
|
|
|
|
extern int swindow; |
extern int swindow; |
extern int no_init; |
extern int no_init; |
extern int no_keypad; |
extern int no_keypad; |
extern int sigs; |
extern volatile sig_atomic_t sigs; |
extern int wscroll; |
extern int wscroll; |
extern int screen_trashed; |
extern int screen_trashed; |
extern int tty; |
extern int tty; |
|
|
*/ |
*/ |
s = save_term; |
s = save_term; |
} |
} |
|
tcsetattr(tty, TCSASOFT | TCSADRAIN, &s); |
#if HAVE_FSYNC |
#if HAVE_FSYNC |
fsync(tty); |
fsync(tty); |
#endif |
#endif |
tcsetattr(tty, TCSADRAIN, &s); |
|
#if MUST_SET_LINE_DISCIPLINE |
#if MUST_SET_LINE_DISCIPLINE |
if (!on) |
if (!on) |
{ |
{ |
|
|
struct env { struct env *next; char *name; char *value; }; |
struct env { struct env *next; char *name; char *value; }; |
static struct env *envs = NULL; |
static struct env *envs = NULL; |
struct env *p; |
struct env *p; |
|
size_t len; |
for (p = envs; p != NULL; p = p->next) |
for (p = envs; p != NULL; p = p->next) |
if (strcmp(p->name, capname) == 0) |
if (strcmp(p->name, capname) == 0) |
return p->value; |
return p->value; |
p = (struct env *) ecalloc(1, sizeof(struct env)); |
p = (struct env *) ecalloc(1, sizeof(struct env)); |
p->name = save(capname); |
p->name = save(capname); |
p->value = (char *) ecalloc(strlen(capname)+3, sizeof(char)); |
len = strlen(capname) + 3; |
sprintf(p->value, "<%s>", capname); |
p->value = (char *) ecalloc(len, sizeof(char)); |
|
snprintf(p->value, len, "<%s>", capname); |
p->next = envs; |
p->next = envs; |
envs = p; |
envs = p; |
return p->value; |
return p->value; |
} |
} |
strcpy(name, "LESS_TERMCAP_"); |
strlcpy(name, "LESS_TERMCAP_", sizeof(name)); |
strcat(name, capname); |
strlcat(name, capname, sizeof(name)); |
return (lgetenv(name)); |
return (lgetenv(name)); |
} |
} |
|
|
|
|
else if ((n = ltgetnum("li")) > 0) |
else if ((n = ltgetnum("li")) > 0) |
sc_height = n; |
sc_height = n; |
#endif |
#endif |
else |
if (sc_height <= 0) |
sc_height = DEF_SC_HEIGHT; |
sc_height = DEF_SC_HEIGHT; |
|
|
if (sys_width > 0) |
if (sys_width > 0) |
|
|
else if ((n = ltgetnum("co")) > 0) |
else if ((n = ltgetnum("co")) > 0) |
sc_width = n; |
sc_width = n; |
#endif |
#endif |
else |
if (sc_width <= 0) |
sc_width = DEF_SC_WIDTH; |
sc_width = DEF_SC_WIDTH; |
} |
} |
|
|
|
|
char *termcap; |
char *termcap; |
if ((sp = homefile("termcap.dat")) != NULL) |
if ((sp = homefile("termcap.dat")) != NULL) |
{ |
{ |
termcap = (char *) ecalloc(strlen(sp)+9, sizeof(char)); |
size_t len = strlen(sp) + 9; |
sprintf(termcap, "TERMCAP=%s", sp); |
termcap = (char *) ecalloc(len, sizeof(char)); |
|
snprintf(termcap, len, "TERMCAP=%s", sp); |
free(sp); |
free(sp); |
putenv(termcap); |
putenv(termcap); |
} |
} |
|
|
t2 = ""; |
t2 = ""; |
else |
else |
{ |
{ |
strcpy(sp, tgoto(sc_move, 0, 0)); |
strlcpy(sp, tgoto(sc_move, 0, 0), sbuf + sizeof(sbuf) - sp); |
t2 = sp; |
t2 = sp; |
sp += strlen(sp) + 1; |
sp += strlen(sp) + 1; |
} |
} |
|
|
t2 = ""; |
t2 = ""; |
else |
else |
{ |
{ |
strcpy(sp, tgoto(sc_move, 0, sc_height-1)); |
strlcpy(sp, tgoto(sc_move, 0, sc_height-1), |
|
sbuf + sizeof(sbuf) - sp); |
t2 = sp; |
t2 = sp; |
sp += strlen(sp) + 1; |
sp += strlen(sp) + 1; |
} |
} |
|
|
#if MSDOS_COMPILER==WIN32C |
#if MSDOS_COMPILER==WIN32C |
MessageBeep(0); |
MessageBeep(0); |
#else |
#else |
write(1, "\7", 1); |
write(STDOUT_FILENO, "\7", 1); |
#endif |
#endif |
#endif |
#endif |
} |
} |