diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-10-21 00:02:43 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-10-21 00:03:50 -0400 |
commit | f2b7dd0e1bd6d7e89e5cd6b3e4ee13dbb45e04a4 (patch) | |
tree | e9928debda661d9d61a996e5ace2d8a95b0b4513 | |
parent | 1f02c35acb0c3b3f7534fb55384cf7f708b5b92d (diff) | |
download | libvt100-f2b7dd0e1bd6d7e89e5cd6b3e4ee13dbb45e04a4.tar.gz libvt100-f2b7dd0e1bd6d7e89e5cd6b3e4ee13dbb45e04a4.zip |
parse CSI params from DECSED and DECSEL properly
-rw-r--r-- | src/parser.c | 20 | ||||
-rw-r--r-- | src/parser.l | 20 |
2 files changed, 36 insertions, 4 deletions
diff --git a/src/parser.c b/src/parser.c index b9fa3ed..89831fa 100644 --- a/src/parser.c +++ b/src/parser.c @@ -2591,7 +2591,15 @@ static void vt100_parser_handle_ed(VT100Screen *vt, char *buf, size_t len) { int params[VT100_PARSER_CSI_MAX_PARAMS] = { 0 }, nparams; - vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + /* this also gets called by handle_decsed, which will pass it something + * of the form \e[?1J instead of \e[1J */ + buf += 2; + len -= 3; + if (*buf == '?') { + buf++; + len--; + } + vt100_parser_extract_csi_params(buf, len, params, &nparams); switch (params[0]) { case 0: vt100_screen_clear_screen_forward(vt); @@ -2612,7 +2620,15 @@ static void vt100_parser_handle_el(VT100Screen *vt, char *buf, size_t len) { int params[VT100_PARSER_CSI_MAX_PARAMS] = { 0 }, nparams; - vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + /* this also gets called by handle_decsel, which will pass it something + * of the form \e[?1J instead of \e[1J */ + buf += 2; + len -= 3; + if (*buf == '?') { + buf++; + len--; + } + vt100_parser_extract_csi_params(buf, len, params, &nparams); switch (params[0]) { case 0: vt100_screen_kill_line_forward(vt); diff --git a/src/parser.l b/src/parser.l index 4ac44d7..773aa95 100644 --- a/src/parser.l +++ b/src/parser.l @@ -430,7 +430,15 @@ static void vt100_parser_handle_ed(VT100Screen *vt, char *buf, size_t len) { int params[VT100_PARSER_CSI_MAX_PARAMS] = { 0 }, nparams; - vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + /* this also gets called by handle_decsed, which will pass it something + * of the form \e[?1J instead of \e[1J */ + buf += 2; + len -= 3; + if (*buf == '?') { + buf++; + len--; + } + vt100_parser_extract_csi_params(buf, len, params, &nparams); switch (params[0]) { case 0: vt100_screen_clear_screen_forward(vt); @@ -451,7 +459,15 @@ static void vt100_parser_handle_el(VT100Screen *vt, char *buf, size_t len) { int params[VT100_PARSER_CSI_MAX_PARAMS] = { 0 }, nparams; - vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + /* this also gets called by handle_decsel, which will pass it something + * of the form \e[?1J instead of \e[1J */ + buf += 2; + len -= 3; + if (*buf == '?') { + buf++; + len--; + } + vt100_parser_extract_csi_params(buf, len, params, &nparams); switch (params[0]) { case 0: vt100_screen_kill_line_forward(vt); |