Mon Apr 18 21:49:08 2005 Michael Jennings (mej)

Re-indent code.
----------------------------------------------------------------------


SVN revision: 14229
This commit is contained in:
Michael Jennings 2005-04-19 01:57:24 +00:00
parent 05469ad9f0
commit 6657911db3
25 changed files with 3315 additions and 3088 deletions

View File

@ -11,7 +11,7 @@ aclocal.m4
config.status config.status
config.h config.h
libtool libtool
stamp-h stamp-h*
move-themes move-themes
*.spec *.spec
config.h.in config.h.in
@ -20,3 +20,8 @@ mkinstalldirs
install-sh install-sh
Eterm*.tar.gz Eterm*.tar.gz
*.sddf *.sddf
autom4te*
depcomp
build.mezz
iconv_test*
utf8*

View File

@ -5325,3 +5325,7 @@ test scripts into utils/, and in playing around with them, I found and
fixed an X server resource leak. Use Etpalette to view the 256-color fixed an X server resource leak. Use Etpalette to view the 256-color
palette. palette.
---------------------------------------------------------------------- ----------------------------------------------------------------------
Mon Apr 18 21:49:08 2005 Michael Jennings (mej)
Re-indent code.
----------------------------------------------------------------------

View File

@ -2,14 +2,14 @@
TYPENAMES="" TYPENAMES=""
for i in button_t buttonbar_t menu_t menuitem_t ; do for i in eterm_action_t button_t buttonbar_t menu_t menuitem_t ; do
TYPENAMES="$TYPENAMES -T $i" TYPENAMES="$TYPENAMES -T $i"
done done
for i in *.c src/*.c utils/*.c ; do for i in *.c src/*.c utils/*.c ; do
if test -f $i; then if test -f $i; then
echo Reformatting $i echo Reformatting $i
indent -bad -bap -bbo -br -brs -cdw -ce -ci4 -cli2 -cs -di1 -i4 -l180 \ indent -bad -bap -bbo -br -brs -cdw -ce -ci4 -cli4 -cs -di1 -i4 -l132 \
-lp -lps -nbc -nbfda -npcs -nprs -nsob -nss -nut -psl -saf -sai -saw $TYPENAMES $i -lp -lps -nbc -nbfda -npcs -nprs -nsob -nss -nut -psl -saf -sai -saw $TYPENAMES $i
fi fi
done done

View File

@ -97,7 +97,8 @@ action_t *action_find_match(unsigned short mod, unsigned char button, KeySym key
D_ACTIONS(("mod == 0x%08x, button == %d, keysym == 0x%08x\n", mod, button, keysym)); D_ACTIONS(("mod == 0x%08x, button == %d, keysym == 0x%08x\n", mod, button, keysym));
for (action = action_list; action; action = action->next) { for (action = action_list; action; action = action->next) {
D_ACTIONS(("Checking action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button, action->keysym)); D_ACTIONS(("Checking action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button,
action->keysym));
if ((action->mod == mod) && (action->button == button) && (action->keysym == keysym)) { if ((action->mod == mod) && (action->button == button) && (action->keysym == keysym)) {
D_ACTIONS(("Match found at %8p\n", action)); D_ACTIONS(("Match found at %8p\n", action));
return action; return action;
@ -146,7 +147,8 @@ 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 /* 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. */ 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) { if (mod != MOD_ANY) {
/* LOGICAL_XOR() returns true if either the first parameter or the second parameter /* 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 is true, but not both...just like XOR. If the mask we're looking for is set in
@ -202,7 +204,8 @@ action_dispatch(event_t *ev, KeySym keysym)
ASSERT_RVAL(ev != NULL, 0); ASSERT_RVAL(ev != NULL, 0);
ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 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) { for (action = action_list; action; action = action->next) {
/* The very first thing we do is match the event type to the type /* 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 of the current action. This means that we'll only run through
@ -241,29 +244,29 @@ action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_
action->type = type; action->type = type;
action->keysym = keysym; action->keysym = keysym;
switch (type) { switch (type) {
case ACTION_STRING: case ACTION_STRING:
action->handler = (action_handler_t) action_handle_string; action->handler = (action_handler_t) action_handle_string;
action->param.string = (char *) MALLOC(strlen((char *) param) + 2); action->param.string = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.string, (char *) param); strcpy(action->param.string, (char *) param);
parse_escaped_string(action->param.string); parse_escaped_string(action->param.string);
break; break;
case ACTION_ECHO: case ACTION_ECHO:
action->handler = (action_handler_t) action_handle_echo; action->handler = (action_handler_t) action_handle_echo;
action->param.string = (char *) MALLOC(strlen((char *) param) + 2); action->param.string = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.string, (char *) param); strcpy(action->param.string, (char *) param);
parse_escaped_string(action->param.string); parse_escaped_string(action->param.string);
break; break;
case ACTION_SCRIPT: case ACTION_SCRIPT:
action->handler = (action_handler_t) action_handle_script; action->handler = (action_handler_t) action_handle_script;
action->param.script = (char *) MALLOC(strlen((char *) param) + 2); action->param.script = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.script, (char *) param); strcpy(action->param.script, (char *) param);
break; break;
case ACTION_MENU: case ACTION_MENU:
action->handler = (action_handler_t) action_handle_menu; action->handler = (action_handler_t) action_handle_menu;
action->param.menu = (menu_t *) param; action->param.menu = (menu_t *) param;
break; break;
default: default:
break; break;
} }
D_ACTIONS(("Added action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button, action->keysym)); D_ACTIONS(("Added action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button, action->keysym));
} }

View File

@ -60,7 +60,8 @@ static inline void
draw_string(buttonbar_t *bbar, Drawable d, GC gc, int x, int y, char *str, size_t len) draw_string(buttonbar_t *bbar, Drawable d, GC gc, int x, int y, char *str, size_t len)
{ {
D_BBAR(("Writing string \"%s\" (length %lu) using font 0x%08x onto drawable 0x%08x at %d, %d\n", str, len, bbar->font, d, x, y)); D_BBAR(("Writing string \"%s\" (length %lu) using font 0x%08x onto drawable 0x%08x at %d, %d\n",
str, len, bbar->font, d, x, y));
REQUIRE(bbar != NULL); REQUIRE(bbar != NULL);
REQUIRE(d != None); REQUIRE(d != None);
REQUIRE(gc != None); REQUIRE(gc != None);
@ -91,7 +92,8 @@ buttonbar_t *bbar_create(void)
xattr.colormap = cmap; xattr.colormap = cmap;
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr); cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
mask = KeyPressMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; mask = KeyPressMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
gcvalue.foreground = xattr.border_pixel; gcvalue.foreground = xattr.border_pixel;
bbar->font = load_font(etfonts[def_font_idx], "fixed", FONT_TYPE_X); bbar->font = load_font(etfonts[def_font_idx], "fixed", FONT_TYPE_X);
@ -195,7 +197,8 @@ bbar_handle_enter_notify(event_t *ev)
return 0; return 0;
} }
bbar_draw(bbar, IMAGE_STATE_SELECTED, 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); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
if (b) { if (b) {
bbar_select_button(bbar, b); bbar_select_button(bbar, b);
@ -299,7 +302,9 @@ bbar_handle_button_release(event_t *ev)
size_t l = strlen(orig_argv0) + strlen(u) + 7; size_t l = strlen(orig_argv0) + strlen(u) + 7;
if ((c = MALLOC(l))) { if ((c = MALLOC(l))) {
snprintf(c, l, "%s%s -U %s", ((orig_argv0[0] == '/') || ((orig_argv0[0] == '.') && (orig_argv0[1] == '/'))) ? "" : "./", orig_argv0, u); 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)); D_ESCREEN(("(experimental) creating other frame using \"%s\"\n", c));
(void) ns_run(TermWin.screen->efuns, c); (void) ns_run(TermWin.screen->efuns, c);
FREE(c); FREE(c);
@ -326,13 +331,15 @@ bbar_handle_button_release(event_t *ev)
return 0; 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); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
if (b) { if (b) {
D_EVENTS(("Event in buttonbar %8p, button %8p (%s)\n", bbar, b, NONULL(b->text))); D_EVENTS(("Event in buttonbar %8p, button %8p (%s)\n", bbar, b, NONULL(b->text)));
if (bbar->current && (b != bbar->current)) { 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))); 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); bbar_deselect_button(bbar, bbar->current);
} else { } else {
bbar_select_button(bbar, b); bbar_select_button(bbar, b);
@ -361,7 +368,8 @@ bbar_handle_motion_notify(event_t *ev)
return 0; return 0;
} }
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev)); 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)); 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); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y);
@ -576,7 +584,8 @@ button_calc_size(buttonbar_t *bbar, button_t *button)
D_BBAR((" -> Final icon dimensions are %hux%hu\n", button->icon_w, button->icon_h)); D_BBAR((" -> Final icon dimensions are %hux%hu\n", button->icon_w, button->icon_h));
} }
#endif #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 void
@ -654,7 +663,8 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
ASSERT_RVAL(fontname != NULL, 0); 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) { if (bbar->font) {
free_font(bbar->font); free_font(bbar->font);
} }
@ -674,7 +684,8 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname)
bbar->fheight = font->ascent + font->descent; bbar->fheight = font->ascent + font->descent;
XSetFont(Xdisplay, bbar->gc, font->fid); XSetFont(Xdisplay, bbar->gc, font->fid);
bbar_reset_total_height(); 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)); 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); bbar_calc_height(bbar);
return 1; return 1;
@ -803,24 +814,24 @@ button_set_action(button_t *button, action_type_t type, char *action)
button->type = type; button->type = type;
switch (type) { switch (type) {
case ACTION_MENU: case ACTION_MENU:
button->action.menu = find_menu_by_title(menu_list, action); button->action.menu = find_menu_by_title(menu_list, action);
return ((button->action.menu == NULL) ? (0) : (1)); return ((button->action.menu == NULL) ? (0) : (1));
break; break;
case ACTION_STRING: case ACTION_STRING:
case ACTION_ECHO: case ACTION_ECHO:
button->action.string = (char *) MALLOC(strlen(action) + 2); button->action.string = (char *) MALLOC(strlen(action) + 2);
strcpy(button->action.string, action); strcpy(button->action.string, action);
parse_escaped_string(button->action.string); parse_escaped_string(button->action.string);
return ((button->action.string == NULL) ? (0) : (1)); return ((button->action.string == NULL) ? (0) : (1));
break; break;
case ACTION_SCRIPT: case ACTION_SCRIPT:
button->action.script = (char *) MALLOC(strlen(action) + 2); button->action.script = (char *) MALLOC(strlen(action) + 2);
strcpy(button->action.script, action); strcpy(button->action.script, action);
return ((button->action.script == NULL) ? (0) : (1)); return ((button->action.script == NULL) ? (0) : (1));
break; break;
default: default:
break; break;
} }
return 0; return 0;
} }
@ -871,7 +882,8 @@ bbar_click_button(buttonbar_t *bbar, button_t *button)
if (image_mode_is(image_button, MODE_MASK)) { 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); paste_simage(images[image_button].clicked, image_button, bbar->win, bbar->win, button->x, button->y, button->w, button->h);
} else { } 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)) { if (image_mode_is(image_button, MODE_AUTO)) {
enl_ipc_sync(); enl_ipc_sync();
@ -893,99 +905,100 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
REQUIRE(button != NULL); 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)); 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) { switch (button->type) {
case ACTION_MENU: case ACTION_MENU:
D_BBAR((" -> Menu button found.\n")); D_BBAR((" -> Menu button found.\n"));
if (press) { if (press) {
menu_invoke(button->x, button->y + button->h, bbar->win, button->action.menu, t); menu_invoke(button->x, button->y + button->h, bbar->win, button->action.menu, t);
} }
break; break;
case ACTION_STRING: case ACTION_STRING:
D_BBAR((" -> String button found.\n")); D_BBAR((" -> String button found.\n"));
if (!press) { if (!press) {
size_t len; size_t len;
len = strlen(button->action.string); len = strlen(button->action.string);
D_BBAR(("Writing \"%s\" to command buffer.\n", safe_print_string(button->action.string, len))); 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)); cmd_write((unsigned char *) button->action.string, strlen(button->action.string));
} }
break; break;
case ACTION_ECHO: case ACTION_ECHO:
D_BBAR((" -> Echo button found.\n")); D_BBAR((" -> Echo button found.\n"));
if (!press) { if (!press) {
size_t len; size_t len;
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen && TermWin.screen->backend) { /* translate escapes */ if (TermWin.screen && TermWin.screen->backend) { /* translate escapes */
button_t *b = bbar->buttons; button_t *b = bbar->buttons;
_ns_disp *d2 = TermWin.screen->dsps; _ns_disp *d2 = TermWin.screen->dsps;
int n = (button->action.string)[1] - '0'; int n = (button->action.string)[1] - '0';
if (b && (b->flags & NS_SCREAM_BUTTON)) { 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)); D_ESCREEN(("Looking for active display, n == %d, press == %d, prvs == %d\n", n, (int) press, (int) prvs));
if (prvs != 1) { if (prvs != 1) {
/* find active disp */ /* find active disp */
for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next); for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next);
if (b && b != button) { if (b && b != button) {
D_ESCREEN((" -> Found button %8p (%s) for current display.\n", b, NONULL(b->text))); D_ESCREEN((" -> Found button %8p (%s) for current display.\n", b, NONULL(b->text)));
/* when trying to change name of non- */ /* when trying to change name of non- */
/* active display, make that disp active */ /* active display, make that disp active */
button->flags |= NS_SCREAM_CURR; button->flags |= NS_SCREAM_CURR;
b->flags &= ~NS_SCREAM_CURR; b->flags &= ~NS_SCREAM_CURR;
bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK); bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK);
button->flags &= ~NS_SCREAM_CURR; button->flags &= ~NS_SCREAM_CURR;
b->flags |= NS_SCREAM_CURR; b->flags |= NS_SCREAM_CURR;
for (; d2 && d2->index != n; d2 = d2->next); for (; d2 && d2->index != n; d2 = d2->next);
if (d2) { if (d2) {
/* pre-adjust curr ptr */ /* pre-adjust curr ptr */
TermWin.screen->curr = d2; TermWin.screen->curr = d2;
} else { } else {
D_ESCREEN(("no display %d in this session : (\n", n)); D_ESCREEN(("no display %d in this session : (\n", n));
} }
ns_go2_disp(TermWin.screen, n); ns_go2_disp(TermWin.screen, n);
} }
if (prvs == 2) { if (prvs == 2) {
/* middle button -- kill */ /* middle button -- kill */
D_ESCREEN((" -> Remove display %d\n", n)); D_ESCREEN((" -> Remove display %d\n", n));
ns_rem_disp(TermWin.screen, n, TRUE); ns_rem_disp(TermWin.screen, n, TRUE);
} else { } else {
/* right button -- rename */ /* right button -- rename */
D_ESCREEN((" -> Rename display %d\n", n)); D_ESCREEN((" -> Rename display %d\n", n));
ns_ren_disp(TermWin.screen, n, NULL); ns_ren_disp(TermWin.screen, n, NULL);
} }
} else { } else {
/* left button -- select */ /* left button -- select */
D_ESCREEN((" -> Go to display %d\n", n)); D_ESCREEN((" -> Go to display %d\n", n));
ns_go2_disp(TermWin.screen, n); ns_go2_disp(TermWin.screen, n);
} }
break; break;
} else { } else {
D_ESCREEN(("Non-screen button, handling normally.\n")); D_ESCREEN(("Non-screen button, handling normally.\n"));
} }
} }
#endif #endif
/* not in screen-mode, use normal facilities */ /* not in screen-mode, use normal facilities */
len = strlen(button->action.string); len = strlen(button->action.string);
D_BBAR(("Writing \"%s\" to subprocess.\n", safe_print_string(button->action.string, len))); D_BBAR(("Writing \"%s\" to subprocess.\n", safe_print_string(button->action.string, len)));
tt_write((unsigned char *) button->action.string, len); tt_write((unsigned char *) button->action.string, len);
} }
break; break;
case ACTION_SCRIPT: case ACTION_SCRIPT:
D_BBAR((" -> Script button found.\n")); D_BBAR((" -> Script button found.\n"));
if (!press) { if (!press) {
script_parse((char *) button->action.script); script_parse((char *) button->action.script);
} }
break; break;
default: default:
D_BBAR((" -> Unknown button type 0x%08x?!\n", button->type)); D_BBAR((" -> Unknown button type 0x%08x?!\n", button->type));
break; break;
} }
prvs = press; prvs = press;
} }
@ -1092,7 +1105,8 @@ bbar_draw(buttonbar_t *bbar, unsigned char image_state, unsigned char force_mode
XSetForeground(Xdisplay, bbar->gc, images[image_bbar].current->fg); XSetForeground(Xdisplay, bbar->gc, images[image_bbar].current->fg);
for (button = bbar->buttons; button; button = button->next) { for (button = bbar->buttons; button; button = button->next) {
if (button->icon) { if (button->icon) {
paste_simage(button->icon, image_max, bbar->win, bbar->bg, button->icon_x, button->icon_y, button->icon_w, button->icon_h); paste_simage(button->icon, image_max, bbar->win, bbar->bg, button->icon_x, button->icon_y, button->icon_w,
button->icon_h);
} }
if (button->len) { if (button->len) {
#ifdef ESCREEN #ifdef ESCREEN
@ -1124,7 +1138,8 @@ bbar_draw(buttonbar_t *bbar, unsigned char image_state, unsigned char force_mode
} }
for (button = bbar->rbuttons; button; button = button->next) { for (button = bbar->rbuttons; button; button = button->next) {
if (button->icon) { if (button->icon) {
paste_simage(button->icon, image_max, bbar->win, bbar->bg, button->icon_x, button->icon_y, button->icon_w, button->icon_h); paste_simage(button->icon, image_max, bbar->win, bbar->bg, button->icon_x, button->icon_y, button->icon_w,
button->icon_h);
} }
if (button->len) { if (button->len) {
draw_string(bbar, bbar->bg, bbar->gc, button->text_x, button->text_y, button->text, button->len); draw_string(bbar, bbar->bg, bbar->gc, button->text_x, button->text_y, button->text, button->len);

View File

@ -201,57 +201,61 @@ privileges(int mode)
#endif #endif
switch (mode) { switch (mode) {
case IGNORE: case IGNORE:
/* Revoke suid/sgid privs and return to normal uid/gid -- mej */ /* Revoke suid/sgid privs and return to normal uid/gid -- mej */
D_UTMP(("[%ld]: Before privileges(REVERT): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), getegid())); D_UTMP(("[%ld]: Before privileges(REVERT): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(),
getegid()));
#ifdef HAVE_SETRESGID #ifdef HAVE_SETRESGID
setresgid(my_rgid, my_rgid, my_egid); setresgid(my_rgid, my_rgid, my_egid);
#elif defined(HAVE_SAVED_UIDS) #elif defined(HAVE_SAVED_UIDS)
setregid(my_rgid, my_rgid); setregid(my_rgid, my_rgid);
#else #else
setregid(my_egid, -1); setregid(my_egid, -1);
setregid(-1, my_rgid); setregid(-1, my_rgid);
#endif #endif
#ifdef HAVE_SETRESUID #ifdef HAVE_SETRESUID
setresuid(my_ruid, my_ruid, my_euid); setresuid(my_ruid, my_ruid, my_euid);
#elif defined(HAVE_SAVED_UIDS) #elif defined(HAVE_SAVED_UIDS)
setreuid(my_ruid, my_ruid); setreuid(my_ruid, my_ruid);
#else #else
setreuid(my_euid, -1); setreuid(my_euid, -1);
setreuid(-1, my_ruid); setreuid(-1, my_ruid);
#endif #endif
D_UTMP(("[%ld]: After privileges(REVERT): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), getegid())); D_UTMP(("[%ld]: After privileges(REVERT): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(),
break; getegid()));
break;
case SAVE: case SAVE:
break; break;
case RESTORE: case RESTORE:
D_UTMP(("[%ld]: Before privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), getegid())); D_UTMP(("[%ld]: Before privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(),
getegid()));
#ifdef HAVE_SETRESUID #ifdef HAVE_SETRESUID
setresuid(my_ruid, my_euid, my_euid); setresuid(my_ruid, my_euid, my_euid);
#elif defined(HAVE_SAVED_UIDS) #elif defined(HAVE_SAVED_UIDS)
setreuid(my_ruid, my_euid); setreuid(my_ruid, my_euid);
#else #else
setreuid(-1, my_euid); setreuid(-1, my_euid);
setreuid(my_ruid, -1); setreuid(my_ruid, -1);
#endif #endif
#ifdef HAVE_SETRESGID #ifdef HAVE_SETRESGID
setresgid(my_rgid, my_egid, my_egid); setresgid(my_rgid, my_egid, my_egid);
#elif defined(HAVE_SAVED_UIDS) #elif defined(HAVE_SAVED_UIDS)
setregid(my_rgid, my_egid); setregid(my_rgid, my_egid);
#else #else
setregid(-1, my_egid); setregid(-1, my_egid);
setregid(my_rgid, -1); setregid(my_rgid, -1);
#endif #endif
D_UTMP(("[%ld]: After privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), getegid())); D_UTMP(("[%ld]: After privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(),
break; getegid()));
break;
} }
} }
@ -1172,7 +1176,8 @@ clean_exit(void)
#ifndef __CYGWIN32__ #ifndef __CYGWIN32__
if (ttydev) { if (ttydev) {
D_CMD(("Restoring \"%s\" to mode %03o, uid %d, gid %d\n", ttydev, ttyfd_stat.st_mode, ttyfd_stat.st_uid, ttyfd_stat.st_gid)); D_CMD(("Restoring \"%s\" to mode %03o, uid %d, gid %d\n", ttydev, ttyfd_stat.st_mode, ttyfd_stat.st_uid,
ttyfd_stat.st_gid));
if (chmod(ttydev, ttyfd_stat.st_mode) != 0) { if (chmod(ttydev, ttyfd_stat.st_mode) != 0) {
D_UTMP(("chmod(\"%s\", %03o) failed: %s\n", ttydev, ttyfd_stat.st_mode, strerror(errno))); D_UTMP(("chmod(\"%s\", %03o) failed: %s\n", ttydev, ttyfd_stat.st_mode, strerror(errno)));
} }
@ -1856,14 +1861,18 @@ xim_send_spot(void)
static void static void
xim_get_area(XRectangle * preedit_rect, XRectangle * status_rect, XRectangle * needed_rect) xim_get_area(XRectangle * preedit_rect, XRectangle * status_rect, XRectangle * needed_rect)
{ {
preedit_rect->x = needed_rect->width + (scrollbar_is_visible() && !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) preedit_rect->x = needed_rect->width + (scrollbar_is_visible()
&& !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT))
? (scrollbar_trough_width()) : (0)); ? (scrollbar_trough_width()) : (0));
preedit_rect->y = Height2Pixel(TERM_WINDOW_GET_ROWS() - 1); preedit_rect->y = Height2Pixel(TERM_WINDOW_GET_ROWS() - 1);
preedit_rect->width = Width2Pixel(TERM_WINDOW_GET_COLS() + 1) - needed_rect->width + (!(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (scrollbar_trough_width()) : 0); preedit_rect->width =
Width2Pixel(TERM_WINDOW_GET_COLS() + 1) - needed_rect->width +
(!(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (scrollbar_trough_width()) : 0);
preedit_rect->height = Height2Pixel(1); preedit_rect->height = Height2Pixel(1);
status_rect->x = (scrollbar_is_visible() && !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT))) ? (scrollbar_trough_width()) : 0; status_rect->x = (scrollbar_is_visible()
&& !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT))) ? (scrollbar_trough_width()) : 0;
status_rect->y = Height2Pixel(TERM_WINDOW_GET_ROWS() - 1); status_rect->y = Height2Pixel(TERM_WINDOW_GET_ROWS() - 1);
status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel(TERM_WINDOW_GET_COLS() + 1); status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel(TERM_WINDOW_GET_COLS() + 1);
@ -1922,7 +1931,8 @@ xim_real_init(void)
*(end + 1) = '\0'; *(end + 1) = '\0';
if (*s) { if (*s) {
snprintf(buf, sizeof(buf), "@im=%s", s); snprintf(buf, sizeof(buf), "@im=%s", s);
if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p) && ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) { if (((p = XSetLocaleModifiers(buf)) != NULL) && (*p)
&& ((xim_input_method = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)) {
break; break;
} }
} }
@ -2011,18 +2021,22 @@ xim_real_init(void)
xim_set_size(&rect); xim_set_size(&rect);
xim_get_position(&spot); xim_get_position(&spot);
xim_set_color(&fg, &bg); 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) { } else if (xim_input_style & XIMPreeditArea) {
xim_set_color(&fg, &bg); xim_set_color(&fg, &bg);
/* The necessary width of preedit area is unknown until create input context. */ /* The necessary width of preedit area is unknown until create input context. */
needed_rect.width = 0; needed_rect.width = 0;
xim_get_area(&rect, &status_rect, &needed_rect); xim_get_area(&rect, &status_rect, &needed_rect);
preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL); preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL);
status_attr = XVaCreateNestedList(0, XNArea, &status_rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL); status_attr =
XVaCreateNestedList(0, XNArea, &status_rect, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL);
} }
xim_input_context = xim_input_context =
XCreateIC(xim_input_method, XNInputStyle, xim_input_style, XNClientWindow, TermWin.parent, XNFocusWindow, TermWin.parent, XCreateIC(xim_input_method, XNInputStyle, xim_input_style, XNClientWindow, TermWin.parent, XNFocusWindow, TermWin.parent,
preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, status_attr ? XNStatusAttributes : NULL, status_attr, NULL); preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, status_attr ? XNStatusAttributes : NULL, status_attr,
NULL);
if (preedit_attr) { if (preedit_attr) {
XFree(preedit_attr); XFree(preedit_attr);
} }
@ -2126,7 +2140,8 @@ run_command(char **argv)
/* store original tty status for restoration clean_exit() -- rgg 04/12/95 */ /* store original tty status for restoration clean_exit() -- rgg 04/12/95 */
lstat(ttydev, &ttyfd_stat); lstat(ttydev, &ttyfd_stat);
D_CMD(("Original settings of %s are mode %o, uid %d, gid %d\n", ttydev, ttyfd_stat.st_mode, ttyfd_stat.st_uid, ttyfd_stat.st_gid)); D_CMD(("Original settings of %s are mode %o, uid %d, gid %d\n", ttydev, ttyfd_stat.st_mode, ttyfd_stat.st_uid,
ttyfd_stat.st_gid));
/* install exit handler for cleanup */ /* install exit handler for cleanup */
#ifdef HAVE_ATEXIT #ifdef HAVE_ATEXIT
@ -2572,12 +2587,12 @@ static int
input_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (void *, char *, size_t, size_t)) 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)) { switch (menu_dialog(xd, prompt, maxlen, retstr, inp_tab)) {
case 0: case 0:
return NS_SUCC; return NS_SUCC;
case -2: case -2:
return NS_USER_CXL; return NS_USER_CXL;
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -2702,45 +2717,45 @@ matrix(int n)
r = screen.rend[ys + y]; r = screen.rend[ys + y];
switch (w) { switch (w) {
case 0: /* restart */ case 0: /* restart */
if (s[x]) { if (s[x]) {
r[x] = MATRIX_LO; r[x] = MATRIX_LO;
s[x] = 0; s[x] = 0;
t = screen.text[ys]; t = screen.text[ys];
r = screen.rend[ys]; r = screen.rend[ys];
} }
r[x] = MATRIX_HI; r[x] = MATRIX_HI;
t[x] = random() & 0xff; t[x] = random() & 0xff;
s[x]++; s[x]++;
/* fall-through */ /* fall-through */
case 1: /* continue */ case 1: /* continue */
case 2: case 2:
case 3: case 3:
for (f = random() & 7; f != 0; f--) { for (f = random() & 7; f != 0; f--) {
if (y < TERM_WINDOW_GET_ROWS() - 1) { if (y < TERM_WINDOW_GET_ROWS() - 1) {
t2 = screen.text[ys + y + 1]; t2 = screen.text[ys + y + 1];
r2 = screen.rend[ys + y + 1]; r2 = screen.rend[ys + y + 1];
t2[x] = t[x]; t2[x] = t[x];
r2[x] = r[x]; r2[x] = r[x];
s[x]++; s[x]++;
y++; y++;
} else { } else {
s[x] = 0; s[x] = 0;
f = 0; f = 0;
} }
r[x] = MATRIX_LO; r[x] = MATRIX_LO;
t[x] = random() & 0xff; t[x] = random() & 0xff;
if (f) { if (f) {
scr_refresh(FAST_REFRESH); scr_refresh(FAST_REFRESH);
t = screen.text[ys + y]; t = screen.text[ys + y];
r = screen.rend[ys + y]; r = screen.rend[ys + y];
} }
} }
break; break;
default: default:
t[x] = random() & 0xff; /* hold */ t[x] = random() & 0xff; /* hold */
} }
} }
} }
@ -2825,6 +2840,7 @@ make_escreen_menu(buttonbar_t *bbar)
{ {
static int been_here = 0; static int been_here = 0;
button_t *button; button_t *button;
#if 0 #if 0
menu_t *m; menu_t *m;
menuitem_t *i; menuitem_t *i;
@ -3040,8 +3056,7 @@ tt_winsize(int fd)
ws.ws_xpixel = (unsigned short) TERM_WINDOW_GET_WIDTH(); ws.ws_xpixel = (unsigned short) TERM_WINDOW_GET_WIDTH();
ws.ws_ypixel = (unsigned short) TERM_WINDOW_GET_HEIGHT(); ws.ws_ypixel = (unsigned short) TERM_WINDOW_GET_HEIGHT();
#endif #endif
D_CMD(("Sending TIOCSWINSZ to fd %d: %hdx%hd (%hdx%hd)\n", D_CMD(("Sending TIOCSWINSZ to fd %d: %hdx%hd (%hdx%hd)\n", fd, ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel));
fd, ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel));
ioctl(fd, TIOCSWINSZ, &ws); ioctl(fd, TIOCSWINSZ, &ws);
} }
@ -3117,7 +3132,8 @@ check_pixmap_change(int sig)
SIG_RETURN(0); SIG_RETURN(0);
} }
now = time(NULL); now = time(NULL);
D_PIXMAP(("now %lu >= %lu (last_update %lu + rs_anim_delay %lu) ?\n", now, last_update + rs_anim_delay, last_update, rs_anim_delay)); D_PIXMAP(("now %lu >= %lu (last_update %lu + rs_anim_delay %lu) ?\n", now, last_update + rs_anim_delay, last_update,
rs_anim_delay));
if (now >= last_update + rs_anim_delay || 1) { if (now >= last_update + rs_anim_delay || 1) {
D_PIXMAP(("Time to update pixmap. now == %lu\n", now)); D_PIXMAP(("Time to update pixmap. now == %lu\n", now));
imlib_context_set_image(images[image_bg].current->iml->im); imlib_context_set_image(images[image_bg].current->iml->im);
@ -3177,42 +3193,43 @@ cmd_getc(void)
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen) { if (TermWin.screen) {
switch (TermWin.screen->backend) { switch (TermWin.screen->backend) {
case NS_MODE_NONE: case NS_MODE_NONE:
break; break;
case NS_MODE_NEGOTIATE: case NS_MODE_NEGOTIATE:
# ifdef NS_HAVE_SCREEN # ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
parse_screen_status_if_necessary(); parse_screen_status_if_necessary();
break; break;
# endif # endif
# ifdef NS_HAVE_SCREAM # ifdef NS_HAVE_SCREAM
case NS_MODE_SCREAM: case NS_MODE_SCREAM:
break; break;
# endif # endif
# ifdef NS_HAVE_TWIN # ifdef NS_HAVE_TWIN
case NS_MODE_TWIN: case NS_MODE_TWIN:
if (!TermWin.screen->twin) { if (!TermWin.screen->twin) {
if (!TermWin.screen->timestamp) { if (!TermWin.screen->timestamp) {
TermWin.screen->timestamp = time(NULL); TermWin.screen->timestamp = time(NULL);
} else if (TermWin.screen->timestamp < time(NULL)) { } else if (TermWin.screen->timestamp < time(NULL)) {
if (!Tw_CheckMagic(libscream_magic)) { if (!Tw_CheckMagic(libscream_magic)) {
D_ESCREEN(("ns_attach_by_sess: Tw_CheckMagic failed\n")); D_ESCREEN(("ns_attach_by_sess: Tw_CheckMagic failed\n"));
TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE;
} else { } else {
if (!(TermWin.screen->twin = Tw_Open(TermWin.screen->twin_str))) { if (!(TermWin.screen->twin = Tw_Open(TermWin.screen->twin_str))) {
ns_desc_twin(TermWin.screen, "cmd_getc->Tw_Open"); ns_desc_twin(TermWin.screen, "cmd_getc->Tw_Open");
TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE;
} else { } else {
D_ESCREEN(("ns_attach_by_sess: Tw_Open(%s) succeeded: handle @ %p\n", TermWin.screen->twin_str, TermWin.screen->twin)); D_ESCREEN(("ns_attach_by_sess: Tw_Open(%s) succeeded: handle @ %p\n", TermWin.screen->twin_str,
} TermWin.screen->twin));
} }
} }
} }
break; }
break;
# endif # endif
default: default:
D_ESCREEN(("mode %d not supported...\n", TermWin.screen->backend)); D_ESCREEN(("mode %d not supported...\n", TermWin.screen->backend));
TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE;
} }
} }
#endif #endif
@ -3521,7 +3538,7 @@ main_loop(void)
set_multichar_encoding("utf8"); set_multichar_encoding("utf8");
} }
handle = iconv_open("WCHAR_T", "UTF-8"); handle = iconv_open("WCHAR_T", "UTF-8");
if (handle == SPIF_CAST_C(iconv_t) -1) { if (handle == SPIF_CAST_C(iconv_t) - 1) {
print_error("Unable to decode UTF-8 locale %s to WCHAR_T. Defaulting to portable C locale.\n", print_error("Unable to decode UTF-8 locale %s to WCHAR_T. Defaulting to portable C locale.\n",
setlocale(LC_ALL, "")); setlocale(LC_ALL, ""));
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");
@ -3536,24 +3553,26 @@ main_loop(void)
bufflen = cmdbuf_ptr - str; bufflen = cmdbuf_ptr - str;
outlen = bufflen * 6; outlen = bufflen * 6;
poutbuff = outbuff = SPIF_CAST_C(char *) MALLOC(outlen); poutbuff = outbuff = SPIF_CAST_C(char *) MALLOC(outlen);
errno = 0; errno = 0;
D_VT(("Allocated output buffer of %lu chars at %010p against input buffer of %lu\n", bufflen * 6, outbuff, bufflen)); D_VT(("Allocated output buffer of %lu chars at %010p against input buffer of %lu\n", bufflen * 6, outbuff,
bufflen));
print_warning("Moo: %s\n", safe_print_string(str, bufflen)); print_warning("Moo: %s\n", safe_print_string(str, bufflen));
retval = iconv(handle, &pinbuff, &bufflen, &poutbuff, &outlen); retval = iconv(handle, &pinbuff, &bufflen, &poutbuff, &outlen);
outlen = (size_t) (poutbuff - outbuff); outlen = (size_t) (poutbuff - outbuff);
if (retval != (size_t) -1) { if (retval != (size_t) - 1) {
errno = 0; errno = 0;
} }
if (errno == E2BIG) { if (errno == E2BIG) {
print_error("My UTF-8 decode buffer was too small by %lu bytes?!\n", bufflen); print_error("My UTF-8 decode buffer was too small by %lu bytes?!\n", bufflen);
} else if (errno == EILSEQ) { } else if (errno == EILSEQ) {
print_error("Illegal multibyte sequence encountered at \'%c\' (0x%02x); skipping.\n", print_error("Illegal multibyte sequence encountered at \'%c\' (0x%02x); skipping.\n", *pinbuff, *pinbuff);
*pinbuff, *pinbuff);
*pinbuff = ' '; *pinbuff = ' ';
pinbuff++; pinbuff++;
} else if (errno == EINVAL) { } else if (errno == EINVAL) {
D_VT(("Incomplete multibyte sequence encountered.\n")); D_VT(("Incomplete multibyte sequence encountered.\n"));
print_warning("Converted %lu input chars to %lu output chars before incomplete sequence.\n", (cmdbuf_ptr - str), outlen); print_warning("Converted %lu input chars to %lu output chars before incomplete sequence.\n",
(cmdbuf_ptr - str), outlen);
} else { } else {
print_warning("Converted %lu input chars to %lu output chars.\n", (cmdbuf_ptr - str), outlen); print_warning("Converted %lu input chars to %lu output chars.\n", (cmdbuf_ptr - str), outlen);
} }
@ -3565,19 +3584,22 @@ main_loop(void)
outlen = wcsrtombs(NULL, &wcbuff, 0, &mbs) + 1; outlen = wcsrtombs(NULL, &wcbuff, 0, &mbs) + 1;
if (outlen > 0) { if (outlen > 0) {
outbuff = SPIF_CAST_C(char *) MALLOC(outlen); outbuff = SPIF_CAST_C(char *) MALLOC(outlen);
outlen = wcsrtombs(outbuff, &wcbuff, outlen, &mbs); outlen = wcsrtombs(outbuff, &wcbuff, outlen, &mbs);
if ((long)outlen >= 0) { if ((long) outlen >= 0) {
FREE(wcbuff); FREE(wcbuff);
print_error("I win!\n"); print_error("I win!\n");
} else { } else {
print_error("wcsrtombs() returned %ld (errno is %d (%s))\n", (unsigned long) outlen, errno, strerror(errno)); print_error("wcsrtombs() returned %ld (errno is %d (%s))\n", (unsigned long) outlen, errno,
strerror(errno));
} }
if (pinbuff > (char *) str) { if (pinbuff > (char *) str) {
cmdbuf_ptr = (unsigned char *) pinbuff; cmdbuf_ptr = (unsigned char *) pinbuff;
scr_add_lines(outbuff, nlines, outlen); scr_add_lines(outbuff, nlines, outlen);
} }
} else { } else {
print_error("wcsrtombs(NULL, %10p, 0) returned %ld (errno is %d (%s))\n", wcbuff, (unsigned long) outlen, errno, strerror(errno)); print_error("wcsrtombs(NULL, %10p, 0) returned %ld (errno is %d (%s))\n", wcbuff, (unsigned long) outlen,
errno, strerror(errno));
} }
FREE(outbuff); FREE(outbuff);
} }
@ -3587,32 +3609,32 @@ main_loop(void)
} else { } else {
switch (ch) { switch (ch) {
# ifdef NO_ENQ_ANS # ifdef NO_ENQ_ANS
case 005: case 005:
break; break;
# else # else
case 005: /* ^E (ENQ) terminal status enquiry */ case 005: /* ^E (ENQ) terminal status enquiry */
tt_printf(VT100_ANS); tt_printf(VT100_ANS);
break; break;
# endif # endif
case 007: /* ^G (BEL) */ case 007: /* ^G (BEL) */
scr_bell(); scr_bell();
break; break;
case '\b': case '\b':
scr_backspace(); scr_backspace();
break; break;
case 013: /* ^K (VT) */ case 013: /* ^K (VT) */
case 014: /* ^L (FF) */ case 014: /* ^L (FF) */
scr_index(UP); scr_index(UP);
break; break;
case 016: /* ^N (SO) shift out (enter ACS mode) */ case 016: /* ^N (SO) shift out (enter ACS mode) */
scr_charset_choose(1); scr_charset_choose(1);
break; break;
case 017: /* ^O (SI) shift in (leave ACS mode) */ case 017: /* ^O (SI) shift in (leave ACS mode) */
scr_charset_choose(0); scr_charset_choose(0);
break; break;
case 033: case 033:
process_escape_seq(); process_escape_seq();
break; break;
} }
} }
} while (ch != EOF); } while (ch != EOF);

