Sat Jun 8 11:41:37 2002 Michael Jennings (mej)

Escreen update with Twin support from Azundris <scream@azundris.com>.


SVN revision: 6307
This commit is contained in:
Michael Jennings 2002-06-08 15:44:08 +00:00
parent ed14ba8dde
commit 92937f46a7
26 changed files with 1417 additions and 566 deletions

View File

@ -4687,3 +4687,7 @@ Sun Jun 2 20:25:55 2002 Michael Jennings (mej)
Oops, missed these.
----------------------------------------------------------------------
Sat Jun 8 11:41:37 2002 Michael Jennings (mej)
Escreen update with Twin support from Azundris <scream@azundris.com>.
----------------------------------------------------------------------

View File

@ -11,121 +11,122 @@
# CONTROL VARIETY ############################################################
# ctrl-left -> previous display, ctrl-right -> next display
bind ctrl Left to echo ^Ap
bind ctrl Right to echo ^An
bind ctrl Left to script es_display(prvs)
bind ctrl Right to script es_display(next)
# ctl-pg_up -> previous display, ctl-pg_dn -> next display (Galeon-like)
bind ctrl Prior to echo ^Ap
bind ctrl Next to echo ^An
# ctl-pg_up -> previous display, ctl-pg_dn -> next display((Galeon-like)
bind ctrl Prior to script es_display(prvs)
bind ctrl Next to script es_display(next)
# no ctrl-up/down; we shouldn't steal that from the app.
# ctl-space -> toggle between last two displays
bind ctrl space to echo ^A^A
bind ctrl space to script es_display(toggle)
# ctrl-1..ctrl-0 -> display_0..display_9
bind ctrl 0x31 to echo ^A0
bind ctrl 0x32 to echo ^A1
bind ctrl 0x33 to echo ^A2
bind ctrl 0x34 to echo ^A3
bind ctrl 0x35 to echo ^A4
bind ctrl 0x36 to echo ^A5
bind ctrl 0x37 to echo ^A6
bind ctrl 0x38 to echo ^A7
bind ctrl 0x39 to echo ^A8
bind ctrl 0x30 to echo ^A9
# ctrl-1..ctrl-0 -> display0..display9
bind ctrl 0x31 to script es_display(goto,0)
bind ctrl 0x32 to script es_display(goto,1)
bind ctrl 0x33 to script es_display(goto,2)
bind ctrl 0x34 to script es_display(goto,3)
bind ctrl 0x35 to script es_display(goto,4)
bind ctrl 0x36 to script es_display(goto,5)
bind ctrl 0x37 to script es_display(goto,6)
bind ctrl 0x38 to script es_display(goto,7)
bind ctrl 0x39 to script es_display(goto,8)
bind ctrl 0x30 to script es_display(goto,9)
# ALT VARIETY ################################################################
# alt-left -> previous display, alt-right -> next display
bind alt Left to echo ^Ap
bind alt Right to echo ^An
bind alt Left to script es_display(prvs)
bind alt Right to script es_display(next)
# alt-up -> previous region, alt-down -> next region
bind alt Down to echo ^A\t
# alt-up -> previous region, alt-down -> next region (^A\t)
bind alt Up to script es_region(prvs)
bind alt Down to script es_region(next)
# alt-pg_up -> previous display, alt-pg_dn -> next display
bind alt Prior to echo ^Ap
bind alt Next to echo ^An
bind alt Prior to script es_display(prvs)
bind alt Next to script es_ display(next)
# alt-space -> toggle between last two displays
bind alt space to echo ^A^A
bind alt space to script es_display(toggle
# alt-1..alt-0 -> display_0..display_9
bind alt 0x31 to echo ^A0
bind alt 0x32 to echo ^A1
bind alt 0x33 to echo ^A2
bind alt 0x34 to echo ^A3
bind alt 0x35 to echo ^A4
bind alt 0x36 to echo ^A5
bind alt 0x37 to echo ^A6
bind alt 0x38 to echo ^A7
bind alt 0x39 to echo ^A8
bind alt 0x30 to echo ^A9
# alt-1..alt-0 -> display(0..display(9
bind alt 0x31 to script es_display(goto,0)
bind alt 0x32 to script es_display(goto,1)
bind alt 0x33 to script es_display(goto,2)
bind alt 0x34 to script es_display(goto,3)
bind alt 0x35 to script es_display(goto,4)
bind alt 0x36 to script es_display(goto,5)
bind alt 0x37 to script es_display(goto,6)
bind alt 0x38 to script es_display(goto,7)
bind alt 0x39 to script es_display(goto,8)
bind alt 0x30 to script es_display(goto,9)
# FUNCTION KEYS ##############################################################
# F1..F10 -> display_0..display_9
bind F1 to echo ^A0
bind F2 to echo ^A1
bind F3 to echo ^A2
bind F4 to echo ^A3
bind F5 to echo ^A4
bind F6 to echo ^A5
bind F7 to echo ^A6
bind F8 to echo ^A7
bind F9 to echo ^A8
bind F10 to echo ^A9
# F1..F10 -> display0..display9
bind F1 to script es_display(goto,0)
bind F2 to script es_display(goto,1)
bind F3 to script es_display(goto,2)
bind F4 to script es_display(goto,3)
bind F5 to script es_display(goto,4)
bind F6 to script es_display(goto,5)
bind F7 to script es_display(goto,6)
bind F8 to script es_display(goto,7)
bind F9 to script es_display(goto,8)
bind F10 to script es_display(goto,9)
# alt F4 -> close display
bind alt F4 to echo ^Ak
# alt F4 -> close display (ask for confirmation)
bind alt F4 to script es_display(kill,ask)
# MISC STUFF #################################################################
# DISPLAY
# alt-n -> new display
bind alt n to echo ^Ac
bind alt n to script es_display(new)
# alt-r -> rename display
bind alt r to echo ^AA
bind alt r to script es_display(title)
# alt-c -> close display
bind alt c to echo ^Ak
bind alt c to script es_display(kill,ask)
# alt-m -> monitor display
bind alt m to echo ^AM
bind alt m to script es_display(monitor)
# alt-b -> backlog
bind alt b to echo ^A^[
# alt-b -> backlog (^A^[)
bind alt b to script es_display(back)
# REGION
# alt-s -> split
bind alt s to echo ^AS
# alt-s -> split (^AS)
bind alt s to script es_region(new)
# alt-u -> unsplit
bind alt u to echo ^AQ
# alt-u -> unsplit (^AQ)
bind alt u to script es_region(full)
# alt-o -> other region
bind alt o to echo ^A^I
# alt-o -> other region (^A^I)
bind alt o to script es_region(next)
# alt-k -> kill region
bind alt k to echo ^AX
# alt-k -> kill region (^AX)
bind alt k to script es_region(kill,ask)
# ^Tab -> next region
bind ctrl Tab to echo ^A^I
# ^Tab -> next region (^A^I)
bind ctrl Tab to script es_region(next)
# OTHER
# alt-S -> statement
bind alt shift S to echo ^A:
# alt-S -> statement (^A:)
bind alt shift S to script es_statement
# alt-R -> reset
bind alt shift R to echo ^AZ
# alt-R -> reset (^AZ)
bind alt shift R to script es_reset

View File

@ -825,7 +825,7 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
case ACTION_ECHO:
if (!press) {
#ifdef ESCREEN
if (TermWin.screen && TermWin.screen->backend) { /* translate escapes */
if (TermWin.screen && TermWin.screen->backend) { /* translate escapes */
button_t *b = bbar->buttons;
_ns_disp *d2 = TermWin.screen->dsps;
int n = (button->action.string)[1] - '0';
@ -855,7 +855,7 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
if (prvs == 2) {
/* middle button -- kill */
(void) ns_rem_disp(TermWin.screen, n);
(void) ns_rem_disp(TermWin.screen, n, TRUE);
} else {
/* right button -- rename */
(void) ns_ren_disp(TermWin.screen, n, NULL);
@ -1164,7 +1164,7 @@ buttonbar_t *bbar_insert_button(buttonbar_t *bbar, button_t *button, int after,
}
}
} else { /* add to buttons */
if (!bbar->buttons || after < 0) { /* first button */
if (!bbar->buttons || after < 0) { /* first button */
button->next = bbar->buttons;
bbar->buttons = button;
} else {

View File

@ -131,7 +131,11 @@ static const char cvs_ident[] = "$Id$";
#include "menus.h"
#ifdef ESCREEN
# include "screamcfg.h"
# include "screamcfg.h"
# ifdef NS_HAVE_TWIN
# include <Tw/Tw.h>
TW_DECL_MAGIC(libscream_magic);
# endif
#endif
static RETSIGTYPE handle_child_signal(int);
@ -141,7 +145,7 @@ static RETSIGTYPE handle_crash(int);
/* local variables */
int my_ruid, my_euid, my_rgid, my_egid;
char initial_dir[PATH_MAX + 1];
static char *ptydev = NULL, *ttydev = NULL; /* pty/tty name */
static char *ptydev = NULL, *ttydev = NULL; /* pty/tty name */
int cmd_fd = -1; /* file descriptor connected to the command */
int pipe_fd = -1;
pid_t cmd_pid = -1; /* process id if child */
@ -955,10 +959,10 @@ const char *
get_ctrl_char_name(char c)
{
const char *lookup[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", /* 0-7 */
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", /* 8-15 */
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", /* 16-23 */
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" /* 24-31 */
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", /* 0-7 */
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", /* 8-15 */
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", /* 16-23 */
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" /* 24-31 */
};
return ((c < ' ') ? (lookup[(int) c]) : (""));
@ -1134,8 +1138,7 @@ clean_exit(void)
font_cache_clear();
eterm_font_list_clear();
# ifdef PIXMAP_SUPPORT
FOREACH_IMAGE(free_eterm_image(&(images[idx]));
);
FOREACH_IMAGE(free_eterm_image(&(images[idx])););
# endif
for (i = 0; i < NRS_COLORS; i++) {
if (rs_color[i]) {
@ -1419,7 +1422,7 @@ get_tty(void)
privileges(INVOKE);
# ifndef __CYGWIN32__
fchown(fd, my_ruid, gid); /* fail silently */
fchown(fd, my_ruid, gid); /* fail silently */
fchmod(fd, mode);
# endif
privileges(REVERT);
@ -1676,28 +1679,28 @@ get_ttymode(ttymode_t *tio)
/* get parameters -- gtty */
if (ioctl(0, TIOCGETP, &(tio->sg)) < 0) {
tio->sg.sg_erase = CERASE; /* ^H */
tio->sg.sg_kill = CKILL; /* ^U */
tio->sg.sg_erase = CERASE; /* ^H */
tio->sg.sg_kill = CKILL; /* ^U */
}
tio->sg.sg_flags = (CRMOD | ECHO | EVENP | ODDP);
/* get special characters */
if (ioctl(0, TIOCGETC, &(tio->tc)) < 0) {
tio->tc.t_intrc = CINTR; /* ^C */
tio->tc.t_quitc = CQUIT; /* ^\ */
tio->tc.t_startc = CSTART; /* ^Q */
tio->tc.t_stopc = CSTOP; /* ^S */
tio->tc.t_intrc = CINTR; /* ^C */
tio->tc.t_quitc = CQUIT; /* ^\ */
tio->tc.t_startc = CSTART; /* ^Q */
tio->tc.t_stopc = CSTOP; /* ^S */
tio->tc.t_eofc = CEOF; /* ^D */
tio->tc.t_brkc = -1;
}
/* get local special chars */
if (ioctl(0, TIOCGLTC, &(tio->lc)) < 0) {
tio->lc.t_suspc = CSUSP; /* ^Z */
tio->lc.t_dsuspc = CDSUSP; /* ^Y */
tio->lc.t_rprntc = CRPRNT; /* ^R */
tio->lc.t_flushc = CFLUSH; /* ^O */
tio->lc.t_werasc = CWERASE; /* ^W */
tio->lc.t_lnextc = CLNEXT; /* ^V */
tio->lc.t_suspc = CSUSP; /* ^Z */
tio->lc.t_dsuspc = CDSUSP; /* ^Y */
tio->lc.t_rprntc = CRPRNT; /* ^R */
tio->lc.t_flushc = CFLUSH; /* ^O */
tio->lc.t_werasc = CWERASE; /* ^W */
tio->lc.t_lnextc = CLNEXT; /* ^V */
}
/* get line discipline */
ioctl(0, TIOCGETD, &(tio->line));
@ -2715,7 +2718,7 @@ matrix(int n)
break;
default:
t[x] = random() & 0xff; /* hold */
t[x] = random() & 0xff; /* hold */
}
}
}
@ -2759,7 +2762,97 @@ waitstate(void *xd, int ms)
return 0;
}
#undef CLEAR
int
make_escreen_menu(void)
{
button_t *button;
menu_t *m;
menuitem_t *i;
if ((m = menu_create(NS_MENU_TITLE))) {
char *sc[] = {
/* display functions */
"New", "display(new)", /* \x01:screen\r */
"New ...", "display(new,ask)",
"Rename ...", "display(name,ask)",
"Backlog ...", "display(backlog)",
"Monitor", "display(monitor)",
"Close", "display(close)",
"-", "",
/* region functions */
"Split", "region(new)",
"Unsplit", "region(full)",
"Prvs region", "region(prvs)", /* NS_SCREEN_PRVS_REG */
"Next region", "region(next)",
"Kill region", "region(kill)",
"-", "",
/* screen functions */
"Reset", "reset",
"Statement", "statement",
"-", ""
};
int n, nsc = sizeof(sc) / sizeof(char *);
if (menu_list) {
for (n = 0; n < menu_list->nummenus; n++) { /* blend in w/ l&f */
if (menu_list->menus[n]->font) {
m->font = menu_list->menus[n]->font;
m->fwidth = menu_list->menus[n]->fwidth;
m->fheight = menu_list->menus[n]->fheight;
#ifdef MULTI_CHARSET
m->fontset = menu_list->menus[n]->fontset;
#endif
break;
}
}
}
for (n = 0; n < (nsc - 1); n += 2) {
if (!strcmp(sc[n], "-")) { /* separator */
if ((i = menuitem_create(NULL))) {
menu_add_item(m, i);
menuitem_set_action(i, MENUITEM_SEP, NULL);
}
} /* menu entry */
else if ((i = menuitem_create(sc[n]))) {
menuitem_set_action(i, MENUITEM_SCRIPT, sc[n + 1]);
menu_add_item(m, i);
}
}
if ((i = menuitem_create("About..."))) {
menuitem_set_action(i, MENUITEM_ALERT, "Screen/Twin compatibility layer by Azundris <scream@azundris.com>");
menu_add_item(m, i);
}
if ((button = button_create(NS_MENU_TITLE))) {
if (!(buttonbar = bbar_insert_button(buttonbar, button, -1, TRUE))) {
m->font = NULL;
#ifdef MULTI_CHARSET
m->fontset = NULL;
#endif
menu_delete(m);
button_set_action(button, ACTION_STRING, NS_MENU_TITLE);
button_free(button);
} else {
int j, k = menu_list ? menu_list->nummenus : 0;
menu_list = menulist_add_menu(menu_list, m);
for (j = k; j < menu_list->nummenus; j++) {
event_data_add_mywin(&menu_event_data, menu_list->menus[j]->win);
}
if (!k) {
menu_init();
}
button_set_action(button, ACTION_MENU, NS_MENU_TITLE);
return 1; /* success! */
}
}
}
return 0;
}
/* Set everything up for escreen mode */
int
@ -2795,92 +2888,10 @@ escreen_init(char **argv)
if (!TermWin.screen_mode) {
return run_command(argv);
} else if ((TermWin.screen = ns_attach_by_URL(rs_url, rs_hop, &efuns, &ns_err, (void *) &buttonbar))) {
button_t *button;
menu_t *m;
menuitem_t *i;
if (rs_delay >= 0) {
TermWin.screen->delay = rs_delay; /* more flexible ways later */
}
if ((m = menu_create(NS_MENU_TITLE))) {
char *sc[] = {
/* display functions */
"New", "\x01:screen\r",
"New ...", "\x01\x03\x01\x41",
"Backlog ...", "\x01\x1b",
"Monitor", "\x01M",
"Close", "\x01k",
"-", "",
/* region functions */
"Split", "\x01S",
"Unsplit", "\x01Q",
"Prvs region", NS_SCREEN_PRVS_REG,
"Next region", "\x01\t",
"Kill region", "\x01X",
"-", "",
/* screen functions */
"Reset", NS_SCREEN_INIT,
"Statement", "\x01:",
"-", ""
};
int n, nsc = sizeof(sc) / sizeof(char *);
if (menu_list) {
for (n = 0; n < menu_list->nummenus; n++) { /* blend in w/ l&f */
if (menu_list->menus[n]->font) {
m->font = menu_list->menus[n]->font;
m->fwidth = menu_list->menus[n]->fwidth;
m->fheight = menu_list->menus[n]->fheight;
#ifdef MULTI_CHARSET
m->fontset = menu_list->menus[n]->fontset;
#endif
break;
}
}
}
for (n = 0; n < (nsc - 1); n += 2) {
if (!strcmp(sc[n], "-")) {
/* separator */
if ((i = menuitem_create(NULL))) {
menu_add_item(m, i);
menuitem_set_action(i, MENUITEM_SEP, NULL);
}
} else if ((i = menuitem_create(sc[n]))) {
/* menu entry */
menuitem_set_action(i, n && strcmp(sc[n + 1], NS_SCREEN_INIT)
&& strcmp(sc[n + 1], NS_SCREEN_PRVS_REG) ? MENUITEM_ECHO : MENUITEM_LITERAL, sc[n + 1]);
menu_add_item(m, i);
}
}
if ((i = menuitem_create("About..."))) {
menuitem_set_action(i, MENUITEM_ALERT, "Screen compatibility layer by Azundris <scream@azundris.com>");
menu_add_item(m, i);
}
if ((button = button_create(NS_MENU_TITLE))) {
if (!(buttonbar = bbar_insert_button(buttonbar, button, -1, TRUE))) {
m->font = NULL;
#ifdef MULTI_CHARSET
m->fontset = NULL;
#endif
menu_delete(m);
button_set_action(button, ACTION_STRING, NS_MENU_TITLE);
button_free(button);
} else {
int j, k = menu_list ? menu_list->nummenus : 0;
menu_list = menulist_add_menu(menu_list, m);
for (j = k; j < menu_list->nummenus; j++) {
event_data_add_mywin(&menu_event_data, menu_list->menus[j]->win);
}
if (!k)
menu_init();
button_set_action(button, ACTION_MENU, NS_MENU_TITLE);
}
}
TermWin.screen->delay = rs_delay; /* more flexible ways later */
}
make_escreen_menu();
/* add_screen_ctl_button(&buttonbar,"New",'c'); */
return TermWin.screen->fd;
}
@ -2976,13 +2987,13 @@ cmd_write(const unsigned char *str, unsigned int count)
/* try and get more space from the end */
unsigned char *src, *dst;
dst = (cmdbuf_base + sizeof(cmdbuf_base) - 1); /* max pointer */
dst = (cmdbuf_base + sizeof(cmdbuf_base) - 1); /* max pointer */
if ((cmdbuf_ptr + n) > dst)
n = (dst - cmdbuf_ptr); /* max # chars to insert */
n = (dst - cmdbuf_ptr); /* max # chars to insert */
if ((cmdbuf_endp + n) > dst)
cmdbuf_endp = (dst - n); /* truncate end if needed */
cmdbuf_endp = (dst - n); /* truncate end if needed */
/* equiv: memmove ((cmdbuf_ptr+n), cmdbuf_ptr, n); */
src = cmdbuf_endp;
@ -3100,11 +3111,27 @@ cmd_getc(void)
# ifdef NS_HAVE_SCREAM
case NS_MODE_SCREAM:
break;
# endif
# ifdef NS_HAVE_TWIN
case NS_MODE_TWIN:
if (!TermWin.screen->twin) {
if (!Tw_CheckMagic(libscream_magic)) {
D_ESCREEN(("ns_attach_by_sess: Tw_CheckMagic failed\n"));
TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE;
} else {
if (!(TermWin.screen->twin = Tw_Open(TermWin.screen->twin_str))) {
D_ESCREEN(("ns_attach_by_sess: Tw_Open(%s) failed\n", TermWin.screen->twin_str));
TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE;
} else {
D_ESCREEN(("ns_attach_by_sess: Tw_Open(%s) succeeded\n", TermWin.screen->twin_str));
}
}
}
break;
# endif
default:
D_ESCREEN(("mode %d not supported...\n", TermWin.screen->backend));
TermWin.screen->backend = NS_MODE_NONE;
TermWin.screen_mode = NS_MODE_NONE;
TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE;
}
}
#endif
@ -3116,7 +3143,7 @@ cmd_getc(void)
for (;;) {
v_doPending();
while (XPending(Xdisplay)) { /* process pending X events */
while (XPending(Xdisplay)) { /* process pending X events */
XEvent ev;
@ -3188,8 +3215,10 @@ cmd_getc(void)
if (retval < 0) {
if (cmd_fd >= 0 && FD_ISSET(cmd_fd, &readfds)) {
print_error("Error reading from tty -- %s\n", strerror(errno));
cmd_fd = -1;
if (errno != EINTR) { /* may have rcvd SIGCHLD or so */
print_error(" (%ld) Error reading from tty -- %s\n", getpid(), strerror(errno));
cmd_fd = -1;
}
}
if (pipe_fd >= 0 && FD_ISSET(pipe_fd, &readfds)) {
print_error("Error reading from pipe -- %s\n", strerror(errno));
@ -3323,7 +3352,7 @@ main_loop(void)
#endif
do {
while ((ch = cmd_getc()) == 0); /* wait for something */
while ((ch = cmd_getc()) == 0); /* wait for something */
if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') {
/* Read a text string from the input buffer */
int nlines = 0;
@ -3437,7 +3466,7 @@ v_writeBig(int f, char *d, int len)
*/
if (len > 0) {
if (v_bufend < v_bufptr + len) { /* we've run out of room */
if (v_bufend < v_bufptr + len) { /* we've run out of room */
if (v_bufstr != v_buffer) {
/* there is unused space, move everything down */
/* possibly overlapping bcopy here */
@ -3450,7 +3479,7 @@ v_writeBig(int f, char *d, int len)
if (v_bufend < v_bufptr + len) {
/* still won't fit: get more space */
/* Don't use XtRealloc because an error is not fatal. */
int size = v_bufptr - v_buffer; /* save across realloc */
int size = v_bufptr - v_buffer; /* save across realloc */
v_buffer = REALLOC(v_buffer, size + len);
if (v_buffer) {
@ -3460,13 +3489,13 @@ v_writeBig(int f, char *d, int len)
} else {
/* no memory: ignore entire write request */
print_error("cannot allocate buffer space\n");
v_buffer = v_bufstr; /* restore clobbered pointer */
v_buffer = v_bufstr; /* restore clobbered pointer */
c = 0;
}
}
}
if (v_bufend >= v_bufptr + len) { /* new stuff will fit */
memcpy(v_bufptr, d, len); /* bcopy(d, v_bufptr, len); */
if (v_bufend >= v_bufptr + len) { /* new stuff will fit */
memcpy(v_bufptr, d, len); /* bcopy(d, v_bufptr, len); */
v_bufptr += len;
}
}
@ -3492,13 +3521,13 @@ v_writeBig(int f, char *d, int len)
}
D_TTY(("Wrote %d characters\n", written));
v_bufstr += written;
if (v_bufstr >= v_bufptr) /* we wrote it all */
if (v_bufstr >= v_bufptr) /* we wrote it all */
v_bufstr = v_bufptr = v_buffer;
}
/*
* If we have lots of unused memory allocated, return it
*/
if (v_bufend - v_bufptr > 1024) { /* arbitrary hysteresis */
if (v_bufend - v_bufptr > 1024) { /* arbitrary hysteresis */
/* save pointers across realloc */
int start = v_bufstr - v_buffer;
int size = v_bufptr - v_buffer;
@ -3511,7 +3540,7 @@ v_writeBig(int f, char *d, int len)
v_bufend = v_buffer + allocsize;
} else {
/* should we print a warning if couldn't return memory? */
v_buffer = v_bufstr - start; /* restore clobbered pointer */
v_buffer = v_bufstr - start; /* restore clobbered pointer */
}
}
}

View File

@ -182,7 +182,7 @@ eterm_default_font_locale(char ***fonts, char ***mfonts, char **mencoding, int *
if ((locale = getenv("LC_ALL")) == NULL)
if ((locale = getenv("LC_CTYPE")) == NULL)
if ((locale = getenv("LANG")) == NULL)
locale = "C"; /* failsafe */
locale = "C"; /* failsafe */
/* Obtain a "normalized" name of current encoding.
* The current encoding is available via nl_langinfo().

View File

@ -144,7 +144,7 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border * bord, unsigned char up)
unsigned int r, g, b;
int real_depth = 0, depth_factor;
register int br, bg, bb; /* Bitshifts */
register unsigned int mr, mg, mb; /* Bitmasks */
register unsigned int mr, mg, mb; /* Bitmasks */
GC gc;
if (!bord)

View File

@ -144,7 +144,7 @@ enl_ipc_send(char *str)
}
}
len = strlen(str);
for (; XCheckTypedWindowEvent(Xdisplay, my_ipc_win, ClientMessage, &ev);); /* Discard any out-of-sync messages */
for (; XCheckTypedWindowEvent(Xdisplay, my_ipc_win, ClientMessage, &ev);); /* Discard any out-of-sync messages */
ev.xclient.type = ClientMessage;
ev.xclient.serial = 0;
ev.xclient.send_event = True;

View File

@ -237,7 +237,7 @@ font_cache_del(const void *info)
current->next = current->next->next;
XFreeFont(Xdisplay, (XFontStruct *) info);
if (cur_font == tmp) {
cur_font = current; /* If we're nuking the last entry in the cache, point cur_font to the *new* last entry. */
cur_font = current; /* If we're nuking the last entry in the cache, point cur_font to the *new* last entry. */
}
FREE(tmp->name);
FREE(tmp);
@ -632,7 +632,7 @@ change_font(int init, const char *fontname)
fw = boldFont->min_bounds.width;
fh = boldFont->ascent + boldFont->descent + rs_line_space;
if (TermWin.fprop == 0) { /* bold font must also be monospaced */
if (TermWin.fprop == 0) { /* bold font must also be monospaced */
if (fw != boldFont->max_bounds.width)
fw = -1;
} else {

View File

@ -53,9 +53,9 @@ static const char cvs_ident[] = "$Id$";
# include <string.h>
/* --- Macros, Types --------- */
# define MAX_STATES 4 /* max # states for the FSM */
# define MAX_SWITCHER 2U /* per state */
# define MAX_VAL 256 /* for temp allocation */
# define MAX_STATES 4 /* max # states for the FSM */
# define MAX_SWITCHER 2U /* per state */
# define MAX_VAL 256 /* for temp allocation */
typedef unsigned char u_char;
typedef unsigned int u_int;
@ -77,7 +77,7 @@ typedef struct s_state {
u_int num_xlat; /* number of translations */
K_XLAT *xlat; /* State translations ((dynamic - realloc'ed) */
u_int num_switcher; /* number of switcher keys */
K_SWITCH switcher[MAX_SWITCHER]; /* switcher keys to other states */
K_SWITCH switcher[MAX_SWITCHER]; /* switcher keys to other states */
u_char life; /* 0 = until switched by key */
u_char prev_state; /* filled when jumped to a new state */
} K_STATE;
@ -111,7 +111,7 @@ static char elot_xlat_plain[] =
/* c and s give copyright and section sign */
static char elot_xlat_acc[] = "65-122:182,194,216,196,184,214,195,185,186,206,202,203,204,205,188,208,81,209,211,212,200,191,87,215,190,198,91,92,93,94,95,96,220,226,"
/*248 */ "169,228,221,246,227,222,223,238,234,235,236,237,252,240,113,241," /*243 */ "167,244,232,254,242,247,253,230";
static char elot_xlat_acc_xtra[] = "46-62:183,47,48,49,50,51,52,53,54,55,56,57,58,59,171,61,187"; /* anw teleia, quotes */
static char elot_xlat_acc_xtra[] = "46-62:183,47,48,49,50,51,52,53,54,55,56,57,58,59,171,61,187"; /* anw teleia, quotes */
static char elot_xlat_uml[] =
"65-122:193,194,216,196,197,214,195,199,218,206,202,203,204,205,207,208,81,209,211,212,200,217,87,215,219,198,91,92,93,94,95,96,225,226,248,228,229,246,227,231,250,238,234,235,236,237,239,240,113,241,243,244,232,249,242,247,251,230";
static char elot_xlat_umacc[] =
@ -122,7 +122,7 @@ static char i437_xlat_plain[] =
"65-122:128,129,150,131,132,148,130,134,136,141,137,138,139,140,142,143,81,144,145,146,135,151,87,149,147,133,91,92,93,94,95,96,152,153,175,155,156,173,154,158,160,165,161,162,163,164,166,167,113,168,169,171,159,224,170,174,172,157";
static char i437_xlat_acc[] =
"65-122:234,129,150,131,235,148,130,236,237,141,137,138,139,140,238,143,81,144,145,146,135,240,87,149,239,133,91,92,93,94,95,96,225,153,175,155,226,173,154,227,229,165,161,162,163,164,230,167,113,168,169,171,159,233,170,174,231,157";
static char i437_xlat_acc_xtra[] = "46-46:250"; /* anw teleia */
static char i437_xlat_acc_xtra[] = "46-46:250"; /* anw teleia */
static char i437_xlat_uml[] =
"65-122:128,129,150,131,132,148,130,134,136,141,137,138,139,140,142,143,81,144,145,146,135,151,87,149,147,133,91,92,93,94,95,96,152,153,175,155,156,173,154,158,228,165,161,162,163,164,166,167,113,168,169,171,159,224,170,174,232,157";
static char i437_xlat_umacc[] =
@ -195,7 +195,7 @@ kstate_init_all(int greek_mode)
kstate_setcurr(i);
kstate_init();
}
if (greek_mode < 0 || greek_mode >= NUM_XLAT_TYPES) /* avoid death */
if (greek_mode < 0 || greek_mode >= NUM_XLAT_TYPES) /* avoid death */
greek_mode = GREEK_ELOT928;
xlat_now = &xlat_type[greek_mode];
kstate_setcurr(0);
@ -309,7 +309,7 @@ kstate_cxlat(unsigned int c)
/* check for ascii switcher */
for (i = 0; i < pStateNow->num_switcher; i++)
if (pStateNow->switcher[i].type == 'A' && /* only ascii here */
if (pStateNow->switcher[i].type == 'A' && /* only ascii here */
c == pStateNow->switcher[i].code) {
kstate_setcurr(pStateNow->switcher[i].nextstate);
pStateNow->switcher[i].on = 1;

File diff suppressed because it is too large Load Diff

View File

@ -309,7 +309,7 @@ menu_handle_button_release(event_t *ev)
menu_reset_all(menu_list);
current_menu = NULL;
} else {
current_menu->state &= ~MENU_STATE_IS_DRAGGING; /* Click, brief drag, release == single click */
current_menu->state &= ~MENU_STATE_IS_DRAGGING; /* Click, brief drag, release == single click */
}
} else {
@ -1304,7 +1304,7 @@ menu_tab(void *xd, char *sc[], int nsc, char *b, size_t l, size_t m)
for (n = n2; n < nsc; n++) {
if (!strncasecmp(b, sc[n], l)) {
if (strcmp(b, sc[n])) {
if (strlen(sc[n]) >= m) /* buffer would overflow => fail */
if (strlen(sc[n]) >= m) /* buffer would overflow => fail */
return -1;
strcpy(b, sc[n]);
return 0;
@ -1360,8 +1360,8 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
}
if ((m = menu_create(prompt))) {
for (l = 0; l < menu_list->nummenus; l++) { /* copycat font entry to */
if (menu_list->menus[l]->font) { /* blend in with l&f */
for (l = 0; l < menu_list->nummenus; l++) { /* copycat font entry to */
if (menu_list->menus[l]->font) { /* blend in with l&f */
m->font = menu_list->menus[l]->font;
m->fwidth = menu_list->menus[l]->fwidth;
m->fheight = menu_list->menus[l]->fheight;

View File

@ -78,7 +78,7 @@ network_display(const char *display)
if (display[0] != ':' && strncmp(display, "unix:", 5))
return display; /* nothing to do */
ifc.ifc_len = sizeof(buffer); /* Get names of all ifaces */
ifc.ifc_len = sizeof(buffer); /* Get names of all ifaces */
ifc.ifc_buf = buffer;
if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {

View File

@ -173,11 +173,6 @@ static const struct {
OPT_STR('t', "theme", "select a theme", &rs_theme),
OPT_STR('X', "config-file", "choose an alternate config file", &rs_config_file), OPT_STR('d', "display", "X server to connect to", &display_name),
#ifdef ESCREEN
OPT_STR('U', "URL", "an URL pointing at a screen-session to pick up", &rs_url),
OPT_STR('Z', "[lclport:]fw[:fwport]", "the destination machine -U can only be seen by the firewall fw. tunnel.", &rs_hop),
OPT_INT('z', "delay", "initial delay in seconds", &rs_delay),
#endif
#if DEBUG <= 0
OPT_ILONG("debug", "level of debugging information to show (support not compiled in)", &DEBUG_LEVEL),
#elif DEBUG == 1
@ -329,7 +324,13 @@ static const struct {
OPT_LONG("term-name", "value to use for setting $TERM", &rs_term_name),
OPT_LONG("pipe-name", "filename of console pipe to emulate -C", &rs_pipe_name),
OPT_STR('a', "attribute", "parse an attribute in the specified context", NULL),
OPT_BOOL('C', "console", "grab console messages", &Options, Opt_console), OPT_ARGS('e', "exec", "execute a command rather than a shell", &rs_exec_args)
OPT_BOOL('C', "console", "grab console messages", &Options, Opt_console),
#ifdef ESCREEN
OPT_STR('U', "URL", "an URL pointing at a screen-session to pick up", &rs_url),
OPT_STR('Z', "[lclport:]fw[:fwport]", "the destination machine -U can only be seen by the firewall fw. tunnel.", &rs_hop),
OPT_INT('z', "delay", "initial delay in seconds", &rs_delay),
#endif
OPT_ARGS('e', "exec", "execute a command rather than a shell", &rs_exec_args)
};
/* Print usage information */
@ -891,7 +892,7 @@ get_options(int argc, char *argv[])
} else if (!strcasecmp(opt, "attribute")) {
conf_parse_line(NULL, val_ptr);
} else { /* It's not --exec */
if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */
if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */
D_OPTIONS(("Boolean option detected\n"));
if (val_ptr) {
if (BOOL_OPT_ISTRUE(val_ptr)) {
@ -914,7 +915,7 @@ get_options(int argc, char *argv[])
*(optList[j].maskvar) |= optList[j].mask;
}
}
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
D_OPTIONS(("Integer option detected\n"));
*((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0);
} else { /* String value */
@ -962,13 +963,13 @@ get_options(int argc, char *argv[])
if ((val_ptr == NULL) || ((*val_ptr == '-') && (optList[j].short_opt != 'F') && (optList[j].short_opt != 'g'))) {
print_error("option -%c requires a%s value\n", opt[pos], (optList[j].flag & OPT_INTEGER ? "n integer" : " string"));
CHECK_BAD();
if (val_ptr) { /* If the "arg" was actually an option, don't skip it */
if (val_ptr) { /* If the "arg" was actually an option, don't skip it */
i--;
}
continue;
}
}
if (opt[pos] == 'e') { /* It's an exec */
if (opt[pos] == 'e') { /* It's an exec */
register unsigned short k, len;
@ -1003,12 +1004,12 @@ get_options(int argc, char *argv[])
} else if (opt[pos] == 'a') {
conf_parse_line(NULL, val_ptr);
} else {
if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */
if (optList[j].flag & OPT_BOOLEAN) { /* Boolean value */
D_OPTIONS(("Boolean option detected\n"));
if (optList[j].maskvar) {
*(optList[j].maskvar) |= optList[j].mask;
}
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
D_OPTIONS(("Integer option detected\n"));
*((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0);
D_OPTIONS(("Got value %d\n", *((int *) optList[j].pval)));
@ -1137,7 +1138,7 @@ get_initial_options(int argc, char *argv[])
D_OPTIONS(("val_ptr == %s done == %d\n", val_ptr, done));
if ((val_ptr == NULL) || (*val_ptr == '-')) {
print_error("option -%c requires a string value\n", opt[pos]);
if (val_ptr) { /* If the "arg" was actually an option, don't skip it */
if (val_ptr) { /* If the "arg" was actually an option, don't skip it */
i--;
}
continue;
@ -1556,12 +1557,10 @@ parse_toggles(char *buff, void *state)
} else if (!BEG_STRCASECMP(buff, "buttonbar")) {
if (bool_val) {
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 1);
);
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 1););
rs_buttonbars = 1; /* Reset for future use. */
} else {
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 0);
);
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 0););
rs_buttonbars = 1; /* Reset for future use. */
}
@ -2162,7 +2161,7 @@ parse_image(char *buff, void *state)
if ((images[idx].current->iml->border->left == 0) && (images[idx].current->iml->border->right == 0)
&& (images[idx].current->iml->border->top == 0) && (images[idx].current->iml->border->bottom == 0)) {
FREE(images[idx].current->iml->border);
images[idx].current->iml->border = (Imlib_Border *) NULL; /* No sense in wasting CPU time and memory if there are no borders */
images[idx].current->iml->border = (Imlib_Border *) NULL; /* No sense in wasting CPU time and memory if there are no borders */
}
} else if (!BEG_STRCASECMP(buff, "bevel ")) {
if (!CHECK_VALID_INDEX(idx)) {
@ -2477,9 +2476,9 @@ parse_bbar(char *buff, void *state)
print_error("Parse error in file %s, line %lu: Attribute dock requires a parameter\n", file_peek_path(), file_peek_line());
} else if (!BEG_STRCASECMP(where, "top")) {
bbar_set_docked(bbar, BBAR_DOCKED_TOP);
} else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */
} else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */
bbar_set_docked(bbar, BBAR_DOCKED_BOTTOM);
} else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */
} else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */
bbar_set_docked(bbar, BBAR_UNDOCKED);
} else {
print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute dock\n", file_peek_path(), file_peek_line(), where);
@ -2888,7 +2887,7 @@ post_parse(void)
if (rs_pixmaps[i]) {
reset_simage(images[i].norm, RESET_ALL_SIMG);
load_image(rs_pixmaps[i], images[i].norm);
FREE(rs_pixmaps[i]); /* These are created by STRDUP() */
FREE(rs_pixmaps[i]); /* These are created by STRDUP() */
}
#else
/* Right now, solid mode is the only thing we can do without pixmap support. */
@ -2997,11 +2996,9 @@ post_parse(void)
specified. If specified, it will either become 3 (on) or 0 (off). */
if (rs_buttonbars != 1) {
if (rs_buttonbars) {
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 1);
);
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 1););
} else {
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 0);
);
FOREACH_BUTTONBAR(bbar_set_visible(bbar, 0););
}
rs_buttonbars = 1; /* Reset for future use. */
}
@ -3168,11 +3165,11 @@ post_parse(void)
unsigned long w, h;
int count;
count = num_words(rs_anim_pixmap_list) - 1; /* -1 for the delay */
count = num_words(rs_anim_pixmap_list) - 1; /* -1 for the delay */
rs_anim_pixmaps = (char **) MALLOC(sizeof(char *) * (count + 1));
for (i = 0; i < count; i++) {
temp = get_word(i + 2, rs_anim_pixmap_list); /* +2 rather than +1 to account for the delay */
temp = get_word(i + 2, rs_anim_pixmap_list); /* +2 rather than +1 to account for the delay */
if (temp == NULL)
break;
if (num_words(temp) != 3) {

View File

@ -1005,7 +1005,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
return;
gcvalue.foreground = gcvalue.background = PixColors[bgColor];
gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
pixmap = simg->pmap->pixmap; /* Save this for later */
pixmap = simg->pmap->pixmap; /* Save this for later */
if ((which == image_bg) && (buffer_pixmap != None)) {
LIBAST_X_FREE_PIXMAP(buffer_pixmap);
buffer_pixmap = None;
@ -1992,7 +1992,7 @@ get_desktop_pixmap(void)
D_PIXMAP(("Current desktop pixmap is 0x%08x\n", (unsigned int) desktop_pixmap));
if (desktop_pixmap == None) {
orig_desktop_pixmap = None; /* Forced re-read. */
orig_desktop_pixmap = None; /* Forced re-read. */
}
if (desktop_window == None) {
D_PIXMAP(("No desktop window. Aborting.\n"));

View File

@ -7,6 +7,16 @@
#include "screamcfg.h"
#ifdef NS_HAVE_TWIN
# include <Tw/Tw.h>
#endif
#define NS_TWIN_PROTO "twin://"
#define NS_SCREEN_PROTO "screen://"
#define NS_SCREAM_PROTO "scream://"
#define NS_DK 0
#define NS_SSH 1
#define NS_LCL 2
@ -16,6 +26,9 @@
#define NS_MODE_NONE 0
#define NS_MODE_SCREEN 1
#define NS_MODE_SCREAM 2
#define NS_MODE_TWIN 3
#define NS_MAGIC_LINE(a) (((a)==NS_MODE_SCREEN)||((a)==NS_MODE_NEGOTIATE))
#define NS_SUCC (-1)
#define NS_FAIL 0
@ -102,6 +115,10 @@ typedef struct __ns_sess { /* a whole screen-session with many clients */
struct __ns_disp *curr; /* current display (NULL for none) */
struct __ns_sess *prvs; /* previous session in session list */
struct __ns_sess *next; /* next session in session list */
#ifdef NS_HAVE_TWIN
tdisplay twin;
char *twin_str;
#endif
} _ns_sess;
@ -164,6 +181,9 @@ _ns_efuns *ns_new_efuns(void);
_ns_efuns *ns_dst_efuns(_ns_efuns **);
_ns_efuns *ns_get_efuns(_ns_sess *,_ns_disp *);
/* get session anchor (for iterations) */
_ns_sess *ns_1st_sess(void);
/* transparent attach/detach */
_ns_sess *ns_attach_by_sess(_ns_sess **,int *);
_ns_sess *ns_attach_by_URL(char *,char *,_ns_efuns **,int *,void *);
@ -172,8 +192,10 @@ int ns_detach(_ns_sess **);
/* convenience */
int ns_run(_ns_efuns *, char *);
int ns_get_ssh_port(void);
int disp_get_real_by_screen(_ns_sess *,int);
int disp_get_screen_by_real(_ns_sess *,int);
int ns_magic_disp(_ns_sess **,_ns_disp **);
/* send command to screen */
int ns_screen_command(_ns_sess *, char *);
@ -204,17 +226,37 @@ int ns_parse_screen(_ns_sess *,int,int,char *);
/* backend abstraction */
/* things the term might ask screen/scream to do ***************************/
int ns_scroll2x(_ns_sess *,int);
int ns_scroll2y(_ns_sess *,int);
int ns_tog_disp(_ns_sess *);
int ns_go2_disp(_ns_sess *,int);
int ns_rel_disp(_ns_sess *,int);
int ns_add_disp(_ns_sess *,int,char *);
int ns_mov_disp(_ns_sess * s,int,int);
int ns_mov_disp(_ns_sess *,int,int);
int ns_rsz_disp(_ns_sess *,int,int,int);
int ns_rem_disp(_ns_sess *,int);
int ns_rem_disp(_ns_sess *,int,int);
int ns_ren_disp(_ns_sess *,int,char *);
int ns_log_disp(_ns_sess *,int,char *);
int ns_mon_disp(_ns_sess *,int);
int ns_sbb_disp(_ns_sess *,int);
int ns_tog_region(_ns_sess *,_ns_disp *);
int ns_go2_region(_ns_sess *,_ns_disp *,int);
int ns_rel_region(_ns_sess *,_ns_disp *,int);
int ns_add_region(_ns_sess *,_ns_disp *,int,char *);
int ns_mov_region(_ns_sess *,_ns_disp *,int,int);
int ns_rsz_region(_ns_sess *,_ns_disp *,int,int,int);
int ns_rem_region(_ns_sess *,_ns_disp *,int,int);
int ns_ren_region(_ns_sess *,_ns_disp *,int,char *);
int ns_log_region(_ns_sess *,_ns_disp *,int,char *);
int ns_mon_region(_ns_sess *,_ns_disp *,int);
int ns_sbb_region(_ns_sess *,_ns_disp *,int);
int ns_one_region(_ns_sess *,_ns_disp *,int);
int ns_upd_stat(_ns_sess *);
int ns_scroll2x(_ns_sess *,int);
int ns_scroll2y(_ns_sess *,int);
int ns_inp_dial(_ns_sess *,char *,int,char **,int (*)(void *,char *,size_t,size_t));
int ns_statement(_ns_sess *,char *);
int ns_reset(_ns_sess *,int);
char *ns_get_url(_ns_sess *,int);

View File

@ -18,6 +18,11 @@
/* compile in support for the GNU "screen" program as a backend */
#define NS_HAVE_SCREEN 1
/* compile in support for the "twin" program as a backend */
#undef NS_HAVE_TWIN
#define NS_MAXCMD 512
#define NS_SSH_CALL "ssh"
@ -31,6 +36,8 @@
#define NS_SCREEM_CALL "%s 2>/dev/null || %s"
#define NS_WRAP_CALL "export TERM=vt100; screen -wipe; %s"
#define NS_SCREEN_RC ".screenrc"
#define NS_TWIN_CALL "export TERM=xterm; twin %s"
#define NS_TWIN_OPTS "-hw=tty"
/* this should never change. the escape-char for an out-of-the-box "screen".
don't change this just because you set something else in your .screenrc */
@ -47,7 +54,7 @@
#define NS_SCREEN_UPDATE "\x01w"
#define NS_SCREEN_VERSION "\x01v"
#define NS_SCREEN_SESSION "\x01:sessionname\r"
#define NS_SCREEN_INIT "\x01:msgminwait 0\r\x01:msgwait 1\r\x01:hardstatus lastline\r\x01:defhstatus \"\\005w\"\r\x01:hstatus \"\\005w\"\r\x01:nethack off\r\x0c" NS_SCREEN_UPDATE NS_SCREEN_VERSION NS_SCREEN_SESSION