| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static ptyc_term_handler csi_illegal_code; |
| static ptyc_term_handler csi_param_decimal_digit; |
| static ptyc_term_handler csi_param_semicolon; |
| |
| |
| static ptyc_term_handler csi_action_select_sgr; |
| static ptyc_term_handler csi_action_process_params; |
| |
| ptyc_term_handler * const ptyc_csi_handlers[PTYC_CSI_ARRAY_SIZE] = { |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_param_decimal_digit, |
| csi_illegal_code, |
| csi_param_semicolon, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_illegal_code, |
| csi_action_select_sgr, |
| csi_illegal_code |
| }; |
| |
| |
| static void * __fastcall csi_illegal_code(struct ptyc_term_ctx * tctx) |
| { |
| |
| return tctx->char_handler; |
| } |
| |
| |
| static void * __fastcall csi_param_decimal_digit(struct ptyc_term_ctx * tctx) |
| { |
| |
| *tctx->ctrl_param *= 10; |
| *tctx->ctrl_param += *tctx->wch_pty - '0'; |
| |
| |
| tctx->wch_pty++; |
| |
| |
| return tctx->ctrl_handler; |
| } |
| |
| |
| static void * __fastcall csi_param_semicolon(struct ptyc_term_ctx * tctx) |
| { |
| |
| if (tctx->ctrl_param == &tctx->ctrl_params[PTYC_CTRL_PARAMS-1]) |
| return csi_illegal_code(tctx); |
| |
| |
| tctx->ctrl_param++; |
| *tctx->ctrl_param = 0; |
| |
| |
| tctx->wch_pty++; |
| |
| |
| return tctx->ctrl_handler; |
| } |
| |
| |
| static void * __fastcall csi_action_invoke( |
| struct ptyc_term_ctx * tctx, |
| ptyc_term_handler * const * handlers, |
| unsigned int ctrl_cap) |
| { |
| |
| tctx->ctrl_state = PTYC_CTRL_STATE_COMMAND_HANDLERS; |
| tctx->ctrl_handlers[tctx->ctrl_state] = handlers; |
| |
| |
| tctx->ctrl_cap = ctrl_cap; |
| |
| |
| tctx->ctrl_command = csi_action_process_params; |
| |
| |
| tctx->ctrl_command(tctx); |
| |
| |
| tctx->wch_pty++; |
| |
| |
| return tctx->char_handler; |
| } |
| |
| |
| static void * __fastcall csi_action_select_sgr(struct ptyc_term_ctx * tctx) |
| { |
| return csi_action_invoke(tctx,ptyc_sgr_handlers,PTYC_SGR_ARRAY_SIZE); |
| } |
| |
| static void * __fastcall csi_action_process_params(struct ptyc_term_ctx * tctx) |
| { |
| ptyc_term_handler * pfn_action; |
| unsigned int action_idx; |
| |
| tctx->ctrl_mark = tctx->ctrl_params; |
| |
| while (tctx->ctrl_mark <= tctx->ctrl_param) { |
| action_idx = (*tctx->ctrl_mark < tctx->ctrl_cap) |
| ? *tctx->ctrl_mark |
| : tctx->ctrl_cap - 1; |
| |
| pfn_action = tctx->ctrl_handlers[tctx->ctrl_state][action_idx]; |
| pfn_action(tctx); |
| |
| tctx->ctrl_mark++; |
| } |
| |
| |
| return tctx->ctrl_mark; |
| } |