View File

@ -71,36 +71,36 @@ draw_arrow(Drawable d, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow,
BOUND(shadow, 1, 2); BOUND(shadow, 1, 2);
switch (type) { switch (type) {
case DRAW_ARROW_UP: case DRAW_ARROW_UP:
for (; shadow > 0; shadow--, x++, y++, w--) { for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, d, gc_top, x, y + w, x + w / 2, y); XDrawLine(Xdisplay, d, gc_top, x, y + w, x + w / 2, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x + w / 2, y); XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x + w / 2, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x, y + w); XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x, y + w);
} }
break; break;
case DRAW_ARROW_DOWN: case DRAW_ARROW_DOWN:
for (; shadow > 0; shadow--, x++, y++, w--) { for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, d, gc_top, x, y, x + w / 2, y + w); XDrawLine(Xdisplay, d, gc_top, x, y, x + w / 2, y + w);
XDrawLine(Xdisplay, d, gc_top, x, y, x + w, y); XDrawLine(Xdisplay, d, gc_top, x, y, x + w, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y, x + w / 2, y + w); XDrawLine(Xdisplay, d, gc_bottom, x + w, y, x + w / 2, y + w);
} }
break; break;
case DRAW_ARROW_LEFT: case DRAW_ARROW_LEFT:
for (; shadow > 0; shadow--, x++, y++, w--) { for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x + w, y); XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x + w, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x, y + w / 2); XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x, y + w / 2);
XDrawLine(Xdisplay, d, gc_top, x, y + w / 2, x + w, y); XDrawLine(Xdisplay, d, gc_top, x, y + w / 2, x + w, y);
} }
break; break;
case DRAW_ARROW_RIGHT: case DRAW_ARROW_RIGHT:
for (; shadow > 0; shadow--, x++, y++, w--) { for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, d, gc_top, x, y, x, y + w); XDrawLine(Xdisplay, d, gc_top, x, y, x, y + w);
XDrawLine(Xdisplay, d, gc_top, x, y, x + w, y + w / 2); XDrawLine(Xdisplay, d, gc_top, x, y, x + w, y + w / 2);
XDrawLine(Xdisplay, d, gc_bottom, x, y + w, x + w, y + w / 2); XDrawLine(Xdisplay, d, gc_bottom, x, y + w, x + w, y + w / 2);
} }
break; break;
default: default:
break; break;
} }
} }
@ -173,27 +173,27 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border * bord, unsigned char up)
} }
/* Determine bitshift and bitmask values */ /* Determine bitshift and bitmask values */
switch (real_depth) { switch (real_depth) {
case 15: case 15:
br = 7; br = 7;
bg = 2; bg = 2;
bb = 3; bb = 3;
mr = mg = mb = 0xf8; mr = mg = mb = 0xf8;
break; break;
case 16: case 16:
br = 8; br = 8;
bg = bb = 3; bg = bb = 3;
mr = mb = 0xf8; mr = mb = 0xf8;
mg = 0xfc; mg = 0xfc;
break; break;
case 24: case 24:
case 32: case 32:
br = 16; br = 16;
bg = 8; bg = 8;
bb = 0; bb = 0;
mr = mg = mb = 0xff; mr = mg = mb = 0xff;
break; break;
default: default:
return; return;
} }
/* Left edge */ /* Left edge */

View File

