Sun Jun 2 20:23:07 2002 Michael Jennings (mej)

Latest Escreen patch along with twin support from Azundris.


SVN revision: 6297
eterm-0.10
Michael Jennings 21 years ago
parent 6df3396a5d
commit 981b29c895
  1. 4
      ChangeLog
  2. 11
      doc/Eterm.1.in
  3. 15
      reformat-code
  4. 16
      src/actions.c
  5. 102
      src/buttons.c
  6. 3
      src/buttons.h
  7. 274
      src/command.c
  8. 2
      src/command.h
  9. 2
      src/defaultfont.c
  10. 2
      src/draw.c
  11. 2
      src/e.c
  12. 2
      src/eterm_debug.h
  13. 85
      src/events.c
  14. 17
      src/font.c
  15. 19
      src/grkelot.c
  16. 1564
      src/libscream.c
  17. 141
      src/menus.c
  18. 6
      src/netdisp.c
  19. 340
      src/options.c
  20. 105
      src/pixmap.c
  21. 47
      src/scream.h
  22. 24
      src/screamcfg.h
  23. 137
      src/screen.c
  24. 1
      src/screen.h
  25. 44
      src/scrollbar.c
  26. 17
      src/startup.c
  27. 2
      src/system.c
  28. 112
      src/term.c
  29. 3
      src/timer.c
  30. 7
      src/utmp.c
  31. 52
      src/windows.c
  32. 15
      utils/Esetroot.c
  33. 8
      utils/Ettable.c

@ -4679,3 +4679,7 @@ Thu May 23 14:12:28 2002 Michael Jennings (mej)
More cleanups and warning removals.
----------------------------------------------------------------------
Sun Jun 2 20:23:07 2002 Michael Jennings (mej)
Latest Escreen patch along with twin support from Azundris.
----------------------------------------------------------------------

