From 6657911db3c1ccbf3f53304cc8926a3c58111256 Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Tue, 19 Apr 2005 01:57:24 +0000 Subject: [PATCH] Mon Apr 18 21:49:08 2005 Michael Jennings (mej) Re-indent code. ---------------------------------------------------------------------- SVN revision: 14229 --- .cvsignore | 7 +- ChangeLog | 4 + reformat-code | 4 +- src/actions.c | 55 +- src/buttons.c | 239 ++-- src/command.c | 312 ++--- src/draw.c | 102 +- src/e.c | 6 +- src/events.c | 236 ++-- src/font.c | 150 +-- src/grkelot.c | 11 +- src/libscream.c | 342 +++--- src/menus.c | 232 ++-- src/misc.c | 118 +- src/netdisp.c | 3 +- src/options.c | 304 ++--- src/pixmap.c | 442 +++---- src/screen.c | 552 ++++----- src/scrollbar.c | 124 +- src/startup.c | 11 +- src/term.c | 2981 +++++++++++++++++++++++----------------------- src/timer.c | 3 +- src/utmp.c | 10 +- src/windows.c | 132 +- utils/Esetroot.c | 23 +- 25 files changed, 3315 insertions(+), 3088 deletions(-) diff --git a/.cvsignore b/.cvsignore index b740d1d..5bb918b 100644 --- a/.cvsignore +++ b/.cvsignore @@ -11,7 +11,7 @@ aclocal.m4 config.status config.h libtool -stamp-h +stamp-h* move-themes *.spec config.h.in @@ -20,3 +20,8 @@ mkinstalldirs install-sh Eterm*.tar.gz *.sddf +autom4te* +depcomp +build.mezz +iconv_test* +utf8* diff --git a/ChangeLog b/ChangeLog index 3bbbcfa..9e5e09c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 palette. ---------------------------------------------------------------------- +Mon Apr 18 21:49:08 2005 Michael Jennings (mej) + +Re-indent code. +---------------------------------------------------------------------- diff --git a/reformat-code b/reformat-code index 8f79abe..c18365e 100755 --- a/reformat-code +++ b/reformat-code @@ -2,14 +2,14 @@ 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" done for i in *.c src/*.c utils/*.c ; do if test -f $i; then 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 fi done diff --git a/src/actions.c b/src/actions.c index 409218f..5db1ef1 100644 --- a/src/actions.c +++ b/src/actions.c @@ -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)); 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)) { D_ACTIONS(("Match found at %8p\n", 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 most popular choices first. If any test fails, we return FALSE. */ - D_ACTIONS(("Checking modifier set 0x%08x (" MOD_FMT ") vs. X modifier set 0x%08x (" MOD_FMT ")\n", mod, SHOW_MODS(mod), x_mod, SHOW_X_MODS(x_mod))); + D_ACTIONS(("Checking modifier set 0x%08x (" MOD_FMT ") vs. X modifier set 0x%08x (" MOD_FMT ")\n", mod, SHOW_MODS(mod), x_mod, + SHOW_X_MODS(x_mod))); if (mod != MOD_ANY) { /* LOGICAL_XOR() returns true if either the first parameter or the second parameter is true, but not both...just like XOR. If the mask we're looking for is set in @@ -202,7 +204,8 @@ action_dispatch(event_t *ev, KeySym keysym) ASSERT_RVAL(ev != NULL, 0); ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, 0); - D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", ev, ev->xbutton.button, keysym, ev->xkey.state, SHOW_X_MODS(ev->xkey.state))); + D_ACTIONS(("Event %8p: Button %d, Keysym 0x%08x, Key State 0x%08x (modifiers " MOD_FMT ")\n", ev, ev->xbutton.button, keysym, + ev->xkey.state, SHOW_X_MODS(ev->xkey.state))); for (action = action_list; action; action = action->next) { /* The very first thing we do is match the event type to the type of the current action. This means that we'll only run through @@ -241,29 +244,29 @@ action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_ action->type = type; action->keysym = keysym; switch (type) { - case ACTION_STRING: - action->handler = (action_handler_t) action_handle_string; - action->param.string = (char *) MALLOC(strlen((char *) param) + 2); - strcpy(action->param.string, (char *) param); - parse_escaped_string(action->param.string); - break; - case ACTION_ECHO: - action->handler = (action_handler_t) action_handle_echo; - action->param.string = (char *) MALLOC(strlen((char *) param) + 2); - strcpy(action->param.string, (char *) param); - parse_escaped_string(action->param.string); - break; - case ACTION_SCRIPT: - action->handler = (action_handler_t) action_handle_script; - action->param.script = (char *) MALLOC(strlen((char *) param) + 2); - strcpy(action->param.script, (char *) param); - break; - case ACTION_MENU: - action->handler = (action_handler_t) action_handle_menu; - action->param.menu = (menu_t *) param; - break; - default: - break; + case ACTION_STRING: + action->handler = (action_handler_t) action_handle_string; + action->param.string = (char *) MALLOC(strlen((char *) param) + 2); + strcpy(action->param.string, (char *) param); + parse_escaped_string(action->param.string); + break; + case ACTION_ECHO: + action->handler = (action_handler_t) action_handle_echo; + action->param.string = (char *) MALLOC(strlen((char *) param) + 2); + strcpy(action->param.string, (char *) param); + parse_escaped_string(action->param.string); + break; + case ACTION_SCRIPT: + action->handler = (action_handler_t) action_handle_script; + action->param.script = (char *) MALLOC(strlen((char *) param) + 2); + strcpy(action->param.script, (char *) param); + break; + case ACTION_MENU: + action->handler = (action_handler_t) action_handle_menu; + action->param.menu = (menu_t *) param; + break; + default: + break; } D_ACTIONS(("Added action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button, action->keysym)); } diff --git a/src/buttons.c b/src/buttons.c index b1daf92..6f4645f 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -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) { - 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(d != None); REQUIRE(gc != None); @@ -91,7 +92,8 @@ buttonbar_t *bbar_create(void) xattr.colormap = cmap; 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; 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; } bbar_draw(bbar, IMAGE_STATE_SELECTED, 0); - XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); + XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), + &(ev->xbutton.y), &unused_mask); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y); if (b) { bbar_select_button(bbar, b); @@ -299,7 +302,9 @@ bbar_handle_button_release(event_t *ev) size_t l = strlen(orig_argv0) + strlen(u) + 7; if ((c = MALLOC(l))) { - snprintf(c, l, "%s%s -U %s", ((orig_argv0[0] == '/') || ((orig_argv0[0] == '.') && (orig_argv0[1] == '/'))) ? "" : "./", orig_argv0, u); + snprintf(c, l, "%s%s -U %s", ((orig_argv0[0] == '/') + || ((orig_argv0[0] == '.') + && (orig_argv0[1] == '/'))) ? "" : "./", orig_argv0, u); D_ESCREEN(("(experimental) creating other frame using \"%s\"\n", c)); (void) ns_run(TermWin.screen->efuns, c); FREE(c); @@ -326,13 +331,15 @@ bbar_handle_button_release(event_t *ev) return 0; } - XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask); + XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), + &(ev->xbutton.y), &unused_mask); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y); if (b) { D_EVENTS(("Event in buttonbar %8p, button %8p (%s)\n", bbar, b, NONULL(b->text))); if (bbar->current && (b != bbar->current)) { - D_EVENTS(("Current button %8p (%s) doesn't match event button %8p (%s)\n", bbar->current, NONULL(bbar->current->text), b, NONULL(b->text))); + D_EVENTS(("Current button %8p (%s) doesn't match event button %8p (%s)\n", bbar->current, NONULL(bbar->current->text), + b, NONULL(b->text))); bbar_deselect_button(bbar, bbar->current); } else { bbar_select_button(bbar, b); @@ -361,7 +368,8 @@ bbar_handle_motion_notify(event_t *ev) return 0; } while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, MotionNotify, ev)); - XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), &(ev->xbutton.y), &mask); + XQueryPointer(Xdisplay, bbar->win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &(ev->xbutton.x), + &(ev->xbutton.y), &mask); D_BBAR((" -> Pointer is at %d, %d with mask 0x%08x\n", ev->xbutton.x, ev->xbutton.y, mask)); b = find_button_by_coords(bbar, ev->xbutton.x, ev->xbutton.y); @@ -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)); } #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 @@ -654,7 +663,8 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname) ASSERT_RVAL(fontname != NULL, 0); - D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth, bbar->fheight, bbar->h)); + D_BBAR(("bbar_set_font(%8p, \"%s\"): Current font is %8p, dimensions %d/%d/%d\n", bbar, fontname, bbar->font, bbar->fwidth, + bbar->fheight, bbar->h)); if (bbar->font) { free_font(bbar->font); } @@ -674,7 +684,8 @@ bbar_set_font(buttonbar_t *bbar, const char *fontname) bbar->fheight = font->ascent + font->descent; XSetFont(Xdisplay, bbar->gc, font->fid); 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); return 1; @@ -803,24 +814,24 @@ button_set_action(button_t *button, action_type_t type, char *action) button->type = type; switch (type) { - case ACTION_MENU: - button->action.menu = find_menu_by_title(menu_list, action); - return ((button->action.menu == NULL) ? (0) : (1)); - break; - case ACTION_STRING: - case ACTION_ECHO: - button->action.string = (char *) MALLOC(strlen(action) + 2); - strcpy(button->action.string, action); - parse_escaped_string(button->action.string); - return ((button->action.string == NULL) ? (0) : (1)); - break; - case ACTION_SCRIPT: - button->action.script = (char *) MALLOC(strlen(action) + 2); - strcpy(button->action.script, action); - return ((button->action.script == NULL) ? (0) : (1)); - break; - default: - break; + case ACTION_MENU: + button->action.menu = find_menu_by_title(menu_list, action); + return ((button->action.menu == NULL) ? (0) : (1)); + break; + case ACTION_STRING: + case ACTION_ECHO: + button->action.string = (char *) MALLOC(strlen(action) + 2); + strcpy(button->action.string, action); + parse_escaped_string(button->action.string); + return ((button->action.string == NULL) ? (0) : (1)); + break; + case ACTION_SCRIPT: + button->action.script = (char *) MALLOC(strlen(action) + 2); + strcpy(button->action.script, action); + return ((button->action.script == NULL) ? (0) : (1)); + break; + default: + break; } return 0; } @@ -871,7 +882,8 @@ bbar_click_button(buttonbar_t *bbar, button_t *button) if (image_mode_is(image_button, MODE_MASK)) { paste_simage(images[image_button].clicked, image_button, bbar->win, bbar->win, button->x, button->y, button->w, button->h); } else { - draw_shadow_from_colors(bbar->win, PixColors[menuBottomShadowColor], PixColors[menuTopShadowColor], button->x, button->y, button->w, button->h, 2); + draw_shadow_from_colors(bbar->win, PixColors[menuBottomShadowColor], PixColors[menuTopShadowColor], button->x, button->y, + button->w, button->h, 2); } if (image_mode_is(image_button, MODE_AUTO)) { enl_ipc_sync(); @@ -893,99 +905,100 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti 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) { - case ACTION_MENU: - D_BBAR((" -> Menu button found.\n")); - if (press) { - menu_invoke(button->x, button->y + button->h, bbar->win, button->action.menu, t); - } - break; - case ACTION_STRING: - D_BBAR((" -> String button found.\n")); - if (!press) { - size_t len; + case ACTION_MENU: + D_BBAR((" -> Menu button found.\n")); + if (press) { + menu_invoke(button->x, button->y + button->h, bbar->win, button->action.menu, t); + } + break; + case ACTION_STRING: + D_BBAR((" -> String button found.\n")); + if (!press) { + size_t len; - len = strlen(button->action.string); - D_BBAR(("Writing \"%s\" to command buffer.\n", safe_print_string(button->action.string, len))); - cmd_write((unsigned char *) button->action.string, strlen(button->action.string)); - } - break; - case ACTION_ECHO: - D_BBAR((" -> Echo button found.\n")); - if (!press) { - size_t len; + len = strlen(button->action.string); + D_BBAR(("Writing \"%s\" to command buffer.\n", safe_print_string(button->action.string, len))); + cmd_write((unsigned char *) button->action.string, strlen(button->action.string)); + } + break; + case ACTION_ECHO: + D_BBAR((" -> Echo button found.\n")); + if (!press) { + size_t len; #ifdef ESCREEN - if (TermWin.screen && TermWin.screen->backend) { /* translate escapes */ - button_t *b = bbar->buttons; - _ns_disp *d2 = TermWin.screen->dsps; - int n = (button->action.string)[1] - '0'; + if (TermWin.screen && TermWin.screen->backend) { /* translate escapes */ + button_t *b = bbar->buttons; + _ns_disp *d2 = TermWin.screen->dsps; + int n = (button->action.string)[1] - '0'; - if (b && (b->flags & NS_SCREAM_BUTTON)) { - D_ESCREEN(("Looking for active display, n == %d, press == %d, prvs == %d\n", n, (int) press, (int) prvs)); - if (prvs != 1) { - /* find active disp */ - for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next); + if (b && (b->flags & NS_SCREAM_BUTTON)) { + D_ESCREEN(("Looking for active display, n == %d, press == %d, prvs == %d\n", n, (int) press, (int) prvs)); + if (prvs != 1) { + /* find active disp */ + for (; b && !(b->flags & NS_SCREAM_CURR); b = b->next); - if (b && b != button) { - D_ESCREEN((" -> Found button %8p (%s) for current display.\n", b, NONULL(b->text))); + if (b && b != button) { + D_ESCREEN((" -> Found button %8p (%s) for current display.\n", b, NONULL(b->text))); - /* when trying to change name of non- */ - /* active display, make that disp active */ - button->flags |= NS_SCREAM_CURR; - b->flags &= ~NS_SCREAM_CURR; - bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK); - button->flags &= ~NS_SCREAM_CURR; - b->flags |= NS_SCREAM_CURR; + /* when trying to change name of non- */ + /* active display, make that disp active */ + button->flags |= NS_SCREAM_CURR; + b->flags &= ~NS_SCREAM_CURR; + bbar_draw(bbar, IMAGE_STATE_CURRENT, MODE_MASK); + button->flags &= ~NS_SCREAM_CURR; + b->flags |= NS_SCREAM_CURR; - for (; d2 && d2->index != n; d2 = d2->next); - if (d2) { - /* pre-adjust curr ptr */ - TermWin.screen->curr = d2; - } else { - D_ESCREEN(("no display %d in this session : (\n", n)); - } - ns_go2_disp(TermWin.screen, n); - } + for (; d2 && d2->index != n; d2 = d2->next); + if (d2) { + /* pre-adjust curr ptr */ + TermWin.screen->curr = d2; + } else { + D_ESCREEN(("no display %d in this session : (\n", n)); + } + ns_go2_disp(TermWin.screen, n); + } - if (prvs == 2) { - /* middle button -- kill */ - D_ESCREEN((" -> Remove display %d\n", n)); - ns_rem_disp(TermWin.screen, n, TRUE); - } else { - /* right button -- rename */ - D_ESCREEN((" -> Rename display %d\n", n)); - ns_ren_disp(TermWin.screen, n, NULL); - } - } else { - /* left button -- select */ - D_ESCREEN((" -> Go to display %d\n", n)); - ns_go2_disp(TermWin.screen, n); - } - break; - } else { - D_ESCREEN(("Non-screen button, handling normally.\n")); - } - } + if (prvs == 2) { + /* middle button -- kill */ + D_ESCREEN((" -> Remove display %d\n", n)); + ns_rem_disp(TermWin.screen, n, TRUE); + } else { + /* right button -- rename */ + D_ESCREEN((" -> Rename display %d\n", n)); + ns_ren_disp(TermWin.screen, n, NULL); + } + } else { + /* left button -- select */ + D_ESCREEN((" -> Go to display %d\n", n)); + ns_go2_disp(TermWin.screen, n); + } + break; + } else { + D_ESCREEN(("Non-screen button, handling normally.\n")); + } + } #endif - /* not in screen-mode, use normal facilities */ - len = strlen(button->action.string); - D_BBAR(("Writing \"%s\" to subprocess.\n", safe_print_string(button->action.string, len))); - tt_write((unsigned char *) button->action.string, len); - } - break; - case ACTION_SCRIPT: - D_BBAR((" -> Script button found.\n")); - if (!press) { - script_parse((char *) button->action.script); - } - break; - default: - D_BBAR((" -> Unknown button type 0x%08x?!\n", button->type)); - break; + /* not in screen-mode, use normal facilities */ + len = strlen(button->action.string); + D_BBAR(("Writing \"%s\" to subprocess.\n", safe_print_string(button->action.string, len))); + tt_write((unsigned char *) button->action.string, len); + } + break; + case ACTION_SCRIPT: + D_BBAR((" -> Script button found.\n")); + if (!press) { + script_parse((char *) button->action.script); + } + break; + default: + D_BBAR((" -> Unknown button type 0x%08x?!\n", button->type)); + break; } prvs = press; } @@ -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); for (button = bbar->buttons; button; button = button->next) { 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) { #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) { 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) { draw_string(bbar, bbar->bg, bbar->gc, button->text_x, button->text_y, button->text, button->len); diff --git a/src/command.c b/src/command.c index 54d093d..23abcc3 100644 --- a/src/command.c +++ b/src/command.c @@ -201,57 +201,61 @@ privileges(int mode) #endif switch (mode) { - case IGNORE: - /* 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())); + case IGNORE: + /* 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())); #ifdef HAVE_SETRESGID - setresgid(my_rgid, my_rgid, my_egid); + setresgid(my_rgid, my_rgid, my_egid); #elif defined(HAVE_SAVED_UIDS) - setregid(my_rgid, my_rgid); + setregid(my_rgid, my_rgid); #else - setregid(my_egid, -1); - setregid(-1, my_rgid); + setregid(my_egid, -1); + setregid(-1, my_rgid); #endif #ifdef HAVE_SETRESUID - setresuid(my_ruid, my_ruid, my_euid); + setresuid(my_ruid, my_ruid, my_euid); #elif defined(HAVE_SAVED_UIDS) - setreuid(my_ruid, my_ruid); + setreuid(my_ruid, my_ruid); #else - setreuid(my_euid, -1); - setreuid(-1, my_ruid); + setreuid(my_euid, -1); + setreuid(-1, my_ruid); #endif - D_UTMP(("[%ld]: After privileges(REVERT): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), getegid())); - break; + D_UTMP(("[%ld]: After privileges(REVERT): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), + getegid())); + break; - case SAVE: - break; + case SAVE: + break; - case RESTORE: - D_UTMP(("[%ld]: Before privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), getegid())); + case RESTORE: + D_UTMP(("[%ld]: Before privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), + getegid())); #ifdef HAVE_SETRESUID - setresuid(my_ruid, my_euid, my_euid); + setresuid(my_ruid, my_euid, my_euid); #elif defined(HAVE_SAVED_UIDS) - setreuid(my_ruid, my_euid); + setreuid(my_ruid, my_euid); #else - setreuid(-1, my_euid); - setreuid(my_ruid, -1); + setreuid(-1, my_euid); + setreuid(my_ruid, -1); #endif #ifdef HAVE_SETRESGID - setresgid(my_rgid, my_egid, my_egid); + setresgid(my_rgid, my_egid, my_egid); #elif defined(HAVE_SAVED_UIDS) - setregid(my_rgid, my_egid); + setregid(my_rgid, my_egid); #else - setregid(-1, my_egid); - setregid(my_rgid, -1); + setregid(-1, my_egid); + setregid(my_rgid, -1); #endif - D_UTMP(("[%ld]: After privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), getegid())); - break; + D_UTMP(("[%ld]: After privileges(INVOKE): [ %ld, %ld ] [ %ld, %ld ]\n", getpid(), getuid(), getgid(), geteuid(), + getegid())); + break; } } @@ -1172,7 +1176,8 @@ clean_exit(void) #ifndef __CYGWIN32__ 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) { 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 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)); 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); - 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->width = needed_rect->width ? needed_rect->width : Width2Pixel(TERM_WINDOW_GET_COLS() + 1); @@ -1922,7 +1931,8 @@ xim_real_init(void) *(end + 1) = '\0'; if (*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; } } @@ -2011,18 +2021,22 @@ xim_real_init(void) xim_set_size(&rect); xim_get_position(&spot); xim_set_color(&fg, &bg); - preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, XNFontSet, TermWin.fontset, NULL); + preedit_attr = + XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNForeground, fg, XNBackground, bg, XNFontSet, + TermWin.fontset, NULL); } else if (xim_input_style & XIMPreeditArea) { xim_set_color(&fg, &bg); /* The necessary width of preedit area is unknown until create input context. */ needed_rect.width = 0; xim_get_area(&rect, &status_rect, &needed_rect); 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 = 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) { XFree(preedit_attr); } @@ -2126,7 +2140,8 @@ run_command(char **argv) /* store original tty status for restoration clean_exit() -- rgg 04/12/95 */ 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 */ #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)) { switch (menu_dialog(xd, prompt, maxlen, retstr, inp_tab)) { - case 0: - return NS_SUCC; - case -2: - return NS_USER_CXL; - default: - return NS_FAIL; + case 0: + return NS_SUCC; + case -2: + return NS_USER_CXL; + default: + return NS_FAIL; } } @@ -2702,45 +2717,45 @@ matrix(int n) r = screen.rend[ys + y]; switch (w) { - case 0: /* restart */ - if (s[x]) { - r[x] = MATRIX_LO; - s[x] = 0; - t = screen.text[ys]; - r = screen.rend[ys]; - } - r[x] = MATRIX_HI; - t[x] = random() & 0xff; - s[x]++; - /* fall-through */ + case 0: /* restart */ + if (s[x]) { + r[x] = MATRIX_LO; + s[x] = 0; + t = screen.text[ys]; + r = screen.rend[ys]; + } + r[x] = MATRIX_HI; + t[x] = random() & 0xff; + s[x]++; + /* fall-through */ - case 1: /* continue */ - case 2: - case 3: - for (f = random() & 7; f != 0; f--) { - if (y < TERM_WINDOW_GET_ROWS() - 1) { - t2 = screen.text[ys + y + 1]; - r2 = screen.rend[ys + y + 1]; - t2[x] = t[x]; - r2[x] = r[x]; - s[x]++; - y++; - } else { - s[x] = 0; - f = 0; - } - r[x] = MATRIX_LO; - t[x] = random() & 0xff; - if (f) { - scr_refresh(FAST_REFRESH); - t = screen.text[ys + y]; - r = screen.rend[ys + y]; - } - } - break; + case 1: /* continue */ + case 2: + case 3: + for (f = random() & 7; f != 0; f--) { + if (y < TERM_WINDOW_GET_ROWS() - 1) { + t2 = screen.text[ys + y + 1]; + r2 = screen.rend[ys + y + 1]; + t2[x] = t[x]; + r2[x] = r[x]; + s[x]++; + y++; + } else { + s[x] = 0; + f = 0; + } + r[x] = MATRIX_LO; + t[x] = random() & 0xff; + if (f) { + scr_refresh(FAST_REFRESH); + t = screen.text[ys + y]; + r = screen.rend[ys + y]; + } + } + break; - default: - t[x] = random() & 0xff; /* hold */ + default: + t[x] = random() & 0xff; /* hold */ } } } @@ -2825,6 +2840,7 @@ make_escreen_menu(buttonbar_t *bbar) { static int been_here = 0; button_t *button; + #if 0 menu_t *m; menuitem_t *i; @@ -3040,8 +3056,7 @@ tt_winsize(int fd) ws.ws_xpixel = (unsigned short) TERM_WINDOW_GET_WIDTH(); ws.ws_ypixel = (unsigned short) TERM_WINDOW_GET_HEIGHT(); #endif - 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)); + 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)); ioctl(fd, TIOCSWINSZ, &ws); } @@ -3117,7 +3132,8 @@ check_pixmap_change(int sig) SIG_RETURN(0); } 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) { D_PIXMAP(("Time to update pixmap. now == %lu\n", now)); imlib_context_set_image(images[image_bg].current->iml->im); @@ -3177,42 +3193,43 @@ cmd_getc(void) #ifdef ESCREEN if (TermWin.screen) { switch (TermWin.screen->backend) { - case NS_MODE_NONE: - break; - case NS_MODE_NEGOTIATE: + case NS_MODE_NONE: + break; + case NS_MODE_NEGOTIATE: # ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - parse_screen_status_if_necessary(); - break; + case NS_MODE_SCREEN: + parse_screen_status_if_necessary(); + break; # endif # ifdef NS_HAVE_SCREAM - case NS_MODE_SCREAM: - break; + case NS_MODE_SCREAM: + break; # endif # ifdef NS_HAVE_TWIN - case NS_MODE_TWIN: - if (!TermWin.screen->twin) { - if (!TermWin.screen->timestamp) { - TermWin.screen->timestamp = time(NULL); - } else if (TermWin.screen->timestamp < time(NULL)) { - if (!Tw_CheckMagic(libscream_magic)) { - D_ESCREEN(("ns_attach_by_sess: Tw_CheckMagic failed\n")); - TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; - } else { - if (!(TermWin.screen->twin = Tw_Open(TermWin.screen->twin_str))) { - ns_desc_twin(TermWin.screen, "cmd_getc->Tw_Open"); - TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; - } else { - D_ESCREEN(("ns_attach_by_sess: Tw_Open(%s) succeeded: handle @ %p\n", TermWin.screen->twin_str, TermWin.screen->twin)); - } - } - } - } - break; + case NS_MODE_TWIN: + if (!TermWin.screen->twin) { + if (!TermWin.screen->timestamp) { + TermWin.screen->timestamp = time(NULL); + } else if (TermWin.screen->timestamp < time(NULL)) { + if (!Tw_CheckMagic(libscream_magic)) { + D_ESCREEN(("ns_attach_by_sess: Tw_CheckMagic failed\n")); + TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; + } else { + if (!(TermWin.screen->twin = Tw_Open(TermWin.screen->twin_str))) { + ns_desc_twin(TermWin.screen, "cmd_getc->Tw_Open"); + TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; + } else { + D_ESCREEN(("ns_attach_by_sess: Tw_Open(%s) succeeded: handle @ %p\n", TermWin.screen->twin_str, + TermWin.screen->twin)); + } + } + } + } + break; # endif - default: - D_ESCREEN(("mode %d not supported...\n", TermWin.screen->backend)); - TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; + default: + D_ESCREEN(("mode %d not supported...\n", TermWin.screen->backend)); + TermWin.screen->backend = TermWin.screen_mode = NS_MODE_NONE; } } #endif @@ -3521,7 +3538,7 @@ main_loop(void) set_multichar_encoding("utf8"); } 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", setlocale(LC_ALL, "")); setlocale(LC_ALL, "C"); @@ -3536,24 +3553,26 @@ main_loop(void) bufflen = cmdbuf_ptr - str; outlen = bufflen * 6; poutbuff = outbuff = SPIF_CAST_C(char *) MALLOC(outlen); + 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)); retval = iconv(handle, &pinbuff, &bufflen, &poutbuff, &outlen); outlen = (size_t) (poutbuff - outbuff); - if (retval != (size_t) -1) { + if (retval != (size_t) - 1) { errno = 0; } if (errno == E2BIG) { print_error("My UTF-8 decode buffer was too small by %lu bytes?!\n", bufflen); } else if (errno == EILSEQ) { - print_error("Illegal multibyte sequence encountered at \'%c\' (0x%02x); skipping.\n", - *pinbuff, *pinbuff); + print_error("Illegal multibyte sequence encountered at \'%c\' (0x%02x); skipping.\n", *pinbuff, *pinbuff); *pinbuff = ' '; pinbuff++; } else if (errno == EINVAL) { 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 { 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; if (outlen > 0) { outbuff = SPIF_CAST_C(char *) MALLOC(outlen); + outlen = wcsrtombs(outbuff, &wcbuff, outlen, &mbs); - if ((long)outlen >= 0) { + if ((long) outlen >= 0) { FREE(wcbuff); print_error("I win!\n"); } 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) { cmdbuf_ptr = (unsigned char *) pinbuff; scr_add_lines(outbuff, nlines, outlen); } } 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); } @@ -3587,32 +3609,32 @@ main_loop(void) } else { switch (ch) { # ifdef NO_ENQ_ANS - case 005: - break; + case 005: + break; # else - case 005: /* ^E (ENQ) terminal status enquiry */ - tt_printf(VT100_ANS); - break; + case 005: /* ^E (ENQ) terminal status enquiry */ + tt_printf(VT100_ANS); + break; # endif - case 007: /* ^G (BEL) */ - scr_bell(); - break; - case '\b': - scr_backspace(); - break; - case 013: /* ^K (VT) */ - case 014: /* ^L (FF) */ - scr_index(UP); - break; - case 016: /* ^N (SO) shift out (enter ACS mode) */ - scr_charset_choose(1); - break; - case 017: /* ^O (SI) shift in (leave ACS mode) */ - scr_charset_choose(0); - break; - case 033: - process_escape_seq(); - break; + case 007: /* ^G (BEL) */ + scr_bell(); + break; + case '\b': + scr_backspace(); + break; + case 013: /* ^K (VT) */ + case 014: /* ^L (FF) */ + scr_index(UP); + break; + case 016: /* ^N (SO) shift out (enter ACS mode) */ + scr_charset_choose(1); + break; + case 017: /* ^O (SI) shift in (leave ACS mode) */ + scr_charset_choose(0); + break; + case 033: + process_escape_seq(); + break; } } } while (ch != EOF); diff --git a/src/draw.c b/src/draw.c index 0566d8d..5bd2c30 100644 --- a/src/draw.c +++ b/src/draw.c @@ -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); switch (type) { - case DRAW_ARROW_UP: - for (; shadow > 0; shadow--, x++, y++, w--) { - 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, y + w); - } - break; - case DRAW_ARROW_DOWN: - 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, y); - XDrawLine(Xdisplay, d, gc_bottom, x + w, y, x + w / 2, y + w); - } - break; - case DRAW_ARROW_LEFT: - 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, y + w / 2); - XDrawLine(Xdisplay, d, gc_top, x, y + w / 2, x + w, y); - } - break; - case DRAW_ARROW_RIGHT: - 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 + w, y + w / 2); - XDrawLine(Xdisplay, d, gc_bottom, x, y + w, x + w, y + w / 2); - } - break; - default: - break; + case DRAW_ARROW_UP: + for (; shadow > 0; shadow--, x++, y++, w--) { + 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, y + w); + } + break; + case DRAW_ARROW_DOWN: + 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, y); + XDrawLine(Xdisplay, d, gc_bottom, x + w, y, x + w / 2, y + w); + } + break; + case DRAW_ARROW_LEFT: + 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, y + w / 2); + XDrawLine(Xdisplay, d, gc_top, x, y + w / 2, x + w, y); + } + break; + case DRAW_ARROW_RIGHT: + 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 + w, y + w / 2); + XDrawLine(Xdisplay, d, gc_bottom, x, y + w, x + w, y + w / 2); + } + break; + default: + break; } } @@ -173,27 +173,27 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border * bord, unsigned char up) } /* Determine bitshift and bitmask values */ switch (real_depth) { - case 15: - br = 7; - bg = 2; - bb = 3; - mr = mg = mb = 0xf8; - break; - case 16: - br = 8; - bg = bb = 3; - mr = mb = 0xf8; - mg = 0xfc; - break; - case 24: - case 32: - br = 16; - bg = 8; - bb = 0; - mr = mg = mb = 0xff; - break; - default: - return; + case 15: + br = 7; + bg = 2; + bb = 3; + mr = mg = mb = 0xf8; + break; + case 16: + br = 8; + bg = bb = 3; + mr = mb = 0xf8; + mg = 0xfc; + break; + case 24: + case 32: + br = 16; + bg = 8; + bb = 0; + mr = mg = mb = 0xff; + break; + default: + return; } /* Left edge */ diff --git a/src/e.c b/src/e.c index 26120d1..c2b62a1 100644 --- a/src/e.c +++ b/src/e.c @@ -85,13 +85,15 @@ enl_ipc_get_win(void) XFree(str); } 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")); ipc_win = None; } str = NULL; 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) { XFree(str); } else { diff --git a/src/events.c b/src/events.c index f35d926..18311eb 100644 --- a/src/events.c +++ b/src/events.c @@ -73,7 +73,8 @@ event_register_dispatcher(event_dispatcher_t func, event_dispatcher_init_t init) /* Add a secondary event dispatcher */ 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; (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)) { 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]) { win = get_desktop_window(); if (win == (Window) 1) { @@ -270,7 +272,8 @@ handle_property_notify(event_t *ev) } #endif 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 ((enl_ipc_get_win()) != None) { #ifdef PIXMAP_SUPPORT @@ -341,7 +344,8 @@ handle_client_message(event_t *ev) unsigned char *data; 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) { XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, strlen(data)); selection_paste(XA_CUT_BUFFER0); @@ -394,18 +398,18 @@ handle_visibility_notify(event_t *ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0); switch (ev->xvisibility.state) { - case VisibilityUnobscured: - D_X11(("Window completely visible. Using FAST_REFRESH.\n")); - refresh_type = FAST_REFRESH; - break; - case VisibilityPartiallyObscured: - D_X11(("Window partially hidden. Using SLOW_REFRESH.\n")); - refresh_type = SLOW_REFRESH; - break; - default: - D_X11(("Window completely hidden. Using NO_REFRESH.\n")); - refresh_type = NO_REFRESH; - break; + case VisibilityUnobscured: + D_X11(("Window completely visible. Using FAST_REFRESH.\n")); + refresh_type = FAST_REFRESH; + break; + case VisibilityPartiallyObscured: + D_X11(("Window partially hidden. Using SLOW_REFRESH.\n")); + refresh_type = SLOW_REFRESH; + break; + default: + D_X11(("Window completely hidden. Using NO_REFRESH.\n")); + refresh_type = NO_REFRESH; + break; } return 1; } @@ -460,7 +464,8 @@ handle_focus_in(event_t *ev) unsigned int unused_mask; 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 (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); 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) { int x = ev->xconfigure.x, y = ev->xconfigure.y; @@ -651,85 +657,87 @@ handle_button_press(event_t *ev) mouse_report(&(ev->xbutton)); } else { switch (ev->xbutton.button) { - case Button1: - if ((button_state.last_button_press == 1) && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) { - button_state.clicks++; - } else { - button_state.clicks = 1; - } - selection_click(button_state.clicks, ev->xbutton.x, ev->xbutton.y); - button_state.last_button_press = 1; - break; + case Button1: + if ((button_state.last_button_press == 1) + && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) { + button_state.clicks++; + } else { + button_state.clicks = 1; + } + selection_click(button_state.clicks, ev->xbutton.x, ev->xbutton.y); + button_state.last_button_press = 1; + break; - case Button3: - if ((button_state.last_button_press == 3) && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) { - selection_rotate(ev->xbutton.x, ev->xbutton.y); - } else { - selection_extend(ev->xbutton.x, ev->xbutton.y, 1); - } - button_state.last_button_press = 3; - break; + case Button3: + if ((button_state.last_button_press == 3) + && (ev->xbutton.time - button_state.button_press < MULTICLICK_TIME)) { + selection_rotate(ev->xbutton.x, ev->xbutton.y); + } else { + selection_extend(ev->xbutton.x, ev->xbutton.y, 1); + } + button_state.last_button_press = 3; + break; #ifdef MOUSEWHEEL - /* This section activates the following bindings: - * - * Mousewheel Up -- Scroll up 1 page - * Ctrl + Mousewheel Up -- Scroll up 5 pages - * Shift + Mousewheel Up -- Scroll up 1 line - * Alt + Mousewheel Up -- Send PgUp to tty - * Alt + Ctrl + Mousewheel Up -- Send 5 PgUp's to tty - * Alt + Shift + Mousewheel Up -- Send Up Arrow to tty - * - * Mousewheel Down -- Scroll down 1 page - * Ctrl + Mousewheel Down -- Scroll down 5 pages - * Shift + Mousewheel Down -- Scroll down 1 line - * Alt + Mousewheel Down -- Send PgDn to tty - * Alt + Ctrl + Mousewheel Down -- Send 5 PgDn's 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 - * 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 - * (5 * LINES_PER_PAGE) - CONTEXT_LINES - * _not_ - * (LINES_PER_PAGE - CONTEXT_LINES) * 5 - * - * This is also true for the scroll() function in script.c. - */ - case Button4: - if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) { - scr_page(UP, (TermWin.nrow * 5) - CONTEXT_LINES); - } else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) { - scr_page(UP, 1); - } else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) { - tt_write("\033[5~", 4); - } else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) { - tt_write("\033[A", 3); - } 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); - } else { - scr_page(UP, TermWin.nrow - CONTEXT_LINES); - } - button_state.last_button_press = 4; - break; - case Button5: - if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) { - scr_page(DN, (TermWin.nrow * 5) - CONTEXT_LINES); - } else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) { - scr_page(DN, 1); - } else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) { - tt_write("\033[6~", 4); - } else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) { - tt_write("\033[B", 3); - } 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); - } else { - scr_page(DN, TermWin.nrow - CONTEXT_LINES); - } - button_state.last_button_press = 5; - break; + /* This section activates the following bindings: + * + * Mousewheel Up -- Scroll up 1 page + * Ctrl + Mousewheel Up -- Scroll up 5 pages + * Shift + Mousewheel Up -- Scroll up 1 line + * Alt + Mousewheel Up -- Send PgUp to tty + * Alt + Ctrl + Mousewheel Up -- Send 5 PgUp's to tty + * Alt + Shift + Mousewheel Up -- Send Up Arrow to tty + * + * Mousewheel Down -- Scroll down 1 page + * Ctrl + Mousewheel Down -- Scroll down 5 pages + * Shift + Mousewheel Down -- Scroll down 1 line + * Alt + Mousewheel Down -- Send PgDn to tty + * Alt + Ctrl + Mousewheel Down -- Send 5 PgDn's 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 + * 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 + * (5 * LINES_PER_PAGE) - CONTEXT_LINES + * _not_ + * (LINES_PER_PAGE - CONTEXT_LINES) * 5 + * + * This is also true for the scroll() function in script.c. + */ + case Button4: + if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) { + scr_page(UP, (TermWin.nrow * 5) - CONTEXT_LINES); + } else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) { + scr_page(UP, 1); + } else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) { + tt_write("\033[5~", 4); + } else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) { + tt_write("\033[A", 3); + } 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); + } else { + scr_page(UP, TermWin.nrow - CONTEXT_LINES); + } + button_state.last_button_press = 4; + break; + case Button5: + if (action_check_modifiers(MOD_CTRL, ev->xbutton.state)) { + scr_page(DN, (TermWin.nrow * 5) - CONTEXT_LINES); + } else if (action_check_modifiers(MOD_SHIFT, ev->xbutton.state)) { + scr_page(DN, 1); + } else if (action_check_modifiers(MOD_ALT, ev->xbutton.state)) { + tt_write("\033[6~", 4); + } else if (action_check_modifiers((MOD_ALT | MOD_SHIFT), ev->xbutton.state)) { + tt_write("\033[B", 3); + } 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); + } else { + scr_page(DN, TermWin.nrow - CONTEXT_LINES); + } + button_state.last_button_press = 5; + break; #endif - default: - break; + default: + break; } } button_state.button_press = ev->xbutton.time; @@ -757,14 +765,14 @@ handle_button_release(event_t *ev) if (ev->xbutton.subwindow == None) { if (button_state.report_mode) { switch (PrivateModes & PrivMode_mouse_report) { - case PrivMode_MouseX10: - break; + case PrivMode_MouseX10: + break; - case PrivMode_MouseX11: - ev->xbutton.state = button_state.bypass_keystate; - ev->xbutton.button = AnyButton; - mouse_report(&(ev->xbutton)); - break; + case PrivMode_MouseX11: + ev->xbutton.state = button_state.bypass_keystate; + ev->xbutton.button = AnyButton; + mouse_report(&(ev->xbutton)); + break; } return (1); } @@ -777,16 +785,16 @@ handle_button_release(event_t *ev) selection_extend(ev->xbutton.x, ev->xbutton.y, 0); } switch (ev->xbutton.button) { - case Button1: - case Button3: - selection_make(ev->xbutton.time); - break; + case Button1: + case Button3: + selection_make(ev->xbutton.time); + break; - case Button2: - selection_paste(XA_PRIMARY); - break; - default: - break; + case Button2: + selection_paste(XA_PRIMARY); + break; + default: + break; } } } @@ -824,7 +832,8 @@ handle_motion_notify(event_t *ev) unsigned int unused_mask; 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 /* deal with a `jumpy' mouse */ if ((ev->xmotion.time - button_state.button_press) > MOUSE_THRESHOLD) @@ -865,8 +874,9 @@ xerror_handler(Display * display, XErrorEvent * event) strcpy(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), - (int) event->resourceid, event->request_code, event->minor_code, err_string, event->error_code); + print_error("XError in function %s, resource 0x%08x (request %d.%d): %s (error %d)\n", + 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_LEVEL >= DEBUG_X11) { dump_stack_trace(); diff --git a/src/font.c b/src/font.c index 9e36b6f..4218fb6 100644 --- a/src/font.c +++ b/src/font.c @@ -166,15 +166,15 @@ font_cache_add(const char *name, unsigned char type, void *info) font->type = type; font->ref_cnt = 1; switch (type) { - case FONT_TYPE_X: - font->fontinfo.xfontinfo = (XFontStruct *) info; - break; - case FONT_TYPE_TTF: - break; - case FONT_TYPE_FNLIB: - break; - default: - break; + case FONT_TYPE_X: + font->fontinfo.xfontinfo = (XFontStruct *) info; + break; + case FONT_TYPE_TTF: + break; + case FONT_TYPE_FNLIB: + break; + default: + break; } 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. */ for (current = font_cache; current->next; current = current->next) { 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) { D_FONT((" -> Reference count is now 0. Deleting from cache.\n")); 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)) { D_FONT((" -> Match!\n")); switch (type) { - case FONT_TYPE_X: - return ((void *) current->fontinfo.xfontinfo); - break; - case FONT_TYPE_TTF: - return (NULL); - break; - case FONT_TYPE_FNLIB: - return (NULL); - break; - default: - return (NULL); - break; + case FONT_TYPE_X: + return ((void *) current->fontinfo.xfontinfo); + break; + case FONT_TYPE_TTF: + return (NULL); + break; + case FONT_TYPE_FNLIB: + return (NULL); + break; + default: + return (NULL); + break; } } } @@ -398,18 +399,18 @@ load_font(const char *name, const char *fallback, unsigned char type) font_cache_add_ref(font); D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt)); switch (type) { - case FONT_TYPE_X: - return ((void *) font->fontinfo.xfontinfo); - break; - case FONT_TYPE_TTF: - return (NULL); - break; - case FONT_TYPE_FNLIB: - return (NULL); - break; - default: - return (NULL); - break; + case FONT_TYPE_X: + return ((void *) font->fontinfo.xfontinfo); + break; + case FONT_TYPE_TTF: + return (NULL); + break; + case FONT_TYPE_FNLIB: + return (NULL); + break; + default: + return (NULL); + break; } } @@ -455,7 +456,8 @@ change_font(int init, const char *fontname) short idx = 0, old_idx = font_idx; 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) { ASSERT(etfonts != NULL); @@ -473,46 +475,46 @@ change_font(int init, const char *fontname) ASSERT(fontname != NULL); switch (*fontname) { - /* Empty font name. Reset to default. */ - case '\0': - font_idx = def_font_idx; - fontname = NULL; - break; + /* Empty font name. Reset to default. */ + case '\0': + font_idx = def_font_idx; + fontname = NULL; + break; - /* A font escape sequence. See which one it is. */ - case FONT_CMD: - idx = atoi(++fontname); - switch (*fontname) { - case '+': - NEXT_FONT(idx); - break; + /* A font escape sequence. See which one it is. */ + case FONT_CMD: + idx = atoi(++fontname); + switch (*fontname) { + case '+': + NEXT_FONT(idx); + break; - case '-': - PREV_FONT(idx); - break; + case '-': + PREV_FONT(idx); + break; - default: - if (*fontname != '\0' && !isdigit(*fontname)) - return; /* It's not a number. Punt. */ - /* Set current font to font N */ - BOUND(idx, 0, (font_cnt - 1)); - font_idx = idx; - break; - } - /* NULL out the fontname so we don't try to load it */ - fontname = NULL; - break; + default: + if (*fontname != '\0' && !isdigit(*fontname)) + return; /* It's not a number. Punt. */ + /* Set current font to font N */ + BOUND(idx, 0, (font_cnt - 1)); + font_idx = idx; + break; + } + /* NULL out the fontname so we don't try to load it */ + fontname = NULL; + break; - default: - /* 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++) { - if (!strcasecmp(etfonts[idx], fontname)) { - font_idx = idx; - fontname = NULL; - break; - } - } - break; + default: + /* 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++) { + if (!strcasecmp(etfonts[idx], fontname)) { + font_idx = idx; + fontname = NULL; + break; + } + } + break; } /* 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 */ /* 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; unsigned int i; double dev; @@ -610,7 +613,8 @@ change_font(int init, const char *fontname) /* Final font width is the average width plus 2 standard deviations, but no larger than the font's max width */ 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); } else { LOWER_BOUND(fw, TermWin.font->max_bounds.width); diff --git a/src/grkelot.c b/src/grkelot.c index b918d28..d8fed71 100644 --- a/src/grkelot.c +++ b/src/grkelot.c @@ -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"; /* 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"; 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[] = @@ -286,10 +287,10 @@ kstate_add_switcher(char *str) return; switcher = &pStateNow->switcher[pStateNow->num_switcher]; switch (switcher->type = str[0]) { - case 'A': /* ascii eg: A;:2 */ - switcher->code = str[1]; - switcher->nextstate = atoi(&str[3]); - break; + case 'A': /* ascii eg: A;:2 */ + switcher->code = str[1]; + switcher->nextstate = atoi(&str[3]); + break; } switcher->on = 0; pStateNow->num_switcher++; diff --git a/src/libscream.c b/src/libscream.c index b0ba913..e1e9868 100644 --- a/src/libscream.c +++ b/src/libscream.c @@ -185,7 +185,8 @@ ns_new_hop(int lp, char *fw, int fp, int delay, _ns_sess * s) if (s) { /* 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; 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)))) p = p->next; 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 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, 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 USE_VAR(sess); USE_VAR(doc); @@ -827,7 +833,8 @@ ns_desc_hop(_ns_hop * h, char *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", - 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)); else { 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) D_ESCREEN((":%s", sess->port)); } @@ -1093,17 +1101,21 @@ ns_attach_ssh(_ns_sess ** sp) if (sess->hop) { 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", - 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) return NS_FAIL; ns_run(sess->efuns, cmd); sleep(sess->hop->delay); } 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 { - 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, - ((sess->backend == NS_MODE_SCREEN) || (sess->backend == NS_MODE_NEGOTIATE)) ? esc : ""); + 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, ((sess->backend == NS_MODE_SCREEN) || (sess->backend == NS_MODE_NEGOTIATE)) ? esc : ""); } ns_free(&call); @@ -1139,21 +1151,21 @@ ns_attach_by_sess(_ns_sess ** sp, int *err) (void) ns_sess_init(sess); switch (sess->where) { - case NS_LCL: - sess->fd = ns_attach_lcl(&sess); - break; - case NS_SU: /* (fixme) uses ssh, should use su */ - /* local session, but for a different uid. */ - /* FALL-THROUGH */ - case NS_SSH: - if (!sess->delay) { - sess->delay = NS_INIT_DELAY ? NS_INIT_DELAY : 1; - } - sess->fd = ns_attach_ssh(&sess); - break; - default: - *err = NS_UNKNOWN_LOC; - goto fail; + case NS_LCL: + sess->fd = ns_attach_lcl(&sess); + break; + case NS_SU: /* (fixme) uses ssh, should use su */ + /* local session, but for a different uid. */ + /* FALL-THROUGH */ + case NS_SSH: + if (!sess->delay) { + sess->delay = NS_INIT_DELAY ? NS_INIT_DELAY : 1; + } + sess->fd = ns_attach_ssh(&sess); + break; + default: + *err = NS_UNKNOWN_LOC; + goto fail; } 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 # endif - { - NOP; - } + { + NOP; + } while (*r && (f || *r != ' ')) { if (*r == '\"') f = 1 - f; @@ -1382,11 +1394,11 @@ ns_attach_by_URL(char *url, char *hop, _ns_efuns ** ef, int *err, void *xd) goto fail; } else { char *loc[] = { - "/usr/local/etc/screenrc", /* official */ - "/etc/screenrc", /* actual (on SuSE) */ - "/usr/etc/screenrc", - "/opt/etc/screenrc", - "/etc/screen/screenrc" + "/usr/local/etc/screenrc", /* official */ + "/etc/screenrc", /* actual (on SuSE) */ + "/usr/etc/screenrc", + "/opt/etc/screenrc", + "/etc/screen/screenrc" }; 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)) { 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")); } @@ -1559,12 +1572,12 @@ ns_tog_disp(_ns_sess * s) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - return ns_screen_command(s, "\x01\x01"); - break; + case NS_MODE_SCREEN: + return ns_screen_command(s, "\x01\x01"); + break; #endif - default: - return NS_FAIL; + default: + return NS_FAIL; } } @@ -1581,28 +1594,28 @@ ns_go2_disp(_ns_sess * s, int d) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - b[1] = '0' + d; - return ns_screen_command(s, b); - break; + case NS_MODE_SCREEN: + b[1] = '0' + d; + return ns_screen_command(s, b); + break; #endif #ifdef NS_HAVE_TWIN - case NS_MODE_TWIN: - { - tscreen ts = Tw_FirstScreen(s->twin); + case NS_MODE_TWIN: + { + tscreen ts = Tw_FirstScreen(s->twin); - printf("screen: %p\n", ts); - while (d-- && ts) - ts = Tw_NextObj(s->twin, ts); - if (ts) { - Tw_RaiseScreen(s->twin, ts); - return NS_SUCC; - } - } - break; + printf("screen: %p\n", ts); + while (d-- && ts) + ts = Tw_NextObj(s->twin, ts); + if (ts) { + Tw_RaiseScreen(s->twin, ts); + return NS_SUCC; + } + } + break; #endif - default: - return NS_FAIL; + default: + return NS_FAIL; } } @@ -1617,13 +1630,13 @@ ns_mon_disp(_ns_sess * s, int no, int quiet) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - if (no >= 0) - ns_go2_disp(s, no); - if (quiet == NS_MON_TOGGLE_QUIET) - s->flags |= NS_SESS_NO_MON_MSG; - return ns_screen_command(s, "\x01M"); - break; + case NS_MODE_SCREEN: + if (no >= 0) + ns_go2_disp(s, no); + if (quiet == NS_MON_TOGGLE_QUIET) + s->flags |= NS_SESS_NO_MON_MSG; + return ns_screen_command(s, "\x01M"); + break; #endif } return NS_FAIL; @@ -1638,13 +1651,13 @@ ns_sbb_disp(_ns_sess * s, int no) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - ns_go2_disp(s, no); - return ns_screen_command(s, "\x01\x1b"); - break; + case NS_MODE_SCREEN: + ns_go2_disp(s, no); + return ns_screen_command(s, "\x01\x1b"); + break; #endif - default: - return NS_FAIL; + default: + return NS_FAIL; } } @@ -1705,21 +1718,21 @@ ns_add_disp(_ns_sess * s, int after, char *name) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - if (after >= 0) - ns_go2_disp(s, after); - if (ns_screen_command(s, "\x01\x03") == NS_SUCC) { - if (!name || strlen(name)) - ns_ren_disp(s, -2, name); - ret = ns_mon_disp(s, -2, NS_MON_TOGGLE_QUIET); - } - break; + case NS_MODE_SCREEN: + if (after >= 0) + ns_go2_disp(s, after); + if (ns_screen_command(s, "\x01\x03") == NS_SUCC) { + if (!name || strlen(name)) + ns_ren_disp(s, -2, name); + ret = ns_mon_disp(s, -2, NS_MON_TOGGLE_QUIET); + } + break; #endif #ifdef NS_HAVE_TWIN - case NS_MODE_TWIN: - ret = ns_twin_control(s, "twin", TW_MSG_CONTROL_OPEN); - printf("ns_add_disp: twin add window after %d -> %d\n", after, ret); - break; + case NS_MODE_TWIN: + ret = ns_twin_control(s, "twin", TW_MSG_CONTROL_OPEN); + printf("ns_add_disp: twin add window after %d -> %d\n", after, ret); + break; #endif } return ret; @@ -1754,10 +1767,10 @@ ns_mov_disp(_ns_sess * s, int fm, int to) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - D_ESCREEN(("ns_mov_disp: move #%d to #%d\n", fm, to)); - ns_mov_screen_disp(s, fm, to); - break; + case NS_MODE_SCREEN: + D_ESCREEN(("ns_mov_disp: move #%d to #%d\n", fm, to)); + ns_mov_screen_disp(s, fm, to); + break; #endif } return NS_FAIL; @@ -1776,8 +1789,8 @@ ns_rsz_disp(_ns_sess * s, int d, int w, int h) } switch (s->backend) { - default: - return NS_FAIL; + default: + return NS_FAIL; } } @@ -1810,10 +1823,10 @@ ns_rem_disp(_ns_sess * s, int d, int ask) if (*i == 'y' || *i == 'Y') { switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - ns_go2_disp(s, d); - ret = ns_screen_command(s, "\x01ky\r"); - break; + case NS_MODE_SCREEN: + ns_go2_disp(s, d); + ret = ns_screen_command(s, "\x01ky\r"); + break; #endif } } @@ -1866,17 +1879,17 @@ ns_ren_disp(_ns_sess * s, int d, char *name) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - if ((n = MALLOC(strlen(i ? i : name) + l + 1))) { - if (d >= 0) - ns_go2_disp(s, d); - strcpy(&n[l], i ? i : name); /* copy new name */ - while (l) /* prepend backspaces */ - n[--l] = '\x08'; - ret = ns_screen_xcommand(s, 'A', n); /* rename */ - FREE(n); - } - break; + case NS_MODE_SCREEN: + if ((n = MALLOC(strlen(i ? i : name) + l + 1))) { + if (d >= 0) + ns_go2_disp(s, d); + strcpy(&n[l], i ? i : name); /* copy new name */ + while (l) /* prepend backspaces */ + n[--l] = '\x08'; + ret = ns_screen_xcommand(s, 'A', n); /* rename */ + FREE(n); + } + break; #endif } @@ -1895,8 +1908,8 @@ ns_log_disp(_ns_sess * s, int d, char *logfile) } switch (s->backend) { - default: - return NS_FAIL; + default: + return NS_FAIL; } } @@ -1935,13 +1948,13 @@ ns_rel_region(_ns_sess * s, _ns_disp * d, int n) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - if (n < 0) - return NS_FAIL; - do { - ret = ns_screen_command(s, "\x01\x09"); - } while (--n && (ret == NS_SUCC)); - break; + case NS_MODE_SCREEN: + if (n < 0) + return NS_FAIL; + do { + ret = ns_screen_command(s, "\x01\x09"); + } while (--n && (ret == NS_SUCC)); + break; #endif } return ret; @@ -1962,9 +1975,9 @@ ns_add_region(_ns_sess * s, _ns_disp * d, int after, char *name) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - ret = ns_screen_command(s, "\x01S"); - break; + case NS_MODE_SCREEN: + ret = ns_screen_command(s, "\x01S"); + break; #endif } return ret; @@ -1995,9 +2008,9 @@ ns_rem_region(_ns_sess * s, _ns_disp * d, int r, int ask) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - ret = ns_screen_command(s, "\x01X"); - break; + case NS_MODE_SCREEN: + ret = ns_screen_command(s, "\x01X"); + break; #endif } return ret; @@ -2017,9 +2030,9 @@ ns_one_region(_ns_sess * s, _ns_disp * d, int r) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - ret = ns_screen_command(s, "\x01Q"); - break; + case NS_MODE_SCREEN: + ret = ns_screen_command(s, "\x01Q"); + break; #endif } return ret; @@ -2109,11 +2122,11 @@ ns_upd_stat(_ns_sess * s) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - return ns_screen_command(s, NS_SCREEN_UPDATE); + case NS_MODE_SCREEN: + return ns_screen_command(s, NS_SCREEN_UPDATE); #endif - default: - return NS_FAIL; + default: + return NS_FAIL; } } @@ -2144,20 +2157,20 @@ ns_statement(_ns_sess * s, char *c) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - if ((ret = ns_parse_screen_cmd(s, i ? i : c, NS_ESC_INTERACTIVE)) == NS_SUCC) { - if (s->escape != x) { - y = s->escape; - s->escape = x; - } - ret = ns_screen_xcommand(s, NS_SCREEN_CMD, i ? i : c); - s->escape = y; - } else if (ret == NS_NOT_ALLOWED) { - ns_inp_dial(s, "Sorry, David, I cannot allow that.", 0, NULL, NULL); - } + case NS_MODE_SCREEN: + if ((ret = ns_parse_screen_cmd(s, i ? i : c, NS_ESC_INTERACTIVE)) == NS_SUCC) { + if (s->escape != x) { + y = s->escape; + s->escape = x; + } + ret = ns_screen_xcommand(s, NS_SCREEN_CMD, i ? i : c); + s->escape = y; + } else if (ret == NS_NOT_ALLOWED) { + ns_inp_dial(s, "Sorry, David, I cannot allow that.", 0, NULL, NULL); + } #endif - default: - ret = NS_FAIL; + default: + ret = NS_FAIL; } if (i) @@ -2177,11 +2190,11 @@ ns_reset(_ns_sess * s, int type) switch (s->backend) { #ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - return ns_screen_command(s, NS_SCREEN_INIT); + case NS_MODE_SCREEN: + return ns_screen_command(s, NS_SCREEN_INIT); #endif - default: - return NS_FAIL; + default: + return NS_FAIL; } } @@ -2199,8 +2212,8 @@ ns_get_url(_ns_sess * s, int d) 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) + - 1; + 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) + 1; if ((u = MALLOC(l + 1))) { if (!s->escape) { @@ -2219,8 +2232,9 @@ ns_get_url(_ns_sess * s, int d) lit[0] = s->literal; 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 : ""), - ((s->escape) ? "+-e" : ""), esc, ((s->escape) ? lit : ""), ((s->name) ? "+-x+" : ""), ((s->name) ? s->name : "")); + 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 : ""), ((s->escape) ? "+-e" : ""), esc, ((s->escape) ? lit : ""), + ((s->name) ? "+-x+" : ""), ((s->name) ? s->name : "")); D_ESCREEN(("ns_get_url: URL is %s\n", u)); if ((r >= 0) && (r < l)) { 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)); switch (c) { - case NS_SCREEN_CMD: /* send command (statement) to screen server */ - ns_statement(s, NULL); - break; - case NS_SCREEN_RENAME: /* rename current display */ - ret = ns_ren_disp(s, -1, NULL); - break; - case NS_SCREEN_KILL: - ret = ns_rem_disp(s, -1, TRUE); - break; - default: - ret = ns_screen_command(s, b); + case NS_SCREEN_CMD: /* send command (statement) to screen server */ + ns_statement(s, NULL); + break; + case NS_SCREEN_RENAME: /* rename current display */ + ret = ns_ren_disp(s, -1, NULL); + break; + case NS_SCREEN_KILL: + ret = ns_rem_disp(s, -1, TRUE); + break; + default: + ret = ns_screen_command(s, b); } return ret; @@ -2853,7 +2867,8 @@ ns_screen_weird(_ns_sess * screen, long type, char *doc) "send the result of 'screen --version' to \n" "(together with your ~/.screenrc and /etc/screenrc if present).\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); return NS_FAIL; @@ -3033,7 +3048,8 @@ ns_parse_screen_msg(_ns_sess * screen, char *p) else if (!strcmp("am", vtype)) screen->backend = NS_MODE_SCREAM; 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)) p = "debug info was not compiled into \"screen\"..."; 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); size_t status_blanks = 0; /* status-bar overflow? */ int ret = NS_SUCC, tmp, parsed, /* no of *visible* elements in status line */ - n, /* screen's index (immutable, sparse) */ - r; /* real index (r'th element) */ + n, /* screen's index (immutable, sparse) */ + r; /* real index (r'th element) */ _ns_efuns *efuns; _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 == ' ') { status_blanks++; *(p2--) = '\0'; - } /* p2 now points behind last item */ + } /* p2 now points behind last item */ } 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)); diff --git a/src/menus.c b/src/menus.c index 5db6e5f..007ecf3 100644 --- a/src/menus.c +++ b/src/menus.c @@ -71,24 +71,25 @@ grab_pointer(Window win) D_EVENTS(("Grabbing control of pointer for window 0x%08x.\n", win)); success = XGrabPointer(Xdisplay, win, False, - EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask - | Button1MotionMask | Button2MotionMask | Button3MotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); + EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ButtonPressMask | + ButtonReleaseMask | Button1MotionMask | Button2MotionMask | Button3MotionMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime); if (success != GrabSuccess) { switch (success) { - case GrabNotViewable: - D_MENU((" -> Unable to grab pointer -- Grab window is not viewable.\n")); - break; - case AlreadyGrabbed: - D_MENU((" -> Unable to grab pointer -- Pointer is already grabbed by another client.\n")); - break; - case GrabFrozen: - D_MENU((" -> Unable to grab pointer -- Pointer is frozen by another grab.\n")); - break; - case GrabInvalidTime: - D_MENU((" -> Unable to grab pointer -- Invalid grab time.\n")); - break; - default: - break; + case GrabNotViewable: + D_MENU((" -> Unable to grab pointer -- Grab window is not viewable.\n")); + break; + case AlreadyGrabbed: + D_MENU((" -> Unable to grab pointer -- Pointer is already grabbed by another client.\n")); + break; + case GrabFrozen: + D_MENU((" -> Unable to grab pointer -- Pointer is frozen by another grab.\n")); + break; + case GrabInvalidTime: + D_MENU((" -> Unable to grab pointer -- Invalid grab time.\n")); + break; + default: + break; } } } @@ -259,10 +260,12 @@ menu_handle_button_press(event_t *ev) ungrab_pointer(); menu_reset_all(menu_list); 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); 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; 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); @@ -292,7 +295,8 @@ menu_handle_button_release(event_t *ev) if (current_menu && (current_menu->state & MENU_STATE_IS_DRAGGING)) { /* 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(); 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 { /* 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) && (ev->xbutton.y < current_menu->h)) { /* 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 */ ungrab_pointer(); /* Reset the state of the menu system. */ @@ -468,12 +474,16 @@ menu_t *menu_create(char *title) MEMSET(menu, 0, sizeof(menu_t)); 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); XSelectInput(Xdisplay, menu->win, mask); 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); menuitem_clear_current(menu); @@ -669,14 +679,16 @@ menuitem_change_current(menuitem_t *item) current = menuitem_get_current(current_menu); 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) { /* Reset the current item */ 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 no current item at all, reset the tree for the current submenu */ 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)) || (!item)) { menu_reset_tree(current->action.submenu); @@ -767,25 +779,25 @@ menuitem_set_action(menuitem_t *item, unsigned char type, char *action) item->type = type; switch (type) { - case MENUITEM_SUBMENU: - item->action.submenu = find_menu_by_title(menu_list, action); - break; - case MENUITEM_SCRIPT: - item->action.script = STRDUP(action); - break; - case MENUITEM_ALERT: - item->action.alert = STRDUP(action); - break; - case MENUITEM_STRING: - case MENUITEM_ECHO: - case MENUITEM_LITERAL: - item->action.string = (char *) MALLOC(strlen(action) + 2); - strcpy(item->action.string, action); - if (type != MENUITEM_LITERAL) - parse_escaped_string(item->action.string); - break; - default: - break; + case MENUITEM_SUBMENU: + item->action.submenu = find_menu_by_title(menu_list, action); + break; + case MENUITEM_SCRIPT: + item->action.script = STRDUP(action); + break; + case MENUITEM_ALERT: + item->action.alert = STRDUP(action); + break; + case MENUITEM_STRING: + case MENUITEM_ECHO: + case MENUITEM_LITERAL: + item->action.string = (char *) MALLOC(strlen(action) + 2); + strcpy(item->action.string, action); + if (type != MENUITEM_LITERAL) + parse_escaped_string(item->action.string); + break; + default: + break; } return 1; } @@ -889,7 +901,8 @@ menuitem_select(menu_t *menu) item = menuitem_get_current(menu); 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; XMoveWindow(Xdisplay, menu->swin, item->x, item->y); XMapWindow(Xdisplay, menu->swin); @@ -899,7 +912,8 @@ menuitem_select(menu_t *menu) enl_ipc_sync(); } 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_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 { 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); draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len); 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); } @@ -943,7 +958,8 @@ menu_display_submenu(menu_t *menu, menuitem_t *item) REQUIRE(item->action.submenu != NULL); 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); /* 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); menu->bg = images[image_menu].norm->pmap->pixmap; 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)); XMapWindow(Xdisplay, menu->win); @@ -1099,8 +1116,10 @@ menu_draw(menu_t *menu) str_y = menu->fheight + MENU_VGAP; len = strlen(menu->title); 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_shadow(menu->bg, topShadowGC, botShadowGC, str_x, str_y - chars.descent - MENU_VGAP / 2 + 1, menu->w - (4 * MENU_HGAP), MENU_VGAP, 2); + 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_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; for (i = 0; i < menu->numitems; i++) { @@ -1114,9 +1133,11 @@ menu_draw(menu_t *menu) item->y = str_y - 2 * MENU_VGAP; item->w = menu->w - MENU_HGAP; 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 { 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->w = menu->w - MENU_HGAP; 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) { - case MENUITEM_SUBMENU: - 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); - } else { - 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, DRAW_ARROW_RIGHT); - } - break; - default: - break; + case MENUITEM_SUBMENU: + 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); + } else { + 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, + DRAW_ARROW_RIGHT); + } + break; + default: + break; } draw_string(menu->bg, menu->gc, str_x, str_y - MENU_VGAP / 2, item->text, item->len); 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)); switch (item->type) { - case MENUITEM_SEP: - D_MENU(("Internal Program Error: menu_action() called for a separator.\n")); - break; - case MENUITEM_SUBMENU: - D_MENU(("Internal Program Error: menu_action() called for a submenu.\n")); - break; - case MENUITEM_STRING: - cmd_write((unsigned char *) item->action.string, strlen(item->action.string)); - break; - case MENUITEM_ECHO: - case MENUITEM_LITERAL: + case MENUITEM_SEP: + D_MENU(("Internal Program Error: menu_action() called for a separator.\n")); + break; + case MENUITEM_SUBMENU: + D_MENU(("Internal Program Error: menu_action() called for a submenu.\n")); + break; + case MENUITEM_STRING: + cmd_write((unsigned char *) item->action.string, strlen(item->action.string)); + break; + case MENUITEM_ECHO: + case MENUITEM_LITERAL: #ifdef ESCREEN - if (TermWin.screen && TermWin.screen->backend) { - /* translate escapes */ - switch (TermWin.screen->backend) { + if (TermWin.screen && TermWin.screen->backend) { + /* translate escapes */ + switch (TermWin.screen->backend) { # ifdef NS_HAVE_SCREEN - case NS_MODE_SCREEN: - if (item->type == MENUITEM_ECHO) { - ns_parse_screen_interactive(TermWin.screen, item->action.string); - } else { - ns_screen_command(TermWin.screen, item->action.string); - } - break; + case NS_MODE_SCREEN: + if (item->type == MENUITEM_ECHO) { + ns_parse_screen_interactive(TermWin.screen, item->action.string); + } else { + ns_screen_command(TermWin.screen, item->action.string); + } + break; # endif - default: - tt_write((unsigned char *) item->action.string, strlen(item->action.string)); - } - } else + default: + tt_write((unsigned char *) item->action.string, strlen(item->action.string)); + } + } else #endif - tt_write((unsigned char *) item->action.string, strlen(item->action.string)); - break; - case MENUITEM_SCRIPT: - script_parse((char *) item->action.script); - break; - case MENUITEM_ALERT: - menu_dialog(NULL, item->action.alert, 0, NULL, NULL); - break; - default: - fatal_error("Internal Program Error: Unknown menuitem type: %u\n", item->type); - break; + tt_write((unsigned char *) item->action.string, strlen(item->action.string)); + break; + case MENUITEM_SCRIPT: + script_parse((char *) item->action.script); + break; + case MENUITEM_ALERT: + menu_dialog(NULL, item->action.alert, 0, NULL, NULL); + break; + default: + fatal_error("Internal Program Error: Unknown menuitem type: %u\n", item->type); + 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"); 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(); @@ -1379,7 +1405,7 @@ menu_dialog(void *xd, char *prompt, int maxlen, char **retstr, int (*inp_tab) (v for (;;) { ret = XNextEvent(Xdisplay, &ev); 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. */ if (ev.type == KeyPress) { break; diff --git a/src/misc.c b/src/misc.c index 577fd73..ffcb8d7 100644 --- a/src/misc.c +++ b/src/misc.c @@ -143,64 +143,64 @@ parse_escaped_string(char *str) } D_STRINGS(("Operating on \'%c\'\n", *pold)); switch (*pold) { - case '\\': - D_STRINGS(("Backslash + %c\n", *(pold + 1))); - switch (tolower(*(++pold))) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - for (i = 0; *pold >= '0' && *pold <= '7'; pold++) { - i = (i * 8) + (*pold - '0'); - } - pold--; - D_STRINGS(("Octal number evaluates to %d\n", i)); - *pnew = i; - break; - case 'n': - *pnew = '\n'; - break; - case 'r': - *pnew = '\r'; - break; - case 't': - *pnew = '\t'; - break; - case 'b': - *pnew = '\b'; - break; - case 'f': - *pnew = '\f'; - break; - case 'a': - *pnew = '\a'; - break; - case 'v': - *pnew = '\v'; - break; - case 'e': - *pnew = '\033'; - break; - case 'c': - pold++; - *pnew = MAKE_CTRL_CHAR(*pold); - break; - default: - *pnew = *pold; - break; - } - break; - case '^': - D_STRINGS(("Caret + %c\n", *(pold + 1))); - pold++; - *pnew = MAKE_CTRL_CHAR(*pold); - break; - default: - *pnew = *pold; + case '\\': + D_STRINGS(("Backslash + %c\n", *(pold + 1))); + switch (tolower(*(++pold))) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + for (i = 0; *pold >= '0' && *pold <= '7'; pold++) { + i = (i * 8) + (*pold - '0'); + } + pold--; + D_STRINGS(("Octal number evaluates to %d\n", i)); + *pnew = i; + break; + case 'n': + *pnew = '\n'; + break; + case 'r': + *pnew = '\r'; + break; + case 't': + *pnew = '\t'; + break; + case 'b': + *pnew = '\b'; + break; + case 'f': + *pnew = '\f'; + break; + case 'a': + *pnew = '\a'; + break; + case 'v': + *pnew = '\v'; + break; + case 'e': + *pnew = '\033'; + break; + case 'c': + pold++; + *pnew = MAKE_CTRL_CHAR(*pold); + break; + default: + *pnew = *pold; + break; + } + break; + case '^': + D_STRINGS(("Caret + %c\n", *(pold + 1))); + pold++; + *pnew = MAKE_CTRL_CHAR(*pold); + break; + default: + *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; D_STRINGS(("escape_string(%s %c %ld)\n", (char *) str, quote, maxlen)); - if (! quote) { + if (!quote) { quote = '\"'; } diff --git a/src/netdisp.c b/src/netdisp.c index 92acc5d..f3ee7fa 100644 --- a/src/netdisp.c +++ b/src/netdisp.c @@ -111,7 +111,8 @@ network_display(const char *display) if (colon == NULL) 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; break; diff --git a/src/options.c b/src/options.c index 4d9d34a..ace6f6b 100644 --- a/src/options.c +++ b/src/options.c @@ -79,12 +79,14 @@ static void *parse_multichar(char *, void *); static void *parse_escreen(char *, void *); static char *rs_pipe_name = NULL; + #ifdef PIXMAP_SUPPORT static int rs_shade = 0; static char *rs_tint = NULL; #endif static unsigned long rs_buttonbars = 1; static char *rs_font_effects = NULL; + #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) static char *rs_bigfont_key = NULL; static char *rs_smallfont_key = NULL; @@ -108,11 +110,13 @@ char *rs_geometry = NULL; /* Geometry string */ int rs_desktop = -1; char *rs_path = NULL; int rs_saveLines = SAVELINES; /* Lines in the scrollback buffer */ + #ifdef USE_XIM char *rs_input_method = NULL; char *rs_preedit_type = NULL; #endif char *rs_name = NULL; + #ifndef NO_BOLDFONT char *rs_boldFont = NULL; #endif @@ -126,6 +130,7 @@ unsigned long rs_scrollbar_width = 0; char *rs_finished_title = NULL; char *rs_finished_text = NULL; char *rs_term_name = NULL; + #ifdef PIXMAP_SUPPORT char *rs_pixmapScale = NULL; char *rs_icon = NULL; @@ -134,6 +139,7 @@ char *rs_cmod_red = NULL; char *rs_cmod_green = NULL; char *rs_cmod_blue = NULL; unsigned long rs_cache_size = (unsigned long) -1; + # ifdef BACKGROUND_CYCLING_SUPPORT char *rs_anim_pixmap_list = NULL; char **rs_anim_pixmaps = NULL; @@ -143,6 +149,7 @@ static char *rs_pixmaps[image_max]; #endif char *rs_theme = NULL; char *rs_config_file = NULL; + #ifdef ESCREEN char *rs_url = NULL; char *rs_hop = NULL; @@ -154,6 +161,7 @@ spif_charptr_t rs_beep_command = NULL; spif_uint32_t rs_opacity = 0xffffffff; unsigned int rs_line_space = 0; unsigned int rs_meta_mod = 0, rs_alt_mod = 0, rs_numlock_mod = 0; + #ifdef KEYSYM_ATTRIBUTE unsigned char *KeySym_map[256]; /* probably mostly empty */ #endif @@ -209,12 +217,12 @@ spifopt_t option_list[] = { #ifndef NO_BOLDUNDERLINE SPIFOPT_STR_LONG("colorBD", "bold color", rs_color[colorBD]), 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]), #ifndef NO_CURSORCOLOR SPIFOPT_STR('c', "cursor-color", "cursor color", rs_color[cursorColor]), SPIFOPT_STR_LONG("cursor-text-color", "cursor text color", rs_color[cursorColor2]), -#endif /* NO_CURSORCOLOR */ +#endif /* NO_CURSORCOLOR */ /* =======[ X11 options ]======= */ 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), # ifdef BACKGROUND_CYCLING_SUPPORT SPIFOPT_STR('N', "anim", "a delay and list of pixmaps for cycling", rs_anim_pixmap_list), -# endif /* BACKGROUND_CYCLING_SUPPORT */ -#endif /* PIXMAP_SUPPORT */ +# endif /* BACKGROUND_CYCLING_SUPPORT */ +#endif /* PIXMAP_SUPPORT */ /* =======[ Kanji options ]======= */ #ifdef MULTI_CHARSET @@ -272,7 +280,7 @@ spifopt_t option_list[] = { SPIFOPT_STR_LONG("mfont3", "multichar font 3", rs_mfont[3]), 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), -#endif /* MULTI_CHARSET */ +#endif /* MULTI_CHARSET */ #ifdef USE_XIM SPIFOPT_STR_LONG("input-method", "XIM input method", rs_input_method), 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('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-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('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("bold-brightens-foreground", "\"bold\" attribute brightens foreground color", vt_options, 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("bold-brightens-foreground", "\"bold\" attribute brightens foreground color", vt_options, + 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), #ifndef NO_MAPALERT # ifdef MAPALERT_OPTION @@ -302,15 +313,18 @@ spifopt_t option_list[] = { #ifdef META8_OPTION SPIFOPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", vt_options, VT_OPTIONS_META8), #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("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("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("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), /* =======[ Keyboard options ]======= */ @@ -338,7 +352,7 @@ spifopt_t option_list[] = { #endif #ifdef CUTCHAR_OPTION 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-text", "post-termination terminal text", rs_finished_text), SPIFOPT_STR_LONG("term-name", "value to use for setting $TERM", rs_term_name), @@ -408,10 +422,7 @@ version(void) " " SCROLLBAR_IDENT "\n" " " STARTUP_IDENT "\n" " " SYSTEM_IDENT "\n" - " " TERM_IDENT "\n" - " " TIMER_IDENT "\n" - " " UTMP_IDENT "\n" - " " WINDOWS_IDENT "\n" "\n"); + " " TERM_IDENT "\n" " " TIMER_IDENT "\n" " " UTMP_IDENT "\n" " " WINDOWS_IDENT "\n" "\n"); printf("Debugging configuration: "); #ifdef DEBUG @@ -947,7 +958,8 @@ parse_color(char *buff, void *state) } else { 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); } } else { @@ -1023,7 +1035,8 @@ parse_attributes(char *buff, void *state) } else { 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); } @@ -1044,7 +1057,8 @@ parse_toggles(char *buff, void *state) return NULL; } 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; } if (BOOL_OPT_ISTRUE(tmp)) { @@ -1631,7 +1645,8 @@ parse_image(char *buff, void *state) return NULL; } 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; } if (!BEG_STRCASECMP(mode, "image")) { @@ -1661,7 +1676,8 @@ parse_image(char *buff, void *state) images[idx].mode |= ALLOW_AUTO; } else if (!BEG_STRCASECMP(allow, "solid")) { } 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; 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(), - file_peek_line()); + print_error("Parse error in file %s, line %lu: Encountered color modifier with no image type defined\n", + file_peek_path(), file_peek_line()); return 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(), - file_peek_line()); + print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined\n", + file_peek_path(), file_peek_line()); return NULL; } 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) && (images[idx].current->iml->border->top == 0) && (images[idx].current->iml->border->bottom == 0)) { FREE(images[idx].current->iml->border); - images[idx].current->iml->border = (Imlib_Border *) NULL; /* No sense in wasting CPU time and memory if there are no borders */ + images[idx].current->iml->border = (Imlib_Border *) NULL; /* No sense in wasting CPU time and memory if there are no borders */ } } else if (!BEG_STRCASECMP(buff, "bevel ")) { if (!CHECK_VALID_INDEX(idx)) { @@ -1944,8 +1960,8 @@ parse_image(char *buff, void *state) return 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(), - file_peek_line()); + print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined\n", + file_peek_path(), file_peek_line()); return NULL; } if (num_words(buff + 8) < 4) { @@ -2024,7 +2040,8 @@ parse_actions(char *buff, void *state) } FREE(str); 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; } i++; @@ -2155,7 +2172,8 @@ parse_menuitem(char *buff, void *state) char *rtext = get_word(2, buff); 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); } menuitem_set_rtext(curitem, rtext); @@ -2220,12 +2238,13 @@ parse_bbar(char *buff, void *state) char *where = get_pword(2, buff); 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")) { bbar_set_docked(bbar, BBAR_DOCKED_TOP); - } else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */ + } else if (!BEG_STRCASECMP(where, "bot")) { /* "bot" or "bottom" */ bbar_set_docked(bbar, BBAR_DOCKED_BOTTOM); - } else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */ + } else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */ bbar_set_docked(bbar, BBAR_UNDOCKED); } else { print_error("Parse error in file %s, line %lu: Invalid parameter \"%s\" to attribute dock\n", file_peek_path(), @@ -2286,7 +2305,8 @@ parse_bbar(char *buff, void *state) } else if (!BEG_STRCASECMP(type, "script ")) { button_set_action(button, ACTION_SCRIPT, action); } 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(button); return ((void *) bbar); @@ -2377,7 +2397,8 @@ parse_multichar(char *buff, void *state) } } else { 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); } @@ -2414,12 +2435,13 @@ parse_escreen(char *buff, void *state) char *where = get_pword(2, buff); 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")) { 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; - } else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */ + } else if (!BEG_STRCASECMP(where, "no")) { /* "no" or "none" */ rs_es_dock = BBAR_UNDOCKED; } else { 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); if (path_env) { - snprintf(path, sizeof(path), "%s:%s", CONFIG_SEARCH_PATH, - path_env); + snprintf(path, sizeof(path), "%s:%s", CONFIG_SEARCH_PATH, path_env); } else { snprintf(path, sizeof(path), CONFIG_SEARCH_PATH); } @@ -2570,8 +2591,7 @@ post_parse(void) #if DEBUG > 0 if (DEBUG_LEVEL > DEBUG) { - print_warning("Requested debug level of %d exceeds compile-time maximum of %d\n", - DEBUG_LEVEL, DEBUG); + print_warning("Requested debug level of %d exceeds compile-time maximum of %d\n", DEBUG_LEVEL, DEBUG); } else if (DEBUG_LEVEL > 0) { DPRINTF1(("Now running with debugging level of %d\n", DEBUG_LEVEL)); } @@ -2736,7 +2756,7 @@ post_parse(void) if (rs_pixmaps[i]) { reset_simage(images[i].norm, RESET_ALL_SIMG); load_image(rs_pixmaps[i], images[i].norm); - FREE(rs_pixmaps[i]); /* These are created by STRDUP() */ + FREE(rs_pixmaps[i]); /* These are created by STRDUP() */ } #else /* Right now, solid mode is the only thing we can do without pixmap support. */ @@ -3024,11 +3044,11 @@ post_parse(void) unsigned long w, h; int count; - count = num_words(rs_anim_pixmap_list) - 1; /* -1 for the delay */ + count = num_words(rs_anim_pixmap_list) - 1; /* -1 for the delay */ rs_anim_pixmaps = (char **) MALLOC(sizeof(char *) * (count + 1)); for (i = 0; i < count; i++) { - temp = get_word(i + 2, rs_anim_pixmap_list); /* +2 rather than +1 to account for the delay */ + temp = get_word(i + 2, rs_anim_pixmap_list); /* +2 rather than +1 to account for the delay */ if (temp == NULL) break; if (num_words(temp) != 3) { @@ -3116,8 +3136,8 @@ save_config(char *path, unsigned char save_theme) *(--tmp) = '/'; } 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"), - path); + print_error("I couldn't write to \"%s\" or \"%s\". I give up.", + (theme_dir ? theme_dir : PKGDATADIR "/themes/Eterm\n"), path); return errno; } } @@ -3146,8 +3166,8 @@ save_config(char *path, unsigned char save_theme) *(--tmp) = '/'; } 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"), - path); + print_error("I couldn't write to \"%s\" or \"%s\". I give up.", + (user_dir ? user_dir : PKGDATADIR "/themes/Eterm\n"), path); return errno; } } @@ -3263,69 +3283,69 @@ save_config(char *path, unsigned char save_theme) for (i = 0; i < image_max; i++) { fprintf(fp, " begin image\n"); switch (i) { - case image_bg: - fprintf(fp, " type background\n"); - break; - case image_sb: - fprintf(fp, " type trough\n"); - break; - case image_sa: - fprintf(fp, " type anchor\n"); - break; - case image_st: - fprintf(fp, " type thumb\n"); - break; - case image_up: - fprintf(fp, " type up_arrow\n"); - break; - case image_down: - fprintf(fp, " type down_arrow\n"); - break; - case image_left: - fprintf(fp, " type left_arrow\n"); - break; - case image_right: - fprintf(fp, " type right_arrow\n"); - break; - case image_menu: - fprintf(fp, " type menu\n"); - break; - case image_menuitem: - fprintf(fp, " type menuitem\n"); - break; - case image_submenu: - fprintf(fp, " type submenu\n"); - break; - case image_button: - fprintf(fp, " type button\n"); - break; - case image_bbar: - fprintf(fp, " type button_bar\n"); - break; - case image_gbar: - fprintf(fp, " type grab_bar\n"); - break; - case image_dialog: - fprintf(fp, " type dialog_box\n"); - break; + case image_bg: + fprintf(fp, " type background\n"); + break; + case image_sb: + fprintf(fp, " type trough\n"); + break; + case image_sa: + fprintf(fp, " type anchor\n"); + break; + case image_st: + fprintf(fp, " type thumb\n"); + break; + case image_up: + fprintf(fp, " type up_arrow\n"); + break; + case image_down: + fprintf(fp, " type down_arrow\n"); + break; + case image_left: + fprintf(fp, " type left_arrow\n"); + break; + case image_right: + fprintf(fp, " type right_arrow\n"); + break; + case image_menu: + fprintf(fp, " type menu\n"); + break; + case image_menuitem: + fprintf(fp, " type menuitem\n"); + break; + case image_submenu: + fprintf(fp, " type submenu\n"); + break; + case image_button: + fprintf(fp, " type button\n"); + break; + case image_bbar: + fprintf(fp, " type button_bar\n"); + break; + case image_gbar: + fprintf(fp, " type grab_bar\n"); + break; + case image_dialog: + fprintf(fp, " type dialog_box\n"); + break; } fprintf(fp, " mode "); switch (images[i].mode & MODE_MASK) { - case MODE_IMAGE: - fprintf(fp, "image"); - break; - case MODE_TRANS: - fprintf(fp, "trans"); - break; - case MODE_VIEWPORT: - fprintf(fp, "viewport"); - break; - case MODE_AUTO: - fprintf(fp, "auto"); - break; - default: - fprintf(fp, "solid"); - break; + case MODE_IMAGE: + fprintf(fp, "image"); + break; + case MODE_TRANS: + fprintf(fp, "trans"); + break; + case MODE_VIEWPORT: + fprintf(fp, "viewport"); + break; + case MODE_AUTO: + fprintf(fp, "auto"); + break; + default: + fprintf(fp, "solid"); + break; } if (images[i].mode & ALLOW_MASK) { fprintf(fp, " allow"); @@ -3392,12 +3412,13 @@ save_config(char *path, unsigned char save_theme) } #endif if (simg->iml->border) { - fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, - simg->iml->border->bottom); + fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, + simg->iml->border->top, simg->iml->border->bottom); } if (simg->iml->bevel) { - fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, - simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); + fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), + simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, + simg->iml->bevel->edges->bottom); } if (simg->iml->pad) { 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); } if (simg->iml->gmod) { - fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, - simg->iml->gmod->gamma); + fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, + simg->iml->gmod->contrast, simg->iml->gmod->gamma); } if (simg->iml->bmod) { - fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, - simg->iml->bmod->gamma); + fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, + simg->iml->bmod->contrast, simg->iml->bmod->gamma); } #endif if (simg->iml->border) { - fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, - simg->iml->border->bottom); + fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, + simg->iml->border->top, simg->iml->border->bottom); } if (simg->iml->bevel) { - fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, - simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); + fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), + simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, + simg->iml->bevel->edges->bottom); } if (simg->iml->pad) { 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); } if (simg->iml->gmod) { - fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, - simg->iml->gmod->gamma); + fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, + simg->iml->gmod->contrast, simg->iml->gmod->gamma); } if (simg->iml->bmod) { - fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, - simg->iml->bmod->gamma); + fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, + simg->iml->bmod->contrast, simg->iml->bmod->gamma); } #endif if (simg->iml->border) { - fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, - simg->iml->border->bottom); + fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, + simg->iml->border->top, simg->iml->border->bottom); } if (simg->iml->bevel) { - fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, - simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); + fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), + simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, + simg->iml->bevel->edges->bottom); } if (simg->iml->pad) { 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); } if (simg->iml->gmod) { - fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, - simg->iml->gmod->gamma); + fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, + simg->iml->gmod->contrast, simg->iml->gmod->gamma); } if (simg->iml->bmod) { - fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, - simg->iml->bmod->gamma); + fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, + simg->iml->bmod->contrast, simg->iml->bmod->gamma); } #endif if (simg->iml->border) { - fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, - simg->iml->border->bottom); + fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, + simg->iml->border->top, simg->iml->border->bottom); } if (simg->iml->bevel) { - fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, - simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom); + fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), + simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, + simg->iml->bevel->edges->bottom); } if (simg->iml->pad) { 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, " border_width %d\n", TermWin.internalBorder); fprintf(fp, " term_name %s\n", getenv("TERM")); - fprintf(fp, " beep_command \"%s\"\n", SPIF_CAST_PTR(char) ( - (rs_beep_command) + fprintf(fp, " beep_command \"%s\"\n", SPIF_CAST_PTR(char) ((rs_beep_command) ? (SPIF_CAST_PTR(char) rs_beep_command) : (SPIF_CAST_PTR(char) "") - )); + )); + fprintf(fp, " debug %d\n", DEBUG_LEVEL); if (save_theme && rs_exec_args && rs_theme && strcmp(rs_theme, PACKAGE)) { fprintf(fp, " exec "); diff --git a/src/pixmap.c b/src/pixmap.c index a7b785f..e0cb16b 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -95,55 +95,55 @@ const char * get_image_type(unsigned char type) { switch (type) { - case image_bg: - return "image_bg"; - break; - case image_up: - return "image_up"; - break; - case image_down: - return "image_down"; - break; - case image_left: - return "image_left"; - break; - case image_right: - return "image_right"; - break; - case image_sb: - return "image_sb"; - break; - case image_sa: - return "image_sa"; - break; - case image_st: - return "image_st"; - break; - case image_menu: - return "image_menu"; - break; - case image_menuitem: - return "image_menuitem"; - break; - case image_submenu: - return "image_submenu"; - break; - case image_button: - return "image_button"; - break; - case image_bbar: - return "image_bbar"; - break; - case image_gbar: - return "image_gbar"; - break; - case image_dialog: - return "image_dialog"; - break; - case image_max: - default: - return "image_max"; - break; + case image_bg: + return "image_bg"; + break; + case image_up: + return "image_up"; + break; + case image_down: + return "image_down"; + break; + case image_left: + return "image_left"; + break; + case image_right: + return "image_right"; + break; + case image_sb: + return "image_sb"; + break; + case image_sa: + return "image_sa"; + break; + case image_st: + return "image_st"; + break; + case image_menu: + return "image_menu"; + break; + case image_menuitem: + return "image_menuitem"; + break; + case image_submenu: + return "image_submenu"; + break; + case image_button: + return "image_button"; + break; + case image_bbar: + return "image_bbar"; + break; + case image_gbar: + return "image_gbar"; + break; + case image_dialog: + return "image_dialog"; + break; + case image_max: + default: + return "image_max"; + break; } ASSERT_NOTREACHED_RVAL(""); } @@ -162,52 +162,52 @@ const char * imlib_strerror(Imlib_Load_Error err) { switch (err) { - case IMLIB_LOAD_ERROR_NONE: - return "Success"; - break; - case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: - return "No such file or directory"; - break; - case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: - return "Is a directory"; - break; - case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: - return "Permission denied"; - break; - case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT: - return "No loader available for that file format"; - break; - case IMLIB_LOAD_ERROR_PATH_TOO_LONG: - return "Path too long"; - break; - case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT: - return "Path component does not exist"; - break; - case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY: - return "Path component is not a directory"; - break; - case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE: - return "Path points outside address space"; - break; - case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS: - return "Too many symbolic links in path"; - break; - case IMLIB_LOAD_ERROR_OUT_OF_MEMORY: - return "Out of memory"; - break; - case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS: - return "No more file descriptors"; - break; - case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE: - return "Permission denied"; - break; - case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: - return "Disk full"; - break; - case IMLIB_LOAD_ERROR_UNKNOWN: - default: - return "Unknown error"; - break; + case IMLIB_LOAD_ERROR_NONE: + return "Success"; + break; + case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: + return "No such file or directory"; + break; + case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: + return "Is a directory"; + break; + case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: + return "Permission denied"; + break; + case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT: + return "No loader available for that file format"; + break; + case IMLIB_LOAD_ERROR_PATH_TOO_LONG: + return "Path too long"; + break; + case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT: + return "Path component does not exist"; + break; + case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY: + return "Path component is not a directory"; + break; + case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE: + return "Path points outside address space"; + break; + case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS: + return "Too many symbolic links in path"; + break; + case IMLIB_LOAD_ERROR_OUT_OF_MEMORY: + return "Out of memory"; + break; + case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS: + return "No more file descriptors"; + break; + case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE: + return "Permission denied"; + break; + case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: + return "Disk full"; + break; + case IMLIB_LOAD_ERROR_UNKNOWN: + default: + return "Unknown error"; + break; } ASSERT_NOTREACHED_RVAL(""); } @@ -334,7 +334,8 @@ set_pixmap_scale(const char *geom, pixmap_t *pmap) pmap->op = op; 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; } @@ -538,54 +539,54 @@ static const char * get_iclass_name(unsigned char which) { switch (which) { - case image_bg: - return "ETERM_BG"; - break; - case image_up: - return "ETERM_ARROW_UP"; - break; - case image_down: - return "ETERM_ARROW_DOWN"; - break; - case image_left: - return "ETERM_ARROW_LEFT"; - break; - case image_right: - return "ETERM_ARROW_RIGHT"; - break; - case image_sb: - return "ETERM_TROUGH"; - break; - case image_sa: - return "ETERM_ANCHOR"; - break; - case image_st: - return "ETERM_THUMB"; - break; - case image_menu: - return "ETERM_MENU_ITEM"; - break; /* FIXME: This should be ETERM_MENU_BOX */ - case image_menuitem: - return "ETERM_MENU_ITEM"; - break; - case image_submenu: - return "ETERM_MENU_SUBMENU"; - break; - case image_button: - return "ETERM_MENU_ITEM"; - break; /* FIXME: These four should */ - case image_bbar: - return "ETERM_MENU_BOX"; - break; /* have their own image classes */ - case image_gbar: - return "ETERM_ANCHOR"; - break; - case image_dialog: - return "ETERM_MENU_BOX"; - break; - default: - ASSERT_NOTREACHED_RVAL(NULL); - break; + case image_bg: + return "ETERM_BG"; + break; + case image_up: + return "ETERM_ARROW_UP"; + break; + case image_down: + return "ETERM_ARROW_DOWN"; + break; + case image_left: + return "ETERM_ARROW_LEFT"; + break; + case image_right: + return "ETERM_ARROW_RIGHT"; + break; + case image_sb: + return "ETERM_TROUGH"; + break; + case image_sa: + return "ETERM_ANCHOR"; + break; + case image_st: + return "ETERM_THUMB"; + break; + case image_menu: + return "ETERM_MENU_ITEM"; + break; /* FIXME: This should be ETERM_MENU_BOX */ + case image_menuitem: + return "ETERM_MENU_ITEM"; + break; + case image_submenu: + return "ETERM_MENU_SUBMENU"; + break; + case image_button: + return "ETERM_MENU_ITEM"; + break; /* FIXME: These four should */ + case image_bbar: + return "ETERM_MENU_BOX"; + break; /* have their own image classes */ + case image_gbar: + return "ETERM_ANCHOR"; + break; + case image_dialog: + return "ETERM_MENU_BOX"; + break; + default: + ASSERT_NOTREACHED_RVAL(NULL); + break; } } @@ -628,7 +629,8 @@ check_image_ipc(unsigned char reset) } ); /* *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); checked = 2; 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); 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 (pw < scr->width || ph < scr->height) { 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); XFillRectangle(Xdisplay, p, gc, 0, 0, width, height); } 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); } - 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)) { 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 -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; GC gc; 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(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); reply = enl_send_and_wait(buff); 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); FREE(reply); } else { @@ -832,7 +840,8 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign LIBAST_X_FREE_GC(gc); return; } 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); image_mode_fallback(which); } @@ -905,31 +914,31 @@ redraw_image(unsigned char which) { switch (which) { - case image_bg: - render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); - scr_touch(); - break; - case image_up: - scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, MODE_MASK); - break; - case image_down: - scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, MODE_MASK); - break; - case image_sb: - scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK); - break; - case image_sa: - case image_st: - scrollbar_draw_anchor(IMAGE_STATE_CURRENT, MODE_MASK); - break; - case image_button: - case image_bbar: - case image_gbar: - bbar_draw_all(IMAGE_STATE_CURRENT, MODE_MASK); - break; - default: - D_PIXMAP(("Bad value %u\n", which)); - break; + case image_bg: + render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); + scr_touch(); + break; + case image_up: + scrollbar_draw_uparrow(IMAGE_STATE_CURRENT, MODE_MASK); + break; + case image_down: + scrollbar_draw_downarrow(IMAGE_STATE_CURRENT, MODE_MASK); + break; + case image_sb: + scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK); + break; + case image_sa: + case image_st: + scrollbar_draw_anchor(IMAGE_STATE_CURRENT, MODE_MASK); + break; + case image_button: + case image_bbar: + case image_gbar: + bbar_draw_all(IMAGE_STATE_CURRENT, MODE_MASK); + break; + default: + D_PIXMAP(("Bad value %u\n", which)); + break; } } @@ -998,7 +1007,8 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h ASSERT(simg->iml != NULL); ASSERT(simg->pmap != NULL); 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)); #ifdef PIXMAP_SUPPORT 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); buffer_pixmap = None; } - #ifdef PIXMAP_SUPPORT /* Reset window shape mask. */ 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) { 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); 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); FREE(reply); } 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); enl_ipc_send(buff); } 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); 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)) { 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); if (p && (p != simg->pmap->pixmap)) { 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))); XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); 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 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 */ switch (real_depth) { - case 15: + case 15: #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 - 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 - break; - case 16: + break; + case 16: #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 - 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 - break; - case 24: - if (ximg->bits_per_pixel != 32) { - shade_ximage_24(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); - } - /* drop */ - case 32: + break; + case 24: + if (ximg->bits_per_pixel != 32) { + shade_ximage_24(ximg->data, ximg->bytes_per_line, w, h, rm, gm, bm); + } + /* drop */ + case 32: #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 - 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 - break; - default: - print_warning("Bit depth of %d is unsupported for tinting/shading.\n", real_depth); - return; + break; + default: + print_warning("Bit depth of %d is unsupported for tinting/shading.\n", real_depth); + return; } } 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); } 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; 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(Xdisplay, w, props[PROP_TRANS_COLOR], 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data)) != Success) { + if ((XGetWindowProperty + (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; } } @@ -2020,7 +2039,8 @@ get_desktop_pixmap(void) LIBAST_X_FREE_PIXMAP(color_pixmap); 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) { p = *((Pixmap *) data); XFree(data); @@ -2068,7 +2088,8 @@ get_desktop_pixmap(void) } else { 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) { XGCValues gcvalue; GC gc; @@ -2172,7 +2193,8 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints) if (XGetIconSizes(Xdisplay, Xroot, &icon_sizes, &count)) { 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, - 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) { continue; } diff --git a/src/screen.c b/src/screen.c index e28bbdd..75ea89b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -398,21 +398,21 @@ scr_cursor(int mode) D_SCREEN(("scr_cursor(%s)\n", (mode == SAVE ? "SAVE" : "RESTORE"))); switch (mode) { - case SAVE: - save.row = screen.row; - save.col = screen.col; - save.rstyle = rstyle; - save.charset = screen.charset; - save.charset_char = charsets[screen.charset]; - break; - case RESTORE: - screen.row = save.row; - screen.col = save.col; - rstyle = save.rstyle; - screen.charset = save.charset; - charsets[screen.charset] = save.charset_char; - set_font_style(); - break; + case SAVE: + save.row = screen.row; + save.col = screen.col; + save.rstyle = rstyle; + save.charset = screen.charset; + save.charset_char = charsets[screen.charset]; + break; + case RESTORE: + screen.row = save.row; + screen.col = save.col; + rstyle = save.rstyle; + screen.charset = save.charset; + charsets[screen.charset] = save.charset_char; + set_font_style(); + break; } } @@ -483,12 +483,12 @@ scr_color(unsigned int color, unsigned int Intensity) else { if (Xdepth <= 2) { /* Monochrome - ignore color changes */ switch (Intensity) { - case RS_Bold: - color = fgColor; - break; - case RS_Blink: - color = bgColor; - break; + case RS_Bold: + color = fgColor; + break; + case RS_Blink: + color = bgColor; + break; } } else { if ((rstyle & Intensity) && (color >= minColor) && (color <= maxColor)) { @@ -508,12 +508,12 @@ scr_color(unsigned int color, unsigned int Intensity) } } switch (Intensity) { - case RS_Bold: - rstyle = SET_FGCOLOR(rstyle, color); - break; - case RS_Blink: - rstyle = SET_BGCOLOR(rstyle, color); - break; + case RS_Bold: + rstyle = SET_FGCOLOR(rstyle, color); + break; + case RS_Blink: + rstyle = SET_BGCOLOR(rstyle, color); + break; } } @@ -531,47 +531,47 @@ scr_rendition(int set, int style) /* A: Set style */ rstyle |= style; switch (style) { - case RS_RVid: - if (rvideo) - rstyle &= ~RS_RVid; - break; - case RS_Bold: - color = GET_FGCOLOR(rstyle); - scr_color((color == fgColor ? GET_FGCOLOR(colorfgbg) : color), RS_Bold); - break; - case RS_Blink: - color = GET_BGCOLOR(rstyle); - scr_color((color == bgColor ? GET_BGCOLOR(colorfgbg) : color), RS_Blink); - break; + case RS_RVid: + if (rvideo) + rstyle &= ~RS_RVid; + break; + case RS_Bold: + color = GET_FGCOLOR(rstyle); + scr_color((color == fgColor ? GET_FGCOLOR(colorfgbg) : color), RS_Bold); + break; + case RS_Blink: + color = GET_BGCOLOR(rstyle); + scr_color((color == bgColor ? GET_BGCOLOR(colorfgbg) : color), RS_Blink); + break; } } else { /* B: Unset style */ rstyle &= ~style; switch (style) { - case ~RS_None: /* default fg/bg colors */ - rstyle = DEFAULT_RSTYLE | (old_style & RS_fontMask); - /* FALLTHROUGH */ - case RS_RVid: - if (rvideo) - rstyle |= RS_RVid; - break; - case RS_Bold: - color = GET_FGCOLOR(rstyle); - if (color >= minBright && color <= maxBright) { - scr_color(color, RS_Bold); - if ((rstyle & RS_fgMask) == (colorfgbg & RS_fgMask)) - scr_color(restoreFG, RS_Bold); - } - break; - case RS_Blink: - color = GET_BGCOLOR(rstyle); - if (color >= minBright && color <= maxBright) { - scr_color(color, RS_Blink); - if ((rstyle & RS_bgMask) == (colorfgbg & RS_bgMask)) - scr_color(restoreBG, RS_Blink); - } - break; + case ~RS_None: /* default fg/bg colors */ + rstyle = DEFAULT_RSTYLE | (old_style & RS_fontMask); + /* FALLTHROUGH */ + case RS_RVid: + if (rvideo) + rstyle |= RS_RVid; + break; + case RS_Bold: + color = GET_FGCOLOR(rstyle); + if (color >= minBright && color <= maxBright) { + scr_color(color, RS_Bold); + if ((rstyle & RS_fgMask) == (colorfgbg & RS_fgMask)) + scr_color(restoreFG, RS_Bold); + } + break; + case RS_Blink: + color = GET_BGCOLOR(rstyle); + if (color >= minBright && color <= maxBright) { + scr_color(color, RS_Blink); + if ((rstyle & RS_bgMask) == (colorfgbg & RS_bgMask)) + scr_color(restoreBG, RS_Blink); + } + break; } } } @@ -752,35 +752,35 @@ scr_add_lines(const unsigned char *str, int nlines, int len) } else #endif switch (c) { - case 127: - continue; /* ummmm..... */ - case '\t': - scr_tab(1); - continue; - case '\n': - LOWER_BOUND(stp[last_col], screen.col); - screen.flags &= ~Screen_WrapNext; - if (screen.row == screen.bscroll) { - scroll_text(screen.tscroll, screen.bscroll, 1, 0); - j = screen.bscroll + TermWin.saveLines; - blank_screen_mem(screen.text, screen.rend, j, rstyle & ~(RS_Uline|RS_Overscore)); - } else if (screen.row < (TERM_WINDOW_GET_REPORTED_ROWS() - 1)) { - screen.row++; - row = screen.row + TermWin.saveLines; - } - stp = screen.text[row]; /* _must_ refresh */ - srp = screen.rend[row]; /* _must_ refresh */ - continue; - case '\r': - LOWER_BOUND(stp[last_col], screen.col); - screen.flags &= ~Screen_WrapNext; - screen.col = 0; - continue; - default: + case 127: + continue; /* ummmm..... */ + case '\t': + scr_tab(1); + continue; + case '\n': + LOWER_BOUND(stp[last_col], screen.col); + screen.flags &= ~Screen_WrapNext; + if (screen.row == screen.bscroll) { + scroll_text(screen.tscroll, screen.bscroll, 1, 0); + j = screen.bscroll + TermWin.saveLines; + blank_screen_mem(screen.text, screen.rend, j, rstyle & ~(RS_Uline | RS_Overscore)); + } else if (screen.row < (TERM_WINDOW_GET_REPORTED_ROWS() - 1)) { + screen.row++; + row = screen.row + TermWin.saveLines; + } + stp = screen.text[row]; /* _must_ refresh */ + srp = screen.rend[row]; /* _must_ refresh */ + continue; + case '\r': + LOWER_BOUND(stp[last_col], screen.col); + screen.flags &= ~Screen_WrapNext; + screen.col = 0; + continue; + default: #ifdef MULTI_CHARSET - rstyle &= ~RS_multiMask; + rstyle &= ~RS_multiMask; #endif - break; + break; } #ifdef MULTI_CHARSET } @@ -792,7 +792,7 @@ scr_add_lines(const unsigned char *str, int nlines, int len) j = screen.bscroll + TermWin.saveLines; /* blank_line(screen.text[j], screen.rend[j], TermWin.ncol, 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)) { screen.row++; row = screen.row + TermWin.saveLines; @@ -832,7 +832,7 @@ scr_add_lines(const unsigned char *str, int nlines, int len) #ifdef ESCREEN 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; } } @@ -928,7 +928,7 @@ scr_gotorc(int row, int col, int relative) } #ifdef ESCREEN 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; } else if (TermWin.screen_pending) { /* left last -> upd-finis */ TermWin.screen_pending |= 2; @@ -993,26 +993,26 @@ scr_erase_line(int mode) if (screen.text[row]) { switch (mode) { - case 0: /* erase to end of line */ - col = screen.col; - num = TERM_WINDOW_GET_REPORTED_COLS() - col; - UPPER_BOUND(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()], col); - break; - case 1: /* erase to beginning of line */ - col = 0; - num = screen.col + 1; - break; - case 2: /* erase whole line */ - col = 0; - num = TERM_WINDOW_GET_REPORTED_COLS(); - screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0; - break; - default: - return; + case 0: /* erase to end of line */ + col = screen.col; + num = TERM_WINDOW_GET_REPORTED_COLS() - col; + UPPER_BOUND(screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()], col); + break; + case 1: /* erase to beginning of line */ + col = 0; + num = screen.col + 1; + break; + case 2: /* erase whole line */ + col = 0; + num = TERM_WINDOW_GET_REPORTED_COLS(); + screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0; + break; + default: + 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 { - 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) { - case 0: /* erase to end of screen */ - scr_erase_line(0); - row = screen.row + 1; /* possible OOB */ - num = TERM_WINDOW_GET_REPORTED_ROWS() - row; - break; - case 1: /* erase to beginning of screen */ - scr_erase_line(1); - row = 0; /* possible OOB */ - num = screen.row; - break; - case 2: /* erase whole screen */ - row = 0; - num = TERM_WINDOW_GET_REPORTED_ROWS(); - break; - default: - return; + case 0: /* erase to end of screen */ + scr_erase_line(0); + row = screen.row + 1; /* possible OOB */ + num = TERM_WINDOW_GET_REPORTED_ROWS() - row; + break; + case 1: /* erase to beginning of screen */ + scr_erase_line(1); + row = 0; /* possible OOB */ + num = screen.row; + break; + case 2: /* erase whole screen */ + row = 0; + num = TERM_WINDOW_GET_REPORTED_ROWS(); + break; + default: + 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)); if (rstyle & RS_RVid || rstyle & RS_Uline || rstyle & RS_Overscore) ren = -1; @@ -1172,27 +1172,28 @@ scr_insdel_chars(int count, int insdel) screen.flags &= ~Screen_WrapNext; switch (insdel) { - case INSERT: - for (col = TERM_WINDOW_GET_REPORTED_COLS() - 1; (col - count) >= screen.col; col--) { - screen.text[row][col] = screen.text[row][col - count]; - screen.rend[row][col] = screen.rend[row][col - 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()); - /* FALLTHROUGH */ - case ERASE: - blank_line(&(screen.text[row][screen.col]), &(screen.rend[row][screen.col]), count, rstyle); - break; - case DELETE: - for (col = screen.col; (col + count) < TERM_WINDOW_GET_REPORTED_COLS(); col++) { - screen.text[row][col] = screen.text[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); - screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] -= count; - if (((signed char) screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()]) < 0) - screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0; - break; + case INSERT: + for (col = TERM_WINDOW_GET_REPORTED_COLS() - 1; (col - count) >= screen.col; col--) { + screen.text[row][col] = screen.text[row][col - count]; + screen.rend[row][col] = screen.rend[row][col - 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()); + /* FALLTHROUGH */ + case ERASE: + blank_line(&(screen.text[row][screen.col]), &(screen.rend[row][screen.col]), count, rstyle); + break; + case DELETE: + for (col = screen.col; (col + count) < TERM_WINDOW_GET_REPORTED_COLS(); col++) { + screen.text[row][col] = screen.text[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); + screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] -= count; + if (((signed char) screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()]) < 0) + screen.text[row][TERM_WINDOW_GET_REPORTED_COLS()] = 0; + break; } #ifdef MULTI_CHARSET if ((screen.rend[row][0] & RS_multiMask) == RS_multi2) { @@ -1337,22 +1338,22 @@ set_font_style(void) { rstyle &= ~RS_fontMask; switch (charsets[screen.charset]) { - case '0': /* DEC Special Character & Line Drawing Set */ - rstyle |= RS_acsFont; - break; - case 'A': /* United Kingdom (UK) */ - rstyle |= RS_ukFont; - break; - case 'B': /* United States (USASCII) */ - break; - case '<': /* Multinational character set */ - break; - case '5': /* Finnish character set */ - break; - case 'C': /* Finnish character set */ - break; - case 'K': /* German character set */ - break; + case '0': /* DEC Special Character & Line Drawing Set */ + rstyle |= RS_acsFont; + break; + case 'A': /* United Kingdom (UK) */ + rstyle |= RS_ukFont; + break; + case 'B': /* United States (USASCII) */ + break; + case '<': /* Multinational character set */ + break; + case '5': /* Finnish character set */ + break; + case 'C': /* Finnish character set */ + break; + case 'K': /* German character set */ + break; } } @@ -1495,7 +1496,8 @@ scr_expose(int x, int y, int width, int height) rect_end.row = Pixel2Row(y + height + TermWin.fheight - 1); 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++) { 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); } 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 { XBell(Xdisplay, 0); } @@ -1619,14 +1621,14 @@ scr_refresh(int type) scrrow, /* screen row offset */ row_offset, /* basic offset in screen structure */ boldlast = 0, /* last character in some row was bold */ - len, wlen, /* text length screen/buffer */ - fprop, /* proportional font used */ - is_cursor, /* cursor this position */ - rvid, /* reverse video this position */ - fore, back, /* desired foreground/background */ - wbyte, /* we're in multibyte */ - xpixel, /* x offset for start of drawing (font) */ - ypixel; /* y offset for start of drawing (font) */ + len, wlen, /* text length screen/buffer */ + fprop, /* proportional font used */ + is_cursor, /* cursor this position */ + rvid, /* reverse video this position */ + fore, back, /* desired foreground/background */ + wbyte, /* we're in multibyte */ + xpixel, /* x offset for start of drawing (font) */ + ypixel; /* y offset for start of drawing (font) */ register int col, row, /* column/row we're processing */ rend; /* rendition */ static int focus = -1; /* screen in focus? */ @@ -1657,15 +1659,15 @@ scr_refresh(int type) PROF_INIT(scr_refresh); switch (type) { - case NO_REFRESH: - D_SCREEN(("scr_refresh(NO_REFRESH) called.\n")); - break; - case SLOW_REFRESH: - D_SCREEN(("scr_refresh(SLOW_REFRESH) called.\n")); - break; - case FAST_REFRESH: - D_SCREEN(("scr_refresh(FAST_REFRESH) called.\n")); - break; + case NO_REFRESH: + D_SCREEN(("scr_refresh(NO_REFRESH) called.\n")); + break; + case SLOW_REFRESH: + D_SCREEN(("scr_refresh(SLOW_REFRESH) called.\n")); + break; + case FAST_REFRESH: + D_SCREEN(("scr_refresh(FAST_REFRESH) called.\n")); + break; } if (type == NO_REFRESH) return; @@ -1870,18 +1872,18 @@ scr_refresh(int type) } else is_cursor = 0; switch (rend & RS_fontMask) { - case RS_acsFont: - for (i = 0; i < len; i++) - if (buffer[i] == 0x5f) - buffer[i] = 0x7f; - else if (buffer[i] > 0x5f && buffer[i] < 0x7f) - buffer[i] -= 0x5f; - break; - case RS_ukFont: - for (i = 0; i < len; i++) - if (buffer[i] == '#') - buffer[i] = 0x1e; - break; + case RS_acsFont: + for (i = 0; i < len; i++) + if (buffer[i] == 0x5f) + buffer[i] = 0x7f; + else if (buffer[i] > 0x5f && buffer[i] < 0x7f) + buffer[i] -= 0x5f; + break; + case RS_ukFont: + for (i = 0; i < len; i++) + if (buffer[i] == '#') + buffer[i] = 0x1e; + break; } if (rvid) SWAP_IT(fore, back, i); @@ -2057,10 +2059,12 @@ scr_refresh(int type) gcmask |= (GCForeground | GCBackground); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); 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) { - 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); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); @@ -2088,7 +2092,8 @@ scr_refresh(int type) } if (rend & RS_Overscore) { 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); } else { 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]); } #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); XSetForeground(Xdisplay, TermWin.gc, PixColors[fgColor]); } @@ -2133,18 +2139,22 @@ scr_refresh(int type) #endif } 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); 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); } 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); } 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); } if (fshadow.shadow[SHADOW_BOTTOM_LEFT] || fshadow.shadow[SHADOW_BOTTOM_RIGHT]) { @@ -2439,7 +2449,9 @@ selection_fetch(Window win, unsigned prop, int delete) return; } 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)) { D_SELECT(("Unable to fetch the value of property %d from window 0x%08x\n", (int) prop, (int) win)); if (data != NULL) { @@ -2448,7 +2460,8 @@ selection_fetch(Window win, unsigned prop, int delete) return; } 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) { 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. */ selection_write(data, nitems); } 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; XSelectInput(Xdisplay, TermWin.vt, TermWin.mask); } else { @@ -2687,18 +2701,18 @@ selection_make(Time tm) D_SELECT(("selection.op=%d, selection.clicks=%d\n", selection.op, selection.clicks)); switch (selection.op) { - case SELECTION_CONT: - break; - case SELECTION_INIT: - selection_reset(); - selection.end.row = selection.beg.row = selection.mark.row; - selection.end.col = selection.beg.col = selection.mark.col; - /* FALLTHROUGH */ - case SELECTION_BEGIN: - selection.op = SELECTION_DONE; - /* FALLTHROUGH */ - default: - return; + case SELECTION_CONT: + break; + case SELECTION_INIT: + selection_reset(); + selection.end.row = selection.beg.row = selection.mark.row; + selection.end.col = selection.beg.col = selection.mark.col; + /* FALLTHROUGH */ + case SELECTION_BEGIN: + selection.op = SELECTION_DONE; + /* FALLTHROUGH */ + default: + return; } 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 srp = &(screen.rend[beg_row + row_offset - 1][last_col + 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--; #else 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]; #ifdef MULTI_CHARSET 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 - 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 end_row++; 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)); switch (selection.op) { - case SELECTION_INIT: - selection_reset(); - selection.end.col = selection.beg.col = selection.mark.col; - selection.end.row = selection.beg.row = selection.mark.row; - selection.op = SELECTION_BEGIN; - /* FALLTHROUGH */ - case SELECTION_BEGIN: - break; - case SELECTION_DONE: - selection.op = SELECTION_CONT; - /* FALLTHROUGH */ - case SELECTION_CONT: - break; - case SELECTION_CLEAR: - selection_start_colrow(col, row); - /* FALLTHROUGH */ - default: - return; + case SELECTION_INIT: + selection_reset(); + selection.end.col = selection.beg.col = selection.mark.col; + selection.end.row = selection.beg.row = selection.mark.row; + selection.op = SELECTION_BEGIN; + /* FALLTHROUGH */ + case SELECTION_BEGIN: + break; + case SELECTION_DONE: + selection.op = SELECTION_CONT; + /* FALLTHROUGH */ + case SELECTION_CONT: + break; + case SELECTION_CLEAR: + selection_start_colrow(col, row); + /* FALLTHROUGH */ + default: + return; } if ((selection.beg.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[1] = (Atom32) XA_STRING; 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; #if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H) } else if (rq->target == XA_TEXT(Xdisplay) || rq->target == XA_COMPOUND_TEXT(Xdisplay)) { @@ -3297,7 +3316,8 @@ selection_send(XSelectionRequestEvent * rq) xtextp.nitems = 0; if (XmbTextListToTextProperty(Xdisplay, l, 1, XCompoundTextStyle, &xtextp) == Success) { 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; } } @@ -3315,22 +3335,23 @@ twin_mouse_drag_report(XButtonEvent * ev) int button_number, key_state, x = Pixel2Col(ev->x), y = Pixel2Row(ev->y); switch (ev->button) { - case AnyButton: /* Button release */ - button_number = pb + Button1; /* yeah, yeah */ - break; - case Button1: /* Button press */ - case Button2: - case Button3: - pb = button_number = ev->button - Button1; - break; - default: /* Wheel mouse */ - button_number = 64 + ev->button - Button3 - 1; - break; + case AnyButton: /* Button release */ + button_number = pb + Button1; /* yeah, yeah */ + break; + case Button1: /* Button press */ + case Button2: + case Button3: + pb = button_number = ev->button - Button1; + break; + default: /* Wheel mouse */ + button_number = 64 + ev->button - Button3 - 1; + break; } key_state = ((ev->state & (ShiftMask | ControlMask)) + ((ev->state & Mod1Mask) ? 2 : 0)); 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 @@ -3339,21 +3360,22 @@ mouse_report(XButtonEvent * ev) int button_number, key_state; switch (ev->button) { - case AnyButton: /* Button release */ - button_number = 3; - break; - case Button1: /* Button press */ - case Button2: - case Button3: - pb = button_number = ev->button - Button1; - break; - default: /* Wheel mouse */ - button_number = 64 + ev->button - Button3 - 1; - break; + case AnyButton: /* Button release */ + button_number = 3; + break; + case Button1: /* Button press */ + case Button2: + case Button3: + pb = button_number = ev->button - Button1; + break; + default: /* Wheel mouse */ + button_number = 64 + ev->button - Button3 - 1; + break; } key_state = ((ev->state & (ShiftMask | ControlMask)) + ((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 diff --git a/src/scrollbar.c b/src/scrollbar.c index e659df8..5513653 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -203,22 +203,23 @@ sb_handle_button_press(event_t *ev) tt_printf((unsigned char *) "\033[B"); else { switch (ev->xbutton.button) { - case Button2: - tt_printf((unsigned char *) "\014"); - break; - case Button1: - tt_printf((unsigned char *) "\033[6~"); - break; - case Button3: - tt_printf((unsigned char *) "\033[5~"); - break; + case Button2: + tt_printf((unsigned char *) "\014"); + break; + case Button1: + tt_printf((unsigned char *) "\033[6~"); + break; + case Button3: + tt_printf((unsigned char *) "\033[5~"); + break; } } } else #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((" 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)) { 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); } switch (ev->xbutton.button) { - case Button2: - button_state.mouse_offset = scrollbar_anchor_height() / 2; /* Align to center */ - if (!scrollbar_win_is_anchor(ev->xany.window)) { - scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); - } else if (scrollbar.type == SCROLLBAR_XTERM) { - scr_move_to(scrollbar.anchor_top + ev->xbutton.y - button_state.mouse_offset, scrollbar_scrollarea_height()); - } - scrollbar_set_motion(1); - break; + case Button2: + button_state.mouse_offset = scrollbar_anchor_height() / 2; /* Align to center */ + if (!scrollbar_win_is_anchor(ev->xany.window)) { + scr_move_to(scrollbar_position(ev->xbutton.y) - button_state.mouse_offset, scrollbar_scrollarea_height()); + } else if (scrollbar.type == SCROLLBAR_XTERM) { + scr_move_to(scrollbar.anchor_top + ev->xbutton.y - button_state.mouse_offset, + scrollbar_scrollarea_height()); + } + scrollbar_set_motion(1); + break; - case Button1: - button_state.mouse_offset = ((scrollbar_win_is_anchor(ev->xany.window)) ? (MAX(ev->xbutton.y, 1)) : (1)); - /* drop */ - case Button3: + case Button1: + button_state.mouse_offset = ((scrollbar_win_is_anchor(ev->xany.window)) ? (MAX(ev->xbutton.y, 1)) : (1)); + /* drop */ + case Button3: #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) - if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) { - if (scrollbar_is_above_anchor(ev->xany.window, ev->xbutton.y)) { - scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); - scr_page(UP, TermWin.nrow - CONTEXT_LINES); - } else if (scrollbar_is_below_anchor(ev->xany.window, ev->xbutton.y)) { - scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); - scr_page(DN, TermWin.nrow - CONTEXT_LINES); - } else { - scrollbar_set_motion(1); - } - } + if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) { + if (scrollbar_is_above_anchor(ev->xany.window, ev->xbutton.y)) { + scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); + scr_page(UP, TermWin.nrow - CONTEXT_LINES); + } else if (scrollbar_is_below_anchor(ev->xany.window, ev->xbutton.y)) { + scrollbar_draw_trough(IMAGE_STATE_CLICKED, 0); + scr_page(DN, TermWin.nrow - CONTEXT_LINES); + } else { + scrollbar_set_motion(1); + } + } #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ #ifdef XTERM_SCROLLBAR - if (scrollbar.type == SCROLLBAR_XTERM) { - scr_page((ev->xbutton.button == Button1 ? DN : UP), TermWin.nrow - CONTEXT_LINES); - } + if (scrollbar.type == SCROLLBAR_XTERM) { + scr_page((ev->xbutton.button == Button1 ? DN : UP), TermWin.nrow - CONTEXT_LINES); + } #endif /* XTERM_SCROLLBAR */ - break; + break; } } } @@ -333,7 +335,8 @@ sb_handle_motion_notify(event_t *ev) return 1; 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()) { Window unused_root, unused_child; @@ -341,7 +344,8 @@ sb_handle_motion_notify(event_t *ev) unsigned int unused_mask; 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()); refresh_count = refresh_limit = 0; 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); 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); } #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_bottom, get_bottom_shadow_color(images[image_sa].current->bg, "")); 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 { - 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 @@ -573,7 +580,8 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes) Pixmap pmap; 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; /* Draw the thumb if there is one. */ if (thumb) { @@ -600,7 +608,8 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes) UPPER_BOUND(th, scrollbar_anchor_height() >> 1); D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th)); 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); XClearWindow(Xdisplay, scrollbar.sa_win); 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()); 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, "")); - 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; } @@ -696,9 +706,10 @@ scrollbar_init(int width, int height) /* Create the scrollbar trough window. It will be the parent to the other windows. */ scrollbar.win = - XCreateWindow(Xdisplay, TermWin.parent, ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)), - bbar_calc_docked_height(BBAR_DOCKED_TOP), scrollbar_trough_width(), height, 0, Xdepth, InputOutput, CopyFromParent, - CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap, &Attributes); + XCreateWindow(Xdisplay, TermWin.parent, + ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)), + 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); XSelectInput(Xdisplay, scrollbar.win, mask); XStoreName(Xdisplay, scrollbar.win, "Eterm Scrollbar"); @@ -707,7 +718,8 @@ scrollbar_init(int width, int height) /* Now the up arrow window. */ scrollbar.up_win = 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); XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Up Arrow"); 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 */ scrollbar.dn_win = 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); XStoreName(Xdisplay, scrollbar.up_win, "Eterm Scrollbar Down Arrow"); 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 */ scrollbar.sa_win = 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); XMapWindow(Xdisplay, scrollbar.sa_win); 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.win_width = scrollbar.width + (2 * scrollbar_get_shadow()); 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, 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, ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (width - scrollbar_trough_width()) : (0)), 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()); scrollbar_draw_trough(IMAGE_STATE_CURRENT, MODE_MASK); scrollbar_reposition_and_draw(MODE_MASK); diff --git a/src/startup.c b/src/startup.c index ce3031d..f993b14 100644 --- a/src/startup.c +++ b/src/startup.c @@ -76,6 +76,7 @@ eterm_bootstrap(int argc, char *argv[]) int i; char *val; + /* "WINDOWID=\0" = 10 chars, UINT_MAX = 10 chars */ 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); 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; D_OPTIONS(("conf_parse_theme() returned \"%s\"\n", user_dir)); @@ -194,7 +197,8 @@ eterm_bootstrap(int argc, char *argv[]) #endif 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(("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 # define ESCREEN_PREFIX "Escreen" @@ -240,7 +244,8 @@ eterm_bootstrap(int argc, char *argv[]) /* Initialize the scrollbar */ 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. */ menu_init(); diff --git a/src/term.c b/src/term.c index 0ebac1c..79674d7 100644 --- a/src/term.c +++ b/src/term.c @@ -326,10 +326,10 @@ char *def_colorName[] = { #ifndef NO_CURSORCOLOR NULL, NULL, /* cursorColor, cursorColor2 */ -#endif /* NO_CURSORCOLOR */ +#endif /* NO_CURSORCOLOR */ #ifndef NO_BOLDUNDERLINE NULL, NULL, /* colorBD, colorUL */ -#endif /* NO_BOLDUNDERLINE */ +#endif /* NO_BOLDUNDERLINE */ #ifdef ESCREEN NULL, NULL, /* ES_COLOR_CURRENT, ES_COLOR_ACTIVE */ #endif @@ -375,22 +375,22 @@ get_modifiers(void) } /* Check to see if it's one that we care about. */ switch (XKeycodeToKeysym(Xdisplay, kc[k], 0)) { - case XK_Meta_L: - case XK_Meta_R: - D_X11(("Found Meta key as mod %d\n", l + 1)); - match = MetaMask = modmasks[l]; - break; - case XK_Alt_L: - case XK_Alt_R: - D_X11(("Found Alt key as mod %d\n", l + 1)); - match = AltMask = modmasks[l]; - break; - case XK_Num_Lock: - D_X11(("Found NumLock key as mod %d\n", l + 1)); - match = NumLockMask = modmasks[l]; - break; - default: - break; + case XK_Meta_L: + case XK_Meta_R: + D_X11(("Found Meta key as mod %d\n", l + 1)); + match = MetaMask = modmasks[l]; + break; + case XK_Alt_L: + case XK_Alt_R: + D_X11(("Found Alt key as mod %d\n", l + 1)); + match = AltMask = modmasks[l]; + break; + case XK_Num_Lock: + D_X11(("Found NumLock key as mod %d\n", l + 1)); + match = NumLockMask = modmasks[l]; + break; + default: + break; } if (match) { break; @@ -486,20 +486,21 @@ lookup_key(XEvent * ev) kbuf = (unsigned char *) MALLOC(len + 1); kbuf_alloced = 1; len = XmbLookupString(xim_input_context, &ev->xkey, (char *) kbuf, len, &keysym, &status_return); - D_TTY(("XmbLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\" based on the XIM input context %010p\n", - len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len), xim_input_context)); + D_TTY(("XmbLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\" based on the XIM input context %010p\n", len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len), xim_input_context)); } valid_keysym = (status_return == XLookupKeySym) || (status_return == XLookupBoth); } else { /* No XIM input context. Do it the normal way. */ len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(short_buf), &keysym, NULL); - D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len))); + D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, + safe_print_string(kbuf, len))); valid_keysym = 1; } #else /* USE_XIM */ /* Translate the key event into its corresponding string according to X. This also gets us a keysym. */ len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, NULL); - D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len))); + D_TTY(("XLookupString() gave us len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, + safe_print_string(kbuf, len))); /* If there is no string and it's a Latin2-7 character, replace it with the Latin1 character instead. */ if (!len && (keysym >= 0x0100) && (keysym < 0x0900)) { @@ -562,21 +563,21 @@ lookup_key(XEvent * ev) #if defined(HAVE_X11_SUNKEYSYM_H) && defined(HAVE_X11_XMU_ATOMS_H) switch (keysym) { - case SunXK_Copy: - case SunXK_Cut: - selection_copy(XA_CLIPBOARD(Xdisplay)); - LK_RET(); - break; - case SunXK_Paste: - selection_paste(XA_CLIPBOARD(Xdisplay)); - LK_RET(); - break; - case SunXK_Front: - xterm_seq(ESCSEQ_XTERM_TAKEOVER, ""); - LK_RET(); - break; - default: - break; + case SunXK_Copy: + case SunXK_Cut: + selection_copy(XA_CLIPBOARD(Xdisplay)); + LK_RET(); + break; + case SunXK_Paste: + selection_paste(XA_CLIPBOARD(Xdisplay)); + LK_RET(); + break; + case SunXK_Front: + xterm_seq(ESCSEQ_XTERM_TAKEOVER, ""); + LK_RET(); + break; + default: + break; } #endif @@ -587,34 +588,34 @@ lookup_key(XEvent * ev) shft = 0; } else if (!ctrl && !meta && (PrivateModes & PrivMode_ShiftKeys)) { switch (keysym) { - case XK_Prior: /* Shift-PgUp scrolls up a page */ - if (TermWin.saveLines) { - scr_page(UP, (TermWin.nrow - CONTEXT_LINES)); - LK_RET(); - } - break; + case XK_Prior: /* Shift-PgUp scrolls up a page */ + if (TermWin.saveLines) { + scr_page(UP, (TermWin.nrow - CONTEXT_LINES)); + LK_RET(); + } + break; - case XK_Next: /* Shift-PgDn scrolls down a page */ - if (TermWin.saveLines) { - scr_page(DN, (TermWin.nrow - CONTEXT_LINES)); - LK_RET(); - } - break; + case XK_Next: /* Shift-PgDn scrolls down a page */ + if (TermWin.saveLines) { + scr_page(DN, (TermWin.nrow - CONTEXT_LINES)); + LK_RET(); + } + break; - case XK_Insert: /* Shift-Ins pastes the current selection. */ - selection_paste(XA_PRIMARY); - LK_RET(); - break; + case XK_Insert: /* Shift-Ins pastes the current selection. */ + selection_paste(XA_PRIMARY); + LK_RET(); + break; - case XK_KP_Add: /* Shift-Plus on the keypad increases the font size */ - change_font(0, BIGGER_FONT); - LK_RET(); - break; + case XK_KP_Add: /* Shift-Plus on the keypad increases the font size */ + change_font(0, BIGGER_FONT); + LK_RET(); + break; - case XK_KP_Subtract: /* Shift-Minus on the keypad decreases the font size */ - change_font(0, SMALLER_FONT); - LK_RET(); - break; + case XK_KP_Subtract: /* Shift-Minus on the keypad decreases the font size */ + change_font(0, SMALLER_FONT); + LK_RET(); + break; } } } @@ -622,48 +623,48 @@ lookup_key(XEvent * ev) /* Allow PgUp/PgDn by themselves to scroll. Not recommended. */ else if (!ctrl && !meta) { switch (keysym) { - case XK_Prior: - if (TermWin.saveLines) { - scr_page(UP, TermWin.nrow - CONTEXT_LINES); - LK_RET(); - } - break; + case XK_Prior: + if (TermWin.saveLines) { + scr_page(UP, TermWin.nrow - CONTEXT_LINES); + LK_RET(); + } + break; - case XK_Next: - if (TermWin.saveLines) { - scr_page(DN, TermWin.nrow - CONTEXT_LINES); - LK_RET(); - } - break; + case XK_Next: + if (TermWin.saveLines) { + scr_page(DN, TermWin.nrow - CONTEXT_LINES); + LK_RET(); + } + break; } } #endif switch (keysym) { - case XK_Print: /* Print the screen contents out to the print pipe */ + case XK_Print: /* Print the screen contents out to the print pipe */ #if DEBUG >= DEBUG_SELECTION - if (DEBUG_LEVEL >= DEBUG_SELECTION) { - scr_dump_to_file("/tmp/Eterm_screen_dump.log"); - } else + if (DEBUG_LEVEL >= DEBUG_SELECTION) { + scr_dump_to_file("/tmp/Eterm_screen_dump.log"); + } else #endif #ifdef PRINTPIPE - scr_printscreen(ctrl | shft); + scr_printscreen(ctrl | shft); #endif - LK_RET(); - break; + LK_RET(); + break; - case XK_Mode_switch: + case XK_Mode_switch: #ifdef GREEK_SUPPORT - greek_mode = !greek_mode; - if (greek_mode) { - xterm_seq(ESCSEQ_XTERM_TITLE, (greek_getmode() == GREEK_ELOT928 ? "[Greek: iso]" : "[Greek: ibm]")); - greek_reset(); - } else - xterm_seq(ESCSEQ_XTERM_TITLE, APL_NAME "-" VERSION); - LK_RET(); + greek_mode = !greek_mode; + if (greek_mode) { + xterm_seq(ESCSEQ_XTERM_TITLE, (greek_getmode() == GREEK_ELOT928 ? "[Greek: iso]" : "[Greek: ibm]")); + greek_reset(); + } else + xterm_seq(ESCSEQ_XTERM_TITLE, APL_NAME "-" VERSION); + LK_RET(); #endif - break; + break; } /* At this point, all the keystrokes that have special meaning to us have been handled. @@ -703,301 +704,301 @@ lookup_key(XEvent * ev) #endif /* This is a big-ass switch statement that handles all the special keysyms */ switch (keysym) { - case XK_BackSpace: - len = 1; + case XK_BackSpace: + len = 1; #ifdef FORCE_BACKSPACE - kbuf[0] = (!(shft | ctrl) ? '\b' : '\177'); + kbuf[0] = (!(shft | ctrl) ? '\b' : '\177'); #elif defined(FORCE_DELETE) - kbuf[0] = ((shft | ctrl) ? '\b' : '\177'); + kbuf[0] = ((shft | ctrl) ? '\b' : '\177'); #else - kbuf[0] = (((PrivateModes & PrivMode_BackSpace) ? !(shft | ctrl) : (shft | ctrl)) ? '\b' : '\177'); + kbuf[0] = (((PrivateModes & PrivMode_BackSpace) ? !(shft | ctrl) : (shft | ctrl)) ? '\b' : '\177'); #endif #ifdef MULTI_CHARSET - if ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_MBYTE_CURSOR)) && scr_multi2()) { - memmove(kbuf + len, kbuf, len); - len *= 2; - } + if ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_MBYTE_CURSOR)) && scr_multi2()) { + memmove(kbuf + len, kbuf, len); + len *= 2; + } #endif /* MULTI_CHARSET */ - break; + break; - /* Tab key is normal unless it's shift-tab. */ - case XK_Tab: - case XK_ISO_Left_Tab: - if (shft) { - len = 3; - strcpy(kbuf, "\033[Z"); - } - break; + /* Tab key is normal unless it's shift-tab. */ + case XK_Tab: + case XK_ISO_Left_Tab: + if (shft) { + len = 3; + strcpy(kbuf, "\033[Z"); + } + break; #ifdef XK_KP_Home - case XK_KP_Home: - /* allow shift to override */ - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033Ow"); - break; - } - /* -> else FALL THROUGH */ + case XK_KP_Home: + /* allow shift to override */ + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033Ow"); + break; + } + /* -> else FALL THROUGH */ #endif - case XK_Home: - len = strlen(strcpy(kbuf, KS_HOME)); - break; + case XK_Home: + len = strlen(strcpy(kbuf, KS_HOME)); + break; #ifdef XK_KP_Left - case XK_KP_Left: /* \033Ot or standard cursor key */ - case XK_KP_Up: /* \033Ox or standard cursor key */ - case XK_KP_Right: /* \033Ov or standard cursor key */ - case XK_KP_Down: /* \033Or or standard cursor key */ - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033OZ"); /* The Z is replaced by t, x, v, or r */ - kbuf[2] = ("txvr"[keysym - XK_KP_Left]); - break; - } else { - keysym = XK_Left + (keysym - XK_KP_Left); - } - /* Continue on with the normal cursor keys... */ + case XK_KP_Left: /* \033Ot or standard cursor key */ + case XK_KP_Up: /* \033Ox or standard cursor key */ + case XK_KP_Right: /* \033Ov or standard cursor key */ + case XK_KP_Down: /* \033Or or standard cursor key */ + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033OZ"); /* The Z is replaced by t, x, v, or r */ + kbuf[2] = ("txvr"[keysym - XK_KP_Left]); + break; + } else { + keysym = XK_Left + (keysym - XK_KP_Left); + } + /* Continue on with the normal cursor keys... */ #endif - case XK_Left: /* "\033[D" */ - case XK_Up: /* "\033[A" */ - case XK_Right: /* "\033[C" */ - case XK_Down: /* "\033[B" */ - len = 3; - strcpy(kbuf, "\033[@"); - kbuf[2] = ("DACB"[keysym - XK_Left]); - if (PrivateModes & PrivMode_aplCUR) { - kbuf[1] = 'O'; - } else if (shft) { /* do Shift first */ - kbuf[2] = ("dacb"[keysym - XK_Left]); - } else if (ctrl) { - kbuf[1] = 'O'; - kbuf[2] = ("dacb"[keysym - XK_Left]); - } + case XK_Left: /* "\033[D" */ + case XK_Up: /* "\033[A" */ + case XK_Right: /* "\033[C" */ + case XK_Down: /* "\033[B" */ + len = 3; + strcpy(kbuf, "\033[@"); + kbuf[2] = ("DACB"[keysym - XK_Left]); + if (PrivateModes & PrivMode_aplCUR) { + kbuf[1] = 'O'; + } else if (shft) { /* do Shift first */ + kbuf[2] = ("dacb"[keysym - XK_Left]); + } else if (ctrl) { + kbuf[1] = 'O'; + kbuf[2] = ("dacb"[keysym - XK_Left]); + } #ifdef MULTI_CHARSET - if ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_MBYTE_CURSOR)) - && ((keysym == XK_Left && scr_multi2()) - || (keysym == XK_Right && scr_multi1()))) { - memmove(kbuf + len, kbuf, len); - len *= 2; - } + if ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_MBYTE_CURSOR)) + && ((keysym == XK_Left && scr_multi2()) + || (keysym == XK_Right && scr_multi1()))) { + memmove(kbuf + len, kbuf, len); + len *= 2; + } #endif /* MULTI_CHARSET */ - break; + break; - /* Keypad and normal PgUp/PgDn */ + /* Keypad and normal PgUp/PgDn */ #ifndef UNSHIFTED_SCROLLKEYS # ifdef XK_KP_Prior - case XK_KP_Prior: - /* allow shift to override */ - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033Oy"); - break; - } - /* -> else FALL THROUGH */ + case XK_KP_Prior: + /* allow shift to override */ + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033Oy"); + break; + } + /* -> else FALL THROUGH */ # endif /* XK_KP_Prior */ - case XK_Prior: - len = 4; - strcpy(kbuf, "\033[5~"); - break; + case XK_Prior: + len = 4; + strcpy(kbuf, "\033[5~"); + break; # ifdef XK_KP_Next - case XK_KP_Next: - /* allow shift to override */ - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033Os"); - break; - } - /* -> else FALL THROUGH */ + case XK_KP_Next: + /* allow shift to override */ + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033Os"); + break; + } + /* -> else FALL THROUGH */ # endif /* XK_KP_Next */ - case XK_Next: - len = 4; - strcpy(kbuf, "\033[6~"); - break; + case XK_Next: + len = 4; + strcpy(kbuf, "\033[6~"); + break; #endif /* UNSHIFTED_SCROLLKEYS */ - /* End key */ + /* End key */ #ifdef XK_KP_End - case XK_KP_End: - /* allow shift to override */ - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033Oq"); - break; - } - /* -> else FALL THROUGH */ + case XK_KP_End: + /* allow shift to override */ + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033Oq"); + break; + } + /* -> else FALL THROUGH */ #endif /* XK_KP_End */ - case XK_End: - len = strlen(strcpy(kbuf, KS_END)); - break; + case XK_End: + len = strlen(strcpy(kbuf, KS_END)); + break; - case XK_Select: - len = 4; - strcpy(kbuf, "\033[4~"); - break; + case XK_Select: + len = 4; + strcpy(kbuf, "\033[4~"); + break; #ifdef DXK_Remove - case DXK_Remove: + case DXK_Remove: #endif - case XK_Execute: - len = 4; - strcpy(kbuf, "\033[3~"); - break; + case XK_Execute: + len = 4; + strcpy(kbuf, "\033[3~"); + break; #ifdef XK_KP_Insert - case XK_KP_Insert: - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033Op"); - break; - } + case XK_KP_Insert: + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033Op"); + break; + } #endif - case XK_Insert: - len = 4; - strcpy(kbuf, "\033[2~"); - break; + case XK_Insert: + len = 4; + strcpy(kbuf, "\033[2~"); + break; #ifdef XK_KP_Delete - case XK_KP_Delete: - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033On"); - break; - } + case XK_KP_Delete: + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033On"); + break; + } #endif - case XK_Delete: + case XK_Delete: #ifdef KS_DELETE - len = strlen(strcpy(kbuf, KS_DELETE)); + len = strlen(strcpy(kbuf, KS_DELETE)); #ifdef MULTI_CHARSET - if ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_MBYTE_CURSOR)) && scr_multi1()) { - memmove(kbuf + len, kbuf, len); - len *= 2; - } + if ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_MBYTE_CURSOR)) && scr_multi1()) { + memmove(kbuf + len, kbuf, len); + len *= 2; + } #endif /* MULTI_CHARSET */ #endif - break; + break; - case XK_Menu: - len = 5; - strcpy(kbuf, "\033[29~"); - break; - case XK_Find: - len = 4; - strcpy(kbuf, "\033[1~"); - break; - case XK_Help: - len = 5; - strcpy(kbuf, "\033[28~"); - break; + case XK_Menu: + len = 5; + strcpy(kbuf, "\033[29~"); + break; + case XK_Find: + len = 4; + strcpy(kbuf, "\033[1~"); + break; + case XK_Help: + len = 5; + strcpy(kbuf, "\033[28~"); + break; - case XK_KP_Enter: - /* allow shift to override */ - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033OM"); - } else { - len = 1; - kbuf[0] = '\r'; - } - break; + case XK_KP_Enter: + /* allow shift to override */ + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033OM"); + } else { + len = 1; + kbuf[0] = '\r'; + } + break; #ifdef XK_KP_Begin - case XK_KP_Begin: - len = 3; - strcpy(kbuf, "\033Ou"); - break; + case XK_KP_Begin: + len = 3; + strcpy(kbuf, "\033Ou"); + break; #endif /* XK_KP_Begin */ - case XK_KP_F1: /* "\033OP" */ - case XK_KP_F2: /* "\033OQ" */ - case XK_KP_F3: /* "\033OR" */ - case XK_KP_F4: /* "\033OS" */ - len = 3; - strcpy(kbuf, "\033OP"); - kbuf[2] += (keysym - XK_KP_F1); - break; + case XK_KP_F1: /* "\033OP" */ + case XK_KP_F2: /* "\033OQ" */ + case XK_KP_F3: /* "\033OR" */ + case XK_KP_F4: /* "\033OS" */ + len = 3; + strcpy(kbuf, "\033OP"); + kbuf[2] += (keysym - XK_KP_F1); + break; - case XK_KP_Multiply: /* "\033Oj" : "*" */ - case XK_KP_Add: /* "\033Ok" : "+" */ - case XK_KP_Separator: /* "\033Ol" : "," */ - case XK_KP_Subtract: /* "\033Om" : "-" */ - case XK_KP_Decimal: /* "\033On" : "." */ - case XK_KP_Divide: /* "\033Oo" : "/" */ - case XK_KP_0: /* "\033Op" : "0" */ - case XK_KP_1: /* "\033Oq" : "1" */ - case XK_KP_2: /* "\033Or" : "2" */ - case XK_KP_3: /* "\033Os" : "3" */ - case XK_KP_4: /* "\033Ot" : "4" */ - case XK_KP_5: /* "\033Ou" : "5" */ - case XK_KP_6: /* "\033Ov" : "6" */ - case XK_KP_7: /* "\033Ow" : "7" */ - case XK_KP_8: /* "\033Ox" : "8" */ - case XK_KP_9: /* "\033Oy" : "9" */ - /* allow shift to override */ - if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { - len = 3; - strcpy(kbuf, "\033Oj"); - kbuf[2] += (keysym - XK_KP_Multiply); - } else { - len = 1; - kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); - } - break; + case XK_KP_Multiply: /* "\033Oj" : "*" */ + case XK_KP_Add: /* "\033Ok" : "+" */ + case XK_KP_Separator: /* "\033Ol" : "," */ + case XK_KP_Subtract: /* "\033Om" : "-" */ + case XK_KP_Decimal: /* "\033On" : "." */ + case XK_KP_Divide: /* "\033Oo" : "/" */ + case XK_KP_0: /* "\033Op" : "0" */ + case XK_KP_1: /* "\033Oq" : "1" */ + case XK_KP_2: /* "\033Or" : "2" */ + case XK_KP_3: /* "\033Os" : "3" */ + case XK_KP_4: /* "\033Ot" : "4" */ + case XK_KP_5: /* "\033Ou" : "5" */ + case XK_KP_6: /* "\033Ov" : "6" */ + case XK_KP_7: /* "\033Ow" : "7" */ + case XK_KP_8: /* "\033Ox" : "8" */ + case XK_KP_9: /* "\033Oy" : "9" */ + /* allow shift to override */ + if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) { + len = 3; + strcpy(kbuf, "\033Oj"); + kbuf[2] += (keysym - XK_KP_Multiply); + } else { + len = 1; + kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); + } + break; #define FKEY(n,fkey) do { \ len = 5; \ sprintf((char *) kbuf,"\033[%02d~", (int)((n) + (keysym - fkey))); \ } while (0); - case XK_F1: /* "\033[11~" */ - case XK_F2: /* "\033[12~" */ - case XK_F3: /* "\033[13~" */ - case XK_F4: /* "\033[14~" */ - case XK_F5: /* "\033[15~" */ - FKEY(11, XK_F1); - break; + case XK_F1: /* "\033[11~" */ + case XK_F2: /* "\033[12~" */ + case XK_F3: /* "\033[13~" */ + case XK_F4: /* "\033[14~" */ + case XK_F5: /* "\033[15~" */ + FKEY(11, XK_F1); + break; - case XK_F6: /* "\033[17~" */ - case XK_F7: /* "\033[18~" */ - case XK_F8: /* "\033[19~" */ - case XK_F9: /* "\033[20~" */ - case XK_F10: /* "\033[21~" */ - FKEY(17, XK_F6); - break; + case XK_F6: /* "\033[17~" */ + case XK_F7: /* "\033[18~" */ + case XK_F8: /* "\033[19~" */ + case XK_F9: /* "\033[20~" */ + case XK_F10: /* "\033[21~" */ + FKEY(17, XK_F6); + break; - case XK_F11: /* "\033[23~" */ - case XK_F12: /* "\033[24~" */ - case XK_F13: /* "\033[25~" */ - case XK_F14: /* "\033[26~" */ - FKEY(23, XK_F11); - break; + case XK_F11: /* "\033[23~" */ + case XK_F12: /* "\033[24~" */ + case XK_F13: /* "\033[25~" */ + case XK_F14: /* "\033[26~" */ + FKEY(23, XK_F11); + break; - case XK_F15: /* "\033[28~" */ - case XK_F16: /* "\033[29~" */ - FKEY(28, XK_F15); - break; + case XK_F15: /* "\033[28~" */ + case XK_F16: /* "\033[29~" */ + FKEY(28, XK_F15); + break; - case XK_F17: /* "\033[31~" */ - case XK_F18: /* "\033[32~" */ - case XK_F19: /* "\033[33~" */ - case XK_F20: /* "\033[34~" */ - case XK_F21: /* "\033[35~" */ - case XK_F22: /* "\033[36~" */ - case XK_F23: /* "\033[37~" */ - case XK_F24: /* "\033[38~" */ - case XK_F25: /* "\033[39~" */ - case XK_F26: /* "\033[40~" */ - case XK_F27: /* "\033[41~" */ - case XK_F28: /* "\033[42~" */ - case XK_F29: /* "\033[43~" */ - case XK_F30: /* "\033[44~" */ - case XK_F31: /* "\033[45~" */ - case XK_F32: /* "\033[46~" */ - case XK_F33: /* "\033[47~" */ - case XK_F34: /* "\033[48~" */ - case XK_F35: /* "\033[49~" */ - FKEY(31, XK_F17); - break; + case XK_F17: /* "\033[31~" */ + case XK_F18: /* "\033[32~" */ + case XK_F19: /* "\033[33~" */ + case XK_F20: /* "\033[34~" */ + case XK_F21: /* "\033[35~" */ + case XK_F22: /* "\033[36~" */ + case XK_F23: /* "\033[37~" */ + case XK_F24: /* "\033[38~" */ + case XK_F25: /* "\033[39~" */ + case XK_F26: /* "\033[40~" */ + case XK_F27: /* "\033[41~" */ + case XK_F28: /* "\033[42~" */ + case XK_F29: /* "\033[43~" */ + case XK_F30: /* "\033[44~" */ + case XK_F31: /* "\033[45~" */ + case XK_F32: /* "\033[46~" */ + case XK_F33: /* "\033[47~" */ + case XK_F34: /* "\033[48~" */ + case XK_F35: /* "\033[49~" */ + FKEY(31, XK_F17); + break; #undef FKEY } @@ -1061,7 +1062,8 @@ sprintf((char *) kbuf,"\033[%02d~", (int)((n) + (keysym - fkey))); \ tt_write(&ch, 1); } - D_TTY(("After handling: len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, safe_print_string(kbuf, len))); + D_TTY(("After handling: len %d, keysym \"%s\" (0x%04x), and buffer \"%s\"\n", len, XKeysymToString(keysym), keysym, + safe_print_string(kbuf, len))); tt_write(kbuf, len); /* Send the resulting string to the child process */ LK_RET(); @@ -1134,79 +1136,79 @@ process_escape_seq(void) unsigned char ch = cmd_getc(); switch (ch) { - case '#': - if (cmd_getc() == '8') - scr_E(); - break; - case '(': - scr_charset_set(0, cmd_getc()); - break; - case ')': - scr_charset_set(1, cmd_getc()); - break; - case '*': - scr_charset_set(2, cmd_getc()); - break; - case '+': - scr_charset_set(3, cmd_getc()); - break; + case '#': + if (cmd_getc() == '8') + scr_E(); + break; + case '(': + scr_charset_set(0, cmd_getc()); + break; + case ')': + scr_charset_set(1, cmd_getc()); + break; + case '*': + scr_charset_set(2, cmd_getc()); + break; + case '+': + scr_charset_set(3, cmd_getc()); + break; #ifdef MULTI_CHARSET - case '$': - scr_charset_set(-2, cmd_getc()); - break; + case '$': + scr_charset_set(-2, cmd_getc()); + break; #endif - case '7': - scr_cursor(SAVE); - break; - case '8': - scr_cursor(RESTORE); - break; - case '=': - case '>': - PrivMode((ch == '='), PrivMode_aplKP); - break; - case '@': - (void) cmd_getc(); - break; - case 'D': - scr_index(UP); - break; - case 'E': - scr_add_lines((unsigned char *) "\n\r", 1, 2); - break; - case 'G': - if ((ch = cmd_getc()) == 'Q') { /* query graphics */ - tt_printf((unsigned char *) "\033G0\n"); /* no graphics */ - } else { - do { - ch = cmd_getc(); - } while (ch != ':'); - } - break; - case 'H': - scr_set_tab(1); - break; - case 'M': - scr_index(DN); - break; - case 'Z': - tt_printf((unsigned char *) ESCZ_ANSWER); - break; - case '[': - process_csi_seq(); - break; - case ']': - process_xterm_seq(); - break; - case 'c': - scr_poweron(); - break; - case 'n': - scr_charset_choose(2); - break; - case 'o': - scr_charset_choose(3); - break; + case '7': + scr_cursor(SAVE); + break; + case '8': + scr_cursor(RESTORE); + break; + case '=': + case '>': + PrivMode((ch == '='), PrivMode_aplKP); + break; + case '@': + (void) cmd_getc(); + break; + case 'D': + scr_index(UP); + break; + case 'E': + scr_add_lines((unsigned char *) "\n\r", 1, 2); + break; + case 'G': + if ((ch = cmd_getc()) == 'Q') { /* query graphics */ + tt_printf((unsigned char *) "\033G0\n"); /* no graphics */ + } else { + do { + ch = cmd_getc(); + } while (ch != ':'); + } + break; + case 'H': + scr_set_tab(1); + break; + case 'M': + scr_index(DN); + break; + case 'Z': + tt_printf((unsigned char *) ESCZ_ANSWER); + break; + case '[': + process_csi_seq(); + break; + case ']': + process_xterm_seq(); + break; + case 'c': + scr_poweron(); + break; + case 'n': + scr_charset_choose(2); + break; + case 'o': + scr_charset_choose(3); + break; } } @@ -1262,213 +1264,214 @@ process_csi_seq(void) return; switch (ch) { - case '@': - scr_insdel_chars((arg[0] ? arg[0] : 1), INSERT); - break; - case 'A': - case 'e': /* Cursor up n lines "\e[A" */ - scr_gotorc((arg[0] ? -arg[0] : -1), 0, RELATIVE); - break; - case 'B': /* Cursor down n lines "\e[B" */ - scr_gotorc((arg[0] ? +arg[0] : +1), 0, RELATIVE); - break; - case 'C': - case 'a': /* Cursor right n columns "\e[C" */ - scr_gotorc(0, (arg[0] ? +arg[0] : +1), RELATIVE); - break; - case 'D': /* Cursor left n columns "\e[D" */ - scr_gotorc(0, (arg[0] ? -arg[0] : -1), RELATIVE); - break; - case 'E': /* Cursor down n lines and to first column "\e[E" */ - scr_gotorc((arg[0] ? +arg[0] : +1), 0, R_RELATIVE); - break; - case 'F': /* Cursor up n lines and to first column "\e[F" */ - scr_gotorc((arg[0] ? -arg[0] : -1), 0, R_RELATIVE); - break; - case 'G': - case '`': /* Cursor to column n "\e[G" */ - scr_gotorc(0, (arg[0] ? arg[0] - 1 : +1), R_RELATIVE); - break; - case 'H': - case 'f': /* Cursor to row r, column c "\e[;H" */ - switch (nargs) { - case 0: - scr_gotorc(0, 0, 0); - break; - case 1: - scr_gotorc((arg[0] ? arg[0] - 1 : 0), 0, 0); - break; - default: - scr_gotorc(arg[0] - 1, arg[1] - 1, 0); - break; - } - break; - case 'I': /* Tab right n tab stops "\e[I" */ - scr_tab(arg[0] ? +arg[0] : +1); - break; - case 'J': /* Clear part or all of screen, depending on n "\e[J" */ - scr_erase_screen(arg[0]); - break; - case 'K': /* Clear part or all of line, depending on n "\e[K" */ - scr_erase_line(arg[0]); - break; - case 'L': - scr_insdel_lines((arg[0] ? arg[0] : 1), INSERT); - break; - case 'M': - scr_insdel_lines((arg[0] ? arg[0] : 1), DELETE); - break; - case 'P': - scr_insdel_chars((arg[0] ? arg[0] : 1), DELETE); - break; - case 'W': - switch (arg[0]) { - case 0: - scr_set_tab(1); - break; /* = ESC H */ - case 2: - scr_set_tab(0); - break; /* = ESC [ 0 g */ - case 5: - scr_set_tab(-1); - break; /* = ESC [ 3 g */ - } - break; - case 'X': - scr_insdel_chars((arg[0] ? arg[0] : 1), ERASE); - break; - case 'Z': /* Tab left n tab stops "\e[Z" */ - scr_tab(arg[0] ? -arg[0] : -1); - break; + case '@': + scr_insdel_chars((arg[0] ? arg[0] : 1), INSERT); + break; + case 'A': + case 'e': /* Cursor up n lines "\e[A" */ + scr_gotorc((arg[0] ? -arg[0] : -1), 0, RELATIVE); + break; + case 'B': /* Cursor down n lines "\e[B" */ + scr_gotorc((arg[0] ? +arg[0] : +1), 0, RELATIVE); + break; + case 'C': + case 'a': /* Cursor right n columns "\e[C" */ + scr_gotorc(0, (arg[0] ? +arg[0] : +1), RELATIVE); + break; + case 'D': /* Cursor left n columns "\e[D" */ + scr_gotorc(0, (arg[0] ? -arg[0] : -1), RELATIVE); + break; + case 'E': /* Cursor down n lines and to first column "\e[E" */ + scr_gotorc((arg[0] ? +arg[0] : +1), 0, R_RELATIVE); + break; + case 'F': /* Cursor up n lines and to first column "\e[F" */ + scr_gotorc((arg[0] ? -arg[0] : -1), 0, R_RELATIVE); + break; + case 'G': + case '`': /* Cursor to column n "\e[G" */ + scr_gotorc(0, (arg[0] ? arg[0] - 1 : +1), R_RELATIVE); + break; + case 'H': + case 'f': /* Cursor to row r, column c "\e[;H" */ + switch (nargs) { + case 0: + scr_gotorc(0, 0, 0); + break; + case 1: + scr_gotorc((arg[0] ? arg[0] - 1 : 0), 0, 0); + break; + default: + scr_gotorc(arg[0] - 1, arg[1] - 1, 0); + break; + } + break; + case 'I': /* Tab right n tab stops "\e[I" */ + scr_tab(arg[0] ? +arg[0] : +1); + break; + case 'J': /* Clear part or all of screen, depending on n "\e[J" */ + scr_erase_screen(arg[0]); + break; + case 'K': /* Clear part or all of line, depending on n "\e[K" */ + scr_erase_line(arg[0]); + break; + case 'L': + scr_insdel_lines((arg[0] ? arg[0] : 1), INSERT); + break; + case 'M': + scr_insdel_lines((arg[0] ? arg[0] : 1), DELETE); + break; + case 'P': + scr_insdel_chars((arg[0] ? arg[0] : 1), DELETE); + break; + case 'W': + switch (arg[0]) { + case 0: + scr_set_tab(1); + break; /* = ESC H */ + case 2: + scr_set_tab(0); + break; /* = ESC [ 0 g */ + case 5: + scr_set_tab(-1); + break; /* = ESC [ 3 g */ + } + break; + case 'X': + scr_insdel_chars((arg[0] ? arg[0] : 1), ERASE); + break; + case 'Z': /* Tab left n tab stops "\e[Z" */ + scr_tab(arg[0] ? -arg[0] : -1); + break; - case 'c': - /* TODO: A different response should be sent depending on the value of - priv and of arg[0], but what should those reponses be? */ + case 'c': + /* TODO: A different response should be sent depending on the value of + priv and of arg[0], but what should those reponses be? */ #ifndef NO_VT100_ANS - tt_printf((unsigned char *) VT100_ANS); + tt_printf((unsigned char *) VT100_ANS); #endif - break; - case 'd': /* Cursor to row n "\e[d" */ - scr_gotorc((arg[0] ? arg[0] - 1 : +1), 0, C_RELATIVE); - break; - case 'g': - switch (arg[0]) { - case 0: - scr_set_tab(0); - break; /* delete tab */ - case 3: - scr_set_tab(-1); - break; /* clear all tabs */ - } - break; + break; + case 'd': /* Cursor to row n "\e[d" */ + scr_gotorc((arg[0] ? arg[0] - 1 : +1), 0, C_RELATIVE); + break; + case 'g': + switch (arg[0]) { + case 0: + scr_set_tab(0); + break; /* delete tab */ + case 3: + scr_set_tab(-1); + break; /* clear all tabs */ + } + break; #ifdef PRINTPIPE - case 'i': - switch (arg[0]) { - case 0: - scr_printscreen(0); /* Print screen "\e[0i" */ - break; - case 5: - process_print_pipe(); /* Start printing to print pipe "\e[5i" */ - break; - } - break; + case 'i': + switch (arg[0]) { + case 0: + scr_printscreen(0); /* Print screen "\e[0i" */ + break; + case 5: + process_print_pipe(); /* Start printing to print pipe "\e[5i" */ + break; + } + break; #endif - case 'm': - process_sgr_mode(nargs, arg); - break; - case 'n': /* request for information */ - switch (arg[0]) { - case 5: - tt_printf((unsigned char *) "\033[0n"); - break; /* ready */ - case 6: - scr_report_position(); - break; + case 'm': + process_sgr_mode(nargs, arg); + break; + case 'n': /* request for information */ + switch (arg[0]) { + case 5: + tt_printf((unsigned char *) "\033[0n"); + break; /* ready */ + case 6: + scr_report_position(); + break; #if defined (ENABLE_DISPLAY_ANSWER) - case 7: - tt_write((unsigned char *) display_name, strlen(display_name)); - tt_write("\n", 1); - break; + case 7: + tt_write((unsigned char *) display_name, strlen(display_name)); + tt_write("\n", 1); + break; #endif - case 8: - xterm_seq(ESCSEQ_XTERM_TITLE, APL_NAME "-" VERSION); - break; - case 9: + case 8: + xterm_seq(ESCSEQ_XTERM_TITLE, APL_NAME "-" VERSION); + break; + case 9: #ifdef PIXMAP_OFFSET - if (image_mode_is(image_bg, MODE_TRANS)) { - char tbuff[70]; - char shading = 0; - unsigned long tint = 0xffffff; + if (image_mode_is(image_bg, MODE_TRANS)) { + char tbuff[70]; + char shading = 0; + unsigned long tint = 0xffffff; - if (images[image_bg].current->iml->mod) { - shading = images[image_bg].current->iml->mod->brightness / 0xff * 100; - } - if (images[image_bg].current->iml->rmod) { - tint = (tint & 0x00ffff) | ((images[image_bg].current->iml->rmod->brightness & 0xff) << 16); - } - if (images[image_bg].current->iml->gmod) { - tint = (tint & 0xff00ff) | ((images[image_bg].current->iml->gmod->brightness & 0xff) << 8); - } - if (images[image_bg].current->iml->bmod) { - tint = (tint & 0xffff00) | (images[image_bg].current->iml->bmod->brightness & 0xff); - } - snprintf(tbuff, sizeof(tbuff), APL_NAME "-" VERSION ": Transparent - %d%% shading - 0x%06lx tint mask", shading, tint); - xterm_seq(ESCSEQ_XTERM_TITLE, tbuff); - } else + if (images[image_bg].current->iml->mod) { + shading = images[image_bg].current->iml->mod->brightness / 0xff * 100; + } + if (images[image_bg].current->iml->rmod) { + tint = (tint & 0x00ffff) | ((images[image_bg].current->iml->rmod->brightness & 0xff) << 16); + } + if (images[image_bg].current->iml->gmod) { + tint = (tint & 0xff00ff) | ((images[image_bg].current->iml->gmod->brightness & 0xff) << 8); + } + if (images[image_bg].current->iml->bmod) { + tint = (tint & 0xffff00) | (images[image_bg].current->iml->bmod->brightness & 0xff); + } + snprintf(tbuff, sizeof(tbuff), APL_NAME "-" VERSION ": Transparent - %d%% shading - 0x%06lx tint mask", + shading, tint); + xterm_seq(ESCSEQ_XTERM_TITLE, tbuff); + } else #endif #ifdef PIXMAP_SUPPORT - { - char *tbuff; - unsigned short len; + { + char *tbuff; + unsigned short len; - if (background_is_pixmap()) { - const char *fname; + if (background_is_pixmap()) { + const char *fname; - imlib_context_set_image(images[image_bg].current->iml->im); - fname = imlib_image_get_filename(); - len = strlen(fname) + sizeof(APL_NAME) + sizeof(VERSION) + 5; - tbuff = MALLOC(len); - snprintf(tbuff, len, APL_NAME "-" VERSION ": %s", fname); - xterm_seq(ESCSEQ_XTERM_TITLE, tbuff); - FREE(tbuff); - } else { - xterm_seq(ESCSEQ_XTERM_TITLE, APL_NAME "-" VERSION ": No Pixmap"); + imlib_context_set_image(images[image_bg].current->iml->im); + fname = imlib_image_get_filename(); + len = strlen(fname) + sizeof(APL_NAME) + sizeof(VERSION) + 5; + tbuff = MALLOC(len); + snprintf(tbuff, len, APL_NAME "-" VERSION ": %s", fname); + xterm_seq(ESCSEQ_XTERM_TITLE, tbuff); + FREE(tbuff); + } else { + xterm_seq(ESCSEQ_XTERM_TITLE, APL_NAME "-" VERSION ": No Pixmap"); + } } - } #endif /* PIXMAP_SUPPORT */ + break; + } + break; + case 'r': /* set top and bottom margins */ + if (priv != '?') { + if (nargs < 2 || arg[0] >= arg[1]) + scr_scroll_region(0, 10000); + else + scr_scroll_region(arg[0] - 1, arg[1] - 1); break; - } - break; - case 'r': /* set top and bottom margins */ - if (priv != '?') { - if (nargs < 2 || arg[0] >= arg[1]) - scr_scroll_region(0, 10000); - else - scr_scroll_region(arg[0] - 1, arg[1] - 1); - break; - } - /* drop */ - case 't': - if (priv != '?') { - process_window_mode(nargs, arg); - break; - } - /* drop */ - case 's': - if (ch == 's' && !nargs) { - scr_cursor(SAVE); - break; - } - /* drop */ - case 'h': - case 'l': - process_terminal_mode(ch, priv, nargs, arg); - break; - case 'u': - if (!nargs) { - scr_cursor(RESTORE); - } - break; + } + /* drop */ + case 't': + if (priv != '?') { + process_window_mode(nargs, arg); + break; + } + /* drop */ + case 's': + if (ch == 's' && !nargs) { + scr_cursor(SAVE); + break; + } + /* drop */ + case 'h': + case 'l': + process_terminal_mode(ch, priv, nargs, arg); + break; + case 'u': + if (!nargs) { + scr_cursor(RESTORE); + } + break; } } @@ -1516,10 +1519,10 @@ process_xterm_seq(void) if (ch == '\t') ch = ' '; /* translate '\t' to space */ else if (ch < ' ') { - if (ch == 27 && (ch = cmd_getc()) == '\\') /* ESC \ (ST) is String Terminator in Xterm */ - break; + if (ch == 27 && (ch = cmd_getc()) == '\\') /* ESC \ (ST) is String Terminator in Xterm */ + break; return; /* control character - exit */ - } + } if (n < sizeof(string) - 1) string[n++] = ch; } @@ -1547,17 +1550,17 @@ process_xterm_seq(void) return; } switch (arg) { - case 'l': - xterm_seq(ESCSEQ_XTERM_TITLE, (char *) string); - break; - case 'L': - xterm_seq(ESCSEQ_XTERM_ICONNAME, (char *) string); - break; - case 'I': - set_icon_pixmap((char *) string, NULL); - break; - default: - break; + case 'l': + xterm_seq(ESCSEQ_XTERM_TITLE, (char *) string); + break; + case 'L': + xterm_seq(ESCSEQ_XTERM_ICONNAME, (char *) string); + break; + case 'I': + set_icon_pixmap((char *) string, NULL); + break; + default: + break; } } } @@ -1574,6 +1577,7 @@ process_window_mode(unsigned int nargs, int args[]) int dummy_x, dummy_y; unsigned int dummy_border, dummy_depth; char buff[1024]; + #ifdef ENABLE_NAME_REPORTING_ESCAPES char *name; #endif @@ -1586,86 +1590,87 @@ process_window_mode(unsigned int nargs, int args[]) for (i = 0; i < nargs; i++) { switch (args[i]) { - case 1: - XMapRaised(Xdisplay, TermWin.parent); - break; - case 2: - XIconifyWindow(Xdisplay, TermWin.parent, Xscreen); - break; - case 3: - if (i + 2 >= nargs) - return; /* Make sure there are 2 args left */ - x = args[++i]; - y = args[++i]; - if (((unsigned int) x > (unsigned int) scr->width) || ((unsigned int) y > (unsigned int) scr->height)) - return; /* Don't move off-screen */ - XMoveWindow(Xdisplay, TermWin.parent, x, y); - break; - case 4: - if (i + 2 >= nargs) - return; /* Make sure there are 2 args left */ - y = args[++i]; - x = args[++i]; - BOUND(y, szHint.min_height, scr->height); - BOUND(x, szHint.min_width, scr->width); - XResizeWindow(Xdisplay, TermWin.parent, x, y); - break; - case 5: - XRaiseWindow(Xdisplay, TermWin.parent); - break; - case 6: - XLowerWindow(Xdisplay, TermWin.parent); - break; - case 7: - XClearWindow(Xdisplay, TermWin.vt); - XSync(Xdisplay, False); - scr_touch(); - scr_refresh(DEFAULT_REFRESH); - break; - case 8: - if (i + 2 >= nargs) - return; /* Make sure there are 2 args left */ - y = args[++i]; - x = args[++i]; - BOUND(y, 1, scr->height / TermWin.fheight); - BOUND(x, 1, scr->width / TermWin.fwidth); - XResizeWindow(Xdisplay, TermWin.parent, - Width2Pixel(x) + 2 * TermWin.internalBorder + (scrollbar_is_visible()? scrollbar_trough_width() : 0), - Height2Pixel(y) + 2 * TermWin.internalBorder); - break; - case 11: - break; - case 13: - XTranslateCoordinates(Xdisplay, TermWin.parent, Xroot, 0, 0, &x, &y, &dummy_child); - snprintf(buff, sizeof(buff), "\033[3;%d;%dt", x, y); - tt_write((unsigned char *) buff, strlen(buff)); - break; - case 14: - /* Store current width and height in x and y */ - XGetGeometry(Xdisplay, TermWin.parent, &dummy_child, &dummy_x, &dummy_y, (unsigned int *) (&x), (unsigned int *) (&y), &dummy_border, &dummy_depth); - snprintf(buff, sizeof(buff), "\033[4;%d;%dt", y, x); - tt_write((unsigned char *) buff, strlen(buff)); - break; - case 18: - snprintf(buff, sizeof(buff), "\033[8;%d;%dt", TERM_WINDOW_GET_REPORTED_ROWS(), TERM_WINDOW_GET_REPORTED_COLS()); - tt_write((unsigned char *) buff, strlen(buff)); - break; + case 1: + XMapRaised(Xdisplay, TermWin.parent); + break; + case 2: + XIconifyWindow(Xdisplay, TermWin.parent, Xscreen); + break; + case 3: + if (i + 2 >= nargs) + return; /* Make sure there are 2 args left */ + x = args[++i]; + y = args[++i]; + if (((unsigned int) x > (unsigned int) scr->width) || ((unsigned int) y > (unsigned int) scr->height)) + return; /* Don't move off-screen */ + XMoveWindow(Xdisplay, TermWin.parent, x, y); + break; + case 4: + if (i + 2 >= nargs) + return; /* Make sure there are 2 args left */ + y = args[++i]; + x = args[++i]; + BOUND(y, szHint.min_height, scr->height); + BOUND(x, szHint.min_width, scr->width); + XResizeWindow(Xdisplay, TermWin.parent, x, y); + break; + case 5: + XRaiseWindow(Xdisplay, TermWin.parent); + break; + case 6: + XLowerWindow(Xdisplay, TermWin.parent); + break; + case 7: + XClearWindow(Xdisplay, TermWin.vt); + XSync(Xdisplay, False); + scr_touch(); + scr_refresh(DEFAULT_REFRESH); + break; + case 8: + if (i + 2 >= nargs) + return; /* Make sure there are 2 args left */ + y = args[++i]; + x = args[++i]; + BOUND(y, 1, scr->height / TermWin.fheight); + BOUND(x, 1, scr->width / TermWin.fwidth); + XResizeWindow(Xdisplay, TermWin.parent, + Width2Pixel(x) + 2 * TermWin.internalBorder + (scrollbar_is_visible()? scrollbar_trough_width() : 0), + Height2Pixel(y) + 2 * TermWin.internalBorder); + break; + case 11: + break; + case 13: + XTranslateCoordinates(Xdisplay, TermWin.parent, Xroot, 0, 0, &x, &y, &dummy_child); + snprintf(buff, sizeof(buff), "\033[3;%d;%dt", x, y); + tt_write((unsigned char *) buff, strlen(buff)); + break; + case 14: + /* Store current width and height in x and y */ + XGetGeometry(Xdisplay, TermWin.parent, &dummy_child, &dummy_x, &dummy_y, (unsigned int *) (&x), + (unsigned int *) (&y), &dummy_border, &dummy_depth); + snprintf(buff, sizeof(buff), "\033[4;%d;%dt", y, x); + tt_write((unsigned char *) buff, strlen(buff)); + break; + case 18: + snprintf(buff, sizeof(buff), "\033[8;%d;%dt", TERM_WINDOW_GET_REPORTED_ROWS(), TERM_WINDOW_GET_REPORTED_COLS()); + tt_write((unsigned char *) buff, strlen(buff)); + break; #ifdef ENABLE_NAME_REPORTING_ESCAPES - case 20: - XGetIconName(Xdisplay, TermWin.parent, &name); - snprintf(buff, sizeof(buff), "\033]L%s\033\\", name); - tt_write((unsigned char *) buff, strlen(buff)); - XFree(name); - break; - case 21: - XFetchName(Xdisplay, TermWin.parent, &name); - snprintf(buff, sizeof(buff), "\033]l%s\033\\", name); - tt_write((unsigned char *) buff, strlen(buff)); - XFree(name); - break; + case 20: + XGetIconName(Xdisplay, TermWin.parent, &name); + snprintf(buff, sizeof(buff), "\033]L%s\033\\", name); + tt_write((unsigned char *) buff, strlen(buff)); + XFree(name); + break; + case 21: + XFetchName(Xdisplay, TermWin.parent, &name); + snprintf(buff, sizeof(buff), "\033]l%s\033\\", name); + tt_write((unsigned char *) buff, strlen(buff)); + XFree(name); + break; #endif - default: - break; + default: + break; } } } @@ -1690,149 +1695,149 @@ process_terminal_mode(int mode, int priv, unsigned int nargs, int arg[]) /* make lo/hi boolean */ switch (mode) { - case 'l': - mode = 0; - break; - case 'h': - mode = 1; - break; + case 'l': + mode = 0; + break; + case 'h': + mode = 1; + break; } switch (priv) { - case 0: - if (mode && mode != 1) - return; /* only do high/low */ - for (i = 0; i < nargs; i++) - switch (arg[i]) { - case 4: - scr_insert_mode(mode); - break; - /* case 38: TEK mode */ - } - break; + case 0: + if (mode && mode != 1) + return; /* only do high/low */ + for (i = 0; i < nargs; i++) + switch (arg[i]) { + case 4: + scr_insert_mode(mode); + break; + /* case 38: TEK mode */ + } + break; - case '?': - for (i = 0; i < nargs; i++) - switch (arg[i]) { - case 1: /* application cursor keys */ - PrivCases(PrivMode_aplCUR); - break; + case '?': + for (i = 0; i < nargs; i++) + switch (arg[i]) { + case 1: /* application cursor keys */ + PrivCases(PrivMode_aplCUR); + break; - /* case 2: - reset charsets to USASCII */ + /* case 2: - reset charsets to USASCII */ - case 3: /* 80/132 */ - PrivCases(PrivMode_132); - if (PrivateModes & PrivMode_132OK) - set_width(state ? 132 : 80); - break; + case 3: /* 80/132 */ + PrivCases(PrivMode_132); + if (PrivateModes & PrivMode_132OK) + set_width(state ? 132 : 80); + break; - /* case 4: - smooth scrolling */ + /* case 4: - smooth scrolling */ - case 5: /* reverse video */ - PrivCases(PrivMode_rVideo); - scr_rvideo_mode(state); - break; + case 5: /* reverse video */ + PrivCases(PrivMode_rVideo); + scr_rvideo_mode(state); + break; - case 6: /* relative/absolute origins */ - PrivCases(PrivMode_relOrigin); - scr_relative_origin(state); - break; + case 6: /* relative/absolute origins */ + PrivCases(PrivMode_relOrigin); + scr_relative_origin(state); + break; - case 7: /* autowrap */ - PrivCases(PrivMode_Autowrap); - scr_autowrap(state); - break; + case 7: /* autowrap */ + PrivCases(PrivMode_Autowrap); + scr_autowrap(state); + break; - /* case 8: - auto repeat, can't do on a per window basis */ + /* case 8: - auto repeat, can't do on a per window basis */ - case 9: /* X10 mouse reporting */ - PrivCases(PrivMode_MouseX10); - /* orthogonal */ - if (PrivateModes & PrivMode_MouseX10) - PrivateModes &= ~(PrivMode_MouseX11); - break; + case 9: /* X10 mouse reporting */ + PrivCases(PrivMode_MouseX10); + /* orthogonal */ + if (PrivateModes & PrivMode_MouseX10) + PrivateModes &= ~(PrivMode_MouseX11); + break; - case 25: /* visible/invisible cursor */ - PrivCases(PrivMode_VisibleCursor); - scr_cursor_visible(state); - break; + case 25: /* visible/invisible cursor */ + PrivCases(PrivMode_VisibleCursor); + scr_cursor_visible(state); + break; - case 30: - PrivCases(PrivMode_scrollbar); - map_scrollbar(state); - break; + case 30: + PrivCases(PrivMode_scrollbar); + map_scrollbar(state); + break; - case 35: - PrivCases(PrivMode_ShiftKeys); - break; + case 35: + PrivCases(PrivMode_ShiftKeys); + break; - case 40: /* 80 <--> 132 mode */ - PrivCases(PrivMode_132OK); - break; + case 40: /* 80 <--> 132 mode */ + PrivCases(PrivMode_132OK); + break; - case 47: /* secondary screen */ - PrivCases(PrivMode_Screen); - scr_change_screen(state); - break; + case 47: /* secondary screen */ + PrivCases(PrivMode_Screen); + scr_change_screen(state); + break; - case 66: /* application key pad */ - PrivCases(PrivMode_aplKP); - break; + case 66: /* application key pad */ + PrivCases(PrivMode_aplKP); + break; - case 67: - PrivCases(PrivMode_BackSpace); - break; + case 67: + PrivCases(PrivMode_BackSpace); + break; - case 1000: /* X11 mouse reporting */ - PrivCases(PrivMode_MouseX11); - /* orthogonal */ - if (PrivateModes & PrivMode_MouseX11) - PrivateModes &= ~(PrivMode_MouseX10); - break; + case 1000: /* X11 mouse reporting */ + PrivCases(PrivMode_MouseX11); + /* orthogonal */ + if (PrivateModes & PrivMode_MouseX11) + PrivateModes &= ~(PrivMode_MouseX10); + break; #if 0 - case 1001: - break; /* X11 mouse highlighting */ + case 1001: + break; /* X11 mouse highlighting */ #endif - case 1010: /* Scroll to bottom on TTY output */ - if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_HOME_ON_OUTPUT)) - BITFIELD_CLEAR(vt_options, VT_OPTIONS_HOME_ON_OUTPUT); - else - BITFIELD_SET(vt_options, VT_OPTIONS_HOME_ON_OUTPUT); - break; - case 1012: /* Scroll to bottom on TTY input */ - if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_HOME_ON_INPUT)) - BITFIELD_CLEAR(vt_options, VT_OPTIONS_HOME_ON_INPUT); - else - BITFIELD_SET(vt_options, VT_OPTIONS_HOME_ON_INPUT); - break; + case 1010: /* Scroll to bottom on TTY output */ + if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_HOME_ON_OUTPUT)) + BITFIELD_CLEAR(vt_options, VT_OPTIONS_HOME_ON_OUTPUT); + else + BITFIELD_SET(vt_options, VT_OPTIONS_HOME_ON_OUTPUT); + break; + case 1012: /* Scroll to bottom on TTY input */ + if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_HOME_ON_INPUT)) + BITFIELD_CLEAR(vt_options, VT_OPTIONS_HOME_ON_INPUT); + else + BITFIELD_SET(vt_options, VT_OPTIONS_HOME_ON_INPUT); + break; - case 1047: /* Alternate screen & clear */ - PrivCases(PrivMode_Screen); - if (!state) { - /* Only clear the screen before switching from - secondary to primary. */ - scr_erase_screen(2); - } - scr_change_screen(state); - break; - case 1048: /* Save/restore cursor pos */ - PrivCases(PrivMode_Screen); - scr_cursor(state ? SAVE : RESTORE); - break; - case 1049: /* Alternate screen & cursor */ - PrivCases(PrivMode_Screen); - scr_cursor(state ? SAVE : RESTORE); - if (!state) { - /* Only clear the screen before switching from - secondary to primary. */ - scr_erase_screen(2); - } - scr_change_screen(state); - break; - } - break; + case 1047: /* Alternate screen & clear */ + PrivCases(PrivMode_Screen); + if (!state) { + /* Only clear the screen before switching from + secondary to primary. */ + scr_erase_screen(2); + } + scr_change_screen(state); + break; + case 1048: /* Save/restore cursor pos */ + PrivCases(PrivMode_Screen); + scr_cursor(state ? SAVE : RESTORE); + break; + case 1049: /* Alternate screen & cursor */ + PrivCases(PrivMode_Screen); + scr_cursor(state ? SAVE : RESTORE); + if (!state) { + /* Only clear the screen before switching from + secondary to primary. */ + scr_erase_screen(2); + } + scr_change_screen(state); + break; + } + break; } } @@ -1848,125 +1853,125 @@ process_sgr_mode(unsigned int nargs, int arg[]) } for (i = 0; i < nargs; i++) switch (arg[i]) { - case 0: - scr_rendition(0, ~RS_None); - break; - case 1: - scr_rendition(1, RS_Bold); - break; - case 2: - scr_rendition(1, RS_Dim); - break; - case 3: - scr_rendition(1, RS_Italic); - break; - case 4: - scr_rendition(1, RS_Uline); - break; - case 5: - scr_rendition(1, RS_Blink); - break; - case 6: - scr_rendition(1, RS_Overscore); - break; - case 7: - scr_rendition(1, RS_RVid); - break; - case 8: - scr_rendition(1, RS_Conceal); - break; - case 22: - scr_rendition(0, RS_Bold); - scr_rendition(0, RS_Dim); - break; - case 24: - scr_rendition(0, RS_Uline); - break; - case 25: - scr_rendition(0, RS_Blink); - scr_rendition(0, RS_Overscore); - break; - case 27: - scr_rendition(0, RS_RVid); - break; + case 0: + scr_rendition(0, ~RS_None); + break; + case 1: + scr_rendition(1, RS_Bold); + break; + case 2: + scr_rendition(1, RS_Dim); + break; + case 3: + scr_rendition(1, RS_Italic); + break; + case 4: + scr_rendition(1, RS_Uline); + break; + case 5: + scr_rendition(1, RS_Blink); + break; + case 6: + scr_rendition(1, RS_Overscore); + break; + case 7: + scr_rendition(1, RS_RVid); + break; + case 8: + scr_rendition(1, RS_Conceal); + break; + case 22: + scr_rendition(0, RS_Bold); + scr_rendition(0, RS_Dim); + break; + case 24: + scr_rendition(0, RS_Uline); + break; + case 25: + scr_rendition(0, RS_Blink); + scr_rendition(0, RS_Overscore); + break; + case 27: + scr_rendition(0, RS_RVid); + break; - /* set fg color */ - case 30: - case 31: - case 32: - case 33: - case 34: - case 35: - case 36: - case 37: - scr_color(minColor + (arg[i] - 30), RS_Bold); - break; - case 38: - if (arg[i+1] == 5) { - i += 2; - if (arg[i] >= 0 && arg[i] < 256) - scr_color(arg[i], RS_Bold); - } - break; - /* default fg */ - case 39: - scr_color(restoreFG, RS_Bold); - break; + /* set fg color */ + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + scr_color(minColor + (arg[i] - 30), RS_Bold); + break; + case 38: + if (arg[i + 1] == 5) { + i += 2; + if (arg[i] >= 0 && arg[i] < 256) + scr_color(arg[i], RS_Bold); + } + break; + /* default fg */ + case 39: + scr_color(restoreFG, RS_Bold); + break; - /* set bg color */ - case 40: - case 41: - case 42: - case 43: - case 44: - case 45: - case 46: - case 47: - scr_color(minColor + (arg[i] - 40), RS_Blink); - break; - case 48: - if (arg[i+1] == 5) { - i += 2; - if (arg[i] >= 0 && arg[i] < 256) - scr_color(arg[i], RS_Blink); - } - break; - /* default bg */ - case 49: - scr_color(restoreBG, RS_Blink); - break; + /* set bg color */ + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + scr_color(minColor + (arg[i] - 40), RS_Blink); + break; + case 48: + if (arg[i + 1] == 5) { + i += 2; + if (arg[i] >= 0 && arg[i] < 256) + scr_color(arg[i], RS_Blink); + } + break; + /* default bg */ + case 49: + scr_color(restoreBG, RS_Blink); + break; - /* set fg color - bright */ - case 90: - case 91: - case 92: - case 93: - case 94: - case 95: - case 96: - case 97: - scr_color(minBright + (arg[i] - 90), RS_Bold); - break; - /* default fg */ - case 99: - scr_color(restoreFG, RS_Bold); - break; + /* set fg color - bright */ + case 90: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 97: + scr_color(minBright + (arg[i] - 90), RS_Bold); + break; + /* default fg */ + case 99: + scr_color(restoreFG, RS_Bold); + break; - /* set bg color - bright */ - case 100: - case 101: - case 102: - case 103: - case 104: - case 105: - case 106: - case 107: - scr_color(minBright + (arg[i] - 100), RS_Blink); - break; - /* default bg */ - case 109: - scr_color(restoreBG, RS_Blink); - break; + /* set bg color - bright */ + case 100: + case 101: + case 102: + case 103: + case 104: + case 105: + case 106: + case 107: + scr_color(minBright + (arg[i] - 100), RS_Blink); + break; + /* default bg */ + case 109: + scr_color(restoreBG, RS_Blink); + break; } } @@ -2142,60 +2147,60 @@ xterm_seq(int op, const char *str) #endif switch (op) { - case ESCSEQ_XTERM_NAME: /* 0 */ - set_title(str); /* drop */ - case ESCSEQ_XTERM_ICONNAME: /* 1 */ - set_icon_name(str); - break; - case ESCSEQ_XTERM_TITLE: /* 2 */ - set_title(str); - break; - case ESCSEQ_XTERM_PROP: /* 3 */ - if ((nstr = (char *) strsep(&tnstr, ";")) == NULL) { - break; - } - if ((valptr = strchr(nstr, '=')) != NULL) { - *(valptr++) = 0; - } - set_text_property(TermWin.parent, nstr, valptr); - break; - case ESCSEQ_XTERM_CHANGE_COLOR: /* Changing existing colors 256 */ - while ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - i = (unsigned int) strtoul(nstr, (char **) NULL, 0); - nstr = (char *) strsep(&tnstr, ";"); - if ((i < 256) && (nstr != NULL)) { - D_COLORS(("Changing color : [%d] -> %s\n", i, nstr)); - set_window_color(i, nstr); - } - } - break; - - case ESCSEQ_XTERM_TAKEOVER: /* 5 */ - XSetInputFocus(Xdisplay, TermWin.parent, RevertToParent, CurrentTime); - XRaiseWindow(Xdisplay, TermWin.parent); - break; - - case ESCSEQ_XTERM_ETERMSEQ: /* 6 */ - /* Eterm proprietary escape sequences. See technical reference for details. */ - D_CMD(("Got ESCSEQ_XTERM_ETERMSEQ sequence\n")); - nstr = (char *) strsep(&tnstr, ";"); - eterm_seq_op = (unsigned char) strtol(nstr, (char **) NULL, 10); - D_CMD((" ESCSEQ_XTERM_ETERMSEQ operation is %d\n", eterm_seq_op)); - /* Yes, there is order to the numbers for this stuff. And here it is: - 0-9 Image Class/Mode Configuration - 10-19 Scrollbar/Buttonbar/Menu Configuration - 20-39 Miscellaneous Toggles - 40-49 Foreground/Background Color Configuration - 50-69 Window/Window Manager Configuration/Interaction - 70+ Internal Eterm Operations - */ - switch (eterm_seq_op) { -#ifdef PIXMAP_SUPPORT - case 0: + case ESCSEQ_XTERM_NAME: /* 0 */ + set_title(str); /* drop */ + case ESCSEQ_XTERM_ICONNAME: /* 1 */ + set_icon_name(str); + break; + case ESCSEQ_XTERM_TITLE: /* 2 */ + set_title(str); + break; + case ESCSEQ_XTERM_PROP: /* 3 */ + if ((nstr = (char *) strsep(&tnstr, ";")) == NULL) { + break; + } + if ((valptr = strchr(nstr, '=')) != NULL) { + *(valptr++) = 0; + } + set_text_property(TermWin.parent, nstr, valptr); + break; + case ESCSEQ_XTERM_CHANGE_COLOR: /* Changing existing colors 256 */ + while ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + i = (unsigned int) strtoul(nstr, (char **) NULL, 0); nstr = (char *) strsep(&tnstr, ";"); - if (nstr) { - if (BOOL_OPT_ISTRUE(nstr)) { - D_CMD((" Request to enable transparency.\n")); + if ((i < 256) && (nstr != NULL)) { + D_COLORS(("Changing color : [%d] -> %s\n", i, nstr)); + set_window_color(i, nstr); + } + } + break; + + case ESCSEQ_XTERM_TAKEOVER: /* 5 */ + XSetInputFocus(Xdisplay, TermWin.parent, RevertToParent, CurrentTime); + XRaiseWindow(Xdisplay, TermWin.parent); + break; + + case ESCSEQ_XTERM_ETERMSEQ: /* 6 */ + /* Eterm proprietary escape sequences. See technical reference for details. */ + D_CMD(("Got ESCSEQ_XTERM_ETERMSEQ sequence\n")); + nstr = (char *) strsep(&tnstr, ";"); + eterm_seq_op = (unsigned char) strtol(nstr, (char **) NULL, 10); + D_CMD((" ESCSEQ_XTERM_ETERMSEQ operation is %d\n", eterm_seq_op)); + /* Yes, there is order to the numbers for this stuff. And here it is: + 0-9 Image Class/Mode Configuration + 10-19 Scrollbar/Buttonbar/Menu Configuration + 20-39 Miscellaneous Toggles + 40-49 Foreground/Background Color Configuration + 50-69 Window/Window Manager Configuration/Interaction + 70+ Internal Eterm Operations + */ + switch (eterm_seq_op) { +#ifdef PIXMAP_SUPPORT + case 0: + nstr = (char *) strsep(&tnstr, ";"); + if (nstr) { + if (BOOL_OPT_ISTRUE(nstr)) { + D_CMD((" Request to enable transparency.\n")); /* *INDENT-OFF* */ FOREACH_IMAGE( if (!image_mode_is(idx, MODE_TRANS) && image_mode_is(idx, ALLOW_TRANS)) { @@ -2207,8 +2212,8 @@ xterm_seq(int op, const char *str) } ); /* *INDENT-ON* */ - } else if (BOOL_OPT_ISFALSE(nstr)) { - D_CMD((" Request to disable transparency.\n")); + } else if (BOOL_OPT_ISFALSE(nstr)) { + D_CMD((" Request to disable transparency.\n")); /* *INDENT-OFF* */ FOREACH_IMAGE( if (image_mode_is(idx, MODE_TRANS)) { @@ -2220,12 +2225,12 @@ xterm_seq(int op, const char *str) } ); /* *INDENT-ON* */ + } else { + D_CMD((" Bad boolean value in transparency request.\n")); + break; + } } else { - D_CMD((" Bad boolean value in transparency request.\n")); - break; - } - } else { - D_CMD((" Request to toggle transparency.\n")); + D_CMD((" Request to toggle transparency.\n")); /* *INDENT-OFF* */ FOREACH_IMAGE( if (!image_mode_is(idx, MODE_TRANS) && image_mode_is(idx, ALLOW_TRANS)) { @@ -2243,42 +2248,59 @@ xterm_seq(int op, const char *str) } ); /* *INDENT-ON* */ - } - redraw_all_images(); - break; - case 1: - changed = 0; - for (; 1;) { - if ((color = (char *) strsep(&tnstr, ";")) == NULL) { - break; } - which = image_max; - FOREACH_IMAGE(if (!strcasecmp(color, (get_image_type(idx) + 6))) { - which = idx; break;} - ); - if (which != image_max) { + redraw_all_images(); + break; + case 1: + changed = 0; + for (; 1;) { if ((color = (char *) strsep(&tnstr, ";")) == NULL) { break; } - } else { - which = image_bg; - } - if ((mod = (char *) strsep(&tnstr, ";")) == NULL) { - break; - } - if (!strcasecmp(mod, "clear")) { - imlib_t *iml = images[which].current->iml; - - D_CMD(("Clearing the %s color modifier of the %s image\n", color, get_image_type(which))); - if (!strcasecmp(color, "image")) { - FREE(iml->mod); - } else if (!strcasecmp(color, "red")) { - FREE(iml->rmod); - } else if (!strcasecmp(color, "green")) { - FREE(iml->gmod); - } else if (!strcasecmp(color, "blue")) { - FREE(iml->bmod); + which = image_max; + FOREACH_IMAGE(if (!strcasecmp(color, (get_image_type(idx) + 6))) { + which = idx; break;} + ); + if (which != image_max) { + if ((color = (char *) strsep(&tnstr, ";")) == NULL) { + break; + } + } else { + which = image_bg; } + if ((mod = (char *) strsep(&tnstr, ";")) == NULL) { + break; + } + if (!strcasecmp(mod, "clear")) { + imlib_t *iml = images[which].current->iml; + + D_CMD(("Clearing the %s color modifier of the %s image\n", color, get_image_type(which))); + if (!strcasecmp(color, "image")) { + FREE(iml->mod); + } else if (!strcasecmp(color, "red")) { + FREE(iml->rmod); + } else if (!strcasecmp(color, "green")) { + FREE(iml->gmod); + } else if (!strcasecmp(color, "blue")) { + FREE(iml->bmod); + } +# ifdef PIXMAP_OFFSET + if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { + free_desktop_pixmap(); + } else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { + LIBAST_X_FREE_PIXMAP(viewport_pixmap); + viewport_pixmap = None; /* Force the re-read */ + } +# endif + changed = 1; + continue; + } + if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { + break; + } + D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n", + mod, color, get_image_type(which), valptr)); + changed = 1; # ifdef PIXMAP_OFFSET if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { free_desktop_pixmap(); @@ -2287,533 +2309,516 @@ xterm_seq(int op, const char *str) viewport_pixmap = None; /* Force the re-read */ } # endif - changed = 1; - continue; + if (!strcasecmp(color, "image")) { + imlib_t *iml = images[which].current->iml; + + if (iml->mod == NULL) { + iml->mod = create_colormod(); + } + if (!BEG_STRCASECMP(mod, "brightness")) { + iml->mod->brightness = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "contrast")) { + iml->mod->contrast = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "gamma")) { + iml->mod->gamma = (int) strtol(valptr, (char **) NULL, 0); + } + update_cmod(iml->mod); + reload_image(iml); + update_cmod_tables(iml); + + } else if (!strcasecmp(color, "red")) { + imlib_t *iml = images[which].current->iml; + + if (iml->rmod == NULL) { + iml->rmod = create_colormod(); + } + if (!BEG_STRCASECMP(mod, "brightness")) { + iml->rmod->brightness = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "contrast")) { + iml->rmod->contrast = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "gamma")) { + iml->rmod->gamma = (int) strtol(valptr, (char **) NULL, 0); + } + update_cmod(iml->rmod); + reload_image(iml); + update_cmod_tables(iml); + + } else if (!strcasecmp(color, "green")) { + imlib_t *iml = images[which].current->iml; + + if (iml->gmod == NULL) { + iml->gmod = create_colormod(); + } + if (!BEG_STRCASECMP(mod, "brightness")) { + iml->gmod->brightness = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "contrast")) { + iml->gmod->contrast = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "gamma")) { + iml->gmod->gamma = (int) strtol(valptr, (char **) NULL, 0); + } + update_cmod(iml->gmod); + reload_image(iml); + update_cmod_tables(iml); + + } else if (!strcasecmp(color, "blue")) { + imlib_t *iml = images[which].current->iml; + + if (iml->bmod == NULL) { + iml->bmod = create_colormod(); + } + if (!BEG_STRCASECMP(mod, "bright")) { + iml->bmod->brightness = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "contrast")) { + iml->bmod->contrast = (int) strtol(valptr, (char **) NULL, 0); + } else if (!BEG_STRCASECMP(mod, "gamma")) { + iml->bmod->gamma = (int) strtol(valptr, (char **) NULL, 0); + } + update_cmod(iml->bmod); + reload_image(iml); + update_cmod_tables(iml); + } } - if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { - break; + if (changed) { + redraw_all_images(); } - D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n", - mod, color, get_image_type(which), valptr)); - changed = 1; -# ifdef PIXMAP_OFFSET - if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { - free_desktop_pixmap(); - } else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { - LIBAST_X_FREE_PIXMAP(viewport_pixmap); - viewport_pixmap = None; /* Force the re-read */ - } -# endif - if (!strcasecmp(color, "image")) { - imlib_t *iml = images[which].current->iml; - - if (iml->mod == NULL) { - iml->mod = create_colormod(); - } - if (!BEG_STRCASECMP(mod, "brightness")) { - iml->mod->brightness = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "contrast")) { - iml->mod->contrast = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "gamma")) { - iml->mod->gamma = (int) strtol(valptr, (char **) NULL, 0); - } - update_cmod(iml->mod); - reload_image(iml); - update_cmod_tables(iml); - - } else if (!strcasecmp(color, "red")) { - imlib_t *iml = images[which].current->iml; - - if (iml->rmod == NULL) { - iml->rmod = create_colormod(); - } - if (!BEG_STRCASECMP(mod, "brightness")) { - iml->rmod->brightness = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "contrast")) { - iml->rmod->contrast = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "gamma")) { - iml->rmod->gamma = (int) strtol(valptr, (char **) NULL, 0); - } - update_cmod(iml->rmod); - reload_image(iml); - update_cmod_tables(iml); - - } else if (!strcasecmp(color, "green")) { - imlib_t *iml = images[which].current->iml; - - if (iml->gmod == NULL) { - iml->gmod = create_colormod(); - } - if (!BEG_STRCASECMP(mod, "brightness")) { - iml->gmod->brightness = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "contrast")) { - iml->gmod->contrast = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "gamma")) { - iml->gmod->gamma = (int) strtol(valptr, (char **) NULL, 0); - } - update_cmod(iml->gmod); - reload_image(iml); - update_cmod_tables(iml); - - } else if (!strcasecmp(color, "blue")) { - imlib_t *iml = images[which].current->iml; - - if (iml->bmod == NULL) { - iml->bmod = create_colormod(); - } - if (!BEG_STRCASECMP(mod, "bright")) { - iml->bmod->brightness = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "contrast")) { - iml->bmod->contrast = (int) strtol(valptr, (char **) NULL, 0); - } else if (!BEG_STRCASECMP(mod, "gamma")) { - iml->bmod->gamma = (int) strtol(valptr, (char **) NULL, 0); - } - update_cmod(iml->bmod); - reload_image(iml); - update_cmod_tables(iml); - } - } - if (changed) { - redraw_all_images(); - } - break; - case 2: - changed = 0; - which = image_max; - if ((nstr = (char *) strsep(&tnstr, ";")) == NULL || (valptr = (char *) strsep(&tnstr, ";")) == NULL) { break; - } - FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) { - which = idx; break;} - ); - if (which != image_max) { - if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { + case 2: + changed = 0; + which = image_max; + if ((nstr = (char *) strsep(&tnstr, ";")) == NULL || (valptr = (char *) strsep(&tnstr, ";")) == NULL) { break; } - } else { - which = image_bg; - } - D_PIXMAP(("Operation == \"%s\", which == %d, value == \"%s\"\n", nstr, (int) which, valptr)); - if (!strcasecmp(nstr, "shade")) { - imlib_t *iml = images[which].current->iml; - int s; - - s = (int) strtol(valptr, (char **) NULL, 0); - s = ((100 - s) << 8) / 100; - if (s == 0x100) { - if (iml->mod != NULL) { - if (iml->mod->brightness != 0x100) { - iml->mod->brightness = 0x100; - changed = 1; - } - if (iml->mod->contrast == 0x100 && iml->mod->gamma == 0x100) { - FREE(iml->mod); - } - } - } else { - if (iml->mod == NULL) { - iml->mod = create_colormod(); - } - if (iml->mod->brightness != s) { - iml->mod->brightness = s; - changed = 1; - } - } - } else if (!strcasecmp(nstr, "tint")) { - imlib_t *iml = images[which].current->iml; - unsigned long t, r, g, b; - - if (!isdigit(*valptr)) { - t = get_tint_by_color_name(valptr); - } else { - t = (unsigned long) strtoul(valptr, (char **) NULL, 0); - D_PIXMAP(("Got numerical tint 0x%06x\n", t)); - } - r = (t & 0xff0000) >> 16; - if (r == 0xff) { - if (iml->rmod != NULL) { - if (iml->rmod->brightness != 0x100) { - iml->rmod->brightness = 0x100; - changed = 1; - if (iml->rmod->contrast == 0x100 && iml->rmod->gamma == 0x100) { - FREE(iml->rmod); - } - } - } - } else { - if (iml->rmod == NULL) { - iml->rmod = create_colormod(); - } - if (iml->rmod->brightness != (int) r) { - iml->rmod->brightness = r; - changed = 1; - } - } - g = (t & 0xff00) >> 8; - if (g == 0xff) { - if (iml->gmod != NULL) { - if (iml->gmod->brightness != 0x100) { - iml->gmod->brightness = 0x100; - changed = 1; - if (iml->gmod->contrast == 0x100 && iml->gmod->gamma == 0x100) { - FREE(iml->gmod); - } - } - } - } else { - if (iml->gmod == NULL) { - iml->gmod = create_colormod(); - } - if (iml->gmod->brightness != (int) g) { - iml->gmod->brightness = g; - changed = 1; - } - } - b = t & 0xff; - if (b == 0xff) { - if (iml->bmod != NULL) { - if (iml->bmod->brightness != 0x100) { - iml->bmod->brightness = 0x100; - changed = 1; - if (iml->bmod->contrast == 0x100 && iml->bmod->gamma == 0x100) { - FREE(iml->bmod); - } - } - } - } else { - if (iml->bmod == NULL) { - iml->bmod = create_colormod(); - iml->bmod->contrast = iml->bmod->gamma = 0x100; - } - if (iml->bmod->brightness != (int) b) { - iml->bmod->brightness = b; - changed = 1; - } - } - } - if (changed) { - if (image_mode_is(which, MODE_TRANS)) { - free_desktop_pixmap(); - } - redraw_image(which); - } - break; - case 3: -# ifdef PIXMAP_OFFSET - get_desktop_window(); - if (desktop_window == None) { - FOREACH_IMAGE(if (image_mode_is(idx, MODE_TRANS)) { - image_set_mode(idx, MODE_IMAGE); image_allow_mode(idx, ALLOW_IMAGE);} + FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) { + which = idx; break;} ); + if (which != image_max) { + if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { + break; + } + } else { + which = image_bg; + } + D_PIXMAP(("Operation == \"%s\", which == %d, value == \"%s\"\n", nstr, (int) which, valptr)); + if (!strcasecmp(nstr, "shade")) { + imlib_t *iml = images[which].current->iml; + int s; + + s = (int) strtol(valptr, (char **) NULL, 0); + s = ((100 - s) << 8) / 100; + if (s == 0x100) { + if (iml->mod != NULL) { + if (iml->mod->brightness != 0x100) { + iml->mod->brightness = 0x100; + changed = 1; + } + if (iml->mod->contrast == 0x100 && iml->mod->gamma == 0x100) { + FREE(iml->mod); + } + } + } else { + if (iml->mod == NULL) { + iml->mod = create_colormod(); + } + if (iml->mod->brightness != s) { + iml->mod->brightness = s; + changed = 1; + } + } + } else if (!strcasecmp(nstr, "tint")) { + imlib_t *iml = images[which].current->iml; + unsigned long t, r, g, b; + + if (!isdigit(*valptr)) { + t = get_tint_by_color_name(valptr); + } else { + t = (unsigned long) strtoul(valptr, (char **) NULL, 0); + D_PIXMAP(("Got numerical tint 0x%06x\n", t)); + } + r = (t & 0xff0000) >> 16; + if (r == 0xff) { + if (iml->rmod != NULL) { + if (iml->rmod->brightness != 0x100) { + iml->rmod->brightness = 0x100; + changed = 1; + if (iml->rmod->contrast == 0x100 && iml->rmod->gamma == 0x100) { + FREE(iml->rmod); + } + } + } + } else { + if (iml->rmod == NULL) { + iml->rmod = create_colormod(); + } + if (iml->rmod->brightness != (int) r) { + iml->rmod->brightness = r; + changed = 1; + } + } + g = (t & 0xff00) >> 8; + if (g == 0xff) { + if (iml->gmod != NULL) { + if (iml->gmod->brightness != 0x100) { + iml->gmod->brightness = 0x100; + changed = 1; + if (iml->gmod->contrast == 0x100 && iml->gmod->gamma == 0x100) { + FREE(iml->gmod); + } + } + } + } else { + if (iml->gmod == NULL) { + iml->gmod = create_colormod(); + } + if (iml->gmod->brightness != (int) g) { + iml->gmod->brightness = g; + changed = 1; + } + } + b = t & 0xff; + if (b == 0xff) { + if (iml->bmod != NULL) { + if (iml->bmod->brightness != 0x100) { + iml->bmod->brightness = 0x100; + changed = 1; + if (iml->bmod->contrast == 0x100 && iml->bmod->gamma == 0x100) { + FREE(iml->bmod); + } + } + } + } else { + if (iml->bmod == NULL) { + iml->bmod = create_colormod(); + iml->bmod->contrast = iml->bmod->gamma = 0x100; + } + if (iml->bmod->brightness != (int) b) { + iml->bmod->brightness = b; + changed = 1; + } + } + } + if (changed) { + if (image_mode_is(which, MODE_TRANS)) { + free_desktop_pixmap(); + } + redraw_image(which); + } break; - } - get_desktop_pixmap(); - redraw_images_by_mode(MODE_TRANS | MODE_VIEWPORT); + case 3: +# ifdef PIXMAP_OFFSET + get_desktop_window(); + if (desktop_window == None) { + FOREACH_IMAGE(if (image_mode_is(idx, MODE_TRANS)) { + image_set_mode(idx, MODE_IMAGE); image_allow_mode(idx, ALLOW_IMAGE);} + ); + break; + } + get_desktop_pixmap(); + redraw_images_by_mode(MODE_TRANS | MODE_VIEWPORT); # endif - break; + break; #endif - case 10: - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr) { - if (!strcasecmp(nstr, "xterm")) { + case 10: + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr) { + if (!strcasecmp(nstr, "xterm")) { #ifdef XTERM_SCROLLBAR - scrollbar_change_type(SCROLLBAR_XTERM); + scrollbar_change_type(SCROLLBAR_XTERM); #else - print_error("Support for xterm scrollbars was not compiled in. Sorry.\n"); + print_error("Support for xterm scrollbars was not compiled in. Sorry.\n"); #endif - } else if (!strcasecmp(nstr, "next")) { + } else if (!strcasecmp(nstr, "next")) { #ifdef NEXT_SCROLLBAR - scrollbar_change_type(SCROLLBAR_NEXT); + scrollbar_change_type(SCROLLBAR_NEXT); #else - print_error("Support for NeXT scrollbars was not compiled in. Sorry.\n"); + print_error("Support for NeXT scrollbars was not compiled in. Sorry.\n"); #endif - } else if (!strcasecmp(nstr, "motif")) { + } else if (!strcasecmp(nstr, "motif")) { #ifdef MOTIF_SCROLLBAR - scrollbar_change_type(SCROLLBAR_MOTIF); + scrollbar_change_type(SCROLLBAR_MOTIF); #else - print_error("Support for motif scrollbars was not compiled in. Sorry.\n"); + print_error("Support for motif scrollbars was not compiled in. Sorry.\n"); #endif - } else { - print_error("Unrecognized scrollbar type \"%s\".\n", nstr); + } else { + print_error("Unrecognized scrollbar type \"%s\".\n", nstr); + } } - } - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr) { - scrollbar_change_width((unsigned short) strtoul(nstr, (char **) NULL, 0)); - } - break; - case 11: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT); - scr_touch(); - parent_resize(); - break; - case 12: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SCROLLBAR_FLOATING); - scrollbar_reposition_and_always_draw(); - break; - case 13: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SCROLLBAR_POPUP); - break; - case 14: - nstr = (char *) strsep(&tnstr, ";"); - if (!(nstr) || !(*(nstr))) { - bbar_show_all(-1); + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr) { + scrollbar_change_width((unsigned short) strtoul(nstr, (char **) NULL, 0)); + } + break; + case 11: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT); + scr_touch(); parent_resize(); - } else if (BOOL_OPT_ISTRUE(nstr)) { - bbar_show_all(1); - parent_resize(); - } else if (BOOL_OPT_ISFALSE(nstr)) { - bbar_show_all(0); - parent_resize(); - } - break; - case 20: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, vt_options, VT_OPTIONS_VISUAL_BELL); - break; + break; + case 12: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SCROLLBAR_FLOATING); + scrollbar_reposition_and_always_draw(); + break; + case 13: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SCROLLBAR_POPUP); + break; + case 14: + nstr = (char *) strsep(&tnstr, ";"); + if (!(nstr) || !(*(nstr))) { + bbar_show_all(-1); + parent_resize(); + } else if (BOOL_OPT_ISTRUE(nstr)) { + bbar_show_all(1); + parent_resize(); + } else if (BOOL_OPT_ISFALSE(nstr)) { + bbar_show_all(0); + parent_resize(); + } + break; + case 20: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, vt_options, VT_OPTIONS_VISUAL_BELL); + break; #ifdef MAPALERT_OPTION - case 21: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, vt_options, VT_OPTIONS_MAP_ALERT); - break; + case 21: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, vt_options, VT_OPTIONS_MAP_ALERT); + break; #endif - case 22: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_XTERM_SELECT); - break; - case 23: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SELECT_WHOLE_LINE); - break; - case 24: - nstr = (char *) strsep(&tnstr, ";"); - FOREACH_IMAGE(if (!image_mode_is(idx, MODE_VIEWPORT) && image_mode_is(idx, ALLOW_VIEWPORT)) { - image_set_mode(idx, MODE_VIEWPORT);} - ); - redraw_images_by_mode(MODE_VIEWPORT); - break; - case 25: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SELECT_TRAILING_SPACES); - break; - case 26: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, vt_options, VT_OPTIONS_REPORT_AS_KEYSYMS); - break; - case 27: - nstr = (char *) strsep(&tnstr, ";"); - OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_NO_INPUT); - wm_hints = XGetWMHints(Xdisplay, TermWin.parent); - wm_hints->flags |= InputHint; - wm_hints->input = ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_NO_INPUT)) ? False : True); - XSetWMHints(Xdisplay, TermWin.parent, wm_hints); - XFree(wm_hints); - break; - case 40: - nstr = (char *) strsep(&tnstr, ";"); - if (nstr) { - if (XParseColor(Xdisplay, cmap, nstr, &xcol) && XAllocColor(Xdisplay, cmap, &xcol)) { - PixColors[fgColor] = xcol.pixel; - scr_refresh(DEFAULT_REFRESH); + case 22: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_XTERM_SELECT); + break; + case 23: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SELECT_WHOLE_LINE); + break; + case 24: + nstr = (char *) strsep(&tnstr, ";"); + FOREACH_IMAGE(if (!image_mode_is(idx, MODE_VIEWPORT) && image_mode_is(idx, ALLOW_VIEWPORT)) { + image_set_mode(idx, MODE_VIEWPORT);} + ); + redraw_images_by_mode(MODE_VIEWPORT); + break; + case 25: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_SELECT_TRAILING_SPACES); + break; + case 26: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, vt_options, VT_OPTIONS_REPORT_AS_KEYSYMS); + break; + case 27: + nstr = (char *) strsep(&tnstr, ";"); + OPT_SET_OR_TOGGLE(nstr, eterm_options, ETERM_OPTIONS_NO_INPUT); + wm_hints = XGetWMHints(Xdisplay, TermWin.parent); + wm_hints->flags |= InputHint; + wm_hints->input = ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_NO_INPUT)) ? False : True); + XSetWMHints(Xdisplay, TermWin.parent, wm_hints); + XFree(wm_hints); + break; + case 40: + nstr = (char *) strsep(&tnstr, ";"); + if (nstr) { + if (XParseColor(Xdisplay, cmap, nstr, &xcol) && XAllocColor(Xdisplay, cmap, &xcol)) { + PixColors[fgColor] = xcol.pixel; + scr_refresh(DEFAULT_REFRESH); + } } - } - break; - case 41: - nstr = (char *) strsep(&tnstr, ";"); - if (nstr) { - if (XParseColor(Xdisplay, cmap, nstr, &xcol) && XAllocColor(Xdisplay, cmap, &xcol)) { - PixColors[bgColor] = xcol.pixel; - scr_refresh(DEFAULT_REFRESH); + break; + case 41: + nstr = (char *) strsep(&tnstr, ";"); + if (nstr) { + if (XParseColor(Xdisplay, cmap, nstr, &xcol) && XAllocColor(Xdisplay, cmap, &xcol)) { + PixColors[bgColor] = xcol.pixel; + scr_refresh(DEFAULT_REFRESH); + } } - } - break; - case 50: - /* Change desktops */ - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr) { - XClientMessageEvent xev; + break; + case 50: + /* Change desktops */ + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr) { + XClientMessageEvent xev; - rs_desktop = (int) strtol(nstr, (char **) NULL, 0); - xev.type = ClientMessage; - xev.window = TermWin.parent; - xev.message_type = props[PROP_DESKTOP]; - xev.format = 32; - xev.data.l[0] = rs_desktop; - XChangeProperty(Xdisplay, TermWin.parent, xev.message_type, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &rs_desktop, 1); - XSendEvent(Xdisplay, Xroot, False, SubstructureNotifyMask, (XEvent *) & xev); - } - break; - case 51: - /* Change opacity */ - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr) { - XClientMessageEvent xev; - spif_uint32_t tmp; + rs_desktop = (int) strtol(nstr, (char **) NULL, 0); + xev.type = ClientMessage; + xev.window = TermWin.parent; + xev.message_type = props[PROP_DESKTOP]; + xev.format = 32; + xev.data.l[0] = rs_desktop; + XChangeProperty(Xdisplay, TermWin.parent, xev.message_type, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *) &rs_desktop, 1); + XSendEvent(Xdisplay, Xroot, False, SubstructureNotifyMask, (XEvent *) & xev); + } + break; + case 51: + /* Change opacity */ + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr) { + XClientMessageEvent xev; + spif_uint32_t tmp; - tmp = (int) strtol(nstr, (char **) NULL, 0); - if (tmp < 0x100) { - rs_opacity = tmp | (tmp << 24) | (tmp << 16) | (tmp << 8); + tmp = (int) strtol(nstr, (char **) NULL, 0); + if (tmp < 0x100) { + rs_opacity = tmp | (tmp << 24) | (tmp << 16) | (tmp << 8); + } else { + rs_opacity = 0xffffffff; + } + xev.type = ClientMessage; + xev.window = TermWin.parent; + xev.message_type = props[PROP_EWMH_OPACITY]; + xev.format = 32; + xev.data.l[0] = rs_opacity; + XChangeProperty(Xdisplay, TermWin.parent, xev.message_type, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *) &rs_opacity, 1); + XChangeProperty(Xdisplay, TermWin.vt, xev.message_type, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *) &rs_opacity, 1); + XSendEvent(Xdisplay, Xroot, False, SubstructureNotifyMask, (XEvent *) (&xev)); + } + break; + + case 72: + /* Search scrollback buffer for a string. NULL to clear. */ + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr) { + scr_search_scrollback(nstr); } else { - rs_opacity = 0xffffffff; + scr_search_scrollback(NULL); } - xev.type = ClientMessage; - xev.window = TermWin.parent; - xev.message_type = props[PROP_EWMH_OPACITY]; - xev.format = 32; - xev.data.l[0] = rs_opacity; - XChangeProperty(Xdisplay, TermWin.parent, xev.message_type, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &rs_opacity, 1); - XChangeProperty(Xdisplay, TermWin.vt, xev.message_type, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &rs_opacity, 1); - XSendEvent(Xdisplay, Xroot, False, SubstructureNotifyMask, (XEvent *) (&xev)); - } - break; + break; - case 72: - /* Search scrollback buffer for a string. NULL to clear. */ - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr) { - scr_search_scrollback(nstr); - } else { - scr_search_scrollback(NULL); - } - break; + case 80: + /* Set debugging level */ + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr) { + DEBUG_LEVEL = (unsigned int) strtoul(nstr, (char **) NULL, 0); + } + break; - case 80: - /* Set debugging level */ - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr) { - DEBUG_LEVEL = (unsigned int) strtoul(nstr, (char **) NULL, 0); - } - break; - - default: - break; - } - break; + default: + break; + } + break; #ifdef XTERM_COLOR_CHANGE - case ESCSEQ_XTERM_FGCOLOR: /* 10 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - set_window_color(fgColor, nstr); - } - /* drop */ - case ESCSEQ_XTERM_BGCOLOR: /* 11 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - set_window_color(bgColor, nstr); - } - /* drop */ - case ESCSEQ_XTERM_CURSOR_COLOR: /* 12 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + case ESCSEQ_XTERM_FGCOLOR: /* 10 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + set_window_color(fgColor, nstr); + } + /* drop */ + case ESCSEQ_XTERM_BGCOLOR: /* 11 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + set_window_color(bgColor, nstr); + } + /* drop */ + case ESCSEQ_XTERM_CURSOR_COLOR: /* 12 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { # ifndef NO_CURSORCOLOR - set_window_color(cursorColor, nstr); + set_window_color(cursorColor, nstr); # endif - } - /* drop */ - case ESCSEQ_XTERM_PTR_FGCOLOR: /* 13 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - set_pointer_colors(nstr, NULL); - } - /* drop */ - case ESCSEQ_XTERM_PTR_BGCOLOR: /* 14 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - /* UNSUPPORTED */ - } - /* drop */ - case ESCSEQ_XTERM_TEK_FGCOLOR: /* 15 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - /* UNSUPPORTED */ - } - /* drop */ - case ESCSEQ_XTERM_TEK_BGCOLOR: /* 16 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - /* UNSUPPORTED */ - } - /* drop */ - case ESCSEQ_XTERM_HILIGHT_COLOR: /* 17 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - /* UNSUPPORTED */ - } - /* drop */ - case ESCSEQ_XTERM_BOLD_COLOR: /* 18 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - set_window_color(colorBD, nstr); - } - /* drop */ - case ESCSEQ_XTERM_ULINE_COLOR: /* 19 */ - if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { - set_window_color(colorUL, nstr); - } + } + /* drop */ + case ESCSEQ_XTERM_PTR_FGCOLOR: /* 13 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + set_pointer_colors(nstr, NULL); + } + /* drop */ + case ESCSEQ_XTERM_PTR_BGCOLOR: /* 14 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + /* UNSUPPORTED */ + } + /* drop */ + case ESCSEQ_XTERM_TEK_FGCOLOR: /* 15 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + /* UNSUPPORTED */ + } + /* drop */ + case ESCSEQ_XTERM_TEK_BGCOLOR: /* 16 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + /* UNSUPPORTED */ + } + /* drop */ + case ESCSEQ_XTERM_HILIGHT_COLOR: /* 17 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + /* UNSUPPORTED */ + } + /* drop */ + case ESCSEQ_XTERM_BOLD_COLOR: /* 18 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + set_window_color(colorBD, nstr); + } + /* drop */ + case ESCSEQ_XTERM_ULINE_COLOR: /* 19 */ + if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) { + set_window_color(colorUL, nstr); + } #endif - break; + break; - case ESCSEQ_XTERM_PIXMAP: /* 20 */ + case ESCSEQ_XTERM_PIXMAP: /* 20 */ #ifdef PIXMAP_SUPPORT - FOREACH_IMAGE(if (!image_mode_is(idx, MODE_IMAGE) && image_mode_is(idx, ALLOW_IMAGE)) { - image_set_mode(idx, MODE_IMAGE);} - ); - if (!strcmp(str, ";")) { - image_set_mode(image_bg, MODE_SOLID); - bg_needs_update = 1; - } else { - nstr = (char *) strsep(&tnstr, ";"); - if (nstr) { - if (*nstr) { - set_pixmap_scale("", images[image_bg].current->pmap); - bg_needs_update = 1; - load_image(nstr, images[image_bg].current); - } - while ((nstr = (char *) strsep(&tnstr, ";")) && *nstr) { - changed += set_pixmap_scale(nstr, images[image_bg].current->pmap); - scaled = 1; - } - } else { - image_set_mode(image_bg, MODE_SOLID); - bg_needs_update = 1; - } - } - if ((changed) || (bg_needs_update)) { - redraw_image(image_bg); - } + FOREACH_IMAGE(if (!image_mode_is(idx, MODE_IMAGE) && image_mode_is(idx, ALLOW_IMAGE)) { + image_set_mode(idx, MODE_IMAGE);} + ); + if (!strcmp(str, ";")) { + image_set_mode(image_bg, MODE_SOLID); + bg_needs_update = 1; + } else { + nstr = (char *) strsep(&tnstr, ";"); + if (nstr) { + if (*nstr) { + set_pixmap_scale("", images[image_bg].current->pmap); + bg_needs_update = 1; + load_image(nstr, images[image_bg].current); + } + while ((nstr = (char *) strsep(&tnstr, ";")) && *nstr) { + changed += set_pixmap_scale(nstr, images[image_bg].current->pmap); + scaled = 1; + } + } else { + image_set_mode(image_bg, MODE_SOLID); + bg_needs_update = 1; + } + } + if ((changed) || (bg_needs_update)) { + redraw_image(image_bg); + } #endif /* PIXMAP_SUPPORT */ - break; + break; - case ESCSEQ_XTERM_DUMPSCREEN: /* 30 */ + case ESCSEQ_XTERM_DUMPSCREEN: /* 30 */ #if 0 - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr) { - scr_dump_to_file(nstr); - } - break; + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr) { + scr_dump_to_file(nstr); + } + break; #endif - case ESCSEQ_XTERM_RESTOREFG: /* 39 */ + case ESCSEQ_XTERM_RESTOREFG: /* 39 */ #ifdef XTERM_COLOR_CHANGE - set_window_color(fgColor, str); + set_window_color(fgColor, str); #endif - break; - case ESCSEQ_XTERM_RESTOREBG: /* 40 */ + break; + case ESCSEQ_XTERM_RESTOREBG: /* 40 */ #ifdef XTERM_COLOR_CHANGE - set_window_color(bgColor, str); + set_window_color(bgColor, str); #endif - break; - case ESCSEQ_XTERM_LOGFILE: /* 46 */ - nstr = (char *) strsep(&tnstr, ";"); - if (nstr && *nstr && BOOL_OPT_ISTRUE(nstr)) { - /* Logging on */ - } else { - /* Logging off */ - } - break; - case ESCSEQ_XTERM_FONT: /* 50 */ - change_font(0, str); - break; - default: - D_CMD(("Unsupported xterm escape sequence operator: 0x%02x\n", op)); - break; + break; + case ESCSEQ_XTERM_LOGFILE: /* 46 */ + nstr = (char *) strsep(&tnstr, ";"); + if (nstr && *nstr && BOOL_OPT_ISTRUE(nstr)) { + /* Logging on */ + } else { + /* Logging off */ + } + break; + case ESCSEQ_XTERM_FONT: /* 50 */ + change_font(0, str); + break; + default: + D_CMD(("Unsupported xterm escape sequence operator: 0x%02x\n", op)); + break; } #ifdef PIXMAP_SUPPORT FREE(orig_tnstr); diff --git a/src/timer.c b/src/timer.c index 1b9faac..1e42540 100644 --- a/src/timer.c +++ b/src/timer.c @@ -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->handler = handler; 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); } diff --git a/src/utmp.c b/src/utmp.c index 6efb15b..9cb8191 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -247,11 +247,11 @@ void b_login(struct utmp *ut) { /* - ** replacement for freebsd's login(), which uses ttyslot() - ** - ** like I shouldn't have just KNOWN that from the comment on get_tslot - ** below... - ** - brian + ** replacement for freebsd's login(), which uses ttyslot() + ** + ** like I shouldn't have just KNOWN that from the comment on get_tslot + ** below... + ** - brian */ register int fd; int tty; diff --git a/src/windows.c b/src/windows.c index b18043c..b002c9e 100644 --- a/src/windows.c +++ b/src/windows.c @@ -144,7 +144,8 @@ get_bottom_shadow_color(Pixel norm_color, const char *type) xcol.blue /= 2; 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]; } 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); 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]; } return (xcol.pixel); @@ -206,7 +208,9 @@ get_color_by_name(const char *name, const char *fallback) name = fallback; if (name) { 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); } } else { @@ -219,7 +223,8 @@ get_color_by_name(const char *name, const char *fallback) name = fallback; if (name) { 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); } } else { @@ -244,10 +249,12 @@ get_color_by_pixel(Pixel pixel, Pixel fallback) } } 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; 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); } } @@ -261,51 +268,51 @@ process_colors(void) Pixel pixel; 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))) { switch (i) { - case fgColor: - pixel = WhitePixel(Xdisplay, Xscreen); - break; - case bgColor: - pixel = BlackPixel(Xdisplay, Xscreen); - break; + case fgColor: + pixel = WhitePixel(Xdisplay, Xscreen); + break; + case bgColor: + pixel = BlackPixel(Xdisplay, Xscreen); + break; #ifndef NO_CURSORCOLOR - case cursorColor: - pixel = PixColors[bgColor]; - break; - case cursorColor2: - pixel = PixColors[fgColor]; - break; + case cursorColor: + pixel = PixColors[bgColor]; + break; + case cursorColor2: + pixel = PixColors[fgColor]; + break; #endif /* NO_CURSORCOLOR */ #ifndef NO_BOLDUNDERLINE - case colorBD: - pixel = PixColors[fgColor]; - break; - case colorUL: - pixel = PixColors[fgColor]; - break; + case colorBD: + pixel = PixColors[fgColor]; + break; + case colorUL: + pixel = PixColors[fgColor]; + break; #endif #ifdef ESCREEN - case ES_COLOR_CURRENT: - pixel = PixColors[YellowColor]; - break; - case ES_COLOR_ACTIVE: - pixel = PixColors[BlueColor]; - break; + case ES_COLOR_CURRENT: + pixel = PixColors[YellowColor]; + break; + case ES_COLOR_ACTIVE: + pixel = PixColors[BlueColor]; + break; #endif - case pointerColor: - pixel = PixColors[fgColor]; - break; - case borderColor: - pixel = PixColors[bgColor]; - break; - default: - pixel = PixColors[fgColor]; /* None */ - break; + case pointerColor: + pixel = PixColors[fgColor]; + break; + case borderColor: + pixel = PixColors[bgColor]; + break; + default: + pixel = PixColors[fgColor]; /* None */ + break; } } - D_COLORS(("Pixel : %x\n",pixel)); + D_COLORS(("Pixel : %x\n", pixel)); PixColors[i] = pixel; } @@ -321,14 +328,17 @@ process_colors(void) PixColors[unfocusedMenuBottomShadowColor] = PixColors[fgColor]; } else { 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[unfocusedTopShadowColor] = get_top_shadow_color(images[image_sb].disabled->bg, "unfocusedTopShadowColor"); 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[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); } @@ -423,7 +433,8 @@ Create_Windows(int argc, char *argv[]) Attributes.background_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", - 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, #ifdef PREFER_24BIT Xvisual, @@ -447,7 +458,8 @@ Create_Windows(int argc, char *argv[]) XSetWMProperties(Xdisplay, TermWin.parent, NULL, NULL, argv, argc, &szHint, &wmHint, &classHint); 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) { prop = XInternAtom(Xdisplay, "_MOTIF_WM_HINTS", False); XChangeProperty(Xdisplay, TermWin.parent, prop, prop, 32, @@ -475,22 +487,23 @@ Create_Windows(int argc, char *argv[]) XClearWindow(Xdisplay, TermWin.vt); } 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); /* If the user wants a specific desktop, tell the WM that */ if (rs_desktop != -1) { val = rs_desktop; - XChangeProperty(Xdisplay, TermWin.parent, props[PROP_DESKTOP], - XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); + XChangeProperty(Xdisplay, TermWin.parent, props[PROP_DESKTOP], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); } /* Set window opacity if needed. */ if ((props[PROP_EWMH_OPACITY] != None) && (rs_opacity != 0xff)) { 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], - 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. */ @@ -554,7 +567,8 @@ resize_parent(unsigned int width, unsigned int height) /* exact center */ 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); } } @@ -578,19 +592,21 @@ void update_size_hints(void) { 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.width_inc = TermWin.fwidth; 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_height = szHint.base_height + szHint.height_inc; szHint.width = szHint.base_width + TERM_WINDOW_GET_WIDTH(); 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; 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())); width = TERM_WINDOW_FULL_WIDTH(); height = TERM_WINDOW_FULL_HEIGHT(); - XMoveResizeWindow(Xdisplay, TermWin.vt, - ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (0) : ((scrollbar_is_visible())? (scrollbar_trough_width()) : (0))), + XMoveResizeWindow(Xdisplay, TermWin.vt, ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? (0) + : ((scrollbar_is_visible())? (scrollbar_trough_width()) : (0))), bbar_calc_docked_height(BBAR_DOCKED_TOP), width, height); if (width != last_width || height != last_height) { 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 */ i -= 8; 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]; } else { print_warning("Color index %d is invalid.\n", i); diff --git a/utils/Esetroot.c b/utils/Esetroot.c index cac8ab3..dbe6b37 100644 --- a/utils/Esetroot.c +++ b/utils/Esetroot.c @@ -56,15 +56,18 @@ set_pixmap_property(Pixmap p) if (prop_root != None && prop_esetroot != None) { XGetWindowProperty(Xdisplay, Xroot, prop_root, 0L, 1L, False, AnyPropertyType, &type, &format, &length, &after, &data_root); 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 (debug) { - fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): data_root == 0x%08x, data_esetroot == 0x%08x\n", __FILE__, - __LINE__, (unsigned int) p, (unsigned int) *((Pixmap *) data_root), (unsigned int) *((Pixmap *) data_esetroot)); + fprintf(stderr, "%s:%d: set_pixmap_property(0x%08x): data_root == 0x%08x, data_esetroot == 0x%08x\n", + __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 (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)); } @@ -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_esetroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1); 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); XFlush(Xdisplay); @@ -145,13 +149,15 @@ main(int argc, char *argv[]) if (debug) { 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: 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)"); } if (!displayname) { displayname = getenv("DISPLAY"); 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) { @@ -224,7 +230,8 @@ main(int argc, char *argv[]) } if (debug) { 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); } imlib_context_set_anti_alias(1);