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 |
… | |
… | |
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 | { |
672 | scr_refresh (refresh_type); |
671 | scr_refresh (refresh_type); |
673 | scrollbar_show (1); |
672 | scrollbar_show (1); |
674 | #ifdef USE_XIM |
673 | #ifdef USE_XIM |
675 | IMSendSpot (); |
674 | IMSendSpot (); |
676 | #endif |
675 | #endif |
677 | |
|
|
678 | } |
676 | } |
679 | |
677 | |
680 | display->flush (); |
678 | display->flush (); |
|
|
679 | |
|
|
680 | flush_ev.stop (); |
681 | } |
681 | } |
682 | |
682 | |
683 | void |
683 | void |
684 | rxvt_term::check_cb (check_watcher &w) |
684 | rxvt_term::check_cb (check_watcher &w) |
685 | { |
685 | { |
686 | SET_R (this); |
686 | SET_R (this); |
687 | SET_LOCALE (locale); |
687 | SET_LOCALE (locale); |
688 | |
688 | |
|
|
689 | display->flush (); |
|
|
690 | |
|
|
691 | if (want_refresh && !flush_ev.active) |
|
|
692 | flush_ev.start (NOW + 0.01); |
|
|
693 | } |
|
|
694 | |
|
|
695 | void |
|
|
696 | rxvt_term::flush_cb (time_watcher &w) |
|
|
697 | { |
|
|
698 | SET_R (this); |
|
|
699 | SET_LOCALE (locale); |
|
|
700 | |
|
|
701 | refresh_limit = 1; |
|
|
702 | refresh_count = 0; |
689 | flush (); |
703 | flush (); |
690 | } |
704 | } |
691 | |
705 | |
692 | #ifdef CURSOR_BLINK |
706 | #ifdef CURSOR_BLINK |
693 | void |
707 | void |
… | |
… | |
711 | w.start (w.at + TEXT_BLINK_INTERVAL); |
725 | w.start (w.at + TEXT_BLINK_INTERVAL); |
712 | } |
726 | } |
713 | } |
727 | } |
714 | #endif |
728 | #endif |
715 | |
729 | |
|
|
730 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
731 | void |
|
|
732 | rxvt_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 |
|
|
745 | void |
|
|
746 | rxvt_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) |
|
|
759 | void |
|
|
760 | rxvt_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); |
|
|
769 | } |
|
|
770 | } |
|
|
771 | #endif |
|
|
772 | |
716 | bool |
773 | bool |
717 | rxvt_term::pty_fill () |
774 | rxvt_term::pty_fill () |
718 | { |
775 | { |
719 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
776 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
|
|
777 | |
|
|
778 | if (CBUFSIZ == n) |
|
|
779 | { |
|
|
780 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
|
|
781 | n = 0; |
|
|
782 | } |
720 | |
783 | |
721 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
784 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
722 | cmdbuf_ptr = cmdbuf_base; |
785 | cmdbuf_ptr = cmdbuf_base; |
723 | cmdbuf_endp = cmdbuf_ptr + n; |
786 | cmdbuf_endp = cmdbuf_ptr + n; |
724 | |
787 | |
… | |
… | |
742 | SET_LOCALE (locale); |
805 | SET_LOCALE (locale); |
743 | |
806 | |
744 | if (revents & EVENT_WRITE) |
807 | if (revents & EVENT_WRITE) |
745 | tt_write (0, 0); |
808 | tt_write (0, 0); |
746 | else if (revents & EVENT_READ) |
809 | else if (revents & EVENT_READ) |
747 | { |
|
|
748 | // loop, but don't allow a single term to monopolize us |
810 | // 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 ()) |
811 | 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 ()) |
812 | if (cmd_parse ()) |
761 | break; |
813 | break; |
762 | } |
|
|
763 | } |
|
|
764 | } |
814 | } |
765 | |
815 | |
766 | #ifdef POINTER_BLANK |
|
|
767 | void |
816 | void |
768 | rxvt_term::pointer_unblank () |
817 | rxvt_term::pointer_unblank () |
769 | { |
818 | { |
770 | XDefineCursor (display->display, TermWin.vt, TermWin_cursor); |
819 | XDefineCursor (display->display, TermWin.vt, TermWin_cursor); |
771 | recolour_cursor (); |
820 | recolour_cursor (); |
772 | |
821 | |
|
|
822 | #ifdef POINTER_BLANK |
773 | hidden_pointer = 0; |
823 | hidden_pointer = 0; |
774 | |
824 | |
775 | if (Options & Opt_pointerBlank) |
825 | if (Options & Opt_pointerBlank) |
776 | pointer_ev.start (NOW + pointerBlankDelay); |
826 | pointer_ev.start (NOW + pointerBlankDelay); |
|
|
827 | #endif |
777 | } |
828 | } |
778 | |
829 | |
|
|
830 | #ifdef POINTER_BLANK |
779 | void |
831 | void |
780 | rxvt_term::pointer_blank () |
832 | rxvt_term::pointer_blank () |
781 | { |
833 | { |
782 | if (! (Options & Opt_pointerBlank)) |
834 | if (! (Options & Opt_pointerBlank)) |
783 | return; |
835 | return; |
… | |
… | |
979 | break; |
1031 | break; |
980 | |
1032 | |
981 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1033 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
982 | case KeyRelease: |
1034 | case KeyRelease: |
983 | { |
1035 | { |
984 | if (! (ev.xkey.state & ControlMask)) |
1036 | if (!(ev.xkey.state & ControlMask)) |
985 | mouse_slip_wheel_speed = 0; |
1037 | slip_wheel_ev.stop (); |
986 | else |
1038 | else |
987 | { |
1039 | { |
988 | KeySym ks; |
1040 | KeySym ks; |
989 | |
1041 | |
990 | ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); |
1042 | ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); |
991 | if (ks == XK_Control_L || ks == XK_Control_R) |
1043 | if (ks == XK_Control_L || ks == XK_Control_R) |
992 | mouse_slip_wheel_speed = 0; |
1044 | mouse_slip_wheel_speed = 0; |
993 | } |
1045 | } |
… | |
… | |
1013 | && (ev.xclient.data.l[0] == DndFile |
1065 | && (ev.xclient.data.l[0] == DndFile |
1014 | || ev.xclient.data.l[0] == DndDir |
1066 | || ev.xclient.data.l[0] == DndDir |
1015 | || ev.xclient.data.l[0] == DndLink)) |
1067 | || ev.xclient.data.l[0] == DndLink)) |
1016 | { |
1068 | { |
1017 | /* Get Dnd data */ |
1069 | /* Get Dnd data */ |
1018 | Atom ActualType; |
1070 | Atom ActualType; |
1019 | int ActualFormat; |
1071 | int ActualFormat; |
1020 | unsigned char *data; |
1072 | unsigned char *data; |
1021 | unsigned long Size, RemainingBytes; |
1073 | unsigned long Size, RemainingBytes; |
1022 | |
1074 | |
1023 | XGetWindowProperty (display->display, display->root, |
1075 | XGetWindowProperty (display->display, display->root, |
1024 | xa[XA_DNDSELECTION], |
1076 | xa[XA_DNDSELECTION], |
1025 | 0L, 1000000L, |
1077 | 0L, 1000000L, |
1026 | False, AnyPropertyType, |
1078 | False, AnyPropertyType, |
… | |
… | |
1029 | &data); |
1081 | &data); |
1030 | XChangeProperty (display->display, display->root, |
1082 | XChangeProperty (display->display, display->root, |
1031 | XA_CUT_BUFFER0, XA_STRING, |
1083 | XA_CUT_BUFFER0, XA_STRING, |
1032 | 8, PropModeReplace, |
1084 | 8, PropModeReplace, |
1033 | data, STRLEN (data)); |
1085 | data, STRLEN (data)); |
|
|
1086 | XFree (data); |
1034 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1087 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1035 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1088 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1036 | } |
1089 | } |
1037 | #endif /* OFFIX_DND */ |
1090 | #endif /* OFFIX_DND */ |
1038 | break; |
1091 | break; |
1039 | |
1092 | |
1040 | case MappingNotify: |
1093 | case MappingNotify: |
1041 | XRefreshKeyboardMapping (& (ev.xmapping)); |
1094 | XRefreshKeyboardMapping (&ev.xmapping); |
1042 | break; |
1095 | break; |
1043 | |
1096 | |
1044 | /* |
1097 | /* |
1045 | * XXX: this is not the _current_ arrangement |
1098 | * XXX: this is not the _current_ arrangement |
1046 | * Here's my conclusion: |
1099 | * Here's my conclusion: |
… | |
… | |
1077 | #endif |
1130 | #endif |
1078 | #ifdef CURSOR_BLINK |
1131 | #ifdef CURSOR_BLINK |
1079 | if (Options & Opt_cursorBlink) |
1132 | if (Options & Opt_cursorBlink) |
1080 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1133 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1081 | #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 |
1082 | |
1144 | |
1083 | } |
1145 | } |
1084 | break; |
1146 | break; |
1085 | |
1147 | |
1086 | case FocusOut: |
1148 | case FocusOut: |
… | |
… | |
1095 | #ifdef CURSOR_BLINK |
1157 | #ifdef CURSOR_BLINK |
1096 | if (Options & Opt_cursorBlink) |
1158 | if (Options & Opt_cursorBlink) |
1097 | cursor_blink_ev.stop (); |
1159 | cursor_blink_ev.stop (); |
1098 | hidden_cursor = 0; |
1160 | hidden_cursor = 0; |
1099 | #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 |
1100 | |
1171 | |
1101 | } |
1172 | } |
1102 | break; |
1173 | break; |
1103 | |
1174 | |
1104 | case ConfigureNotify: |
1175 | case ConfigureNotify: |
… | |
… | |
1113 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1184 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1114 | } |
1185 | } |
1115 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1186 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1116 | |
1187 | |
1117 | if (szHint.width != width || szHint.height != height) |
1188 | if (szHint.width != width || szHint.height != height) |
1118 | { |
|
|
1119 | D_SIZE ((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height)); |
|
|
1120 | resize_all_windows (width, height, 1); |
1189 | resize_all_windows (width, height, 1); |
1121 | } |
1190 | |
1122 | #ifdef DEBUG_SIZE |
|
|
1123 | else |
|
|
1124 | { |
|
|
1125 | D_SIZE ((stderr, "Size: Not resizing")); |
|
|
1126 | } |
|
|
1127 | #endif |
|
|
1128 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1191 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1129 | if (Options & Opt_transparent) |
1192 | if (Options & Opt_transparent) |
1130 | { |
1193 | { |
1131 | check_our_parents (); |
1194 | check_our_parents (); |
1132 | if (am_transparent) |
1195 | if (am_transparent) |
1133 | want_full_refresh = 1; |
1196 | want_refresh = want_full_refresh = 1; |
1134 | } |
1197 | } |
1135 | #endif |
1198 | #endif |
1136 | } |
1199 | } |
1137 | break; |
1200 | break; |
1138 | |
1201 | |
… | |
… | |
1172 | |
1235 | |
1173 | case GraphicsExpose: |
1236 | case GraphicsExpose: |
1174 | case Expose: |
1237 | case Expose: |
1175 | if (ev.xany.window == TermWin.vt) |
1238 | if (ev.xany.window == TermWin.vt) |
1176 | { |
1239 | { |
1177 | #ifdef NO_SLOW_LINK_SUPPORT |
1240 | do |
1178 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1241 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1179 | ev.xexpose.width, ev.xexpose.height, False); |
1242 | ev.xexpose.width, ev.xexpose.height, False); |
1180 | #else |
1243 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); |
1181 | // don't understand this, so commented it out |
1244 | |
|
|
1245 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
|
|
1246 | |
|
|
1247 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) |
1182 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1248 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1183 | ev.xexpose.width, ev.xexpose.height, False); |
1249 | ev.xexpose.width, ev.xexpose.height, False); |
1184 | //scr_expose (ev.xexpose.x, 0, |
1250 | |
1185 | // ev.xexpose.width, TermWin.height, False); |
1251 | scr_refresh (refresh_type); |
1186 | #endif |
|
|
1187 | want_refresh = 1; |
|
|
1188 | } |
1252 | } |
1189 | else |
1253 | else |
1190 | { |
1254 | { |
1191 | XEvent unused_event; |
1255 | XEvent unused_event; |
1192 | |
1256 | |
1193 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1257 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1194 | Expose, |
1258 | ; |
1195 | &unused_event)) ; |
|
|
1196 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1259 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1197 | GraphicsExpose, |
1260 | ; |
1198 | &unused_event)) ; |
1261 | |
1199 | if (isScrollbarWindow (ev.xany.window)) |
1262 | if (isScrollbarWindow (ev.xany.window)) |
1200 | { |
1263 | { |
1201 | scrollBar.setIdle (); |
1264 | scrollBar.setIdle (); |
1202 | scrollbar_show (0); |
1265 | scrollbar_show (0); |
1203 | } |
1266 | } |
1204 | #ifdef MENUBAR |
1267 | #ifdef MENUBAR |
1205 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1268 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
1206 | 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); |
1207 | #endif |
1275 | #endif |
1208 | } |
1276 | } |
1209 | break; |
1277 | break; |
1210 | |
1278 | |
1211 | case MotionNotify: |
1279 | case MotionNotify: |
… | |
… | |
1246 | if (ev.xbutton.y < TermWin.int_bwidth |
1314 | if (ev.xbutton.y < TermWin.int_bwidth |
1247 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1315 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1248 | { |
1316 | { |
1249 | int dist; |
1317 | int dist; |
1250 | |
1318 | |
1251 | pending_scroll_selection=1; |
|
|
1252 | |
|
|
1253 | /* don't clobber the current delay if we are |
1319 | /* don't clobber the current delay if we are |
1254 | * already in the middle of scrolling. |
1320 | * already in the middle of scrolling. |
1255 | */ |
1321 | */ |
1256 | if (scroll_selection_delay<=0) |
1322 | if (!sel_scroll_ev.active) |
1257 | scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; |
1323 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1258 | |
1324 | |
1259 | /* save the event params so we can highlight |
1325 | /* save the event params so we can highlight |
1260 | * the selection in the pending-scroll loop |
1326 | * the selection in the pending-scroll loop |
1261 | */ |
1327 | */ |
1262 | selection_save_x=ev.xbutton.x; |
1328 | selection_save_x=ev.xbutton.x; |
… | |
… | |
1284 | else |
1350 | else |
1285 | { |
1351 | { |
1286 | /* we are within the text window, so we |
1352 | /* we are within the text window, so we |
1287 | * shouldn't be scrolling |
1353 | * shouldn't be scrolling |
1288 | */ |
1354 | */ |
1289 | pending_scroll_selection = 0; |
1355 | if (sel_scroll_ev.active) |
|
|
1356 | sel_scroll_ev.stop(); |
1290 | } |
1357 | } |
1291 | #endif |
1358 | #endif |
1292 | #ifdef MOUSE_THRESHOLD |
1359 | #ifdef MOUSE_THRESHOLD |
1293 | |
1360 | |
1294 | } |
1361 | } |
… | |
… | |
1345 | } |
1412 | } |
1346 | |
1413 | |
1347 | /* FALLTHROUGH */ |
1414 | /* FALLTHROUGH */ |
1348 | case ReparentNotify: |
1415 | case ReparentNotify: |
1349 | if ((Options & Opt_transparent) && check_our_parents () && am_transparent) |
1416 | if ((Options & Opt_transparent) && check_our_parents () && am_transparent) |
1350 | want_full_refresh = 1; |
1417 | want_refresh = want_full_refresh = 1; |
1351 | break; |
1418 | break; |
1352 | #endif |
1419 | #endif |
1353 | } |
1420 | } |
1354 | } |
1421 | } |
1355 | |
1422 | |
… | |
… | |
1511 | upordown = 1; /* down */ |
1578 | upordown = 1; /* down */ |
1512 | } |
1579 | } |
1513 | if (upordown) |
1580 | if (upordown) |
1514 | { |
1581 | { |
1515 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1582 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1516 | scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; |
1583 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1517 | #endif |
1584 | #endif |
1518 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1585 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1519 | { |
1586 | { |
1520 | if (upordown < 0) |
1587 | if (upordown < 0) |
1521 | scrollBar.setUp (); |
1588 | scrollBar.setUp (); |
… | |
… | |
1537 | break; |
1604 | break; |
1538 | case R_SB_ALIGN_BOTTOM: |
1605 | case R_SB_ALIGN_BOTTOM: |
1539 | csrO = scrollBar.bot - scrollBar.top; |
1606 | csrO = scrollBar.bot - scrollBar.top; |
1540 | break; |
1607 | break; |
1541 | } |
1608 | } |
|
|
1609 | |
1542 | if (scrollBar.style == R_SB_XTERM |
1610 | if (scrollBar.style == R_SB_XTERM |
1543 | || scrollbar_above_slider (ev.y) |
1611 | || scrollbar_above_slider (ev.y) |
1544 | || scrollbar_below_slider (ev.y)) |
1612 | || scrollbar_below_slider (ev.y)) |
1545 | scr_move_to ( scrollbar_position (ev.y) - csrO, |
1613 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
1546 | scrollbar_size ()); |
1614 | |
1547 | scrollBar.setMotion (); |
1615 | scrollBar.setMotion (); |
1548 | break; |
1616 | break; |
1549 | |
1617 | |
1550 | case Button1: |
1618 | case Button1: |
1551 | if (scrollbar_align == R_SB_ALIGN_CENTRE) |
1619 | if (scrollbar_align == R_SB_ALIGN_CENTRE) |
… | |
… | |
1575 | scr_page ((ev.button == Button1 ? DN : UP), |
1643 | scr_page ((ev.button == Button1 ? DN : UP), |
1576 | (TermWin.nrow |
1644 | (TermWin.nrow |
1577 | * scrollbar_position (ev.y) |
1645 | * scrollbar_position (ev.y) |
1578 | / scrollbar_size ())); |
1646 | / scrollbar_size ())); |
1579 | } |
1647 | } |
|
|
1648 | |
1580 | break; |
1649 | break; |
1581 | } |
1650 | } |
1582 | } |
1651 | } |
1583 | return; |
1652 | return; |
1584 | } |
1653 | } |
… | |
… | |
1608 | refresh_type &= ~SMOOTH_REFRESH; |
1677 | refresh_type &= ~SMOOTH_REFRESH; |
1609 | #endif |
1678 | #endif |
1610 | |
1679 | |
1611 | } |
1680 | } |
1612 | #ifdef SELECTION_SCROLLING |
1681 | #ifdef SELECTION_SCROLLING |
1613 | pending_scroll_selection=0; |
1682 | if (sel_scroll_ev.active) |
|
|
1683 | sel_scroll_ev.stop(); |
1614 | #endif |
1684 | #endif |
1615 | if (ev.window == TermWin.vt) |
1685 | if (ev.window == TermWin.vt) |
1616 | { |
1686 | { |
1617 | if (reportmode) |
1687 | if (reportmode) |
1618 | { |
1688 | { |
… | |
… | |
1660 | case Button5: |
1730 | case Button5: |
1661 | { |
1731 | { |
1662 | int i; |
1732 | int i; |
1663 | page_dirn v; |
1733 | page_dirn v; |
1664 | |
1734 | |
1665 | v = (ev.button == Button4) ? UP : DN; |
1735 | v = ev.button == Button4 ? UP : DN; |
|
|
1736 | |
1666 | if (ev.state & ShiftMask) |
1737 | if (ev.state & ShiftMask) |
1667 | i = 1; |
1738 | i = 1; |
1668 | else if ((Options & Opt_mouseWheelScrollPage)) |
1739 | else if (Options & Opt_mouseWheelScrollPage) |
1669 | i = TermWin.nrow - 1; |
1740 | i = TermWin.nrow - 1; |
1670 | else |
1741 | else |
1671 | i = 5; |
1742 | i = 5; |
|
|
1743 | |
1672 | # ifdef MOUSE_SLIP_WHEELING |
1744 | # ifdef MOUSE_SLIP_WHEELING |
1673 | if (ev.state & ControlMask) |
1745 | if (ev.state & ControlMask) |
1674 | { |
1746 | { |
1675 | 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) |
1676 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1752 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
|
|
1753 | |
|
|
1754 | slip_wheel_ev.start (); |
1677 | } |
1755 | } |
|
|
1756 | else |
|
|
1757 | { |
1678 | # endif |
1758 | # endif |
1679 | # ifdef JUMP_MOUSE_WHEEL |
1759 | # 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); |
1760 | scr_page (v, i); |
1687 | scr_refresh (SMOOTH_REFRESH); |
1761 | scr_refresh (SMOOTH_REFRESH); |
1688 | 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 |
1689 | } |
1772 | } |
1690 | # endif |
1773 | #endif |
1691 | |
|
|
1692 | } |
1774 | } |
1693 | break; |
1775 | break; |
1694 | #endif |
1776 | #endif |
1695 | |
|
|
1696 | } |
1777 | } |
1697 | } |
1778 | } |
1698 | #ifdef MENUBAR |
1779 | #ifdef MENUBAR |
1699 | else if (isMenuBarWindow (ev.window)) |
1780 | else if (isMenuBarWindow (ev.window)) |
1700 | menubar_control (ev); |
1781 | menubar_control (ev); |
1701 | #endif |
1782 | #endif |
1702 | } |
1783 | } |
1703 | |
1784 | |
1704 | #ifdef TRANSPARENT |
1785 | #ifdef TRANSPARENT |
1705 | #if TINTING |
1786 | #if TINTING |
1706 | /* shading taken from eterm-0.9.2 */ |
1787 | /* taken from aterm-0.4.2 */ |
1707 | /* RGB 15 */ |
|
|
1708 | |
1788 | |
1709 | static void |
1789 | typedef uint32_t RUINT32T; |
1710 | shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm) |
|
|
1711 | { |
|
|
1712 | unsigned char *ptr; |
|
|
1713 | int x, y; |
|
|
1714 | |
1790 | |
1715 | ptr = (unsigned char *)data + (w * sizeof(uint16_t)); |
1791 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
1716 | if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { |
1792 | { |
1717 | /* No saturation */ |
1793 | int sh_r, sh_g, sh_b; |
1718 | for (y = h; --y >= 0;) { |
1794 | RUINT32T mask_r, mask_g, mask_b; |
1719 | for (x = -w; x < 0; x++) { |
1795 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1720 | 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; |
1721 | |
1799 | |
1722 | b = ((uint16_t *) ptr)[x]; |
1800 | Visual* visual = display->visual; |
1723 | r = (b & 0x7c00) * rm; |
1801 | |
1724 | g = (b & 0x3e0) * gm; |
1802 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
1725 | b = (b & 0x1f) * bm; |
1803 | |
1726 | ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) |
1804 | /* for convenience */ |
1727 | | ((g >> 8) & 0x3e0) |
1805 | mask_r = visual->red_mask; |
1728 | | ((b >> 8) & 0x1f); |
1806 | mask_g = visual->green_mask; |
1729 | } |
1807 | mask_b = visual->blue_mask; |
1730 | ptr += bpl; |
1808 | |
1731 | } |
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; |
1732 | } else { |
1882 | } else { |
1733 | for (y = h; --y >= 0;) { |
1883 | if (shade < 0) shade = 0; |
1734 | for (x = -w; x < 0; x++) { |
1884 | if (shade > 100) shade = 100; |
1735 | int r, g, b; |
|
|
1736 | |
1885 | |
1737 | b = ((uint16_t *) ptr)[x]; |
1886 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
1738 | r = (b & 0x7c00) * rm; |
1887 | |
1739 | g = (b & 0x3e0) * gm; |
1888 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
1740 | b = (b & 0x1f) * bm; |
1889 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
1741 | r |= (!(r >> 15) - 1); |
1890 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
1742 | g |= (!(g >> 10) - 1); |
1891 | } |
1743 | b |= (!(b >> 5) - 1); |
1892 | |
1744 | ((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 */ |
1745 | | ((g >> 8) & 0x3e0) |
1894 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
1746 | | ((b >> 8) & 0x1f); |
1895 | { |
1747 | } |
1896 | unsigned int tmp; |
1748 | 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++) |
1749 | } |
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); |
1750 | } |
1949 | } |
1751 | } |
1950 | break; |
1752 | |
1951 | } |
1753 | /* RGB 16 */ |
1952 | case 16: |
1754 | static void |
1953 | { |
1755 | shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm) |
1954 | unsigned short *p1, *pf, *p, *pl; |
1756 | { |
1955 | p1 = (unsigned short *) srcImage->data; |
1757 | unsigned char *ptr; |
1956 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
1758 | int x, y; |
1957 | while (p1 < pf) |
1759 | |
1958 | { |
1760 | ptr = (unsigned char *)data + (w * sizeof(uint16_t)); |
1959 | p = p1; |
1761 | if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { |
1960 | pl = p1 + srcImage->width; |
1762 | /* No saturation */ |
1961 | for (; p < pl; p++) |
1763 | for (y = h; --y >= 0;) { |
|
|
1764 | for (x = -w; x < 0; x++) { |
|
|
1765 | int r, g, b; |
|
|
1766 | |
|
|
1767 | b = ((uint16_t *) ptr)[x]; |
|
|
1768 | r = (b & 0xf800) * rm; |
|
|
1769 | g = (b & 0x7e0) * gm; |
|
|
1770 | b = (b & 0x1f) * bm; |
|
|
1771 | ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800) |
|
|
1772 | | ((g >> 8) & 0x7e0) |
|
|
1773 | | ((b >> 8) & 0x1f); |
|
|
1774 | } |
|
|
1775 | ptr += bpl; |
|
|
1776 | } |
1962 | { |
1777 | } else { |
1963 | *p = lookup_r[(*p & 0xf800)>>11] | |
1778 | for (y = h; --y >= 0;) { |
1964 | lookup_g[(*p & 0x07e0)>> 5] | |
1779 | for (x = -w; x < 0; x++) { |
1965 | lookup_b[(*p & 0x001f)]; |
1780 | int r, g, b; |
|
|
1781 | |
|
|
1782 | b = ((uint16_t *) ptr)[x]; |
|
|
1783 | r = (b & 0xf800) * rm; |
|
|
1784 | g = (b & 0x7e0) * gm; |
|
|
1785 | b = (b & 0x1f) * bm; |
|
|
1786 | r |= (!(r >> 16) - 1); |
|
|
1787 | g |= (!(g >> 11) - 1); |
|
|
1788 | b |= (!(b >> 5) - 1); |
|
|
1789 | ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800) |
|
|
1790 | | ((g >> 8) & 0x7e0) |
|
|
1791 | | ((b >> 8) & 0x1f); |
|
|
1792 | } |
1966 | } |
1793 | 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) |
1794 | } |
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); |
1795 | } |
1987 | } |
1796 | } |
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); |
1797 | |
1995 | |
1798 | /* RGB 24 */ |
1996 | while (p1 < pf) |
1799 | static void |
1997 | { |
1800 | shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm) |
1998 | p = p1; |
1801 | { |
1999 | pl = p1 + srcImage->width; |
1802 | unsigned char *ptr; |
2000 | for (; p < pl; p++) |
1803 | int x, y; |
|
|
1804 | |
|
|
1805 | ptr = (unsigned char *)data + (w * 3); |
|
|
1806 | if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { |
|
|
1807 | /* No saturation */ |
|
|
1808 | for (y = h; --y >= 0;) { |
|
|
1809 | for (x = -(w * 3); x < 0; x += 3) { |
|
|
1810 | int r, g, b; |
|
|
1811 | |
|
|
1812 | if (byteorder.big_endian()) { |
|
|
1813 | r = (ptr[x + 0] * rm) >> 8; |
|
|
1814 | g = (ptr[x + 1] * gm) >> 8; |
|
|
1815 | b = (ptr[x + 2] * bm) >> 8; |
|
|
1816 | ptr[x + 0] = r; |
|
|
1817 | ptr[x + 1] = g; |
|
|
1818 | ptr[x + 2] = b; |
|
|
1819 | } else { |
|
|
1820 | r = (ptr[x + 2] * rm) >> 8; |
|
|
1821 | g = (ptr[x + 1] * gm) >> 8; |
|
|
1822 | b = (ptr[x + 0] * bm) >> 8; |
|
|
1823 | ptr[x + 2] = r; |
|
|
1824 | ptr[x + 1] = g; |
|
|
1825 | ptr[x + 0] = b; |
|
|
1826 | } |
|
|
1827 | } |
|
|
1828 | ptr += bpl; |
|
|
1829 | } |
2001 | { |
1830 | } else { |
2002 | *p = lookup_r[(*p & 0xff0000)>>16] | |
1831 | for (y = h; --y >= 0;) { |
2003 | lookup_g[(*p & 0x00ff00)>> 8] | |
1832 | for (x = -(w * 3); x < 0; x += 3) { |
2004 | lookup_b[(*p & 0x0000ff)] | |
1833 | int r, g, b; |
2005 | (*p & ~0xffffff); |
1834 | |
|
|
1835 | if (byteorder.big_endian()) { |
|
|
1836 | r = (ptr[x + 0] * rm) >> 8; |
|
|
1837 | g = (ptr[x + 1] * gm) >> 8; |
|
|
1838 | b = (ptr[x + 2] * bm) >> 8; |
|
|
1839 | |
|
|
1840 | r |= (!(r >> 8) - 1); |
|
|
1841 | g |= (!(g >> 8) - 1); |
|
|
1842 | b |= (!(b >> 8) - 1); |
|
|
1843 | |
|
|
1844 | ptr[x + 0] = r; |
|
|
1845 | ptr[x + 1] = g; |
|
|
1846 | ptr[x + 2] = b; |
|
|
1847 | } else { |
|
|
1848 | r = (ptr[x + 2] * rm) >> 8; |
|
|
1849 | g = (ptr[x + 1] * gm) >> 8; |
|
|
1850 | b = (ptr[x + 0] * bm) >> 8; |
|
|
1851 | |
|
|
1852 | r |= (!(r >> 8) - 1); |
|
|
1853 | g |= (!(g >> 8) - 1); |
|
|
1854 | b |= (!(b >> 8) - 1); |
|
|
1855 | |
|
|
1856 | ptr[x + 2] = r; |
|
|
1857 | ptr[x + 1] = g; |
|
|
1858 | ptr[x + 0] = b; |
|
|
1859 | } |
|
|
1860 | } |
2006 | } |
1861 | ptr += bpl; |
2007 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
1862 | } |
2008 | } |
|
|
2009 | break; |
|
|
2010 | } |
1863 | } |
2011 | } |
1864 | } |
|
|
1865 | |
2012 | |
1866 | /* RGB 32 */ |
2013 | free (lookup); |
1867 | static void |
|
|
1868 | shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm) |
|
|
1869 | { |
|
|
1870 | unsigned char *ptr; |
|
|
1871 | int x, y; |
|
|
1872 | |
|
|
1873 | ptr = (unsigned char *)data + (w * 4); |
|
|
1874 | if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { |
|
|
1875 | /* No saturation */ |
|
|
1876 | for (y = h; --y >= 0;) { |
|
|
1877 | if (byteorder.big_endian()) { |
|
|
1878 | for (x = -(w * 4); x < 0; x += 4) { |
|
|
1879 | int r, g, b; |
|
|
1880 | |
|
|
1881 | r = (ptr[x + 1] * rm) >> 8; |
|
|
1882 | g = (ptr[x + 2] * gm) >> 8; |
|
|
1883 | b = (ptr[x + 3] * bm) >> 8; |
|
|
1884 | ptr[x + 1] = r; |
|
|
1885 | ptr[x + 2] = g; |
|
|
1886 | ptr[x + 3] = b; |
|
|
1887 | } |
|
|
1888 | } else { |
|
|
1889 | for (x = -(w * 4); x < 0; x += 4) { |
|
|
1890 | int r, g, b; |
|
|
1891 | |
|
|
1892 | r = (ptr[x + 2] * rm) >> 8; |
|
|
1893 | g = (ptr[x + 1] * gm) >> 8; |
|
|
1894 | b = (ptr[x + 0] * bm) >> 8; |
|
|
1895 | ptr[x + 2] = r; |
|
|
1896 | ptr[x + 1] = g; |
|
|
1897 | ptr[x + 0] = b; |
|
|
1898 | } |
|
|
1899 | } |
|
|
1900 | ptr += bpl; |
|
|
1901 | } |
|
|
1902 | } else { |
|
|
1903 | for (y = h; --y >= 0;) { |
|
|
1904 | for (x = -(w * 4); x < 0; x += 4) { |
|
|
1905 | int r, g, b; |
|
|
1906 | |
|
|
1907 | if (byteorder.big_endian()) { |
|
|
1908 | r = (ptr[x + 1] * rm) >> 8; |
|
|
1909 | g = (ptr[x + 2] * gm) >> 8; |
|
|
1910 | b = (ptr[x + 3] * bm) >> 8; |
|
|
1911 | |
|
|
1912 | r |= (!(r >> 8) - 1); |
|
|
1913 | g |= (!(g >> 8) - 1); |
|
|
1914 | b |= (!(b >> 8) - 1); |
|
|
1915 | |
|
|
1916 | ptr[x + 1] = r; |
|
|
1917 | ptr[x + 2] = g; |
|
|
1918 | ptr[x + 3] = b; |
|
|
1919 | } else { |
|
|
1920 | r = (ptr[x + 2] * rm) >> 8; |
|
|
1921 | g = (ptr[x + 1] * gm) >> 8; |
|
|
1922 | b = (ptr[x + 0] * bm) >> 8; |
|
|
1923 | |
|
|
1924 | r |= (!(r >> 8) - 1); |
|
|
1925 | g |= (!(g >> 8) - 1); |
|
|
1926 | b |= (!(b >> 8) - 1); |
|
|
1927 | |
|
|
1928 | ptr[x + 2] = r; |
|
|
1929 | ptr[x + 1] = g; |
|
|
1930 | ptr[x + 0] = b; |
|
|
1931 | } |
|
|
1932 | } |
|
|
1933 | ptr += bpl; |
|
|
1934 | } |
|
|
1935 | } |
|
|
1936 | } |
2014 | } |
1937 | |
|
|
1938 | #endif |
2015 | #endif |
1939 | |
2016 | |
1940 | /* |
2017 | /* |
1941 | * Check our parents are still who we think they are. |
2018 | * Check our parents are still who we think they are. |
1942 | * Do transparency updates if required |
2019 | * Do transparency updates if required |
… | |
… | |
1965 | if (rootdepth != wattr.depth) |
2042 | if (rootdepth != wattr.depth) |
1966 | { |
2043 | { |
1967 | if (am_transparent) |
2044 | if (am_transparent) |
1968 | { |
2045 | { |
1969 | pchanged = 1; |
2046 | pchanged = 1; |
1970 | XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); |
2047 | XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); |
1971 | am_transparent = am_pixmap_trans = 0; |
2048 | am_transparent = am_pixmap_trans = 0; |
1972 | } |
2049 | } |
1973 | |
2050 | |
1974 | return pchanged; /* Don't try any more */ |
2051 | return pchanged; /* Don't try any more */ |
1975 | } |
2052 | } |
… | |
… | |
1991 | i = (xa[XA_XSETROOTID] |
2068 | i = (xa[XA_XSETROOTID] |
1992 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2069 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
1993 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2070 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
1994 | &nitems, &bytes_after, &prop) == Success); |
2071 | &nitems, &bytes_after, &prop) == Success); |
1995 | |
2072 | |
1996 | if (!i || prop == NULL) |
2073 | if (!i || prop == NULL |
|
|
2074 | #if TINTING |
|
|
2075 | || !rs[Rs_color + Color_tint] |
|
|
2076 | #endif |
|
|
2077 | ) |
1997 | have_pixmap = 0; |
2078 | have_pixmap = 0; |
1998 | else |
2079 | else |
1999 | { |
2080 | { |
2000 | have_pixmap = 1; |
2081 | have_pixmap = 1; |
2001 | rootpixmap = * ((Pixmap *)prop); |
2082 | rootpixmap = *(Pixmap *)prop; |
2002 | XFree (prop); |
2083 | XFree (prop); |
2003 | } |
2084 | } |
2004 | |
2085 | |
2005 | if (have_pixmap) |
2086 | if (have_pixmap) |
2006 | { |
2087 | { |
… | |
… | |
2063 | XFreePixmap (display->display, TermWin.pixmap); |
2144 | XFreePixmap (display->display, TermWin.pixmap); |
2064 | |
2145 | |
2065 | #if TINTING |
2146 | #if TINTING |
2066 | if (ISSET_PIXCOLOR (Color_tint)) |
2147 | if (ISSET_PIXCOLOR (Color_tint)) |
2067 | { |
2148 | { |
2068 | unsigned short shade, rm, gm, bm; |
2149 | unsigned short rm, gm, bm; |
|
|
2150 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2069 | |
2151 | |
2070 | PixColors[Color_tint].get (display, rm, gm, bm); |
2152 | PixColorsFocused[Color_tint].get (display, rm, gm, bm); |
2071 | |
2153 | |
2072 | rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but... |
2154 | ShadeXImage (display, image, shade, rm, gm, bm); |
2073 | |
|
|
2074 | /* Determine bitshift and bitmask values */ |
|
|
2075 | switch (image->bits_per_pixel) |
|
|
2076 | { |
|
|
2077 | case 15: shade_ximage_15 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; |
|
|
2078 | case 16: shade_ximage_16 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; |
|
|
2079 | case 24: shade_ximage_24 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; |
|
|
2080 | case 32: shade_ximage_32 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; |
|
|
2081 | } |
|
|
2082 | } |
2155 | } |
2083 | #endif |
2156 | #endif |
2084 | |
2157 | |
2085 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
2158 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
2086 | szHint.width, szHint.height, image->depth); |
2159 | szHint.width, szHint.height, image->depth); |
2087 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2160 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2088 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2161 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2089 | nx, ny, image->width, image->height); |
2162 | nx, ny, image->width, image->height); |
2090 | XFreeGC (display->display, gc); |
2163 | XFreeGC (display->display, gc); |
2091 | XDestroyImage (image); |
2164 | XDestroyImage (image); |
2092 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, |
2165 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); |
2093 | TermWin.pixmap); |
2166 | XClearWindow (display->display, TermWin.parent[0]); |
2094 | |
2167 | |
2095 | if (!am_transparent || !am_pixmap_trans) |
2168 | if (!am_transparent || !am_pixmap_trans) |
2096 | pchanged = 1; |
2169 | pchanged = 1; |
2097 | |
2170 | |
2098 | am_transparent = am_pixmap_trans = 1; |
2171 | am_transparent = am_pixmap_trans = 1; |
… | |
… | |
2143 | } |
2216 | } |
2144 | |
2217 | |
2145 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2218 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2146 | { |
2219 | { |
2147 | D_X ((stderr, "InheritPixmap Turning off")); |
2220 | D_X ((stderr, "InheritPixmap Turning off")); |
2148 | XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); |
2221 | XSetWindowBackground (display->display, TermWin.parent[0], PixColorsFocused[Color_fg]); |
2149 | XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); |
2222 | XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); |
2150 | am_transparent = 0; |
2223 | am_transparent = 0; |
2151 | /* XXX: also turn off Opt_transparent? */ |
2224 | /* XXX: also turn off Opt_transparent? */ |
2152 | } |
2225 | } |
2153 | else |
2226 | else |
2154 | { |
2227 | { |
… | |
… | |
2157 | * needed for fvwm2.2.2 (and before?) */ |
2230 | * needed for fvwm2.2.2 (and before?) */ |
2158 | sleep (1); |
2231 | sleep (1); |
2159 | #endif |
2232 | #endif |
2160 | D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); |
2233 | D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); |
2161 | for (n = 0; n < (unsigned int)i; n++) |
2234 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2235 | { |
2162 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); |
2236 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); |
|
|
2237 | XClearWindow (display->display, TermWin.parent[n]); |
|
|
2238 | } |
2163 | |
2239 | |
2164 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2240 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2165 | am_transparent = 1; |
2241 | am_transparent = 1; |
2166 | } |
2242 | } |
2167 | |
2243 | |
2168 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2244 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2169 | 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); |
2170 | } |
2255 | } |
2171 | |
2256 | |
2172 | return pchanged; |
2257 | return pchanged; |
2173 | } |
2258 | } |
2174 | #endif |
2259 | #endif |
… | |
… | |
2191 | } |
2276 | } |
2192 | |
2277 | |
2193 | if (ch == NOCHAR) // TODO: improve |
2278 | if (ch == NOCHAR) // TODO: improve |
2194 | break; |
2279 | break; |
2195 | |
2280 | |
2196 | if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r') |
2281 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2197 | { |
2282 | { |
2198 | /* Read a text string from the input buffer */ |
2283 | /* Read a text string from the input buffer */ |
2199 | unicode_t buf[UBUFSIZ]; |
2284 | unicode_t buf[UBUFSIZ]; |
2200 | bool refreshnow = false; |
2285 | bool refreshnow = false; |
2201 | int nlines = 0; |
2286 | int nlines = 0; |
2202 | unicode_t *str = buf; |
2287 | unicode_t *str = buf; |
2203 | |
2288 | |
2204 | *str++ = ch; |
|
|
2205 | |
|
|
2206 | for (;;) |
2289 | for (;;) |
2207 | { |
2290 | { |
2208 | seq_begin = cmdbuf_ptr; |
|
|
2209 | ch = next_char (); |
|
|
2210 | |
|
|
2211 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r')) |
2291 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2212 | break; |
2292 | break; |
2213 | |
2293 | |
2214 | *str++ = ch; |
2294 | *str++ = ch; |
2215 | |
2295 | |
2216 | if (ch == '\n') |
2296 | if (ch == C0_LF) |
2217 | { |
2297 | { |
2218 | nlines++; |
2298 | nlines++; |
2219 | refresh_count++; |
2299 | refresh_count++; |
2220 | |
2300 | |
2221 | if (! (Options & Opt_jumpScroll) |
2301 | if (!(Options & Opt_jumpScroll) |
2222 | || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) |
2302 | || (refresh_count >= refresh_limit * (TermWin.nrow - 1))) |
2223 | { |
2303 | { |
2224 | refreshnow = true; |
2304 | refreshnow = true; |
2225 | flag = true; |
|
|
2226 | ch = NOCHAR; |
2305 | ch = NOCHAR; |
2227 | break; |
2306 | break; |
2228 | } |
2307 | } |
2229 | |
2308 | |
2230 | // scr_add_lines only works for nlines < TermWin.nrow - 1. |
2309 | // scr_add_lines only works for nlines <= TermWin.nrow - 1. |
2231 | if (nlines >= TermWin.nrow - 1) |
2310 | if (nlines >= TermWin.nrow - 1) |
2232 | { |
2311 | { |
2233 | scr_add_lines (buf, nlines, str - buf); |
2312 | scr_add_lines (buf, nlines, str - buf); |
2234 | nlines = 0; |
2313 | nlines = 0; |
2235 | str = buf; |
2314 | str = buf; |
… | |
… | |
2239 | if (str >= buf + UBUFSIZ) |
2318 | if (str >= buf + UBUFSIZ) |
2240 | { |
2319 | { |
2241 | ch = NOCHAR; |
2320 | ch = NOCHAR; |
2242 | break; |
2321 | break; |
2243 | } |
2322 | } |
|
|
2323 | |
|
|
2324 | seq_begin = cmdbuf_ptr; |
|
|
2325 | ch = next_char (); |
2244 | } |
2326 | } |
2245 | |
2327 | |
2246 | scr_add_lines (buf, nlines, str - buf); |
2328 | scr_add_lines (buf, nlines, str - buf); |
2247 | |
2329 | |
2248 | /* |
2330 | /* |
2249 | * 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 |
2250 | * 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. |
2251 | * the number of pages between refreshes is refresh_limit, which |
2333 | * the number of pages between refreshes is refresh_limit, which |
2252 | * is incremented here because we must be doing flat-out scrolling. |
2334 | * is incremented here because we must be doing flat-out scrolling. |
2253 | * |
|
|
2254 | * refreshing should be correct for small scrolls, because of the |
|
|
2255 | * time-out |
|
|
2256 | */ |
2335 | */ |
2257 | if (refreshnow) |
2336 | if (refreshnow) |
2258 | { |
2337 | { |
2259 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2338 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2260 | refresh_limit++; |
2339 | refresh_limit++; |
2261 | |
2340 | else |
|
|
2341 | { |
|
|
2342 | flag = true; |
2262 | scr_refresh (refresh_type); |
2343 | scr_refresh (refresh_type); |
|
|
2344 | } |
2263 | } |
2345 | } |
2264 | |
2346 | |
2265 | } |
2347 | } |
2266 | else |
2348 | else |
2267 | { |
2349 | { |
… | |
… | |
2281 | } |
2363 | } |
2282 | |
2364 | |
2283 | return flag; |
2365 | return flag; |
2284 | } |
2366 | } |
2285 | |
2367 | |
|
|
2368 | // read the next octet |
|
|
2369 | unicode_t |
|
|
2370 | rxvt_term::next_octet () |
|
|
2371 | { |
|
|
2372 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2373 | ? *cmdbuf_ptr++ |
|
|
2374 | : NOCHAR; |
|
|
2375 | } |
|
|
2376 | |
2286 | // read the next character |
2377 | // read the next character |
2287 | unicode_t |
2378 | unicode_t |
2288 | rxvt_term::next_char () |
2379 | rxvt_term::next_char () |
2289 | { |
2380 | { |
2290 | while (cmdbuf_ptr < cmdbuf_endp) |
2381 | while (cmdbuf_ptr < cmdbuf_endp) |
… | |
… | |
2321 | */ |
2412 | */ |
2322 | unicode_t |
2413 | unicode_t |
2323 | rxvt_term::cmd_getc () |
2414 | rxvt_term::cmd_getc () |
2324 | { |
2415 | { |
2325 | 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 | |
|
|
2424 | unicode_t |
|
|
2425 | rxvt_term::cmd_get8 () |
|
|
2426 | { |
|
|
2427 | unicode_t c = next_octet (); |
2326 | |
2428 | |
2327 | if (c == NOCHAR) |
2429 | if (c == NOCHAR) |
2328 | throw out_of_input; |
2430 | throw out_of_input; |
2329 | |
2431 | |
2330 | return c; |
2432 | return c; |
… | |
… | |
2460 | break; |
2562 | break; |
2461 | case C0_SI: /* shift in - acs */ |
2563 | case C0_SI: /* shift in - acs */ |
2462 | scr_charset_choose (0); |
2564 | scr_charset_choose (0); |
2463 | break; |
2565 | break; |
2464 | |
2566 | |
|
|
2567 | #ifdef EIGHT_BIT_CONTROLS |
2465 | // 8-bit controls |
2568 | // 8-bit controls |
2466 | case 0x90: /* DCS */ |
2569 | case 0x90: /* DCS */ |
2467 | process_dcs_seq (); |
2570 | process_dcs_seq (); |
2468 | break; |
2571 | break; |
2469 | case 0x9b: /* CSI */ |
2572 | case 0x9b: /* CSI */ |
2470 | process_csi_seq (); |
2573 | process_csi_seq (); |
2471 | break; |
2574 | break; |
2472 | case 0x9d: /* CSI */ |
2575 | case 0x9d: /* CSI */ |
2473 | process_osc_seq (); |
2576 | process_osc_seq (); |
2474 | break; |
2577 | break; |
|
|
2578 | #endif |
2475 | } |
2579 | } |
2476 | } |
2580 | } |
2477 | /*}}} */ |
2581 | /*}}} */ |
2478 | |
2582 | |
2479 | |
2583 | |
… | |
… | |
2597 | break; |
2701 | break; |
2598 | |
2702 | |
2599 | /* 8.3.87: NEXT LINE */ |
2703 | /* 8.3.87: NEXT LINE */ |
2600 | case C1_NEL: /* ESC E */ |
2704 | case C1_NEL: /* ESC E */ |
2601 | { |
2705 | { |
2602 | unicode_t nlcr[] = { L'\n', L'\r' }; |
2706 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2603 | scr_add_lines (nlcr, 1, 2); |
2707 | scr_add_lines (nlcr, 1, 2); |
2604 | } |
2708 | } |
2605 | break; |
2709 | break; |
2606 | |
2710 | |
2607 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2711 | /* kidnapped escape sequence: Should be 8.3.48 */ |
… | |
… | |
2668 | |
2772 | |
2669 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2773 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2670 | /* *INDENT-OFF* */ |
2774 | /* *INDENT-OFF* */ |
2671 | enum { |
2775 | enum { |
2672 | CSI_ICH = 0x40, |
2776 | CSI_ICH = 0x40, |
2673 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2777 | 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 , |
2778 | 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, |
2779 | 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, |
2780 | 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, |
2781 | 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, |
2782 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
… | |
… | |
3092 | #endif |
3196 | #endif |
3093 | |
3197 | |
3094 | /*----------------------------------------------------------------------*/ |
3198 | /*----------------------------------------------------------------------*/ |
3095 | /* |
3199 | /* |
3096 | * get input up until STRING TERMINATOR (or BEL) |
3200 | * get input up until STRING TERMINATOR (or BEL) |
3097 | * ends_how is terminator used. returned input must be free ()d |
3201 | * ends_how is terminator used. returned input must be free()'d |
3098 | */ |
3202 | */ |
3099 | unsigned char * |
3203 | unsigned char * |
3100 | rxvt_term::get_to_st (unicode_t &ends_how) |
3204 | rxvt_term::get_to_st (unicode_t &ends_how) |
3101 | { |
3205 | { |
3102 | int seen_esc = 0; /* seen escape? */ |
3206 | unicode_t prev = 0, ch; |
3103 | unsigned int n = 0; |
3207 | unsigned int n = 0; |
3104 | unsigned char *s; |
3208 | unsigned char *s; |
3105 | unicode_t ch; |
|
|
3106 | unsigned char string[STRING_MAX]; |
3209 | unsigned char string[STRING_MAX]; |
3107 | |
3210 | |
3108 | while ((ch = cmd_getc ())) |
3211 | while ((ch = cmd_getc ()) != NOCHAR) |
3109 | { |
3212 | { |
3110 | if (ch == C0_BEL || ch == CHAR_ST) |
3213 | if (prev == C0_ESC) |
3111 | break; |
3214 | { |
3112 | |
|
|
3113 | if (seen_esc) |
|
|
3114 | if (ch == 0x5c) /* 7bit ST */ |
3215 | if (ch == 0x5c) /* 7bit ST */ |
3115 | break; |
3216 | break; |
3116 | else |
3217 | else |
3117 | return NULL; |
3218 | return NULL; |
3118 | |
|
|
3119 | if (ch == C0_ESC) |
|
|
3120 | { |
3219 | } |
3121 | seen_esc = 1; |
3220 | else if (ch == C0_BEL || ch == CHAR_ST) |
3122 | continue; |
3221 | break; |
3123 | } |
3222 | 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 */ |
3223 | return NULL; /* other control character - exit */ |
3128 | |
3224 | |
3129 | if (n >= sizeof (string) - 1) |
3225 | if (n >= sizeof (string) - 1) |
3130 | // stop at some sane length |
3226 | // stop at some sane length |
3131 | return NULL; |
3227 | return NULL; |
3132 | |
3228 | |
|
|
3229 | if (ch == C0_SYN) |
|
|
3230 | { |
|
|
3231 | string[n++] = cmd_get8 (); |
|
|
3232 | prev = 0; |
|
|
3233 | } |
|
|
3234 | else |
3133 | string[n++] = ch; |
3235 | string[n++] = prev = ch; |
3134 | seen_esc = 0; |
|
|
3135 | } |
3236 | } |
3136 | |
3237 | |
3137 | string[n++] = '\0'; |
3238 | string[n++] = '\0'; |
3138 | |
3239 | |
3139 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
3240 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
… | |
… | |
3196 | if (str[0] == '?' && !str[1]) |
3297 | if (str[0] == '?' && !str[1]) |
3197 | { |
3298 | { |
3198 | if (Options & Opt_insecure) |
3299 | if (Options & Opt_insecure) |
3199 | { |
3300 | { |
3200 | unsigned short r, g, b; |
3301 | unsigned short r, g, b; |
3201 | PixColors[color].get (display, r, g, b); |
3302 | PixColorsFocused[color].get (display, r, g, b); |
3202 | 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); |
3203 | } |
3304 | } |
3204 | } |
3305 | } |
3205 | else |
3306 | else |
3206 | set_window_color (color, str); |
3307 | set_window_color (color, str); |
… | |
… | |
3311 | if (name[0] == '?' && !name[1]) |
3412 | if (name[0] == '?' && !name[1]) |
3312 | { |
3413 | { |
3313 | if (Options & Opt_insecure) |
3414 | if (Options & Opt_insecure) |
3314 | { |
3415 | { |
3315 | unsigned short r, g, b; |
3416 | unsigned short r, g, b; |
3316 | PixColors[color + minCOLOR].get (display, r, g, b); |
3417 | 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); |
3418 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3318 | } |
3419 | } |
3319 | } |
3420 | } |
3320 | else |
3421 | else |
3321 | set_window_color (color + minCOLOR, name); |
3422 | set_window_color (color + minCOLOR, name); |
… | |
… | |
3694 | rendset = 0, rendstyle = ~RS_None; |
3795 | rendset = 0, rendstyle = ~RS_None; |
3695 | break; |
3796 | break; |
3696 | case 1: |
3797 | case 1: |
3697 | rendset = 1, rendstyle = RS_Bold; |
3798 | rendset = 1, rendstyle = RS_Bold; |
3698 | break; |
3799 | break; |
|
|
3800 | //case 2: // faint or second colour |
3699 | case 4: |
3801 | case 4: |
3700 | rendset = 1, rendstyle = RS_Uline; |
3802 | rendset = 1, rendstyle = RS_Uline; |
3701 | break; |
3803 | break; |
3702 | case 5: |
3804 | case 5: // slowly blinking |
|
|
3805 | case 6: // rapidly blinking |
3703 | rendset = 1, rendstyle = RS_Blink; |
3806 | rendset = 1, rendstyle = RS_Blink; |
3704 | break; |
3807 | break; |
|
|
3808 | //case 6: // scoansi light background |
3705 | case 7: |
3809 | case 7: |
3706 | rendset = 1, rendstyle = RS_RVid; |
3810 | rendset = 1, rendstyle = RS_RVid; |
3707 | break; |
3811 | break; |
3708 | case 8: |
3812 | case 8: |
3709 | // invisible. NYI |
3813 | // invisible. NYI |
3710 | break; |
3814 | break; |
|
|
3815 | //case 9: // crossed out |
|
|
3816 | //case 10: // scoansi acs off, primary font |
|
|
3817 | //case 11: // scoansi acs on, first alt font |
|
|
3818 | //case 12: // scoansi acs on, |0x80, second alt font |
|
|
3819 | //... |
|
|
3820 | //case 19: // ninth alt font |
|
|
3821 | //case 20: // gothic |
|
|
3822 | case 21: // disable bold, faint |
|
|
3823 | rendset = 0, rendstyle = RS_Bold; |
|
|
3824 | break; |
3711 | case 22: |
3825 | case 22: |
3712 | rendset = 0, rendstyle = RS_Bold; |
3826 | rendset = 0, rendstyle = RS_Bold; |
3713 | break; |
3827 | break; |
|
|
3828 | //case 23: disable italic |
3714 | case 24: |
3829 | case 24: |
3715 | rendset = 0, rendstyle = RS_Uline; |
3830 | rendset = 0, rendstyle = RS_Uline; |
3716 | break; |
3831 | break; |
3717 | case 25: |
3832 | case 25: |
3718 | rendset = 0, rendstyle = RS_Blink; |
3833 | rendset = 0, rendstyle = RS_Blink; |
3719 | break; |
3834 | break; |
3720 | case 27: |
3835 | case 27: |
3721 | rendset = 0, rendstyle = RS_RVid; |
3836 | rendset = 0, rendstyle = RS_RVid; |
3722 | break; |
3837 | break; |
3723 | case 28: |
|
|
3724 | // visible. NYI |
3838 | //case 28: // visible. NYI |
3725 | break; |
3839 | //case 29: // not crossed-out |
3726 | } |
3840 | } |
3727 | |
3841 | |
3728 | if (rendset != -1) |
3842 | if (rendset != -1) |
3729 | { |
3843 | { |
3730 | scr_rendition (rendset, rendstyle); |
3844 | scr_rendition (rendset, rendstyle); |
… | |
… | |
3807 | } |
3921 | } |
3808 | } |
3922 | } |
3809 | } |
3923 | } |
3810 | /*}}} */ |
3924 | /*}}} */ |
3811 | |
3925 | |
3812 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3926 | /*{{{ (do not) process Rob Nation's own graphics mode sequences */ |
3813 | void |
3927 | void |
3814 | rxvt_term::process_graphics () |
3928 | rxvt_term::process_graphics () |
3815 | { |
3929 | { |
3816 | unicode_t ch, cmd = cmd_getc (); |
3930 | unicode_t ch, cmd = cmd_getc (); |
3817 | |
3931 | |