@ -618,9 +618,14 @@ rather than a shell. Forces Eterm mode.
.BI \-U " URL" ", \-\-url " URL
Pick up a "screen" session at
.I URL
rather than a local one. URLs look like so (screen://user@host.dom/options),
with all parts optional, defaulting to current user at localhost,
respectively. Forces Escreen mode, overrides \-\-exec.
rather than a local (-U "") one. URLs look like so
(screen://user@host.dom:port/screen_options), with all parts optional,
defaulting to "screen://current_user@localhost:22/-xRR". Forces Escreen mode,
overrides \-\-exec. Note that only screen-options (see "man screen") are
allowed; do not pass a command (with or without arguments) here: to pass
a command to the screen-session, use
.I screen [<options>] <command> [<args>]
instead.
.TP
.BI \-Z " lclport:fw:fwport,delay" ", \-\-fw " lclport:fw:fwport,delay
The URL given to \-U is in an intranet behind firewall

@ -1,10 +1,17 @@
#!/bin/sh
TYPENAMES=""
for i in button_t buttonbar_t menu_t menuitem_t ; do
TYPENAMES="$TYPENAMES -T $i"
done
for i in *.c src/*.c utils/*.c ; do
if test -f $i; then
echo Reformatting $i
indent -bap -br -ce -ci4 -cli2 -cs -di1 -i4 -l140 -lp -lps -nbc -npcs -nss -nsob -psl $i
fi
if test -f $i; then
echo Reformatting $i
indent -bad -bap -bbo -br -brs -cdw -ce -ci4 -cli2 -cs -di1 -i4 -l180 \
-lp -lps -nbc -nbfda -npcs -nprs -nsob -nss -nut -psl -saf -sai -saw $TYPENAMES $i
fi
done
perl -p -i.bak -e 's/(\w+)_t (\*+)\s+/$1_t $2/g;' */*.[ch]

@ -42,6 +42,9 @@ static const char cvs_ident[] = "$Id$";
#include "scrollbar.h"
#include "term.h"
#include "windows.h"
#ifdef ESCREEN
# include "screamcfg.h"
#endif
action_t *action_list = NULL;
@ -60,9 +63,12 @@ action_handle_echo(event_t *ev, action_t *action)
USE_VAR(ev);
REQUIRE_RVAL(action->param.string != NULL, 0);
#ifdef ESCREEN
if (TermWin.screen_mode && TermWin.screen) /* translate escapes */
if (TermWin.screen && TermWin.screen->backend) {
# ifdef NS_HAVE_SCREEN
/* translate escapes */
ns_parse_screen_interactive(TermWin.screen, action->param.string);
else
# endif
} else
#endif
tt_write((unsigned char *) action->param.string, strlen(action->param.string));
return 1;
@ -140,8 +146,7 @@ action_check_modifiers(unsigned short mod, int x_mod)
/* When we do have to check the modifiers, we do so in this order to eliminate the
most popular choices first. If any test fails, we return FALSE. */
D_ACTIONS(("Checking modifier set 0x%08x (" MOD_FMT ") vs. X modifier set 0x%08x (" MOD_FMT ")\n",
mod, SHOW_MODS(mod), x_mod, SHOW_X_MODS(x_mod)));
D_ACTIONS(("Checking modifier set 0x%08x (" MOD_FMT ") vs. X modifier set 0x%08x (" MOD_FMT ")\n", mod, SHOW_MODS(mod), x_mod, SHOW_X_MODS(x_mod)));
if (mod != MOD_ANY) {
/* LOGICAL_XOR() returns true if either the first parameter or the second parameter
is true, but not both...just like XOR. If the mask we're looking for is set in
@ -197,8 +202,7 @@ action_dispatch(event_t *ev, KeySym keysym)
ASSERT_RVAL(ev != NULL, 0);
ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 0);
D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n",
ev, ev->xbutton.button, keysym, ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", ev, ev->xbutton.button, keysym, ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
for (action = action_list; action; action = action->next) {
/* The very first thing we do is match the event type to the type
of the current action. This means that we'll only run through

@ -50,6 +50,10 @@ static const char cvs_ident[] = "$Id$";
static inline void draw_string(buttonbar_t *, Drawable, GC, int, int, char *, size_t);
buttonbar_t *buttonbar = NULL;
#ifdef ESCREEN
button_t *drag = NULL;
#endif
long bbar_total_h = -1;
static inline void
@ -70,8 +74,7 @@ draw_string(buttonbar_t *bbar, Drawable d, GC gc, int x, int y, char *str, size_
return;
}
buttonbar_t *
bbar_create(void)
buttonbar_t *bbar_create(void)
{
buttonbar_t *bbar;
Cursor cursor;
@ -188,8 +191,7 @@ bbar_handle_enter_notify(event_t *ev)
return 0;
}
bbar_draw(bbar, IMAGE_STATE_SELECTED, 0);
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y),
&unused_mask);
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);
b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
if (b) {
bbar_select_button(bbar, b);
@ -231,6 +233,9 @@ bbar_handle_button_press(event_t *ev)
if (bbar->current) {
bbar_click_button(bbar, bbar->current);
button_check_action(bbar, bbar->current, ev->xbutton.button, ev->xbutton.time);
#ifdef ESCREEN
drag = bbar->current;
#endif
}
return 1;
}
@ -244,6 +249,10 @@ bbar_handle_button_release(event_t *ev)
int unused_root_x, unused_root_y;
unsigned int unused_mask;
#ifdef ESCREEN
drag = NULL;
#endif
D_EVENTS(("bbar_handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
@ -252,8 +261,7 @@ bbar_handle_button_release(event_t *ev)
return 0;
}
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y),
&unused_mask);
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);
b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
if (b) {
@ -285,8 +293,7 @@ bbar_handle_motion_notify(event_t *ev)
return 0;
}
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev));
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y),
&mask);
XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &mask);
D_BBAR((" -> Pointer is at %d, %d with mask 0x%08x\n", ev->xbutton.x, ev->xbutton.y, mask));
b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
@ -315,8 +322,7 @@ bbar_dispatch_event(event_t *ev)
return (0);
}
buttonbar_t *
find_bbar_by_window(Window win)
buttonbar_t *find_bbar_by_window(Window win)
{
buttonbar_t *bbar;
@ -500,8 +506,7 @@ button_calc_size(buttonbar_t *bbar, button_t *button)
D_BBAR((" -> Final icon dimensions are %hux%hu\n", button->icon_w, button->icon_h));
}
#endif
D_BBAR((" -> Set button to %dx%d at %d, %d and icon to %dx%d\n", button->w, button->h, button->x, button->y, button->icon_w,
button->icon_h));
D_BBAR((" -> Set button to %dx%d at %d, %d and icon to %dx%d\n", button->w, button->h, button->x, button->y, button->icon_w, button->icon_h));
}
void
@ -577,8 +582,7 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
ASSERT_RVAL(fontname != NULL, 0);
D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth,
bbar->fheight, bbar->h));
D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth, bbar->fheight, bbar->h));
if (bbar->font) {
free_font(bbar->font);
}
@ -603,8 +607,7 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
return 1;
}
button_t *
find_button_by_text(buttonbar_t *bbar, char *text)
button_t *find_button_by_text(buttonbar_t *bbar, char *text)
{
register button_t *b;
@ -623,8 +626,7 @@ find_button_by_text(buttonbar_t *bbar, char *text)
return NULL;
}
button_t *
find_button_by_index(buttonbar_t *bbar, long idx)
button_t *find_button_by_index(buttonbar_t *bbar, long idx)
{
register button_t *b;
long i;
@ -639,8 +641,7 @@ find_button_by_index(buttonbar_t *bbar, long idx)
return ((i == idx) ? (b) : (NULL));
}
button_t *
find_button_by_coords(buttonbar_t *bbar, int x, int y)
button_t *find_button_by_coords(buttonbar_t *bbar, int x, int y)
{
register button_t *b;
@ -659,8 +660,7 @@ find_button_by_coords(buttonbar_t *bbar, int x, int y)
return NULL;
}
button_t *
button_create(char *text)
button_t *button_create(char *text)
{
button_t *button;
@ -791,8 +791,7 @@ bbar_click_button(buttonbar_t *bbar, button_t *button)
if (image_mode_is(image_button, MODE_MASK)) {
paste_simage(images[image_button].clicked, image_button, bbar->win, bbar->win, button->x, button->y, button->w, button->h);
} else {
draw_shadow_from_colors(bbar->win, PixColors[menuBottomShadowColor], PixColors[menuTopShadowColor], button->x, button->y, button->w,
button->h, 2);
draw_shadow_from_colors(bbar->win, PixColors[menuBottomShadowColor], PixColors[menuTopShadowColor], button->x, button->y, button->w, button->h, 2);
}
if (image_mode_is(image_button, MODE_AUTO)) {
enl_ipc_sync();
@ -826,38 +825,48 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
case ACTION_ECHO:
if (!press) {
#ifdef ESCREEN
if (TermWin.screen_mode && TermWin.screen) { /* 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';
if (prvs != 1) {
button_t *b = bbar->buttons;
_ns_disp *d2 = TermWin.screen->dsps;
int n = (button->action.string)[1] - '0';
/* find active disp */
for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next);
while (b && !(b->flags & NS_SCREAM_CURR)) /* find active disp */
b = b->next; /* when trying to change name of non- */
if (b && b != button) { /* active display, make that disp active */
if (b && b != button) {
/* when trying to change name of non- */
/* active display, make that disp active */
button->flags |= NS_SCREAM_CURR;
b->flags &= ~NS_SCREAM_CURR;
bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK);
button->flags &= ~NS_SCREAM_CURR;
b->flags |= NS_SCREAM_CURR;
while (d2 && d2->index != n)
d2 = d2->next;
if (d2)
TermWin.screen->curr = d2; /* pre-adjust curr ptr */
else
for (; d2 && d2->index != n; d2 = d2->next);
if (d2) {
/* pre-adjust curr ptr */
TermWin.screen->curr = d2;
} else {
D_ESCREEN(("no display %d in this session : (\n", n));
(void) ns_screen_command(TermWin.screen, button->action.string);
}
ns_go2_disp(TermWin.screen, n);
}
if (prvs == 2) /* middle button -- kill */
(void) ns_parse_screen_key(TermWin.screen, NS_SCREEN_KILL);
else /* right button -- rename */
(void) ns_parse_screen_key(TermWin.screen, NS_SCREEN_RENAME);
} else /* left button -- select */
(void) ns_screen_command(TermWin.screen, button->action.string);
} else /* not in screen-mode, use normal facilities */
if (prvs == 2) {
/* middle button -- kill */
(void) ns_rem_disp(TermWin.screen, n);
} else {
/* right button -- rename */
(void) ns_ren_disp(TermWin.screen, n, NULL);
}
} else {
/* left button -- select */
ns_go2_disp(TermWin.screen, n);
}
} else
#endif
/* not in screen-mode, use normal facilities */
tt_write((unsigned char *) button->action.string, strlen(button->action.string));
}
break;
@ -1138,6 +1147,7 @@ buttonbar_t *bbar_insert_button(buttonbar_t *bbar, button_t *button, int after,
} else {
int c = 0;
button_t *b = bbar->rbuttons;
do {
c++;
} while ((b = b->next));
@ -1154,11 +1164,12 @@ 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 {
button_t *b = bbar->buttons;
while (after-- > 0 && b->next)
b = b->next;
button->next = b->next;
@ -1173,6 +1184,7 @@ buttonbar_t *bbar_insert_button(buttonbar_t *bbar, button_t *button, int after,
if (!state) {
if (buttonbar) {
buttonbar_t *bar = buttonbar;
while (bar->next)
bar = bar->next;
bar->next = bbar;

@ -96,6 +96,9 @@ typedef struct buttonbar_struct {
/************ Variables ************/
extern buttonbar_t *buttonbar;
extern long bbar_total_h;
#ifdef ESCREEN
extern button_t *drag;
#endif
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN

@ -141,7 +141,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 */
@ -150,6 +150,7 @@ unsigned int num_fds = 0; /* number of file descriptors being used */
struct stat ttyfd_stat; /* original status of the tty we will use */
int refresh_count = 0, refresh_limit = 1, refresh_type = FAST_REFRESH;
unsigned char cmdbuf_base[CMD_BUF_SIZE], *cmdbuf_ptr, *cmdbuf_endp;
/* Addresses pasting large amounts of data
* code pinched from xterm
*/
@ -157,10 +158,12 @@ static char *v_buffer; /* pointer to physical buffer */
static char *v_bufstr = NULL; /* beginning of area to write */
static char *v_bufptr; /* end of area to write */
static char *v_bufend; /* end of physical buffer */
#ifdef USE_XIM
XIM xim_input_method = NULL;
XIC xim_input_context = NULL; /* input context */
static XIMStyle xim_input_style = 0;
# ifndef XSetIMValues
extern char *XSetIMValues(XIM im, ...);
# endif
@ -952,10 +955,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]) : (""));
@ -1416,7 +1419,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);
@ -1673,28 +1676,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));
@ -1760,6 +1763,7 @@ create_fontset(const char *font1, const char *font2)
#ifdef USE_XIM
static int xim_real_init(void);
# ifdef USE_X11R6_XIM
static void xim_destroy_cb(XIM xim, XPointer client_data, XPointer call_data);
static void xim_instantiate_cb(Display * display, XPointer client_data, XPointer call_data);
@ -1843,8 +1847,7 @@ xim_get_area(XRectangle * preedit_rect, XRectangle * status_rect, XRectangle * n
preedit_rect->x = needed_rect->width + (scrollbar_is_visible() && !(Options & Opt_scrollbar_right) ? (scrollbar_trough_width()) : 0);
preedit_rect->y = Height2Pixel(TermWin.nrow - 1);
preedit_rect->width =
Width2Pixel(TermWin.ncol + 1) - needed_rect->width + (!(Options & Opt_scrollbar_right) ? (scrollbar_trough_width()) : 0);
preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + (!(Options & Opt_scrollbar_right) ? (scrollbar_trough_width()) : 0);
preedit_rect->height = Height2Pixel(1);
status_rect->x = (scrollbar_is_visible() && !(Options & Opt_scrollbar_right)) ? (scrollbar_trough_width()) : 0;
@ -1995,9 +1998,7 @@ xim_real_init(void)
xim_set_size(&rect);
xim_get_position(&spot);
xim_set_color(&fg, &bg);
preedit_attr =
XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset,
NULL);
preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL);
} else if (xim_input_style & XIMPreeditArea) {
xim_set_color(&fg, &bg);
/* The necessary width of preedit area is unknown until create input context. */
@ -2270,12 +2271,14 @@ run_command(char **argv)
return (ptyfd);
}
#ifdef ESCREEN
/***************************************************************************/
/* Escreen: callbacks */
/***********************/
#ifdef ESCREEN
int
static int
set_scroll_x(void *xd, int x)
{
USE_VAR(xd);
@ -2283,7 +2286,7 @@ set_scroll_x(void *xd, int x)
return NS_FAIL;
}
int
static int
set_scroll_y(void *xd, int y)
{
USE_VAR(xd);
@ -2291,7 +2294,7 @@ set_scroll_y(void *xd, int y)
return NS_FAIL;
}
int
static int
set_scroll_w(void *xd, int w)
{
USE_VAR(xd);
@ -2299,7 +2302,7 @@ set_scroll_w(void *xd, int w)
return NS_FAIL;
}
int
static int
set_scroll_h(void *xd, int h)
{
USE_VAR(xd);
@ -2307,7 +2310,7 @@ set_scroll_h(void *xd, int h)
return NS_FAIL;
}
int
static int
redraw(void *xd)
{
USE_VAR(xd);
@ -2315,7 +2318,7 @@ redraw(void *xd)
return NS_FAIL;
}
int
static int
redraw_xywh(void *xd, int x, int y, int w, int h)
{
USE_VAR(xd);
@ -2323,8 +2326,7 @@ redraw_xywh(void *xd, int x, int y, int w, int h)
return NS_FAIL;
}
static button_t *
screen_button_create(char *text, char code)
static button_t *screen_button_create(char *text, char code)
{
button_t *b;
char p[3];
@ -2344,9 +2346,12 @@ screen_button_create(char *text, char code)
/* add a new screen display to button bar.
if our user's configured a bbar, we'll add to that,
otherwise, we'll create one. */
int
ins_disp(void *xd, int after, char *name)
otherwise, we'll create one.
xd address of the pointer to the buttonbar in question
after insert after which display?
name the display's name */
static int
ins_disp(void *xd, int after, int as, char *name)
{
buttonbar_t *bbar;
button_t *button;
@ -2357,12 +2362,10 @@ ins_disp(void *xd, int after, char *name)
bbar = *((buttonbar_t **) xd);
if (!(button = screen_button_create(name, '0' + after + 1))) {
if (!(button = screen_button_create(name, '0' + as))) {
return NS_FAIL;
}
D_ESCREEN(("%s after %d...\n", name, after));
if ((bbar = bbar_insert_button(bbar, button, after, FALSE))) {
*((buttonbar_t **) xd) = bbar;
return NS_SUCC;
@ -2372,7 +2375,8 @@ ins_disp(void *xd, int after, char *name)
return NS_FAIL;
}
# if 0
#if 0
/* add supa-dupa right buttons for screen-features.
if our user's configured a bbar, we'll add to that,
otherwise, we'll create one. */
@ -2388,9 +2392,9 @@ add_screen_ctl_button(buttonbar_t **xd, char *name, char key)
bbar = *xd;
if (!(button = screen_button_create(name, key))) {
if (!(button = screen_button_create(name, key)))
return NS_FAIL;
}
if ((bbar = bbar_insert_button(bbar, button, -1, TRUE))) {
*xd = bbar;
return NS_SUCC;
@ -2399,11 +2403,12 @@ add_screen_ctl_button(buttonbar_t **xd, char *name, char key)
button_free(button);
return NS_FAIL;
}
# endif
#endif
/* delete n'th button
n index of the button (not screen, not data -- the button) */
int
xd address of the pointer to the buttonbar in question
n index of the button (not screen, not data -- the button) */
static int
del_disp(void *xd, int n)
{
buttonbar_t *bbar = *((buttonbar_t **) xd);
@ -2413,16 +2418,6 @@ del_disp(void *xd, int n)
REQUIRE_RVAL(bbar, NS_FAIL);
REQUIRE_RVAL(bbar->buttons, NS_FAIL);
#if DEBUG >= DEBUG_ESCREEN
if (DEBUG_LEVEL >= DEBUG_ESCREEN) {
int c;
for (c = 0, b2 = bbar->buttons; b2; c++, b2 = b2->next) {
D_ESCREEN(("%02d: \"%s\"\n", c, b2->text));
}
}
#endif
b2 = button = bbar->buttons;
if (n == 0) {
bbar->buttons = bbar->buttons->next;
@ -2443,8 +2438,6 @@ del_disp(void *xd, int n)
}
}
D_ESCREEN(("deleting button %d (%s)...\n", bi, button->text));
button->next = NULL;
button_free(button);
@ -2454,12 +2447,12 @@ del_disp(void *xd, int n)
}
/* update the button-representation of a screen-display.
xd
xd address of the pointer to the buttonbar in question
n the button's index (in the list of buttons)
flags the new flags for the display (or -1 to ignore)
name the new name for the display (or NULL)
<- error code */
int
static int
upd_disp(void *xd, int n, int flags, char *name)
{
buttonbar_t *bbar = *((buttonbar_t **) xd);
@ -2484,20 +2477,49 @@ upd_disp(void *xd, int n, int flags, char *name)
return NS_SUCC;
}
/* expire all buttons
xd address of the pointer to the buttonbar in question
n how many buttons do we want to throw out (normally all of them)?
<- error code */
static int
expire_buttons(void *xd, int n)
{
buttonbar_t *bbar = *((buttonbar_t **) xd);
button_t *b, *p;
REQUIRE_RVAL(bbar, NS_FAIL);
if (n < 1) {
return NS_FAIL;
}
if ((b = bbar->buttons)) {
for (; n; n--) {
p = b;
b = b->next;
}
p->next = NULL;
button_free(bbar->buttons);
bbar->buttons = b;
}
return NS_SUCC;
}
/* display a status line the screen program sent us */
int
static int
err_msg(void *xd, int err, char *msg)
{
char *sc[] = { "Copy mode", "Bell in" };
char *sc[] = { "Copy mode", "Bell in", "Wuff, Wuff!!" };
int n, nsc = sizeof(sc) / sizeof(char *);
USE_VAR(xd);
USE_VAR(err);
/* there are certain things that would make sense if we were displaying
a status-line; they do not, however, warrant an alert-box, so we drop
them here. */
if (msg && *msg) {
USE_VAR(xd);
USE_VAR(err);
if (strlen(msg)) {
for (n = 0; n < nsc; n++) {
if (!strncmp(msg, sc[n], strlen(sc[n]))) {
break;
@ -2511,7 +2533,7 @@ err_msg(void *xd, int err, char *msg)
}
/* send text to the application (normally "screen") in the terminal */
int
static int
inp_text(void *xd, int id, char *txt)
{
USE_VAR(xd);
@ -2522,7 +2544,7 @@ inp_text(void *xd, int id, char *txt)
}
/* open a dialog */
int
static int
input_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (void *, char *, size_t, size_t))
{
switch (menu_dialog(xd, prompt, maxlen, retstr, inp_tab)) {
@ -2536,19 +2558,21 @@ input_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (
}
/* run a program (normally "screen") inside the terminal */
int
static int
exe_prg(void *xd, char **argv)
{
USE_VAR(xd);
return run_command(argv);
}
/********************* Azundris' toys ***************************/
/****** Azundris' playthings :-) ******/
#define DIRECT_MASK (~(RS_Cursor|RS_Select|RS_fontMask))
#define COLOUR_MASK (RS_fgMask|RS_bgMask)
#define DIRECT_SET_SCREEN(x,y,fg,bg) (screen.text[ys+y])[x]=fg; (screen.rend[ys+y])[x]=bg&DIRECT_MASK;
#define CLEAR (1<<16)
static void
direct_write_screen(int x, int y, char *fg, rend_t bg)
{
@ -2569,10 +2593,12 @@ bosconian(int n)
{
int x, y;
int ys = TermWin.saveLines - TermWin.view_start;
for (; n != 0; n--) {
for (y = 0; y < TermWin.nrow; y++) {
text_t *t = screen.text[ys + y];
rend_t *r = screen.rend[ys + y];
for (x = 0; x < TermWin.ncol; x++) {
t[x] = random() & 0xff;
r[x] = random() & COLOUR_MASK;
@ -2588,10 +2614,12 @@ unbosconian(void)
int x, y;
int ys = TermWin.saveLines - TermWin.view_start;
rend_t bg;
do {
bg = CLEAR;
for (y = 0; (bg == CLEAR) && y < TermWin.nrow; y++) {
rend_t *r = screen.rend[ys + y];
for (x = 0; (bg == CLEAR) && x < TermWin.ncol; x++) {
if (r[x] != CLEAR) {
bg = r[x];
@ -2602,6 +2630,7 @@ unbosconian(void)
for (y = 0; y < TermWin.nrow; y++) {
text_t *t = screen.text[ys + y];
rend_t *r = screen.rend[ys + y];
for (x = 0; x < TermWin.ncol; x++) {
if (r[x] == bg) {
r[x] = CLEAR;
@ -2613,12 +2642,11 @@ unbosconian(void)
}
} while (bg != CLEAR);
}
#undef DIRECT_MASK
#undef COLOUR_MASK
#undef DIRECT_SET_SCREEN
#define MATRIX_HI CLEAR
#define MATRIX_LO ((4<<8)|CLEAR)
static void
matrix(int n)
{
@ -2634,8 +2662,10 @@ matrix(int n)
}
MEMSET(s, 0, TermWin.ncol);
#define MATRIX_HI CLEAR
#define MATRIX_LO ((4<<8)|CLEAR)
for (; n != 0; n--) {
while (n--) {
for (x = 0; x < TermWin.ncol; x++) {
if (!(random() & 3)) {
if ((y = s[x])) {
@ -2684,7 +2714,8 @@ matrix(int n)
}
break;
default: t[x] = random() & 0xff; /* hold */
default:
t[x] = random() & 0xff; /* hold */
}
}
}
@ -2692,6 +2723,7 @@ matrix(int n)
}
FREE(s);
}
#undef MATRIX_HI
#undef MATRIX_LO
@ -2701,11 +2733,9 @@ waitstate(void *xd, int ms)
{
int y = 1;
time_t dur = (time_t) (ms / 1000);
#if 0
time_t fin = dur + time(NULL);
#endif
USE_VAR(xd);
if (!(random() & 7)) {
if (!(random() & 3)) {
matrix(31);
@ -2725,8 +2755,10 @@ waitstate(void *xd, int ms)
scr_refresh(FAST_REFRESH);
sleep(dur);
return 0;
}
#undef CLEAR
/* Set everything up for escreen mode */
@ -2745,6 +2777,7 @@ escreen_init(char **argv)
ns_register_red(efuns, redraw);
ns_register_rda(efuns, redraw_xywh);
ns_register_exb(efuns, expire_buttons);
ns_register_ins(efuns, ins_disp);
ns_register_del(efuns, del_disp);
@ -2767,7 +2800,7 @@ escreen_init(char **argv)
menuitem_t *i;
if (rs_delay >= 0) {
TermWin.screen->delay = rs_delay; /* more flexible ways later */
TermWin.screen->delay = rs_delay; /* more flexible ways later */
}
if ((m = menu_create(NS_MENU_TITLE))) {
char *sc[] = {
@ -2793,11 +2826,8 @@ escreen_init(char **argv)
int n, nsc = sizeof(sc) / sizeof(char *);
if (menu_list) {
for (n = 0; n < menu_list->nummenus; n++) { /* blend in w/ l&f */
for (n = 0; n < menu_list->nummenus; n++) { /* blend in w/ l&f */
if (menu_list->menus[n]->font) {
#ifdef NS_DEBUG
D_ESCREEN(("%d: %p\n", n, menu_list->menus[n]->font));
#endif
m->font = menu_list->menus[n]->font;
m->fwidth = menu_list->menus[n]->fwidth;
m->fheight = menu_list->menus[n]->fheight;
@ -2810,22 +2840,16 @@ escreen_init(char **argv)
}
for (n = 0; n < (nsc - 1); n += 2) {
if (!strcmp(sc[n], "-")) { /* separator */
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]))) {
} 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]);
# ifdef NS_DEBUG
{
char buf[64];
sprintf(buf, NS_PREFIX "escreen_menu: registered %s as", sc[n]);
ns_desc_string(i->action.string, buf);
}
# endif
menu_add_item(m, i);
}
}
@ -2846,32 +2870,31 @@ escreen_init(char **argv)
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++)
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);
}
}
}
/* add_screen_ctl_button(&buttonbar,"New",'c'); */
cmd_fd = TermWin.screen->fd;
} else {
return -1;
/* add_screen_ctl_button(&buttonbar,"New",'c'); */
return TermWin.screen->fd;
}
# undef ETERM_PREFIX
# undef ESCREEN_PREFIX
return cmd_fd;
return -1;
}
#endif
/* init_command() */
void
init_command(char **argv)
{
int (*command_func)(char **);
int (*command_func) (char **);
/* Use init function appropriate for how we were compiled. */
#ifdef ESCREEN
@ -2953,13 +2976,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;
@ -3064,8 +3087,26 @@ cmd_getc(void)
#endif
}
#ifdef ESCREEN
if (TermWin.screen_mode)
parse_screen_status_if_necessary();
if (TermWin.screen) {
switch (TermWin.screen->backend) {
case NS_MODE_NONE:
break;
case NS_MODE_NEGOTIATE:
# ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN:
parse_screen_status_if_necessary();
break;
# endif
# ifdef NS_HAVE_SCREAM
case NS_MODE_SCREAM:
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;
}
}
#endif
/* characters already read in */
@ -3075,7 +3116,7 @@ cmd_getc(void)
for (;;) {
v_doPending();
while (XPending(Xdisplay)) { /* process pending X events */
while (XPending(Xdisplay)) { /* process pending X events */
XEvent ev;
@ -3282,7 +3323,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;
@ -3321,8 +3362,7 @@ main_loop(void)
break;
}
}
D_SCREEN(("Adding %d lines (%d chars); str == %8p, cmdbuf_ptr == %8p, cmdbuf_endp == %8p\n",
nlines, cmdbuf_ptr - str, str, cmdbuf_ptr, cmdbuf_endp));
D_SCREEN(("Adding %d lines (%d chars); str == %8p, cmdbuf_ptr == %8p, cmdbuf_endp == %8p\n", nlines, cmdbuf_ptr - str, str, cmdbuf_ptr, cmdbuf_endp));
scr_add_lines(str, nlines, (cmdbuf_ptr - str));
} else {
switch (ch) {
@ -3397,7 +3437,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 */
@ -3410,7 +3450,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) {
@ -3420,13 +3460,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;
}
}
@ -3452,13 +3492,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;
@ -3471,7 +3511,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 */
}
}
}

@ -238,6 +238,7 @@ if (test) PrivateModes |= (bit); else PrivateModes &= ~(bit);} while (0)
#endif
#define VT100_ANS "\033[?1;2c" /* vt100 answerback */
#define LINUX_ANS "\033[?6;5c" /* linux answerback */
#ifndef ESCZ_ANSWER
# define ESCZ_ANSWER VT100_ANS /* obsolete ANSI ESC[c */
#endif
@ -359,6 +360,7 @@ extern void init_locale(void);
#else
# define init_locale() ((void)0)
#endif
extern int escreen_init(char **);
extern int run_command(char **);
extern void init_command(char **);
extern void tt_winsize(int);

@ -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.