@ -85,13 +85,15 @@ enl_ipc_get_win(void)
XFree(str); XFree(str);
} }
if (ipc_win != None) { if (ipc_win != None) {
if (!XGetGeometry(Xdisplay, ipc_win, &dummy_win, &dummy_int, &dummy_int, &dummy_uint, &dummy_uint, &dummy_uint, &dummy_uint)) { if (!XGetGeometry
(Xdisplay, ipc_win, &dummy_win, &dummy_int, &dummy_int, &dummy_uint, &dummy_uint, &dummy_uint, &dummy_uint)) {
D_ENL((" -> IPC Window property is valid, but the window doesn't exist. I give up!\n")); D_ENL((" -> IPC Window property is valid, but the window doesn't exist. I give up!\n"));
ipc_win = None; ipc_win = None;
} }
str = NULL; str = NULL;
if (ipc_win != None) { if (ipc_win != None) {
XGetWindowProperty(Xdisplay, ipc_win, props[PROP_ENL_COMMS], 0, 14, False, AnyPropertyType, &prop, &format, &num, &after, &str); XGetWindowProperty(Xdisplay, ipc_win, props[PROP_ENL_COMMS], 0, 14, False, AnyPropertyType, &prop, &format, &num,
&after, &str);
if (str) { if (str) {
XFree(str); XFree(str);
} else { } else {

View File

@ -73,7 +73,8 @@ event_register_dispatcher(event_dispatcher_t func, event_dispatcher_init_t init)
/* Add a secondary event dispatcher */ /* Add a secondary event dispatcher */
event_master.num_dispatchers++; event_master.num_dispatchers++;
event_master.dispatchers = (event_dispatcher_t *) REALLOC(event_master.dispatchers, sizeof(event_dispatcher_t) * event_master.num_dispatchers); event_master.dispatchers =
(event_dispatcher_t *) REALLOC(event_master.dispatchers, sizeof(event_dispatcher_t) * event_master.num_dispatchers);
event_master.dispatchers[event_master.num_dispatchers - 1] = (event_dispatcher_t) func; event_master.dispatchers[event_master.num_dispatchers - 1] = (event_dispatcher_t) func;
(init) (); /* Initialize the dispatcher's data */ (init) (); /* Initialize the dispatcher's data */
} }
@ -230,7 +231,8 @@ handle_property_notify(event_t *ev)
if ((ev->xany.window == TermWin.parent) || (ev->xany.window == Xroot)) { if ((ev->xany.window == TermWin.parent) || (ev->xany.window == Xroot)) {
D_EVENTS(("On %s. prop (_WIN_WORKSPACE) == 0x%08x, ev->xproperty.atom == 0x%08x\n", D_EVENTS(("On %s. prop (_WIN_WORKSPACE) == 0x%08x, ev->xproperty.atom == 0x%08x\n",
((ev->xany.window == Xroot) ? "the root window" : "TermWin.parent"), (int) props[PROP_DESKTOP], (int) ev->xproperty.atom)); ((ev->xany.window == Xroot) ? "the root window" : "TermWin.parent"), (int) props[PROP_DESKTOP],
(int) ev->xproperty.atom));
if (ev->xproperty.atom == props[PROP_DESKTOP]) { if (ev->xproperty.atom == props[PROP_DESKTOP]) {
win = get_desktop_window(); win = get_desktop_window();
if (win == (Window) 1) { if (win == (Window) 1) {
@ -270,7 +272,8 @@ handle_property_notify(event_t *ev)
} }
#endif #endif
if ((ev->xany.window == Xroot) && (image_mode_any(MODE_AUTO))) { if ((ev->xany.window == Xroot) && (image_mode_any(MODE_AUTO))) {
D_EVENTS(("On the root window. prop (ENLIGHTENMENT_COMMS) == %d, ev->xproperty.atom == %d\n", (int) props[PROP_ENL_COMMS], (int) ev->xproperty.atom)); D_EVENTS(("On the root window. prop (ENLIGHTENMENT_COMMS) == %d, ev->xproperty.atom == %d\n", (int) props[PROP_ENL_COMMS],
(int) ev->xproperty.atom));
if ((props[PROP_ENL_COMMS] != None) && (ev->xproperty.atom == props[PROP_ENL_COMMS])) { if ((props[PROP_ENL_COMMS] != None) && (ev->xproperty.atom == props[PROP_ENL_COMMS])) {
if ((enl_ipc_get_win()) != None) { if ((enl_ipc_get_win()) != None) {
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
@ -341,7 +344,8 @@ handle_client_message(event_t *ev)
unsigned char *data; unsigned char *data;
unsigned long Size, RemainingBytes; unsigned long Size, RemainingBytes;
XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType, &ActualFormat, &Size, &RemainingBytes, &data); XGetWindowProperty(Xdisplay, Xroot, props[PROP_DND_SELECTION], 0L, 1000000L, False, AnyPropertyType, &ActualType,
&ActualFormat, &Size, &RemainingBytes, &data);
if (data != NULL) { if (data != NULL) {
XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data)); XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data));
selection_paste(XA_CUT_BUFFER0); selection_paste(XA_CUT_BUFFER0);
@ -394,18 +398,18 @@ handle_visibility_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0); REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
switch (ev->xvisibility.state) { switch (ev->xvisibility.state) {
case VisibilityUnobscured: case VisibilityUnobscured:
D_X11(("Window completely visible. Using FAST_REFRESH.\n")); D_X11(("Window completely visible. Using FAST_REFRESH.\n"));
refresh_type = FAST_REFRESH; refresh_type = FAST_REFRESH;
break; break;
case VisibilityPartiallyObscured: case VisibilityPartiallyObscured:
D_X11(("Window partially hidden. Using SLOW_REFRESH.\n")); D_X11(("Window partially hidden. Using SLOW_REFRESH.\n"));
refresh_type = SLOW_REFRESH; refresh_type = SLOW_REFRESH;
break; break;
default: default:
D_X11(("Window completely hidden. Using NO_REFRESH.\n")); D_X11(("Window completely hidden. Using NO_REFRESH.\n"));
refresh_type = NO_REFRESH; refresh_type = NO_REFRESH;
break; break;
} }
return 1; return 1;
} }
@ -460,7 +464,8 @@ handle_focus_in(event_t *ev)
unsigned int unused_mask; unsigned int unused_mask;
TermWin.focus = 1; TermWin.focus = 1;
XQueryPointer(Xdisplay, TermWin.parent, &unused_root, &child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); XQueryPointer(Xdisplay, TermWin.parent, &unused_root, &child, &unused_root_x, &unused_root_y, &(ev->xbutton.x),
&(ev->xbutton.y), &unused_mask);
if (child == TermWin.vt) { if (child == TermWin.vt) {
if (images[image_bg].current != images[image_bg].selected) { if (images[image_bg].current != images[image_bg].selected) {
images[image_bg].current = images[image_bg].selected; images[image_bg].current = images[image_bg].selected;
@ -523,7 +528,8 @@ handle_configure_notify(event_t *ev)
REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0); REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, ConfigureNotify, ev)) { while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, ConfigureNotify, ev)) {
D_EVENTS(("New event: Window 0x%08x, %dx%d at %d, %d\n", ev->xany.window, ev->xconfigure.width, ev->xconfigure.height, ev->xconfigure.x, ev->xconfigure.y)); D_EVENTS(("New event: Window 0x%08x, %dx%d at %d, %d\n", ev->xany.window, ev->xconfigure.width, ev->xconfigure.height,
ev->xconfigure.x, ev->xconfigure.y));
} }
if (ev->xany.window == TermWin.parent) { if (ev->xany.window == TermWin.parent) {
int x = ev->xconfigure.x, y = ev->xconfigure.y; int x = ev->xconfigure.x, y = ev->xconfigure.y;
@ -651,85 +657,87 @@ handle_button_press(event_t *ev)
mouse_report(&(ev->xbutton)); mouse_report(&(ev->xbutton));
} else { } else {
switch (ev->xbutton.button) { switch (ev->xbutton.button) {
case Button1: case Button1:
if ((button_state.last_button_press == 1) && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) { if ((button_state.last_button_press == 1)
button_state.clicks++; && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) {
} else { button_state.clicks++;
button_state.clicks = 1; } else {
} button_state.clicks = 1;
selection_click(button_state.clicks, ev->xbutton.x, ev->xbutton.y); }
button_state.last_button_press = 1; selection_click(button_state.clicks, ev->xbutton.x, ev->xbutton.y);
break; button_state.last_button_press = 1;
break;
case Button3: case Button3:
if ((button_state.last_button_press == 3) && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) { if ((button_state.last_button_press == 3)
selection_rotate(ev->xbutton.x, ev->xbutton.y); && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) {
} else { selection_rotate(ev->xbutton.x, ev->xbutton.y);
selection_extend(ev->xbutton.x, ev->xbutton.y, 1); } else {
} selection_extend(ev->xbutton.x, ev->xbutton.y, 1);
button_state.last_button_press = 3; }
break; button_state.last_button_press = 3;
break;
#ifdef MOUSEWHEEL #ifdef MOUSEWHEEL
/* This section activates the following bindings: /* This section activates the following bindings:
* *
* Mousewheel Up -- Scroll up 1 page * Mousewheel Up -- Scroll up 1 page
* Ctrl + Mousewheel Up -- Scroll up 5 pages * Ctrl + Mousewheel Up -- Scroll up 5 pages
* Shift + Mousewheel Up -- Scroll up 1 line * Shift + Mousewheel Up -- Scroll up 1 line
* Alt + Mousewheel Up -- Send PgUp to tty * Alt + Mousewheel Up -- Send PgUp to tty
* Alt + Ctrl + Mousewheel Up -- Send 5 PgUp's to tty * Alt + Ctrl + Mousewheel Up -- Send 5 PgUp's to tty
* Alt + Shift + Mousewheel Up -- Send Up Arrow to tty * Alt + Shift + Mousewheel Up -- Send Up Arrow to tty
* *
* Mousewheel Down -- Scroll down 1 page * Mousewheel Down -- Scroll down 1 page
* Ctrl + Mousewheel Down -- Scroll down 5 pages * Ctrl + Mousewheel Down -- Scroll down 5 pages
* Shift + Mousewheel Down -- Scroll down 1 line * Shift + Mousewheel Down -- Scroll down 1 line
* Alt + Mousewheel Down -- Send PgDn to tty * Alt + Mousewheel Down -- Send PgDn to tty
* Alt + Ctrl + Mousewheel Down -- Send 5 PgDn's to tty * Alt + Ctrl + Mousewheel Down -- Send 5 PgDn's to tty
* Alt + Shift + Mousewheel Down -- Send Down Arrow to tty * Alt + Shift + Mousewheel Down -- Send Down Arrow to tty
* *
* Note that the number of lines which constitute a "page" is equal to the number * Note that the number of lines which constitute a "page" is equal to the number
* of text rows in the terminal window. The context lines are subtracted out *after* * of text rows in the terminal window. The context lines are subtracted out *after*
* the conversion is done. In other words, scrolling 5 pages means scrolling * the conversion is done. In other words, scrolling 5 pages means scrolling
* (5 * LINES_PER_PAGE) - CONTEXT_LINES * (5 * LINES_PER_PAGE) - CONTEXT_LINES
* _not_ * _not_
* (LINES_PER_PAGE - CONTEXT_LINES) * 5 * (LINES_PER_PAGE - CONTEXT_LINES) * 5
* *
* This is also true for the scroll() function in script.c. * This is also true for the scroll() function in script.c.
*/ */
case Button4: case Button4:
if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) { if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) {
scr_page(UP, (TermWin.nrow * 5) - CONTEXT_LINES); scr_page(UP, (TermWin.nrow * 5) - CONTEXT_LINES);
} else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) { } else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) {
scr_page(UP, 1); scr_page(UP, 1);
} else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) { } else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) {
tt_write("\033[5~", 4); tt_write("\033[5~", 4);
} else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) { } else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) {
tt_write("\033[A", 3); tt_write("\033[A", 3);
} else if (action_check_modifiers((MOD_ALT | MOD_CTRL), ev->xbutton.state)) { } else if (action_check_modifiers((MOD_ALT | MOD_CTRL), ev->xbutton.state)) {
tt_write("\033[5~\033[5~\033[5~\033[5~\033[5~", 20); tt_write("\033[5~\033[5~\033[5~\033[5~\033[5~", 20);
} else { } else {
scr_page(UP, TermWin.nrow - CONTEXT_LINES); scr_page(UP, TermWin.nrow - CONTEXT_LINES);
} }
button_state.last_button_press = 4; button_state.last_button_press = 4;
break; break;
case Button5: case Button5:
if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) { if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) {
scr_page(DN, (TermWin.nrow * 5) - CONTEXT_LINES); scr_page(DN, (TermWin.nrow * 5) - CONTEXT_LINES);
} else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) { } else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) {
scr_page(DN, 1); scr_page(DN, 1);
} else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) { } else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) {
tt_write("\033[6~", 4); tt_write("\033[6~", 4);
} else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) { } else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) {
tt_write("\033[B", 3); tt_write("\033[B", 3);
} else if (action_check_modifiers((MOD_ALT | MOD_CTRL), ev->xbutton.state)) { } else if (action_check_modifiers((MOD_ALT | MOD_CTRL), ev->xbutton.state)) {
tt_write("\033[6~\033[6~\033[6~\033[6~\033[6~", 20); tt_write("\033[6~\033[6~\033[6~\033[6~\033[6~", 20);
} else { } else {
scr_page(DN, TermWin.nrow - CONTEXT_LINES); scr_page(DN, TermWin.nrow - CONTEXT_LINES);
} }
button_state.last_button_press = 5; button_state.last_button_press = 5;
break; break;
#endif #endif
default: default:
break; break;
} }
} }
button_state.button_press = ev->xbutton.time; button_state.button_press = ev->xbutton.time;
@ -757,14 +765,14 @@ handle_button_release(event_t *ev)
if (ev->xbutton.subwindow == None) { if (ev->xbutton.subwindow == None) {
if (button_state.report_mode) { if (button_state.report_mode) {
switch (PrivateModes & PrivMode_mouse_report) { switch (PrivateModes & PrivMode_mouse_report) {
case PrivMode_MouseX10: case PrivMode_MouseX10:
break; break;
case PrivMode_MouseX11: case PrivMode_MouseX11:
ev->xbutton.state = button_state.bypass_keystate; ev->xbutton.state = button_state.bypass_keystate;
ev->xbutton.button = AnyButton; ev->xbutton.button = AnyButton;
mouse_report(&(ev->xbutton)); mouse_report(&(ev->xbutton));
break; break;
} }
return (1); return (1);
} }
@ -777,16 +785,16 @@ handle_button_release(event_t *ev)
selection_extend(ev->xbutton.x, ev->xbutton.y, 0); selection_extend(ev->xbutton.x, ev->xbutton.y, 0);
} }
switch (ev->xbutton.button) { switch (ev->xbutton.button) {
case Button1: case Button1:
case Button3: case Button3:
selection_make(ev->xbutton.time); selection_make(ev->xbutton.time);
break; break;
case Button2: case Button2:
selection_paste(XA_PRIMARY); selection_paste(XA_PRIMARY);
break; break;
default: default:
break; break;
} }
} }
} }
@ -824,7 +832,8 @@ handle_motion_notify(event_t *ev)
unsigned int unused_mask; unsigned int unused_mask;
while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt, MotionNotify, ev)); while (XCheckTypedWindowEvent(Xdisplay, TermWin.vt, MotionNotify, ev));
XQueryPointer(Xdisplay, TermWin.vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); XQueryPointer(Xdisplay, TermWin.vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x),
&(ev->xbutton.y), &unused_mask);
#ifdef MOUSE_THRESHOLD #ifdef MOUSE_THRESHOLD
/* deal with a `jumpy' mouse */ /* deal with a `jumpy' mouse */
if ((ev->xmotion.time - button_state.button_press) > MOUSE_THRESHOLD) if ((ev->xmotion.time - button_state.button_press) > MOUSE_THRESHOLD)
@ -865,8 +874,9 @@ xerror_handler(Display * display, XErrorEvent * event)
strcpy(err_string, ""); strcpy(err_string, "");
XGetErrorText(display, event->error_code, err_string, sizeof(err_string)); XGetErrorText(display, event->error_code, err_string, sizeof(err_string));
print_error("XError in function %s, resource 0x%08x (request %d.%d): %s (error %d)\n", request_code_to_name(event->request_code), print_error("XError in function %s, resource 0x%08x (request %d.%d): %s (error %d)\n",
(int) event->resourceid, event->request_code, event->minor_code, err_string, event->error_code); request_code_to_name(event->request_code), (int) event->resourceid, event->request_code, event->minor_code,
err_string, event->error_code);
#if DEBUG > DEBUG_X11 #if DEBUG > DEBUG_X11
if (DEBUG_LEVEL >= DEBUG_X11) { if (DEBUG_LEVEL >= DEBUG_X11) {
dump_stack_trace(); dump_stack_trace();

View File

@ -166,15 +166,15 @@ font_cache_add(const char *name, unsigned char type, void *info)
font->type = type; font->type = type;
font->ref_cnt = 1; font->ref_cnt = 1;
switch (type) { switch (type) {
case FONT_TYPE_X: case FONT_TYPE_X:
font->fontinfo.xfontinfo = (XFontStruct *) info; font->fontinfo.xfontinfo = (XFontStruct *) info;
break; break;
case FONT_TYPE_TTF: case FONT_TYPE_TTF:
break; break;
case FONT_TYPE_FNLIB: case FONT_TYPE_FNLIB:
break; break;
default: default:
break; break;
} }
D_FONT((" -> Created new cachefont_t struct at %p: \"%s\", %d, %p\n", font, font->name, font->type, font->fontinfo.xfontinfo)); D_FONT((" -> Created new cachefont_t struct at %p: \"%s\", %d, %p\n", font, font->name, font->type, font->fontinfo.xfontinfo));
@ -230,7 +230,8 @@ font_cache_del(const void *info)
update the "next" pointer of the font prior to the one we're actually deleting. */ update the "next" pointer of the font prior to the one we're actually deleting. */
for (current = font_cache; current->next; current = current->next) { for (current = font_cache; current->next; current = current->next) {
if (((current->next->type == FONT_TYPE_X) && (current->next->fontinfo.xfontinfo == (XFontStruct *) info))) { if (((current->next->type == FONT_TYPE_X) && (current->next->fontinfo.xfontinfo == (XFontStruct *) info))) {
D_FONT((" -> Match found at current->next (%8p, current == %8p). Font name is \"%s\"\n", current->next, current, NONULL(current->next->name))); D_FONT((" -> Match found at current->next (%8p, current == %8p). Font name is \"%s\"\n", current->next, current,
NONULL(current->next->name)));
if (--(current->next->ref_cnt) == 0) { if (--(current->next->ref_cnt) == 0) {
D_FONT((" -> Reference count is now 0. Deleting from cache.\n")); D_FONT((" -> Reference count is now 0. Deleting from cache.\n"));
tmp = current->next; tmp = current->next;
@ -315,18 +316,18 @@ font_cache_find_info(const char *name, unsigned char type)
if ((current->type == type) && !strcasecmp(current->name, name)) { if ((current->type == type) && !strcasecmp(current->name, name)) {
D_FONT((" -> Match!\n")); D_FONT((" -> Match!\n"));
switch (type) { switch (type) {
case FONT_TYPE_X: case FONT_TYPE_X:
return ((void *) current->fontinfo.xfontinfo); return ((void *) current->fontinfo.xfontinfo);
break; break;
case FONT_TYPE_TTF: case FONT_TYPE_TTF:
return (NULL); return (NULL);
break; break;
case FONT_TYPE_FNLIB: case FONT_TYPE_FNLIB:
return (NULL); return (NULL);
break; break;
default: default:
return (NULL); return (NULL);
break; break;
} }
} }
} }
@ -398,18 +399,18 @@ load_font(const char *name, const char *fallback, unsigned char type)
font_cache_add_ref(font); font_cache_add_ref(font);
D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt)); D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt));
switch (type) { switch (type) {
case FONT_TYPE_X: case FONT_TYPE_X:
return ((void *) font->fontinfo.xfontinfo); return ((void *) font->fontinfo.xfontinfo);
break; break;
case FONT_TYPE_TTF: case FONT_TYPE_TTF:
return (NULL); return (NULL);
break; break;
case FONT_TYPE_FNLIB: case FONT_TYPE_FNLIB:
return (NULL); return (NULL);
break; break;
default: default:
return (NULL); return (NULL);
break; break;
} }
} }
@ -455,7 +456,8 @@ change_font(int init, const char *fontname)
short idx = 0, old_idx = font_idx; short idx = 0, old_idx = font_idx;
int fh, fw = 0; int fh, fw = 0;
D_FONT(("change_font(%d, \"%s\"): def_font_idx == %u, font_idx == %u\n", init, NONULL(fontname), (unsigned int) def_font_idx, (unsigned int) font_idx)); D_FONT(("change_font(%d, \"%s\"): def_font_idx == %u, font_idx == %u\n", init, NONULL(fontname), (unsigned int) def_font_idx,
(unsigned int) font_idx));
if (init) { if (init) {
ASSERT(etfonts != NULL); ASSERT(etfonts != NULL);
@ -473,46 +475,46 @@ change_font(int init, const char *fontname)
ASSERT(fontname != NULL); ASSERT(fontname != NULL);
switch (*fontname) { switch (*fontname) {
/* Empty font name. Reset to default. */ /* Empty font name. Reset to default. */
case '\0': case '\0':
font_idx = def_font_idx; font_idx = def_font_idx;
fontname = NULL; fontname = NULL;
break; break;
/* A font escape sequence. See which one it is. */ /* A font escape sequence. See which one it is. */
case FONT_CMD: case FONT_CMD:
idx = atoi(++fontname); idx = atoi(++fontname);
switch (*fontname) { switch (*fontname) {
case '+': case '+':
NEXT_FONT(idx); NEXT_FONT(idx);
break; break;
case '-': case '-':
PREV_FONT(idx); PREV_FONT(idx);
break; break;
default: default:
if (*fontname != '\0' && !isdigit(*fontname)) if (*fontname != '\0' && !isdigit(*fontname))
return; /* It's not a number. Punt. */ return; /* It's not a number. Punt. */
/* Set current font to font N */ /* Set current font to font N */
BOUND(idx, 0, (font_cnt - 1)); BOUND(idx, 0, (font_cnt - 1));
font_idx = idx; font_idx = idx;
break; break;
} }
/* NULL out the fontname so we don't try to load it */ /* NULL out the fontname so we don't try to load it */
fontname = NULL; fontname = NULL;
break; break;
default: default:
/* Change to the named font. See if we already have it, and if so, just set the index. */ /* Change to the named font. See if we already have it, and if so, just set the index. */
for (idx = 0; idx < font_cnt; idx++) { for (idx = 0; idx < font_cnt; idx++) {
if (!strcasecmp(etfonts[idx], fontname)) { if (!strcasecmp(etfonts[idx], fontname)) {
font_idx = idx; font_idx = idx;
fontname = NULL; fontname = NULL;
break; break;
} }
} }
break; break;
} }
/* If we get here with a non-NULL fontname, we have to load a new font. Rats. */ /* If we get here with a non-NULL fontname, we have to load a new font. Rats. */
@ -588,7 +590,8 @@ change_font(int init, const char *fontname)
TermWin.fprop = 1; /* Proportional font */ TermWin.fprop = 1; /* Proportional font */
/* For proportional fonts with large size variations, do some math-fu to try and help the appearance */ /* For proportional fonts with large size variations, do some math-fu to try and help the appearance */
if (TermWin.fprop && (BITFIELD_IS_SET(vt_options, VT_OPTIONS_PROPORTIONAL)) && TermWin.font->per_char && (TermWin.font->max_bounds.width - TermWin.font->min_bounds.width >= 3)) { if (TermWin.fprop && (BITFIELD_IS_SET(vt_options, VT_OPTIONS_PROPORTIONAL)) && TermWin.font->per_char
&& (TermWin.font->max_bounds.width - TermWin.font->min_bounds.width >= 3)) {
int cw, n = 0, sum = 0, sumsq = 0, min_w, max_w; int cw, n = 0, sum = 0, sumsq = 0, min_w, max_w;
unsigned int i; unsigned int i;
double dev; double dev;
@ -610,7 +613,8 @@ change_font(int init, const char *fontname)
/* Final font width is the average width plus 2 standard /* Final font width is the average width plus 2 standard
deviations, but no larger than the font's max width */ deviations, but no larger than the font's max width */
fw = ((sum / n) + (((int) dev) << 1)); fw = ((sum / n) + (((int) dev) << 1));
D_FONT(("Proportional font optimizations: Average width %d, standard deviation %3.2f, new width %d\n", (sum / n), dev, fw)); D_FONT(("Proportional font optimizations: Average width %d, standard deviation %3.2f, new width %d\n", (sum / n), dev,
fw));
UPPER_BOUND(fw, max_w); UPPER_BOUND(fw, max_w);
} else { } else {
LOWER_BOUND(fw, TermWin.font->max_bounds.width); LOWER_BOUND(fw, TermWin.font->max_bounds.width);

View File

@ -109,7 +109,8 @@ static char elot_xlat_plain[] =
"65-122:193,194,216,196,197,214,195,199,201,206,202,203,204,205,207,208,81,209,211,212,200,217,87,215,213,198,91,92,93,94,95,96,225,226,248,228,229,246,227,231,233,238,234,235,236,237,239,240,113,241,243,244,232,249,242,247,245,230"; "65-122:193,194,216,196,197,214,195,199,201,206,202,203,204,205,207,208,81,209,211,212,200,217,87,215,213,198,91,92,93,94,95,96,225,226,248,228,229,246,227,231,233,238,234,235,236,237,239,240,113,241,243,244,232,249,242,247,245,230";
/* c and s give copyright and section sign */ /* 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," 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"; /*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[] = static char elot_xlat_uml[] =
@ -286,10 +287,10 @@ kstate_add_switcher(char *str)
return; return;
switcher = &pStateNow->switcher[pStateNow->num_switcher]; switcher = &pStateNow->switcher[pStateNow->num_switcher];
switch (switcher->type = str[0]) { switch (switcher->type = str[0]) {
case 'A': /* ascii eg: A;:2 */ case 'A': /* ascii eg: A;:2 */
switcher->code = str[1]; switcher->code = str[1];
switcher->nextstate = atoi(&str[3]); switcher->nextstate = atoi(&str[3]);
break; break;
} }
switcher->on = 0; switcher->on = 0;
pStateNow->num_switcher++; pStateNow->num_switcher++;

View File

@ -185,7 +185,8 @@ ns_new_hop(int lp, char *fw, int fp, int delay, _ns_sess * s)
if (s) { if (s) {
/* see if we already have a matching hop. */ /* see if we already have a matching hop. */
while (h && !(((h->localport == lp) || (!lp)) && (!strcmp(h->fw, fw)) && (h->fwport == fp) && (h->sess->port == s->port) && (!strcmp(h->sess->host, s->host)))) while (h && !(((h->localport == lp) || (!lp)) && (!strcmp(h->fw, fw)) && (h->fwport == fp) && (h->sess->port == s->port)
&& (!strcmp(h->sess->host, s->host))))
h = h->next; h = h->next;
if (h) { if (h) {
@ -277,7 +278,9 @@ ns_dst_hop(_ns_hop ** ss, _ns_sess * sp)
while (p && ((p == sp) || (p->port != sp->port) || (strcmp(p->host, sp->host)))) while (p && ((p == sp) || (p->port != sp->port) || (strcmp(p->host, sp->host))))
p = p->next; p = p->next;
if (!p) if (!p)
ns_desc_hop(s, NS_PREFIX "ns_dst_sess: Leak alert -- found a hop that is only\n referenced once, but has a refcount > 1. Hop data follow"); ns_desc_hop(s,
NS_PREFIX
"ns_dst_sess: Leak alert -- found a hop that is only\n referenced once, but has a refcount > 1. Hop data follow");
else else
s->sess = p; s->sess = p;
} }
@ -800,7 +803,10 @@ ns_desc_twin(_ns_sess * sess, char *doc)
} }
D_ESCREEN(("%s: twin status (%s) is %d-%s, %d-%s\n", doc, sess->twin_str, D_ESCREEN(("%s: twin status (%s) is %d-%s, %d-%s\n", doc, sess->twin_str,
Tw_Errno(sess->twin), Tw_Errno(sess->twin),
Tw_StrError(sess->twin, Tw_Errno(sess->twin)), Tw_ErrnoDetail(sess->twin), Tw_StrErrorDetail(sess->twin, Tw_Errno(sess->twin), Tw_ErrnoDetail(sess->twin)))); Tw_StrError(sess->twin, Tw_Errno(sess->twin)), Tw_ErrnoDetail(sess->twin), Tw_StrErrorDetail(sess->twin,
Tw_Errno(sess->twin),
Tw_ErrnoDetail(sess->
twin))));
#else #else
USE_VAR(sess); USE_VAR(sess);
USE_VAR(doc); USE_VAR(doc);
@ -827,7 +833,8 @@ ns_desc_hop(_ns_hop * h, char *doc)
D_ESCREEN(("%s:\n", doc)); D_ESCREEN(("%s:\n", doc));
D_ESCREEN(("tunnel from localhost:%d to %s:%d to %s:%d is %s. (delay %d, %d ref%s)\n", D_ESCREEN(("tunnel from localhost:%d to %s:%d to %s:%d is %s. (delay %d, %d ref%s)\n",
h->localport, h->fw, h->fwport, h->sess->host, h->sess->port, h->established ? "up" : "down", h->delay, h->refcount, h->refcount == 1 ? "" : "s")); h->localport, h->fw, h->fwport, h->sess->host, h->sess->port, h->established ? "up" : "down", h->delay, h->refcount,
h->refcount == 1 ? "" : "s"));
} }
@ -849,7 +856,8 @@ ns_desc_sess(_ns_sess * sess, char *doc)
D_ESCREEN(("%s: (efuns@%p)\t (user %s) local %s", doc, sess->efuns, sess->user, sess->proto)); D_ESCREEN(("%s: (efuns@%p)\t (user %s) local %s", doc, sess->efuns, sess->user, sess->proto));
else { else {
D_ESCREEN(("%s: (efuns@%p)\t %s://%s%s%s@%s", D_ESCREEN(("%s: (efuns@%p)\t %s://%s%s%s@%s",
doc, sess->efuns, sess->proto ? sess->proto : "???", sess->user, sess->pass ? ":" : "", sess->pass ? sess->pass : "", sess->host)); doc, sess->efuns, sess->proto ? sess->proto : "???", sess->user, sess->pass ? ":" : "",
sess->pass ? sess->pass : "", sess->host));
if (sess->port != NS_DFLT_SSH_PORT) if (sess->port != NS_DFLT_SSH_PORT)
D_ESCREEN((":%s", sess->port)); D_ESCREEN((":%s", sess->port));
} }
@ -1093,17 +1101,21 @@ ns_attach_ssh(_ns_sess ** sp)
if (sess->hop) { if (sess->hop) {
if (sess->hop->established == NS_HOP_DOWN) { /* the nightmare foe */ if (sess->hop->established == NS_HOP_DOWN) { /* the nightmare foe */
ret = snprintf(cmd, NS_MAXCMD, "%s %s -p %d -L %d:%s:%d %s@%s", ret = snprintf(cmd, NS_MAXCMD, "%s %s -p %d -L %d:%s:%d %s@%s",
NS_SSH_CALL, NS_SSH_TUNNEL_OPTS, sess->hop->fwport, sess->hop->localport, sess->host, sess->port, sess->user, sess->hop->fw); NS_SSH_CALL, NS_SSH_TUNNEL_OPTS, sess->hop->fwport, sess->hop->localport, sess->host, sess->port,
sess->user, sess->hop->fw);
if (ret < 0 || ret > NS_MAXCMD) if (ret < 0 || ret > NS_MAXCMD)
return NS_FAIL; return NS_FAIL;
ns_run(sess->efuns, cmd); ns_run(sess->efuns, cmd);
sleep(sess->hop->delay); sleep(sess->hop->delay);
} }
ret = snprintf(cmd, NS_MAXCMD, "%s %s -p %d %s@localhost \"%s%s\"", ret = snprintf(cmd, NS_MAXCMD, "%s %s -p %d %s@localhost \"%s%s\"",
NS_SSH_CALL, NS_SSH_OPTS, sess->hop->localport, sess->user, call, ((sess->backend == NS_MODE_SCREEN) || (sess->backend == NS_MODE_NEGOTIATE)) ? esc : ""); NS_SSH_CALL, NS_SSH_OPTS, sess->hop->localport, sess->user, call, ((sess->backend == NS_MODE_SCREEN)
|| (sess->backend ==
NS_MODE_NEGOTIATE)) ? esc : "");
} else { } else {
ret = snprintf(cmd, NS_MAXCMD, "%s %s -p %d %s@%s \"%s%s\"", NS_SSH_CALL, NS_SSH_OPTS, sess->port, sess->user, sess->host, call, ret =
((sess->backend == NS_MODE_SCREEN) || (sess->backend == NS_MODE_NEGOTIATE)) ? esc : ""); snprintf(cmd, NS_MAXCMD, "%s %s -p %d %s@%s \"%s%s\"", NS_SSH_CALL, NS_SSH_OPTS, sess->port, sess->user, sess->host,
call, ((sess->backend == NS_MODE_SCREEN) || (sess->backend == NS_MODE_NEGOTIATE)) ? esc : "");
} }
ns_free(&call); ns_free(&call);
@ -1139,21 +1151,21 @@ ns_attach_by_sess(_ns_sess ** sp, int *err)
(void) ns_sess_init(sess); (void) ns_sess_init(sess);
switch (sess->where) { switch (sess->where) {
case NS_LCL: case NS_LCL:
sess->fd = ns_attach_lcl(&sess); sess->fd = ns_attach_lcl(&sess);
break; break;
case NS_SU: /* (fixme) uses ssh, should use su */ case NS_SU: /* (fixme) uses ssh, should use su */
/* local session, but for a different uid. */ /* local session, but for a different uid. */
/* FALL-THROUGH */ /* FALL-THROUGH */
case NS_SSH: case NS_SSH:
if (!sess->delay) { if (!sess->delay) {
sess->delay = NS_INIT_DELAY ? NS_INIT_DELAY : 1; sess->delay = NS_INIT_DELAY ? NS_INIT_DELAY : 1;
} }
sess->fd = ns_attach_ssh(&sess); sess->fd = ns_attach_ssh(&sess);
break; break;
default: default:
*err = NS_UNKNOWN_LOC; *err = NS_UNKNOWN_LOC;
goto fail; goto fail;
} }
D_ESCREEN(("ns_attach_by_sess: screen session-fd is %d, ^%c-%c\n", sess->fd, sess->escape + 'A' - 1, sess->literal)); D_ESCREEN(("ns_attach_by_sess: screen session-fd is %d, ^%c-%c\n", sess->fd, sess->escape + 'A' - 1, sess->literal));
@ -1316,9 +1328,9 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd)
} }
} else } else
# endif # endif
{ {
NOP; NOP;
} }
while (*r && (f || *r != ' ')) { while (*r && (f || *r != ' ')) {
if (*r == '\"') if (*r == '\"')
f = 1 - f; f = 1 - f;
@ -1382,11 +1394,11 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd)
goto fail; goto fail;
} else { } else {
char *loc[] = { char *loc[] = {
"/usr/local/etc/screenrc", /* official */ "/usr/local/etc/screenrc", /* official */
"/etc/screenrc", /* actual (on SuSE) */ "/etc/screenrc", /* actual (on SuSE) */
"/usr/etc/screenrc", "/usr/etc/screenrc",
"/opt/etc/screenrc", "/opt/etc/screenrc",
"/etc/screen/screenrc" "/etc/screen/screenrc"
}; };
int n, nloc = sizeof(loc) / sizeof(char *); int n, nloc = sizeof(loc) / sizeof(char *);
@ -1491,7 +1503,8 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd)
if (hop && strlen(hop)) { if (hop && strlen(hop)) {
sess->hop = ns_parse_hop(sess, hop); sess->hop = ns_parse_hop(sess, hop);
if (sess->hop && (!strcmp(sess->host, sess->hop->fw) || !strcmp(sess->host, "localhost") || !strcmp(sess->host, "127.0.0.1"))) if (sess->hop
&& (!strcmp(sess->host, sess->hop->fw) || !strcmp(sess->host, "localhost") || !strcmp(sess->host, "127.0.0.1")))
D_ESCREEN(("ns_attach_by_URL: routing in circles...\n")); D_ESCREEN(("ns_attach_by_URL: routing in circles...\n"));
} }
@ -1559,12 +1572,12 @@ ns_tog_disp(_ns_sess * s)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
return ns_screen_command(s, "\x01\x01"); return ns_screen_command(s, "\x01\x01");
break; break;
#endif #endif
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -1581,28 +1594,28 @@ ns_go2_disp(_ns_sess * s, int d)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
b[1] = '0' + d; b[1] = '0' + d;
return ns_screen_command(s, b); return ns_screen_command(s, b);
break; break;
#endif #endif
#ifdef NS_HAVE_TWIN #ifdef NS_HAVE_TWIN
case NS_MODE_TWIN: case NS_MODE_TWIN:
{ {
tscreen ts = Tw_FirstScreen(s->twin); tscreen ts = Tw_FirstScreen(s->twin);
printf("screen: %p\n", ts); printf("screen: %p\n", ts);
while (d-- && ts) while (d-- && ts)
ts = Tw_NextObj(s->twin, ts); ts = Tw_NextObj(s->twin, ts);
if (ts) { if (ts) {
Tw_RaiseScreen(s->twin, ts); Tw_RaiseScreen(s->twin, ts);
return NS_SUCC; return NS_SUCC;
} }
} }
break; break;
#endif #endif
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -1617,13 +1630,13 @@ ns_mon_disp(_ns_sess * s, int no, int quiet)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
if (no >= 0) if (no >= 0)
ns_go2_disp(s, no); ns_go2_disp(s, no);
if (quiet == NS_MON_TOGGLE_QUIET) if (quiet == NS_MON_TOGGLE_QUIET)
s->flags |= NS_SESS_NO_MON_MSG; s->flags |= NS_SESS_NO_MON_MSG;
return ns_screen_command(s, "\x01M"); return ns_screen_command(s, "\x01M");
break; break;
#endif #endif
} }
return NS_FAIL; return NS_FAIL;
@ -1638,13 +1651,13 @@ ns_sbb_disp(_ns_sess * s, int no)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
ns_go2_disp(s, no); ns_go2_disp(s, no);
return ns_screen_command(s, "\x01\x1b"); return ns_screen_command(s, "\x01\x1b");
break; break;
#endif #endif
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -1705,21 +1718,21 @@ ns_add_disp(_ns_sess * s, int after, char *name)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
if (after >= 0) if (after >= 0)
ns_go2_disp(s, after); ns_go2_disp(s, after);
if (ns_screen_command(s, "\x01\x03") == NS_SUCC) { if (ns_screen_command(s, "\x01\x03") == NS_SUCC) {
if (!name || strlen(name)) if (!name || strlen(name))
ns_ren_disp(s, -2, name); ns_ren_disp(s, -2, name);
ret = ns_mon_disp(s, -2, NS_MON_TOGGLE_QUIET); ret = ns_mon_disp(s, -2, NS_MON_TOGGLE_QUIET);
} }
break; break;
#endif #endif
#ifdef NS_HAVE_TWIN #ifdef NS_HAVE_TWIN
case NS_MODE_TWIN: case NS_MODE_TWIN:
ret = ns_twin_control(s, "twin", TW_MSG_CONTROL_OPEN); ret = ns_twin_control(s, "twin", TW_MSG_CONTROL_OPEN);
printf("ns_add_disp: twin add window after %d -> %d\n", after, ret); printf("ns_add_disp: twin add window after %d -> %d\n", after, ret);
break; break;
#endif #endif
} }
return ret; return ret;
@ -1754,10 +1767,10 @@ ns_mov_disp(_ns_sess * s, int fm, int to)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
D_ESCREEN(("ns_mov_disp: move #%d to #%d\n", fm, to)); D_ESCREEN(("ns_mov_disp: move #%d to #%d\n", fm, to));
ns_mov_screen_disp(s, fm, to); ns_mov_screen_disp(s, fm, to);
break; break;
#endif #endif
} }
return NS_FAIL; return NS_FAIL;
@ -1776,8 +1789,8 @@ ns_rsz_disp(_ns_sess * s, int d, int w, int h)
} }
switch (s->backend) { switch (s->backend) {
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -1810,10 +1823,10 @@ ns_rem_disp(_ns_sess * s, int d, int ask)
if (*i == 'y' || *i == 'Y') { if (*i == 'y' || *i == 'Y') {
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
ns_go2_disp(s, d); ns_go2_disp(s, d);
ret = ns_screen_command(s, "\x01ky\r"); ret = ns_screen_command(s, "\x01ky\r");
break; break;
#endif #endif
} }
} }
@ -1866,17 +1879,17 @@ ns_ren_disp(_ns_sess * s, int d, char *name)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
if ((n = MALLOC(strlen(i ? i : name) + l + 1))) { if ((n = MALLOC(strlen(i ? i : name) + l + 1))) {
if (d >= 0) if (d >= 0)
ns_go2_disp(s, d); ns_go2_disp(s, d);
strcpy(&n[l], i ? i : name); /* copy new name */ strcpy(&n[l], i ? i : name); /* copy new name */
while (l) /* prepend backspaces */ while (l) /* prepend backspaces */
n[--l] = '\x08'; n[--l] = '\x08';
ret = ns_screen_xcommand(s, 'A', n); /* rename */ ret = ns_screen_xcommand(s, 'A', n); /* rename */
FREE(n); FREE(n);
} }
break; break;
#endif #endif
} }
@ -1895,8 +1908,8 @@ ns_log_disp(_ns_sess * s, int d, char *logfile)
} }
switch (s->backend) { switch (s->backend) {
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -1935,13 +1948,13 @@ ns_rel_region(_ns_sess * s, _ns_disp * d, int n)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
if (n < 0) if (n < 0)
return NS_FAIL; return NS_FAIL;
do { do {
ret = ns_screen_command(s, "\x01\x09"); ret = ns_screen_command(s, "\x01\x09");
} while (--n && (ret == NS_SUCC)); } while (--n && (ret == NS_SUCC));
break; break;
#endif #endif
} }
return ret; return ret;
@ -1962,9 +1975,9 @@ ns_add_region(_ns_sess * s, _ns_disp * d, int after, char *name)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
ret = ns_screen_command(s, "\x01S"); ret = ns_screen_command(s, "\x01S");
break; break;
#endif #endif
} }
return ret; return ret;
@ -1995,9 +2008,9 @@ ns_rem_region(_ns_sess * s, _ns_disp * d, int r, int ask)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
ret = ns_screen_command(s, "\x01X"); ret = ns_screen_command(s, "\x01X");
break; break;
#endif #endif
} }
return ret; return ret;
@ -2017,9 +2030,9 @@ ns_one_region(_ns_sess * s, _ns_disp * d, int r)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
ret = ns_screen_command(s, "\x01Q"); ret = ns_screen_command(s, "\x01Q");
break; break;
#endif #endif
} }
return ret; return ret;
@ -2109,11 +2122,11 @@ ns_upd_stat(_ns_sess * s)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
return ns_screen_command(s, NS_SCREEN_UPDATE); return ns_screen_command(s, NS_SCREEN_UPDATE);
#endif #endif
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -2144,20 +2157,20 @@ ns_statement(_ns_sess * s, char *c)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
if ((ret = ns_parse_screen_cmd(s, i ? i : c, NS_ESC_INTERACTIVE)) == NS_SUCC) { if ((ret = ns_parse_screen_cmd(s, i ? i : c, NS_ESC_INTERACTIVE)) == NS_SUCC) {
if (s->escape != x) { if (s->escape != x) {
y = s->escape; y = s->escape;
s->escape = x; s->escape = x;
} }
ret = ns_screen_xcommand(s, NS_SCREEN_CMD, i ? i : c); ret = ns_screen_xcommand(s, NS_SCREEN_CMD, i ? i : c);
s->escape = y; s->escape = y;
} else if (ret == NS_NOT_ALLOWED) { } else if (ret == NS_NOT_ALLOWED) {
ns_inp_dial(s, "Sorry, David, I cannot allow that.", 0, NULL, NULL); ns_inp_dial(s, "Sorry, David, I cannot allow that.", 0, NULL, NULL);
} }
#endif #endif
default: default:
ret = NS_FAIL; ret = NS_FAIL;
} }
if (i) if (i)
@ -2177,11 +2190,11 @@ ns_reset(_ns_sess * s, int type)
switch (s->backend) { switch (s->backend) {
#ifdef NS_HAVE_SCREEN #ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
return ns_screen_command(s, NS_SCREEN_INIT); return ns_screen_command(s, NS_SCREEN_INIT);
#endif #endif
default: default:
return NS_FAIL; return NS_FAIL;
} }
} }
@ -2199,8 +2212,8 @@ ns_get_url(_ns_sess * s, int d)
return NULL; return NULL;
} }
l = ((s->proto) ? strlen(s->proto) + 3 : 0) + strlen(s->user) + 1 + strlen(s->host) + 1 + 5 + 1 + ((s->rsrc) ? strlen(s->rsrc) : 0) + 7 + (s->name ? strlen(s->name) + 4 : 0) + l = ((s->proto) ? strlen(s->proto) + 3 : 0) + strlen(s->user) + 1 + strlen(s->host) + 1 + 5 + 1 +
1; ((s->rsrc) ? strlen(s->rsrc) : 0) + 7 + (s->name ? strlen(s->name) + 4 : 0) + 1;
if ((u = MALLOC(l + 1))) { if ((u = MALLOC(l + 1))) {
if (!s->escape) { if (!s->escape) {
@ -2219,8 +2232,9 @@ ns_get_url(_ns_sess * s, int d)
lit[0] = s->literal; lit[0] = s->literal;
lit[1] = '\0'; lit[1] = '\0';
} }
r = snprintf(u, l, "%s%s%s@%s:%d/%s%s%s%s%s%s", s->proto ? s->proto : "", s->proto ? "://" : "", s->user, s->host, s->port, ((s->rsrc) ? s->rsrc : ""), r = snprintf(u, l, "%s%s%s@%s:%d/%s%s%s%s%s%s", s->proto ? s->proto : "", s->proto ? "://" : "", s->user, s->host, s->port,
((s->escape) ? "+-e" : ""), esc, ((s->escape) ? lit : ""), ((s->name) ? "+-x+" : ""), ((s->name) ? s->name : "")); ((s->rsrc) ? s->rsrc : ""), ((s->escape) ? "+-e" : ""), esc, ((s->escape) ? lit : ""),
((s->name) ? "+-x+" : ""), ((s->name) ? s->name : ""));
D_ESCREEN(("ns_get_url: URL is %s\n", u)); D_ESCREEN(("ns_get_url: URL is %s\n", u));
if ((r >= 0) && (r < l)) { if ((r >= 0) && (r < l)) {
return u; return u;
@ -2770,17 +2784,17 @@ ns_parse_screen_key(_ns_sess * s, char c)
D_ESCREEN(("screen_key: ^%c-%c %d\n", s->escape + 'A' - 1, c, c)); D_ESCREEN(("screen_key: ^%c-%c %d\n", s->escape + 'A' - 1, c, c));
switch (c) { switch (c) {
case NS_SCREEN_CMD: /* send command (statement) to screen server */ case NS_SCREEN_CMD: /* send command (statement) to screen server */
ns_statement(s, NULL); ns_statement(s, NULL);
break; break;
case NS_SCREEN_RENAME: /* rename current display */ case NS_SCREEN_RENAME: /* rename current display */
ret = ns_ren_disp(s, -1, NULL); ret = ns_ren_disp(s, -1, NULL);
break; break;
case NS_SCREEN_KILL: case NS_SCREEN_KILL:
ret = ns_rem_disp(s, -1, TRUE); ret = ns_rem_disp(s, -1, TRUE);
break; break;
default: default:
ret = ns_screen_command(s, b); ret = ns_screen_command(s, b);
} }
return ret; return ret;
@ -2853,7 +2867,8 @@ ns_screen_weird(_ns_sess * screen, long type, char *doc)
"send the result of 'screen --version' to <scream@azundris.com>\n" "send the result of 'screen --version' to <scream@azundris.com>\n"
"(together with your ~/.screenrc and /etc/screenrc if present).\n" "(together with your ~/.screenrc and /etc/screenrc if present).\n"
"If at all possible, please also run 'Eterm -e screen' and make\n" "If at all possible, please also run 'Eterm -e screen' and make\n"
"a screenshot of the offending window (and the window only, the\n" "beauty of your desktop is not relevant to this investigation. : ).\n", doc, type); "a screenshot of the offending window (and the window only, the\n"
"beauty of your desktop is not relevant to this investigation. : ).\n", doc, type);
} }
(void) ns_upd_stat(screen); (void) ns_upd_stat(screen);
return NS_FAIL; return NS_FAIL;
@ -3033,7 +3048,8 @@ ns_parse_screen_msg(_ns_sess * screen, char *p)
else if (!strcmp("am", vtype)) else if (!strcmp("am", vtype))
screen->backend = NS_MODE_SCREAM; screen->backend = NS_MODE_SCREAM;
p = NULL; p = NULL;
D_ESCREEN(("ns_parse_screen_msg: scre%s %d.%2d.%2d %s a/o %s -> mode %d\n", vtype, ma, mi, mu, vrem, vdate, screen->backend)); D_ESCREEN(("ns_parse_screen_msg: scre%s %d.%2d.%2d %s a/o %s -> mode %d\n", vtype, ma, mi, mu, vrem, vdate,
screen->backend));
} else if (!strcmp(p, NS_SCREEN_NO_DEBUG)) } else if (!strcmp(p, NS_SCREEN_NO_DEBUG))
p = "debug info was not compiled into \"screen\"..."; p = "debug info was not compiled into \"screen\"...";
else if (!strncmp(p, NS_SCREEN_DK_CMD_T, strlen(NS_SCREEN_DK_CMD_T))) { else if (!strncmp(p, NS_SCREEN_DK_CMD_T, strlen(NS_SCREEN_DK_CMD_T))) {
@ -3080,8 +3096,8 @@ ns_parse_screen(_ns_sess * screen, int force, int width, char *p)
static int l = sizeof(NS_SCREEN_FLAGS); static int l = sizeof(NS_SCREEN_FLAGS);
size_t status_blanks = 0; /* status-bar overflow? */ size_t status_blanks = 0; /* status-bar overflow? */
int ret = NS_SUCC, tmp, parsed, /* no of *visible* elements in status line */ int ret = NS_SUCC, tmp, parsed, /* no of *visible* elements in status line */
n, /* screen's index (immutable, sparse) */ n, /* screen's index (immutable, sparse) */
r; /* real index (r'th element) */ r; /* real index (r'th element) */
_ns_efuns *efuns; _ns_efuns *efuns;
_ns_disp *disp = NULL, *d2 = NULL; _ns_disp *disp = NULL, *d2 = NULL;
@ -3099,9 +3115,9 @@ ns_parse_screen(_ns_sess * screen, int force, int width, char *p)
while (p2 > p && *p2 == ' ') { while (p2 > p && *p2 == ' ') {
status_blanks++; status_blanks++;
*(p2--) = '\0'; *(p2--) = '\0';
} /* p2 now points behind last item */ } /* p2 now points behind last item */
} else { } else {
*p2 = 0; /* make darn sure it's NUL-terminated */ *p2 = 0; /* make darn sure it's NUL-terminated */
} }
D_ESCREEN(("parse_screen: screen sends (%d) ::%s::\n", strlen(p), p)); D_ESCREEN(("parse_screen: screen sends (%d) ::%s::\n", strlen(p), p));

View File

