aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2017-06-05 20:47:41 +0200
committerBoris Faure <billiob@gmail.com>2017-06-05 20:47:41 +0200
commit9f72ea3a9dcb69ae47046cdd0d4c6fe156b57c4c (patch)
tree729a2f770691b336634cd8445a8c698c2a759f6f
parenttermptyops: handle right/left margins. Ref T5533 (diff)
downloadterminology-9f72ea3a9dcb69ae47046cdd0d4c6fe156b57c4c.tar.gz
termptyesc: handle DECFRA
-rw-r--r--src/bin/termptyesc.c60
-rw-r--r--src/bin/termptyops.c12
-rw-r--r--src/bin/termptyops.h1
3 files changed, 71 insertions, 2 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 78c2e36..cb2aa21 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -826,6 +826,63 @@ bad:
}
static void
+_handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
+{
+ int c = _csi_arg_get(b);
+
+ int top = _csi_arg_get(b);
+ int left = _csi_arg_get(b);
+ int bottom = _csi_arg_get(b);
+ int right = _csi_arg_get(b);
+ int len;
+
+ DBG("DECFRA (%d; %d;%d;%d;%d) Fill Rectangular Area",
+ c, top, left, bottom, right);
+ if (! ((c >= 32 && c <= 126) || (c >= 160 && c <= 255)))
+ return;
+
+ TERMPTY_RESTRICT_FIELD(top, 1, ty->h);
+ top--;
+ if (ty->termstate.restrict_cursor)
+ top += ty->termstate.top_margin;
+
+ TERMPTY_RESTRICT_FIELD(left, 1, ty->w);
+ left--;
+ if (ty->termstate.restrict_cursor)
+ left += ty->termstate.left_margin;
+
+ if (right < 1)
+ right = ty->w;
+ if (ty->termstate.restrict_cursor)
+ {
+ right += ty->termstate.left_margin;
+ if (ty->termstate.right_margin && right >= ty->termstate.right_margin)
+ right = ty->termstate.right_margin;
+ }
+
+ if (bottom < 1)
+ bottom = ty->h;
+ if (ty->termstate.restrict_cursor)
+ {
+ bottom += ty->termstate.top_margin;
+ if (ty->termstate.bottom_margin && bottom >= ty->termstate.bottom_margin)
+ bottom = ty->termstate.bottom_margin - 1;
+ }
+ bottom--;
+
+ if ((bottom < top) || (right < left))
+ return;
+
+ len = right - left;
+
+ for (; top <= bottom; top++)
+ {
+ Termcell *cells = &(TERMPTY_SCREEN(ty, left, top));
+ termpty_cells_fill(ty, c, cells, len);
+ }
+}
+
+static void
_handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b,
const Eina_Unicode *cc)
{
@@ -990,6 +1047,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
ty->cursor_state.cx = 0;
break;
+ case 'x':
+ _handle_esc_csi_decfra(ty, &b);
+ break;
case 'X': // erase N chars
arg = _csi_arg_get(&b);
TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
diff --git a/src/bin/termptyops.c b/src/bin/termptyops.c
index a3646d5..70e366a 100644
--- a/src/bin/termptyops.c
+++ b/src/bin/termptyops.c
@@ -22,17 +22,25 @@
#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__)
void
-termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
+termpty_cells_fill(Termpty *ty, Eina_Unicode codepoint,
+ Termcell *cells, int count)
{
Termcell src;
memset(&src, 0, sizeof(src));
- src.codepoint = 0;
+ src.codepoint = codepoint;
src.att = ty->termstate.att;
termpty_cell_fill(ty, &src, cells, count);
}
void
+termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
+{
+ termpty_cells_fill(ty, 0, cells, count);
+}
+
+
+void
termpty_text_scroll(Termpty *ty, Eina_Bool clear)
{
Termcell *cells = NULL, *cells2;
diff --git a/src/bin/termptyops.h b/src/bin/termptyops.h
index c2be8f2..177fab0 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -10,6 +10,7 @@ typedef enum _Termpty_Clear
void termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max);
void termpty_cells_copy(Termpty *ty, Termcell *cells, Termcell *dest, int count);
+void termpty_cells_fill(Termpty *ty, Eina_Unicode codepoint, Termcell *cells, int count);
void termpty_cells_clear(Termpty *ty, Termcell *cells, int count);
void termpty_text_scroll(Termpty *ty, Eina_Bool clear);
void termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear);