Skip to content

Commit f1482f3

Browse files
WIP
Signed-off-by: Christian Parpart <[email protected]>
1 parent f059320 commit f1482f3

File tree

8 files changed

+205
-151
lines changed

8 files changed

+205
-151
lines changed

cmake/presets/common.json

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
3131
"LIBUNICODE_TABLEGEN_FASTBUILD": "ON"
3232
}
33+
},
34+
{
35+
"name": "gcc-like-debug",
36+
"hidden": true,
37+
"inherits": ["debug"],
38+
"cacheVariables": {
39+
"CMAKE_CXX_FLAGS_DEBUG": "-O0 -ggdb3 -fno-inline-small-functions -ginline-points -fno-omit-frame-pointer"
40+
}
3341
}
3442
]
3543
}

cmake/presets/os-linux.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
{
4646
"name": "linux-debug",
4747
"displayName": "Linux 64-bit",
48-
"inherits": ["linux-common", "debug"]
48+
"inherits": ["linux-common", "gcc-like-debug"]
4949
},
5050
{
5151
"name": "linux-clang-release",
@@ -55,7 +55,7 @@
5555
{
5656
"name": "linux-clang-debug",
5757
"displayName": "Linux 64-bit (Clang)",
58-
"inherits": ["linux-clang", "debug"]
58+
"inherits": ["linux-clang", "gcc-like-debug"]
5959
},
6060
{
6161
"name": "linux-gcc-release",
@@ -65,7 +65,7 @@
6565
{
6666
"name": "linux-gcc-debug",
6767
"displayName": "Linux 64-bit (GCC)",
68-
"inherits": ["linux-gcc", "debug"]
68+
"inherits": ["linux-gcc", "gcc-like-debug"]
6969
}
7070
],
7171
"buildPresets": [

cmake/presets/os-macos.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{
2121
"name": "macos-debug",
2222
"displayName": "MacOS - Debug",
23-
"inherits": ["macos-common", "debug"]
23+
"inherits": ["macos-common", "gcc-like-debug"]
2424
},
2525
{
2626
"name": "macos-release",

src/vtbackend/Line.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ struct TrivialLineInflater
175175
auto lineSegmenter = unicode::grapheme_line_segmenter { *this, input.text.view() };
176176
auto result = lineSegmenter.process(std::numeric_limits<unsigned>::max());
177177
assert(result.stop_condition == unicode::StopCondition::EndOfInput);
178+
auto const flushed = lineSegmenter.flush(std::numeric_limits<unsigned>::max());
179+
assert(flushed.stop_condition == unicode::StopCondition::EndOfInput);
178180
vtParserLog()("Inflated {}/{} columns", columns.size(), input.displayWidth);
179181

180182
// Fill remaining columns

src/vtbackend/Selector_test.cpp

+110-110
Original file line numberDiff line numberDiff line change
@@ -93,74 +93,74 @@ TEST_CASE("Selector.Linear", "[selector]")
9393
REQUIRE(screen.grid().lineText(LineOffset(1)) == "ab,cdefg,hi");
9494
REQUIRE(screen.grid().lineText(LineOffset(2)) == "12345,67890");
9595

96-
SECTION("single-cell")
97-
{ // "b"
98-
auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
99-
auto selector = LinearSelection(selectionHelper, pos, []() {});
100-
(void) selector.extend(pos);
101-
selector.complete();
102-
103-
vector<Selection::Range> const selection = selector.ranges();
104-
REQUIRE(selection.size() == 1);
105-
Selection::Range const& r1 = selection[0];
106-
CHECK(r1.line == pos.line);
107-
CHECK(r1.fromColumn == pos.column);
108-
CHECK(r1.toColumn == pos.column);
109-
CHECK(r1.length() == ColumnCount(1));
110-
111-
auto selectedText = TextSelection { screen };
112-
renderSelection(selector, selectedText);
113-
CHECK(selectedText.text == "b");
114-
}
115-
116-
SECTION("forward single-line")
117-
{ // "b,c"
118-
auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
119-
auto selector = LinearSelection(selectionHelper, pos, []() {});
120-
(void) selector.extend(CellLocation { LineOffset(1), ColumnOffset(3) });
121-
selector.complete();
122-
123-
vector<Selection::Range> const selection = selector.ranges();
124-
REQUIRE(selection.size() == 1);
125-
Selection::Range const& r1 = selection[0];
126-
CHECK(r1.line == LineOffset(1));
127-
CHECK(r1.fromColumn == ColumnOffset(1));
128-
CHECK(r1.toColumn == ColumnOffset(3));
129-
CHECK(r1.length() == ColumnCount(3));
130-
131-
auto selectedText = TextSelection { screen };
132-
renderSelection(selector, selectedText);
133-
CHECK(selectedText.text == "b,c");
134-
}
135-
136-
SECTION("forward multi-line")
137-
{ // "b,cdefg,hi\n1234"
138-
auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
139-
auto selector = LinearSelection(selectionHelper, pos, []() {});
140-
(void) selector.extend(CellLocation { LineOffset(2), ColumnOffset(3) });
141-
selector.complete();
142-
143-
vector<Selection::Range> const selection = selector.ranges();
144-
REQUIRE(selection.size() == 2);
145-
146-
Selection::Range const& r1 = selection[0];
147-
CHECK(r1.line == LineOffset(1));
148-
CHECK(r1.fromColumn == ColumnOffset(1));
149-
CHECK(r1.toColumn == ColumnOffset(10));
150-
CHECK(r1.length() == ColumnCount(10));
151-
152-
Selection::Range const& r2 = selection[1];
153-
CHECK(r2.line == LineOffset(2));
154-
CHECK(r2.fromColumn == ColumnOffset(0));
155-
CHECK(r2.toColumn == ColumnOffset(3));
156-
CHECK(r2.length() == ColumnCount(4));
157-
158-
auto selectedText = TextSelection { screen };
159-
renderSelection(selector, selectedText);
160-
CHECK(selectedText.text == "b,cdefg,hi\n1234");
161-
}
162-
163-
SECTION("multiple lines fully in history")
96+
// SECTION("single-cell")
97+
// { // "b"
98+
// auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
99+
// auto selector = LinearSelection(selectionHelper, pos, []() {});
100+
// (void) selector.extend(pos);
101+
// selector.complete();
102+
//
103+
// vector<Selection::Range> const selection = selector.ranges();
104+
// REQUIRE(selection.size() == 1);
105+
// Selection::Range const& r1 = selection[0];
106+
// CHECK(r1.line == pos.line);
107+
// CHECK(r1.fromColumn == pos.column);
108+
// CHECK(r1.toColumn == pos.column);
109+
// CHECK(r1.length() == ColumnCount(1));
110+
//
111+
// auto selectedText = TextSelection { screen };
112+
// renderSelection(selector, selectedText);
113+
// CHECK(selectedText.text == "b");
114+
// }
115+
116+
// SECTION("forward single-line")
117+
// { // "b,c"
118+
// auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
119+
// auto selector = LinearSelection(selectionHelper, pos, []() {});
120+
// (void) selector.extend(CellLocation { LineOffset(1), ColumnOffset(3) });
121+
// selector.complete();
122+
//
123+
// vector<Selection::Range> const selection = selector.ranges();
124+
// REQUIRE(selection.size() == 1);
125+
// Selection::Range const& r1 = selection[0];
126+
// CHECK(r1.line == LineOffset(1));
127+
// CHECK(r1.fromColumn == ColumnOffset(1));
128+
// CHECK(r1.toColumn == ColumnOffset(3));
129+
// CHECK(r1.length() == ColumnCount(3));
130+
//
131+
// auto selectedText = TextSelection { screen };
132+
// renderSelection(selector, selectedText);
133+
// CHECK(selectedText.text == "b,c");
134+
// }
135+
136+
// SECTION("forward multi-line")
137+
// { // "b,cdefg,hi\n1234"
138+
// auto const pos = CellLocation { LineOffset(1), ColumnOffset(1) };
139+
// auto selector = LinearSelection(selectionHelper, pos, []() {});
140+
// (void) selector.extend(CellLocation { LineOffset(2), ColumnOffset(3) });
141+
// selector.complete();
142+
//
143+
// vector<Selection::Range> const selection = selector.ranges();
144+
// REQUIRE(selection.size() == 2);
145+
//
146+
// Selection::Range const& r1 = selection[0];
147+
// CHECK(r1.line == LineOffset(1));
148+
// CHECK(r1.fromColumn == ColumnOffset(1));
149+
// CHECK(r1.toColumn == ColumnOffset(10));
150+
// CHECK(r1.length() == ColumnCount(10));
151+
//
152+
// Selection::Range const& r2 = selection[1];
153+
// CHECK(r2.line == LineOffset(2));
154+
// CHECK(r2.fromColumn == ColumnOffset(0));
155+
// CHECK(r2.toColumn == ColumnOffset(3));
156+
// CHECK(r2.length() == ColumnCount(4));
157+
//
158+
// auto selectedText = TextSelection { screen };
159+
// renderSelection(selector, selectedText);
160+
// CHECK(selectedText.text == "b,cdefg,hi\n1234");
161+
// }
162+
163+
// SECTION("multiple lines fully in history")
164164
{
165165
term.writeToScreen("foo\r\nbar\r\n"); // move first two lines into history.
166166
/*
@@ -197,48 +197,48 @@ TEST_CASE("Selector.Linear", "[selector]")
197197
CHECK(selectedText.text == "fg,hi\n123");
198198
}
199199

200-
SECTION("multiple lines from history into main buffer")
201-
{
202-
term.writeToScreen("foo\r\nbar\r\n"); // move first two lines into history.
203-
/*
204-
-3 | "12345,67890"
205-
-2 | "ab,cdefg,hi" (--
206-
-1 | "12345,67890" -----------
207-
0 | "foo" --)
208-
1 | "bar"
209-
2 | ""
210-
*/
211-
212-
auto selector =
213-
LinearSelection(selectionHelper, CellLocation { LineOffset(-2), ColumnOffset(8) }, []() {});
214-
(void) selector.extend(CellLocation { LineOffset(0), ColumnOffset(1) });
215-
selector.complete();
216-
217-
vector<Selection::Range> const selection = selector.ranges();
218-
REQUIRE(selection.size() == 3);
219-
220-
Selection::Range const& r1 = selection[0];
221-
CHECK(r1.line == LineOffset(-2));
222-
CHECK(r1.fromColumn == ColumnOffset(8));
223-
CHECK(r1.toColumn == ColumnOffset(10));
224-
CHECK(r1.length() == ColumnCount(3));
225-
226-
Selection::Range const& r2 = selection[1];
227-
CHECK(r2.line == LineOffset(-1));
228-
CHECK(r2.fromColumn == ColumnOffset(0));
229-
CHECK(r2.toColumn == ColumnOffset(10));
230-
CHECK(r2.length() == ColumnCount(11));
231-
232-
Selection::Range const& r3 = selection[2];
233-
CHECK(r3.line == LineOffset(0));
234-
CHECK(r3.fromColumn == ColumnOffset(0));
235-
CHECK(r3.toColumn == ColumnOffset(1));
236-
CHECK(r3.length() == ColumnCount(2));
237-
238-
auto selectedText = TextSelection { screen };
239-
renderSelection(selector, selectedText);
240-
CHECK(selectedText.text == ",hi\n12345,67890\nfo");
241-
}
200+
// SECTION("multiple lines from history into main buffer")
201+
// {
202+
// term.writeToScreen("foo\r\nbar\r\n"); // move first two lines into history.
203+
// /*
204+
// -3 | "12345,67890"
205+
// -2 | "ab,cdefg,hi" (--
206+
// -1 | "12345,67890" -----------
207+
// 0 | "foo" --)
208+
// 1 | "bar"
209+
// 2 | ""
210+
// */
211+
//
212+
// auto selector =
213+
// LinearSelection(selectionHelper, CellLocation { LineOffset(-2), ColumnOffset(8) }, []() {});
214+
// (void) selector.extend(CellLocation { LineOffset(0), ColumnOffset(1) });
215+
// selector.complete();
216+
//
217+
// vector<Selection::Range> const selection = selector.ranges();
218+
// REQUIRE(selection.size() == 3);
219+
//
220+
// Selection::Range const& r1 = selection[0];
221+
// CHECK(r1.line == LineOffset(-2));
222+
// CHECK(r1.fromColumn == ColumnOffset(8));
223+
// CHECK(r1.toColumn == ColumnOffset(10));
224+
// CHECK(r1.length() == ColumnCount(3));
225+
//
226+
// Selection::Range const& r2 = selection[1];
227+
// CHECK(r2.line == LineOffset(-1));
228+
// CHECK(r2.fromColumn == ColumnOffset(0));
229+
// CHECK(r2.toColumn == ColumnOffset(10));
230+
// CHECK(r2.length() == ColumnCount(11));
231+
//
232+
// Selection::Range const& r3 = selection[2];
233+
// CHECK(r3.line == LineOffset(0));
234+
// CHECK(r3.fromColumn == ColumnOffset(0));
235+
// CHECK(r3.toColumn == ColumnOffset(1));
236+
// CHECK(r3.length() == ColumnCount(2));
237+
//
238+
// auto selectedText = TextSelection { screen };
239+
// renderSelection(selector, selectedText);
240+
// CHECK(selectedText.text == ",hi\n12345,67890\nfo");
241+
// }
242242
}
243243

244244
TEST_CASE("Selector.LinearWordWise", "[selector]")

src/vtbackend/Sequencer.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@ void Sequencer::error(std::string_view errorString)
2727

2828
void Sequencer::print(char32_t codepoint)
2929
{
30+
if (vtParserLog)
31+
{
32+
if (codepoint < 0x80 && std::isprint(static_cast<char>(codepoint)))
33+
vtParserLog()("Print: '{}'", static_cast<char>(codepoint));
34+
else
35+
vtParserLog()("Print: U+{:X}", (unsigned) codepoint);
36+
}
3037
_terminal.incrementInstructionCounter();
3138
_terminal.sequenceHandler().writeText(codepoint);
3239
}
3340

3441
size_t Sequencer::print(std::string_view chars, size_t cellCount)
3542
{
43+
if (vtParserLog)
44+
vtParserLog()("Print: ({}) '{}'", cellCount, crispy::escape(chars));
45+
3646
assert(!chars.empty());
3747

3848
_terminal.incrementInstructionCounter(chars.size());
@@ -44,6 +54,9 @@ size_t Sequencer::print(std::string_view chars, size_t cellCount)
4454

4555
void Sequencer::printEnd() noexcept
4656
{
57+
if (vtParserLog)
58+
vtParserLog()("PrintEnd");
59+
4760
_terminal.sequenceHandler().writeTextEnd();
4861
}
4962

0 commit comments

Comments
 (0)