@ -71,24 +71,25 @@ grab_pointer(Window win)
D_EVENTS(("Grabbing control of pointer for window 0x%08x.\n", win)); D_EVENTS(("Grabbing control of pointer for window 0x%08x.\n", win));
success = XGrabPointer(Xdisplay, win, False, success = XGrabPointer(Xdisplay, win, False,
EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask |
| Button1MotionMask | Button2MotionMask | Button3MotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); ButtonReleaseMask | Button1MotionMask | Button2MotionMask | Button3MotionMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime);
if (success != GrabSuccess) { if (success != GrabSuccess) {
switch (success) { switch (success) {
case GrabNotViewable: case GrabNotViewable:
D_MENU((" -> Unable to grab pointer -- Grab window is not viewable.\n")); D_MENU((" -> Unable to grab pointer -- Grab window is not viewable.\n"));
break; break;
case AlreadyGrabbed: case AlreadyGrabbed:
D_MENU((" -> Unable to grab pointer -- Pointer is already grabbed by another client.\n")); D_MENU((" -> Unable to grab pointer -- Pointer is already grabbed by another client.\n"));
break; break;
case GrabFrozen: case GrabFrozen:
D_MENU((" -> Unable to grab pointer -- Pointer is frozen by another grab.\n")); D_MENU((" -> Unable to grab pointer -- Pointer is frozen by another grab.\n"));
break; break;
case GrabInvalidTime: case GrabInvalidTime:
D_MENU((" -> Unable to grab pointer -- Invalid grab time.\n")); D_MENU((" -> Unable to grab pointer -- Invalid grab time.\n"));
break; break;
default: default:
break; break;
} }
} }
} }
@ -259,10 +260,12 @@ menu_handle_button_press(event_t *ev)
ungrab_pointer(); ungrab_pointer();
menu_reset_all(menu_list); menu_reset_all(menu_list);
current_menu = NULL; current_menu = NULL;
XTranslateCoordinates(Xdisplay, ev->xany.window, Xroot, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_win); XTranslateCoordinates(Xdisplay, ev->xany.window, Xroot, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y),
&unused_win);
child_win = find_window_by_coords(Xroot, 0, 0, ev->xbutton.x, ev->xbutton.y); child_win = find_window_by_coords(Xroot, 0, 0, ev->xbutton.x, ev->xbutton.y);
if (child_win != None) { if (child_win != None) {
XTranslateCoordinates(Xdisplay, Xroot, child_win, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_win); XTranslateCoordinates(Xdisplay, Xroot, child_win, ev->xbutton.x, ev->xbutton.y, &(ev->xbutton.x), &(ev->xbutton.y),
&unused_win);
ev->xany.window = child_win; ev->xany.window = child_win;
D_EVENTS(("Sending synthetic event on to window 0x%08x at %d, %d\n", child_win, ev->xbutton.x, ev->xbutton.y)); D_EVENTS(("Sending synthetic event on to window 0x%08x at %d, %d\n", child_win, ev->xbutton.x, ev->xbutton.y));
XSendEvent(Xdisplay, child_win, False, 0, ev); XSendEvent(Xdisplay, child_win, False, 0, ev);
@ -292,7 +295,8 @@ menu_handle_button_release(event_t *ev)
if (current_menu && (current_menu->state & MENU_STATE_IS_DRAGGING)) { if (current_menu && (current_menu->state & MENU_STATE_IS_DRAGGING)) {
/* Dragging-and-release mode */ /* Dragging-and-release mode */
D_MENU(("Drag-and-release mode, detected release. Button press time is %lu, release time is %lu\n", button_press_time, ev->xbutton.time)); D_MENU(("Drag-and-release mode, detected release. Button press time is %lu, release time is %lu\n", button_press_time,
ev->xbutton.time));
ungrab_pointer(); ungrab_pointer();
if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) { if (button_press_time && (ev->xbutton.time - button_press_time > MENU_CLICK_TIME)) {
@ -317,7 +321,8 @@ menu_handle_button_release(event_t *ev)
} else { } else {
/* Single-click mode */ /* Single-click mode */
D_MENU(("Single click mode, detected click. Button press time is %lu, release time is %lu\n", button_press_time, ev->xbutton.time)); D_MENU(("Single click mode, detected click. Button press time is %lu, release time is %lu\n", button_press_time,
ev->xbutton.time));
if (current_menu && (ev->xbutton.x >= 0) && (ev->xbutton.y >= 0) && (ev->xbutton.x < current_menu->w) if (current_menu && (ev->xbutton.x >= 0) && (ev->xbutton.y >= 0) && (ev->xbutton.x < current_menu->w)
&& (ev->xbutton.y < current_menu->h)) { && (ev->xbutton.y < current_menu->h)) {
/* Click inside the menu window. Activate the current item. */ /* Click inside the menu window. Activate the current item. */
@ -333,7 +338,8 @@ menu_handle_button_release(event_t *ev)
} }
} }
} }
} else if (!(button_press_time && (ev->xbutton.time - button_press_time < MENU_CLICK_TIME)) || (button_press_x && button_press_y)) { } else if (!(button_press_time && (ev->xbutton.time - button_press_time < MENU_CLICK_TIME))
|| (button_press_x && button_press_y)) {
/* Single click which lasted too long, or the second click occured outside the menu */ /* Single click which lasted too long, or the second click occured outside the menu */
ungrab_pointer(); ungrab_pointer();
/* Reset the state of the menu system. */ /* Reset the state of the menu system. */
@ -468,12 +474,16 @@ menu_t *menu_create(char *title)
MEMSET(menu, 0, sizeof(menu_t)); MEMSET(menu, 0, sizeof(menu_t));
menu->title = STRDUP(title ? title : ""); menu->title = STRDUP(title ? title : "");
menu->win = XCreateWindow(Xdisplay, Xroot, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr); menu->win =
XCreateWindow(Xdisplay, Xroot, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr);
XDefineCursor(Xdisplay, menu->win, cursor); XDefineCursor(Xdisplay, menu->win, cursor);
XSelectInput(Xdisplay, menu->win, mask); XSelectInput(Xdisplay, menu->win, mask);
XStoreName(Xdisplay, menu->win, menu->title); XStoreName(Xdisplay, menu->win, menu->title);
menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr); menu->swin =
XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr);
menu->gc = LIBAST_X_CREATE_GC(0, NULL); menu->gc = LIBAST_X_CREATE_GC(0, NULL);
menuitem_clear_current(menu); menuitem_clear_current(menu);
@ -669,14 +679,16 @@ menuitem_change_current(menuitem_t *item)
current = menuitem_get_current(current_menu); current = menuitem_get_current(current_menu);
if (current != item) { if (current != item) {
D_MENU(("Changing current item in menu \"%s\" from \"%s\" to \"%s\"\n", current_menu->title, (current ? current->text : "(NULL)"), (item ? item->text : "(NULL)"))); D_MENU(("Changing current item in menu \"%s\" from \"%s\" to \"%s\"\n", current_menu->title,
(current ? current->text : "(NULL)"), (item ? item->text : "(NULL)")));
if (current) { if (current) {
/* Reset the current item */ /* Reset the current item */
menuitem_deselect(current_menu); menuitem_deselect(current_menu);
/* If we're changing from one submenu to another and neither is a child of the other, or if we're changing from a submenu to /* If we're changing from one submenu to another and neither is a child of the other, or if we're changing from a submenu to
no current item at all, reset the tree for the current submenu */ no current item at all, reset the tree for the current submenu */
if (current->type == MENUITEM_SUBMENU && current->action.submenu != NULL) { if (current->type == MENUITEM_SUBMENU && current->action.submenu != NULL) {
if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu != NULL && !menu_is_child(current->action.submenu, item->action.submenu) if ((item && item->type == MENUITEM_SUBMENU && item->action.submenu != NULL
&& !menu_is_child(current->action.submenu, item->action.submenu)
&& !menu_is_child(item->action.submenu, current->action.submenu)) && !menu_is_child(item->action.submenu, current->action.submenu))
|| (!item)) { || (!item)) {
menu_reset_tree(current->action.submenu); menu_reset_tree(current->action.submenu);
@ -767,25 +779,25 @@ menuitem_set_action(menuitem_t *item, unsigned char type, char *action)
item->type = type; item->type = type;
switch (type) { switch (type) {
case MENUITEM_SUBMENU: case MENUITEM_SUBMENU:
item->action.submenu = find_menu_by_title(menu_list, action); item->action.submenu = find_menu_by_title(menu_list, action);
break; break;
case MENUITEM_SCRIPT: case MENUITEM_SCRIPT:
item->action.script = STRDUP(action); item->action.script = STRDUP(action);
break; break;
case MENUITEM_ALERT: case MENUITEM_ALERT:
item->action.alert = STRDUP(action); item->action.alert = STRDUP(action);
break; break;
case MENUITEM_STRING: case MENUITEM_STRING:
case MENUITEM_ECHO: case MENUITEM_ECHO:
case MENUITEM_LITERAL: case MENUITEM_LITERAL:
item->action.string = (char *) MALLOC(strlen(action) + 2); item->action.string = (char *) MALLOC(strlen(action) + 2);
strcpy(item->action.string, action); strcpy(item->action.string, action);
if (type != MENUITEM_LITERAL) if (type != MENUITEM_LITERAL)
parse_escaped_string(item->action.string); parse_escaped_string(item->action.string);
break; break;
default: default:
break; break;
} }
return 1; return 1;
} }
@ -889,7 +901,8 @@ menuitem_select(menu_t *menu)
item = menuitem_get_current(menu); item = menuitem_get_current(menu);
REQUIRE(item != NULL); REQUIRE(item != NULL);
D_MENU(("Selecting new current item \"%s\" within menu \"%s\" (window 0x%08x, selection window 0x%08x)\n", item->text, menu->title, menu->win, menu->swin)); D_MENU(("Selecting new current item \"%s\" within menu \"%s\" (window 0x%08x, selection window 0x%08x)\n", item->text,
menu->title, menu->win, menu->swin));
item->state |= MENU_STATE_IS_CURRENT; item->state |= MENU_STATE_IS_CURRENT;
XMoveWindow(Xdisplay, menu->swin, item->x, item->y); XMoveWindow(Xdisplay, menu->swin, item->x, item->y);
XMapWindow(Xdisplay, menu->swin); XMapWindow(Xdisplay, menu->swin);
@ -899,7 +912,8 @@ menuitem_select(menu_t *menu)
enl_ipc_sync(); enl_ipc_sync();
} else if (!image_mode_is(image_submenu, MODE_MASK)) { } else if (!image_mode_is(image_submenu, MODE_MASK)) {
draw_shadow_from_colors(menu->swin, top, bottom, 0, 0, item->w - MENU_VGAP, item->h, 2); draw_shadow_from_colors(menu->swin, top, bottom, 0, 0, item->w - MENU_VGAP, item->h, 2);
draw_arrow_from_colors(menu->swin, top, bottom, item->w - 3 * MENU_HGAP, (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, DRAW_ARROW_RIGHT); draw_arrow_from_colors(menu->swin, top, bottom, item->w - 3 * MENU_HGAP, (item->h - MENU_VGAP) / 2, MENU_VGAP, 2,
DRAW_ARROW_RIGHT);
} }
} else { } else {
if (image_mode_is(image_menu, MODE_MASK)) { if (image_mode_is(image_menu, MODE_MASK)) {
@ -914,7 +928,8 @@ menuitem_select(menu_t *menu)
XSetForeground(Xdisplay, menu->gc, images[image_menu].selected->fg); XSetForeground(Xdisplay, menu->gc, images[image_menu].selected->fg);
draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len); draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len);
if (item->rtext) { if (item->rtext) {
draw_string(menu->swin, menu->gc, item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP, item->h - MENU_VGAP, item->rtext, item->rlen); draw_string(menu->swin, menu->gc, item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP,
item->h - MENU_VGAP, item->rtext, item->rlen);
} }
XSetForeground(Xdisplay, menu->gc, images[image_menu].norm->fg); XSetForeground(Xdisplay, menu->gc, images[image_menu].norm->fg);
} }
@ -943,7 +958,8 @@ menu_display_submenu(menu_t *menu, menuitem_t *item)
REQUIRE(item->action.submenu != NULL); REQUIRE(item->action.submenu != NULL);
submenu = item->action.submenu; submenu = item->action.submenu;
D_MENU(("Displaying submenu \"%s\" (window 0x%08x) of menu \"%s\" (window 0x%08x)\n", submenu->title, submenu->win, menu->title, menu->win)); D_MENU(("Displaying submenu \"%s\" (window 0x%08x) of menu \"%s\" (window 0x%08x)\n", submenu->title, submenu->win, menu->title,
menu->win));
menu_invoke(item->x + item->w, item->y, menu->win, submenu, CurrentTime); menu_invoke(item->x + item->w, item->y, menu->win, submenu, CurrentTime);
/* Invoking the submenu makes it current. Undo that behavior. */ /* Invoking the submenu makes it current. Undo that behavior. */
@ -1086,7 +1102,8 @@ menu_draw(menu_t *menu)
render_simage(images[image_menu].norm, menu->win, menu->w, menu->h, image_menu, RENDER_FORCE_PIXMAP); render_simage(images[image_menu].norm, menu->win, menu->w, menu->h, image_menu, RENDER_FORCE_PIXMAP);
menu->bg = images[image_menu].norm->pmap->pixmap; menu->bg = images[image_menu].norm->pmap->pixmap;
if (!image_mode_is(image_menu, MODE_MASK)) { if (!image_mode_is(image_menu, MODE_MASK)) {
draw_shadow_from_colors(menu->bg, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor], 0, 0, menu->w, menu->h, 2); draw_shadow_from_colors(menu->bg, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor], 0, 0, menu->w, menu->h,
2);
} }
D_MENU(("Menu background is 0x%08x\n", menu->bg)); D_MENU(("Menu background is 0x%08x\n", menu->bg));
XMapWindow(Xdisplay, menu->win); XMapWindow(Xdisplay, menu->win);
@ -1099,8 +1116,10 @@ menu_draw(menu_t *menu)
str_y = menu->fheight + MENU_VGAP; str_y = menu->fheight + MENU_VGAP;
len = strlen(menu->title); len = strlen(menu->title);
XTextExtents(menu->font, menu->title, len, &direction, &ascent, &descent, &chars); XTextExtents(menu->font, menu->title, len, &direction, &ascent, &descent, &chars);
draw_string(menu->bg, menu->gc, center_coords(2 * MENU_HGAP, menu->w - 2 * MENU_HGAP) - (chars.width >> 1), str_y - chars.descent - MENU_VGAP / 2, menu->title, len); draw_string(menu->bg, menu->gc, center_coords(2 * MENU_HGAP, menu->w - 2 * MENU_HGAP) - (chars.width >> 1),
draw_shadow(menu->bg, topShadowGC, botShadowGC, str_x, str_y - chars.descent - MENU_VGAP / 2 + 1, menu->w - (4 * MENU_HGAP), MENU_VGAP, 2); str_y - chars.descent - MENU_VGAP / 2, menu->title, len);
draw_shadow(menu->bg, topShadowGC, botShadowGC, str_x, str_y - chars.descent - MENU_VGAP / 2 + 1, menu->w - (4 * MENU_HGAP),
MENU_VGAP, 2);
str_y += MENU_VGAP; str_y += MENU_VGAP;
for (i = 0; i < menu->numitems; i++) { for (i = 0; i < menu->numitems; i++) {
@ -1114,9 +1133,11 @@ menu_draw(menu_t *menu)
item->y = str_y - 2 * MENU_VGAP; item->y = str_y - 2 * MENU_VGAP;
item->w = menu->w - MENU_HGAP; item->w = menu->w - MENU_HGAP;
item->h = 2 * MENU_VGAP; item->h = 2 * MENU_VGAP;
D_MENU(("Hot Area at %hu, %hu to %hu, %hu (width %hu, height %hu)\n", item->x, item->y, item->x + item->w, item->y + item->h, item->w, item->h)); D_MENU(("Hot Area at %hu, %hu to %hu, %hu (width %hu, height %hu)\n", item->x, item->y, item->x + item->w,
item->y + item->h, item->w, item->h));
} }
draw_shadow(menu->bg, botShadowGC, topShadowGC, str_x, str_y - MENU_VGAP - MENU_VGAP / 2, menu->w - 4 * MENU_HGAP, MENU_VGAP, 2); draw_shadow(menu->bg, botShadowGC, topShadowGC, str_x, str_y - MENU_VGAP - MENU_VGAP / 2, menu->w - 4 * MENU_HGAP,
MENU_VGAP, 2);
} else { } else {
str_y += menu->fheight + MENU_VGAP; str_y += menu->fheight + MENU_VGAP;
@ -1125,23 +1146,27 @@ menu_draw(menu_t *menu)
item->y = str_y - menu->fheight - MENU_VGAP / 2; item->y = str_y - menu->fheight - MENU_VGAP / 2;
item->w = menu->w - MENU_HGAP; item->w = menu->w - MENU_HGAP;
item->h = menu->fheight + MENU_VGAP; item->h = menu->fheight + MENU_VGAP;
D_MENU(("Hot Area at %hu, %hu to %hu, %hu (width %hu, height %hu)\n", item->x, item->y, item->x + item->w, item->y + item->h, item->w, item->h)); D_MENU(("Hot Area at %hu, %hu to %hu, %hu (width %hu, height %hu)\n", item->x, item->y, item->x + item->w,
item->y + item->h, item->w, item->h));
} }
switch (item->type) { switch (item->type) {
case MENUITEM_SUBMENU: case MENUITEM_SUBMENU:
if (image_mode_is(image_submenu, MODE_MASK)) { if (image_mode_is(image_submenu, MODE_MASK)) {
paste_simage(images[image_submenu].norm, image_submenu, menu->win, menu->bg, item->x, item->y, item->w - MENU_VGAP, item->h); paste_simage(images[image_submenu].norm, image_submenu, menu->win, menu->bg, item->x, item->y,
} else { item->w - MENU_VGAP, item->h);
draw_arrow_from_colors(menu->bg, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor], } else {
item->x + item->w - 3 * MENU_HGAP, item->y + (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, DRAW_ARROW_RIGHT); draw_arrow_from_colors(menu->bg, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor],
} item->x + item->w - 3 * MENU_HGAP, item->y + (item->h - MENU_VGAP) / 2, MENU_VGAP, 2,
break; DRAW_ARROW_RIGHT);
default: }
break; break;
default:
break;
} }
draw_string(menu->bg, menu->gc, str_x, str_y - MENU_VGAP / 2, item->text, item->len); draw_string(menu->bg, menu->gc, str_x, str_y - MENU_VGAP / 2, item->text, item->len);
if (item->rtext) { if (item->rtext) {
draw_string(menu->bg, menu->gc, str_x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 3 * MENU_HGAP, str_y - MENU_VGAP / 2, item->rtext, item->rlen); draw_string(menu->bg, menu->gc, str_x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 3 * MENU_HGAP,
str_y - MENU_VGAP / 2, item->rtext, item->rlen);
} }
} }
} }
@ -1176,46 +1201,46 @@ menu_action(menuitem_t *item)
D_MENU(("menu_action() called to invoke %s\n", item->text)); D_MENU(("menu_action() called to invoke %s\n", item->text));
switch (item->type) { switch (item->type) {
case MENUITEM_SEP: case MENUITEM_SEP:
D_MENU(("Internal Program Error: menu_action() called for a separator.\n")); D_MENU(("Internal Program Error: menu_action() called for a separator.\n"));
break; break;
case MENUITEM_SUBMENU: case MENUITEM_SUBMENU:
D_MENU(("Internal Program Error: menu_action() called for a submenu.\n")); D_MENU(("Internal Program Error: menu_action() called for a submenu.\n"));
break; break;
case MENUITEM_STRING: case MENUITEM_STRING:
cmd_write((unsigned char *) item->action.string, strlen(item->action.string)); cmd_write((unsigned char *) item->action.string, strlen(item->action.string));
break; break;
case MENUITEM_ECHO: case MENUITEM_ECHO:
case MENUITEM_LITERAL: case MENUITEM_LITERAL:
#ifdef ESCREEN #ifdef ESCREEN
if (TermWin.screen && TermWin.screen->backend) { if (TermWin.screen && TermWin.screen->backend) {
/* translate escapes */ /* translate escapes */
switch (TermWin.screen->backend) { switch (TermWin.screen->backend) {
# ifdef NS_HAVE_SCREEN # ifdef NS_HAVE_SCREEN
case NS_MODE_SCREEN: case NS_MODE_SCREEN:
if (item->type == MENUITEM_ECHO) { if (item->type == MENUITEM_ECHO) {
ns_parse_screen_interactive(TermWin.screen, item->action.string); ns_parse_screen_interactive(TermWin.screen, item->action.string);
} else { } else {
ns_screen_command(TermWin.screen, item->action.string); ns_screen_command(TermWin.screen, item->action.string);
} }
break; break;
# endif # endif
default: default:
tt_write((unsigned char *) item->action.string, strlen(item->action.string)); tt_write((unsigned char *) item->action.string, strlen(item->action.string));
} }
} else } else
#endif #endif
tt_write((unsigned char *) item->action.string, strlen(item->action.string)); tt_write((unsigned char *) item->action.string, strlen(item->action.string));
break; break;
case MENUITEM_SCRIPT: case MENUITEM_SCRIPT:
script_parse((char *) item->action.script); script_parse((char *) item->action.script);
break; break;
case MENUITEM_ALERT: case MENUITEM_ALERT:
menu_dialog(NULL, item->action.alert, 0, NULL, NULL); menu_dialog(NULL, item->action.alert, 0, NULL, NULL);
break; break;
default: default:
fatal_error("Internal Program Error: Unknown menuitem type: %u\n", item->type); fatal_error("Internal Program Error: Unknown menuitem type: %u\n", item->type);
break; break;
} }
} }
@ -1369,7 +1394,8 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
menuitem_set_action(i, MENUITEM_STRING, "error"); menuitem_set_action(i, MENUITEM_STRING, "error");
menu_add_item(m, i); menu_add_item(m, i);
menu_invoke((int) ((TermWin_TotalWidth() - l) / 2), (int) (TermWin_TotalHeight() / 2) - 20, TermWin.parent, m, CurrentTime); menu_invoke((int) ((TermWin_TotalWidth() - l) / 2), (int) (TermWin_TotalHeight() / 2) - 20, TermWin.parent, m,
CurrentTime);
ungrab_pointer(); ungrab_pointer();
@ -1379,7 +1405,7 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v
for (;;) { for (;;) {
ret = XNextEvent(Xdisplay, &ev); ret = XNextEvent(Xdisplay, &ev);
D_MENU(("In menu_dialog(%s): XNextEvent() returned %d with a %s event.\n", D_MENU(("In menu_dialog(%s): XNextEvent() returned %d with a %s event.\n",
NONULL(prompt), ret, event_type_to_name(ev.type))); NONULL(prompt), ret, event_type_to_name(ev.type)));
/* Handle all events normally *except* for keypresses; those are handled here. */ /* Handle all events normally *except* for keypresses; those are handled here. */
if (ev.type == KeyPress) { if (ev.type == KeyPress) {
break; break;

View File

@ -143,64 +143,64 @@ parse_escaped_string(char *str)
} }
D_STRINGS(("Operating on \'%c\'\n", *pold)); D_STRINGS(("Operating on \'%c\'\n", *pold));
switch (*pold) { switch (*pold) {
case '\\': case '\\':
D_STRINGS(("Backslash + %c\n", *(pold + 1))); D_STRINGS(("Backslash + %c\n", *(pold + 1)));
switch (tolower(*(++pold))) { switch (tolower(*(++pold))) {
case '0': case '0':
case '1': case '1':
case '2': case '2':
case '3': case '3':
case '4': case '4':
case '5': case '5':
case '6': case '6':
case '7': case '7':
for (i = 0; *pold >= '0' && *pold <= '7'; pold++) { for (i = 0; *pold >= '0' && *pold <= '7'; pold++) {
i = (i * 8) + (*pold - '0'); i = (i * 8) + (*pold - '0');
} }
pold--; pold--;
D_STRINGS(("Octal number evaluates to %d\n", i)); D_STRINGS(("Octal number evaluates to %d\n", i));
*pnew = i; *pnew = i;
break; break;
case 'n': case 'n':
*pnew = '\n'; *pnew = '\n';
break; break;
case 'r': case 'r':
*pnew = '\r'; *pnew = '\r';
break; break;
case 't': case 't':
*pnew = '\t'; *pnew = '\t';
break; break;
case 'b': case 'b':
*pnew = '\b'; *pnew = '\b';
break; break;
case 'f': case 'f':
*pnew = '\f'; *pnew = '\f';
break; break;
case 'a': case 'a':
*pnew = '\a'; *pnew = '\a';
break; break;
case 'v': case 'v':
*pnew = '\v'; *pnew = '\v';
break; break;
case 'e': case 'e':
*pnew = '\033'; *pnew = '\033';
break; break;
case 'c': case 'c':
pold++; pold++;
*pnew = MAKE_CTRL_CHAR(*pold); *pnew = MAKE_CTRL_CHAR(*pold);
break; break;
default: default:
*pnew = *pold; *pnew = *pold;
break; break;
} }
break; break;
case '^': case '^':
D_STRINGS(("Caret + %c\n", *(pold + 1))); D_STRINGS(("Caret + %c\n", *(pold + 1)));
pold++; pold++;
*pnew = MAKE_CTRL_CHAR(*pold); *pnew = MAKE_CTRL_CHAR(*pold);
break; break;
default: default:
*pnew = *pold; *pnew = *pold;
} }
} }
@ -229,7 +229,7 @@ escape_string(spif_charptr_t str, spif_char_t quote, spif_int32_t maxlen)
spif_charptr_t buff, s = str, pbuff; spif_charptr_t buff, s = str, pbuff;
D_STRINGS(("escape_string(%s %c %ld)\n", (char *) str, quote, maxlen)); D_STRINGS(("escape_string(%s %c %ld)\n", (char *) str, quote, maxlen));
if (! quote) { if (!quote) {
quote = '\"'; quote = '\"';
} }

View File

@ -111,7 +111,8 @@ network_display(const char *display)
if (colon == NULL) if (colon == NULL)
colon = ":0.0"; colon = ":0.0";
sprintf(ipaddress, "%d.%d.%d.%d%s", (int) ((addr >> 030) & 0xFF), (int) ((addr >> 020) & 0xFF), (int) ((addr >> 010) & 0xFF), (int) (addr & 0xFF), colon); sprintf(ipaddress, "%d.%d.%d.%d%s", (int) ((addr >> 030) & 0xFF), (int) ((addr >> 020) & 0xFF),
(int) ((addr >> 010) & 0xFF), (int) (addr & 0xFF), colon);
rval = ipaddress; rval = ipaddress;
break; break;

View File

