Sat Jun 8 12:46:44 2002 Michael Jennings (mej)
My own Escreen updates, primarily for devoting a dedicated buttonbar to Escreen's use. This keeps Escreen from trodding on your existing buttonbar, if you have one. It's hard-coded to bottom-dock right now; we'll look at configuration later. :-) SVN revision: 6308
This commit is contained in:
parent
92937f46a7
commit
b8c1785c39
|
@ -4691,3 +4691,10 @@ Sat Jun 8 11:41:37 2002 Michael Jennings (mej)
|
|||
|
||||
Escreen update with Twin support from Azundris <scream@azundris.com>.
|
||||
----------------------------------------------------------------------
|
||||
Sat Jun 8 12:46:44 2002 Michael Jennings (mej)
|
||||
|
||||
My own Escreen updates, primarily for devoting a dedicated buttonbar
|
||||
to Escreen's use. This keeps Escreen from trodding on your existing
|
||||
buttonbar, if you have one. It's hard-coded to bottom-dock right
|
||||
now; we'll look at configuration later. :-)
|
||||
----------------------------------------------------------------------
|
||||
|
|
|
@ -14,4 +14,7 @@ for i in *.c src/*.c utils/*.c ; do
|
|||
fi
|
||||
done
|
||||
|
||||
perl -p -i.bak -e 's/(\w+)_t (\*+)\s+/$1_t $2/g;' */*.[ch]
|
||||
perl -p -i.bak -e '
|
||||
s/(\w+)_t (\*+)\s+/$1_t $2/g;
|
||||
s/^(\w+_t\s+\**)\s*(\w+)\s*(\([^\)]+\))\s*$/$1\n$2$3\n/g;
|
||||
' */*.[ch]
|
||||
|
|
271
src/buttons.c
271
src/buttons.c
|
@ -228,6 +228,7 @@ bbar_handle_button_press(event_t *ev)
|
|||
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &buttonbar->event_data), 0);
|
||||
|
||||
if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) {
|
||||
D_EVENTS((" -> No buttonbar found for this window.\n"));
|
||||
return 0;
|
||||
}
|
||||
if (bbar->current) {
|
||||
|
@ -249,15 +250,74 @@ bbar_handle_button_release(event_t *ev)
|
|||
int unused_root_x, unused_root_y;
|
||||
unsigned int unused_mask;
|
||||
|
||||
D_EVENTS(("bbar_handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
|
||||
|
||||
#ifdef ESCREEN
|
||||
if (drag && TermWin.screen && TermWin.screen->backend && TermWin.screen->userdef) {
|
||||
buttonbar_t *bbar = (buttonbar_t *) TermWin.screen->userdef;
|
||||
button_t *b;
|
||||
int fm = 0, to = 0;
|
||||
|
||||
D_ESCREEN(("Checking for dragged button.\n"));
|
||||
if (bbar && (b = bbar->buttons) && (drag != bbar->current)) {
|
||||
while (b && (b != drag)) {
|
||||
b = b->next;
|
||||
fm++;
|
||||
}
|
||||
if (!b) {
|
||||
D_ESCREEN((" -> Dragged button is not on the Escreen buttonbar.\n"));
|
||||
drag = NULL;
|
||||
} else {
|
||||
|
||||
if (bbar->current) {
|
||||
b = bbar->buttons;
|
||||
while (b && (b != bbar->current)) {
|
||||
b = b->next;
|
||||
to++;
|
||||
}
|
||||
if (!b) {
|
||||
D_ESCREEN((" -> Target button is not on the Escreen buttonbar.\n"));
|
||||
drag = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
drag = NULL;
|
||||
}
|
||||
|
||||
if (drag) {
|
||||
if (!bbar->current) {
|
||||
char *u = ns_get_url(TermWin.screen, fm);
|
||||
|
||||
D_ESCREEN(("Button for display %d dragged off.\n", fm));
|
||||
if (u) {
|
||||
char *c;
|
||||
size_t l = strlen(orig_argv0) + strlen(u) + 7;
|
||||
|
||||
if ((c = MALLOC(l))) {
|
||||
snprintf(c, l, "%s%s -U %s", ((orig_argv0[0] == '/') || ((orig_argv0[0] == '.') && (orig_argv0[1] == '/'))) ? "" : "./", orig_argv0, u);
|
||||
D_ESCREEN(("(experimental) creating other frame using \"%s\"\n", c));
|
||||
(void) ns_run(TermWin.screen->efuns, c);
|
||||
FREE(c);
|
||||
}
|
||||
FREE(u);
|
||||
}
|
||||
return 1;
|
||||
} else if (buttonbar->current != drag) {
|
||||
D_ESCREEN(("Button for display %d dragged to display %d\n", fm, to));
|
||||
ns_mov_disp(TermWin.screen, fm, to);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
D_ESCREEN(("No drag detected. Proceeding with normal handling.\n"));
|
||||
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);
|
||||
|
||||
if ((bbar = find_bbar_by_window(ev->xany.window)) == NULL) {
|
||||
D_EVENTS((" -> No buttonbar found for this window.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -265,14 +325,17 @@ bbar_handle_button_release(event_t *ev)
|
|||
|
||||
b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
|
||||
if (b) {
|
||||
D_EVENTS(("Event in buttonbar %8p, button %8p (%s)\n", bbar, b, NONULL(b->text)));
|
||||
if (bbar->current && (b != bbar->current)) {
|
||||
D_EVENTS(("Current button %8p (%s) doesn't match event button %8p (%s)\n", bbar->current, NONULL(bbar->current->text), b, NONULL(b->text)));
|
||||
bbar_deselect_button(bbar, bbar->current);
|
||||
} else {
|
||||
bbar_select_button(bbar, b);
|
||||
button_check_action(bbar, b, 0, ev->xbutton.time);
|
||||
}
|
||||
} else {
|
||||
D_EVENTS(("Event in buttonbar %8p but no button.\n", bbar));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -347,6 +410,7 @@ bbar_add(buttonbar_t *bbar)
|
|||
}
|
||||
bbar->next = NULL;
|
||||
bbar_reset_total_height();
|
||||
event_data_add_mywin(&buttonbar->event_data, bbar->win);
|
||||
}
|
||||
|
||||
unsigned short
|
||||
|
@ -372,7 +436,7 @@ bbar_calc_height(buttonbar_t *bbar)
|
|||
bord = NULL;
|
||||
}
|
||||
|
||||
bbar->h = bbar->fascent + bbar->fdescent + 1;
|
||||
bbar->h = bbar->fheight + 1;
|
||||
if (bord) {
|
||||
bbar->h += bord->top + bord->bottom;
|
||||
}
|
||||
|
@ -554,6 +618,8 @@ bbar_add_button(buttonbar_t *bbar, button_t *button)
|
|||
|
||||
D_BBAR(("bbar_add_button(%8p, %8p): Adding button \"%s\".\n", bbar, button, button->text));
|
||||
|
||||
ASSERT(bbar != NULL);
|
||||
|
||||
if (bbar->buttons) {
|
||||
for (b = bbar->buttons; b->next; b = b->next);
|
||||
b->next = button;
|
||||
|
@ -604,6 +670,7 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
|
|||
bbar_reset_total_height();
|
||||
D_BBAR(("Font is \"%s\" (0x%08x). New dimensions are %d/%d/%d\n", NONULL(fontname), font, bbar->fwidth, bbar->fheight, bbar->h));
|
||||
|
||||
bbar_calc_height(bbar);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -787,6 +854,10 @@ bbar_deselect_button(buttonbar_t *bbar, button_t *button)
|
|||
void
|
||||
bbar_click_button(buttonbar_t *bbar, button_t *button)
|
||||
{
|
||||
REQUIRE(button != NULL);
|
||||
|
||||
D_BBAR(("Drawing clicked button %8p (%s) on buttonbar %8p\n", button, NONULL(button->text), bbar));
|
||||
|
||||
bbar->current = 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);
|
||||
|
@ -811,71 +882,97 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
|
|||
{
|
||||
static unsigned char prvs = 0;
|
||||
|
||||
REQUIRE(button != NULL);
|
||||
|
||||
D_BBAR(("Checking action for button %8p (%s) on buttonbar %8p, press %d, prvs %d, time %lu\n", button, NONULL(button->text), bbar, (int) press, (int) prvs, (unsigned long) t));
|
||||
|
||||
switch (button->type) {
|
||||
case ACTION_MENU:
|
||||
D_BBAR((" -> Menu button found.\n"));
|
||||
if (press) {
|
||||
menu_invoke(button->x, button->y + button->h, bbar->win, button->action.menu, t);
|
||||
}
|
||||
break;
|
||||
case ACTION_STRING:
|
||||
D_BBAR((" -> String button found.\n"));
|
||||
if (!press) {
|
||||
size_t len;
|
||||
|
||||
len = strlen(button->action.string);
|
||||
D_BBAR(("Writing \"%s\" to command buffer.\n", safe_print_string(button->action.string, len)));
|
||||
cmd_write((unsigned char *) button->action.string, strlen(button->action.string));
|
||||
}
|
||||
break;
|
||||
case ACTION_ECHO:
|
||||
D_BBAR((" -> Echo button found.\n"));
|
||||
if (!press) {
|
||||
size_t len;
|
||||
|
||||
#ifdef ESCREEN
|
||||
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) {
|
||||
/* find active disp */
|
||||
for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next);
|
||||
if (b && (b->flags & NS_SCREAM_BUTTON)) {
|
||||
D_ESCREEN(("Looking for active display, n == %d, press == %d, prvs == %d\n", n, (int) press, (int) prvs));
|
||||
if (prvs != 1) {
|
||||
/* find active disp */
|
||||
for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next);
|
||||
|
||||
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;
|
||||
if (b && b != button) {
|
||||
D_ESCREEN((" -> Found button %8p (%s) for current display.\n", b, NONULL(b->text)));
|
||||
|
||||
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));
|
||||
/* 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;
|
||||
|
||||
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));
|
||||
}
|
||||
ns_go2_disp(TermWin.screen, n);
|
||||
}
|
||||
|
||||
if (prvs == 2) {
|
||||
/* middle button -- kill */
|
||||
(void) ns_rem_disp(TermWin.screen, n, TRUE);
|
||||
} else {
|
||||
/* right button -- rename */
|
||||
(void) ns_ren_disp(TermWin.screen, n, NULL);
|
||||
}
|
||||
} else {
|
||||
/* left button -- select */
|
||||
ns_go2_disp(TermWin.screen, n);
|
||||
}
|
||||
|
||||
if (prvs == 2) {
|
||||
/* middle button -- kill */
|
||||
(void) ns_rem_disp(TermWin.screen, n, TRUE);
|
||||
} else {
|
||||
/* right button -- rename */
|
||||
(void) ns_ren_disp(TermWin.screen, n, NULL);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
/* left button -- select */
|
||||
ns_go2_disp(TermWin.screen, n);
|
||||
D_ESCREEN(("Non-screen button, handling normally.\n"));
|
||||
}
|
||||
} else
|
||||
}
|
||||
#endif
|
||||
/* not in screen-mode, use normal facilities */
|
||||
tt_write((unsigned char *) button->action.string, strlen(button->action.string));
|
||||
|
||||
/* not in screen-mode, use normal facilities */
|
||||
len = strlen(button->action.string);
|
||||
D_BBAR(("Writing \"%s\" to subprocess.\n", safe_print_string(button->action.string, len)));
|
||||
tt_write((unsigned char *) button->action.string, len);
|
||||
}
|
||||
break;
|
||||
case ACTION_SCRIPT:
|
||||
D_BBAR((" -> Script button found.\n"));
|
||||
if (!press) {
|
||||
script_parse((char *) button->action.script);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
D_BBAR((" -> Unknown button type 0x%08x?!\n", button->type));
|
||||
break;
|
||||
}
|
||||
prvs = press;
|
||||
|
@ -918,9 +1015,9 @@ bbar_resize(buttonbar_t *bbar, int w)
|
|||
{
|
||||
D_BBAR(("bbar_resize(%8p, %d) called.\n", bbar, w));
|
||||
if ((w >= 0) && !bbar_is_visible(bbar)) {
|
||||
D_BBAR((" -> Buttonbar is not visible, returning."));
|
||||
return;
|
||||
}
|
||||
/*bbar_redock(bbar); FIXME: We can't do this here. Did we ever actually need it? */
|
||||
if (w < 0) {
|
||||
bbar_calc_button_sizes(bbar);
|
||||
bbar_calc_height(bbar);
|
||||
|
@ -989,13 +1086,14 @@ bbar_draw(buttonbar_t *bbar, unsigned char image_state, unsigned char force_mode
|
|||
#ifdef ESCREEN
|
||||
GC gc; /* evil temporary hack */
|
||||
XGCValues gcvalue;
|
||||
int f = button->flags & ~NS_SCREAM_BUTTON;
|
||||
|
||||
gcvalue.foreground = PixColors[button->flags + 2];
|
||||
gcvalue.foreground = PixColors[f + 2];
|
||||
gcvalue.font = bbar->font->fid;
|
||||
|
||||
if (button->flags && (gc = LIBAST_X_CREATE_GC(GCForeground | GCFont, &gcvalue))) {
|
||||
if (f && (gc = LIBAST_X_CREATE_GC(GCForeground | GCFont, &gcvalue))) {
|
||||
draw_string(bbar, bbar->bg, gc, button->text_x, button->text_y, button->text, button->len);
|
||||
XFreeGC(Xdisplay, gc);
|
||||
LIBAST_X_FREE_GC(gc);
|
||||
} else
|
||||
#endif
|
||||
draw_string(bbar, bbar->bg, bbar->gc, button->text_x, button->text_y, button->text, button->len);
|
||||
|
@ -1084,7 +1182,7 @@ bbar_calc_total_height(void)
|
|||
bbar_total_h += bbar->h;
|
||||
}
|
||||
}
|
||||
D_BBAR(("Returning %d\n", bbar_total_h));
|
||||
D_BBAR(("Height of all visible buttonbars: %lu\n", bbar_total_h));
|
||||
return bbar_total_h;
|
||||
}
|
||||
|
||||
|
@ -1099,107 +1197,16 @@ bbar_calc_docked_height(register unsigned char dock_flag)
|
|||
h += bbar->h;
|
||||
}
|
||||
}
|
||||
D_BBAR(("Returning %d\n", h));
|
||||
D_BBAR(("Height of buttonbars with dock state 0x%02x: %lu\n", (unsigned) dock_flag, h));
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* redraw a button bar */
|
||||
void
|
||||
bbar_redraw(buttonbar_t *bbar)
|
||||
{
|
||||
bbar_calc_height(bbar);
|
||||
bbar_calc_button_sizes(bbar);
|
||||
bbar_calc_button_positions(bbar);
|
||||
bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* insert a button to the given bar, at the given position.
|
||||
create a new bar if required.
|
||||
bar the bar
|
||||
button the button
|
||||
after insert after this button (-1 for before first button)
|
||||
addright add to rbuttons instead of buttons
|
||||
<- NULL, or the bar */
|
||||
|
||||
buttonbar_t *bbar_insert_button(buttonbar_t *bbar, button_t *button, int after, int addright)
|
||||
{
|
||||
int state = 1;
|
||||
|
||||
if (!bbar) {
|
||||
if (!(bbar = bbar_create())) {
|
||||
fprintf(stderr, "ins_disp: failed to create button-bar...\n");
|
||||
return NULL;
|
||||
} else {
|
||||
bbar->next = NULL;
|
||||
bbar_set_font(bbar, "-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1");
|
||||
bbar_set_docked(bbar, BBAR_DOCKED_TOP);
|
||||
}
|
||||
state = 0;
|
||||
}
|
||||
|
||||
if (addright) { /* add to rbuttons */
|
||||
if (!bbar->rbuttons) { /* first button */
|
||||
button->next = NULL;
|
||||
bbar->rbuttons = button;
|
||||
} else {
|
||||
int c = 0;
|
||||
button_t *b = bbar->rbuttons;
|
||||
|
||||
do {
|
||||
c++;
|
||||
} while ((b = b->next));
|
||||
if (after >= (c - 1)) {
|
||||
button->next = bbar->rbuttons;
|
||||
bbar->rbuttons = button;
|
||||
} else {
|
||||
b = bbar->rbuttons;
|
||||
after = c - after - 2;
|
||||
while (after-- > 0 && b->next)
|
||||
b = b->next;
|
||||
button->next = b->next;
|
||||
b->next = button;
|
||||
}
|
||||
}
|
||||
} else { /* add to buttons */
|
||||
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;
|
||||
b->next = button;
|
||||
}
|
||||
}
|
||||
|
||||
bbar->current = button;
|
||||
|
||||
/* add to list of bbars so bbar_event_init_dispatcher() won't break */
|
||||
|
||||
if (!state) {
|
||||
if (buttonbar) {
|
||||
buttonbar_t *bar = buttonbar;
|
||||
|
||||
while (bar->next)
|
||||
bar = bar->next;
|
||||
bar->next = bbar;
|
||||
} else
|
||||
buttonbar = bbar;
|
||||
|
||||
bbar_init(bbar, TermWin.width);
|
||||
bbar_add(bbar);
|
||||
}
|
||||
|
||||
bbar_redraw(bbar);
|
||||
|
||||
if (!state) {
|
||||
parent_resize();
|
||||
}
|
||||
|
||||
return bbar;
|
||||
}
|
||||
|
|
271
src/command.c
271
src/command.c
|
@ -2179,6 +2179,8 @@ run_command(char **argv)
|
|||
unsetenv("COLUMNS");
|
||||
unsetenv("TERMCAP");
|
||||
#endif
|
||||
DEBUG_LEVEL = 0;
|
||||
|
||||
get_tty();
|
||||
SET_TTYMODE(0, &tio);
|
||||
|
||||
|
@ -2343,6 +2345,7 @@ static button_t *screen_button_create(char *text, char code)
|
|||
p[1] = code;
|
||||
p[2] = '\0';
|
||||
button_set_action(b, ACTION_ECHO, p);
|
||||
b->flags |= NS_SCREAM_BUTTON;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
@ -2356,26 +2359,20 @@ static button_t *screen_button_create(char *text, char code)
|
|||
static int
|
||||
ins_disp(void *xd, int after, int as, char *name)
|
||||
{
|
||||
buttonbar_t *bbar;
|
||||
buttonbar_t *bbar = (buttonbar_t *) xd;
|
||||
button_t *button;
|
||||
|
||||
USE_VAR(after);
|
||||
REQUIRE_RVAL(xd, NS_FAIL);
|
||||
REQUIRE_RVAL(name, NS_FAIL);
|
||||
REQUIRE_RVAL(*name, NS_FAIL);
|
||||
|
||||
bbar = *((buttonbar_t **) xd);
|
||||
|
||||
if (!(button = screen_button_create(name, '0' + as))) {
|
||||
return NS_FAIL;
|
||||
}
|
||||
|
||||
if ((bbar = bbar_insert_button(bbar, button, after, FALSE))) {
|
||||
*((buttonbar_t **) xd) = bbar;
|
||||
return NS_SUCC;
|
||||
}
|
||||
|
||||
button_free(button);
|
||||
return NS_FAIL;
|
||||
bbar_add_button(bbar, button);
|
||||
return NS_SUCC;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -2384,27 +2381,19 @@ ins_disp(void *xd, int after, int as, char *name)
|
|||
if our user's configured a bbar, we'll add to that,
|
||||
otherwise, we'll create one. */
|
||||
static int
|
||||
add_screen_ctl_button(buttonbar_t **xd, char *name, char key)
|
||||
add_screen_ctl_button(buttonbar_t *bbar, char *name, char key)
|
||||
{
|
||||
buttonbar_t *bbar;
|
||||
button_t *button;
|
||||
|
||||
REQUIRE_RVAL(xd, NS_FAIL);
|
||||
REQUIRE_RVAL(bbar, NS_FAIL);
|
||||
REQUIRE_RVAL(name, NS_FAIL);
|
||||
REQUIRE_RVAL(*name, NS_FAIL);
|
||||
|
||||
bbar = *xd;
|
||||
|
||||
if (!(button = screen_button_create(name, key)))
|
||||
return NS_FAIL;
|
||||
|
||||
if ((bbar = bbar_insert_button(bbar, button, -1, TRUE))) {
|
||||
*xd = bbar;
|
||||
return NS_SUCC;
|
||||
}
|
||||
|
||||
button_free(button);
|
||||
return NS_FAIL;
|
||||
bbar_add_button(bbar, button);
|
||||
return NS_SUCC;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2414,7 +2403,7 @@ add_screen_ctl_button(buttonbar_t **xd, char *name, char key)
|
|||
static int
|
||||
del_disp(void *xd, int n)
|
||||
{
|
||||
buttonbar_t *bbar = *((buttonbar_t **) xd);
|
||||
buttonbar_t *bbar = (buttonbar_t *) xd;
|
||||
button_t *button, *b2;
|
||||
int bi = n;
|
||||
|
||||
|
@ -2458,7 +2447,7 @@ del_disp(void *xd, int n)
|
|||
static int
|
||||
upd_disp(void *xd, int n, int flags, char *name)
|
||||
{
|
||||
buttonbar_t *bbar = *((buttonbar_t **) xd);
|
||||
buttonbar_t *bbar = (buttonbar_t *) xd;
|
||||
button_t *button;
|
||||
|
||||
REQUIRE_RVAL(bbar, NS_FAIL);
|
||||
|
@ -2472,7 +2461,7 @@ upd_disp(void *xd, int n, int flags, char *name)
|
|||
}
|
||||
|
||||
if (flags >= 0) {
|
||||
button->flags = flags;
|
||||
button->flags = (flags | NS_SCREAM_BUTTON);
|
||||
}
|
||||
|
||||
bbar_redraw(bbar);
|
||||
|
@ -2487,7 +2476,7 @@ upd_disp(void *xd, int n, int flags, char *name)
|
|||
static int
|
||||
expire_buttons(void *xd, int n)
|
||||
{
|
||||
buttonbar_t *bbar = *((buttonbar_t **) xd);
|
||||
buttonbar_t *bbar = (buttonbar_t *) xd;
|
||||
button_t *b, *p;
|
||||
|
||||
REQUIRE_RVAL(bbar, NS_FAIL);
|
||||
|
@ -2762,105 +2751,12 @@ waitstate(void *xd, int ms)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
make_escreen_menu(void)
|
||||
static _ns_efuns *
|
||||
escreen_reg_funcs(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
|
||||
escreen_init(char **argv)
|
||||
{
|
||||
int ns_err;
|
||||
_ns_efuns *efuns;
|
||||
|
||||
/* Register functions */
|
||||
efuns = ns_new_efuns();
|
||||
|
||||
ns_register_ssx(efuns, set_scroll_x);
|
||||
|
@ -2885,17 +2781,132 @@ escreen_init(char **argv)
|
|||
|
||||
ns_register_fun(efuns, waitstate);
|
||||
|
||||
return efuns;
|
||||
}
|
||||
|
||||
static int
|
||||
make_escreen_menu(buttonbar_t *bbar)
|
||||
{
|
||||
button_t *button;
|
||||
menu_t *m;
|
||||
menuitem_t *i;
|
||||
|
||||
if ((m = menu_create(NS_MENU_TITLE))) {
|
||||
char *sc[] = {
|
||||
/* display functions */
|
||||
"New", "es_display(new)", /* \x01:screen\r */
|
||||
"New (w/ name)...", "es_display(new,ask)",
|
||||
"Rename...", "es_display(name,ask)",
|
||||
"Backlog...", "es_display(backlog)",
|
||||
"Monitor", "es_display(monitor)",
|
||||
"Close", "es_display(close)",
|
||||
"-", "",
|
||||
/* region functions */
|
||||
"Split", "es_region(new)",
|
||||
"Unsplit", "es_region(full)",
|
||||
"Prev region", "es_region(prev)", /* NS_SCREEN_PRVS_REG */
|
||||
"Next region", "es_region(next)",
|
||||
"Kill region", "es_region(kill)",
|
||||
"-", "",
|
||||
/* screen functions */
|
||||
"Reset", "es_reset",
|
||||
"Statement", "es_statement",
|
||||
"-", ""
|
||||
};
|
||||
int n, nsc = sizeof(sc) / sizeof(char *);
|
||||
int j, k = menu_list ? menu_list->nummenus : 0;
|
||||
|
||||
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]))) {
|
||||
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);
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
if ((button = button_create(NS_MENU_TITLE))) {
|
||||
bbar_add_rbutton(bbar, button);
|
||||
button_set_action(button, ACTION_MENU, NS_MENU_TITLE);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set everything up for escreen mode */
|
||||
int
|
||||
escreen_init(char **argv)
|
||||
{
|
||||
int ns_err;
|
||||
_ns_efuns *efuns;
|
||||
buttonbar_t *bbar;
|
||||
|
||||
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))) {
|
||||
if (rs_delay >= 0) {
|
||||
TermWin.screen->delay = rs_delay; /* more flexible ways later */
|
||||
}
|
||||
make_escreen_menu();
|
||||
/* add_screen_ctl_button(&buttonbar,"New",'c'); */
|
||||
return TermWin.screen->fd;
|
||||
}
|
||||
return -1;
|
||||
|
||||
efuns = escreen_reg_funcs();
|
||||
|
||||
/* Create buttonbar for Escreen's use. */
|
||||
if ((bbar = bbar_create()) == NULL) {
|
||||
if (buttonbar != NULL) {
|
||||
bbar = buttonbar;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
bbar_set_font(bbar, "-*-helvetica-medium-r-normal--10-*-*-*-p-*-iso8859-1");
|
||||
bbar_init(bbar, TermWin.width);
|
||||
bbar_add(bbar);
|
||||
}
|
||||
|
||||
if ((TermWin.screen = ns_attach_by_URL(rs_url, rs_hop, &efuns, &ns_err, bbar)) == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (rs_delay >= 0) {
|
||||
TermWin.screen->delay = rs_delay; /* more flexible ways later */
|
||||
}
|
||||
|
||||
make_escreen_menu(bbar);
|
||||
|
||||
bbar_set_docked(bbar, BBAR_DOCKED_BOTTOM);
|
||||
bbar_set_visible(bbar, 0);
|
||||
bbar_show(bbar, 1);
|
||||
parent_resize();
|
||||
|
||||
/* add_screen_ctl_button(bbar,"New",'c'); */
|
||||
return TermWin.screen->fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
57
src/events.c
57
src/events.c
|
@ -734,65 +734,8 @@ handle_button_press(event_t *ev)
|
|||
unsigned char
|
||||
handle_button_release(event_t *ev)
|
||||
{
|
||||
|
||||
D_EVENTS(("handle_button_release(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
|
||||
|
||||
#ifdef ESCREEN
|
||||
if (!XEVENT_IS_MYWIN(ev, &primary_data) && drag && TermWin.screen && TermWin.screen->backend && TermWin.screen->userdef) {
|
||||
buttonbar_t *bbar = *((buttonbar_t **) (TermWin.screen->userdef));
|
||||
button_t *b;
|
||||
int fm = 0, to = 0;
|
||||
|
||||
if (!bbar || !(b = bbar->buttons)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (b && (b != drag)) {
|
||||
b = b->next;
|
||||
fm++;
|
||||
}
|
||||
if (!b) {
|
||||
/* dragged button is not on the bar with our displays on */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bbar->current) {
|
||||
b = bbar->buttons;
|
||||
while (b && (b != bbar->current)) {
|
||||
b = b->next;
|
||||
to++;
|
||||
}
|
||||
if (!b) {
|
||||
/* dragged-to button is not on the bar with our displays */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bbar->current) {
|
||||
/* tab torn off */
|
||||
char *u = ns_get_url(TermWin.screen, fm);
|
||||
|
||||
if (u) {
|
||||
char *c;
|
||||
size_t l = strlen(orig_argv0) + strlen(u) + 7;
|
||||
|
||||
if ((c = MALLOC(l))) {
|
||||
snprintf(c, l, "%s%s -U %s", ((orig_argv0[0] == '/') || ((orig_argv0[0] == '.') && (orig_argv0[1] == '/'))) ? "" : "./", orig_argv0, u);
|
||||
D_ESCREEN(("(experimental) creating other frame using \"%s\"\n", c));
|
||||
(void) ns_run(TermWin.screen->efuns, c);
|
||||
FREE(c);
|
||||
}
|
||||
FREE(u);
|
||||
}
|
||||
return 1;
|
||||
} else if (buttonbar->current != drag) {
|
||||
/* tab "moved" */
|
||||
ns_mov_disp(TermWin.screen, fm, to);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (button_state.ignore_release == 1) {
|
||||
button_state.ignore_release = 0;
|
||||
return 0;
|
||||
|
|
75
src/menus.c
75
src/menus.c
|
@ -410,7 +410,8 @@ menu_dispatch_event(event_t *ev)
|
|||
return (0);
|
||||
}
|
||||
|
||||
menulist_t *menulist_add_menu(menulist_t *list, menu_t *menu)
|
||||
menulist_t *
|
||||
menulist_add_menu(menulist_t *list, menu_t *menu)
|
||||
{
|
||||
ASSERT_RVAL(menu != NULL, list);
|
||||
|
||||
|
@ -442,7 +443,8 @@ menulist_clear(menulist_t *list)
|
|||
FREE(list);
|
||||
}
|
||||
|
||||
menu_t *menu_create(char *title)
|
||||
menu_t *
|
||||
menu_create(char *title)
|
||||
{
|
||||
menu_t *menu;
|
||||
static Cursor cursor;
|
||||
|
@ -594,7 +596,8 @@ menu_is_child(menu_t *menu, menu_t *submenu)
|
|||
return 0;
|
||||
}
|
||||
|
||||
menu_t *find_menu_by_title(menulist_t *list, char *title)
|
||||
menu_t *
|
||||
find_menu_by_title(menulist_t *list, char *title)
|
||||
{
|
||||
register unsigned char i;
|
||||
|
||||
|
@ -608,7 +611,8 @@ menu_t *find_menu_by_title(menulist_t *list, char *title)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
menu_t *find_menu_by_window(menulist_t *list, Window win)
|
||||
menu_t *
|
||||
find_menu_by_window(menulist_t *list, Window win)
|
||||
{
|
||||
register unsigned char i;
|
||||
|
||||
|
@ -622,7 +626,8 @@ menu_t *find_menu_by_window(menulist_t *list, Window win)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
menuitem_t *find_item_by_coords(menu_t *menu, int x, int y)
|
||||
menuitem_t *
|
||||
find_item_by_coords(menu_t *menu, int x, int y)
|
||||
{
|
||||
register unsigned char i;
|
||||
register menuitem_t *item;
|
||||
|
@ -692,7 +697,8 @@ menuitem_change_current(menuitem_t *item)
|
|||
}
|
||||
}
|
||||
|
||||
menuitem_t *menuitem_create(char *text)
|
||||
menuitem_t *
|
||||
menuitem_create(char *text)
|
||||
{
|
||||
menuitem_t *menuitem;
|
||||
|
||||
|
@ -968,10 +974,6 @@ menu_draw(menu_t *menu)
|
|||
{
|
||||
register unsigned short i, len;
|
||||
unsigned long width, height;
|
||||
|
||||
#if 0
|
||||
char *safeaction;
|
||||
#endif
|
||||
unsigned short str_x, str_y;
|
||||
XGCValues gcvalue;
|
||||
int ascent, descent, direction, dx, dy;
|
||||
|
@ -1134,23 +1136,6 @@ menu_draw(menu_t *menu)
|
|||
item->x + item->w - 3 * MENU_HGAP, item->y + (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, DRAW_ARROW_RIGHT);
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case MENUITEM_STRING:
|
||||
safeaction = STRDUP(item->action.string);
|
||||
safe_str(safeaction, strlen(safeaction));
|
||||
D_MENU((" Item %hu: %s (string %s)\n", i, item->text, safeaction));
|
||||
FREE(safeaction);
|
||||
break;
|
||||
case MENUITEM_ECHO:
|
||||
safeaction = STRDUP(item->action.string);
|
||||
safe_str(safeaction, strlen(safeaction));
|
||||
D_MENU((" Item %hu: %s (echo %s)\n", i, item->text, safeaction));
|
||||
FREE(safeaction);
|
||||
break;
|
||||
default:
|
||||
fatal_error("Internal Program Error: Unknown menuitem type: %u\n", item->type);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1201,30 +1186,18 @@ menu_action(menuitem_t *item)
|
|||
cmd_write((unsigned char *) item->action.string, strlen(item->action.string));
|
||||
break;
|
||||
case MENUITEM_ECHO:
|
||||
case MENUITEM_LITERAL:
|
||||
#ifdef ESCREEN
|
||||
if (TermWin.screen && TermWin.screen->backend) {
|
||||
/* translate escapes */
|
||||
switch (TermWin.screen->backend) {
|
||||
# ifdef NS_HAVE_SCREEN
|
||||
case NS_MODE_SCREEN:
|
||||
ns_parse_screen_interactive(TermWin.screen, item->action.string);
|
||||
break;
|
||||
# endif
|
||||
default:
|
||||
tt_write((unsigned char *) item->action.string, strlen(item->action.string));
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
tt_write((unsigned char *) item->action.string, strlen(item->action.string));
|
||||
break;
|
||||
case MENUITEM_LITERAL:
|
||||
#ifdef ESCREEN
|
||||
if (TermWin.screen) {
|
||||
/* translate escapes */
|
||||
switch (TermWin.screen->backend) {
|
||||
# ifdef NS_HAVE_SCREEN
|
||||
case NS_MODE_SCREEN:
|
||||
(void) ns_screen_command(TermWin.screen, item->action.string);
|
||||
if (item->type == MENUITEM_ECHO) {
|
||||
ns_parse_screen_interactive(TermWin.screen, item->action.string);
|
||||
} else {
|
||||
ns_screen_command(TermWin.screen, item->action.string);
|
||||
}
|
||||
break;
|
||||
# endif
|
||||
default:
|
||||
|
@ -1261,7 +1234,6 @@ menu_invoke(int x, int y, Window win, menu_t *menu, Time timestamp)
|
|||
XTranslateCoordinates(Xdisplay, win, Xroot, x, y, &root_x, &root_y, &unused);
|
||||
}
|
||||
menu_display(root_x, root_y, menu);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1359,9 +1331,13 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
|
|||
b[0] = '\0';
|
||||
}
|
||||
|
||||
/* Hide any menu that might've brought up this dialog. */
|
||||
menu_reset_all(menu_list);
|
||||
|
||||
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++) {
|
||||
if (menu_list->menus[l]->font) {
|
||||
/* copycat font entry to 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;
|
||||
|
@ -1377,7 +1353,8 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
|
|||
i->text = b;
|
||||
i->len = strlen(b);
|
||||
|
||||
if (m->font) { /* pre-calc width so we can center the dialog */
|
||||
if (m->font) {
|
||||
/* pre-calc width so we can center the dialog */
|
||||
l = strlen(prompt);
|
||||
if (i->len > l) {
|
||||
l = XTextWidth(m->font, i->text, i->len);
|
||||
|
|
|
@ -44,11 +44,9 @@ static const char cvs_ident[] = "$Id$";
|
|||
const char *
|
||||
my_basename(const char *str)
|
||||
{
|
||||
|
||||
const char *base = strrchr(str, '/');
|
||||
|
||||
return (base ? base + 1 : str);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -58,7 +56,6 @@ my_basename(const char *str)
|
|||
unsigned long
|
||||
str_leading_match(register const char *s1, register const char *s2)
|
||||
{
|
||||
|
||||
register unsigned long n;
|
||||
|
||||
if (!s1 || !s2) {
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#define NS_SCREAM_FILE 32
|
||||
#define NS_SCREAM_SHARED 64
|
||||
#define NS_SCREAM_ZOMBIE 128
|
||||
#define NS_SCREAM_BUTTON 0xf0
|
||||
|
||||
#define NS_SCREAM_MASK (~(NS_SCREAM_UTMP|NS_SCREAM_PRVS))
|
||||
|
||||
|
|
|
@ -975,10 +975,13 @@ scr_erase_line(int mode)
|
|||
ZERO_SCROLLBACK;
|
||||
RESET_CHSTAT;
|
||||
|
||||
if (screen.flags & Screen_WrapNext)
|
||||
if (screen.flags & Screen_WrapNext) {
|
||||
screen.flags &= ~Screen_WrapNext;
|
||||
}
|
||||
|
||||
row = TermWin.saveLines + screen.row;
|
||||
ASSERT(row < TermWin.nrow + TermWin.saveLines);
|
||||
|
||||
if (screen.text[row]) {
|
||||
switch (mode) {
|
||||
case 0: /* erase to end of line */
|
||||
|
|
|
@ -194,27 +194,22 @@ eterm_bootstrap(int argc, char *argv[])
|
|||
D_UTMP(("Now running with real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", getuid(), getgid(), geteuid(), getegid()));
|
||||
|
||||
#ifdef ESCREEN
|
||||
# define ESCREEN_PREFIX "Escreen"
|
||||
|
||||
TermWin.screen = NULL;
|
||||
TermWin.screen_mode = NS_MODE_NONE;
|
||||
{
|
||||
char *p = strrchr(orig_argv0, '/');
|
||||
|
||||
# define ESCREEN_PREFIX "Escreen"
|
||||
# define ETERM_PREFIX "Eterm"
|
||||
p = p ? (p + 1) : orig_argv0;
|
||||
if (rs_url) {
|
||||
if (!strncmp(rs_url, NS_TWIN_PROTO, strlen(NS_TWIN_PROTO))) {
|
||||
TermWin.screen_mode = NS_MODE_TWIN;
|
||||
} else if (!strncmp(rs_url, NS_SCREEN_PROTO, strlen(NS_SCREEN_PROTO))) {
|
||||
TermWin.screen_mode = NS_MODE_SCREEN;
|
||||
} else if (!strncmp(rs_url, NS_SCREAM_PROTO, strlen(NS_SCREAM_PROTO))) {
|
||||
TermWin.screen_mode = NS_MODE_SCREAM;
|
||||
} else {
|
||||
TermWin.screen_mode = NS_MODE_NEGOTIATE;
|
||||
}
|
||||
} else if (!strncasecmp(ESCREEN_PREFIX, p, strlen(ESCREEN_PREFIX))) {
|
||||
if (rs_url) {
|
||||
if (!BEG_STRCASECMP(rs_url, NS_TWIN_PROTO)) {
|
||||
TermWin.screen_mode = NS_MODE_TWIN;
|
||||
} else if (!BEG_STRCASECMP(rs_url, NS_SCREEN_PROTO)) {
|
||||
TermWin.screen_mode = NS_MODE_SCREEN;
|
||||
} else if (!BEG_STRCASECMP(rs_url, NS_SCREAM_PROTO)) {
|
||||
TermWin.screen_mode = NS_MODE_SCREAM;
|
||||
} else {
|
||||
TermWin.screen_mode = NS_MODE_NEGOTIATE;
|
||||
}
|
||||
} else if (!strcmp(ESCREEN_PREFIX, my_basename(orig_argv0))) {
|
||||
TermWin.screen_mode = NS_MODE_SCREEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
23
src/timer.c
23
src/timer.c
|
@ -43,25 +43,24 @@ static etimer_t *timers = NULL;
|
|||
timerhdl_t
|
||||
timer_add(unsigned long msec, timer_handler_t handler, void *data)
|
||||
{
|
||||
|
||||
static etimer_t *timer;
|
||||
struct timeval tv;
|
||||
static struct timezone tz;
|
||||
|
||||
if (!timers) {
|
||||
timers = (etimer_t *) MALLOC(sizeof(etimer_t));
|
||||
timer = timers;
|
||||
timer->next = NULL;
|
||||
} else {
|
||||
timer->next = (etimer_t *) MALLOC(sizeof(etimer_t));
|
||||
timer = timer->next;
|
||||
timer = (etimer_t *) MALLOC(sizeof(etimer_t));
|
||||
timer->next = timers;
|
||||
timers = timer;
|
||||
}
|
||||
timer->msec = msec;
|
||||
gettimeofday(&tv, &tz);
|
||||
gettimeofday(&tv, NULL);
|
||||
timer->time.tv_sec = (msec / 1000) + tv.tv_sec;
|
||||
timer->time.tv_usec = ((msec % 1000) * 1000) + tv.tv_usec;
|
||||
timer->handler = handler;
|
||||
timer->data = data;
|
||||
timer->next = NULL;
|
||||
D_TIMER(("Added timer. Timer set to %lu/%lu with handler %8p and data %8p\n", timer->time.tv_sec, timer->time.tv_usec, timer->handler, timer->data));
|
||||
return ((timerhdl_t) timer);
|
||||
}
|
||||
|
@ -69,7 +68,6 @@ timer_add(unsigned long msec, timer_handler_t handler, void *data)
|
|||
unsigned char
|
||||
timer_del(timerhdl_t handle)
|
||||
{
|
||||
|
||||
register etimer_t *current;
|
||||
etimer_t *temp;
|
||||
|
||||
|
@ -95,12 +93,10 @@ timer_del(timerhdl_t handle)
|
|||
unsigned char
|
||||
timer_change_delay(timerhdl_t handle, unsigned long msec)
|
||||
{
|
||||
|
||||
struct timeval tv;
|
||||
static struct timezone tz;
|
||||
|
||||
handle->msec = msec;
|
||||
gettimeofday(&tv, &tz);
|
||||
gettimeofday(&tv, NULL);
|
||||
handle->time.tv_sec = (msec / 1000) + tv.tv_sec;
|
||||
handle->time.tv_usec = ((msec % 1000) * 1000) + tv.tv_usec;
|
||||
return 1;
|
||||
|
@ -109,15 +105,12 @@ timer_change_delay(timerhdl_t handle, unsigned long msec)
|
|||
void
|
||||
timer_check(void)
|
||||
{
|
||||
|
||||
register etimer_t *current;
|
||||
struct timeval tv;
|
||||
static struct timezone tz;
|
||||
|
||||
if (!timers)
|
||||
return;
|
||||
REQUIRE(timers);
|
||||
|
||||
gettimeofday(&tv, &tz);
|
||||
gettimeofday(&tv, NULL);
|
||||
for (current = timers; current; current = current->next) {
|
||||
if ((current->time.tv_sec > tv.tv_sec) || ((current->time.tv_sec == tv.tv_sec) && (current->time.tv_usec >= tv.tv_usec))) {
|
||||
if (!((current->handler) (current->data))) {
|
||||
|
|
|
@ -568,7 +568,11 @@ term_resize(int width, int height)
|
|||
|
||||
D_X11(("term_resize(%d, %d)\n", width, height));
|
||||
TermWin.width = TermWin.ncol * TermWin.fwidth;
|
||||
#ifdef ESCREEN
|
||||
TermWin.height = (TermWin.screen_mode ? TermWin.nrow - 1 : TermWin.nrow) * TermWin.fheight;
|
||||
#else
|
||||
TermWin.height = TermWin.nrow * TermWin.fheight;
|
||||
#endif
|
||||
D_X11((" -> New TermWin width/height == %lux%lu\n", TermWin.width, TermWin.height));
|
||||
width = TermWin_TotalWidth();
|
||||
height = TermWin_TotalHeight();
|
||||
|
@ -611,14 +615,16 @@ handle_resize(unsigned int width, unsigned int height)
|
|||
int new_nrow = (height - szHint.base_height) / TermWin.fheight;
|
||||
|
||||
D_EVENTS(("handle_resize(%u, %u)\n", width, height));
|
||||
if (first_time || (new_ncol != TermWin.ncol) || (new_nrow != TermWin.nrow)) {
|
||||
TermWin.ncol = new_ncol;
|
||||
|
||||
#ifdef ESCREEN
|
||||
TermWin.nrow = new_nrow + (NS_MAGIC_LINE(TermWin.screen_mode) ? 1 : 0);
|
||||
#else
|
||||
TermWin.nrow = new_nrow;
|
||||
if (NS_MAGIC_LINE(TermWin.screen_mode)) {
|
||||
new_nrow++;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (first_time || (new_ncol != TermWin.ncol) || (new_nrow != TermWin.nrow)) {
|
||||
TermWin.ncol = new_ncol;
|
||||
TermWin.nrow = new_nrow;
|
||||
term_resize(width, height);
|
||||
szHint.width = szHint.base_width + TermWin.width;
|
||||
szHint.height = szHint.base_height + TermWin.height;
|
||||
|
|
Loading…
Reference in New Issue