… | |
… | |
759 | |
759 | |
760 | bool |
760 | bool |
761 | rxvt_term::cmd_parse () |
761 | rxvt_term::cmd_parse () |
762 | { |
762 | { |
763 | bool flag = false; |
763 | bool flag = false; |
764 | uint32_t ch = NOCHAR; |
764 | unicode_t ch = NOCHAR; |
765 | |
765 | |
766 | for (;;) |
766 | for (;;) |
767 | { |
767 | { |
768 | if (ch == NOCHAR) |
768 | if (ch == NOCHAR) |
769 | ch = next_char (); |
769 | ch = next_char (); |
… | |
… | |
772 | break; |
772 | break; |
773 | |
773 | |
774 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
774 | if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r') |
775 | { |
775 | { |
776 | /* Read a text string from the input buffer */ |
776 | /* Read a text string from the input buffer */ |
777 | uint32_t buf[BUFSIZ]; |
777 | unicode_t buf[BUFSIZ]; |
778 | bool refreshnow = false; |
778 | bool refreshnow = false; |
779 | int nlines = 0; |
779 | int nlines = 0; |
780 | uint32_t *str = buf; |
780 | unicode_t *str = buf; |
781 | |
781 | |
782 | *str++ = ch; |
782 | *str++ = ch; |
783 | |
783 | |
784 | for (;;) |
784 | for (;;) |
785 | { |
785 | { |
… | |
… | |
863 | return flag; |
863 | return flag; |
864 | } |
864 | } |
865 | |
865 | |
866 | // read the next character, currently handles UTF-8 |
866 | // read the next character, currently handles UTF-8 |
867 | // will probably handle all sorts of other stuff in the future |
867 | // will probably handle all sorts of other stuff in the future |
868 | uint32_t |
868 | unicode_t |
869 | rxvt_term::next_char () |
869 | rxvt_term::next_char () |
870 | { |
870 | { |
871 | while (cmdbuf_ptr < cmdbuf_endp) |
871 | while (cmdbuf_ptr < cmdbuf_endp) |
872 | { |
872 | { |
873 | // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh |
873 | // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh |
… | |
… | |
899 | /* rxvt_cmd_getc () - Return next input character */ |
899 | /* rxvt_cmd_getc () - Return next input character */ |
900 | /* |
900 | /* |
901 | * Return the next input character after first passing any keyboard input |
901 | * Return the next input character after first passing any keyboard input |
902 | * to the command. |
902 | * to the command. |
903 | */ |
903 | */ |
904 | uint32_t |
904 | unicode_t |
905 | rxvt_term::cmd_getc () |
905 | rxvt_term::cmd_getc () |
906 | { |
906 | { |
907 | for (;;) |
907 | for (;;) |
908 | { |
908 | { |
909 | uint32_t c = next_char (); |
909 | unicode_t c = next_char (); |
910 | if (c != NOCHAR) |
910 | if (c != NOCHAR) |
911 | return c; |
911 | return c; |
912 | |
912 | |
913 | // incomplete sequences should occur rarely, still, a better solution |
913 | // incomplete sequences should occur rarely, still, a better solution |
914 | // would be preferred. either setjmp/longjmp or better design. |
914 | // would be preferred. either setjmp/longjmp or better design. |
… | |
… | |
2331 | break; |
2331 | break; |
2332 | |
2332 | |
2333 | /* 8.3.87: NEXT LINE */ |
2333 | /* 8.3.87: NEXT LINE */ |
2334 | case C1_NEL: /* ESC E */ |
2334 | case C1_NEL: /* ESC E */ |
2335 | { |
2335 | { |
2336 | uint32_t nlcr[] = { '\n', '\r' }; |
2336 | unicode_t nlcr[] = { L'\n', L'\r' }; |
2337 | scr_add_lines (nlcr, 1, 2); |
2337 | scr_add_lines (nlcr, 1, 2); |
2338 | } |
2338 | } |
2339 | break; |
2339 | break; |
2340 | |
2340 | |
2341 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2341 | /* kidnapped escape sequence: Should be 8.3.48 */ |
… | |
… | |
3126 | { menuBar_esc, PrivMode_menuBar }, |
3126 | { menuBar_esc, PrivMode_menuBar }, |
3127 | #endif |
3127 | #endif |
3128 | #ifdef scrollBar_esc |
3128 | #ifdef scrollBar_esc |
3129 | { scrollBar_esc, PrivMode_scrollBar }, |
3129 | { scrollBar_esc, PrivMode_scrollBar }, |
3130 | #endif |
3130 | #endif |
|
|
3131 | // 18, 19 printing-related |
3131 | { 25, PrivMode_VisibleCursor }, |
3132 | { 25, PrivMode_VisibleCursor }, |
|
|
3133 | // 30 show scrollbar rxvt. extension |
3132 | { 35, PrivMode_ShiftKeys }, |
3134 | { 35, PrivMode_ShiftKeys }, // rxvt extension |
3133 | { 40, PrivMode_132OK }, |
3135 | { 40, PrivMode_132OK }, |
|
|
3136 | // 41 xterm more fixes NYI |
|
|
3137 | // 45 margin bell NYI |
|
|
3138 | // 46 start logging |
3134 | { 47, PrivMode_Screen }, |
3139 | { 47, PrivMode_Screen }, |
3135 | { 66, PrivMode_aplKP }, |
3140 | { 66, PrivMode_aplKP }, |
3136 | #ifndef NO_BACKSPACE_KEY |
3141 | #ifndef NO_BACKSPACE_KEY |
3137 | { 67, PrivMode_BackSpace }, |
3142 | { 67, PrivMode_BackSpace }, |
3138 | #endif |
3143 | #endif |
3139 | { 1000, PrivMode_MouseX11 }, |
3144 | { 1000, PrivMode_MouseX11 }, |
|
|
3145 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
|
|
3146 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
|
|
3147 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
3140 | { 1010, PrivMode_TtyOutputInh }, |
3148 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3141 | { 1011, PrivMode_Keypress }, |
3149 | { 1011, PrivMode_Keypress }, // rxvt extension |
|
|
3150 | // 1035 enable modifiers for alt, numlock NYI |
|
|
3151 | // 1036 send ESC for meta keys NYI |
|
|
3152 | // 1037 send DEL for keypad delete NYI |
3142 | { 1047, PrivMode_Screen }, |
3153 | { 1047, PrivMode_Screen }, |
|
|
3154 | // 1048 save and restore cursor |
3143 | { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ |
3155 | { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ |
|
|
3156 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3144 | }; |
3157 | }; |
3145 | |
3158 | |
3146 | if (nargs == 0) |
3159 | if (nargs == 0) |
3147 | return; |
3160 | return; |
3148 | |
3161 | |
… | |
… | |
3163 | state = privcases (mode, argtopriv[j].bit); |
3176 | state = privcases (mode, argtopriv[j].bit); |
3164 | break; |
3177 | break; |
3165 | } |
3178 | } |
3166 | |
3179 | |
3167 | /* extra handling for values with state unkept */ |
3180 | /* extra handling for values with state unkept */ |
|
|
3181 | switch (arg[i]) |
|
|
3182 | { |
|
|
3183 | case 1048: /* alternative cursor save */ |
|
|
3184 | case 1049: |
|
|
3185 | if (mode == 0) |
|
|
3186 | scr_cursor (RESTORE); |
|
|
3187 | else if (mode == 1) |
|
|
3188 | scr_cursor (SAVE); |
|
|
3189 | /* FALLTHROUGH */ |
|
|
3190 | } |
|
|
3191 | |
3168 | if (state == -1) |
3192 | if (state >= 0) |
|
|
3193 | /* extra handling for values with valid 0 or 1 state */ |
3169 | switch (arg[i]) |
3194 | switch (arg[i]) |
3170 | { |
3195 | { |
3171 | case 1048: /* alternative cursor save */ |
3196 | /* case 1: - application cursor keys */ |
|
|
3197 | case 2: /* VT52 mode */ |
|
|
3198 | /* oddball mode. should be set regardless of set/reset |
|
|
3199 | * parameter. Return from VT52 mode with an ESC < from |
|
|
3200 | * within VT52 mode |
|
|
3201 | */ |
|
|
3202 | PrivMode (1, PrivMode_vt52); |
|
|
3203 | break; |
|
|
3204 | case 3: /* 80/132 */ |
|
|
3205 | if (PrivateModes & PrivMode_132OK) |
|
|
3206 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
|
|
3207 | break; |
|
|
3208 | case 4: /* smooth scrolling */ |
3172 | if (mode == 0) |
3209 | if (state) |
3173 | scr_cursor (RESTORE); |
3210 | Options &= ~Opt_jumpScroll; |
3174 | else if (mode == 1) |
3211 | else |
3175 | scr_cursor (SAVE); |
3212 | Options |= Opt_jumpScroll; |
|
|
3213 | break; |
|
|
3214 | case 5: /* reverse video */ |
|
|
3215 | scr_rvideo_mode (state); |
|
|
3216 | break; |
|
|
3217 | case 6: /* relative/absolute origins */ |
|
|
3218 | scr_relative_origin (state); |
|
|
3219 | break; |
|
|
3220 | case 7: /* autowrap */ |
|
|
3221 | scr_autowrap (state); |
|
|
3222 | break; |
|
|
3223 | /* case 8: - auto repeat, can't do on a per window basis */ |
|
|
3224 | case 9: /* X10 mouse reporting */ |
|
|
3225 | if (state) /* orthogonal */ |
|
|
3226 | PrivateModes &= ~ (PrivMode_MouseX11); |
|
|
3227 | break; |
|
|
3228 | #ifdef menuBar_esc |
|
|
3229 | case menuBar_esc: |
|
|
3230 | #ifdef MENUBAR |
|
|
3231 | map_menuBar (state); |
|
|
3232 | #endif |
|
|
3233 | break; |
|
|
3234 | #endif |
|
|
3235 | #ifdef scrollBar_esc |
|
|
3236 | case scrollBar_esc: |
|
|
3237 | if (scrollbar_mapping (state)) |
|
|
3238 | { |
|
|
3239 | resize_all_windows (0, 0, 0); |
|
|
3240 | scr_touch (true); |
|
|
3241 | } |
|
|
3242 | break; |
|
|
3243 | #endif |
|
|
3244 | case 25: /* visible/invisible cursor */ |
|
|
3245 | scr_cursor_visible (state); |
|
|
3246 | break; |
|
|
3247 | /* case 35: - shift keys */ |
|
|
3248 | /* case 40: - 80 <--> 132 mode */ |
|
|
3249 | case 47: /* secondary screen */ |
|
|
3250 | scr_change_screen (state); |
|
|
3251 | break; |
|
|
3252 | /* case 66: - application key pad */ |
|
|
3253 | /* case 67: - backspace key */ |
|
|
3254 | case 1000: /* X11 mouse reporting */ |
|
|
3255 | if (state) /* orthogonal */ |
|
|
3256 | PrivateModes &= ~ (PrivMode_MouseX10); |
|
|
3257 | break; |
|
|
3258 | #if 0 |
|
|
3259 | case 1001: |
|
|
3260 | break; /* X11 mouse highlighting */ |
|
|
3261 | #endif |
|
|
3262 | case 1010: /* scroll to bottom on TTY output inhibit */ |
|
|
3263 | if (state) |
|
|
3264 | Options &= ~Opt_scrollTtyOutput; |
|
|
3265 | else |
|
|
3266 | Options |= Opt_scrollTtyOutput; |
|
|
3267 | break; |
|
|
3268 | case 1011: /* scroll to bottom on key press */ |
|
|
3269 | if (state) |
|
|
3270 | Options |= Opt_scrollTtyKeypress; |
|
|
3271 | else |
|
|
3272 | Options &= ~Opt_scrollTtyKeypress; |
|
|
3273 | break; |
|
|
3274 | case 1047: /* secondary screen w/ clearing */ |
|
|
3275 | case 1049: /* better secondary screen w/ clearing, but not fully implemented */ |
|
|
3276 | if (current_screen != PRIMARY) |
|
|
3277 | scr_erase_screen (2); |
|
|
3278 | scr_change_screen (state); |
3176 | /* FALLTHROUGH */ |
3279 | /* FALLTHROUGH */ |
3177 | default: |
3280 | default: |
3178 | continue; /* for (;i;) */ |
3281 | break; |
3179 | } |
3282 | } |
3180 | |
|
|
3181 | /* extra handling for values with valid 0 or 1 state */ |
|
|
3182 | switch (arg[i]) |
|
|
3183 | { |
|
|
3184 | /* case 1: - application cursor keys */ |
|
|
3185 | case 2: /* VT52 mode */ |
|
|
3186 | /* oddball mode. should be set regardless of set/reset |
|
|
3187 | * parameter. Return from VT52 mode with an ESC < from |
|
|
3188 | * within VT52 mode |
|
|
3189 | */ |
|
|
3190 | PrivMode (1, PrivMode_vt52); |
|
|
3191 | break; |
|
|
3192 | case 3: /* 80/132 */ |
|
|
3193 | if (PrivateModes & PrivMode_132OK) |
|
|
3194 | set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); |
|
|
3195 | break; |
|
|
3196 | case 4: /* smooth scrolling */ |
|
|
3197 | if (state) |
|
|
3198 | Options &= ~Opt_jumpScroll; |
|
|
3199 | else |
|
|
3200 | Options |= Opt_jumpScroll; |
|
|
3201 | break; |
|
|
3202 | case 5: /* reverse video */ |
|
|
3203 | scr_rvideo_mode (state); |
|
|
3204 | break; |
|
|
3205 | case 6: /* relative/absolute origins */ |
|
|
3206 | scr_relative_origin (state); |
|
|
3207 | break; |
|
|
3208 | case 7: /* autowrap */ |
|
|
3209 | scr_autowrap (state); |
|
|
3210 | break; |
|
|
3211 | /* case 8: - auto repeat, can't do on a per window basis */ |
|
|
3212 | case 9: /* X10 mouse reporting */ |
|
|
3213 | if (state) /* orthogonal */ |
|
|
3214 | PrivateModes &= ~ (PrivMode_MouseX11); |
|
|
3215 | break; |
|
|
3216 | #ifdef menuBar_esc |
|
|
3217 | case menuBar_esc: |
|
|
3218 | #ifdef MENUBAR |
|
|
3219 | map_menuBar (state); |
|
|
3220 | #endif |
|
|
3221 | break; |
|
|
3222 | #endif |
|
|
3223 | #ifdef scrollBar_esc |
|
|
3224 | case scrollBar_esc: |
|
|
3225 | if (scrollbar_mapping (state)) |
|
|
3226 | { |
|
|
3227 | resize_all_windows (0, 0, 0); |
|
|
3228 | scr_touch (true); |
|
|
3229 | } |
|
|
3230 | break; |
|
|
3231 | #endif |
|
|
3232 | case 25: /* visible/invisible cursor */ |
|
|
3233 | scr_cursor_visible (state); |
|
|
3234 | break; |
|
|
3235 | /* case 35: - shift keys */ |
|
|
3236 | /* case 40: - 80 <--> 132 mode */ |
|
|
3237 | case 47: /* secondary screen */ |
|
|
3238 | scr_change_screen (state); |
|
|
3239 | break; |
|
|
3240 | /* case 66: - application key pad */ |
|
|
3241 | /* case 67: - backspace key */ |
|
|
3242 | case 1000: /* X11 mouse reporting */ |
|
|
3243 | if (state) /* orthogonal */ |
|
|
3244 | PrivateModes &= ~ (PrivMode_MouseX10); |
|
|
3245 | break; |
|
|
3246 | #if 0 |
|
|
3247 | case 1001: |
|
|
3248 | break; /* X11 mouse highlighting */ |
|
|
3249 | #endif |
|
|
3250 | case 1010: /* scroll to bottom on TTY output inhibit */ |
|
|
3251 | if (state) |
|
|
3252 | Options &= ~Opt_scrollTtyOutput; |
|
|
3253 | else |
|
|
3254 | Options |= Opt_scrollTtyOutput; |
|
|
3255 | break; |
|
|
3256 | case 1011: /* scroll to bottom on key press */ |
|
|
3257 | if (state) |
|
|
3258 | Options |= Opt_scrollTtyKeypress; |
|
|
3259 | else |
|
|
3260 | Options &= ~Opt_scrollTtyKeypress; |
|
|
3261 | break; |
|
|
3262 | case 1047: /* secondary screen w/ clearing */ |
|
|
3263 | case 1049: /* better secondary screen w/ clearing, but not fully implemented */ |
|
|
3264 | if (current_screen != PRIMARY) |
|
|
3265 | scr_erase_screen (2); |
|
|
3266 | scr_change_screen (state); |
|
|
3267 | /* FALLTHROUGH */ |
|
|
3268 | default: |
|
|
3269 | break; |
|
|
3270 | } |
|
|
3271 | } |
3283 | } |
3272 | } |
3284 | } |
3273 | /*}}} */ |
3285 | /*}}} */ |
3274 | |
3286 | |
3275 | /*{{{ process sgr sequences */ |
3287 | /*{{{ process sgr sequences */ |
… | |
… | |
3303 | rendset = 1, rendstyle = RS_Blink; |
3315 | rendset = 1, rendstyle = RS_Blink; |
3304 | break; |
3316 | break; |
3305 | case 7: |
3317 | case 7: |
3306 | rendset = 1, rendstyle = RS_RVid; |
3318 | rendset = 1, rendstyle = RS_RVid; |
3307 | break; |
3319 | break; |
|
|
3320 | case 8: |
|
|
3321 | // invisible. NYI |
|
|
3322 | break; |
3308 | case 22: |
3323 | case 22: |
3309 | rendset = 0, rendstyle = RS_Bold; |
3324 | rendset = 0, rendstyle = RS_Bold; |
3310 | break; |
3325 | break; |
3311 | case 24: |
3326 | case 24: |
3312 | rendset = 0, rendstyle = RS_Uline; |
3327 | rendset = 0, rendstyle = RS_Uline; |
… | |
… | |
3315 | rendset = 0, rendstyle = RS_Blink; |
3330 | rendset = 0, rendstyle = RS_Blink; |
3316 | break; |
3331 | break; |
3317 | case 27: |
3332 | case 27: |
3318 | rendset = 0, rendstyle = RS_RVid; |
3333 | rendset = 0, rendstyle = RS_RVid; |
3319 | break; |
3334 | break; |
|
|
3335 | case 28: |
|
|
3336 | // visible. NYI |
|
|
3337 | break; |
3320 | } |
3338 | } |
|
|
3339 | |
3321 | if (rendset != -1) |
3340 | if (rendset != -1) |
3322 | { |
3341 | { |
3323 | scr_rendition (rendset, rendstyle); |
3342 | scr_rendition (rendset, rendstyle); |
3324 | continue; /* for (;i;) */ |
3343 | continue; /* for (;i;) */ |
3325 | } |
3344 | } |
… | |
… | |
3332 | case 33: |
3351 | case 33: |
3333 | case 34: |
3352 | case 34: |
3334 | case 35: |
3353 | case 35: |
3335 | case 36: |
3354 | case 36: |
3336 | case 37: |
3355 | case 37: |
3337 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), |
3356 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
3338 | Color_fg); |
|
|
3339 | break; |
3357 | break; |
3340 | #ifdef TTY_256COLOR |
3358 | #ifdef TTY_256COLOR |
3341 | case 38: |
3359 | case 38: |
3342 | if (nargs > i + 2 && arg[i + 1] == 5) |
3360 | if (nargs > i + 2 && arg[i + 1] == 5) |
3343 | { |
3361 | { |
3344 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), |
3362 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
3345 | Color_fg); |
|
|
3346 | i += 2; |
3363 | i += 2; |
3347 | } |
3364 | } |
3348 | break; |
3365 | break; |
3349 | #endif |
3366 | #endif |
3350 | case 39: /* default fg */ |
3367 | case 39: /* default fg */ |
… | |
… | |
3357 | case 43: |
3374 | case 43: |
3358 | case 44: |
3375 | case 44: |
3359 | case 45: |
3376 | case 45: |
3360 | case 46: |
3377 | case 46: |
3361 | case 47: |
3378 | case 47: |
3362 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), |
3379 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
3363 | Color_bg); |
|
|
3364 | break; |
3380 | break; |
3365 | #ifdef TTY_256COLOR |
3381 | #ifdef TTY_256COLOR |
3366 | case 48: |
3382 | case 48: |
3367 | if (nargs > i + 2 && arg[i + 1] == 5) |
3383 | if (nargs > i + 2 && arg[i + 1] == 5) |
3368 | { |
3384 | { |
3369 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), |
3385 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
3370 | Color_bg); |
|
|
3371 | i += 2; |
3386 | i += 2; |
3372 | } |
3387 | } |
3373 | break; |
3388 | break; |
3374 | #endif |
3389 | #endif |
3375 | case 49: /* default bg */ |
3390 | case 49: /* default bg */ |