@ -79,12 +79,14 @@ static void *parse_multichar(char *, void *);
static void *parse_escreen(char *, void *); static void *parse_escreen(char *, void *);
static char *rs_pipe_name = NULL; static char *rs_pipe_name = NULL;
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
static int rs_shade = 0; static int rs_shade = 0;
static char *rs_tint = NULL; static char *rs_tint = NULL;
#endif #endif
static unsigned long rs_buttonbars = 1; static unsigned long rs_buttonbars = 1;
static char *rs_font_effects = NULL; static char *rs_font_effects = NULL;
#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) #if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
static char *rs_bigfont_key = NULL; static char *rs_bigfont_key = NULL;
static char *rs_smallfont_key = NULL; static char *rs_smallfont_key = NULL;
@ -108,11 +110,13 @@ char *rs_geometry = NULL; /* Geometry string */
int rs_desktop = -1; int rs_desktop = -1;
char *rs_path = NULL; char *rs_path = NULL;
int rs_saveLines = SAVELINES; /* Lines in the scrollback buffer */ int rs_saveLines = SAVELINES; /* Lines in the scrollback buffer */
#ifdef USE_XIM #ifdef USE_XIM
char *rs_input_method = NULL; char *rs_input_method = NULL;
char *rs_preedit_type = NULL; char *rs_preedit_type = NULL;
#endif #endif
char *rs_name = NULL; char *rs_name = NULL;
#ifndef NO_BOLDFONT #ifndef NO_BOLDFONT
char *rs_boldFont = NULL; char *rs_boldFont = NULL;
#endif #endif
@ -126,6 +130,7 @@ unsigned long rs_scrollbar_width = 0;
char *rs_finished_title = NULL; char *rs_finished_title = NULL;
char *rs_finished_text = NULL; char *rs_finished_text = NULL;
char *rs_term_name = NULL; char *rs_term_name = NULL;
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
char *rs_pixmapScale = NULL; char *rs_pixmapScale = NULL;
char *rs_icon = NULL; char *rs_icon = NULL;
@ -134,6 +139,7 @@ char *rs_cmod_red = NULL;
char *rs_cmod_green = NULL; char *rs_cmod_green = NULL;
char *rs_cmod_blue = NULL; char *rs_cmod_blue = NULL;
unsigned long rs_cache_size = (unsigned long) -1; unsigned long rs_cache_size = (unsigned long) -1;
# ifdef BACKGROUND_CYCLING_SUPPORT # ifdef BACKGROUND_CYCLING_SUPPORT
char *rs_anim_pixmap_list = NULL; char *rs_anim_pixmap_list = NULL;
char **rs_anim_pixmaps = NULL; char **rs_anim_pixmaps = NULL;
@ -143,6 +149,7 @@ static char *rs_pixmaps[image_max];
#endif #endif
char *rs_theme = NULL; char *rs_theme = NULL;
char *rs_config_file = NULL; char *rs_config_file = NULL;
#ifdef ESCREEN #ifdef ESCREEN
char *rs_url = NULL; char *rs_url = NULL;
char *rs_hop = NULL; char *rs_hop = NULL;
@ -154,6 +161,7 @@ spif_charptr_t rs_beep_command = NULL;
spif_uint32_t rs_opacity = 0xffffffff; spif_uint32_t rs_opacity = 0xffffffff;
unsigned int rs_line_space = 0; unsigned int rs_line_space = 0;
unsigned int rs_meta_mod = 0, rs_alt_mod = 0, rs_numlock_mod = 0; unsigned int rs_meta_mod = 0, rs_alt_mod = 0, rs_numlock_mod = 0;
#ifdef KEYSYM_ATTRIBUTE #ifdef KEYSYM_ATTRIBUTE
unsigned char *KeySym_map[256]; /* probably mostly empty */ unsigned char *KeySym_map[256]; /* probably mostly empty */
#endif #endif
@ -209,12 +217,12 @@ spifopt_t option_list[] = {
#ifndef NO_BOLDUNDERLINE #ifndef NO_BOLDUNDERLINE
SPIFOPT_STR_LONG("colorBD", "bold color", rs_color[colorBD]), SPIFOPT_STR_LONG("colorBD", "bold color", rs_color[colorBD]),
SPIFOPT_STR_LONG("colorUL", "underline color", rs_color[colorUL]), SPIFOPT_STR_LONG("colorUL", "underline color", rs_color[colorUL]),
#endif /* NO_BOLDUNDERLINE */ #endif /* NO_BOLDUNDERLINE */
SPIFOPT_STR_LONG("pointer-color", "mouse pointer color", rs_color[pointerColor]), SPIFOPT_STR_LONG("pointer-color", "mouse pointer color", rs_color[pointerColor]),
#ifndef NO_CURSORCOLOR #ifndef NO_CURSORCOLOR
SPIFOPT_STR('c', "cursor-color", "cursor color", rs_color[cursorColor]), SPIFOPT_STR('c', "cursor-color", "cursor color", rs_color[cursorColor]),
SPIFOPT_STR_LONG("cursor-text-color", "cursor text color", rs_color[cursorColor2]), SPIFOPT_STR_LONG("cursor-text-color", "cursor text color", rs_color[cursorColor2]),
#endif /* NO_CURSORCOLOR */ #endif /* NO_CURSORCOLOR */
/* =======[ X11 options ]======= */ /* =======[ X11 options ]======= */
SPIFOPT_STR('g', "geometry", "WxH+X+Y = size and position", rs_geometry), SPIFOPT_STR('g', "geometry", "WxH+X+Y = size and position", rs_geometry),
@ -261,8 +269,8 @@ spifopt_t option_list[] = {
SPIFOPT_INT_LONG("cache", "set Imlib2 image/pixmap cache size", rs_cache_size), SPIFOPT_INT_LONG("cache", "set Imlib2 image/pixmap cache size", rs_cache_size),
# ifdef BACKGROUND_CYCLING_SUPPORT # ifdef BACKGROUND_CYCLING_SUPPORT
SPIFOPT_STR('N', "anim", "a delay and list of pixmaps for cycling", rs_anim_pixmap_list), SPIFOPT_STR('N', "anim", "a delay and list of pixmaps for cycling", rs_anim_pixmap_list),
# endif /* BACKGROUND_CYCLING_SUPPORT */ # endif /* BACKGROUND_CYCLING_SUPPORT */
#endif /* PIXMAP_SUPPORT */ #endif /* PIXMAP_SUPPORT */
/* =======[ Kanji options ]======= */ /* =======[ Kanji options ]======= */
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
@ -272,7 +280,7 @@ spifopt_t option_list[] = {
SPIFOPT_STR_LONG("mfont3", "multichar font 3", rs_mfont[3]), SPIFOPT_STR_LONG("mfont3", "multichar font 3", rs_mfont[3]),
SPIFOPT_STR_LONG("mfont4", "multichar font 4", rs_mfont[4]), SPIFOPT_STR_LONG("mfont4", "multichar font 4", rs_mfont[4]),
SPIFOPT_STR_LONG("mencoding", "multichar encoding mode (eucj/sjis/euckr/big5/gb)", rs_multichar_encoding), SPIFOPT_STR_LONG("mencoding", "multichar encoding mode (eucj/sjis/euckr/big5/gb)", rs_multichar_encoding),
#endif /* MULTI_CHARSET */ #endif /* MULTI_CHARSET */
#ifdef USE_XIM #ifdef USE_XIM
SPIFOPT_STR_LONG("input-method", "XIM input method", rs_input_method), SPIFOPT_STR_LONG("input-method", "XIM input method", rs_input_method),
SPIFOPT_STR_LONG("preedit-type", "XIM preedit type", rs_preedit_type), SPIFOPT_STR_LONG("preedit-type", "XIM preedit type", rs_preedit_type),
@ -287,12 +295,15 @@ spifopt_t option_list[] = {
SPIFOPT_BOOL_LONG("home-on-input", "jump to bottom on input", vt_options, VT_OPTIONS_HOME_ON_INPUT), SPIFOPT_BOOL_LONG("home-on-input", "jump to bottom on input", vt_options, VT_OPTIONS_HOME_ON_INPUT),
SPIFOPT_BOOL('q', "no-input", "configure for output only", eterm_options, ETERM_OPTIONS_NO_INPUT), SPIFOPT_BOOL('q', "no-input", "configure for output only", eterm_options, ETERM_OPTIONS_NO_INPUT),
SPIFOPT_BOOL_LONG("scrollbar-right", "display the scrollbar on the right", eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT), SPIFOPT_BOOL_LONG("scrollbar-right", "display the scrollbar on the right", eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT),
SPIFOPT_BOOL_LONG("scrollbar-floating", "display the scrollbar with no trough", eterm_options, ETERM_OPTIONS_SCROLLBAR_FLOATING), SPIFOPT_BOOL_LONG("scrollbar-floating", "display the scrollbar with no trough", eterm_options,
ETERM_OPTIONS_SCROLLBAR_FLOATING),
SPIFOPT_BOOL_LONG("scrollbar-popup", "popup the scrollbar only when focused", eterm_options, ETERM_OPTIONS_SCROLLBAR_POPUP), SPIFOPT_BOOL_LONG("scrollbar-popup", "popup the scrollbar only when focused", eterm_options, ETERM_OPTIONS_SCROLLBAR_POPUP),
SPIFOPT_BOOL('x', "borderless", "force Eterm to have no borders", eterm_options, ETERM_OPTIONS_BORDERLESS), SPIFOPT_BOOL('x', "borderless", "force Eterm to have no borders", eterm_options, ETERM_OPTIONS_BORDERLESS),
SPIFOPT_BOOL_LONG("overstrike-bold", "simulate bold by overstriking characters", vt_options, VT_OPTIONS_OVERSTRIKE_BOLD), SPIFOPT_BOOL_LONG("overstrike-bold", "simulate bold by overstriking characters", vt_options, VT_OPTIONS_OVERSTRIKE_BOLD),
SPIFOPT_BOOL_LONG("bold-brightens-foreground", "\"bold\" attribute brightens foreground color", vt_options, VT_OPTIONS_BOLD_BRIGHTENS_FOREGROUND), SPIFOPT_BOOL_LONG("bold-brightens-foreground", "\"bold\" attribute brightens foreground color", vt_options,
SPIFOPT_BOOL_LONG("blink-brightens-background", "\"blink\" attribute brightens background color", vt_options, VT_OPTIONS_BLINK_BRIGHTENS_BACKGROUND), VT_OPTIONS_BOLD_BRIGHTENS_FOREGROUND),
SPIFOPT_BOOL_LONG("blink-brightens-background", "\"blink\" attribute brightens background color", vt_options,
VT_OPTIONS_BLINK_BRIGHTENS_BACKGROUND),
SPIFOPT_BOOL_LONG("colors-suppress-bold", "do not make ANSI colors 0-16 bold", vt_options, VT_OPTIONS_COLORS_SUPPRESS_BOLD), SPIFOPT_BOOL_LONG("colors-suppress-bold", "do not make ANSI colors 0-16 bold", vt_options, VT_OPTIONS_COLORS_SUPPRESS_BOLD),
#ifndef NO_MAPALERT #ifndef NO_MAPALERT
# ifdef MAPALERT_OPTION # ifdef MAPALERT_OPTION
@ -302,15 +313,18 @@ spifopt_t option_list[] = {
#ifdef META8_OPTION #ifdef META8_OPTION
SPIFOPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", vt_options, VT_OPTIONS_META8), SPIFOPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", vt_options, VT_OPTIONS_META8),
#endif #endif
SPIFOPT_BOOL_LONG("double-buffer", "reduce exposes using double-buffering (and more memory)", eterm_options, ETERM_OPTIONS_DOUBLE_BUFFER), SPIFOPT_BOOL_LONG("double-buffer", "reduce exposes using double-buffering (and more memory)", eterm_options,
ETERM_OPTIONS_DOUBLE_BUFFER),
SPIFOPT_BOOL_LONG("no-cursor", "disable the text cursor", eterm_options, ETERM_OPTIONS_NO_CURSOR), SPIFOPT_BOOL_LONG("no-cursor", "disable the text cursor", eterm_options, ETERM_OPTIONS_NO_CURSOR),
SPIFOPT_BOOL_LONG("pause", "pause after the child process exits", eterm_options, ETERM_OPTIONS_PAUSE), SPIFOPT_BOOL_LONG("pause", "pause after the child process exits", eterm_options, ETERM_OPTIONS_PAUSE),
SPIFOPT_BOOL_LONG("xterm-select", "duplicate xterm's selection behavior", eterm_options, ETERM_OPTIONS_XTERM_SELECT), SPIFOPT_BOOL_LONG("xterm-select", "duplicate xterm's selection behavior", eterm_options, ETERM_OPTIONS_XTERM_SELECT),
SPIFOPT_BOOL_LONG("select-line", "triple-click selects whole line", eterm_options, ETERM_OPTIONS_SELECT_WHOLE_LINE), SPIFOPT_BOOL_LONG("select-line", "triple-click selects whole line", eterm_options, ETERM_OPTIONS_SELECT_WHOLE_LINE),
SPIFOPT_BOOL_LONG("select-trailing-spaces", "do not skip trailing spaces when selecting", eterm_options, ETERM_OPTIONS_SELECT_TRAILING_SPACES), SPIFOPT_BOOL_LONG("select-trailing-spaces", "do not skip trailing spaces when selecting", eterm_options,
ETERM_OPTIONS_SELECT_TRAILING_SPACES),
SPIFOPT_BOOL_LONG("report-as-keysyms", "report special keys as keysyms", vt_options, VT_OPTIONS_REPORT_AS_KEYSYMS), SPIFOPT_BOOL_LONG("report-as-keysyms", "report special keys as keysyms", vt_options, VT_OPTIONS_REPORT_AS_KEYSYMS),
SPIFOPT_BOOL_LONG("buttonbar", "toggle the display of all buttonbars", rs_buttonbars, BBAR_FORCE_TOGGLE), SPIFOPT_BOOL_LONG("buttonbar", "toggle the display of all buttonbars", rs_buttonbars, BBAR_FORCE_TOGGLE),
SPIFOPT_BOOL_LONG("resize-gravity", "toggle gravitation to nearest corner on resize", eterm_options, ETERM_OPTIONS_RESIZE_GRAVITY), SPIFOPT_BOOL_LONG("resize-gravity", "toggle gravitation to nearest corner on resize", eterm_options,
ETERM_OPTIONS_RESIZE_GRAVITY),
SPIFOPT_BOOL_LONG("secondary-screen", "toggle use of secondary screen", vt_options, VT_OPTIONS_SECONDARY_SCREEN), SPIFOPT_BOOL_LONG("secondary-screen", "toggle use of secondary screen", vt_options, VT_OPTIONS_SECONDARY_SCREEN),
/* =======[ Keyboard options ]======= */ /* =======[ Keyboard options ]======= */
@ -338,7 +352,7 @@ spifopt_t option_list[] = {
#endif #endif
#ifdef CUTCHAR_OPTION #ifdef CUTCHAR_OPTION
SPIFOPT_STR_LONG("cut-chars", "seperators for double-click selection", rs_cutchars), SPIFOPT_STR_LONG("cut-chars", "seperators for double-click selection", rs_cutchars),
#endif /* CUTCHAR_OPTION */ #endif /* CUTCHAR_OPTION */
SPIFOPT_STR_LONG("finished-title", "post-termination window title text", rs_finished_title), SPIFOPT_STR_LONG("finished-title", "post-termination window title text", rs_finished_title),
SPIFOPT_STR_LONG("finished-text", "post-termination terminal text", rs_finished_text), SPIFOPT_STR_LONG("finished-text", "post-termination terminal text", rs_finished_text),
SPIFOPT_STR_LONG("term-name", "value to use for setting $TERM", rs_term_name), SPIFOPT_STR_LONG("term-name", "value to use for setting $TERM", rs_term_name),
@ -408,10 +422,7 @@ version(void)
" " SCROLLBAR_IDENT "\n" " " SCROLLBAR_IDENT "\n"
" " STARTUP_IDENT "\n" " " STARTUP_IDENT "\n"
" " SYSTEM_IDENT "\n" " " SYSTEM_IDENT "\n"
" " TERM_IDENT "\n" " " TERM_IDENT "\n" " " TIMER_IDENT "\n" " " UTMP_IDENT "\n" " " WINDOWS_IDENT "\n" "\n");
" " TIMER_IDENT "\n"
" " UTMP_IDENT "\n"
" " WINDOWS_IDENT "\n" "\n");
printf("Debugging configuration: "); printf("Debugging configuration: ");
#ifdef DEBUG #ifdef DEBUG
@ -947,7 +958,8 @@ parse_color(char *buff, void *state)
} else { } else {
tmp = get_word(1, tmp); tmp = get_word(1, tmp);
print_error("Parse error in file %s, line %lu: Invalid color index \"%s\"\n", file_peek_path(), file_peek_line(), NONULL(tmp)); print_error("Parse error in file %s, line %lu: Invalid color index \"%s\"\n", file_peek_path(), file_peek_line(),
NONULL(tmp));
FREE(tmp); FREE(tmp);
} }
} else { } else {
@ -1023,7 +1035,8 @@ parse_attributes(char *buff, void *state)
} else { } else {
tmp = get_word(1, tmp); tmp = get_word(1, tmp);
print_error("Parse error in file %s, line %lu: Invalid font index \"%s\"\n", file_peek_path(), file_peek_line(), NONULL(tmp)); print_error("Parse error in file %s, line %lu: Invalid font index \"%s\"\n", file_peek_path(), file_peek_line(),
NONULL(tmp));
FREE(tmp); FREE(tmp);
} }
@ -1044,7 +1057,8 @@ parse_toggles(char *buff, void *state)
return NULL; return NULL;
} }
if (!(tmp = get_pword(2, buff))) { if (!(tmp = get_pword(2, buff))) {
print_error("Parse error in file %s, line %lu: Missing boolean value in context toggles\n", file_peek_path(), file_peek_line()); print_error("Parse error in file %s, line %lu: Missing boolean value in context toggles\n", file_peek_path(),
file_peek_line());
return NULL; return NULL;
} }
if (BOOL_OPT_ISTRUE(tmp)) { if (BOOL_OPT_ISTRUE(tmp)) {
@ -1631,7 +1645,8 @@ parse_image(char *buff, void *state)
return NULL; return NULL;
} }
if (!mode) { if (!mode) {
print_error("Parse error in file %s, line %lu: Missing parameters for mode line\n", file_peek_path(), file_peek_line()); print_error("Parse error in file %s, line %lu: Missing parameters for mode line\n", file_peek_path(),
file_peek_line());
return NULL; return NULL;
} }
if (!BEG_STRCASECMP(mode, "image")) { if (!BEG_STRCASECMP(mode, "image")) {
@ -1661,7 +1676,8 @@ parse_image(char *buff, void *state)
images[idx].mode |= ALLOW_AUTO; images[idx].mode |= ALLOW_AUTO;
} else if (!BEG_STRCASECMP(allow, "solid")) { } else if (!BEG_STRCASECMP(allow, "solid")) {
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid mode \"%s\"\n", file_peek_path(), file_peek_line(), allow); print_error("Parse error in file %s, line %lu: Invalid mode \"%s\"\n", file_peek_path(), file_peek_line(),
allow);
} }
} }
} }
@ -1796,13 +1812,13 @@ parse_image(char *buff, void *state)
imlib_t *iml = images[idx].current->iml; imlib_t *iml = images[idx].current->iml;
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
print_error("Parse error in file %s, line %lu: Encountered color modifier with no image type defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered color modifier with no image type defined\n",
file_peek_line()); file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined\n",
file_peek_line()); file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
if (!color) { if (!color) {
@ -1895,7 +1911,7 @@ parse_image(char *buff, void *state)
if ((images[idx].current->iml->border->left == 0) && (images[idx].current->iml->border->right == 0) 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)) { && (images[idx].current->iml->border->top == 0) && (images[idx].current->iml->border->bottom == 0)) {
FREE(images[idx].current->iml->border); 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 ")) { } else if (!BEG_STRCASECMP(buff, "bevel ")) {
if (!CHECK_VALID_INDEX(idx)) { if (!CHECK_VALID_INDEX(idx)) {
@ -1944,8 +1960,8 @@ parse_image(char *buff, void *state)
return NULL; return NULL;
} }
if (images[idx].current == NULL) { if (images[idx].current == NULL) {
print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined\n",
file_peek_line()); file_peek_path(), file_peek_line());
return NULL; return NULL;
} }
if (num_words(buff + 8) < 4) { if (num_words(buff + 8) < 4) {
@ -2024,7 +2040,8 @@ parse_actions(char *buff, void *state)
} }
FREE(str); FREE(str);
if ((button == BUTTON_NONE) && (keysym == 0)) { if ((button == BUTTON_NONE) && (keysym == 0)) {
print_error("Parse error in file %s, line %lu: No valid button/keysym found for action\n", file_peek_path(), file_peek_line()); print_error("Parse error in file %s, line %lu: No valid button/keysym found for action\n", file_peek_path(),
file_peek_line());
return NULL; return NULL;
} }
i++; i++;
@ -2155,7 +2172,8 @@ parse_menuitem(char *buff, void *state)
char *rtext = get_word(2, buff); char *rtext = get_word(2, buff);
if (!rtext) { if (!rtext) {
print_error("Parse error in file %s, line %lu: Missing menuitem right-justified text.\n", file_peek_path(), file_peek_line()); print_error("Parse error in file %s, line %lu: Missing menuitem right-justified text.\n", file_peek_path(),
file_peek_line());
return ((void *) curitem); return ((void *) curitem);
} }
menuitem_set_rtext(curitem, rtext); menuitem_set_rtext(curitem, rtext);
@ -2220,12 +2238,13 @@ parse_bbar(char *buff, void *state)
char *where = get_pword(2, buff); char *where = get_pword(2, buff);
if (!where) { if (!where) {
print_error("Parse error in file %s, line %lu: Attribute dock requires a parameter\n", file_peek_path(), file_peek_line()); 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")) { } else if (!BEG_STRCASECMP(where, "top")) {
bbar_set_docked(bbar, BBAR_DOCKED_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); 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); bbar_set_docked(bbar, BBAR_UNDOCKED);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute dock\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute dock\n", file_peek_path(),
@ -2286,7 +2305,8 @@ parse_bbar(char *buff, void *state)
} else if (!BEG_STRCASECMP(type, "script ")) { } else if (!BEG_STRCASECMP(type, "script ")) {
button_set_action(button, ACTION_SCRIPT, action); button_set_action(button, ACTION_SCRIPT, action);
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid button action \"%s\"\n", file_peek_path(), file_peek_line(), type); print_error("Parse error in file %s, line %lu: Invalid button action \"%s\"\n", file_peek_path(), file_peek_line(),
type);
FREE(action); FREE(action);
FREE(button); FREE(button);
return ((void *) bbar); return ((void *) bbar);
@ -2377,7 +2397,8 @@ parse_multichar(char *buff, void *state)
} }
} else { } else {
tmp = get_word(1, tmp); tmp = get_word(1, tmp);
print_error("Parse error in file %s, line %lu: Invalid font index \"%s\"\n", file_peek_path(), file_peek_line(), NONULL(tmp)); print_error("Parse error in file %s, line %lu: Invalid font index \"%s\"\n", file_peek_path(), file_peek_line(),
NONULL(tmp));
FREE(tmp); FREE(tmp);
} }
@ -2414,12 +2435,13 @@ parse_escreen(char *buff, void *state)
char *where = get_pword(2, buff); char *where = get_pword(2, buff);
if (!where) { if (!where) {
print_error("Parse error in file %s, line %lu: Attribute bbar_dock requires a parameter\n", file_peek_path(), file_peek_line()); print_error("Parse error in file %s, line %lu: Attribute bbar_dock requires a parameter\n", file_peek_path(),
file_peek_line());
} else if (!BEG_STRCASECMP(where, "top")) { } else if (!BEG_STRCASECMP(where, "top")) {
rs_es_dock = BBAR_DOCKED_TOP; rs_es_dock = BBAR_DOCKED_TOP;
} else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */ } else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */
rs_es_dock = BBAR_DOCKED_BOTTOM; rs_es_dock = BBAR_DOCKED_BOTTOM;
} else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */ } else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */
rs_es_dock = BBAR_UNDOCKED; rs_es_dock = BBAR_UNDOCKED;
} else { } else {
print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute bbar_dock\n", file_peek_path(), print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute bbar_dock\n", file_peek_path(),
@ -2448,8 +2470,7 @@ conf_parse_theme(char **theme, char *conf_name, unsigned char fallback)
path_env = getenv(PATH_ENV); path_env = getenv(PATH_ENV);
if (path_env) { if (path_env) {
snprintf(path, sizeof(path), "%s:%s", CONFIG_SEARCH_PATH, snprintf(path, sizeof(path), "%s:%s", CONFIG_SEARCH_PATH, path_env);
path_env);
} else { } else {
snprintf(path, sizeof(path), CONFIG_SEARCH_PATH); snprintf(path, sizeof(path), CONFIG_SEARCH_PATH);
} }
@ -2570,8 +2591,7 @@ post_parse(void)
#if DEBUG > 0 #if DEBUG > 0
if (DEBUG_LEVEL > DEBUG) { if (DEBUG_LEVEL > DEBUG) {
print_warning("Requested debug level of %d exceeds compile-time maximum of %d\n", print_warning("Requested debug level of %d exceeds compile-time maximum of %d\n", DEBUG_LEVEL, DEBUG);
DEBUG_LEVEL, DEBUG);
} else if (DEBUG_LEVEL > 0) { } else if (DEBUG_LEVEL > 0) {
DPRINTF1(("Now running with debugging level of %d\n", DEBUG_LEVEL)); DPRINTF1(("Now running with debugging level of %d\n", DEBUG_LEVEL));
} }
@ -2736,7 +2756,7 @@ post_parse(void)
if (rs_pixmaps[i]) { if (rs_pixmaps[i]) {
reset_simage(images[i].norm, RESET_ALL_SIMG); reset_simage(images[i].norm, RESET_ALL_SIMG);
load_image(rs_pixmaps[i], images[i].norm); 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 #else
/* Right now, solid mode is the only thing we can do without pixmap support. */ /* Right now, solid mode is the only thing we can do without pixmap support. */
@ -3024,11 +3044,11 @@ post_parse(void)
unsigned long w, h; unsigned long w, h;
int count; 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)); rs_anim_pixmaps = (char **) MALLOC(sizeof(char *) * (count + 1));
for (i = 0; i < count; i++) { 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) if (temp == NULL)
break; break;
if (num_words(temp) != 3) { if (num_words(temp) != 3) {
@ -3116,8 +3136,8 @@ save_config(char *path, unsigned char save_theme)
*(--tmp) = '/'; *(--tmp) = '/';
} }
if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) { if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) {
print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (theme_dir ? theme_dir : PKGDATADIR "/themes/Eterm\n"), print_error("I couldn't write to \"%s\" or \"%s\". I give up.",
path); (theme_dir ? theme_dir : PKGDATADIR "/themes/Eterm\n"), path);
return errno; return errno;
} }
} }
@ -3146,8 +3166,8 @@ save_config(char *path, unsigned char save_theme)
*(--tmp) = '/'; *(--tmp) = '/';
} }
if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) { if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) {
print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (user_dir ? user_dir : PKGDATADIR "/themes/Eterm\n"), print_error("I couldn't write to \"%s\" or \"%s\". I give up.",
path); (user_dir ? user_dir : PKGDATADIR "/themes/Eterm\n"), path);
return errno; return errno;
} }
} }
@ -3263,69 +3283,69 @@ save_config(char *path, unsigned char save_theme)
for (i = 0; i < image_max; i++) { for (i = 0; i < image_max; i++) {
fprintf(fp, " begin image\n"); fprintf(fp, " begin image\n");
switch (i) { switch (i) {
case image_bg: case image_bg:
fprintf(fp, " type background\n"); fprintf(fp, " type background\n");
break; break;
case image_sb: case image_sb:
fprintf(fp, " type trough\n"); fprintf(fp, " type trough\n");
break; break;
case image_sa: case image_sa:
fprintf(fp, " type anchor\n"); fprintf(fp, " type anchor\n");
break; break;
case image_st: case image_st:
fprintf(fp, " type thumb\n"); fprintf(fp, " type thumb\n");
break; break;
case image_up: case image_up:
fprintf(fp, " type up_arrow\n"); fprintf(fp, " type up_arrow\n");
break; break;
case image_down: case image_down:
fprintf(fp, " type down_arrow\n"); fprintf(fp, " type down_arrow\n");
break; break;
case image_left: case image_left:
fprintf(fp, " type left_arrow\n"); fprintf(fp, " type left_arrow\n");
break; break;
case image_right: case image_right:
fprintf(fp, " type right_arrow\n"); fprintf(fp, " type right_arrow\n");
break; break;
case image_menu: case image_menu:
fprintf(fp, " type menu\n"); fprintf(fp, " type menu\n");
break; break;
case image_menuitem: case image_menuitem:
fprintf(fp, " type menuitem\n"); fprintf(fp, " type menuitem\n");
break; break;
case image_submenu: case image_submenu:
fprintf(fp, " type submenu\n"); fprintf(fp, " type submenu\n");
break; break;
case image_button: case image_button:
fprintf(fp, " type button\n"); fprintf(fp, " type button\n");
break; break;
case image_bbar: case image_bbar:
fprintf(fp, " type button_bar\n"); fprintf(fp, " type button_bar\n");
break; break;
case image_gbar: case image_gbar:
fprintf(fp, " type grab_bar\n"); fprintf(fp, " type grab_bar\n");
break; break;
case image_dialog: case image_dialog:
fprintf(fp, " type dialog_box\n"); fprintf(fp, " type dialog_box\n");
break; break;
} }
fprintf(fp, " mode "); fprintf(fp, " mode ");
switch (images[i].mode & MODE_MASK) { switch (images[i].mode & MODE_MASK) {
case MODE_IMAGE: case MODE_IMAGE:
fprintf(fp, "image"); fprintf(fp, "image");
break; break;
case MODE_TRANS: case MODE_TRANS:
fprintf(fp, "trans"); fprintf(fp, "trans");
break; break;
case MODE_VIEWPORT: case MODE_VIEWPORT:
fprintf(fp, "viewport"); fprintf(fp, "viewport");
break; break;
case MODE_AUTO: case MODE_AUTO:
fprintf(fp, "auto"); fprintf(fp, "auto");
break; break;
default: default:
fprintf(fp, "solid"); fprintf(fp, "solid");
break; break;
} }
if (images[i].mode & ALLOW_MASK) { if (images[i].mode & ALLOW_MASK) {
fprintf(fp, " allow"); fprintf(fp, " allow");
@ -3392,12 +3412,13 @@ save_config(char *path, unsigned char save_theme)
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right,
simg->iml->border->bottom); simg->iml->border->top, simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"),
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top,
simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top,
@ -3444,21 +3465,22 @@ save_config(char *path, unsigned char save_theme)
simg->iml->rmod->gamma); simg->iml->rmod->gamma);
} }
if (simg->iml->gmod) { if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness,
simg->iml->gmod->gamma); simg->iml->gmod->contrast, simg->iml->gmod->gamma);
} }
if (simg->iml->bmod) { if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness,
simg->iml->bmod->gamma); simg->iml->bmod->contrast, simg->iml->bmod->gamma);
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right,
simg->iml->border->bottom); simg->iml->border->top, simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"),
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top,
simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top,
@ -3506,21 +3528,22 @@ save_config(char *path, unsigned char save_theme)
simg->iml->rmod->gamma); simg->iml->rmod->gamma);
} }
if (simg->iml->gmod) { if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness,
simg->iml->gmod->gamma); simg->iml->gmod->contrast, simg->iml->gmod->gamma);
} }
if (simg->iml->bmod) { if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness,
simg->iml->bmod->gamma); simg->iml->bmod->contrast, simg->iml->bmod->gamma);
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right,
simg->iml->border->bottom); simg->iml->border->top, simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"),
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top,
simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top,
@ -3568,21 +3591,22 @@ save_config(char *path, unsigned char save_theme)
simg->iml->rmod->gamma); simg->iml->rmod->gamma);
} }
if (simg->iml->gmod) { if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness,
simg->iml->gmod->gamma); simg->iml->gmod->contrast, simg->iml->gmod->gamma);
} }
if (simg->iml->bmod) { if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness,
simg->iml->bmod->gamma); simg->iml->bmod->contrast, simg->iml->bmod->gamma);
} }
#endif #endif
if (simg->iml->border) { if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right,
simg->iml->border->bottom); simg->iml->border->top, simg->iml->border->bottom);
} }
if (simg->iml->bevel) { if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"),
simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top,
simg->iml->bevel->edges->bottom);
} }
if (simg->iml->pad) { if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top,
@ -3849,11 +3873,11 @@ save_config(char *path, unsigned char save_theme)
fprintf(fp, " min_anchor_size %d\n", rs_min_anchor_size); fprintf(fp, " min_anchor_size %d\n", rs_min_anchor_size);
fprintf(fp, " border_width %d\n", TermWin.internalBorder); fprintf(fp, " border_width %d\n", TermWin.internalBorder);
fprintf(fp, " term_name %s\n", getenv("TERM")); fprintf(fp, " term_name %s\n", getenv("TERM"));
fprintf(fp, " beep_command \"%s\"\n", SPIF_CAST_PTR(char) ( fprintf(fp, " beep_command \"%s\"\n", SPIF_CAST_PTR(char) ((rs_beep_command)
(rs_beep_command)
? (SPIF_CAST_PTR(char) rs_beep_command) ? (SPIF_CAST_PTR(char) rs_beep_command)
: (SPIF_CAST_PTR(char) "") : (SPIF_CAST_PTR(char) "")
)); ));
fprintf(fp, " debug %d\n", DEBUG_LEVEL); fprintf(fp, " debug %d\n", DEBUG_LEVEL);
if (save_theme && rs_exec_args && rs_theme && strcmp(rs_theme, PACKAGE)) { if (save_theme && rs_exec_args && rs_theme && strcmp(rs_theme, PACKAGE)) {
fprintf(fp, " exec "); fprintf(fp, " exec ");

View File

@ -95,55 +95,55 @@ const char *
get_image_type(unsigned char type) get_image_type(unsigned char type)
{ {
switch (type) { switch (type) {
case image_bg: case image_bg:
return "image_bg"; return "image_bg";
break; break;
case image_up: case image_up:
return "image_up"; return "image_up";
break; break;
case image_down: case image_down:
return "image_down"; return "image_down";
break; break;
case image_left: case image_left:
return "image_left"; return "image_left";
break; break;
case image_right: case image_right:
return "image_right"; return "image_right";
break; break;
case image_sb: case image_sb:
return "image_sb"; return "image_sb";
break; break;
case image_sa: case image_sa:
return "image_sa"; return "image_sa";
break; break;
case image_st: case image_st:
return "image_st"; return "image_st";
break; break;
case image_menu: case image_menu:
return "image_menu"; return "image_menu";
break; break;
case image_menuitem: case image_menuitem:
return "image_menuitem"; return "image_menuitem";
break; break;
case image_submenu: case image_submenu:
return "image_submenu"; return "image_submenu";
break; break;
case image_button: case image_button:
return "image_button"; return "image_button";
break; break;
case image_bbar: case image_bbar:
return "image_bbar"; return "image_bbar";
break; break;
case image_gbar: case image_gbar:
return "image_gbar"; return "image_gbar";
break; break;
case image_dialog: case image_dialog:
return "image_dialog"; return "image_dialog";
break; break;
case image_max: case image_max:
default: default:
return "image_max"; return "image_max";
break; break;
} }
ASSERT_NOTREACHED_RVAL(""); ASSERT_NOTREACHED_RVAL("");
} }
@ -162,52 +162,52 @@ const char *
imlib_strerror(Imlib_Load_Error err) imlib_strerror(Imlib_Load_Error err)
{ {
switch (err) { switch (err) {
case IMLIB_LOAD_ERROR_NONE: case IMLIB_LOAD_ERROR_NONE:
return "Success"; return "Success";
break; break;
case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST:
return "No such file or directory"; return "No such file or directory";
break; break;
case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY:
return "Is a directory"; return "Is a directory";
break; break;
case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ:
return "Permission denied"; return "Permission denied";
break; break;
case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT: case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT:
return "No loader available for that file format"; return "No loader available for that file format";
break; break;
case IMLIB_LOAD_ERROR_PATH_TOO_LONG: case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
return "Path too long"; return "Path too long";
break; break;
case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT: case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
return "Path component does not exist"; return "Path component does not exist";
break; break;
case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY: case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY:
return "Path component is not a directory"; return "Path component is not a directory";
break; break;
case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE: case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
return "Path points outside address space"; return "Path points outside address space";
break; break;
case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS: case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
return "Too many symbolic links in path"; return "Too many symbolic links in path";
break; break;
case IMLIB_LOAD_ERROR_OUT_OF_MEMORY: case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
return "Out of memory"; return "Out of memory";
break; break;
case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS: case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS:
return "No more file descriptors"; return "No more file descriptors";
break; break;
case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE: case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE:
return "Permission denied"; return "Permission denied";
break; break;
case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE:
return "Disk full"; return "Disk full";
break; break;
case IMLIB_LOAD_ERROR_UNKNOWN: case IMLIB_LOAD_ERROR_UNKNOWN:
default: default:
return "Unknown error"; return "Unknown error";
break; break;
} }
ASSERT_NOTREACHED_RVAL(""); ASSERT_NOTREACHED_RVAL("");
} }
@ -334,7 +334,8 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap)
pmap->op = op; pmap->op = op;
changed++; changed++;
} }
D_PIXMAP(("Returning %hu, *pmap == { op [%hu], w [%hd], h [%hd], x [%hd], y [%hd] }\n", changed, pmap->op, pmap->w, pmap->h, pmap->x, pmap->y)); D_PIXMAP(("Returning %hu, *pmap == { op [%hu], w [%hd], h [%hd], x [%hd], y [%hd] }\n", changed, pmap->op, pmap->w, pmap->h,
pmap->x, pmap->y));
return changed; return changed;
} }
@ -538,54 +539,54 @@ static const char *
get_iclass_name(unsigned char which) get_iclass_name(unsigned char which)
{ {
switch (which) { switch (which) {
case image_bg: case image_bg:
return "ETERM_BG"; return "ETERM_BG";
break; break;
case image_up: case image_up:
return "ETERM_ARROW_UP"; return "ETERM_ARROW_UP";
break; break;
case image_down: case image_down:
return "ETERM_ARROW_DOWN"; return "ETERM_ARROW_DOWN";
break; break;
case image_left: case image_left:
return "ETERM_ARROW_LEFT"; return "ETERM_ARROW_LEFT";
break; break;
case image_right: case image_right:
return "ETERM_ARROW_RIGHT"; return "ETERM_ARROW_RIGHT";
break; break;
case image_sb: case image_sb:
return "ETERM_TROUGH"; return "ETERM_TROUGH";
break; break;
case image_sa: case image_sa:
return "ETERM_ANCHOR"; return "ETERM_ANCHOR";
break; break;
case image_st: case image_st:
return "ETERM_THUMB"; return "ETERM_THUMB";
break; break;
case image_menu: case image_menu:
return "ETERM_MENU_ITEM"; return "ETERM_MENU_ITEM";
break; /* FIXME: This should be ETERM_MENU_BOX */ break; /* FIXME: This should be ETERM_MENU_BOX */
case image_menuitem: case image_menuitem:
return "ETERM_MENU_ITEM"; return "ETERM_MENU_ITEM";
break; break;
case image_submenu: case image_submenu:
return "ETERM_MENU_SUBMENU"; return "ETERM_MENU_SUBMENU";
break; break;
case image_button: case image_button:
return "ETERM_MENU_ITEM"; return "ETERM_MENU_ITEM";
break; /* FIXME: These four should */ break; /* FIXME: These four should */
case image_bbar: case image_bbar:
return "ETERM_MENU_BOX"; return "ETERM_MENU_BOX";
break; /* have their own image classes */ break; /* have their own image classes */
case image_gbar: case image_gbar:
return "ETERM_ANCHOR"; return "ETERM_ANCHOR";
break; break;
case image_dialog: case image_dialog:
return "ETERM_MENU_BOX"; return "ETERM_MENU_BOX";
break; break;
default: default:
ASSERT_NOTREACHED_RVAL(NULL); ASSERT_NOTREACHED_RVAL(NULL);
break; break;
} }
} }
@ -628,7 +629,8 @@ check_image_ipc(unsigned char reset)
} }
); );
/* *INDENT-ON* */ /* *INDENT-ON* */
print_error("Looks like this version of Enlightenment doesn't support the IPC " "commands I need. Disallowing \"auto\" mode for all images.\n"); print_error("Looks like this version of Enlightenment doesn't support the IPC "
"commands I need. Disallowing \"auto\" mode for all images.\n");
FREE(reply); FREE(reply);
checked = 2; checked = 2;
return 0; return 0;
@ -668,7 +670,8 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
} }
p = LIBAST_X_CREATE_PIXMAP(width, height); p = LIBAST_X_CREATE_PIXMAP(width, height);
gc = LIBAST_X_CREATE_GC(0, NULL); gc = LIBAST_X_CREATE_GC(0, NULL);
D_PIXMAP(("Created p [0x%08x] as a %hux%hu pixmap at %d, %d relative to window 0x%08x\n", p, width, height, x, y, desktop_window)); D_PIXMAP(("Created p [0x%08x] as a %hux%hu pixmap at %d, %d relative to window 0x%08x\n", p, width, height, x, y,
desktop_window));
if (p != None) { if (p != None) {
if (pw < scr->width || ph < scr->height) { if (pw < scr->width || ph < scr->height) {
D_PIXMAP(("Tiling %ux%u desktop pixmap 0x%08x onto p.\n", pw, ph, desktop_pixmap)); D_PIXMAP(("Tiling %ux%u desktop pixmap 0x%08x onto p.\n", pw, ph, desktop_pixmap));
@ -677,10 +680,12 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
XSetFillStyle(Xdisplay, gc, FillTiled); XSetFillStyle(Xdisplay, gc, FillTiled);
XFillRectangle(Xdisplay, p, gc, 0, 0, width, height); XFillRectangle(Xdisplay, p, gc, 0, 0, width, height);
} else { } else {
D_PIXMAP(("Copying %hux%hu rectangle at %d, %d from %ux%u desktop pixmap 0x%08x onto p.\n", width, height, x, y, pw, ph, desktop_pixmap)); D_PIXMAP(("Copying %hux%hu rectangle at %d, %d from %ux%u desktop pixmap 0x%08x onto p.\n", width, height, x, y, pw, ph,
desktop_pixmap));
XCopyArea(Xdisplay, desktop_pixmap, p, gc, x, y, width, height, 0, 0); XCopyArea(Xdisplay, desktop_pixmap, p, gc, x, y, width, height, 0, 0);
} }
if ((which != image_bg || (BITFIELD_IS_SET(image_options, IMAGE_OPTIONS_ITRANS)) || images[image_bg].current != images[image_bg].norm) if ((which != image_bg || (BITFIELD_IS_SET(image_options, IMAGE_OPTIONS_ITRANS))
|| images[image_bg].current != images[image_bg].norm)
&& need_colormod(simg->iml)) { && need_colormod(simg->iml)) {
colormod_trans(p, simg->iml, gc, width, height); colormod_trans(p, simg->iml, gc, width, height);
} }
@ -782,13 +787,15 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
} }
void void
paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsigned short x, unsigned short y, unsigned short w, unsigned short h) paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsigned short x, unsigned short y, unsigned short w,
unsigned short h)
{ {
Pixmap pmap = None, mask = None; Pixmap pmap = None, mask = None;
GC gc; GC gc;
ASSERT(simg != NULL); ASSERT(simg != NULL);
D_PIXMAP(("paste_simage(%8p, %s, 0x%08x, 0x%08x, %hd, %hd, %hd, %hd) called.\n", simg, get_image_type(which), (int) win, (int) d, x, y, w, h)); D_PIXMAP(("paste_simage(%8p, %s, 0x%08x, 0x%08x, %hd, %hd, %hd, %hd) called.\n", simg, get_image_type(which), (int) win,
(int) d, x, y, w, h));
REQUIRE(d != None); REQUIRE(d != None);
REQUIRE(w > 0); REQUIRE(w > 0);
@ -814,7 +821,8 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) d, state, w, h); snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) d, state, w, h);
reply = enl_send_and_wait(buff); reply = enl_send_and_wait(buff);
if (strstr(reply, "Error")) { if (strstr(reply, "Error")) {
print_error("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n"); print_error
("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
image_mode_fallback(which); image_mode_fallback(which);
FREE(reply); FREE(reply);
} else { } else {
@ -832,7 +840,8 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
LIBAST_X_FREE_GC(gc); LIBAST_X_FREE_GC(gc);
return; return;
} else { } else {
print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n"); print_error
("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
FREE(reply); FREE(reply);
image_mode_fallback(which); image_mode_fallback(which);
} }
@ -905,31 +914,31 @@ redraw_image(unsigned char which)
{ {
switch (which) { switch (which) {
case image_bg: case image_bg:
render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0);
scr_touch(); scr_touch();
break; break;
case image_up: case image_up:
scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, MODE_MASK); scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, MODE_MASK);
break; break;
case image_down: case image_down:
scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, MODE_MASK); scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, MODE_MASK);
break; break;
case image_sb: case image_sb:
scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK); scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK);
break; break;
case image_sa: case image_sa:
case image_st: case image_st:
scrollbar_draw_anchor(IMAGE_STATE_CURRENT, MODE_MASK); scrollbar_draw_anchor(IMAGE_STATE_CURRENT, MODE_MASK);
break; break;
case image_button: case image_button:
case image_bbar: case image_bbar:
case image_gbar: case image_gbar:
bbar_draw_all(IMAGE_STATE_CURRENT, MODE_MASK); bbar_draw_all(IMAGE_STATE_CURRENT, MODE_MASK);
break; break;
default: default:
D_PIXMAP(("Bad value %u\n", which)); D_PIXMAP(("Bad value %u\n", which));
break; break;
} }
} }
@ -998,7 +1007,8 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
ASSERT(simg->iml != NULL); ASSERT(simg->iml != NULL);
ASSERT(simg->pmap != NULL); ASSERT(simg->pmap != NULL);
REQUIRE(win != None); REQUIRE(win != None);
D_PIXMAP(("Rendering simg->iml->im %8p (%s) at %hux%hu onto window 0x%08x\n", simg->iml->im, get_image_type(which), width, height, win)); D_PIXMAP(("Rendering simg->iml->im %8p (%s) at %hux%hu onto window 0x%08x\n", simg->iml->im, get_image_type(which), width,
height, win));
D_PIXMAP(("Image mode is 0x%02x\n", images[which].mode)); D_PIXMAP(("Image mode is 0x%02x\n", images[which].mode));
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
if ((which == image_bg) && image_mode_is(image_bg, MODE_VIEWPORT)) { if ((which == image_bg) && image_mode_is(image_bg, MODE_VIEWPORT)) {
@ -1015,7 +1025,6 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
LIBAST_X_FREE_PIXMAP(buffer_pixmap); LIBAST_X_FREE_PIXMAP(buffer_pixmap);
buffer_pixmap = None; buffer_pixmap = None;
} }
#ifdef PIXMAP_SUPPORT #ifdef PIXMAP_SUPPORT
/* Reset window shape mask. */ /* Reset window shape mask. */
shaped_window_apply_mask(win, None); shaped_window_apply_mask(win, None);
@ -1038,10 +1047,12 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
if (renderop & RENDER_FORCE_PIXMAP) { if (renderop & RENDER_FORCE_PIXMAP) {
char *reply; char *reply;
snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) win, state, width, height); snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) win, state, width,
height);
reply = enl_send_and_wait(buff); reply = enl_send_and_wait(buff);
if (strstr(reply, "Error")) { if (strstr(reply, "Error")) {
print_error("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n"); print_error
("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n");
image_mode_fallback(which); image_mode_fallback(which);
FREE(reply); FREE(reply);
} else { } else {
@ -1070,7 +1081,8 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap); snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
enl_ipc_send(buff); enl_ipc_send(buff);
} else { } else {
print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n"); print_error
("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
FREE(reply); FREE(reply);
image_mode_fallback(which); image_mode_fallback(which);
} }
@ -1107,7 +1119,8 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) { } else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) {
Pixmap p; Pixmap p;
D_PIXMAP(("Viewport mode enabled. viewport_pixmap == 0x%08x and simg->pmap->pixmap == 0x%08x\n", viewport_pixmap, simg->pmap->pixmap)); D_PIXMAP(("Viewport mode enabled. viewport_pixmap == 0x%08x and simg->pmap->pixmap == 0x%08x\n", viewport_pixmap,
simg->pmap->pixmap));
p = create_viewport_pixmap(simg, win, 0, 0, width, height); p = create_viewport_pixmap(simg, win, 0, 0, width, height);
if (p && (p != simg->pmap->pixmap)) { if (p && (p != simg->pmap->pixmap)) {
if (simg->pmap->pixmap != None) { if (simg->pmap->pixmap != None) {
@ -1272,7 +1285,8 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg))); XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg)));
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
if (simg->iml->bevel != NULL && simg->iml->bevel->edges != NULL) { if (simg->iml->bevel != NULL && simg->iml->bevel->edges != NULL) {
DRAW_SOLID_BEVEL(simg->pmap->pixmap, width, height, simg->bg, simg->iml->bevel->up, simg->iml->bevel->edges->left); DRAW_SOLID_BEVEL(simg->pmap->pixmap, width, height, simg->bg, simg->iml->bevel->up,
simg->iml->bevel->edges->left);
} }
/* FIXME: For efficiency, just fill the window with the pixmap /* FIXME: For efficiency, just fill the window with the pixmap
and handle exposes by copying from simg->pmap->pixmap. */ and handle exposes by copying from simg->pmap->pixmap. */
@ -1858,35 +1872,35 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h
} }
/* Determine bitshift and bitmask values */ /* Determine bitshift and bitmask values */
switch (real_depth) { switch (real_depth) {
case 15: case 15:
#ifdef HAVE_MMX #ifdef HAVE_MMX
shade_ximage_15_mmx(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); shade_ximage_15_mmx(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
#else #else
shade_ximage_15(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); shade_ximage_15(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
#endif #endif
break; break;
case 16: case 16:
#ifdef HAVE_MMX #ifdef HAVE_MMX
shade_ximage_16_mmx(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); shade_ximage_16_mmx(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
#else #else
shade_ximage_16(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); shade_ximage_16(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
#endif #endif
break; break;
case 24: case 24:
if (ximg->bits_per_pixel != 32) { if (ximg->bits_per_pixel != 32) {
shade_ximage_24(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); shade_ximage_24(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
} }
/* drop */ /* drop */
case 32: case 32:
#ifdef HAVE_MMX #ifdef HAVE_MMX
shade_ximage_32_mmx(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); shade_ximage_32_mmx(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
#else #else
shade_ximage_32(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); shade_ximage_32(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm);
#endif #endif
break; break;
default: default:
print_warning("Bit depth of %d is unsupported for tinting/shading.\n", real_depth); print_warning("Bit depth of %d is unsupported for tinting/shading.\n", real_depth);
return; return;
} }
} }
XPutImage(Xdisplay, p, gc, ximg, 0, 0, 0, 0, w, h); XPutImage(Xdisplay, p, gc, ximg, 0, 0, 0, 0, w, h);
@ -1928,7 +1942,8 @@ update_desktop_info(int *w, int *h)
XGetGeometry(Xdisplay, desktop_pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd); XGetGeometry(Xdisplay, desktop_pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd);
} }
if ((pw <= 0) || (ph <= 0)) { if ((pw <= 0) || (ph <= 0)) {
print_error("Value of desktop pixmap property is invalid. Please restart your \n" "window manager or use Esetroot to set a new one."); print_error("Value of desktop pixmap property is invalid. Please restart your \n"
"window manager or use Esetroot to set a new one.");
desktop_pixmap = None; desktop_pixmap = None;
return 0; return 0;
} }
@ -1970,8 +1985,12 @@ get_desktop_window(void)
} }
if ((XGetWindowProperty(Xdisplay, w, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data)) != Success) { if ((XGetWindowProperty
if ((XGetWindowProperty(Xdisplay, w, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data)) != Success) { (Xdisplay, w, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after,
&data)) != Success) {
if ((XGetWindowProperty
(Xdisplay, w, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after,
&data)) != Success) {
continue; continue;
} }
} }
@ -2020,7 +2039,8 @@ get_desktop_pixmap(void)
LIBAST_X_FREE_PIXMAP(color_pixmap); LIBAST_X_FREE_PIXMAP(color_pixmap);
color_pixmap = None; color_pixmap = None;
} }
XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data); XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_PIXMAP], 0L, 1L, False, AnyPropertyType, &type, &format, &length,
&after, &data);
if (type == XA_PIXMAP) { if (type == XA_PIXMAP) {
p = *((Pixmap *) data); p = *((Pixmap *) data);
XFree(data); XFree(data);
@ -2068,7 +2088,8 @@ get_desktop_pixmap(void)
} else { } else {
XFree(data); XFree(data);
} }
XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data); XGetWindowProperty(Xdisplay, desktop_window, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length,
&after, &data);
if (type == XA_CARDINAL) { if (type == XA_CARDINAL) {
XGCValues gcvalue; XGCValues gcvalue;
GC gc; GC gc;
@ -2172,7 +2193,8 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
if (XGetIconSizes(Xdisplay, Xroot, &icon_sizes, &count)) { if (XGetIconSizes(Xdisplay, Xroot, &icon_sizes, &count)) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
D_PIXMAP(("Got icon sizes: Width %d to %d +/- %d, Height %d to %d +/- %d\n", icon_sizes[i].min_width, D_PIXMAP(("Got icon sizes: Width %d to %d +/- %d, Height %d to %d +/- %d\n", icon_sizes[i].min_width,
icon_sizes[i].max_width, icon_sizes[i].width_inc, icon_sizes[i].min_height, icon_sizes[i].max_height, icon_sizes[i].height_inc)); icon_sizes[i].max_width, icon_sizes[i].width_inc, icon_sizes[i].min_height,
icon_sizes[i].max_height, icon_sizes[i].height_inc));
if (icon_sizes[i].max_width > 64 || icon_sizes[i].max_height > 64) { if (icon_sizes[i].max_width > 64 || icon_sizes[i].max_height > 64) {
continue; continue;
} }

View File

@ -398,21 +398,21 @@ scr_cursor(int mode)
D_SCREEN(("scr_cursor(%s)\n", (mode == SAVE ? "SAVE" : "RESTORE"))); D_SCREEN(("scr_cursor(%s)\n", (mode == SAVE ? "SAVE" : "RESTORE")));
switch (mode) { switch (mode) {
case SAVE: case SAVE:
save.row = screen.row; save.row = screen.row;
save.col = screen.col; save.col = screen.col;
save.rstyle = rstyle; save.rstyle = rstyle;
save.charset = screen.charset; save.charset = screen.charset;
save.charset_char = charsets[screen.charset]; save.charset_char = charsets[screen.charset];
break; break;
case RESTORE: case RESTORE:
screen.row = save.row; screen.row = save.row;
screen.col = save.col; screen.col = save.col;
rstyle = save.rstyle; rstyle = save.rstyle;
screen.charset = save.charset; screen.charset = save.charset;
charsets[screen.charset] = save.charset_char; charsets[screen.charset] = save.charset_char;
set_font_style(); set_font_style();
break; break;
} }
} }
@ -483,12 +483,12 @@ scr_color(unsigned int color, unsigned int Intensity)
else { else {
if (Xdepth <= 2) { /* Monochrome - ignore color changes */ if (Xdepth <= 2) { /* Monochrome - ignore color changes */
switch (Intensity) { switch (Intensity) {
case RS_Bold: case RS_Bold:
color = fgColor; color = fgColor;
break; break;
case RS_Blink: case RS_Blink:
color = bgColor; color = bgColor;
break; break;
} }
} else { } else {
if ((rstyle & Intensity) && (color >= minColor) && (color <= maxColor)) { if ((rstyle & Intensity) && (color >= minColor) && (color <= maxColor)) {
@ -508,12 +508,12 @@ scr_color(unsigned int color, unsigned int Intensity)
} }
} }
switch (Intensity) { switch (Intensity) {
case RS_Bold: case RS_Bold:
rstyle = SET_FGCOLOR(rstyle, color); rstyle = SET_FGCOLOR(rstyle, color);
break; break;
case RS_Blink: case RS_Blink:
rstyle = SET_BGCOLOR(rstyle, color); rstyle = SET_BGCOLOR(rstyle, color);
break; break;
} }
} }
@ -531,47 +531,47 @@ scr_rendition(int set, int style)
/* A: Set style */ /* A: Set style */
rstyle |= style; rstyle |= style;
switch (style) { switch (style) {
case RS_RVid: case RS_RVid:
if (rvideo) if (rvideo)
rstyle &= ~RS_RVid; rstyle &= ~RS_RVid;
break; break;
case RS_Bold: case RS_Bold:
color = GET_FGCOLOR(rstyle); color = GET_FGCOLOR(rstyle);
scr_color((color == fgColor ? GET_FGCOLOR(colorfgbg) : color), RS_Bold); scr_color((color == fgColor ? GET_FGCOLOR(colorfgbg) : color), RS_Bold);
break; break;
case RS_Blink: case RS_Blink:
color = GET_BGCOLOR(rstyle); color = GET_BGCOLOR(rstyle);
scr_color((color == bgColor ? GET_BGCOLOR(colorfgbg) : color), RS_Blink); scr_color((color == bgColor ? GET_BGCOLOR(colorfgbg) : color), RS_Blink);
break; break;
} }
} else { } else {
/* B: Unset style */ /* B: Unset style */
rstyle &= ~style; rstyle &= ~style;
switch (style) { switch (style) {
case ~RS_None: /* default fg/bg colors */ case ~RS_None: /* default fg/bg colors */
rstyle = DEFAULT_RSTYLE | (old_style & RS_fontMask); rstyle = DEFAULT_RSTYLE | (old_style & RS_fontMask);
/* FALLTHROUGH */ /* FALLTHROUGH */
case RS_RVid: case RS_RVid:
if (rvideo) if (rvideo)
rstyle |= RS_RVid; rstyle |= RS_RVid;
break; break;
case RS_Bold: case RS_Bold:
color = GET_FGCOLOR(rstyle); color = GET_FGCOLOR(rstyle);
if (color >= minBright && color <= maxBright) { if (color >= minBright && color <= maxBright) {
scr_color(color, RS_Bold); scr_color(color, RS_Bold);
if ((rstyle & RS_fgMask) == (colorfgbg & RS_fgMask)) if ((rstyle & RS_fgMask) == (colorfgbg & RS_fgMask))
scr_color(restoreFG, RS_Bold); scr_color(restoreFG, RS_Bold);
} }
break; break;
case RS_Blink: case RS_Blink:
color = GET_BGCOLOR(rstyle); color = GET_BGCOLOR(rstyle);
if (color >= minBright && color <= maxBright) { if (color >= minBright && color <= maxBright) {
scr_color(color, RS_Blink); scr_color(color, RS_Blink);
if ((rstyle & RS_bgMask) == (colorfgbg & RS_bgMask)) if ((rstyle & RS_bgMask) == (colorfgbg & RS_bgMask))
scr_color(restoreBG, RS_Blink); scr_color(restoreBG, RS_Blink);
} }
break; break;
} }
} }
} }
@ -752,35 +752,35 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
} else } else
#endif #endif
switch (c) { switch (c) {
case 127: case 127:
continue; /* ummmm..... */ continue; /* ummmm..... */
case '\t': case '\t':
scr_tab(1); scr_tab(1);
continue; continue;
case '\n': case '\n':
LOWER_BOUND(stp[last_col], screen.col); LOWER_BOUND(stp[last_col], screen.col);
screen.flags &= ~Screen_WrapNext; screen.flags &= ~Screen_WrapNext;
if (screen.row == screen.bscroll) { if (screen.row == screen.bscroll) {
scroll_text(screen.tscroll, screen.bscroll, 1, 0); scroll_text(screen.tscroll, screen.bscroll, 1, 0);
j = screen.bscroll + TermWin.saveLines; j = screen.bscroll + TermWin.saveLines;
blank_screen_mem(screen.text, screen.rend, j, rstyle & ~(RS_Uline|RS_Overscore)); blank_screen_mem(screen.text, screen.rend, j, rstyle & ~(RS_Uline | RS_Overscore));
} else if (screen.row < (TERM_WINDOW_GET_REPORTED_ROWS() - 1)) { } else if (screen.row < (TERM_WINDOW_GET_REPORTED_ROWS() - 1)) {
screen.row++; screen.row++;
row = screen.row + TermWin.saveLines; row = screen.row + TermWin.saveLines;
} }
stp = screen.text[row]; /* _must_ refresh */ stp = screen.text[row]; /* _must_ refresh */
srp = screen.rend[row]; /* _must_ refresh */ srp = screen.rend[row]; /* _must_ refresh */
continue; continue;
case '\r': case '\r':
LOWER_BOUND(stp[last_col], screen.col); LOWER_BOUND(stp[last_col], screen.col);
screen.flags &= ~Screen_WrapNext; screen.flags &= ~Screen_WrapNext;
screen.col = 0; screen.col = 0;
continue; continue;
default: default:
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
rstyle &= ~RS_multiMask; rstyle &= ~RS_multiMask;
#endif #endif
break; break;
} }
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
} }
@ -792,7 +792,7 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
j = screen.bscroll + TermWin.saveLines; j = screen.bscroll + TermWin.saveLines;
/* blank_line(screen.text[j], screen.rend[j], TermWin.ncol, /* blank_line(screen.text[j], screen.rend[j], TermWin.ncol,
rstyle); Bug fix from John Ellison - need to reset rstyle */ rstyle); Bug fix from John Ellison - need to reset rstyle */
blank_screen_mem(screen.text, screen.rend, j, rstyle & ~(RS_Uline|RS_Overscore)); blank_screen_mem(screen.text, screen.rend, j, rstyle & ~(RS_Uline | RS_Overscore));
} else if (screen.row < (TERM_WINDOW_GET_REPORTED_ROWS() - 1)) { } else if (screen.row < (TERM_WINDOW_GET_REPORTED_ROWS() - 1)) {
screen.row++; screen.row++;
row = screen.row + TermWin.saveLines; row = screen.row + TermWin.saveLines;
@ -832,7 +832,7 @@ scr_add_lines(const unsigned char *str, int nlines, int len)
#ifdef ESCREEN #ifdef ESCREEN
if (NS_MAGIC_LINE(TermWin.screen_mode)) { if (NS_MAGIC_LINE(TermWin.screen_mode)) {
if (screen.row >= TERM_WINDOW_GET_ROWS()) { /* last row -> upd-flag */ if (screen.row >= TERM_WINDOW_GET_ROWS()) { /* last row -> upd-flag */
TermWin.screen_pending |= 1; TermWin.screen_pending |= 1;
} }
} }
@ -928,7 +928,7 @@ scr_gotorc(int row, int col, int relative)
} }
#ifdef ESCREEN #ifdef ESCREEN
if (NS_MAGIC_LINE(TermWin.screen_mode)) { if (NS_MAGIC_LINE(TermWin.screen_mode)) {
if (screen.row >= TERM_WINDOW_GET_ROWS()) { /* last row -> upd-flag */ if (screen.row >= TERM_WINDOW_GET_ROWS()) { /* last row -> upd-flag */
TermWin.screen_pending |= 1; TermWin.screen_pending |= 1;
} else if (TermWin.screen_pending) { /* left last -> upd-finis */ } else if (TermWin.screen_pending) { /* left last -> upd-finis */
TermWin.screen_pending |= 2; TermWin.screen_pending |= 2;
@ -993,26 +993,26 @@ scr_erase_line(int mode)
if (screen.text[row]) { if (screen.text[row]) {
switch (mode) { switch (mode) {
case 0: /* erase to end of line */ case 0: /* erase to end of line */
col = screen.col; col = screen.col;
num = TERM_WINDOW_GET_REPORTED_COLS() - col; num = TERM_WINDOW_GET_REPORTED_COLS() - col;
UPPER_BOUND(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()], col); UPPER_BOUND(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()], col);
break; break;
case 1: /* erase to beginning of line */ case 1: /* erase to beginning of line */
col = 0; col = 0;
num = screen.col + 1; num = screen.col + 1;
break; break;
case 2: /* erase whole line */ case 2: /* erase whole line */
col = 0; col = 0;
num = TERM_WINDOW_GET_REPORTED_COLS(); num = TERM_WINDOW_GET_REPORTED_COLS();
screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0; screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0;
break; break;
default: default:
return; return;
} }
blank_line(&(screen.text[row][col]), &(screen.rend[row][col]), num, rstyle & ~(RS_Uline|RS_Overscore)); blank_line(&(screen.text[row][col]), &(screen.rend[row][col]), num, rstyle & ~(RS_Uline | RS_Overscore));
} else { } else {
blank_screen_mem(screen.text, screen.rend, row, rstyle & ~(RS_Uline|RS_Overscore)); blank_screen_mem(screen.text, screen.rend, row, rstyle & ~(RS_Uline | RS_Overscore));
} }
} }
@ -1046,24 +1046,24 @@ scr_erase_screen(int mode)
switch (mode) { switch (mode) {
case 0: /* erase to end of screen */ case 0: /* erase to end of screen */
scr_erase_line(0); scr_erase_line(0);
row = screen.row + 1; /* possible OOB */ row = screen.row + 1; /* possible OOB */
num = TERM_WINDOW_GET_REPORTED_ROWS() - row; num = TERM_WINDOW_GET_REPORTED_ROWS() - row;
break; break;
case 1: /* erase to beginning of screen */ case 1: /* erase to beginning of screen */
scr_erase_line(1); scr_erase_line(1);
row = 0; /* possible OOB */ row = 0; /* possible OOB */
num = screen.row; num = screen.row;
break; break;
case 2: /* erase whole screen */ case 2: /* erase whole screen */
row = 0; row = 0;
num = TERM_WINDOW_GET_REPORTED_ROWS(); num = TERM_WINDOW_GET_REPORTED_ROWS();
break; break;
default: default:
return; return;
} }
if (row >= 0 && row <= TERM_WINDOW_GET_REPORTED_ROWS()) { /* check OOB */ if (row >= 0 && row <= TERM_WINDOW_GET_REPORTED_ROWS()) { /* check OOB */
UPPER_BOUND(num, (TERM_WINDOW_GET_REPORTED_ROWS() - row)); UPPER_BOUND(num, (TERM_WINDOW_GET_REPORTED_ROWS() - row));
if (rstyle & RS_RVid || rstyle & RS_Uline || rstyle & RS_Overscore) if (rstyle & RS_RVid || rstyle & RS_Uline || rstyle & RS_Overscore)
ren = -1; ren = -1;
@ -1172,27 +1172,28 @@ scr_insdel_chars(int count, int insdel)
screen.flags &= ~Screen_WrapNext; screen.flags &= ~Screen_WrapNext;
switch (insdel) { switch (insdel) {
case INSERT: case INSERT:
for (col = TERM_WINDOW_GET_REPORTED_COLS() - 1; (col - count) >= screen.col; col--) { for (col = TERM_WINDOW_GET_REPORTED_COLS() - 1; (col - count) >= screen.col; col--) {
screen.text[row][col] = screen.text[row][col - count]; screen.text[row][col] = screen.text[row][col - count];
screen.rend[row][col] = screen.rend[row][col - count]; screen.rend[row][col] = screen.rend[row][col - count];
} }
screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] += count; screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] += count;
UPPER_BOUND(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()], TERM_WINDOW_GET_REPORTED_COLS()); UPPER_BOUND(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()], TERM_WINDOW_GET_REPORTED_COLS());
/* FALLTHROUGH */ /* FALLTHROUGH */
case ERASE: case ERASE:
blank_line(&(screen.text[row][screen.col]), &(screen.rend[row][screen.col]), count, rstyle); blank_line(&(screen.text[row][screen.col]), &(screen.rend[row][screen.col]), count, rstyle);
break; break;
case DELETE: case DELETE:
for (col = screen.col; (col + count) < TERM_WINDOW_GET_REPORTED_COLS(); col++) { for (col = screen.col; (col + count) < TERM_WINDOW_GET_REPORTED_COLS(); col++) {
screen.text[row][col] = screen.text[row][col + count]; screen.text[row][col] = screen.text[row][col + count];
screen.rend[row][col] = screen.rend[row][col + count]; screen.rend[row][col] = screen.rend[row][col + count];
} }
blank_line(&(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS() - count]), &(screen.rend[row][TERM_WINDOW_GET_REPORTED_COLS() - count]), count, rstyle); blank_line(&(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS() - count]),
screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] -= count; &(screen.rend[row][TERM_WINDOW_GET_REPORTED_COLS() - count]), count, rstyle);
if (((signed char) screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()]) < 0) screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] -= count;
screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0; if (((signed char) screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()]) < 0)
break; screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0;
break;
} }
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
if ((screen.rend[row][0] & RS_multiMask) == RS_multi2) { if ((screen.rend[row][0] & RS_multiMask) == RS_multi2) {
@ -1337,22 +1338,22 @@ set_font_style(void)
{ {
rstyle &= ~RS_fontMask; rstyle &= ~RS_fontMask;
switch (charsets[screen.charset]) { switch (charsets[screen.charset]) {
case '0': /* DEC Special Character & Line Drawing Set */ case '0': /* DEC Special Character & Line Drawing Set */
rstyle |= RS_acsFont; rstyle |= RS_acsFont;
break; break;
case 'A': /* United Kingdom (UK) */ case 'A': /* United Kingdom (UK) */
rstyle |= RS_ukFont; rstyle |= RS_ukFont;
break; break;
case 'B': /* United States (USASCII) */ case 'B': /* United States (USASCII) */
break; break;
case '<': /* Multinational character set */ case '<': /* Multinational character set */
break; break;
case '5': /* Finnish character set */ case '5': /* Finnish character set */
break; break;
case 'C': /* Finnish character set */ case 'C': /* Finnish character set */
break; break;
case 'K': /* German character set */ case 'K': /* German character set */
break; break;
} }
} }
@ -1495,7 +1496,8 @@ scr_expose(int x, int y, int width, int height)
rect_end.row = Pixel2Row(y + height + TermWin.fheight - 1); rect_end.row = Pixel2Row(y + height + TermWin.fheight - 1);
BOUND(rect_end.row, 0, nr); BOUND(rect_end.row, 0, nr);
D_SCREEN(("scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)\n", x, y, width, height, rect_beg.col, rect_beg.row, rect_end.col, rect_end.row)); D_SCREEN(("scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)\n", x, y, width, height, rect_beg.col, rect_beg.row,
rect_end.col, rect_end.row));
for (i = rect_beg.row; i <= rect_end.row; i++) { for (i = rect_beg.row; i <= rect_end.row; i++) {
MEMSET(&(drawn_text[i][rect_beg.col]), 0, rect_end.col - rect_beg.col + 1); MEMSET(&(drawn_text[i][rect_beg.col]), 0, rect_end.col - rect_beg.col + 1);
@ -1547,7 +1549,7 @@ scr_bell(void)
scr_rvideo_mode(!rvideo); scr_rvideo_mode(!rvideo);
scr_rvideo_mode(!rvideo); scr_rvideo_mode(!rvideo);
} else if (!SPIF_PTR_ISNULL(rs_beep_command) && (*rs_beep_command)) { } else if (!SPIF_PTR_ISNULL(rs_beep_command) && (*rs_beep_command)) {
system_no_wait(SPIF_CAST_C(char *) rs_beep_command); system_no_wait(SPIF_CAST_C(char *)rs_beep_command);
} else { } else {
XBell(Xdisplay, 0); XBell(Xdisplay, 0);
} }
@ -1619,14 +1621,14 @@ scr_refresh(int type)
scrrow, /* screen row offset */ scrrow, /* screen row offset */
row_offset, /* basic offset in screen structure */ row_offset, /* basic offset in screen structure */
boldlast = 0, /* last character in some row was bold */ boldlast = 0, /* last character in some row was bold */
len, wlen, /* text length screen/buffer */ len, wlen, /* text length screen/buffer */
fprop, /* proportional font used */ fprop, /* proportional font used */
is_cursor, /* cursor this position */ is_cursor, /* cursor this position */
rvid, /* reverse video this position */ rvid, /* reverse video this position */
fore, back, /* desired foreground/background */ fore, back, /* desired foreground/background */
wbyte, /* we're in multibyte */ wbyte, /* we're in multibyte */
xpixel, /* x offset for start of drawing (font) */ xpixel, /* x offset for start of drawing (font) */
ypixel; /* y offset for start of drawing (font) */ ypixel; /* y offset for start of drawing (font) */
register int col, row, /* column/row we're processing */ register int col, row, /* column/row we're processing */
rend; /* rendition */ rend; /* rendition */
static int focus = -1; /* screen in focus? */ static int focus = -1; /* screen in focus? */
@ -1657,15 +1659,15 @@ scr_refresh(int type)
PROF_INIT(scr_refresh); PROF_INIT(scr_refresh);
switch (type) { switch (type) {
case NO_REFRESH: case NO_REFRESH:
D_SCREEN(("scr_refresh(NO_REFRESH) called.\n")); D_SCREEN(("scr_refresh(NO_REFRESH) called.\n"));
break; break;
case SLOW_REFRESH: case SLOW_REFRESH:
D_SCREEN(("scr_refresh(SLOW_REFRESH) called.\n")); D_SCREEN(("scr_refresh(SLOW_REFRESH) called.\n"));
break; break;
case FAST_REFRESH: case FAST_REFRESH:
D_SCREEN(("scr_refresh(FAST_REFRESH) called.\n")); D_SCREEN(("scr_refresh(FAST_REFRESH) called.\n"));
break; break;
} }
if (type == NO_REFRESH) if (type == NO_REFRESH)
return; return;
@ -1870,18 +1872,18 @@ scr_refresh(int type)
} else } else
is_cursor = 0; is_cursor = 0;
switch (rend & RS_fontMask) { switch (rend & RS_fontMask) {
case RS_acsFont: case RS_acsFont:
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if (buffer[i] == 0x5f) if (buffer[i] == 0x5f)
buffer[i] = 0x7f; buffer[i] = 0x7f;
else if (buffer[i] > 0x5f && buffer[i] < 0x7f) else if (buffer[i] > 0x5f && buffer[i] < 0x7f)
buffer[i] -= 0x5f; buffer[i] -= 0x5f;
break; break;
case RS_ukFont: case RS_ukFont:
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if (buffer[i] == '#') if (buffer[i] == '#')
buffer[i] = 0x1e; buffer[i] = 0x1e;
break; break;
} }
if (rvid) if (rvid)
SWAP_IT(fore, back, i); SWAP_IT(fore, back, i);
@ -2057,10 +2059,12 @@ scr_refresh(int type)
gcmask |= (GCForeground | GCBackground); gcmask |= (GCForeground | GCBackground);
XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue);
if (font->ascent < ascent) { if (font->ascent < ascent) {
XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, Row2Pixel(row), Width2Pixel(len), ascent - font->ascent); XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, Row2Pixel(row), Width2Pixel(len),
ascent - font->ascent);
} }
if (font->descent < descent) { if (font->descent < descent) {
XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, Row2Pixel(row) + ascent + font->descent, Width2Pixel(len), descent - font->descent); XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, Row2Pixel(row) + ascent + font->descent,
Width2Pixel(len), descent - font->descent);
} }
SWAP_IT(gcvalue.foreground, gcvalue.background, ltmp); SWAP_IT(gcvalue.foreground, gcvalue.background, ltmp);
XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue);
@ -2088,7 +2092,8 @@ scr_refresh(int type)
} }
if (rend & RS_Overscore) { if (rend & RS_Overscore) {
if (ascent > 1) { if (ascent > 1) {
XDrawLine(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - ascent, xpixel + Width2Pixel(wlen) - 1, ypixel - ascent); XDrawLine(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - ascent, xpixel + Width2Pixel(wlen) - 1,
ypixel - ascent);
UPDATE_BOX(xpixel, ypixel + 1, xpixel + Width2Pixel(wlen) - 1, ypixel + 1); UPDATE_BOX(xpixel, ypixel + 1, xpixel + Width2Pixel(wlen) - 1, ypixel + 1);
} else { } else {
XDrawLine(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - 1, xpixel + Width2Pixel(wlen) - 1, ypixel - 1); XDrawLine(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - 1, xpixel + Width2Pixel(wlen) - 1, ypixel - 1);
@ -2101,7 +2106,8 @@ scr_refresh(int type)
XSetForeground(Xdisplay, TermWin.gc, PixColors[cursorColor]); XSetForeground(Xdisplay, TermWin.gc, PixColors[cursorColor]);
} }
#endif #endif
XDrawRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - ascent, Width2Pixel(1 + wbyte) - 1, Height2Pixel(1) - 1); XDrawRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - ascent, Width2Pixel(1 + wbyte) - 1,
Height2Pixel(1) - 1);
UPDATE_BOX(xpixel, ypixel - ascent, Width2Pixel(1 + wbyte) - 1, Height2Pixel(1) - 1); UPDATE_BOX(xpixel, ypixel - ascent, Width2Pixel(1 + wbyte) - 1, Height2Pixel(1) - 1);
XSetForeground(Xdisplay, TermWin.gc, PixColors[fgColor]); XSetForeground(Xdisplay, TermWin.gc, PixColors[fgColor]);
} }
@ -2133,18 +2139,22 @@ scr_refresh(int type)
#endif #endif
} }
if (buffer_pixmap) { if (buffer_pixmap) {
D_SCREEN(("Update box dimensions: from (%d, %d) to (%d, %d). Dimensions %dx%d\n", low_x, low_y, high_x, high_y, high_x - low_x + 1, high_y - low_y + 1)); D_SCREEN(("Update box dimensions: from (%d, %d) to (%d, %d). Dimensions %dx%d\n", low_x, low_y, high_x, high_y,
high_x - low_x + 1, high_y - low_y + 1));
XClearArea(Xdisplay, TermWin.vt, low_x, low_y, high_x - low_x + 1, high_y - low_y + 1, False); XClearArea(Xdisplay, TermWin.vt, low_x, low_y, high_x - low_x + 1, high_y - low_y + 1, False);
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) { if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_BOTTOM_LEFT]) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, TermWin.internalBorder - 1, 0); XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1,
TermWin.internalBorder - 1, 0);
XClearArea(Xdisplay, TermWin.vt, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, False); XClearArea(Xdisplay, TermWin.vt, TermWin.internalBorder - 1, 0, 1, TermWin_TotalHeight() - 1, False);
} }
if (fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) { if (fshadow.shadow[SHADOW_TOP_RIGHT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT] || boldlast) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, TermWin_TotalWidth() - 2, 0); XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1,
TermWin_TotalWidth() - 2, 0);
XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, False); XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, 1, TermWin_TotalHeight() - 1, False);
} }
if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP_RIGHT]) { if (fshadow.shadow[SHADOW_TOP_LEFT] || fshadow.shadow[SHADOW_TOP_RIGHT]) {
XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, 0, TermWin.internalBorder - 1); XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, 0,
TermWin.internalBorder - 1);
XClearArea(Xdisplay, TermWin.vt, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, False); XClearArea(Xdisplay, TermWin.vt, 0, TermWin.internalBorder - 1, TermWin_TotalWidth() - 1, 1, False);
} }
if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) { if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) {
@ -2439,7 +2449,9 @@ selection_fetch(Window win, unsigned prop, int delete)
return; return;
} }
for (nread = 0, bytes_after = 1; bytes_after > 0;) { for (nread = 0, bytes_after = 1; bytes_after > 0;) {
if ((XGetWindowProperty(Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems, &bytes_after, &data) != Success) if ((XGetWindowProperty
(Xdisplay, win, prop, (nread / 4), PROP_SIZE, delete, AnyPropertyType, &actual_type, &actual_fmt, &nitems,
&bytes_after, &data) != Success)
|| (actual_type == None) || (data == NULL)) { || (actual_type == None) || (data == NULL)) {
D_SELECT(("Unable to fetch the value of property %d from window 0x%08x\n", (int) prop, (int) win)); D_SELECT(("Unable to fetch the value of property %d from window 0x%08x\n", (int) prop, (int) win));
if (data != NULL) { if (data != NULL) {
@ -2448,7 +2460,8 @@ selection_fetch(Window win, unsigned prop, int delete)
return; return;
} }
nread += nitems; nread += nitems;
D_SELECT(("Got selection info: Actual type %d (format %d), %lu items at 0x%08x, %lu bytes left over.\n", (int) actual_type, actual_fmt, nitems, data, bytes_after)); D_SELECT(("Got selection info: Actual type %d (format %d), %lu items at 0x%08x, %lu bytes left over.\n", (int) actual_type,
actual_fmt, nitems, data, bytes_after));
if (nitems == 0) { if (nitems == 0) {
D_SELECT(("Retrieval of incremental selection complete.\n")); D_SELECT(("Retrieval of incremental selection complete.\n"));
@ -2460,7 +2473,8 @@ selection_fetch(Window win, unsigned prop, int delete)
/* We can handle strings directly. */ /* We can handle strings directly. */
selection_write(data, nitems); selection_write(data, nitems);
} else if (actual_type == props[PROP_SELECTION_INCR]) { } else if (actual_type == props[PROP_SELECTION_INCR]) {
D_SELECT(("Incremental selection transfer initiated. Length is at least %u bytes.\n", (unsigned) *((unsigned *) data))); D_SELECT(("Incremental selection transfer initiated. Length is at least %u bytes.\n",
(unsigned) *((unsigned *) data)));
TermWin.mask |= PropertyChangeMask; TermWin.mask |= PropertyChangeMask;
XSelectInput(Xdisplay, TermWin.vt, TermWin.mask); XSelectInput(Xdisplay, TermWin.vt, TermWin.mask);
} else { } else {
@ -2687,18 +2701,18 @@ selection_make(Time tm)
D_SELECT(("selection.op=%d, selection.clicks=%d\n", selection.op, selection.clicks)); D_SELECT(("selection.op=%d, selection.clicks=%d\n", selection.op, selection.clicks));
switch (selection.op) { switch (selection.op) {
case SELECTION_CONT: case SELECTION_CONT:
break; break;
case SELECTION_INIT: case SELECTION_INIT:
selection_reset(); selection_reset();
selection.end.row = selection.beg.row = selection.mark.row; selection.end.row = selection.beg.row = selection.mark.row;
selection.end.col = selection.beg.col = selection.mark.col; selection.end.col = selection.beg.col = selection.mark.col;
/* FALLTHROUGH */ /* FALLTHROUGH */
case SELECTION_BEGIN: case SELECTION_BEGIN:
selection.op = SELECTION_DONE; selection.op = SELECTION_DONE;
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
return; return;
} }
selection.op = SELECTION_DONE; selection.op = SELECTION_DONE;
@ -2901,7 +2915,8 @@ selection_delimit_word(int col, int row, row_col_t *beg, row_col_t *end)
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
srp = &(screen.rend[beg_row + row_offset - 1][last_col + 1]); srp = &(screen.rend[beg_row + row_offset - 1][last_col + 1]);
r = *(srp - 1); r = *(srp - 1);
if (DELIMIT_TEXT(t) == w1 && (!w1 || *stp == t || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT))) && DELIMIT_REND(r) == w2) { if (DELIMIT_TEXT(t) == w1 && (!w1 || *stp == t || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT)))
&& DELIMIT_REND(r) == w2) {
srp--; srp--;
#else #else
if (DELIMIT_TEXT(t) == w1 && (!w1 || *stp == t || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT)))) { if (DELIMIT_TEXT(t) == w1 && (!w1 || *stp == t || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT)))) {
@ -2962,9 +2977,12 @@ selection_delimit_word(int col, int row, row_col_t *beg, row_col_t *end)
stp = screen.text[end_row + row_offset + 1]; stp = screen.text[end_row + row_offset + 1];
#ifdef MULTI_CHARSET #ifdef MULTI_CHARSET
srp = screen.rend[end_row + row_offset + 1]; srp = screen.rend[end_row + row_offset + 1];
if (DELIMIT_TEXT(*stp) == w1 && (!w1 || *stp1 == *stp || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT))) && DELIMIT_REND(*srp) == w2) { if (DELIMIT_TEXT(*stp) == w1
&& (!w1 || *stp1 == *stp || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT)))
&& DELIMIT_REND(*srp) == w2) {
#else #else
if (DELIMIT_TEXT(*stp) == w1 && (!w1 || *stp1 == *stp || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT)))) { if (DELIMIT_TEXT(*stp) == w1
&& (!w1 || *stp1 == *stp || !(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_XTERM_SELECT)))) {
#endif #endif
end_row++; end_row++;
end_col = 0; end_col = 0;
@ -3038,24 +3056,24 @@ selection_extend_colrow(int col, int row, int flag, int cont)
D_SELECT(("selection_extend_colrow(%d, %d, %d, %d) clicks:%d\n", col, row, flag, cont, selection.clicks)); D_SELECT(("selection_extend_colrow(%d, %d, %d, %d) clicks:%d\n", col, row, flag, cont, selection.clicks));
switch (selection.op) { switch (selection.op) {
case SELECTION_INIT: case SELECTION_INIT:
selection_reset(); selection_reset();
selection.end.col = selection.beg.col = selection.mark.col; selection.end.col = selection.beg.col = selection.mark.col;
selection.end.row = selection.beg.row = selection.mark.row; selection.end.row = selection.beg.row = selection.mark.row;
selection.op = SELECTION_BEGIN; selection.op = SELECTION_BEGIN;
/* FALLTHROUGH */ /* FALLTHROUGH */
case SELECTION_BEGIN: case SELECTION_BEGIN:
break; break;
case SELECTION_DONE: case SELECTION_DONE:
selection.op = SELECTION_CONT; selection.op = SELECTION_CONT;
/* FALLTHROUGH */ /* FALLTHROUGH */
case SELECTION_CONT: case SELECTION_CONT:
break; break;
case SELECTION_CLEAR: case SELECTION_CLEAR:
selection_start_colrow(col, row); selection_start_colrow(col, row);
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
return; return;
} }
if ((selection.beg.row < -TermWin.nscrolled) if ((selection.beg.row < -TermWin.nscrolled)
|| (selection.end.row < -TermWin.nscrolled)) { || (selection.end.row < -TermWin.nscrolled)) {
@ -3285,7 +3303,8 @@ selection_send(XSelectionRequestEvent * rq)
target_list[0] = (Atom32) props[PROP_SELECTION_TARGETS]; target_list[0] = (Atom32) props[PROP_SELECTION_TARGETS];
target_list[1] = (Atom32) XA_STRING; target_list[1] = (Atom32) XA_STRING;
XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target,
(8 * sizeof(target_list[0])), PropModeReplace, (unsigned char *) target_list, (sizeof(target_list) / sizeof(target_list[0]))); (8 * sizeof(target_list[0])), PropModeReplace, (unsigned char *) target_list,
(sizeof(target_list) / sizeof(target_list[0])));
ev.xselection.property = rq->property; ev.xselection.property = rq->property;
#if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H) #if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H)
} else if (rq->target == XA_TEXT(Xdisplay) || rq->target == XA_COMPOUND_TEXT(Xdisplay)) { } else if (rq->target == XA_TEXT(Xdisplay) || rq->target == XA_COMPOUND_TEXT(Xdisplay)) {
@ -3297,7 +3316,8 @@ selection_send(XSelectionRequestEvent * rq)
xtextp.nitems = 0; xtextp.nitems = 0;
if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) { if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) {
if (xtextp.nitems > 0 && xtextp.value != NULL) { if (xtextp.nitems > 0 && xtextp.value != NULL) {
XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_COMPOUND_TEXT(Xdisplay), 8, PropModeReplace, xtextp.value, xtextp.nitems); XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_COMPOUND_TEXT(Xdisplay), 8, PropModeReplace, xtextp.value,
xtextp.nitems);
ev.xselection.property = rq->property; ev.xselection.property = rq->property;
} }
} }
@ -3315,22 +3335,23 @@ twin_mouse_drag_report(XButtonEvent * ev)
int button_number, key_state, x = Pixel2Col(ev->x), y = Pixel2Row(ev->y); int button_number, key_state, x = Pixel2Col(ev->x), y = Pixel2Row(ev->y);
switch (ev->button) { switch (ev->button) {
case AnyButton: /* Button release */ case AnyButton: /* Button release */
button_number = pb + Button1; /* yeah, yeah */ button_number = pb + Button1; /* yeah, yeah */
break; break;
case Button1: /* Button press */ case Button1: /* Button press */
case Button2: case Button2:
case Button3: case Button3:
pb = button_number = ev->button - Button1; pb = button_number = ev->button - Button1;
break; break;
default: /* Wheel mouse */ default: /* Wheel mouse */
button_number = 64 + ev->button - Button3 - 1; button_number = 64 + ev->button - Button3 - 1;
break; break;
} }
key_state = ((ev->state & (ShiftMask | ControlMask)) key_state = ((ev->state & (ShiftMask | ControlMask))
+ ((ev->state & Mod1Mask) ? 2 : 0)); + ((ev->state & Mod1Mask) ? 2 : 0));
tt_printf((unsigned char *) "\033[5M%c%c%c%c%c", tt_printf((unsigned char *) "\033[5M%c%c%c%c%c",
(32 + button_number + (key_state << 2)), (32 + (x & 0x7f) + 1), (32 + ((x >> 7) & 0x7f) + 1), (32 + (y & 0x7f) + 1), (32 + ((y >> 7) & 0x7f) + 1)); (32 + button_number + (key_state << 2)), (32 + (x & 0x7f) + 1), (32 + ((x >> 7) & 0x7f) + 1), (32 + (y & 0x7f) + 1),
(32 + ((y >> 7) & 0x7f) + 1));
} }
void void
@ -3339,21 +3360,22 @@ mouse_report(XButtonEvent * ev)
int button_number, key_state; int button_number, key_state;
switch (ev->button) { switch (ev->button) {
case AnyButton: /* Button release */ case AnyButton: /* Button release */
button_number = 3; button_number = 3;
break; break;
case Button1: /* Button press */ case Button1: /* Button press */
case Button2: case Button2:
case Button3: case Button3:
pb = button_number = ev->button - Button1; pb = button_number = ev->button - Button1;
break; break;
default: /* Wheel mouse */ default: /* Wheel mouse */
button_number = 64 + ev->button - Button3 - 1; button_number = 64 + ev->button - Button3 - 1;
break; break;
} }
key_state = ((ev->state & (ShiftMask | ControlMask)) key_state = ((ev->state & (ShiftMask | ControlMask))
+ ((ev->state & Mod1Mask) ? 2 : 0)); + ((ev->state & Mod1Mask) ? 2 : 0));
tt_printf((unsigned char *) "\033[M%c%c%c", (32 + button_number + (key_state << 2)), (32 + Pixel2Col(ev->x) + 1), (32 + Pixel2Row(ev->y) + 1)); tt_printf((unsigned char *) "\033[M%c%c%c", (32 + button_number + (key_state << 2)), (32 + Pixel2Col(ev->x) + 1),
(32 + Pixel2Row(ev->y) + 1));
} }
void void

