--- rxvt-unicode/src/command.C 2010/02/04 21:55:12 1.438 +++ rxvt-unicode/src/command.C 2011/01/23 12:28:47 1.472 @@ -164,12 +164,9 @@ rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) { rxvt_fontset *fs = FONTSET (r); - rxvt_font *f = (*fs)[fs->find_font (ch)]; - wchar_t *chr, *alloc, ch2, *fname; + wchar_t *chr, *alloc, ch2, **fname; int len; - fname = rxvt_utf8towcs (f->name); - # if ENABLE_COMBINING if (IS_COMPOSE (ch)) { @@ -199,7 +196,14 @@ r & RS_Uline ? " uline" : "", r & RS_Careful ? " careful" : ""); - int width = wcswidth (fname, wcslen (fname)); + int width = 0; + fname = rxvt_temp_buf (len); + for (int i = 0; i < len; i++) + { + rxvt_font *f = (*fs)[fs->find_font_idx (chr[i])]; + fname[i] = rxvt_utf8towcs (f->name); + max_it (width, wcswidth (fname[i], wcslen (fname[i]))); + } max_it (width, 8+5); // for char + hex max_it (width, strlen (attr)); @@ -210,7 +214,7 @@ x = 0; } - scr_overlay_new (x, y, width, len + 2); + scr_overlay_new (x, y, width, len * 2 + 1); r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); @@ -239,9 +243,11 @@ // scr_overlay_set (0, 0, buf); // } scr_overlay_set (0, len , attr); - scr_overlay_set (0, len + 1, fname); - - free (fname); + for (int i = 0; i < len; i++) + { + scr_overlay_set (0, len + 1 + i, fname[i]); + free (fname[i]); + } # if ENABLE_COMBINING if (alloc) @@ -284,7 +290,7 @@ static int hex_keyval (XKeyEvent &ev) { - // check wether this event corresponds to a hex digit + // check whether this event corresponds to a hex digit // if the modifiers had not been pressed. for (int index = 0; index < 8; index++) { @@ -418,12 +424,6 @@ ctrl = ev.state & ControlMask; meta = ev.state & ModMetaMask; - if (numlock_state || (ev.state & ModNumLockMask)) - { - numlock_state = (ev.state & ModNumLockMask); - set_privmode (PrivMode_aplKP, !numlock_state); - } - kbuf[0] = 0; #ifdef USE_XIM @@ -649,7 +649,12 @@ bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; unsigned int newlen = 1; - switch (translate_keypad (keysym, kp)) + if (ev.state & ModNumLockMask) + kp = false; + + keysym = translate_keypad (keysym, kp); + + switch (keysym) { #ifndef NO_BACKSPACE_KEY case XK_BackSpace: @@ -886,7 +891,7 @@ return; } - for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) + for (unsigned short *i = iso14755_symtab; i[0]; i += 2) if (i[0] == keysym) { iso14755buf = ISO_14755_51 | i[1]; @@ -972,9 +977,9 @@ flush_ev.stop (); #ifdef HAVE_BG_PIXMAP - if (bgPixmap.check_clearChanged ()) + if (bgPixmap.flags & bgPixmap_t::hasChanged) { -// scr_clear (true); This needs to be researched further! + bgPixmap.flags &= ~bgPixmap_t::hasChanged; scr_touch (false); } #endif @@ -1029,7 +1034,7 @@ display->flush (); } -/* checks wether a refresh is requested and starts the refresh timer */ +/* checks whether a refresh is requested and starts the refresh timer */ void rxvt_term::refresh_check () { @@ -1133,7 +1138,7 @@ // ones with high nice levels is a useful thing to do. It surely is is // allowed by the sus... as is returning ENOSYS. // since the linux guys additionally thought that breaking the only - // known workaroudn against their unusable sched_yield hack is cool, + // known workaround against their unusable sched_yield hack is cool, // we just nanosleep a bit and hope for the best. struct timespec ts = { 0, 1000 }; @@ -1248,12 +1253,14 @@ int x, y; int code = 32; - x = Pixel2Col (ev.x); - y = Pixel2Row (ev.y); + x = Pixel2Col (ev.x) + 1; + y = Pixel2Row (ev.y) + 1; + if (ev.type == MotionNotify) { if (x == mouse_row && y == mouse_col) return; + mouse_row = x; mouse_col = y; code += 32; @@ -1266,7 +1273,7 @@ button_number = MEvent.button - Button1; /* add 0x3D for wheel events, like xterm does */ if (button_number >= 3) - button_number += (64 - 3); + button_number += 64 - 3; } if (priv_modes & PrivMode_MouseX10) @@ -1308,14 +1315,27 @@ fputc ('2', stderr); fprintf (stderr, "]: <%d>, %d/%d\n", button_number, - x + 1, - y + 1); + x, + y); #endif - tt_printf ("\033[M%c%c%c", - (code + button_number + key_state), - (32 + x + 1), - (32 + y + 1)); +#if ENABLE_FRILLS + if (priv_modes & PrivMode_ExtMouseRight) + tt_printf ("\033[%d;%d;%dM", + code + button_number + key_state, + x, + y); + else if (priv_modes & PrivMode_ExtModeMouse) + tt_printf ("\033[M%c%lc%lc", + code + button_number + key_state, + wint_t (32 + x), + wint_t (32 + y)); + else +#endif + tt_printf ("\033[M%c%c%c", + code + button_number + key_state, + 32 + x, + 32 + y); } /*{{{ process an X event */ @@ -1427,14 +1447,30 @@ break; case ConfigureNotify: - /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", - ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, - szHint.width, szHint.height);*/ if (ev.xconfigure.window == parent[0]) { while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) ; +#ifdef HAVE_BG_PIXMAP + bool moved = false; + if (bgPixmap.window_position_sensitive ()) + { + int x, y; + if (ev.xconfigure.send_event) + { + x = ev.xconfigure.x; + y = ev.xconfigure.y; + } + else + get_window_origin (x, y); + + if (bgPixmap.set_position (x, y) + || !(bgPixmap.flags & bgPixmap_t::isValid)) + moved = true; + } +#endif + if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) { seen_resize = 1; @@ -1443,7 +1479,7 @@ else { #ifdef HAVE_BG_PIXMAP - if (bgPixmap.window_position_sensitive ()) + if (moved) { if (mapped) update_background (); @@ -1480,19 +1516,19 @@ case MapNotify: #ifdef HAVE_BG_PIXMAP - /* This is needed spcifically to fix the case of no window manager or a + /* This is needed specifically to fix the case of no window manager or a * non-reparenting window manager. In those cases we never get first * ConfigureNotify. Also that speeds startup under normal WM, by taking - * care of multiplicity of ConfigureNotify events arriwing while WM does + * care of multiplicity of ConfigureNotify events arriving while WM does * reparenting. - * We should not render background immidiately, as there could be several + * We should not render background immediately, as there could be several * ConfigureNotify's to follow. Lets take care of all of them in one scoop * by scheduling background redraw as soon as we can, but giving a short * bit of time for ConfigureNotifies to arrive. * We should render background PRIOR to drawing any text, but AFTER all * of ConfigureNotifys for the best results. */ - if (bgPixmap.flags & bgPixmap_t::isInvalid) + if (!(bgPixmap.flags & bgPixmap_t::isValid)) update_background_ev.start (0.025); #endif mapped = 1; @@ -1866,7 +1902,7 @@ #ifdef MOUSE_REPORT_DOUBLECLICK if (ev.button == MEvent.button && clickintime) { - /* same button, within alloted time */ + /* same button, within allowed time */ MEvent.clicks++; if (MEvent.clicks > 1) @@ -2147,7 +2183,7 @@ case Button2: if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? - selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); + selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); break; #ifdef MOUSE_WHEEL @@ -2660,7 +2696,7 @@ case C1_NEL: /* ESC E */ { wchar_t nlcr[] = { C0_LF, C0_CR }; - scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); + scr_add_lines (nlcr, ARRAY_LENGTH(nlcr), 1); } break; @@ -2739,13 +2775,13 @@ CSI_78 , CSI_79 , CSI_7A , CSI_7B , CSI_7C , CSI_7D , CSI_7E , CSI_7F }; -#define make_byte(b7,b6,b5,b4,b3,b2,b1,b0) \ +#define make_byte(b0,b1,b2,b3,b4,b5,b6,b7) \ (((b7) << 7) | ((b6) << 6) | ((b5) << 5) | ((b4) << 4) \ | ((b3) << 3) | ((b2) << 2) | ((b1) << 1) | (b0)) #define get_byte_array_bit(array, bit) \ - (!! ((array)[ (bit) / 8] & (128 >> ((bit) & 7)))) + (!! ((array)[(bit) >> 3] & (1 << ((bit) & 7)))) -const unsigned char csi_defaults[] = +static const unsigned char csi_defaults[] = { make_byte (1,1,1,1,1,1,1,1), /* @, A, B, C, D, E, F, G, */ make_byte (1,1,0,0,1,1,0,0), /* H, I, J, K, L, M, N, O, */ @@ -2844,10 +2880,10 @@ scr_soft_reset (); static const int pm_h[] = { 7, 25 }; - static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1049 }; + static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 }; - process_terminal_mode ('h', 0, sizeof (pm_h) / sizeof (pm_h[0]), pm_h); - process_terminal_mode ('l', 0, sizeof (pm_l) / sizeof (pm_l[0]), pm_l); + process_terminal_mode ('h', 0, ARRAY_LENGTH(pm_h), pm_h); + process_terminal_mode ('l', 0, ARRAY_LENGTH(pm_l), pm_l); } break; } @@ -3228,13 +3264,12 @@ void rxvt_term::process_dcs_seq () { - char *s; - unicode_t eh; - /* * Not handled yet */ - s = get_to_st (eh); + + unicode_t eh; + char *s = get_to_st (eh); if (s) free (s); @@ -3248,15 +3283,15 @@ void rxvt_term::process_osc_seq () { - unicode_t ch, eh; int arg; - ch = cmd_getc (); + unicode_t ch = cmd_getc (); for (arg = 0; isdigit (ch); ch = cmd_getc ()) arg = arg * 10 + (ch - '0'); if (ch == ';') { + unicode_t eh; char *s = get_to_st (eh); if (s) @@ -3391,15 +3426,18 @@ case XTerm_Color_pointer_bg: process_color_seq (op, Color_pointer_bg, str, resp); break; -#ifndef NO_BOLD_UNDERLINE_REVERSE - case XTerm_Color_RV: - process_color_seq (op, Color_RV, str, resp); +#ifdef OPTION_HC + case XTerm_Color_HC: + process_color_seq (op, Color_HC, str, resp); + break; + case XTerm_Color_HTC: + process_color_seq (op, Color_HTC, str, resp); break; - case Rxvt_Color_BD: +#endif +#ifndef NO_BOLD_UNDERLINE_REVERSE case URxvt_Color_BD: process_color_seq (op, Color_BD, str, resp); break; - case Rxvt_Color_UL: case URxvt_Color_UL: process_color_seq (op, Color_UL, str, resp); break; @@ -3418,8 +3456,6 @@ if (ISSET_PIXCOLOR (Color_tint)) changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); - else - changed = bgPixmap.unset_tint (); if (changed) update_background (); @@ -3445,25 +3481,33 @@ if (*str != ';') { - /* reset to default scaling :*/ - bgPixmap.unset_geometry (); if (bgPixmap.set_file (str)) /* change pixmap */ - changed++; - str = strchr (str, ';'); - if (str == NULL) - bgPixmap.set_defaultGeometry (); + { + changed++; + str = strchr (str, ';'); + if (str == NULL) + bgPixmap.set_defaultGeometry (); + else + bgPixmap.set_geometry (str+1); + } } - - while (str) + else { str++; - if (bgPixmap.set_geometry (str)) + if (bgPixmap.set_geometry (str, true)) changed++; - str = strchr (str, ';'); } if (changed) - update_background (); + { + if (bgPixmap.window_position_sensitive ()) + { + int x, y; + get_window_origin (x, y); + bgPixmap.set_position (x, y); + } + update_background (); + } } break; #endif @@ -3576,6 +3620,7 @@ state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ else state = (mode == 't') ? ! (priv_modes & bit) : mode; + set_privmode (bit, state); } @@ -3604,7 +3649,7 @@ // 8, auto-repeat keys // DECARM { 9, PrivMode_MouseX10 }, // 18 end FF to printer after print screen - // 19 Print screen prints full screen/scorll region + // 19 Print screen prints full screen/scroll region { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis #ifdef scrollBar_esc { scrollBar_esc, PrivMode_scrollBar }, @@ -3623,13 +3668,19 @@ { 1000, PrivMode_MouseX11 }, { 1002, PrivMode_MouseBtnEvent }, { 1003, PrivMode_MouseAnyEvent }, +#if ENABLE_FRILLS + { 1005, PrivMode_ExtModeMouse }, +#endif { 1010, PrivMode_TtyOutputInh }, // rxvt extension { 1011, PrivMode_Keypress }, // rxvt extension +#if ENABLE_FRILLS + { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005 +#endif // 1035 enable modifiers for alt, numlock NYI // 1036 send ESC for meta keys NYI // 1037 send DEL for keypad delete NYI { 1047, PrivMode_Screen }, - // 1048 save and restore cursor + // 1048 save and restore cursor, implemented in code { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ // 1051, 1052, 1060, 1061 keyboard emulation NYI { 2004, PrivMode_BracketPaste }, @@ -3649,7 +3700,7 @@ state = -1; /* basic handling */ - for (j = 0; j < (sizeof (argtopriv)/sizeof (argtopriv[0])); j++) + for (j = 0; j < ARRAY_LENGTH(argtopriv); j++) if (argtopriv[j].argval == arg[i]) { state = privcases (mode, argtopriv[j].bit); @@ -3737,6 +3788,7 @@ { priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; + mouse_row = mouse_col = 0; vt_emask_mouse = PointerMotionMask; } else @@ -3972,7 +4024,7 @@ /* Write data to the pty as typed by the user, pasted with the mouse, * or generated by us in response to a query ESC sequence. */ -const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT +static const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT void rxvt_term::tt_write (const char *data, unsigned int len) @@ -3994,7 +4046,7 @@ len -= written; } - v_buffer = (char *)realloc (v_buffer, v_buflen + len); + v_buffer = (char *)rxvt_realloc (v_buffer, v_buflen + len); memcpy (v_buffer + v_buflen, data, len); v_buflen += len;