summaryrefslogtreecommitdiff
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
parent7ea4b65c8dd3ab2eb5e27f363d29d3fd96d26a7d (diff)
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:
826} 826}
827 827
828static void 828static void
829_handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
830{
831 int c = _csi_arg_get(b);
832
833 int top = _csi_arg_get(b);
834 int left = _csi_arg_get(b);
835 int bottom = _csi_arg_get(b);
836 int right = _csi_arg_get(b);
837 int len;
838
839 DBG("DECFRA (%d; %d;%d;%d;%d) Fill Rectangular Area",
840 c, top, left, bottom, right);
841 if (! ((c >= 32 && c <= 126) || (c >= 160 && c <= 255)))
842 return;
843
844 TERMPTY_RESTRICT_FIELD(top, 1, ty->h);
845 top--;
846 if (ty->termstate.restrict_cursor)
847 top += ty->termstate.top_margin;
848
849 TERMPTY_RESTRICT_FIELD(left, 1, ty->w);
850 left--;
851 if (ty->termstate.restrict_cursor)
852 left += ty->termstate.left_margin;
853
854 if (right < 1)
855 right = ty->w;
856 if (ty->termstate.restrict_cursor)
857 {
858 right += ty->termstate.left_margin;
859 if (ty->termstate.right_margin && right >= ty->termstate.right_margin)
860 right = ty->termstate.right_margin;
861 }
862
863 if (bottom < 1)
864 bottom = ty->h;
865 if (ty->termstate.restrict_cursor)
866 {
867 bottom += ty->termstate.top_margin;
868 if (ty->termstate.bottom_margin && bottom >= ty->termstate.bottom_margin)
869 bottom = ty->termstate.bottom_margin - 1;
870 }
871 bottom--;
872
873 if ((bottom < top) || (right < left))
874 return;
875
876 len = right - left;
877
878 for (; top <= bottom; top++)
879 {
880 Termcell *cells = &(TERMPTY_SCREEN(ty, left, top));
881 termpty_cells_fill(ty, c, cells, len);
882 }
883}
884
885static void
829_handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b, 886_handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b,
830 const Eina_Unicode *cc) 887 const Eina_Unicode *cc)
831{ 888{
@@ -990,6 +1047,9 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
990 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h); 1047 TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
991 ty->cursor_state.cx = 0; 1048 ty->cursor_state.cx = 0;
992 break; 1049 break;
1050 case 'x':
1051 _handle_esc_csi_decfra(ty, &b);
1052 break;
993 case 'X': // erase N chars 1053 case 'X': // erase N chars
994 arg = _csi_arg_get(&b); 1054 arg = _csi_arg_get(&b);
995 TERMPTY_RESTRICT_FIELD(arg, 1, ty->w); 1055 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 @@
22#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__) 22#define DBG(...) EINA_LOG_DOM_DBG(_termpty_log_dom, __VA_ARGS__)
23 23
24void 24void
25termpty_cells_clear(Termpty *ty, Termcell *cells, int count) 25termpty_cells_fill(Termpty *ty, Eina_Unicode codepoint,
26 Termcell *cells, int count)
26{ 27{
27 Termcell src; 28 Termcell src;
28 29
29 memset(&src, 0, sizeof(src)); 30 memset(&src, 0, sizeof(src));
30 src.codepoint = 0; 31 src.codepoint = codepoint;
31 src.att = ty->termstate.att; 32 src.att = ty->termstate.att;
32 termpty_cell_fill(ty, &src, cells, count); 33 termpty_cell_fill(ty, &src, cells, count);
33} 34}
34 35
35void 36void
37termpty_cells_clear(Termpty *ty, Termcell *cells, int count)
38{
39 termpty_cells_fill(ty, 0, cells, count);
40}
41
42
43void
36termpty_text_scroll(Termpty *ty, Eina_Bool clear) 44termpty_text_scroll(Termpty *ty, Eina_Bool clear)
37{ 45{
38 Termcell *cells = NULL, *cells2; 46 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
10 10
11void termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max); 11void termpty_text_save_top(Termpty *ty, Termcell *cells, ssize_t w_max);
12void termpty_cells_copy(Termpty *ty, Termcell *cells, Termcell *dest, int count); 12void termpty_cells_copy(Termpty *ty, Termcell *cells, Termcell *dest, int count);
13void termpty_cells_fill(Termpty *ty, Eina_Unicode codepoint, Termcell *cells, int count);
13void termpty_cells_clear(Termpty *ty, Termcell *cells, int count); 14void termpty_cells_clear(Termpty *ty, Termcell *cells, int count);
14void termpty_text_scroll(Termpty *ty, Eina_Bool clear); 15void termpty_text_scroll(Termpty *ty, Eina_Bool clear);
15void termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear); 16void termpty_text_scroll_rev(Termpty *ty, Eina_Bool clear);