View File

@ -203,22 +203,23 @@ sb_handle_button_press(event_t *ev)
tt_printf((unsigned char *) "\033[B"); tt_printf((unsigned char *) "\033[B");
else { else {
switch (ev->xbutton.button) { switch (ev->xbutton.button) {
case Button2: case Button2:
tt_printf((unsigned char *) "\014"); tt_printf((unsigned char *) "\014");
break; break;
case Button1: case Button1:
tt_printf((unsigned char *) "\033[6~"); tt_printf((unsigned char *) "\033[6~");
break; break;
case Button3: case Button3:
tt_printf((unsigned char *) "\033[5~"); tt_printf((unsigned char *) "\033[5~");
break; break;
} }
} }
} else } else
#endif /* NO_SCROLLBAR_REPORT */ #endif /* NO_SCROLLBAR_REPORT */
{ {
D_EVENTS(("ButtonPress event for window 0x%08x at %d, %d\n", ev->xany.window, ev->xbutton.x, ev->xbutton.y)); D_EVENTS(("ButtonPress event for window 0x%08x at %d, %d\n", ev->xany.window, ev->xbutton.x, ev->xbutton.y));
D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollbar.up_win, scrollbar.dn_win, scrollbar.sa_win, scrollbar.win)); D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollbar.up_win, scrollbar.dn_win,
scrollbar.sa_win, scrollbar.win));
if (scrollbar_win_is_uparrow(ev->xany.window)) { if (scrollbar_win_is_uparrow(ev->xany.window)) {
scrollbar_draw_uparrow(IMAGE_STATE_CLICKED, 0); scrollbar_draw_uparrow(IMAGE_STATE_CLICKED, 0);
@ -242,40 +243,41 @@ sb_handle_button_press(event_t *ev)
scrollbar_draw_anchor(IMAGE_STATE_CLICKED, 0); scrollbar_draw_anchor(IMAGE_STATE_CLICKED, 0);
} }
switch (ev->xbutton.button) { switch (ev->xbutton.button) {
case Button2: case Button2:
button_state.mouse_offset = scrollbar_anchor_height() / 2; /* Align to center */ button_state.mouse_offset = scrollbar_anchor_height() / 2; /* Align to center */
if (!scrollbar_win_is_anchor(ev->xany.window)) { if (!scrollbar_win_is_anchor(ev->xany.window)) {
scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height());
} else if (scrollbar.type == SCROLLBAR_XTERM) { } else if (scrollbar.type == SCROLLBAR_XTERM) {
scr_move_to(scrollbar.anchor_top + ev->xbutton.y - button_state.mouse_offset, scrollbar_scrollarea_height()); scr_move_to(scrollbar.anchor_top + ev->xbutton.y - button_state.mouse_offset,
} scrollbar_scrollarea_height());
scrollbar_set_motion(1); }
break; scrollbar_set_motion(1);
break;
case Button1: case Button1:
button_state.mouse_offset = ((scrollbar_win_is_anchor(ev->xany.window)) ? (MAX(ev->xbutton.y, 1)) : (1)); button_state.mouse_offset = ((scrollbar_win_is_anchor(ev->xany.window)) ? (MAX(ev->xbutton.y, 1)) : (1));
/* drop */ /* drop */
case Button3: case Button3:
#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR)
if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) { if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) {
if (scrollbar_is_above_anchor(ev->xany.window, ev->xbutton.y)) { if (scrollbar_is_above_anchor(ev->xany.window, ev->xbutton.y)) {
scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0);
scr_page(UP, TermWin.nrow - CONTEXT_LINES); scr_page(UP, TermWin.nrow - CONTEXT_LINES);
} else if (scrollbar_is_below_anchor(ev->xany.window, ev->xbutton.y)) { } else if (scrollbar_is_below_anchor(ev->xany.window, ev->xbutton.y)) {
scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0);
scr_page(DN, TermWin.nrow - CONTEXT_LINES); scr_page(DN, TermWin.nrow - CONTEXT_LINES);
} else { } else {
scrollbar_set_motion(1); scrollbar_set_motion(1);
} }
} }
#endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */
#ifdef XTERM_SCROLLBAR #ifdef XTERM_SCROLLBAR
if (scrollbar.type == SCROLLBAR_XTERM) { if (scrollbar.type == SCROLLBAR_XTERM) {
scr_page((ev->xbutton.button == Button1 ? DN : UP), TermWin.nrow - CONTEXT_LINES); scr_page((ev->xbutton.button == Button1 ? DN : UP), TermWin.nrow - CONTEXT_LINES);
} }
#endif /* XTERM_SCROLLBAR */ #endif /* XTERM_SCROLLBAR */
break; break;
} }
} }
} }
@ -333,7 +335,8 @@ sb_handle_motion_notify(event_t *ev)
return 1; return 1;
D_EVENTS(("MotionNotify event for window 0x%08x\n", ev->xany.window)); D_EVENTS(("MotionNotify event for window 0x%08x\n", ev->xany.window));
D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollbar.up_win, scrollbar.dn_win, scrollbar.sa_win, scrollbar.win)); D_EVENTS((" up [0x%08x], down [0x%08x], anchor [0x%08x], trough [0x%08x]\n", scrollbar.up_win, scrollbar.dn_win,
scrollbar.sa_win, scrollbar.win));
if ((scrollbar_win_is_trough(ev->xany.window) || scrollbar_win_is_anchor(ev->xany.window)) && scrollbar_is_moving()) { if ((scrollbar_win_is_trough(ev->xany.window) || scrollbar_win_is_anchor(ev->xany.window)) && scrollbar_is_moving()) {
Window unused_root, unused_child; Window unused_root, unused_child;
@ -341,7 +344,8 @@ sb_handle_motion_notify(event_t *ev)
unsigned int unused_mask; unsigned int unused_mask;
while (XCheckTypedWindowEvent(Xdisplay, scrollbar.win, MotionNotify, ev)); while (XCheckTypedWindowEvent(Xdisplay, scrollbar.win, MotionNotify, ev));
XQueryPointer(Xdisplay, scrollbar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); XQueryPointer(Xdisplay, scrollbar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x),
&(ev->xbutton.y), &unused_mask);
scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height());
refresh_count = refresh_limit = 0; refresh_count = refresh_limit = 0;
scr_refresh(refresh_type); scr_refresh(refresh_type);
@ -541,7 +545,8 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
int x = ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? 1 : 0); int x = ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? 1 : 0);
XSetForeground(Xdisplay, gc_stipple, images[image_sa].current->bg); XSetForeground(Xdisplay, gc_stipple, images[image_sa].current->bg);
XFillRectangle(Xdisplay, scrollbar.sa_win, gc_stipple, x + 1, 0, scrollbar_anchor_width() - x - 1, scrollbar_anchor_height()); XFillRectangle(Xdisplay, scrollbar.sa_win, gc_stipple, x + 1, 0, scrollbar_anchor_width() - x - 1,
scrollbar_anchor_height());
XClearWindow(Xdisplay, scrollbar.sa_win); XClearWindow(Xdisplay, scrollbar.sa_win);
} }
#endif /* XTERM_SCROLLBAR */ #endif /* XTERM_SCROLLBAR */
@ -557,9 +562,11 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sa].current->bg, "")); XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sa].current->bg, ""));
XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sa].current->bg, "")); XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sa].current->bg, ""));
if (scrollbar_anchor_is_pressed()) { if (scrollbar_anchor_is_pressed()) {
draw_shadow(scrollbar.sa_win, gc_bottom, gc_top, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(), scrollbar_get_shadow()); draw_shadow(scrollbar.sa_win, gc_bottom, gc_top, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(),
scrollbar_get_shadow());
} else { } else {
draw_shadow(scrollbar.sa_win, gc_top, gc_bottom, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(), scrollbar_get_shadow()); draw_shadow(scrollbar.sa_win, gc_top, gc_bottom, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(),
scrollbar_get_shadow());
} }
} }
#endif #endif
@ -573,7 +580,8 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
Pixmap pmap; Pixmap pmap;
thumb = (images[image_st].current->iml) ? 1 : 0; thumb = (images[image_st].current->iml) ? 1 : 0;
render_simage(images[image_sa].current, scrollbar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, thumb); render_simage(images[image_sa].current, scrollbar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa,
thumb);
pmap = images[image_sa].current->pmap->pixmap; pmap = images[image_sa].current->pmap->pixmap;
/* Draw the thumb if there is one. */ /* Draw the thumb if there is one. */
if (thumb) { if (thumb) {
@ -600,7 +608,8 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
UPPER_BOUND(th, scrollbar_anchor_height() >> 1); UPPER_BOUND(th, scrollbar_anchor_height() >> 1);
D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th)); D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th));
if ((tw > 0) && (th > 0)) { if ((tw > 0) && (th > 0)) {
paste_simage(images[image_st].current, image_st, scrollbar.sa_win, pmap, (scrollbar_anchor_width() - tw) >> 1, (scrollbar_anchor_height() - th) >> 1, tw, th); paste_simage(images[image_st].current, image_st, scrollbar.sa_win, pmap, (scrollbar_anchor_width() - tw) >> 1,
(scrollbar_anchor_height() - th) >> 1, tw, th);
XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, pmap); XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, pmap);
XClearWindow(Xdisplay, scrollbar.sa_win); XClearWindow(Xdisplay, scrollbar.sa_win);
IMLIB_FREE_PIXMAP(pmap); IMLIB_FREE_PIXMAP(pmap);
@ -664,7 +673,8 @@ scrollbar_draw_trough(unsigned char image_state, unsigned char force_modes)
XFillRectangle(Xdisplay, scrollbar.win, gc_scrollbar, 0, 0, scrollbar_trough_width(), scrollbar_trough_height()); XFillRectangle(Xdisplay, scrollbar.win, gc_scrollbar, 0, 0, scrollbar_trough_width(), scrollbar_trough_height());
XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sb].current->bg, "")); XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sb].current->bg, ""));
XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sb].current->bg, "")); XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sb].current->bg, ""));
draw_shadow(scrollbar.win, gc_bottom, gc_top, 0, 0, scrollbar_trough_width(), scrollbar_trough_height(), scrollbar_get_shadow()); draw_shadow(scrollbar.win, gc_bottom, gc_top, 0, 0, scrollbar_trough_width(), scrollbar_trough_height(),
scrollbar_get_shadow());
} }
return; return;
} }
@ -696,9 +706,10 @@ scrollbar_init(int width, int height)
/* Create the scrollbar trough window. It will be the parent to the other windows. */ /* Create the scrollbar trough window. It will be the parent to the other windows. */
scrollbar.win = scrollbar.win =
XCreateWindow(Xdisplay, TermWin.parent, ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)), XCreateWindow(Xdisplay, TermWin.parent,
bbar_calc_docked_height(BBAR_DOCKED_TOP), scrollbar_trough_width(), height, 0, Xdepth, InputOutput, CopyFromParent, ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)),
CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap, &Attributes); bbar_calc_docked_height(BBAR_DOCKED_TOP), scrollbar_trough_width(), height, 0, Xdepth, InputOutput,
CopyFromParent, CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap, &Attributes);
XDefineCursor(Xdisplay, scrollbar.win, cursor); XDefineCursor(Xdisplay, scrollbar.win, cursor);
XSelectInput(Xdisplay, scrollbar.win, mask); XSelectInput(Xdisplay, scrollbar.win, mask);
XStoreName(Xdisplay, scrollbar.win, "Eterm Scrollbar"); XStoreName(Xdisplay, scrollbar.win, "Eterm Scrollbar");
@ -707,7 +718,8 @@ scrollbar_init(int width, int height)
/* Now the up arrow window. */ /* Now the up arrow window. */
scrollbar.up_win = scrollbar.up_win =
XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar_up_loc(), scrollbar_arrow_width(), XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar_up_loc(), scrollbar_arrow_width(),
scrollbar_arrow_height(), 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWColormap, &Attributes); scrollbar_arrow_height(), 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWColormap,
&Attributes);
XSelectInput(Xdisplay, scrollbar.up_win, mask); XSelectInput(Xdisplay, scrollbar.up_win, mask);
XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Up Arrow"); XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Up Arrow");
D_SCROLLBAR(("Created scrollbar up arrow window 0x%08x\n", scrollbar.up_win)); D_SCROLLBAR(("Created scrollbar up arrow window 0x%08x\n", scrollbar.up_win));
@ -715,7 +727,8 @@ scrollbar_init(int width, int height)
/* The down arrow window */ /* The down arrow window */
scrollbar.dn_win = scrollbar.dn_win =
XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar_dn_loc(), scrollbar_arrow_width(), XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar_dn_loc(), scrollbar_arrow_width(),
scrollbar_arrow_height(), 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWColormap, &Attributes); scrollbar_arrow_height(), 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWColormap,
&Attributes);
XSelectInput(Xdisplay, scrollbar.dn_win, mask); XSelectInput(Xdisplay, scrollbar.dn_win, mask);
XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Down Arrow"); XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Down Arrow");
D_SCROLLBAR(("Created scrollbar down arrow window 0x%08x\n", scrollbar.dn_win)); D_SCROLLBAR(("Created scrollbar down arrow window 0x%08x\n", scrollbar.dn_win));
@ -723,7 +736,8 @@ scrollbar_init(int width, int height)
/* The anchor window */ /* The anchor window */
scrollbar.sa_win = scrollbar.sa_win =
XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar.anchor_top, scrollbar_anchor_width(), XCreateWindow(Xdisplay, scrollbar.win, scrollbar_get_shadow(), scrollbar.anchor_top, scrollbar_anchor_width(),
scrollbar_anchor_height(), 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWColormap, &Attributes); scrollbar_anchor_height(), 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWColormap, &Attributes);
XSelectInput(Xdisplay, scrollbar.sa_win, mask); XSelectInput(Xdisplay, scrollbar.sa_win, mask);
XMapWindow(Xdisplay, scrollbar.sa_win); XMapWindow(Xdisplay, scrollbar.sa_win);
XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Anchor"); XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Anchor");
@ -803,7 +817,8 @@ scrollbar_calc_size(int width, int height)
scrollbar.height = height - (2 * scrollbar_get_shadow()); scrollbar.height = height - (2 * scrollbar_get_shadow());
scrollbar.win_width = scrollbar.width + (2 * scrollbar_get_shadow()); scrollbar.win_width = scrollbar.width + (2 * scrollbar_get_shadow());
scrollbar.win_height = height; scrollbar.win_height = height;
D_X11((" -> New scrollbar width/height == %hux%hu, win_width/height == %hux%hu\n", scrollbar.width, scrollbar.height, scrollbar.win_width, scrollbar.win_height)); D_X11((" -> New scrollbar width/height == %hux%hu, win_width/height == %hux%hu\n", scrollbar.width, scrollbar.height,
scrollbar.win_width, scrollbar.win_height));
D_X11((" -> New scroll area start/end == %hu - %hu, up_arrow_loc == %hu, down_arrow_loc == %hu\n", scrollbar.scrollarea_start, D_X11((" -> New scroll area start/end == %hu - %hu, up_arrow_loc == %hu, down_arrow_loc == %hu\n", scrollbar.scrollarea_start,
scrollbar.scrollarea_end, scrollbar.up_arrow_loc, scrollbar.down_arrow_loc)); scrollbar.scrollarea_end, scrollbar.up_arrow_loc, scrollbar.down_arrow_loc));
} }
@ -820,7 +835,8 @@ scrollbar_resize(int width, int height)
D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, y, %d, %d)\n", scrollbar.win, D_SCROLLBAR((" -> XMoveResizeWindow(Xdisplay, 0x%08x, %d, y, %d, %d)\n", scrollbar.win,
((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)), ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)),
scrollbar_trough_width(), scrollbar_trough_height())); scrollbar_trough_width(), scrollbar_trough_height()));
XMoveResizeWindow(Xdisplay, scrollbar.win, ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)), XMoveResizeWindow(Xdisplay, scrollbar.win,
((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)),
bbar_calc_docked_height(BBAR_DOCKED_TOP), scrollbar_trough_width(), scrollbar_trough_height()); bbar_calc_docked_height(BBAR_DOCKED_TOP), scrollbar_trough_width(), scrollbar_trough_height());
scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK); scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK);
scrollbar_reposition_and_draw(MODE_MASK); scrollbar_reposition_and_draw(MODE_MASK);

