1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: command.c |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * - original version |
7 | * - original version |
… | |
… | |
672 | scr_refresh (refresh_type); |
672 | scr_refresh (refresh_type); |
673 | scrollbar_show (1); |
673 | scrollbar_show (1); |
674 | #ifdef USE_XIM |
674 | #ifdef USE_XIM |
675 | IMSendSpot (); |
675 | IMSendSpot (); |
676 | #endif |
676 | #endif |
677 | |
|
|
678 | } |
677 | } |
679 | |
678 | |
680 | display->flush (); |
679 | display->flush (); |
681 | } |
680 | } |
682 | |
681 | |
… | |
… | |
711 | w.start (w.at + TEXT_BLINK_INTERVAL); |
710 | w.start (w.at + TEXT_BLINK_INTERVAL); |
712 | } |
711 | } |
713 | } |
712 | } |
714 | #endif |
713 | #endif |
715 | |
714 | |
|
|
715 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
716 | void |
|
|
717 | rxvt_term::cont_scroll_cb (time_watcher &w) |
|
|
718 | { |
|
|
719 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
|
|
720 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
|
|
721 | { |
|
|
722 | refresh_type |= SMOOTH_REFRESH; |
|
|
723 | want_refresh = 1; |
|
|
724 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
725 | } |
|
|
726 | } |
|
|
727 | #endif |
|
|
728 | |
|
|
729 | #ifdef SELECTION_SCROLLING |
|
|
730 | void |
|
|
731 | rxvt_term::sel_scroll_cb (time_watcher &w) |
|
|
732 | { |
|
|
733 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
|
|
734 | { |
|
|
735 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
|
|
736 | refresh_type |= SMOOTH_REFRESH; |
|
|
737 | want_refresh = 1; |
|
|
738 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
739 | } |
|
|
740 | } |
|
|
741 | #endif |
|
|
742 | |
|
|
743 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
744 | void |
|
|
745 | rxvt_term::slip_wheel_cb (time_watcher &w) |
|
|
746 | { |
|
|
747 | if (mouse_slip_wheel_speed == 0 |
|
|
748 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
|
|
749 | : scr_page (UP, mouse_slip_wheel_speed)) |
|
|
750 | { |
|
|
751 | refresh_type |= SMOOTH_REFRESH; |
|
|
752 | want_refresh = 1; |
|
|
753 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
754 | } |
|
|
755 | } |
|
|
756 | #endif |
|
|
757 | |
716 | bool |
758 | bool |
717 | rxvt_term::pty_fill () |
759 | rxvt_term::pty_fill () |
718 | { |
760 | { |
719 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
761 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
|
|
762 | |
|
|
763 | if (CBUFSIZ == n) |
|
|
764 | { |
|
|
765 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
|
|
766 | n = 0; |
|
|
767 | } |
720 | |
768 | |
721 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
769 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
722 | cmdbuf_ptr = cmdbuf_base; |
770 | cmdbuf_ptr = cmdbuf_base; |
723 | cmdbuf_endp = cmdbuf_ptr + n; |
771 | cmdbuf_endp = cmdbuf_ptr + n; |
724 | |
772 | |
… | |
… | |
742 | SET_LOCALE (locale); |
790 | SET_LOCALE (locale); |
743 | |
791 | |
744 | if (revents & EVENT_WRITE) |
792 | if (revents & EVENT_WRITE) |
745 | tt_write (0, 0); |
793 | tt_write (0, 0); |
746 | else if (revents & EVENT_READ) |
794 | else if (revents & EVENT_READ) |
747 | { |
|
|
748 | // loop, but don't allow a single term to monopolize us |
795 | // loop, but don't allow a single term to monopolize us |
749 | // the number of loops is fully arbitrary, and thus wrong |
|
|
750 | while (pty_fill ()) |
796 | while (pty_fill ()) |
751 | { |
|
|
752 | if (!seen_input) |
|
|
753 | { |
|
|
754 | seen_input = 1; |
|
|
755 | /* once we know the shell is running, send the screen size. Again! */ |
|
|
756 | // I don't know why, btw. |
|
|
757 | tt_winch (); |
|
|
758 | } |
|
|
759 | |
|
|
760 | if (cmd_parse ()) |
797 | if (cmd_parse ()) |
761 | break; |
798 | break; |
762 | } |
|
|
763 | } |
|
|
764 | } |
799 | } |
765 | |
800 | |
766 | #ifdef POINTER_BLANK |
|
|
767 | void |
801 | void |
768 | rxvt_term::pointer_unblank () |
802 | rxvt_term::pointer_unblank () |
769 | { |
803 | { |
770 | XDefineCursor (display->display, TermWin.vt, TermWin_cursor); |
804 | XDefineCursor (display->display, TermWin.vt, TermWin_cursor); |
771 | recolour_cursor (); |
805 | recolour_cursor (); |
772 | |
806 | |
|
|
807 | #ifdef POINTER_BLANK |
773 | hidden_pointer = 0; |
808 | hidden_pointer = 0; |
774 | |
809 | |
775 | if (Options & Opt_pointerBlank) |
810 | if (Options & Opt_pointerBlank) |
776 | pointer_ev.start (NOW + pointerBlankDelay); |
811 | pointer_ev.start (NOW + pointerBlankDelay); |
|
|
812 | #endif |
777 | } |
813 | } |
778 | |
814 | |
|
|
815 | #ifdef POINTER_BLANK |
779 | void |
816 | void |
780 | rxvt_term::pointer_blank () |
817 | rxvt_term::pointer_blank () |
781 | { |
818 | { |
782 | if (! (Options & Opt_pointerBlank)) |
819 | if (! (Options & Opt_pointerBlank)) |
783 | return; |
820 | return; |
… | |
… | |
979 | break; |
1016 | break; |
980 | |
1017 | |
981 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1018 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
982 | case KeyRelease: |
1019 | case KeyRelease: |
983 | { |
1020 | { |
984 | if (! (ev.xkey.state & ControlMask)) |
1021 | if (!(ev.xkey.state & ControlMask)) |
985 | mouse_slip_wheel_speed = 0; |
1022 | slip_wheel_ev.stop (); |
986 | else |
1023 | else |
987 | { |
1024 | { |
988 | KeySym ks; |
1025 | KeySym ks; |
989 | |
1026 | |
990 | ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); |
1027 | ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); |
991 | if (ks == XK_Control_L || ks == XK_Control_R) |
1028 | if (ks == XK_Control_L || ks == XK_Control_R) |
992 | mouse_slip_wheel_speed = 0; |
1029 | mouse_slip_wheel_speed = 0; |
993 | } |
1030 | } |
… | |
… | |
1013 | && (ev.xclient.data.l[0] == DndFile |
1050 | && (ev.xclient.data.l[0] == DndFile |
1014 | || ev.xclient.data.l[0] == DndDir |
1051 | || ev.xclient.data.l[0] == DndDir |
1015 | || ev.xclient.data.l[0] == DndLink)) |
1052 | || ev.xclient.data.l[0] == DndLink)) |
1016 | { |
1053 | { |
1017 | /* Get Dnd data */ |
1054 | /* Get Dnd data */ |
1018 | Atom ActualType; |
1055 | Atom ActualType; |
1019 | int ActualFormat; |
1056 | int ActualFormat; |
1020 | unsigned char *data; |
1057 | unsigned char *data; |
1021 | unsigned long Size, RemainingBytes; |
1058 | unsigned long Size, RemainingBytes; |
1022 | |
1059 | |
1023 | XGetWindowProperty (display->display, display->root, |
1060 | XGetWindowProperty (display->display, display->root, |
1024 | xa[XA_DNDSELECTION], |
1061 | xa[XA_DNDSELECTION], |
1025 | 0L, 1000000L, |
1062 | 0L, 1000000L, |
1026 | False, AnyPropertyType, |
1063 | False, AnyPropertyType, |
… | |
… | |
1029 | &data); |
1066 | &data); |
1030 | XChangeProperty (display->display, display->root, |
1067 | XChangeProperty (display->display, display->root, |
1031 | XA_CUT_BUFFER0, XA_STRING, |
1068 | XA_CUT_BUFFER0, XA_STRING, |
1032 | 8, PropModeReplace, |
1069 | 8, PropModeReplace, |
1033 | data, STRLEN (data)); |
1070 | data, STRLEN (data)); |
|
|
1071 | XFree (data); |
1034 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1072 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1035 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1073 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1036 | } |
1074 | } |
1037 | #endif /* OFFIX_DND */ |
1075 | #endif /* OFFIX_DND */ |
1038 | break; |
1076 | break; |
… | |
… | |
1077 | #endif |
1115 | #endif |
1078 | #ifdef CURSOR_BLINK |
1116 | #ifdef CURSOR_BLINK |
1079 | if (Options & Opt_cursorBlink) |
1117 | if (Options & Opt_cursorBlink) |
1080 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1118 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1081 | #endif |
1119 | #endif |
|
|
1120 | #ifdef OFF_FOCUS_FADING |
|
|
1121 | if (rs[Rs_fade]) |
|
|
1122 | { |
|
|
1123 | PixColors = PixColorsFocused; |
|
|
1124 | set_colorfgbg (); |
|
|
1125 | scr_clear (); |
|
|
1126 | scr_touch (true); |
|
|
1127 | } |
|
|
1128 | #endif |
1082 | |
1129 | |
1083 | } |
1130 | } |
1084 | break; |
1131 | break; |
1085 | |
1132 | |
1086 | case FocusOut: |
1133 | case FocusOut: |
… | |
… | |
1094 | #endif |
1141 | #endif |
1095 | #ifdef CURSOR_BLINK |
1142 | #ifdef CURSOR_BLINK |
1096 | if (Options & Opt_cursorBlink) |
1143 | if (Options & Opt_cursorBlink) |
1097 | cursor_blink_ev.stop (); |
1144 | cursor_blink_ev.stop (); |
1098 | hidden_cursor = 0; |
1145 | hidden_cursor = 0; |
|
|
1146 | #endif |
|
|
1147 | #ifdef OFF_FOCUS_FADING |
|
|
1148 | if (rs[Rs_fade]) |
|
|
1149 | { |
|
|
1150 | PixColors = PixColorsUnFocused; |
|
|
1151 | set_colorfgbg (); |
|
|
1152 | scr_clear (); |
|
|
1153 | scr_touch (true); |
|
|
1154 | } |
1099 | #endif |
1155 | #endif |
1100 | |
1156 | |
1101 | } |
1157 | } |
1102 | break; |
1158 | break; |
1103 | |
1159 | |
… | |
… | |
1176 | { |
1232 | { |
1177 | #ifdef NO_SLOW_LINK_SUPPORT |
1233 | #ifdef NO_SLOW_LINK_SUPPORT |
1178 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1234 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1179 | ev.xexpose.width, ev.xexpose.height, False); |
1235 | ev.xexpose.width, ev.xexpose.height, False); |
1180 | #else |
1236 | #else |
1181 | // don't understand this, so commented it out |
1237 | // I don't understand this, so I changed it :) |
1182 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1238 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1183 | ev.xexpose.width, ev.xexpose.height, False); |
1239 | ev.xexpose.width, ev.xexpose.height, False); |
1184 | //scr_expose (ev.xexpose.x, 0, |
1240 | //scr_expose (ev.xexpose.x, 0, |
1185 | // ev.xexpose.width, TermWin.height, False); |
1241 | // ev.xexpose.width, TermWin.height, False); |
1186 | #endif |
1242 | #endif |
… | |
… | |
1188 | } |
1244 | } |
1189 | else |
1245 | else |
1190 | { |
1246 | { |
1191 | XEvent unused_event; |
1247 | XEvent unused_event; |
1192 | |
1248 | |
1193 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1249 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1194 | Expose, |
1250 | ; |
1195 | &unused_event)) ; |
|
|
1196 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1251 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1197 | GraphicsExpose, |
1252 | ; |
1198 | &unused_event)) ; |
1253 | |
1199 | if (isScrollbarWindow (ev.xany.window)) |
1254 | if (isScrollbarWindow (ev.xany.window)) |
1200 | { |
1255 | { |
1201 | scrollBar.setIdle (); |
1256 | scrollBar.setIdle (); |
1202 | scrollbar_show (0); |
1257 | scrollbar_show (0); |
1203 | } |
1258 | } |
… | |
… | |
1246 | if (ev.xbutton.y < TermWin.int_bwidth |
1301 | if (ev.xbutton.y < TermWin.int_bwidth |
1247 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1302 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1248 | { |
1303 | { |
1249 | int dist; |
1304 | int dist; |
1250 | |
1305 | |
1251 | pending_scroll_selection=1; |
|
|
1252 | |
|
|
1253 | /* don't clobber the current delay if we are |
1306 | /* don't clobber the current delay if we are |
1254 | * already in the middle of scrolling. |
1307 | * already in the middle of scrolling. |
1255 | */ |
1308 | */ |
1256 | if (scroll_selection_delay<=0) |
1309 | if (!sel_scroll_ev.active) |
1257 | scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; |
1310 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1258 | |
1311 | |
1259 | /* save the event params so we can highlight |
1312 | /* save the event params so we can highlight |
1260 | * the selection in the pending-scroll loop |
1313 | * the selection in the pending-scroll loop |
1261 | */ |
1314 | */ |
1262 | selection_save_x=ev.xbutton.x; |
1315 | selection_save_x=ev.xbutton.x; |
… | |
… | |
1284 | else |
1337 | else |
1285 | { |
1338 | { |
1286 | /* we are within the text window, so we |
1339 | /* we are within the text window, so we |
1287 | * shouldn't be scrolling |
1340 | * shouldn't be scrolling |
1288 | */ |
1341 | */ |
1289 | pending_scroll_selection = 0; |
1342 | if (sel_scroll_ev.active) |
|
|
1343 | sel_scroll_ev.stop(); |
1290 | } |
1344 | } |
1291 | #endif |
1345 | #endif |
1292 | #ifdef MOUSE_THRESHOLD |
1346 | #ifdef MOUSE_THRESHOLD |
1293 | |
1347 | |
1294 | } |
1348 | } |
… | |
… | |
1511 | upordown = 1; /* down */ |
1565 | upordown = 1; /* down */ |
1512 | } |
1566 | } |
1513 | if (upordown) |
1567 | if (upordown) |
1514 | { |
1568 | { |
1515 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1569 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1516 | scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; |
1570 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1517 | #endif |
1571 | #endif |
1518 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1572 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1519 | { |
1573 | { |
1520 | if (upordown < 0) |
1574 | if (upordown < 0) |
1521 | scrollBar.setUp (); |
1575 | scrollBar.setUp (); |
… | |
… | |
1608 | refresh_type &= ~SMOOTH_REFRESH; |
1662 | refresh_type &= ~SMOOTH_REFRESH; |
1609 | #endif |
1663 | #endif |
1610 | |
1664 | |
1611 | } |
1665 | } |
1612 | #ifdef SELECTION_SCROLLING |
1666 | #ifdef SELECTION_SCROLLING |
1613 | pending_scroll_selection=0; |
1667 | if (sel_scroll_ev.active) |
|
|
1668 | sel_scroll_ev.stop(); |
1614 | #endif |
1669 | #endif |
1615 | if (ev.window == TermWin.vt) |
1670 | if (ev.window == TermWin.vt) |
1616 | { |
1671 | { |
1617 | if (reportmode) |
1672 | if (reportmode) |
1618 | { |
1673 | { |
… | |
… | |
1660 | case Button5: |
1715 | case Button5: |
1661 | { |
1716 | { |
1662 | int i; |
1717 | int i; |
1663 | page_dirn v; |
1718 | page_dirn v; |
1664 | |
1719 | |
1665 | v = (ev.button == Button4) ? UP : DN; |
1720 | v = ev.button == Button4 ? UP : DN; |
|
|
1721 | |
1666 | if (ev.state & ShiftMask) |
1722 | if (ev.state & ShiftMask) |
1667 | i = 1; |
1723 | i = 1; |
1668 | else if ((Options & Opt_mouseWheelScrollPage)) |
1724 | else if (Options & Opt_mouseWheelScrollPage) |
1669 | i = TermWin.nrow - 1; |
1725 | i = TermWin.nrow - 1; |
1670 | else |
1726 | else |
1671 | i = 5; |
1727 | i = 5; |
|
|
1728 | |
1672 | # ifdef MOUSE_SLIP_WHEELING |
1729 | # ifdef MOUSE_SLIP_WHEELING |
1673 | if (ev.state & ControlMask) |
1730 | if (ev.state & ControlMask) |
1674 | { |
1731 | { |
1675 | mouse_slip_wheel_speed += (v ? -1 : 1); |
1732 | mouse_slip_wheel_speed += v ? -1 : 1; |
|
|
1733 | if (mouse_slip_wheel_speed < -TermWin.nrow) mouse_slip_wheel_speed = -TermWin.nrow; |
|
|
1734 | if (mouse_slip_wheel_speed > +TermWin.nrow) mouse_slip_wheel_speed = +TermWin.nrow; |
|
|
1735 | |
|
|
1736 | if (slip_wheel_ev.at < NOW) |
1676 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1737 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
|
|
1738 | |
|
|
1739 | slip_wheel_ev.start (); |
1677 | } |
1740 | } |
|
|
1741 | else |
|
|
1742 | { |
1678 | # endif |
1743 | # endif |
1679 | # ifdef JUMP_MOUSE_WHEEL |
1744 | # ifdef JUMP_MOUSE_WHEEL |
1680 | scr_page (v, i); |
|
|
1681 | scr_refresh (SMOOTH_REFRESH); |
|
|
1682 | scrollbar_show (1); |
|
|
1683 | # else |
|
|
1684 | while (i--) |
|
|
1685 | { |
|
|
1686 | scr_page (v, 1); |
1745 | scr_page (v, i); |
1687 | scr_refresh (SMOOTH_REFRESH); |
1746 | scr_refresh (SMOOTH_REFRESH); |
1688 | scrollbar_show (1); |
1747 | scrollbar_show (1); |
|
|
1748 | # else |
|
|
1749 | while (i--) |
|
|
1750 | { |
|
|
1751 | scr_page (v, 1); |
|
|
1752 | scr_refresh (SMOOTH_REFRESH); |
|
|
1753 | scrollbar_show (1); |
|
|
1754 | } |
|
|
1755 | # endif |
|
|
1756 | # ifdef MOUSE_SLIP_WHEELING |
1689 | } |
1757 | } |
1690 | # endif |
1758 | #endif |
1691 | |
|
|
1692 | } |
1759 | } |
1693 | break; |
1760 | break; |
1694 | #endif |
1761 | #endif |
1695 | |
|
|
1696 | } |
1762 | } |
1697 | } |
1763 | } |
1698 | #ifdef MENUBAR |
1764 | #ifdef MENUBAR |
1699 | else if (isMenuBarWindow (ev.window)) |
1765 | else if (isMenuBarWindow (ev.window)) |
1700 | menubar_control (ev); |
1766 | menubar_control (ev); |
… | |
… | |
1965 | if (rootdepth != wattr.depth) |
2031 | if (rootdepth != wattr.depth) |
1966 | { |
2032 | { |
1967 | if (am_transparent) |
2033 | if (am_transparent) |
1968 | { |
2034 | { |
1969 | pchanged = 1; |
2035 | pchanged = 1; |
1970 | XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); |
2036 | XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); |
1971 | am_transparent = am_pixmap_trans = 0; |
2037 | am_transparent = am_pixmap_trans = 0; |
1972 | } |
2038 | } |
1973 | |
2039 | |
1974 | return pchanged; /* Don't try any more */ |
2040 | return pchanged; /* Don't try any more */ |
1975 | } |
2041 | } |
… | |
… | |
1991 | i = (xa[XA_XSETROOTID] |
2057 | i = (xa[XA_XSETROOTID] |
1992 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2058 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
1993 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2059 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
1994 | &nitems, &bytes_after, &prop) == Success); |
2060 | &nitems, &bytes_after, &prop) == Success); |
1995 | |
2061 | |
1996 | if (!i || prop == NULL) |
2062 | if (!i || prop == NULL || !rs[Rs_color + Color_tint]) |
1997 | have_pixmap = 0; |
2063 | have_pixmap = 0; |
1998 | else |
2064 | else |
1999 | { |
2065 | { |
2000 | have_pixmap = 1; |
2066 | have_pixmap = 1; |
2001 | rootpixmap = * ((Pixmap *)prop); |
2067 | rootpixmap = *(Pixmap *)prop; |
2002 | XFree (prop); |
2068 | XFree (prop); |
2003 | } |
2069 | } |
2004 | |
2070 | |
2005 | if (have_pixmap) |
2071 | if (have_pixmap) |
2006 | { |
2072 | { |
… | |
… | |
2012 | Window cr; |
2078 | Window cr; |
2013 | XImage *image; |
2079 | XImage *image; |
2014 | GC gc; |
2080 | GC gc; |
2015 | XGCValues gcvalue; |
2081 | XGCValues gcvalue; |
2016 | |
2082 | |
2017 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2083 | XTranslateCoordinates (display->display, TermWin.vt, display->root, |
2018 | 0, 0, &sx, &sy, &cr); |
2084 | 0, 0, &sx, &sy, &cr); |
2019 | nw = (unsigned int)szHint.width; |
2085 | nw = (unsigned int)szHint.width; |
2020 | nh = (unsigned int)szHint.height; |
2086 | nh = (unsigned int)szHint.height; |
2021 | nx = ny = 0; |
2087 | nx = ny = 0; |
2022 | |
2088 | |
… | |
… | |
2063 | XFreePixmap (display->display, TermWin.pixmap); |
2129 | XFreePixmap (display->display, TermWin.pixmap); |
2064 | |
2130 | |
2065 | #if TINTING |
2131 | #if TINTING |
2066 | if (ISSET_PIXCOLOR (Color_tint)) |
2132 | if (ISSET_PIXCOLOR (Color_tint)) |
2067 | { |
2133 | { |
2068 | unsigned short shade, rm, gm, bm; |
2134 | unsigned short rm, gm, bm; |
2069 | |
2135 | if (rs[Rs_shade]) |
|
|
2136 | PixColorsFocused[Color_tint].fade (display, atoi (rs[Rs_shade])).get (display, rm, gm, bm); |
|
|
2137 | else |
2070 | PixColors[Color_tint].get (display, rm, gm, bm); |
2138 | PixColorsFocused[Color_tint].get (display, rm, gm, bm); |
2071 | |
2139 | |
2072 | rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but... |
2140 | rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but... |
2073 | |
2141 | |
2074 | /* Determine bitshift and bitmask values */ |
2142 | /* Determine bitshift and bitmask values */ |
2075 | switch (image->bits_per_pixel) |
2143 | switch (image->bits_per_pixel) |
… | |
… | |
2087 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2155 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2088 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2156 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2089 | nx, ny, image->width, image->height); |
2157 | nx, ny, image->width, image->height); |
2090 | XFreeGC (display->display, gc); |
2158 | XFreeGC (display->display, gc); |
2091 | XDestroyImage (image); |
2159 | XDestroyImage (image); |
2092 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2160 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap); |
2093 | TermWin.pixmap); |
|
|
2094 | |
2161 | |
2095 | if (!am_transparent || !am_pixmap_trans) |
2162 | if (!am_transparent || !am_pixmap_trans) |
2096 | pchanged = 1; |
2163 | pchanged = 1; |
2097 | |
2164 | |
2098 | am_transparent = am_pixmap_trans = 1; |
2165 | am_transparent = am_pixmap_trans = 1; |
… | |
… | |
2142 | } |
2209 | } |
2143 | } |
2210 | } |
2144 | |
2211 | |
2145 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2212 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2146 | { |
2213 | { |
2147 | D_X ((stderr, "InheritPixmap Turning off")); |
2214 | D_X ((stderr, "InheritPixmap Turning off")); /* Mikachu? */ |
2148 | XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); |
2215 | XSetWindowBackground (display->display, TermWin.parent[0], PixColorsFocused[Color_fg]); |
2149 | XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); |
2216 | XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); |
2150 | am_transparent = 0; |
2217 | am_transparent = 0; |
2151 | /* XXX: also turn off Opt_transparent? */ |
2218 | /* XXX: also turn off Opt_transparent? */ |
2152 | } |
2219 | } |
2153 | else |
2220 | else |
2154 | { |
2221 | { |
… | |
… | |
2191 | } |
2258 | } |
2192 | |
2259 | |
2193 | if (ch == NOCHAR) // TODO: improve |
2260 | if (ch == NOCHAR) // TODO: improve |
2194 | break; |
2261 | break; |
2195 | |
2262 | |
2196 | if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r') |
2263 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2197 | { |
2264 | { |
2198 | /* Read a text string from the input buffer */ |
2265 | /* Read a text string from the input buffer */ |
2199 | unicode_t buf[UBUFSIZ]; |
2266 | unicode_t buf[UBUFSIZ]; |
2200 | bool refreshnow = false; |
2267 | bool refreshnow = false; |
2201 | int nlines = 0; |
2268 | int nlines = 0; |
… | |
… | |
2206 | for (;;) |
2273 | for (;;) |
2207 | { |
2274 | { |
2208 | seq_begin = cmdbuf_ptr; |
2275 | seq_begin = cmdbuf_ptr; |
2209 | ch = next_char (); |
2276 | ch = next_char (); |
2210 | |
2277 | |
2211 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r')) |
2278 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2212 | break; |
2279 | break; |
2213 | |
2280 | |
2214 | *str++ = ch; |
2281 | *str++ = ch; |
2215 | |
2282 | |
2216 | if (ch == '\n') |
2283 | if (ch == C0_LF) |
2217 | { |
2284 | { |
2218 | nlines++; |
2285 | nlines++; |
2219 | refresh_count++; |
2286 | refresh_count++; |
2220 | |
2287 | |
2221 | if (! (Options & Opt_jumpScroll) |
2288 | if (! (Options & Opt_jumpScroll) |
… | |
… | |
2256 | */ |
2323 | */ |
2257 | if (refreshnow) |
2324 | if (refreshnow) |
2258 | { |
2325 | { |
2259 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2326 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2260 | refresh_limit++; |
2327 | refresh_limit++; |
2261 | |
2328 | else |
2262 | scr_refresh (refresh_type); |
2329 | scr_refresh (refresh_type); |
2263 | } |
2330 | } |
2264 | |
2331 | |
2265 | } |
2332 | } |
2266 | else |
2333 | else |
2267 | { |
2334 | { |
… | |
… | |
2281 | } |
2348 | } |
2282 | |
2349 | |
2283 | return flag; |
2350 | return flag; |
2284 | } |
2351 | } |
2285 | |
2352 | |
|
|
2353 | // read the next octet |
|
|
2354 | unicode_t |
|
|
2355 | rxvt_term::next_octet () |
|
|
2356 | { |
|
|
2357 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2358 | ? *cmdbuf_ptr++ |
|
|
2359 | : NOCHAR; |
|
|
2360 | } |
|
|
2361 | |
2286 | // read the next character |
2362 | // read the next character |
2287 | unicode_t |
2363 | unicode_t |
2288 | rxvt_term::next_char () |
2364 | rxvt_term::next_char () |
2289 | { |
2365 | { |
2290 | while (cmdbuf_ptr < cmdbuf_endp) |
2366 | while (cmdbuf_ptr < cmdbuf_endp) |
… | |
… | |
2321 | */ |
2397 | */ |
2322 | unicode_t |
2398 | unicode_t |
2323 | rxvt_term::cmd_getc () |
2399 | rxvt_term::cmd_getc () |
2324 | { |
2400 | { |
2325 | unicode_t c = next_char (); |
2401 | unicode_t c = next_char (); |
|
|
2402 | |
|
|
2403 | if (c == NOCHAR) |
|
|
2404 | throw out_of_input; |
|
|
2405 | |
|
|
2406 | return c; |
|
|
2407 | } |
|
|
2408 | |
|
|
2409 | unicode_t |
|
|
2410 | rxvt_term::cmd_get8 () |
|
|
2411 | { |
|
|
2412 | unicode_t c = next_octet (); |
2326 | |
2413 | |
2327 | if (c == NOCHAR) |
2414 | if (c == NOCHAR) |
2328 | throw out_of_input; |
2415 | throw out_of_input; |
2329 | |
2416 | |
2330 | return c; |
2417 | return c; |
… | |
… | |
2460 | break; |
2547 | break; |
2461 | case C0_SI: /* shift in - acs */ |
2548 | case C0_SI: /* shift in - acs */ |
2462 | scr_charset_choose (0); |
2549 | scr_charset_choose (0); |
2463 | break; |
2550 | break; |
2464 | |
2551 | |
|
|
2552 | #ifdef EIGHT_BIT_CONTROLS |
2465 | // 8-bit controls |
2553 | // 8-bit controls |
2466 | case 0x90: /* DCS */ |
2554 | case 0x90: /* DCS */ |
2467 | process_dcs_seq (); |
2555 | process_dcs_seq (); |
2468 | break; |
2556 | break; |
2469 | case 0x9b: /* CSI */ |
2557 | case 0x9b: /* CSI */ |
2470 | process_csi_seq (); |
2558 | process_csi_seq (); |
2471 | break; |
2559 | break; |
2472 | case 0x9d: /* CSI */ |
2560 | case 0x9d: /* CSI */ |
2473 | process_osc_seq (); |
2561 | process_osc_seq (); |
2474 | break; |
2562 | break; |
|
|
2563 | #endif |
2475 | } |
2564 | } |
2476 | } |
2565 | } |
2477 | /*}}} */ |
2566 | /*}}} */ |
2478 | |
2567 | |
2479 | |
2568 | |
… | |
… | |
2597 | break; |
2686 | break; |
2598 | |
2687 | |
2599 | /* 8.3.87: NEXT LINE */ |
2688 | /* 8.3.87: NEXT LINE */ |
2600 | case C1_NEL: /* ESC E */ |
2689 | case C1_NEL: /* ESC E */ |
2601 | { |
2690 | { |
2602 | unicode_t nlcr[] = { L'\n', L'\r' }; |
2691 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2603 | scr_add_lines (nlcr, 1, 2); |
2692 | scr_add_lines (nlcr, 1, 2); |
2604 | } |
2693 | } |
2605 | break; |
2694 | break; |
2606 | |
2695 | |
2607 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2696 | /* kidnapped escape sequence: Should be 8.3.48 */ |
… | |
… | |
2668 | |
2757 | |
2669 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2758 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2670 | /* *INDENT-OFF* */ |
2759 | /* *INDENT-OFF* */ |
2671 | enum { |
2760 | enum { |
2672 | CSI_ICH = 0x40, |
2761 | CSI_ICH = 0x40, |
2673 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2762 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2674 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
2763 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
2675 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
2764 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
2676 | CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F, |
2765 | CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F, |
2677 | CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC, |
2766 | CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC, |
2678 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2767 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
… | |
… | |
3092 | #endif |
3181 | #endif |
3093 | |
3182 | |
3094 | /*----------------------------------------------------------------------*/ |
3183 | /*----------------------------------------------------------------------*/ |
3095 | /* |
3184 | /* |
3096 | * get input up until STRING TERMINATOR (or BEL) |
3185 | * get input up until STRING TERMINATOR (or BEL) |
3097 | * ends_how is terminator used. returned input must be free ()d |
3186 | * ends_how is terminator used. returned input must be free()'d |
3098 | */ |
3187 | */ |
3099 | unsigned char * |
3188 | unsigned char * |
3100 | rxvt_term::get_to_st (unicode_t &ends_how) |
3189 | rxvt_term::get_to_st (unicode_t &ends_how) |
3101 | { |
3190 | { |
3102 | int seen_esc = 0; /* seen escape? */ |
3191 | unicode_t prev = 0, ch; |
3103 | unsigned int n = 0; |
3192 | unsigned int n = 0; |
3104 | unsigned char *s; |
3193 | unsigned char *s; |
3105 | unicode_t ch; |
|
|
3106 | unsigned char string[STRING_MAX]; |
3194 | unsigned char string[STRING_MAX]; |
3107 | |
3195 | |
3108 | while ((ch = cmd_getc ())) |
3196 | while ((ch = cmd_getc ()) != NOCHAR) |
3109 | { |
3197 | { |
3110 | if (ch == C0_BEL || ch == CHAR_ST) |
3198 | if (prev == C0_ESC) |
3111 | break; |
3199 | { |
3112 | |
|
|
3113 | if (seen_esc) |
|
|
3114 | if (ch == 0x5c) /* 7bit ST */ |
3200 | if (ch == 0x5c) /* 7bit ST */ |
3115 | break; |
3201 | break; |
3116 | else |
3202 | else |
3117 | return NULL; |
3203 | return NULL; |
3118 | |
|
|
3119 | if (ch == C0_ESC) |
|
|
3120 | { |
3204 | } |
3121 | seen_esc = 1; |
3205 | else if (ch == C0_BEL || ch == CHAR_ST) |
3122 | continue; |
3206 | break; |
3123 | } |
3207 | else if (ch < 0x20) |
3124 | else if (ch == '\t') |
|
|
3125 | ch = ' '; /* translate '\t' to space */ |
|
|
3126 | else if (ch < 0x20 && (ch != 0x0a && ch != 0x0d)) |
|
|
3127 | return NULL; /* other control character - exit */ |
3208 | return NULL; /* other control character - exit */ |
3128 | |
3209 | |
3129 | if (n >= sizeof (string) - 1) |
3210 | if (n >= sizeof (string) - 1) |
3130 | // stop at some sane length |
3211 | // stop at some sane length |
3131 | return NULL; |
3212 | return NULL; |
3132 | |
3213 | |
|
|
3214 | if (ch == C0_SYN) |
|
|
3215 | { |
|
|
3216 | string[n++] = cmd_get8 (); |
|
|
3217 | prev = 0; |
|
|
3218 | } |
|
|
3219 | else |
3133 | string[n++] = ch; |
3220 | string[n++] = prev = ch; |
3134 | seen_esc = 0; |
|
|
3135 | } |
3221 | } |
3136 | |
3222 | |
3137 | string[n++] = '\0'; |
3223 | string[n++] = '\0'; |
3138 | |
3224 | |
3139 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
3225 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
… | |
… | |
3196 | if (str[0] == '?' && !str[1]) |
3282 | if (str[0] == '?' && !str[1]) |
3197 | { |
3283 | { |
3198 | if (Options & Opt_insecure) |
3284 | if (Options & Opt_insecure) |
3199 | { |
3285 | { |
3200 | unsigned short r, g, b; |
3286 | unsigned short r, g, b; |
3201 | PixColors[color].get (display, r, g, b); |
3287 | PixColorsFocused[color].get (display, r, g, b); |
3202 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3288 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3203 | } |
3289 | } |
3204 | } |
3290 | } |
3205 | else |
3291 | else |
3206 | set_window_color (color, str); |
3292 | set_window_color (color, str); |
… | |
… | |
3311 | if (name[0] == '?' && !name[1]) |
3397 | if (name[0] == '?' && !name[1]) |
3312 | { |
3398 | { |
3313 | if (Options & Opt_insecure) |
3399 | if (Options & Opt_insecure) |
3314 | { |
3400 | { |
3315 | unsigned short r, g, b; |
3401 | unsigned short r, g, b; |
3316 | PixColors[color + minCOLOR].get (display, r, g, b); |
3402 | PixColorsFocused[color + minCOLOR].get (display, r, g, b); |
3317 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3403 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3318 | } |
3404 | } |
3319 | } |
3405 | } |
3320 | else |
3406 | else |
3321 | set_window_color (color + minCOLOR, name); |
3407 | set_window_color (color + minCOLOR, name); |
… | |
… | |
3694 | rendset = 0, rendstyle = ~RS_None; |
3780 | rendset = 0, rendstyle = ~RS_None; |
3695 | break; |
3781 | break; |
3696 | case 1: |
3782 | case 1: |
3697 | rendset = 1, rendstyle = RS_Bold; |
3783 | rendset = 1, rendstyle = RS_Bold; |
3698 | break; |
3784 | break; |
|
|
3785 | //case 2: // faint or second colour |
3699 | case 4: |
3786 | case 4: |
3700 | rendset = 1, rendstyle = RS_Uline; |
3787 | rendset = 1, rendstyle = RS_Uline; |
3701 | break; |
3788 | break; |
3702 | case 5: |
3789 | case 5: // slowly blinking |
|
|
3790 | case 6: // rapidly blinking |
3703 | rendset = 1, rendstyle = RS_Blink; |
3791 | rendset = 1, rendstyle = RS_Blink; |
3704 | break; |
3792 | break; |
|
|
3793 | //case 6: // scoansi light background |
3705 | case 7: |
3794 | case 7: |
3706 | rendset = 1, rendstyle = RS_RVid; |
3795 | rendset = 1, rendstyle = RS_RVid; |
3707 | break; |
3796 | break; |
3708 | case 8: |
3797 | case 8: |
3709 | // invisible. NYI |
3798 | // invisible. NYI |
3710 | break; |
3799 | break; |
|
|
3800 | //case 9: // crossed out |
|
|
3801 | //case 10: // scoansi acs off, primary font |
|
|
3802 | //case 11: // scoansi acs on, first alt font |
|
|
3803 | //case 12: // scoansi acs on, |0x80, second alt font |
|
|
3804 | //... |
|
|
3805 | //case 19: // ninth alt font |
|
|
3806 | //case 20: // gothic |
|
|
3807 | case 21: // disable bold, faint |
|
|
3808 | rendset = 0, rendstyle = RS_Bold; |
|
|
3809 | break; |
3711 | case 22: |
3810 | case 22: |
3712 | rendset = 0, rendstyle = RS_Bold; |
3811 | rendset = 0, rendstyle = RS_Bold; |
3713 | break; |
3812 | break; |
|
|
3813 | //case 23: disable italic |
3714 | case 24: |
3814 | case 24: |
3715 | rendset = 0, rendstyle = RS_Uline; |
3815 | rendset = 0, rendstyle = RS_Uline; |
3716 | break; |
3816 | break; |
3717 | case 25: |
3817 | case 25: |
3718 | rendset = 0, rendstyle = RS_Blink; |
3818 | rendset = 0, rendstyle = RS_Blink; |
3719 | break; |
3819 | break; |
3720 | case 27: |
3820 | case 27: |
3721 | rendset = 0, rendstyle = RS_RVid; |
3821 | rendset = 0, rendstyle = RS_RVid; |
3722 | break; |
3822 | break; |
3723 | case 28: |
|
|
3724 | // visible. NYI |
3823 | //case 28: // visible. NYI |
3725 | break; |
3824 | //case 29: // not crossed-out |
3726 | } |
3825 | } |
3727 | |
3826 | |
3728 | if (rendset != -1) |
3827 | if (rendset != -1) |
3729 | { |
3828 | { |
3730 | scr_rendition (rendset, rendstyle); |
3829 | scr_rendition (rendset, rendstyle); |
… | |
… | |
3807 | } |
3906 | } |
3808 | } |
3907 | } |
3809 | } |
3908 | } |
3810 | /*}}} */ |
3909 | /*}}} */ |
3811 | |
3910 | |
3812 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3911 | /*{{{ (do not) process Rob Nation's own graphics mode sequences */ |
3813 | void |
3912 | void |
3814 | rxvt_term::process_graphics () |
3913 | rxvt_term::process_graphics () |
3815 | { |
3914 | { |
3816 | unicode_t ch, cmd = cmd_getc (); |
3915 | unicode_t ch, cmd = cmd_getc (); |
3817 | |
3916 | |