ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.95 by pcg, Sun May 9 18:19:49 2004 UTC vs.
Revision 1.120 by root, Tue Aug 10 22:36:30 2004 UTC

306 newlen = 0; 306 newlen = 0;
307 } 307 }
308 break; 308 break;
309 309
310#ifdef XK_KP_Left 310#ifdef XK_KP_Left
311 case XK_KP_Up: /* \033Ox or standard */ 311 case XK_KP_Up: /* \033Ox or standard */
312 case XK_KP_Down: /* \033Or or standard */ 312 case XK_KP_Down: /* \033Or or standard */
313 case XK_KP_Right: /* \033Ov or standard */ 313 case XK_KP_Right: /* \033Ov or standard */
314 case XK_KP_Left: /* \033Ot or standard */ 314 case XK_KP_Left: /* \033Ot or standard */
315 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 315 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
316 { 316 {
661 if (want_full_refresh) 661 if (want_full_refresh)
662 { 662 {
663 want_full_refresh = 0; 663 want_full_refresh = 0;
664 scr_clear (); 664 scr_clear ();
665 scr_touch (false); 665 scr_touch (false);
666 want_refresh = 1;
667 } 666 }
668#endif 667#endif
669 668
670 if (want_refresh) 669 if (want_refresh)
671 { 670 {
675 IMSendSpot (); 674 IMSendSpot ();
676#endif 675#endif
677 } 676 }
678 677
679 display->flush (); 678 display->flush ();
679
680 flush_ev.stop ();
680} 681}
681 682
682void 683void
683rxvt_term::check_cb (check_watcher &w) 684rxvt_term::check_cb (check_watcher &w)
684{ 685{
685 SET_R (this); 686 SET_R (this);
686 SET_LOCALE (locale); 687 SET_LOCALE (locale);
687 688
689 display->flush ();
690
691 if (want_refresh && !flush_ev.active)
692 flush_ev.start (NOW + 0.01);
693}
694
695void
696rxvt_term::flush_cb (time_watcher &w)
697{
698 SET_R (this);
699 SET_LOCALE (locale);
700
701 refresh_limit = 1;
702 refresh_count = 0;
688 flush (); 703 flush ();
689} 704}
690 705
691#ifdef CURSOR_BLINK 706#ifdef CURSOR_BLINK
692void 707void
706 if (scr_refresh_rend (RS_Blink, RS_Blink)) 721 if (scr_refresh_rend (RS_Blink, RS_Blink))
707 { 722 {
708 hidden_text = !hidden_text; 723 hidden_text = !hidden_text;
709 want_refresh = 1; 724 want_refresh = 1;
710 w.start (w.at + TEXT_BLINK_INTERVAL); 725 w.start (w.at + TEXT_BLINK_INTERVAL);
726 }
727}
728#endif
729
730#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
731void
732rxvt_term::cont_scroll_cb (time_watcher &w)
733{
734 if ((scrollbar_isUp() || scrollbar_isDn()) &&
735 scr_page (scrollbar_isUp() ? UP : DN, 1))
736 {
737 refresh_type |= SMOOTH_REFRESH;
738 want_refresh = 1;
739 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
740 }
741}
742#endif
743
744#ifdef SELECTION_SCROLLING
745void
746rxvt_term::sel_scroll_cb (time_watcher &w)
747{
748 if (scr_page (scroll_selection_dir, scroll_selection_lines))
749 {
750 selection_extend (selection_save_x, selection_save_y, selection_save_state);
751 refresh_type |= SMOOTH_REFRESH;
752 want_refresh = 1;
753 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
754 }
755}
756#endif
757
758#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
759void
760rxvt_term::slip_wheel_cb (time_watcher &w)
761{
762 if (mouse_slip_wheel_speed == 0
763 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
764 : scr_page (UP, mouse_slip_wheel_speed))
765 {
766 refresh_type |= SMOOTH_REFRESH;
767 want_refresh = 1;
768 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
711 } 769 }
712} 770}
713#endif 771#endif
714 772
715bool 773bool
753 while (pty_fill ()) 811 while (pty_fill ())
754 if (cmd_parse ()) 812 if (cmd_parse ())
755 break; 813 break;
756} 814}
757 815
758#ifdef POINTER_BLANK
759void 816void
760rxvt_term::pointer_unblank () 817rxvt_term::pointer_unblank ()
761{ 818{
762 XDefineCursor (display->display, TermWin.vt, TermWin_cursor); 819 XDefineCursor (display->display, TermWin.vt, TermWin_cursor);
763 recolour_cursor (); 820 recolour_cursor ();
764 821
822#ifdef POINTER_BLANK
765 hidden_pointer = 0; 823 hidden_pointer = 0;
766 824
767 if (Options & Opt_pointerBlank) 825 if (Options & Opt_pointerBlank)
768 pointer_ev.start (NOW + pointerBlankDelay); 826 pointer_ev.start (NOW + pointerBlankDelay);
827#endif
769} 828}
770 829
830#ifdef POINTER_BLANK
771void 831void
772rxvt_term::pointer_blank () 832rxvt_term::pointer_blank ()
773{ 833{
774 if (! (Options & Opt_pointerBlank)) 834 if (! (Options & Opt_pointerBlank))
775 return; 835 return;
971 break; 1031 break;
972 1032
973#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1033#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
974 case KeyRelease: 1034 case KeyRelease:
975 { 1035 {
976 if (! (ev.xkey.state & ControlMask)) 1036 if (!(ev.xkey.state & ControlMask))
977 mouse_slip_wheel_speed = 0; 1037 slip_wheel_ev.stop ();
978 else 1038 else
979 { 1039 {
980 KeySym ks; 1040 KeySym ks;
981 1041
982 ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); 1042 ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0);
983 if (ks == XK_Control_L || ks == XK_Control_R) 1043 if (ks == XK_Control_L || ks == XK_Control_R)
984 mouse_slip_wheel_speed = 0; 1044 mouse_slip_wheel_speed = 0;
985 } 1045 }
1029 } 1089 }
1030#endif /* OFFIX_DND */ 1090#endif /* OFFIX_DND */
1031 break; 1091 break;
1032 1092
1033 case MappingNotify: 1093 case MappingNotify:
1034 XRefreshKeyboardMapping (& (ev.xmapping)); 1094 XRefreshKeyboardMapping (&ev.xmapping);
1035 break; 1095 break;
1036 1096
1037 /* 1097 /*
1038 * XXX: this is not the _current_ arrangement 1098 * XXX: this is not the _current_ arrangement
1039 * Here's my conclusion: 1099 * Here's my conclusion:
1070#endif 1130#endif
1071#ifdef CURSOR_BLINK 1131#ifdef CURSOR_BLINK
1072 if (Options & Opt_cursorBlink) 1132 if (Options & Opt_cursorBlink)
1073 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1133 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1074#endif 1134#endif
1135#ifdef OFF_FOCUS_FADING
1136 if (rs[Rs_fade])
1137 {
1138 PixColors = PixColorsFocused;
1139 set_colorfgbg ();
1140 scr_clear ();
1141 scr_touch (true);
1142 }
1143#endif
1075 1144
1076 } 1145 }
1077 break; 1146 break;
1078 1147
1079 case FocusOut: 1148 case FocusOut:
1088#ifdef CURSOR_BLINK 1157#ifdef CURSOR_BLINK
1089 if (Options & Opt_cursorBlink) 1158 if (Options & Opt_cursorBlink)
1090 cursor_blink_ev.stop (); 1159 cursor_blink_ev.stop ();
1091 hidden_cursor = 0; 1160 hidden_cursor = 0;
1092#endif 1161#endif
1162#ifdef OFF_FOCUS_FADING
1163 if (rs[Rs_fade])
1164 {
1165 PixColors = PixColorsUnFocused;
1166 set_colorfgbg ();
1167 scr_clear ();
1168 scr_touch (true);
1169 }
1170#endif
1093 1171
1094 } 1172 }
1095 break; 1173 break;
1096 1174
1097 case ConfigureNotify: 1175 case ConfigureNotify:
1106 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); 1184 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
1107 } 1185 }
1108 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); 1186 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev));
1109 1187
1110 if (szHint.width != width || szHint.height != height) 1188 if (szHint.width != width || szHint.height != height)
1111 {
1112 D_SIZE ((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height));
1113 resize_all_windows (width, height, 1); 1189 resize_all_windows (width, height, 1);
1114 } 1190
1115#ifdef DEBUG_SIZE
1116 else
1117 {
1118 D_SIZE ((stderr, "Size: Not resizing"));
1119 }
1120#endif
1121#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1191#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1122 if (Options & Opt_transparent) 1192 if (Options & Opt_transparent)
1123 { 1193 {
1124 check_our_parents (); 1194 check_our_parents ();
1125 if (am_transparent) 1195 if (am_transparent)
1126 want_full_refresh = 1; 1196 want_refresh = want_full_refresh = 1;
1127 } 1197 }
1128#endif 1198#endif
1129 } 1199 }
1130 break; 1200 break;
1131 1201
1165 1235
1166 case GraphicsExpose: 1236 case GraphicsExpose:
1167 case Expose: 1237 case Expose:
1168 if (ev.xany.window == TermWin.vt) 1238 if (ev.xany.window == TermWin.vt)
1169 { 1239 {
1170#ifdef NO_SLOW_LINK_SUPPORT 1240 do
1171 scr_expose (ev.xexpose.x, ev.xexpose.y, 1241 scr_expose (ev.xexpose.x, ev.xexpose.y,
1172 ev.xexpose.width, ev.xexpose.height, False); 1242 ev.xexpose.width, ev.xexpose.height, False);
1173#else 1243 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev));
1174 // I don't understand this, so I changed it :) 1244
1245 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1246
1247 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev))
1175 scr_expose (ev.xexpose.x, ev.xexpose.y, 1248 scr_expose (ev.xexpose.x, ev.xexpose.y,
1176 ev.xexpose.width, ev.xexpose.height, False); 1249 ev.xexpose.width, ev.xexpose.height, False);
1177 //scr_expose (ev.xexpose.x, 0, 1250
1178 // ev.xexpose.width, TermWin.height, False); 1251 scr_refresh (refresh_type);
1179#endif
1180 want_refresh = 1;
1181 } 1252 }
1182 else 1253 else
1183 { 1254 {
1184 XEvent unused_event; 1255 XEvent unused_event;
1185 1256
1194 scrollbar_show (0); 1265 scrollbar_show (0);
1195 } 1266 }
1196#ifdef MENUBAR 1267#ifdef MENUBAR
1197 if (menubar_visible () && isMenuBarWindow (ev.xany.window)) 1268 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1198 menubar_expose (); 1269 menubar_expose ();
1270#endif
1271
1272#ifdef TRANSPARENT
1273 if (am_transparent && ev.xany.window == TermWin.parent[0])
1274 XClearWindow (display->display, ev.xany.window);
1199#endif 1275#endif
1200 } 1276 }
1201 break; 1277 break;
1202 1278
1203 case MotionNotify: 1279 case MotionNotify:
1238 if (ev.xbutton.y < TermWin.int_bwidth 1314 if (ev.xbutton.y < TermWin.int_bwidth
1239 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) 1315 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1))
1240 { 1316 {
1241 int dist; 1317 int dist;
1242 1318
1243 pending_scroll_selection=1;
1244
1245 /* don't clobber the current delay if we are 1319 /* don't clobber the current delay if we are
1246 * already in the middle of scrolling. 1320 * already in the middle of scrolling.
1247 */ 1321 */
1248 if (scroll_selection_delay<=0) 1322 if (!sel_scroll_ev.active)
1249 scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; 1323 sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY);
1250 1324
1251 /* save the event params so we can highlight 1325 /* save the event params so we can highlight
1252 * the selection in the pending-scroll loop 1326 * the selection in the pending-scroll loop
1253 */ 1327 */
1254 selection_save_x=ev.xbutton.x; 1328 selection_save_x=ev.xbutton.x;
1276 else 1350 else
1277 { 1351 {
1278 /* we are within the text window, so we 1352 /* we are within the text window, so we
1279 * shouldn't be scrolling 1353 * shouldn't be scrolling
1280 */ 1354 */
1281 pending_scroll_selection = 0; 1355 if (sel_scroll_ev.active)
1356 sel_scroll_ev.stop();
1282 } 1357 }
1283#endif 1358#endif
1284#ifdef MOUSE_THRESHOLD 1359#ifdef MOUSE_THRESHOLD
1285 1360
1286 } 1361 }
1337 } 1412 }
1338 1413
1339 /* FALLTHROUGH */ 1414 /* FALLTHROUGH */
1340 case ReparentNotify: 1415 case ReparentNotify:
1341 if ((Options & Opt_transparent) && check_our_parents () && am_transparent) 1416 if ((Options & Opt_transparent) && check_our_parents () && am_transparent)
1342 want_full_refresh = 1; 1417 want_refresh = want_full_refresh = 1;
1343 break; 1418 break;
1344#endif 1419#endif
1345 } 1420 }
1346} 1421}
1347 1422
1503 upordown = 1; /* down */ 1578 upordown = 1; /* down */
1504 } 1579 }
1505 if (upordown) 1580 if (upordown)
1506 { 1581 {
1507#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1582#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1508 scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; 1583 cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY);
1509#endif 1584#endif
1510 if (scr_page (upordown < 0 ? UP : DN, 1)) 1585 if (scr_page (upordown < 0 ? UP : DN, 1))
1511 { 1586 {
1512 if (upordown < 0) 1587 if (upordown < 0)
1513 scrollBar.setUp (); 1588 scrollBar.setUp ();
1529 break; 1604 break;
1530 case R_SB_ALIGN_BOTTOM: 1605 case R_SB_ALIGN_BOTTOM:
1531 csrO = scrollBar.bot - scrollBar.top; 1606 csrO = scrollBar.bot - scrollBar.top;
1532 break; 1607 break;
1533 } 1608 }
1609
1534 if (scrollBar.style == R_SB_XTERM 1610 if (scrollBar.style == R_SB_XTERM
1535 || scrollbar_above_slider (ev.y) 1611 || scrollbar_above_slider (ev.y)
1536 || scrollbar_below_slider (ev.y)) 1612 || scrollbar_below_slider (ev.y))
1537 scr_move_to ( scrollbar_position (ev.y) - csrO, 1613 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ());
1538 scrollbar_size ()); 1614
1539 scrollBar.setMotion (); 1615 scrollBar.setMotion ();
1540 break; 1616 break;
1541 1617
1542 case Button1: 1618 case Button1:
1543 if (scrollbar_align == R_SB_ALIGN_CENTRE) 1619 if (scrollbar_align == R_SB_ALIGN_CENTRE)
1567 scr_page ((ev.button == Button1 ? DN : UP), 1643 scr_page ((ev.button == Button1 ? DN : UP),
1568 (TermWin.nrow 1644 (TermWin.nrow
1569 * scrollbar_position (ev.y) 1645 * scrollbar_position (ev.y)
1570 / scrollbar_size ())); 1646 / scrollbar_size ()));
1571 } 1647 }
1648
1572 break; 1649 break;
1573 } 1650 }
1574 } 1651 }
1575 return; 1652 return;
1576 } 1653 }
1600 refresh_type &= ~SMOOTH_REFRESH; 1677 refresh_type &= ~SMOOTH_REFRESH;
1601#endif 1678#endif
1602 1679
1603 } 1680 }
1604#ifdef SELECTION_SCROLLING 1681#ifdef SELECTION_SCROLLING
1605 pending_scroll_selection=0; 1682 if (sel_scroll_ev.active)
1683 sel_scroll_ev.stop();
1606#endif 1684#endif
1607 if (ev.window == TermWin.vt) 1685 if (ev.window == TermWin.vt)
1608 { 1686 {
1609 if (reportmode) 1687 if (reportmode)
1610 { 1688 {
1652 case Button5: 1730 case Button5:
1653 { 1731 {
1654 int i; 1732 int i;
1655 page_dirn v; 1733 page_dirn v;
1656 1734
1657 v = (ev.button == Button4) ? UP : DN; 1735 v = ev.button == Button4 ? UP : DN;
1736
1658 if (ev.state & ShiftMask) 1737 if (ev.state & ShiftMask)
1659 i = 1; 1738 i = 1;
1660 else if ((Options & Opt_mouseWheelScrollPage)) 1739 else if (Options & Opt_mouseWheelScrollPage)
1661 i = TermWin.nrow - 1; 1740 i = TermWin.nrow - 1;
1662 else 1741 else
1663 i = 5; 1742 i = 5;
1743
1664# ifdef MOUSE_SLIP_WHEELING 1744# ifdef MOUSE_SLIP_WHEELING
1665 if (ev.state & ControlMask) 1745 if (ev.state & ControlMask)
1666 { 1746 {
1667 mouse_slip_wheel_speed += (v ? -1 : 1); 1747 mouse_slip_wheel_speed += v ? -1 : 1;
1748 if (mouse_slip_wheel_speed < -TermWin.nrow) mouse_slip_wheel_speed = -TermWin.nrow;
1749 if (mouse_slip_wheel_speed > +TermWin.nrow) mouse_slip_wheel_speed = +TermWin.nrow;
1750
1751 if (slip_wheel_ev.at < NOW)
1668 mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; 1752 slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY;
1753
1754 slip_wheel_ev.start ();
1669 } 1755 }
1756 else
1757 {
1670# endif 1758# endif
1671# ifdef JUMP_MOUSE_WHEEL 1759# ifdef JUMP_MOUSE_WHEEL
1672 scr_page (v, i);
1673 scr_refresh (SMOOTH_REFRESH);
1674 scrollbar_show (1);
1675# else
1676 while (i--)
1677 {
1678 scr_page (v, 1); 1760 scr_page (v, i);
1679 scr_refresh (SMOOTH_REFRESH); 1761 scr_refresh (SMOOTH_REFRESH);
1680 scrollbar_show (1); 1762 scrollbar_show (1);
1763# else
1764 while (i--)
1765 {
1766 scr_page (v, 1);
1767 scr_refresh (SMOOTH_REFRESH);
1768 scrollbar_show (1);
1769 }
1770# endif
1771# ifdef MOUSE_SLIP_WHEELING
1681 } 1772 }
1682# endif 1773#endif
1683
1684 } 1774 }
1685 break; 1775 break;
1686#endif 1776#endif
1687
1688 } 1777 }
1689 } 1778 }
1690#ifdef MENUBAR 1779#ifdef MENUBAR
1691 else if (isMenuBarWindow (ev.window)) 1780 else if (isMenuBarWindow (ev.window))
1692 menubar_control (ev); 1781 menubar_control (ev);
1693#endif 1782#endif
1694} 1783}
1695 1784
1696#ifdef TRANSPARENT 1785#ifdef TRANSPARENT
1697#if TINTING 1786#if TINTING
1698/* shading taken from eterm-0.9.2 */ 1787/* taken from aterm-0.4.2 */
1699/* RGB 15 */
1700 1788
1701static void 1789typedef uint32_t RUINT32T;
1702shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1703{
1704 unsigned char *ptr;
1705 int x, y;
1706 1790
1707 ptr = (unsigned char *)data + (w * sizeof(uint16_t)); 1791void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm)
1708 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { 1792{
1709 /* No saturation */ 1793 int sh_r, sh_g, sh_b;
1710 for (y = h; --y >= 0;) { 1794 RUINT32T mask_r, mask_g, mask_b;
1711 for (x = -w; x < 0; x++) { 1795 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
1712 int r, g, b; 1796 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
1797 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
1798 int i;
1713 1799
1714 b = ((uint16_t *) ptr)[x]; 1800 Visual* visual = display->visual;
1715 r = (b & 0x7c00) * rm; 1801
1716 g = (b & 0x3e0) * gm; 1802 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
1717 b = (b & 0x1f) * bm; 1803
1718 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) 1804 /* for convenience */
1719 | ((g >> 8) & 0x3e0) 1805 mask_r = visual->red_mask;
1720 | ((b >> 8) & 0x1f); 1806 mask_g = visual->green_mask;
1721 } 1807 mask_b = visual->blue_mask;
1722 ptr += bpl; 1808
1723 } 1809 /* boring lookup table pre-initialization */
1810 switch (srcImage->bits_per_pixel) {
1811 case 15:
1812 if ((mask_r != 0x7c00) ||
1813 (mask_g != 0x03e0) ||
1814 (mask_b != 0x001f))
1815 return;
1816 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
1817 lookup_r = lookup;
1818 lookup_g = lookup+32;
1819 lookup_b = lookup+32+32;
1820 sh_r = 10;
1821 sh_g = 5;
1822 sh_b = 0;
1823 break;
1824 case 16:
1825 if ((mask_r != 0xf800) ||
1826 (mask_g != 0x07e0) ||
1827 (mask_b != 0x001f))
1828 return;
1829 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
1830 lookup_r = lookup;
1831 lookup_g = lookup+32;
1832 lookup_b = lookup+32+64;
1833 sh_r = 11;
1834 sh_g = 5;
1835 sh_b = 0;
1836 break;
1837 case 24:
1838 if ((mask_r != 0xff0000) ||
1839 (mask_g != 0x00ff00) ||
1840 (mask_b != 0x0000ff))
1841 return;
1842 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
1843 lookup_r = lookup;
1844 lookup_g = lookup+256;
1845 lookup_b = lookup+256+256;
1846 sh_r = 16;
1847 sh_g = 8;
1848 sh_b = 0;
1849 break;
1850 case 32:
1851 if ((mask_r != 0xff0000) ||
1852 (mask_g != 0x00ff00) ||
1853 (mask_b != 0x0000ff))
1854 return;
1855 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
1856 lookup_r = lookup;
1857 lookup_g = lookup+256;
1858 lookup_b = lookup+256+256;
1859 sh_r = 16;
1860 sh_g = 8;
1861 sh_b = 0;
1862 break;
1863 default:
1864 return; /* we do not support this color depth */
1865 }
1866
1867 /* prepare limits for color transformation (each channel is handled separately) */
1868 if (shade < 0) {
1869 shade = -shade;
1870 if (shade < 0) shade = 0;
1871 if (shade > 100) shade = 100;
1872
1873 lower_lim_r = 65535-rm;
1874 lower_lim_g = 65535-gm;
1875 lower_lim_b = 65535-bm;
1876
1877 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
1878 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
1879 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
1880
1881 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1724 } else { 1882 } else {
1725 for (y = h; --y >= 0;) { 1883 if (shade < 0) shade = 0;
1726 for (x = -w; x < 0; x++) { 1884 if (shade > 100) shade = 100;
1727 int r, g, b;
1728 1885
1729 b = ((uint16_t *) ptr)[x]; 1886 lower_lim_r = lower_lim_g = lower_lim_b = 0;
1730 r = (b & 0x7c00) * rm; 1887
1731 g = (b & 0x3e0) * gm; 1888 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
1732 b = (b & 0x1f) * bm; 1889 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
1733 r |= (!(r >> 15) - 1); 1890 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
1734 g |= (!(g >> 10) - 1); 1891 }
1735 b |= (!(b >> 5) - 1); 1892
1736 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) 1893 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
1737 | ((g >> 8) & 0x3e0) 1894 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
1738 | ((b >> 8) & 0x1f); 1895 {
1739 } 1896 unsigned int tmp;
1740 ptr += bpl; 1897
1898 tmp = lower_lim_r;
1899 lower_lim_r = lower_lim_b;
1900 lower_lim_b = tmp;
1901
1902 tmp = upper_lim_r;
1903 upper_lim_r = upper_lim_b;
1904 upper_lim_b = tmp;
1905 }
1906
1907 /* fill our lookup tables */
1908 for (i = 0; i <= mask_r>>sh_r; i++)
1909 {
1910 RUINT32T tmp;
1911 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
1912 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
1913 lookup_r[i] = (tmp/65535)<<sh_r;
1914 }
1915 for (i = 0; i <= mask_g>>sh_g; i++)
1916 {
1917 RUINT32T tmp;
1918 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
1919 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
1920 lookup_g[i] = (tmp/65535)<<sh_g;
1921 }
1922 for (i = 0; i <= mask_b>>sh_b; i++)
1923 {
1924 RUINT32T tmp;
1925 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
1926 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
1927 lookup_b[i] = (tmp/65535)<<sh_b;
1928 }
1929
1930 /* apply table to input image (replacing colors by newly calculated ones) */
1931 switch (srcImage->bits_per_pixel)
1932 {
1933 case 15:
1934 {
1935 unsigned short *p1, *pf, *p, *pl;
1936 p1 = (unsigned short *) srcImage->data;
1937 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1938 while (p1 < pf)
1939 {
1940 p = p1;
1941 pl = p1 + srcImage->width;
1942 for (; p < pl; p++)
1741 } 1943 {
1944 *p = lookup_r[(*p & 0x7c00)>>10] |
1945 lookup_g[(*p & 0x03e0)>> 5] |
1946 lookup_b[(*p & 0x001f)];
1947 }
1948 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
1742 } 1949 }
1743} 1950 break;
1744 1951 }
1745/* RGB 16 */ 1952 case 16:
1746static void 1953 {
1747shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm) 1954 unsigned short *p1, *pf, *p, *pl;
1748{ 1955 p1 = (unsigned short *) srcImage->data;
1749 unsigned char *ptr; 1956 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1750 int x, y; 1957 while (p1 < pf)
1751 1958 {
1752 ptr = (unsigned char *)data + (w * sizeof(uint16_t)); 1959 p = p1;
1753 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { 1960 pl = p1 + srcImage->width;
1754 /* No saturation */ 1961 for (; p < pl; p++)
1755 for (y = h; --y >= 0;) {
1756 for (x = -w; x < 0; x++) {
1757 int r, g, b;
1758
1759 b = ((uint16_t *) ptr)[x];
1760 r = (b & 0xf800) * rm;
1761 g = (b & 0x7e0) * gm;
1762 b = (b & 0x1f) * bm;
1763 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1764 | ((g >> 8) & 0x7e0)
1765 | ((b >> 8) & 0x1f);
1766 }
1767 ptr += bpl;
1768 } 1962 {
1769 } else { 1963 *p = lookup_r[(*p & 0xf800)>>11] |
1770 for (y = h; --y >= 0;) { 1964 lookup_g[(*p & 0x07e0)>> 5] |
1771 for (x = -w; x < 0; x++) { 1965 lookup_b[(*p & 0x001f)];
1772 int r, g, b;
1773
1774 b = ((uint16_t *) ptr)[x];
1775 r = (b & 0xf800) * rm;
1776 g = (b & 0x7e0) * gm;
1777 b = (b & 0x1f) * bm;
1778 r |= (!(r >> 16) - 1);
1779 g |= (!(g >> 11) - 1);
1780 b |= (!(b >> 5) - 1);
1781 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1782 | ((g >> 8) & 0x7e0)
1783 | ((b >> 8) & 0x1f);
1784 } 1966 }
1785 ptr += bpl; 1967 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
1968 }
1969 break;
1970 }
1971 case 24:
1972 {
1973 unsigned char *p1, *pf, *p, *pl;
1974 p1 = (unsigned char *) srcImage->data;
1975 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1976 while (p1 < pf)
1977 {
1978 p = p1;
1979 pl = p1 + srcImage->width * 3;
1980 for (; p < pl; p += 3)
1786 } 1981 {
1982 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
1983 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
1984 p[2] = lookup_r[(p[2] & 0x0000ff)];
1985 }
1986 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
1787 } 1987 }
1788} 1988 break;
1989 }
1990 case 32:
1991 {
1992 RUINT32T *p1, *pf, *p, *pl;
1993 p1 = (RUINT32T *) srcImage->data;
1994 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1789 1995
1790/* RGB 24 */ 1996 while (p1 < pf)
1791static void 1997 {
1792shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm) 1998 p = p1;
1793{ 1999 pl = p1 + srcImage->width;
1794 unsigned char *ptr; 2000 for (; p < pl; p++)
1795 int x, y;
1796
1797 ptr = (unsigned char *)data + (w * 3);
1798 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1799 /* No saturation */
1800 for (y = h; --y >= 0;) {
1801 for (x = -(w * 3); x < 0; x += 3) {
1802 int r, g, b;
1803
1804 if (byteorder.big_endian()) {
1805 r = (ptr[x + 0] * rm) >> 8;
1806 g = (ptr[x + 1] * gm) >> 8;
1807 b = (ptr[x + 2] * bm) >> 8;
1808 ptr[x + 0] = r;
1809 ptr[x + 1] = g;
1810 ptr[x + 2] = b;
1811 } else {
1812 r = (ptr[x + 2] * rm) >> 8;
1813 g = (ptr[x + 1] * gm) >> 8;
1814 b = (ptr[x + 0] * bm) >> 8;
1815 ptr[x + 2] = r;
1816 ptr[x + 1] = g;
1817 ptr[x + 0] = b;
1818 }
1819 }
1820 ptr += bpl;
1821 } 2001 {
1822 } else { 2002 *p = lookup_r[(*p & 0xff0000)>>16] |
1823 for (y = h; --y >= 0;) { 2003 lookup_g[(*p & 0x00ff00)>> 8] |
1824 for (x = -(w * 3); x < 0; x += 3) { 2004 lookup_b[(*p & 0x0000ff)] |
1825 int r, g, b; 2005 (*p & ~0xffffff);
1826
1827 if (byteorder.big_endian()) {
1828 r = (ptr[x + 0] * rm) >> 8;
1829 g = (ptr[x + 1] * gm) >> 8;
1830 b = (ptr[x + 2] * bm) >> 8;
1831
1832 r |= (!(r >> 8) - 1);
1833 g |= (!(g >> 8) - 1);
1834 b |= (!(b >> 8) - 1);
1835
1836 ptr[x + 0] = r;
1837 ptr[x + 1] = g;
1838 ptr[x + 2] = b;
1839 } else {
1840 r = (ptr[x + 2] * rm) >> 8;
1841 g = (ptr[x + 1] * gm) >> 8;
1842 b = (ptr[x + 0] * bm) >> 8;
1843
1844 r |= (!(r >> 8) - 1);
1845 g |= (!(g >> 8) - 1);
1846 b |= (!(b >> 8) - 1);
1847
1848 ptr[x + 2] = r;
1849 ptr[x + 1] = g;
1850 ptr[x + 0] = b;
1851 }
1852 } 2006 }
1853 ptr += bpl; 2007 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
1854 } 2008 }
2009 break;
2010 }
1855 } 2011 }
1856}
1857 2012
1858/* RGB 32 */ 2013 free (lookup);
1859static void
1860shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1861{
1862 unsigned char *ptr;
1863 int x, y;
1864
1865 ptr = (unsigned char *)data + (w * 4);
1866 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1867 /* No saturation */
1868 for (y = h; --y >= 0;) {
1869 if (byteorder.big_endian()) {
1870 for (x = -(w * 4); x < 0; x += 4) {
1871 int r, g, b;
1872
1873 r = (ptr[x + 1] * rm) >> 8;
1874 g = (ptr[x + 2] * gm) >> 8;
1875 b = (ptr[x + 3] * bm) >> 8;
1876 ptr[x + 1] = r;
1877 ptr[x + 2] = g;
1878 ptr[x + 3] = b;
1879 }
1880 } else {
1881 for (x = -(w * 4); x < 0; x += 4) {
1882 int r, g, b;
1883
1884 r = (ptr[x + 2] * rm) >> 8;
1885 g = (ptr[x + 1] * gm) >> 8;
1886 b = (ptr[x + 0] * bm) >> 8;
1887 ptr[x + 2] = r;
1888 ptr[x + 1] = g;
1889 ptr[x + 0] = b;
1890 }
1891 }
1892 ptr += bpl;
1893 }
1894 } else {
1895 for (y = h; --y >= 0;) {
1896 for (x = -(w * 4); x < 0; x += 4) {
1897 int r, g, b;
1898
1899 if (byteorder.big_endian()) {
1900 r = (ptr[x + 1] * rm) >> 8;
1901 g = (ptr[x + 2] * gm) >> 8;
1902 b = (ptr[x + 3] * bm) >> 8;
1903
1904 r |= (!(r >> 8) - 1);
1905 g |= (!(g >> 8) - 1);
1906 b |= (!(b >> 8) - 1);
1907
1908 ptr[x + 1] = r;
1909 ptr[x + 2] = g;
1910 ptr[x + 3] = b;
1911 } else {
1912 r = (ptr[x + 2] * rm) >> 8;
1913 g = (ptr[x + 1] * gm) >> 8;
1914 b = (ptr[x + 0] * bm) >> 8;
1915
1916 r |= (!(r >> 8) - 1);
1917 g |= (!(g >> 8) - 1);
1918 b |= (!(b >> 8) - 1);
1919
1920 ptr[x + 2] = r;
1921 ptr[x + 1] = g;
1922 ptr[x + 0] = b;
1923 }
1924 }
1925 ptr += bpl;
1926 }
1927 }
1928} 2014}
1929
1930#endif 2015#endif
1931 2016
1932/* 2017/*
1933 * Check our parents are still who we think they are. 2018 * Check our parents are still who we think they are.
1934 * Do transparency updates if required 2019 * Do transparency updates if required
1957 if (rootdepth != wattr.depth) 2042 if (rootdepth != wattr.depth)
1958 { 2043 {
1959 if (am_transparent) 2044 if (am_transparent)
1960 { 2045 {
1961 pchanged = 1; 2046 pchanged = 1;
1962 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); 2047 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]);
1963 am_transparent = am_pixmap_trans = 0; 2048 am_transparent = am_pixmap_trans = 0;
1964 } 2049 }
1965 2050
1966 return pchanged; /* Don't try any more */ 2051 return pchanged; /* Don't try any more */
1967 } 2052 }
1983 i = (xa[XA_XSETROOTID] 2068 i = (xa[XA_XSETROOTID]
1984 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], 2069 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID],
1985 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2070 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1986 &nitems, &bytes_after, &prop) == Success); 2071 &nitems, &bytes_after, &prop) == Success);
1987 2072
1988 if (!i || prop == NULL) 2073 if (!i || prop == NULL
2074#if TINTING
2075 || !rs[Rs_color + Color_tint]
2076#endif
2077 )
1989 have_pixmap = 0; 2078 have_pixmap = 0;
1990 else 2079 else
1991 { 2080 {
1992 have_pixmap = 1; 2081 have_pixmap = 1;
1993 rootpixmap = *(Pixmap *)prop; 2082 rootpixmap = *(Pixmap *)prop;
2055 XFreePixmap (display->display, TermWin.pixmap); 2144 XFreePixmap (display->display, TermWin.pixmap);
2056 2145
2057#if TINTING 2146#if TINTING
2058 if (ISSET_PIXCOLOR (Color_tint)) 2147 if (ISSET_PIXCOLOR (Color_tint))
2059 { 2148 {
2060 unsigned short shade, rm, gm, bm; 2149 unsigned short rm, gm, bm;
2150 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2061 2151
2062 PixColors[Color_tint].get (display, rm, gm, bm); 2152 PixColorsFocused[Color_tint].get (display, rm, gm, bm);
2063 2153
2064 rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but... 2154 ShadeXImage (display, image, shade, rm, gm, bm);
2065
2066 /* Determine bitshift and bitmask values */
2067 switch (image->bits_per_pixel)
2068 {
2069 case 15: shade_ximage_15 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2070 case 16: shade_ximage_16 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2071 case 24: shade_ximage_24 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2072 case 32: shade_ximage_32 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2073 }
2074 } 2155 }
2075#endif 2156#endif
2076 2157
2077 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 2158 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
2078 szHint.width, szHint.height, image->depth); 2159 szHint.width, szHint.height, image->depth);
2079 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); 2160 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue);
2080 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, 2161 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0,
2081 nx, ny, image->width, image->height); 2162 nx, ny, image->width, image->height);
2082 XFreeGC (display->display, gc); 2163 XFreeGC (display->display, gc);
2083 XDestroyImage (image); 2164 XDestroyImage (image);
2084 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2165 XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap);
2085 TermWin.pixmap); 2166 XClearWindow (display->display, TermWin.parent[0]);
2086 2167
2087 if (!am_transparent || !am_pixmap_trans) 2168 if (!am_transparent || !am_pixmap_trans)
2088 pchanged = 1; 2169 pchanged = 1;
2089 2170
2090 am_transparent = am_pixmap_trans = 1; 2171 am_transparent = am_pixmap_trans = 1;
2135 } 2216 }
2136 2217
2137 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) 2218 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
2138 { 2219 {
2139 D_X ((stderr, "InheritPixmap Turning off")); 2220 D_X ((stderr, "InheritPixmap Turning off"));
2140 XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); 2221 XSetWindowBackground (display->display, TermWin.parent[0], PixColorsFocused[Color_fg]);
2141 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); 2222 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]);
2142 am_transparent = 0; 2223 am_transparent = 0;
2143 /* XXX: also turn off Opt_transparent? */ 2224 /* XXX: also turn off Opt_transparent? */
2144 } 2225 }
2145 else 2226 else
2146 { 2227 {
2149 * needed for fvwm2.2.2 (and before?) */ 2230 * needed for fvwm2.2.2 (and before?) */
2150 sleep (1); 2231 sleep (1);
2151#endif 2232#endif
2152 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); 2233 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
2153 for (n = 0; n < (unsigned int)i; n++) 2234 for (n = 0; n < (unsigned int)i; n++)
2235 {
2154 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); 2236 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative);
2237 XClearWindow (display->display, TermWin.parent[n]);
2238 }
2155 2239
2156 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); 2240 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
2157 am_transparent = 1; 2241 am_transparent = 1;
2158 } 2242 }
2159 2243
2160 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2244 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2161 TermWin.parent[i] = None; 2245 TermWin.parent[i] = None;
2246 }
2247
2248 // this is experimental
2249 if (scrollBar.win)
2250 {
2251 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
2252 XClearWindow (display->display, scrollBar.win);
2253 scrollBar.setIdle ();
2254 scrollbar_show (0);
2162 } 2255 }
2163 2256
2164 return pchanged; 2257 return pchanged;
2165} 2258}
2166#endif 2259#endif
2191 unicode_t buf[UBUFSIZ]; 2284 unicode_t buf[UBUFSIZ];
2192 bool refreshnow = false; 2285 bool refreshnow = false;
2193 int nlines = 0; 2286 int nlines = 0;
2194 unicode_t *str = buf; 2287 unicode_t *str = buf;
2195 2288
2196 *str++ = ch;
2197
2198 for (;;) 2289 for (;;)
2199 { 2290 {
2200 seq_begin = cmdbuf_ptr;
2201 ch = next_char ();
2202
2203 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2291 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
2204 break; 2292 break;
2205 2293
2206 *str++ = ch; 2294 *str++ = ch;
2207 2295
2208 if (ch == C0_LF) 2296 if (ch == C0_LF)
2209 { 2297 {
2210 nlines++; 2298 nlines++;
2211 refresh_count++; 2299 refresh_count++;
2212 2300
2213 if (! (Options & Opt_jumpScroll) 2301 if (!(Options & Opt_jumpScroll)
2214 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) 2302 || (refresh_count >= refresh_limit * (TermWin.nrow - 1)))
2215 { 2303 {
2216 refreshnow = true; 2304 refreshnow = true;
2217 flag = true;
2218 ch = NOCHAR; 2305 ch = NOCHAR;
2219 break; 2306 break;
2220 } 2307 }
2221 2308
2222 // scr_add_lines only works for nlines < TermWin.nrow - 1. 2309 // scr_add_lines only works for nlines <= TermWin.nrow - 1.
2223 if (nlines >= TermWin.nrow - 1) 2310 if (nlines >= TermWin.nrow - 1)
2224 { 2311 {
2225 scr_add_lines (buf, nlines, str - buf); 2312 scr_add_lines (buf, nlines, str - buf);
2226 nlines = 0; 2313 nlines = 0;
2227 str = buf; 2314 str = buf;
2231 if (str >= buf + UBUFSIZ) 2318 if (str >= buf + UBUFSIZ)
2232 { 2319 {
2233 ch = NOCHAR; 2320 ch = NOCHAR;
2234 break; 2321 break;
2235 } 2322 }
2323
2324 seq_begin = cmdbuf_ptr;
2325 ch = next_char ();
2236 } 2326 }
2237 2327
2238 scr_add_lines (buf, nlines, str - buf); 2328 scr_add_lines (buf, nlines, str - buf);
2239 2329
2240 /* 2330 /*
2241 * If there have been a lot of new lines, then update the screen 2331 * If there have been a lot of new lines, then update the screen
2242 * What the heck I'll cheat and only refresh less than every page-full. 2332 * What the heck I'll cheat and only refresh less than every page-full.
2243 * the number of pages between refreshes is refresh_limit, which 2333 * the number of pages between refreshes is refresh_limit, which
2244 * is incremented here because we must be doing flat-out scrolling. 2334 * is incremented here because we must be doing flat-out scrolling.
2245 *
2246 * refreshing should be correct for small scrolls, because of the
2247 * time-out
2248 */ 2335 */
2249 if (refreshnow) 2336 if (refreshnow)
2250 { 2337 {
2251 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2338 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2252 refresh_limit++; 2339 refresh_limit++;
2253 else 2340 else
2341 {
2342 flag = true;
2254 scr_refresh (refresh_type); 2343 scr_refresh (refresh_type);
2344 }
2255 } 2345 }
2256 2346
2257 } 2347 }
2258 else 2348 else
2259 { 2349 {
2273 } 2363 }
2274 2364
2275 return flag; 2365 return flag;
2276} 2366}
2277 2367
2368// read the next octet
2369unicode_t
2370rxvt_term::next_octet ()
2371{
2372 return cmdbuf_ptr < cmdbuf_endp
2373 ? *cmdbuf_ptr++
2374 : NOCHAR;
2375}
2376
2278// read the next character 2377// read the next character
2279unicode_t 2378unicode_t
2280rxvt_term::next_char () 2379rxvt_term::next_char ()
2281{ 2380{
2282 while (cmdbuf_ptr < cmdbuf_endp) 2381 while (cmdbuf_ptr < cmdbuf_endp)
2313 */ 2412 */
2314unicode_t 2413unicode_t
2315rxvt_term::cmd_getc () 2414rxvt_term::cmd_getc ()
2316{ 2415{
2317 unicode_t c = next_char (); 2416 unicode_t c = next_char ();
2417
2418 if (c == NOCHAR)
2419 throw out_of_input;
2420
2421 return c;
2422}
2423
2424unicode_t
2425rxvt_term::cmd_get8 ()
2426{
2427 unicode_t c = next_octet ();
2318 2428
2319 if (c == NOCHAR) 2429 if (c == NOCHAR)
2320 throw out_of_input; 2430 throw out_of_input;
2321 2431
2322 return c; 2432 return c;
2452 break; 2562 break;
2453 case C0_SI: /* shift in - acs */ 2563 case C0_SI: /* shift in - acs */
2454 scr_charset_choose (0); 2564 scr_charset_choose (0);
2455 break; 2565 break;
2456 2566
2567#ifdef EIGHT_BIT_CONTROLS
2457 // 8-bit controls 2568 // 8-bit controls
2458 case 0x90: /* DCS */ 2569 case 0x90: /* DCS */
2459 process_dcs_seq (); 2570 process_dcs_seq ();
2460 break; 2571 break;
2461 case 0x9b: /* CSI */ 2572 case 0x9b: /* CSI */
2462 process_csi_seq (); 2573 process_csi_seq ();
2463 break; 2574 break;
2464 case 0x9d: /* CSI */ 2575 case 0x9d: /* CSI */
2465 process_osc_seq (); 2576 process_osc_seq ();
2466 break; 2577 break;
2578#endif
2467 } 2579 }
2468} 2580}
2469/*}}} */ 2581/*}}} */
2470 2582
2471 2583
3089 * ends_how is terminator used. returned input must be free()'d 3201 * ends_how is terminator used. returned input must be free()'d
3090 */ 3202 */
3091unsigned char * 3203unsigned char *
3092rxvt_term::get_to_st (unicode_t &ends_how) 3204rxvt_term::get_to_st (unicode_t &ends_how)
3093{ 3205{
3094 int seen_esc = 0; /* seen escape? */ 3206 unicode_t prev = 0, ch;
3095 unsigned int n = 0; 3207 unsigned int n = 0;
3096 unsigned char *s; 3208 unsigned char *s;
3097 unicode_t ch;
3098 unsigned char string[STRING_MAX]; 3209 unsigned char string[STRING_MAX];
3099 3210
3100 while ((ch = cmd_getc ())) 3211 while ((ch = cmd_getc ()) != NOCHAR)
3101 { 3212 {
3102 if (ch == C0_BEL || ch == CHAR_ST) 3213 if (prev == C0_ESC)
3103 break; 3214 {
3104
3105 if (seen_esc)
3106 if (ch == 0x5c) /* 7bit ST */ 3215 if (ch == 0x5c) /* 7bit ST */
3107 break; 3216 break;
3108 else 3217 else
3109 return NULL; 3218 return NULL;
3110
3111 if (ch == C0_ESC)
3112 { 3219 }
3113 seen_esc = 1; 3220 else if (ch == C0_BEL || ch == CHAR_ST)
3114 continue; 3221 break;
3115 }
3116 else if (ch == C0_HT) 3222 else if (ch < 0x20)
3117 ch = ' '; /* translate '\t' to space */
3118 else if (ch < 0x20 && (ch != C0_LF && ch != C0_CR))
3119 return NULL; /* other control character - exit */ 3223 return NULL; /* other control character - exit */
3120 3224
3121 if (n >= sizeof (string) - 1) 3225 if (n >= sizeof (string) - 1)
3122 // stop at some sane length 3226 // stop at some sane length
3123 return NULL; 3227 return NULL;
3124 3228
3229 if (ch == C0_SYN)
3230 {
3231 string[n++] = cmd_get8 ();
3232 prev = 0;
3233 }
3234 else
3125 string[n++] = ch; 3235 string[n++] = prev = ch;
3126 seen_esc = 0;
3127 } 3236 }
3128 3237
3129 string[n++] = '\0'; 3238 string[n++] = '\0';
3130 3239
3131 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) 3240 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL)
3188 if (str[0] == '?' && !str[1]) 3297 if (str[0] == '?' && !str[1])
3189 { 3298 {
3190 if (Options & Opt_insecure) 3299 if (Options & Opt_insecure)
3191 { 3300 {
3192 unsigned short r, g, b; 3301 unsigned short r, g, b;
3193 PixColors[color].get (display, r, g, b); 3302 PixColorsFocused[color].get (display, r, g, b);
3194 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); 3303 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp);
3195 } 3304 }
3196 } 3305 }
3197 else 3306 else
3198 set_window_color (color, str); 3307 set_window_color (color, str);
3303 if (name[0] == '?' && !name[1]) 3412 if (name[0] == '?' && !name[1])
3304 { 3413 {
3305 if (Options & Opt_insecure) 3414 if (Options & Opt_insecure)
3306 { 3415 {
3307 unsigned short r, g, b; 3416 unsigned short r, g, b;
3308 PixColors[color + minCOLOR].get (display, r, g, b); 3417 PixColorsFocused[color + minCOLOR].get (display, r, g, b);
3309 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3418 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3310 } 3419 }
3311 } 3420 }
3312 else 3421 else
3313 set_window_color (color + minCOLOR, name); 3422 set_window_color (color + minCOLOR, name);
3686 rendset = 0, rendstyle = ~RS_None; 3795 rendset = 0, rendstyle = ~RS_None;
3687 break; 3796 break;
3688 case 1: 3797 case 1:
3689 rendset = 1, rendstyle = RS_Bold; 3798 rendset = 1, rendstyle = RS_Bold;
3690 break; 3799 break;
3800 //case 2: // faint or second colour
3691 case 4: 3801 case 4:
3692 rendset = 1, rendstyle = RS_Uline; 3802 rendset = 1, rendstyle = RS_Uline;
3693 break; 3803 break;
3694 case 5: 3804 case 5: // slowly blinking
3805 case 6: // rapidly blinking
3695 rendset = 1, rendstyle = RS_Blink; 3806 rendset = 1, rendstyle = RS_Blink;
3696 break; 3807 break;
3697 //case 6: // scoansi light background 3808 //case 6: // scoansi light background
3698 case 7: 3809 case 7:
3699 rendset = 1, rendstyle = RS_RVid; 3810 rendset = 1, rendstyle = RS_RVid;
3700 break; 3811 break;
3701 case 8: 3812 case 8:
3702 // invisible. NYI 3813 // invisible. NYI
3703 break; 3814 break;
3815 //case 9: // crossed out
3704 //case 10: // scoansi acs off 3816 //case 10: // scoansi acs off, primary font
3705 //case 11: // scoansi acs on 3817 //case 11: // scoansi acs on, first alt font
3706 //case 12: // scoansi acs on, |0x80 3818 //case 12: // scoansi acs on, |0x80, second alt font
3707 case 21: // disable bold, blink and invis (some terminals use this) 3819 //...
3820 //case 19: // ninth alt font
3821 //case 20: // gothic
3822 case 21: // disable bold, faint
3708 rendset = 0, rendstyle = RS_Bold | RS_Blink; 3823 rendset = 0, rendstyle = RS_Bold;
3709 break; 3824 break;
3710 case 22: 3825 case 22:
3711 rendset = 0, rendstyle = RS_Bold; 3826 rendset = 0, rendstyle = RS_Bold;
3712 break; 3827 break;
3828 //case 23: disable italic
3713 case 24: 3829 case 24:
3714 rendset = 0, rendstyle = RS_Uline; 3830 rendset = 0, rendstyle = RS_Uline;
3715 break; 3831 break;
3716 case 25: 3832 case 25:
3717 rendset = 0, rendstyle = RS_Blink; 3833 rendset = 0, rendstyle = RS_Blink;
3718 break; 3834 break;
3719 case 27: 3835 case 27:
3720 rendset = 0, rendstyle = RS_RVid; 3836 rendset = 0, rendstyle = RS_RVid;
3721 break; 3837 break;
3722 case 28:
3723 // visible. NYI 3838 //case 28: // visible. NYI
3724 break; 3839 //case 29: // not crossed-out
3725 } 3840 }
3726 3841
3727 if (rendset != -1) 3842 if (rendset != -1)
3728 { 3843 {
3729 scr_rendition (rendset, rendstyle); 3844 scr_rendition (rendset, rendstyle);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines