summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2019-10-27 16:14:28 +0100
committerBoris Faure <billiob@gmail.com>2019-10-27 16:14:28 +0100
commite197c04f65b01fd75f85e6b73135bbda69f4633f (patch)
tree394aaa0b30f9aa3bef3f6eeb1424adb35a5e8966
parent37a8f0b9c1ba2177f3a9885441e151012c711957 (diff)
termiointernals: be able to select tabs + test
-rw-r--r--src/bin/termiointernals.c64
-rw-r--r--tests/tests.results1
2 files changed, 56 insertions, 9 deletions
diff --git a/src/bin/termiointernals.c b/src/bin/termiointernals.c
index bb91705..598c724 100644
--- a/src/bin/termiointernals.c
+++ b/src/bin/termiointernals.c
@@ -46,7 +46,10 @@ termio_selection_get(Termio *sd,
46 SB_ADD("\n", 1); 46 SB_ADD("\n", 1);
47 continue; 47 continue;
48 } 48 }
49 if (w > sd->grid.w) w = sd->grid.w; 49
50 /* Define how much needs to be read on that line */
51 if (w > sd->grid.w)
52 w = sd->grid.w;
50 if (y == c1y && c1x >= w) 53 if (y == c1y && c1x >= w)
51 { 54 {
52 RTRIM(); 55 RTRIM();
@@ -57,14 +60,17 @@ termio_selection_get(Termio *sd,
57 end_x = (c2x >= w) ? w - 1 : c2x; 60 end_x = (c2x >= w) ? w - 1 : c2x;
58 if (c1y != c2y) 61 if (c1y != c2y)
59 { 62 {
60 if (y == c1y) end_x = w - 1; 63 if (y == c1y)
61 else if (y == c2y) start_x = 0; 64 end_x = w - 1;
65 else if (y == c2y)
66 start_x = 0;
62 else 67 else
63 { 68 {
64 start_x = 0; 69 start_x = 0;
65 end_x = w - 1; 70 end_x = w - 1;
66 } 71 }
67 } 72 }
73
68 for (x = start_x; x <= end_x; x++) 74 for (x = start_x; x <= end_x; x++)
69 { 75 {
70 if ((cells[x].codepoint == 0) && (cells[x].att.dblwidth)) 76 if ((cells[x].codepoint == 0) && (cells[x].att.dblwidth))
@@ -76,6 +82,36 @@ termio_selection_get(Termio *sd,
76 } 82 }
77 if (x >= w) 83 if (x >= w)
78 break; 84 break;
85 if (cells[x].att.tab_inserted)
86 {
87 /* There was a tab inserted.
88 * Only output it if there were spaces/empty cells "bellow"
89 */
90 Eina_Bool is_tab = EINA_TRUE;
91 while ((is_tab) && (x < end_x))
92 {
93 if (((cells[x].codepoint == 0) ||
94 (cells[x].att.invisible == 1) ||
95 (cells[x].codepoint == ' ')))
96 {
97 x++;
98 }
99 else
100 {
101 is_tab = EINA_FALSE;
102 }
103 if (cells[x].att.tab_last)
104 {
105 SB_ADD("\t", 1);
106 if (is_tab)
107 {
108 x++;
109 is_tab = EINA_FALSE;
110 }
111 break;
112 }
113 }
114 }
79 if (cells[x].att.newline) 115 if (cells[x].att.newline)
80 { 116 {
81 last0 = -1; 117 last0 = -1;
@@ -88,7 +124,10 @@ termio_selection_get(Termio *sd,
88 } 124 }
89 else if (cells[x].codepoint == 0) 125 else if (cells[x].codepoint == 0)
90 { 126 {
91 if (last0 < 0) last0 = x; 127 /* empty cell, track it to know whether to replace with
128 * spaces */
129 if (last0 < 0)
130 last0 = x;
92 } 131 }
93 else 132 else
94 { 133 {
@@ -121,6 +160,8 @@ termio_selection_get(Termio *sd,
121 } 160 }
122 if (last0 >= 0) 161 if (last0 >= 0)
123 { 162 {
163 /* line stop by empty cell, need to know whether to insert spaces
164 * or just go to next line */
124 if (y == c2y) 165 if (y == c2y)
125 { 166 {
126 Eina_Bool have_more = EINA_FALSE; 167 Eina_Bool have_more = EINA_FALSE;
@@ -130,8 +171,10 @@ termio_selection_get(Termio *sd,
130 if ((cells[x].codepoint == 0) && 171 if ((cells[x].codepoint == 0) &&
131 (cells[x].att.dblwidth)) 172 (cells[x].att.dblwidth))
132 { 173 {
133 if (x < (w - 1)) x++; 174 if (x < (w - 1))
134 else break; 175 x++;
176 else
177 break;
135 } 178 }
136 if (((cells[x].codepoint != 0) && 179 if (((cells[x].codepoint != 0) &&
137 (cells[x].codepoint != ' ')) || 180 (cells[x].codepoint != ' ')) ||
@@ -153,10 +196,13 @@ termio_selection_get(Termio *sd,
153 if ((cells[x].codepoint == 0) && 196 if ((cells[x].codepoint == 0) &&
154 (cells[x].att.dblwidth)) 197 (cells[x].att.dblwidth))
155 { 198 {
156 if (x < (w - 1)) x++; 199 if (x < (w - 1))
157 else break; 200 x++;
201 else
202 break;
158 } 203 }
159 if (x >= w) break; 204 if (x >= w)
205 break;
160 SB_ADD(" ", 1); 206 SB_ADD(" ", 1);
161 } 207 }
162 } 208 }
diff --git a/tests/tests.results b/tests/tests.results
index 7da2572..bbc8190 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -120,3 +120,4 @@ mouse_reporting_mode_all_ext_urxvt.sh a11bbc8ebea42d06cc3ad823b52c09b3
120shift_in_out.sh 3896bcc6887998bbc41b43840a6b2e33 120shift_in_out.sh 3896bcc6887998bbc41b43840a6b2e33
121osc-11-query.sh b762d503e40641ff896dac46391ad7a8 121osc-11-query.sh b762d503e40641ff896dac46391ad7a8
122link_detection.sh bbe87a849586e8b922f26ad5d88146dc 122link_detection.sh bbe87a849586e8b922f26ad5d88146dc
123selection_with_tabs.sh 23557497a8f28ca246048bb2443b3dab