View File

@ -76,6 +76,7 @@ eterm_bootstrap(int argc, char *argv[])
int i; int i;
char *val; char *val;
/* "WINDOWID=\0" = 10 chars, UINT_MAX = 10 chars */ /* "WINDOWID=\0" = 10 chars, UINT_MAX = 10 chars */
static char windowid_string[20], *display_string, *term_string; static char windowid_string[20], *display_string, *term_string;
@ -160,7 +161,9 @@ eterm_bootstrap(int argc, char *argv[])
sprintf(tmp, "ETERM_THEME_ROOT=%s", theme_dir); sprintf(tmp, "ETERM_THEME_ROOT=%s", theme_dir);
putenv(tmp); putenv(tmp);
} }
if ((user_dir = conf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG), (PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME))) != NULL) { if ((user_dir =
conf_parse_theme(&rs_theme, (rs_config_file ? rs_config_file : USER_CFG),
(PARSE_TRY_USER_THEME | PARSE_TRY_NO_THEME))) != NULL) {
char *tmp; char *tmp;
D_OPTIONS(("conf_parse_theme() returned \"%s\"\n", user_dir)); D_OPTIONS(("conf_parse_theme() returned \"%s\"\n", user_dir));
@ -194,7 +197,8 @@ eterm_bootstrap(int argc, char *argv[])
#endif #endif
spifopt_parse(argc, argv); spifopt_parse(argc, argv);
D_UTMP(("Saved real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", my_ruid, my_rgid, my_euid, my_egid)); D_UTMP(("Saved real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", my_ruid, my_rgid, my_euid, my_egid));
D_UTMP(("Now running with real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", getuid(), getgid(), geteuid(), getegid())); D_UTMP(("Now running with real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", getuid(), getgid(), geteuid(),
getegid()));
#ifdef ESCREEN #ifdef ESCREEN
# define ESCREEN_PREFIX "Escreen" # define ESCREEN_PREFIX "Escreen"
@ -240,7 +244,8 @@ eterm_bootstrap(int argc, char *argv[])
/* Initialize the scrollbar */ /* Initialize the scrollbar */
scrollbar_init(szHint.width, szHint.height - bbar_calc_docked_height(BBAR_DOCKED)); scrollbar_init(szHint.width, szHint.height - bbar_calc_docked_height(BBAR_DOCKED));
scrollbar_mapping((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR)) && !((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_POPUP)) && !TermWin.focus)); scrollbar_mapping((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR))
&& !((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_POPUP)) && !TermWin.focus));
/* Initialize the menu subsystem. */ /* Initialize the menu subsystem. */
menu_init(); menu_init();

