1994-10-07 08:58:58 +00:00
|
|
|
|
|
|
|
/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
|
|
|
|
* details. If they are missing then this copy is in violation of *
|
|
|
|
* the copyright conditions. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
** lib_options.c
|
|
|
|
**
|
|
|
|
** The routines to handle option setting.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
1994-12-02 06:40:24 +00:00
|
|
|
#include "terminfo.h"
|
1994-10-07 08:58:58 +00:00
|
|
|
#include "curses.priv.h"
|
|
|
|
|
|
|
|
int idlok(WINDOW *win, int flag)
|
|
|
|
{
|
|
|
|
T(("idlok(%x,%d) called", win, flag));
|
|
|
|
|
1994-12-02 06:40:24 +00:00
|
|
|
if (flag == FALSE) {
|
|
|
|
win->_idlok = FALSE;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((insert_line || parm_insert_line) && (delete_line || parm_delete_line)) {
|
|
|
|
win->_idlok = TRUE;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
return OK;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int clearok(WINDOW *win, int flag)
|
|
|
|
{
|
|
|
|
T(("clearok(%x,%d) called", win, flag));
|
|
|
|
|
|
|
|
if (win == curscr)
|
|
|
|
newscr->_clear = flag;
|
|
|
|
else
|
|
|
|
win->_clear = flag;
|
1995-05-30 05:51:47 +00:00
|
|
|
return OK;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int leaveok(WINDOW *win, int flag)
|
|
|
|
{
|
|
|
|
T(("leaveok(%x,%d) called", win, flag));
|
|
|
|
|
|
|
|
win->_leave = flag;
|
1994-12-02 06:40:24 +00:00
|
|
|
if (flag == TRUE)
|
|
|
|
curs_set(0);
|
|
|
|
else
|
|
|
|
curs_set(1);
|
1995-05-30 05:51:47 +00:00
|
|
|
return OK;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int scrollok(WINDOW *win, int flag)
|
|
|
|
{
|
|
|
|
T(("scrollok(%x,%d) called", win, flag));
|
|
|
|
|
|
|
|
win->_scroll = flag;
|
1995-05-30 05:51:47 +00:00
|
|
|
return OK;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int halfdelay(int t)
|
|
|
|
{
|
|
|
|
T(("halfdelay(%d) called", t));
|
|
|
|
|
|
|
|
if (t < 1 || t > 255)
|
|
|
|
return ERR;
|
|
|
|
|
|
|
|
cbreak();
|
|
|
|
SP->_cbreak = t+1;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nodelay(WINDOW *win, int flag)
|
|
|
|
{
|
|
|
|
T(("nodelay(%x,%d) called", win, flag));
|
|
|
|
|
|
|
|
if (flag == TRUE)
|
|
|
|
win->_delay = 0;
|
|
|
|
else win->_delay = -1;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int notimeout(WINDOW *win, bool f)
|
|
|
|
{
|
|
|
|
T(("notimout(%x,%d) called", win, f));
|
|
|
|
|
|
|
|
win->_notimeout = f;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wtimeout(WINDOW *win, int delay)
|
|
|
|
{
|
|
|
|
T(("wtimeout(%x,%d) called", win, delay));
|
|
|
|
|
|
|
|
win->_delay = delay;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_keytry();
|
|
|
|
static void add_to_try(char *, short);
|
|
|
|
|
|
|
|
int keypad(WINDOW *win, int flag)
|
|
|
|
{
|
|
|
|
T(("keypad(%x,%d) called", win, flag));
|
|
|
|
|
|
|
|
win->_use_keypad = flag;
|
|
|
|
|
|
|
|
if (flag && keypad_xmit)
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(keypad_xmit);
|
1994-10-07 08:58:58 +00:00
|
|
|
else if (! flag && keypad_local)
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(keypad_local);
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (SP->_keytry == UNINITIALISED)
|
|
|
|
init_keytry();
|
1995-05-30 05:51:47 +00:00
|
|
|
return OK;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int meta(WINDOW *win, int flag)
|
|
|
|
{
|
|
|
|
T(("meta(%x,%d) called", win, flag));
|
|
|
|
|
|
|
|
win->_use_meta = flag;
|
|
|
|
|
|
|
|
if (flag && meta_on)
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(meta_on);
|
1994-10-07 08:58:58 +00:00
|
|
|
else if (! flag && meta_off)
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(meta_off);
|
1995-05-30 05:51:47 +00:00
|
|
|
return OK;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** init_keytry()
|
|
|
|
**
|
|
|
|
** Construct the try for the current terminal's keypad keys.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static struct try *newtry;
|
|
|
|
|
|
|
|
static void init_keytry()
|
|
|
|
{
|
|
|
|
newtry = NULL;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
#include "keys.tries"
|
|
|
|
|
|
|
|
SP->_keytry = newtry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void add_to_try(char *str, short code)
|
|
|
|
{
|
|
|
|
static bool out_of_memory = FALSE;
|
|
|
|
struct try *ptr, *savedptr;
|
|
|
|
|
|
|
|
if (! str || out_of_memory)
|
|
|
|
return;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (newtry != NULL) {
|
|
|
|
ptr = savedptr = newtry;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
for (;;) {
|
|
|
|
while (ptr->ch != (unsigned char) *str
|
|
|
|
&& ptr->sibling != NULL)
|
|
|
|
ptr = ptr->sibling;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (ptr->ch == (unsigned char) *str) {
|
|
|
|
if (*(++str)) {
|
|
|
|
if (ptr->child != NULL)
|
|
|
|
ptr = ptr->child;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
ptr->value = code;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((ptr->sibling = (struct try *) malloc(sizeof *ptr)) == NULL) {
|
|
|
|
out_of_memory = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
savedptr = ptr = ptr->sibling;
|
|
|
|
ptr->child = ptr->sibling = NULL;
|
|
|
|
ptr->ch = *str++;
|
|
|
|
ptr->value = (short) NULL;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
} /* end for (;;) */
|
1994-10-07 08:58:58 +00:00
|
|
|
} else { /* newtry == NULL :: First sequence to be added */
|
|
|
|
savedptr = ptr = newtry = (struct try *) malloc(sizeof *ptr);
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (ptr == NULL) {
|
|
|
|
out_of_memory = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
ptr->child = ptr->sibling = NULL;
|
|
|
|
ptr->ch = *(str++);
|
|
|
|
ptr->value = (short) NULL;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
/* at this point, we are adding to the try. ptr->child == NULL */
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
while (*str) {
|
|
|
|
ptr->child = (struct try *) malloc(sizeof *ptr);
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
ptr = ptr->child;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (ptr == NULL) {
|
|
|
|
out_of_memory = TRUE;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
ptr = savedptr;
|
|
|
|
while (ptr != NULL) {
|
|
|
|
savedptr = ptr->child;
|
|
|
|
free(ptr);
|
|
|
|
ptr = savedptr;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
return;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
ptr->child = ptr->sibling = NULL;
|
|
|
|
ptr->ch = *(str++);
|
|
|
|
ptr->value = (short) NULL;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
ptr->value = code;
|
|
|
|
return;
|
|
|
|
}
|
1994-12-02 06:40:24 +00:00
|
|
|
|
|
|
|
int typeahead(int fd)
|
|
|
|
{
|
|
|
|
|
|
|
|
T(("typeahead(%d) called", fd));
|
|
|
|
SP->_checkfd = fd;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int intrflush(WINDOW *win, bool flag)
|
|
|
|
{
|
|
|
|
T(("intrflush(%x, %d) called", win, flag));
|
|
|
|
return OK;
|
|
|
|
}
|