billiob pushed a commit to branch master. http://git.enlightenment.org/apps/terminology.git/commit/?id=12cc6aaf420d6aed856cfcad6404a1cb265db76b
commit 12cc6aaf420d6aed856cfcad6404a1cb265db76b Author: Boris Faure <[email protected]> Date: Sun Dec 30 18:36:02 2018 +0100 termptyesc: support DECIC/DECDC + tests --- src/bin/termptyesc.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/bin/termptyops.c | 3 +- tests/decic-decdc.sh | 112 +++++++++++++++++++++++++++++++++++++++++++ tests/tests.results | 1 + 4 files changed, 247 insertions(+), 1 deletion(-) diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index a9dba0b..30b3d6f 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -2077,6 +2077,122 @@ _handle_esc_csi_decsace(Termpty *ty, Eina_Unicode **b) } } +static void +_handle_esc_csi_decic(Termpty *ty, Eina_Unicode **b) +{ + int arg = _csi_arg_get(ty, b); + int old_insert = ty->termstate.insert; + Eina_Unicode blank[1] = { ' ' }; + int top = 0; + int bottom = ty->h; + int old_cx = ty->cursor_state.cx; + int old_cy = ty->cursor_state.cy; + + DBG("DECIC Insert %d Column", arg); + + if (arg == -CSI_ARG_ERROR) + return; + if (arg < 1) + arg = 1; + if (ty->termstate.top_margin > 0) + { + if (ty->cursor_state.cy < ty->termstate.top_margin) + return; + top = ty->termstate.top_margin; + } + if (ty->termstate.bottom_margin != 0) + { + if (ty->cursor_state.cy >= ty->termstate.bottom_margin) + return; + bottom = ty->termstate.bottom_margin; + } + + if (((ty->termstate.left_margin > 0) + && (ty->cursor_state.cx < ty->termstate.left_margin)) + || ((ty->termstate.right_margin > 0) + && (ty->cursor_state.cx >= ty->termstate.right_margin))) + return; + + ty->termstate.insert = 1; + for (; top < bottom; top++) + { + int i; + + /* Insert a left column */ + ty->cursor_state.cy = top; + ty->cursor_state.cx = old_cx; + ty->termstate.wrapnext = 0; + for (i = 0; i < arg; i++) + termpty_text_append(ty, blank, 1); + } + ty->termstate.insert = old_insert; + ty->cursor_state.cx = old_cx; + ty->cursor_state.cy = old_cy; +} + +static void +_handle_esc_csi_decdc(Termpty *ty, Eina_Unicode **b) +{ + int arg = _csi_arg_get(ty, b); + int y = 0; + int max_y = ty->h; + int max_x = ty->w; + int lim; + + DBG("DECDC Delete %d Column", arg); + + if (arg == -CSI_ARG_ERROR) + return; + if (arg < 1) + arg = 1; + if (ty->termstate.top_margin > 0) + { + if (ty->cursor_state.cy < ty->termstate.top_margin) + return; + y = ty->termstate.top_margin; + } + if (ty->termstate.bottom_margin != 0) + { + if (ty->cursor_state.cy >= ty->termstate.bottom_margin) + return; + max_y = ty->termstate.bottom_margin; + } + + if (ty->termstate.right_margin > 0) + { + if (ty->cursor_state.cx >= ty->termstate.right_margin) + return; + max_x = ty->termstate.right_margin; + } + + if (((ty->termstate.left_margin > 0) + && (ty->cursor_state.cx < ty->termstate.left_margin))) + return; + + TERMPTY_RESTRICT_FIELD(arg, 1, max_x + 1); + lim = max_x - arg; + for (; y < max_y; y++) + { + int x; + Termcell *cells = &(TERMPTY_SCREEN(ty, 0, y)); + + for (x = ty->cursor_state.cx; x < max_x; x++) + { + if (x < lim) + TERMPTY_CELL_COPY(ty, &(cells[x + arg]), &(cells[x]), 1); + else + { + cells[x].codepoint = ' '; + if (EINA_UNLIKELY(cells[x].att.link_id)) + term_link_refcount_dec(ty, cells[x].att.link_id, 1); + cells[x].att = ty->termstate.att; + cells[x].att.link_id = 0; + cells[x].att.dblwidth = 0; + } + } + } +} + static int _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) { @@ -2563,10 +2679,26 @@ HVP: _handle_esc_csi_decfra(ty, &b); else if (*(cc-1) == '*') _handle_esc_csi_decsace(ty, &b); + else + ty->decoding_error = EINA_TRUE; break; case 'z': if (*(cc-1) == '$') _handle_esc_csi_decera(ty, &b); + else + ty->decoding_error = EINA_TRUE; + break; + case '}': + if (*(cc-1) == '\'') + _handle_esc_csi_decic(ty, &b); + else + ty->decoding_error = EINA_TRUE; + break; + case '~': + if (*(cc-1) == '\'') + _handle_esc_csi_decdc(ty, &b); + else + ty->decoding_error = EINA_TRUE; break; default: goto unhandled; diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c index 2684e88..63968a9 100644 --- a/src/bin/termptyops.c +++ b/src/bin/termptyops.c @@ -158,7 +158,8 @@ termpty_text_scroll_rev_test(Termpty *ty, Eina_Bool clear) { int b = 0; - if (ty->termstate.top_margin != 0) b = ty->termstate.top_margin; + if (ty->termstate.top_margin != 0) + b = ty->termstate.top_margin; if (ty->cursor_state.cy < b) { termpty_text_scroll_rev(ty, clear); diff --git a/tests/decic-decdc.sh b/tests/decic-decdc.sh new file mode 100755 index 0000000..9c4ddf8 --- /dev/null +++ b/tests/decic-decdc.sh @@ -0,0 +1,112 @@ +#!/bin/sh + +# move to 0; 0 +printf '\033[H' +# fill space +PL=0 +for _ in $(seq 0 23); do + PL=$((PL+1)) + if [ $PL -ge 9 ] ; then + PL=0 + fi + for _ in $(seq 1 $PL); do + printf '#' + done + PR=$((10 - PL)) + for _ in $(seq 0 6); do + printf '\033[0;1m\-' + printf '\033[0;46;1;4m/' + printf '\033[0;46;1;4m|' + printf '\033[0;1;4;7m\\' + printf '\033[0m~' + printf '\033[0;1m_' + printf '\033[0;31;7m>' + printf '\033[0;31;4;7m^' + printf '\033[0;1;7m<' + done + printf '\033[0m' + for _ in $(seq 1 $PR); do + printf '#' + done +done + +# move to 0; 0 +printf '\033[H' + +#set color +printf '\033[43;32;3m' + +# set top/bottom margins: +printf '\033[3;20r' +# allow left/right margins +printf '\033[?69h' +# set left/right margins: +printf '\033[5;75s' + + +# +# INSERT +# + +# move to +printf '\033[2;2H' +# insert column, outside margin, do nothing +printf '\033[\047}' +# move to +printf '\033[2;8H' +# insert column, outside margin, do nothing +printf '\033[\047}' +# move to +printf '\033[5;2H' +# insert column, outside margin, do nothing +printf '\033[\047}' + + +# move to +printf '\033[10;12H' +# insert column +printf '\033[\047}' + +# move to +printf '\033[10;17H' +# insert 0 column (but 1 actually) +printf '\033[0\047}' + +# move to +printf '\033[10;21H' +# insert 3 columns +printf '\033[3\047}' + + +# +# DELETE +# + +# move to +printf '\033[2;78H' +# insert column, outside margin, do nothing +printf '\033[\047~' +# move to +printf '\033[10;78H' +# insert column, outside margin, do nothing +printf '\033[\047~' +# move to +printf '\033[2;60H' +# insert column, outside margin, do nothing +printf '\033[\047~' + +# move to +printf '\033[10;50H' +# delete column +printf '\033[\047~' + +# move to +printf '\033[10;55H' +# delete 0 column (but 1 actually) +printf '\033[0\047~' + +# move to +printf '\033[10;60H' +# delete 3 columns +printf '\033[3\047~' + diff --git a/tests/tests.results b/tests/tests.results index aeff779..a06e713 100644 --- a/tests/tests.results +++ b/tests/tests.results @@ -49,3 +49,4 @@ decrara-rectangular-no-restrict-cursor.sh be9836ff18eafb90795faecc042f34d6 decrara-rectangular-restrict-cursor.sh e98723f8f749e4902f7f4aaa677b85d6 decrara-no-rectangular-no-restrict-cursor.sh c375dd5d6538aff4c920b022f32f4ab0 decrara-no-rectangular-restrict-cursor.sh 815a848844cf7ea33d60e71948346a33 +decic-decdc.sh 6d67999a7c5c771281ff2229cdbdda76 --
