1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: command.c |
2 | * File: command.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: command.C,v 1.14 2003/12/08 23:14:40 pcg Exp $ |
4 | * $Id: command.C,v 1.17 2003/12/18 00:29:29 pcg Exp $ |
5 | * |
5 | * |
6 | * All portions of code are copyright by their respective author/s. |
6 | * All portions of code are copyright by their respective author/s. |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
8 | * - original version |
8 | * - original version |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
… | |
… | |
88 | if (R->Input_Context) |
88 | if (R->Input_Context) |
89 | { |
89 | { |
90 | Status status_return; |
90 | Status status_return; |
91 | |
91 | |
92 | #ifdef X_HAVE_UTF8_STRING |
92 | #ifdef X_HAVE_UTF8_STRING |
93 | len = Xutf8LookupString(R->Input_Context, ev, (char *)kbuf, |
93 | len = Xutf8LookupString (R->Input_Context, ev, (char *)kbuf, |
94 | KBUFSZ, &keysym, &status_return); |
94 | KBUFSZ, &keysym, &status_return); |
95 | #else |
95 | #else |
|
|
96 | wchar_t wkbuf[KBUFSZ + 1]; |
|
|
97 | |
|
|
98 | // assume wchar_t == unicode or better |
96 | len = XmbLookupString(R->Input_Context, ev, (char *)kbuf, |
99 | len = XwcLookupString (R->Input_Context, ev, wkbuf, |
97 | KBUFSZ, &keysym, &status_return); |
100 | KBUFSZ, &keysym, &status_return); |
|
|
101 | |
|
|
102 | if (status_return == XLookupChars |
|
|
103 | || status_return == XLookupBoth) |
|
|
104 | { |
|
|
105 | wkbuf[len] = 0; |
|
|
106 | len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); |
|
|
107 | } |
|
|
108 | else |
|
|
109 | len = 0; |
98 | #endif |
110 | #endif |
99 | valid_keysym = ((status_return == XLookupKeySym) |
111 | valid_keysym = status_return == XLookupKeySym |
100 | || (status_return == XLookupBoth)); |
112 | || status_return == XLookupBoth; |
101 | } |
113 | } |
102 | else |
114 | else |
103 | #endif |
115 | #endif |
104 | { |
116 | { |
105 | len = XLookupString(ev, (char *)kbuf, KBUFSZ, &keysym, &R->compose); |
117 | len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &R->compose); |
106 | valid_keysym = !len; |
118 | valid_keysym = !len; |
107 | } |
119 | } |
108 | |
120 | |
109 | if (valid_keysym) |
121 | if (valid_keysym) |
110 | { |
122 | { |
… | |
… | |
1146 | { |
1158 | { |
1147 | int i, want_timeout; |
1159 | int i, want_timeout; |
1148 | Window unused_root, unused_child; |
1160 | Window unused_root, unused_child; |
1149 | int unused_root_x, unused_root_y; |
1161 | int unused_root_x, unused_root_y; |
1150 | unsigned int unused_mask; |
1162 | unsigned int unused_mask; |
1151 | struct timeval tp; |
|
|
1152 | |
1163 | |
1153 | #ifdef DEBUG_X |
1164 | #ifdef DEBUG_X |
1154 | const char *const eventnames[] = |
1165 | const char *const eventnames[] = |
1155 | { /* mason - this matches my system */ |
1166 | { /* mason - this matches my system */ |
1156 | "", |
1167 | "", |
… | |
… | |
1187 | "SelectionNotify", |
1198 | "SelectionNotify", |
1188 | "ColormapNotify", |
1199 | "ColormapNotify", |
1189 | "ClientMessage", |
1200 | "ClientMessage", |
1190 | "MappingNotify" |
1201 | "MappingNotify" |
1191 | }; |
1202 | }; |
|
|
1203 | #endif |
|
|
1204 | |
|
|
1205 | #ifdef DEBUG_X |
|
|
1206 | struct timeval tp; |
1192 | struct tm *ltt; |
1207 | struct tm *ltt; |
1193 | #endif |
|
|
1194 | |
|
|
1195 | /* |
|
|
1196 | * check if we need to get the time for any timeouts |
|
|
1197 | */ |
|
|
1198 | |
|
|
1199 | for (i = NUM_TIMEOUTS; i--; ) |
|
|
1200 | if (R->timeout[i].tv_sec) { |
|
|
1201 | want_timeout = 1; |
|
|
1202 | break; |
|
|
1203 | } |
|
|
1204 | |
|
|
1205 | #ifndef DEBUG_X |
|
|
1206 | if (want_timeout) |
|
|
1207 | #endif |
|
|
1208 | (void)gettimeofday(&tp, NULL); |
1208 | (void)gettimeofday(&tp, NULL); |
1209 | |
|
|
1210 | #ifdef DEBUG_X |
|
|
1211 | ltt = localtime(&(tp.tv_sec)); |
1209 | ltt = localtime(&(tp.tv_sec)); |
1212 | D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial)); |
1210 | D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial)); |
1213 | #endif |
1211 | #endif |
1214 | |
|
|
1215 | /* X event timeouts */ |
|
|
1216 | if (want_timeout) |
|
|
1217 | for (i = NUM_TIMEOUTS; i--; ) { |
|
|
1218 | if (R->timeout[i].tv_sec == 0) |
|
|
1219 | continue; |
|
|
1220 | if ((tp.tv_sec < R->timeout[i].tv_sec) |
|
|
1221 | || (tp.tv_sec == R->timeout[i].tv_sec |
|
|
1222 | && tp.tv_usec < R->timeout[i].tv_usec)) |
|
|
1223 | continue; |
|
|
1224 | R->timeout[i].tv_sec = 0; |
|
|
1225 | switch(i) { |
|
|
1226 | case TIMEOUT_INCR: |
|
|
1227 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
|
|
1228 | R->selection_wait = Sel_none; |
|
|
1229 | break; |
|
|
1230 | default: |
|
|
1231 | break; |
|
|
1232 | } |
|
|
1233 | } |
|
|
1234 | |
1212 | |
1235 | switch (ev->type) { |
1213 | switch (ev->type) { |
1236 | case KeyPress: |
1214 | case KeyPress: |
1237 | rxvt_lookup_key(aR_ (XKeyEvent *)ev); |
1215 | rxvt_lookup_key(aR_ (XKeyEvent *)ev); |
1238 | break; |
1216 | break; |
… | |
… | |
2616 | |
2594 | |
2617 | case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */ |
2595 | case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */ |
2618 | arg[0] = -arg[0]; |
2596 | arg[0] = -arg[0]; |
2619 | /* FALLTHROUGH */ |
2597 | /* FALLTHROUGH */ |
2620 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
2598 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
2621 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, arg[0], 0); |
2599 | R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, arg[0], 0); |
2622 | break; |
2600 | break; |
2623 | |
2601 | |
2624 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
2602 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
2625 | R->tt_write((const unsigned char *)VT100_ANS, |
2603 | R->tt_write((const unsigned char *)VT100_ANS, |
2626 | (unsigned int)(sizeof(VT100_ANS) - 1)); |
2604 | (unsigned int)(sizeof(VT100_ANS) - 1)); |