2981
src/term.c

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,8 @@ timer_add(unsigned long msec, timer_handler_t handler, void *data)
timer->time.tv_usec = ((msec % 1000) * 1000) + tv.tv_usec; timer->time.tv_usec = ((msec % 1000) * 1000) + tv.tv_usec;
timer->handler = handler; timer->handler = handler;
timer->data = data; timer->data = data;
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)); 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); return ((timerhdl_t) timer);
} }

View File

@ -247,11 +247,11 @@ void
b_login(struct utmp *ut) b_login(struct utmp *ut)
{ {
/* /*
** replacement for freebsd's login(), which uses ttyslot() ** replacement for freebsd's login(), which uses ttyslot()
** **
** like I shouldn't have just KNOWN that from the comment on get_tslot ** like I shouldn't have just KNOWN that from the comment on get_tslot
** below... ** below...
** - brian ** - brian
*/ */
register int fd; register int fd;
int tty; int tty;

View File

@ -144,7 +144,8 @@ get_bottom_shadow_color(Pixel norm_color, const char *type)
xcol.blue /= 2; xcol.blue /= 2;
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red, xcol.green, xcol.blue); print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red,
xcol.green, xcol.blue);
xcol.pixel = PixColors[minColor]; xcol.pixel = PixColors[minColor];
} }
return (xcol.pixel); return (xcol.pixel);
@ -176,7 +177,8 @@ get_top_shadow_color(Pixel norm_color, const char *type)
xcol.blue = MIN(white.blue, (xcol.blue * 7) / 5); xcol.blue = MIN(white.blue, (xcol.blue * 7) / 5);
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red, xcol.green, xcol.blue); print_error("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", type, xcol.pixel, xcol.red,
xcol.green, xcol.blue);
xcol.pixel = PixColors[WhiteColor]; xcol.pixel = PixColors[WhiteColor];
} }
return (xcol.pixel); return (xcol.pixel);
@ -206,7 +208,9 @@ get_color_by_name(const char *name, const char *fallback)
name = fallback; name = fallback;
if (name) { if (name) {
if (!XParseColor(Xdisplay, cmap, name, &xcol)) { if (!XParseColor(Xdisplay, cmap, name, &xcol)) {
print_warning("Unable to resolve \"%s\" as a color name. This should never fail. Please repair/restore your RGB database.\n", name); print_warning
("Unable to resolve \"%s\" as a color name. This should never fail. Please repair/restore your RGB database.\n",
name);
return ((Pixel) - 1); return ((Pixel) - 1);
} }
} else { } else {
@ -219,7 +223,8 @@ get_color_by_name(const char *name, const char *fallback)
name = fallback; name = fallback;
if (name) { if (name) {
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", name, xcol.pixel, xcol.red, xcol.green, xcol.blue); print_warning("Unable to allocate \"%s\" (0x%08x: 0x%04x, 0x%04x, 0x%04x) in the color map.\n", name, xcol.pixel,
xcol.red, xcol.green, xcol.blue);
return ((Pixel) - 1); return ((Pixel) - 1);
} }
} else { } else {
@ -244,10 +249,12 @@ get_color_by_pixel(Pixel pixel, Pixel fallback)
} }
} }
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on 0x%08x.\n", xcol.pixel, xcol.red, xcol.green, xcol.blue, fallback); print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map. Falling back on 0x%08x.\n", xcol.pixel,
xcol.red, xcol.green, xcol.blue, fallback);
xcol.pixel = fallback; xcol.pixel = fallback;
if (!XAllocColor(Xdisplay, cmap, &xcol)) { if (!XAllocColor(Xdisplay, cmap, &xcol)) {
print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map.\n", xcol.pixel, xcol.red, xcol.green, xcol.blue); print_warning("Unable to allocate 0x%08x (0x%04x, 0x%04x, 0x%04x) in the color map.\n", xcol.pixel, xcol.red,
xcol.green, xcol.blue);
return ((Pixel) 0); return ((Pixel) 0);
} }
} }
@ -261,51 +268,51 @@ process_colors(void)
Pixel pixel; Pixel pixel;
for (i = 0; i < NRS_COLORS; i++) { for (i = 0; i < NRS_COLORS; i++) {
D_COLORS(("Adding color %d of %d (%s)\n",i,NRS_COLORS,def_colorName[i])); D_COLORS(("Adding color %d of %d (%s)\n", i, NRS_COLORS, def_colorName[i]));
if ((Xdepth <= 2) || ((pixel = get_color_by_name(rs_color[i], def_colorName[i])) == (Pixel) (-1))) { if ((Xdepth <= 2) || ((pixel = get_color_by_name(rs_color[i], def_colorName[i])) == (Pixel) (-1))) {
switch (i) { switch (i) {
case fgColor: case fgColor:
pixel = WhitePixel(Xdisplay, Xscreen); pixel = WhitePixel(Xdisplay, Xscreen);
break; break;
case bgColor: case bgColor:
pixel = BlackPixel(Xdisplay, Xscreen); pixel = BlackPixel(Xdisplay, Xscreen);
break; break;
#ifndef NO_CURSORCOLOR #ifndef NO_CURSORCOLOR
case cursorColor: case cursorColor:
pixel = PixColors[bgColor]; pixel = PixColors[bgColor];
break; break;
case cursorColor2: case cursorColor2:
pixel = PixColors[fgColor]; pixel = PixColors[fgColor];
break; break;
#endif /* NO_CURSORCOLOR */ #endif /* NO_CURSORCOLOR */
#ifndef NO_BOLDUNDERLINE #ifndef NO_BOLDUNDERLINE
case colorBD: case colorBD:
pixel = PixColors[fgColor]; pixel = PixColors[fgColor];
break; break;
case colorUL: case colorUL:
pixel = PixColors[fgColor]; pixel = PixColors[fgColor];
break; break;
#endif #endif
#ifdef ESCREEN #ifdef ESCREEN
case ES_COLOR_CURRENT: case ES_COLOR_CURRENT:
pixel = PixColors[YellowColor]; pixel = PixColors[YellowColor];
break; break;
case ES_COLOR_ACTIVE: case ES_COLOR_ACTIVE:
pixel = PixColors[BlueColor]; pixel = PixColors[BlueColor];
break; break;
#endif #endif
case pointerColor: case pointerColor:
pixel = PixColors[fgColor]; pixel = PixColors[fgColor];
break; break;
case borderColor: case borderColor:
pixel = PixColors[bgColor]; pixel = PixColors[bgColor];
break; break;
default: default:
pixel = PixColors[fgColor]; /* None */ pixel = PixColors[fgColor]; /* None */
break; break;
} }
} }
D_COLORS(("Pixel : %x\n",pixel)); D_COLORS(("Pixel : %x\n", pixel));
PixColors[i] = pixel; PixColors[i] = pixel;
} }
@ -321,14 +328,17 @@ process_colors(void)
PixColors[unfocusedMenuBottomShadowColor] = PixColors[fgColor]; PixColors[unfocusedMenuBottomShadowColor] = PixColors[fgColor];
} else { } else {
PixColors[bottomShadowColor] = get_bottom_shadow_color(images[image_sb].norm->bg, "bottomShadowColor"); PixColors[bottomShadowColor] = get_bottom_shadow_color(images[image_sb].norm->bg, "bottomShadowColor");
PixColors[unfocusedBottomShadowColor] = get_bottom_shadow_color(images[image_sb].disabled->bg, "unfocusedBottomShadowColor"); PixColors[unfocusedBottomShadowColor] =
get_bottom_shadow_color(images[image_sb].disabled->bg, "unfocusedBottomShadowColor");
PixColors[topShadowColor] = get_top_shadow_color(images[image_sb].norm->bg, "topShadowColor"); PixColors[topShadowColor] = get_top_shadow_color(images[image_sb].norm->bg, "topShadowColor");
PixColors[unfocusedTopShadowColor] = get_top_shadow_color(images[image_sb].disabled->bg, "unfocusedTopShadowColor"); PixColors[unfocusedTopShadowColor] = get_top_shadow_color(images[image_sb].disabled->bg, "unfocusedTopShadowColor");
PixColors[menuBottomShadowColor] = get_bottom_shadow_color(images[image_menu].norm->bg, "menuBottomShadowColor"); PixColors[menuBottomShadowColor] = get_bottom_shadow_color(images[image_menu].norm->bg, "menuBottomShadowColor");
PixColors[unfocusedMenuBottomShadowColor] = get_bottom_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuBottomShadowColor"); PixColors[unfocusedMenuBottomShadowColor] =
get_bottom_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuBottomShadowColor");
PixColors[menuTopShadowColor] = get_top_shadow_color(images[image_menu].norm->bg, "menuTopShadowColor"); PixColors[menuTopShadowColor] = get_top_shadow_color(images[image_menu].norm->bg, "menuTopShadowColor");
PixColors[unfocusedMenuTopShadowColor] = get_top_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuTopShadowColor"); PixColors[unfocusedMenuTopShadowColor] =
get_top_shadow_color(images[image_menu].disabled->bg, "unfocusedMenuTopShadowColor");
} }
stored_palette(SAVE); stored_palette(SAVE);
} }
@ -423,7 +433,8 @@ Create_Windows(int argc, char *argv[])
Attributes.background_pixel = PixColors[bgColor]; Attributes.background_pixel = PixColors[bgColor];
Attributes.border_pixel = PixColors[bgColor]; Attributes.border_pixel = PixColors[bgColor];
D_X11(("Size Hints: x %d, y %d. Width/Height: Base %dx%d, Minimum %dx%d, Current %dx%d, Increment %dx%d\n", D_X11(("Size Hints: x %d, y %d. Width/Height: Base %dx%d, Minimum %dx%d, Current %dx%d, Increment %dx%d\n",
szHint.x, szHint.y, szHint.base_width, szHint.base_height, szHint.min_width, szHint.min_height, szHint.width, szHint.height, szHint.width_inc, szHint.height_inc)); szHint.x, szHint.y, szHint.base_width, szHint.base_height, szHint.min_width, szHint.min_height, szHint.width,
szHint.height, szHint.width_inc, szHint.height_inc));
TermWin.parent = XCreateWindow(Xdisplay, Xroot, szHint.x, szHint.y, szHint.width, szHint.height, 0, Xdepth, InputOutput, TermWin.parent = XCreateWindow(Xdisplay, Xroot, szHint.x, szHint.y, szHint.width, szHint.height, 0, Xdepth, InputOutput,
#ifdef PREFER_24BIT #ifdef PREFER_24BIT
Xvisual, Xvisual,
@ -447,7 +458,8 @@ Create_Windows(int argc, char *argv[])
XSetWMProperties(Xdisplay, TermWin.parent, NULL, NULL, argv, argc, &szHint, &wmHint, &classHint); XSetWMProperties(Xdisplay, TermWin.parent, NULL, NULL, argv, argc, &szHint, &wmHint, &classHint);
XSelectInput(Xdisplay, Xroot, PropertyChangeMask); XSelectInput(Xdisplay, Xroot, PropertyChangeMask);
XSelectInput(Xdisplay, TermWin.parent, (KeyPressMask | FocusChangeMask | StructureNotifyMask | VisibilityChangeMask | PropertyChangeMask)); XSelectInput(Xdisplay, TermWin.parent,
(KeyPressMask | FocusChangeMask | StructureNotifyMask | VisibilityChangeMask | PropertyChangeMask));
if (mwmhints.flags) { if (mwmhints.flags) {
prop = XInternAtom(Xdisplay, "_MOTIF_WM_HINTS", False); prop = XInternAtom(Xdisplay, "_MOTIF_WM_HINTS", False);
XChangeProperty(Xdisplay, TermWin.parent, prop, prop, 32, XChangeProperty(Xdisplay, TermWin.parent, prop, prop, 32,
@ -475,22 +487,23 @@ Create_Windows(int argc, char *argv[])
XClearWindow(Xdisplay, TermWin.vt); XClearWindow(Xdisplay, TermWin.vt);
} }
XDefineCursor(Xdisplay, TermWin.vt, TermWin_cursor); XDefineCursor(Xdisplay, TermWin.vt, TermWin_cursor);
TermWin.mask = (EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask | Button3MotionMask); TermWin.mask =
(EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask |
Button2MotionMask | Button3MotionMask);
XSelectInput(Xdisplay, TermWin.vt, TermWin.mask); XSelectInput(Xdisplay, TermWin.vt, TermWin.mask);
/* If the user wants a specific desktop, tell the WM that */ /* If the user wants a specific desktop, tell the WM that */
if (rs_desktop != -1) { if (rs_desktop != -1) {
val = rs_desktop; val = rs_desktop;
XChangeProperty(Xdisplay, TermWin.parent, props[PROP_DESKTOP], XChangeProperty(Xdisplay, TermWin.parent, props[PROP_DESKTOP], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
} }
/* Set window opacity if needed. */ /* Set window opacity if needed. */
if ((props[PROP_EWMH_OPACITY] != None) && (rs_opacity != 0xff)) { if ((props[PROP_EWMH_OPACITY] != None) && (rs_opacity != 0xff)) {
XChangeProperty(Xdisplay, TermWin.parent, props[PROP_EWMH_OPACITY], XChangeProperty(Xdisplay, TermWin.parent, props[PROP_EWMH_OPACITY],
XA_CARDINAL, 32, PropModeReplace, SPIF_CAST_PTR(uchar) &rs_opacity, 1); XA_CARDINAL, 32, PropModeReplace, SPIF_CAST_PTR(uchar) & rs_opacity, 1);
XChangeProperty(Xdisplay, TermWin.vt, props[PROP_EWMH_OPACITY], XChangeProperty(Xdisplay, TermWin.vt, props[PROP_EWMH_OPACITY],
XA_CARDINAL, 32, PropModeReplace, SPIF_CAST_PTR(uchar) &rs_opacity, 1); XA_CARDINAL, 32, PropModeReplace, SPIF_CAST_PTR(uchar) & rs_opacity, 1);
} }
/* We're done creating our windows. Now let's initialize the event subsystem to handle them. */ /* We're done creating our windows. Now let's initialize the event subsystem to handle them. */
@ -554,7 +567,8 @@ resize_parent(unsigned int width, unsigned int height)
/* exact center */ /* exact center */
dy /= 2; dy /= 2;
} }
D_X11(("Calling XMoveResizeWindow(Xdisplay, 0x%08x, %d + %d, %d + %d, %d, %d)\n", TermWin.parent, x, dx, y, dy, width, height)); D_X11(("Calling XMoveResizeWindow(Xdisplay, 0x%08x, %d + %d, %d + %d, %d, %d)\n", TermWin.parent, x, dx, y, dy, width,
height));
XMoveResizeWindow(Xdisplay, TermWin.parent, x + dx, y + dy, width, height); XMoveResizeWindow(Xdisplay, TermWin.parent, x + dx, y + dy, width, height);
} }
} }
@ -578,19 +592,21 @@ void
update_size_hints(void) update_size_hints(void)
{ {
D_X11(("Called.\n")); D_X11(("Called.\n"));
szHint.base_width = (2 * TermWin.internalBorder) + ((scrollbar_is_visible()) ? (scrollbar_trough_width()) : (0)); szHint.base_width = (2 * TermWin.internalBorder) + ((scrollbar_is_visible())? (scrollbar_trough_width()) : (0));
szHint.base_height = (2 * TermWin.internalBorder) + bbar_calc_docked_height(BBAR_DOCKED); szHint.base_height = (2 * TermWin.internalBorder) + bbar_calc_docked_height(BBAR_DOCKED);
szHint.width_inc = TermWin.fwidth; szHint.width_inc = TermWin.fwidth;
szHint.height_inc = TermWin.fheight; szHint.height_inc = TermWin.fheight;
D_X11(("Size Hints: base width/height == %lux%lu, width/height increment == %lux%lu\n", szHint.base_width, szHint.base_height, szHint.width_inc, szHint.height_inc)); D_X11(("Size Hints: base width/height == %lux%lu, width/height increment == %lux%lu\n", szHint.base_width, szHint.base_height,
szHint.width_inc, szHint.height_inc));
szHint.min_width = szHint.base_width + szHint.width_inc; szHint.min_width = szHint.base_width + szHint.width_inc;
szHint.min_height = szHint.base_height + szHint.height_inc; szHint.min_height = szHint.base_height + szHint.height_inc;
szHint.width = szHint.base_width + TERM_WINDOW_GET_WIDTH(); szHint.width = szHint.base_width + TERM_WINDOW_GET_WIDTH();
szHint.height = szHint.base_height + TERM_WINDOW_GET_HEIGHT(); szHint.height = szHint.base_height + TERM_WINDOW_GET_HEIGHT();
D_X11((" Minimum width/height == %lux%lu, width/height == %lux%lu\n", szHint.min_width, szHint.min_height, szHint.width, szHint.height)); D_X11((" Minimum width/height == %lux%lu, width/height == %lux%lu\n", szHint.min_width, szHint.min_height,
szHint.width, szHint.height));
szHint.flags = PMinSize | PResizeInc | PBaseSize; szHint.flags = PMinSize | PResizeInc | PBaseSize;
XSetWMNormalHints(Xdisplay, TermWin.parent, &szHint); XSetWMNormalHints(Xdisplay, TermWin.parent, &szHint);
@ -608,8 +624,8 @@ term_resize(int width, int height)
D_X11((" -> New TermWin width/height == %lux%lu\n", TERM_WINDOW_GET_WIDTH(), TERM_WINDOW_GET_HEIGHT())); D_X11((" -> New TermWin width/height == %lux%lu\n", TERM_WINDOW_GET_WIDTH(), TERM_WINDOW_GET_HEIGHT()));
width = TERM_WINDOW_FULL_WIDTH(); width = TERM_WINDOW_FULL_WIDTH();
height = TERM_WINDOW_FULL_HEIGHT(); height = TERM_WINDOW_FULL_HEIGHT();
XMoveResizeWindow(Xdisplay, TermWin.vt, XMoveResizeWindow(Xdisplay, TermWin.vt, ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (0)
((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (0) : ((scrollbar_is_visible())? (scrollbar_trough_width()) : (0))), : ((scrollbar_is_visible())? (scrollbar_trough_width()) : (0))),
bbar_calc_docked_height(BBAR_DOCKED_TOP), width, height); bbar_calc_docked_height(BBAR_DOCKED_TOP), width, height);
if (width != last_width || height != last_height) { if (width != last_width || height != last_height) {
render_simage(images[image_bg].current, TermWin.vt, width, height, image_bg, 0); render_simage(images[image_bg].current, TermWin.vt, width, height, image_bg, 0);
@ -710,7 +726,7 @@ set_window_color(int idx, const char *color)
if (i >= 8 && i <= 15) { /* bright colors */ if (i >= 8 && i <= 15) { /* bright colors */
i -= 8; i -= 8;
PixColors[idx] = PixColors[minBright + i]; PixColors[idx] = PixColors[minBright + i];
} else if (i >= 0 && i <= 7) { /* normal colors */ } else if (i >= 0 && i <= 7) { /* normal colors */
PixColors[idx] = PixColors[minColor + i]; PixColors[idx] = PixColors[minColor + i];
} else { } else {
print_warning("Color index %d is invalid.\n", i); print_warning("Color index %d is invalid.\n", i);

View File

@ -56,15 +56,18 @@ set_pixmap_property(Pixmap p)
if (prop_root != None && prop_esetroot != None) { if (prop_root != None && prop_esetroot != None) {
XGetWindowProperty(Xdisplay, Xroot, prop_root, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_root); XGetWindowProperty(Xdisplay, Xroot, prop_root, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_root);
if (type == XA_PIXMAP) { if (type == XA_PIXMAP) {
XGetWindowProperty(Xdisplay, Xroot, prop_esetroot, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_esetroot); XGetWindowProperty(Xdisplay, Xroot, prop_esetroot, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after,
&data_esetroot);
if (data_root && data_esetroot) { if (data_root && data_esetroot) {
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): data_root == 0x%08x, data_esetroot == 0x%08x\n", __FILE__, fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): data_root == 0x%08x, data_esetroot == 0x%08x\n",
__LINE__, (unsigned int) p, (unsigned int) *((Pixmap *) data_root), (unsigned int) *((Pixmap *) data_esetroot)); __FILE__, __LINE__, (unsigned int) p, (unsigned int) *((Pixmap *) data_root),
(unsigned int) *((Pixmap *) data_esetroot));
} }
if (type == XA_PIXMAP && *((Pixmap *) data_root) == *((Pixmap *) data_esetroot)) { if (type == XA_PIXMAP && *((Pixmap *) data_root) == *((Pixmap *) data_esetroot)) {
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): XKillClient() is being called.\n", __FILE__, __LINE__, (unsigned int) p); fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): XKillClient() is being called.\n", __FILE__,
__LINE__, (unsigned int) p);
} }
XKillClient(Xdisplay, *((Pixmap *) data_root)); XKillClient(Xdisplay, *((Pixmap *) data_root));
} }
@ -83,7 +86,8 @@ set_pixmap_property(Pixmap p)
XChangeProperty(Xdisplay, Xroot, prop_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1); XChangeProperty(Xdisplay, Xroot, prop_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
XChangeProperty(Xdisplay, Xroot, prop_esetroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1); XChangeProperty(Xdisplay, Xroot, prop_esetroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): _XROOTPMAP_ID and ESETROOT_PMAP_ID set to 0x%08x.\n", __FILE__, __LINE__, (unsigned int) p, (unsigned int) p); fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): _XROOTPMAP_ID and ESETROOT_PMAP_ID set to 0x%08x.\n", __FILE__,
__LINE__, (unsigned int) p, (unsigned int) p);
} }
XSetCloseDownMode(Xdisplay, RetainPermanent); XSetCloseDownMode(Xdisplay, RetainPermanent);
XFlush(Xdisplay); XFlush(Xdisplay);
@ -145,13 +149,15 @@ main(int argc, char *argv[])
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: Display name is \"%s\"\n", __FILE__, __LINE__, displayname ? displayname : "(nil)"); fprintf(stderr, "%s:%d: Display name is \"%s\"\n", __FILE__, __LINE__, displayname ? displayname : "(nil)");
fprintf(stderr, "%s:%d: Background color name is \"%s\"\n", __FILE__, __LINE__, bgcolor ? bgcolor : "(nil)"); fprintf(stderr, "%s:%d: Background color name is \"%s\"\n", __FILE__, __LINE__, bgcolor ? bgcolor : "(nil)");
fprintf(stderr, "%s:%d: Image will be %s\n", __FILE__, __LINE__, scale ? "scaled" : (center ? "centered" : (fit ? "fit" : "tiled"))); fprintf(stderr, "%s:%d: Image will be %s\n", __FILE__, __LINE__,
scale ? "scaled" : (center ? "centered" : (fit ? "fit" : "tiled")));
fprintf(stderr, "%s:%d: Image file is %s\n", __FILE__, __LINE__, fname ? fname : "(nil)"); fprintf(stderr, "%s:%d: Image file is %s\n", __FILE__, __LINE__, fname ? fname : "(nil)");
} }
if (!displayname) { if (!displayname) {
displayname = getenv("DISPLAY"); displayname = getenv("DISPLAY");
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: Display name set to %s via getenv(\"DISPLAY\")\n", __FILE__, __LINE__, displayname ? displayname : "(nil)"); fprintf(stderr, "%s:%d: Display name set to %s via getenv(\"DISPLAY\")\n", __FILE__, __LINE__,
displayname ? displayname : "(nil)");
} }
} }
if (!displayname) { if (!displayname) {
@ -224,7 +230,8 @@ main(int argc, char *argv[])
} }
if (debug) { if (debug) {
fprintf(stderr, "%s:%d: Assigned width and height for rendering as %dx%d\n", __FILE__, __LINE__, w, h); fprintf(stderr, "%s:%d: Assigned width and height for rendering as %dx%d\n", __FILE__, __LINE__, w, h);
fprintf(stderr, "%s:%d: Created %dx%d+%d+%d pixmap 0x%08x\n", __FILE__, __LINE__, scr->width, scr->height, x, y, (unsigned int) p); fprintf(stderr, "%s:%d: Created %dx%d+%d+%d pixmap 0x%08x\n", __FILE__, __LINE__, scr->width, scr->height, x, y,
(unsigned int) p);
fprintf(stderr, "%s:%d: Applied Graphics Context %8p to pixmap.\n", __FILE__, __LINE__, gc); fprintf(stderr, "%s:%d: Applied Graphics Context %8p to pixmap.\n", __FILE__, __LINE__, gc);
} }
imlib_context_set_anti_alias(1); imlib_context_set_anti_alias(1);