Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use VT for COOKED_READ_DATA #17445

Merged
merged 24 commits into from
Jul 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bbbe20f
Move colorbrewer into its own proper header
lhecker Jun 19, 2024
b0cc432
Use VT for COOKED_READ_DATA
lhecker Jun 19, 2024
e08ebbe
Fix GetVirtualViewport, Fix popup alignment
lhecker Jun 20, 2024
88ef5f4
Address feedback
lhecker Jun 20, 2024
413991e
Address feedback, Fix scrolling bug
lhecker Jun 21, 2024
8688a50
Merge remote-tracking branch 'origin/main' into dev/lhecker/14000-vt-…
lhecker Jun 21, 2024
32a1249
Fix several issues with control character visualizers
lhecker Jun 25, 2024
4471e98
Fix ambiguous chars, Improve F7+F9 UX
lhecker Jun 25, 2024
0e63bd0
Merge remote-tracking branch 'origin/main' into dev/lhecker/14000-vt-…
lhecker Jun 25, 2024
8f39b49
Overkill initialData impl, but hopefully not kill
lhecker Jun 25, 2024
b6e4046
Fix break not breaking, Fix column not columning
lhecker Jun 25, 2024
671f371
C++ cast
lhecker Jun 25, 2024
e5b8f5b
Fix cursor position after reflow
lhecker Jul 1, 2024
567260e
Fix prompt boundaries after wrapping
lhecker Jul 1, 2024
4cda975
Fix _viewport size after shrinking
lhecker Jul 1, 2024
398d795
More robust bodgy reflow hacks
lhecker Jul 2, 2024
2fe302c
Merge remote-tracking branch 'origin/main' into dev/lhecker/14000-vt-…
lhecker Jul 9, 2024
a63b806
Address feedback, Add comments, Update formatAttributes
lhecker Jul 9, 2024
8116d5b
Address j4james' feedback from the other PR
lhecker Jul 9, 2024
1f5dc90
Fix buffer invalidation
lhecker Jul 9, 2024
8c7cf58
Oh, right, we support graphemes
lhecker Jul 9, 2024
b3f11d5
Fix formatAttributes
lhecker Jul 9, 2024
08f3bac
Forgot to finish this
lhecker Jul 9, 2024
dc8ac1d
Improve comments, resize_and_overwrite is terrible
lhecker Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address feedback, Fix scrolling bug
lhecker committed Jun 21, 2024
commit 413991e5902ab319de2728ba7157c92905bbfd18
19 changes: 7 additions & 12 deletions doc/COOKED_READ_DATA.md
Original file line number Diff line number Diff line change
@@ -4,12 +4,8 @@

All of the following ✅ marks must be fulfilled during manual testing:
* ASCII input
* Chinese input (中文維基百科) ❔
* Resizing the window properly wraps/unwraps wide glyphs ❌
Broken due to `TextBuffer::Reflow` bugs
* Surrogate pair input (🙂) ❔
* Resizing the window properly wraps/unwraps surrogate pairs ❌
Broken due to `TextBuffer::Reflow` bugs
* Chinese input (中文維基百科) ✅
* Surrogate pair input (🙂) ✅
* In cmd.exe
* Create 2 file: "a😊b.txt" and "a😟b.txt"
* Press tab: Autocomplete to "a😊b.txt" ✅
@@ -62,21 +58,20 @@ All of the following ✅ marks must be fulfilled during manual testing:
* F6 inserts Ctrl+Z ✅
* F7 without modifiers starts "command list" prompt ✅
* Escape dismisses prompt ✅
* Minimum size of 40x10 characters ✅
* Width expands to fit the widest history command ✅
* Entries wider than the window width are truncated ✅
* Height expands up to 20 rows with longer histories ✅
* F9 starts "command number" prompt ✅
* Left/Right paste replace the buffer with the given command ✅
* Left/Right replace the buffer with the given command ✅
* And put cursor at the end of the buffer ✅
* Up/Down navigate selection through history ✅
* Stops at start/end with <10 entries ✅
* Stops at start/end with >20 entries ✅
* Wide text rendering during pagination with >20 entries
* Scrolls through the entries if there are too many
* Shift+Up/Down moves history items around ✅
* Home navigates to first entry ✅
* End navigates to last entry ✅
* PageUp navigates by 20 items at a time or to first ✅
* PageDown navigates by 20 items at a time or to last ✅
* PageUp navigates by $height items at a time or to first ✅
* PageDown navigates by $height items at a time or to last ✅
* Alt+F7 clears command history ✅
* F8 cycles through commands that start with the same text as
the current buffer up until the current cursor position ✅
2 changes: 1 addition & 1 deletion src/host/VtIo.cpp
Original file line number Diff line number Diff line change
@@ -511,7 +511,7 @@ static size_t formatAttributes(char (&buffer)[16], WORD attributes) noexcept
{
// The Console API represents colors in BGR order, but VT represents them in RGB order.
// This LUT transposes them. This is for foreground colors. Add +10 to get the background ones.
static const uint8_t lut[] = { 30, 34, 32, 36, 31, 35, 33, 37, 90, 94, 92, 96, 91, 95, 93, 97 };
static constexpr uint8_t lut[] = { 30, 34, 32, 36, 31, 35, 33, 37, 90, 94, 92, 96, 91, 95, 93, 97 };
fg = lut[attributes & 0xf];
bg = lut[(attributes >> 4) & 0xf] + 10;
}
7 changes: 4 additions & 3 deletions src/host/readDataCooked.cpp
Original file line number Diff line number Diff line change
@@ -777,7 +777,7 @@ void COOKED_READ_DATA::_redisplay()
return;
}

const auto size = _screenInfo.GetBufferSize().Dimensions();
const auto size = _screenInfo.GetVtPageArea().Dimensions();
auto originInViewportFinal = _originInViewport;
til::point cursorPositionFinal;
til::point pagerPromptEnd;
@@ -959,8 +959,9 @@ void COOKED_READ_DATA::_redisplay()
_popupOpened = popupOpened;
}

// Scroll the contents of the pager if needed, so we only need to write what actually changed.
if (const auto delta = pagerContentTop - _pagerContentTop; delta != 0)
// If we have so much text that it doesn't fit into the viewport (origin == {0,0}),
// then we can scroll the existing contents of the pager and only write what got newly uncovered.
if (const auto delta = pagerContentTop - _pagerContentTop; delta != 0 && _originInViewport == til::point{})
{
const auto deltaAbs = abs(delta);
til::CoordType beg = 0;
1 change: 0 additions & 1 deletion src/host/readDataCooked.hpp
Original file line number Diff line number Diff line change
@@ -169,6 +169,5 @@ class COOKED_READ_DATA final : public ReadData
til::CoordType _pagerContentHeight = 0;

std::vector<Popup> _popups;
std::wstring _popupAttr;
bool _popupOpened = false;
};