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

Add primitive TUI mode #185

Merged
merged 15 commits into from
Mar 1, 2024
Merged

Add primitive TUI mode #185

merged 15 commits into from
Mar 1, 2024

Conversation

evanrelf
Copy link
Member

@evanrelf evanrelf commented Dec 9, 2023

Shows the same GHCi output and logging as the current print-to-stdout behavior, but renders it as a TUI. This mode is off by default, enabled by passing an undocumented --tui flag.

@github-actions github-actions bot added the patch Bug fixes or non-functional changes label Dec 9, 2023
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/async_buffer_redirect.rs Outdated Show resolved Hide resolved
src/tui/mod.rs Show resolved Hide resolved
src/tui/mod.rs Show resolved Hide resolved
Comment on lines +28 to +29
// TODO(evan): Follow output when scrolled to bottom
scroll_offset: usize,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the user is scrolled to the bottom of the scrollback (the default if they haven't scrolled at all), new output should push old output up and off the screen. Like a "follow logs" option in a CI service.

src/tui/terminal.rs Show resolved Hide resolved
Comment on lines +56 to +68
crossterm::execute!(
stdout,
terminal::EnterAlternateScreen,
cursor::Hide,
event::EnableMouseCapture,
event::EnableFocusChange,
event::EnableBracketedPaste,
event::PushKeyboardEnhancementFlags(
KEF::DISAMBIGUATE_ESCAPE_CODES
| KEF::REPORT_EVENT_TYPES
| KEF::REPORT_ALL_KEYS_AS_ESCAPE_CODES
),
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could remove some of these, like focus change and bracketed paste events - but they don't make a big difference.

The spammy one that does make a dent is mouse events: did you know TUI apps can track mouse movement generally, like hover? So just moving the mouse over a TUI sends dozens of events. But we need mouse events for scrolling.

@evanrelf evanrelf requested a review from 9999years December 9, 2023 01:57
@evanrelf
Copy link
Member Author

Ugh, no, the performance is abysmal because of the stupid gag thing. It's going through a temp file. Of course that's the problem, duh.

@9999years 9999years mentioned this pull request Feb 28, 2024
A couple minor changes to #185 before we merge it.
Copy link
Member

@9999years 9999years left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ship it! Still needs tests (see #202 for my plan) and I have a couple fixups / extra features in #200, but this is good to merge so we can start experimenting.

@9999years 9999years merged commit dac46e0 into main Mar 1, 2024
28 checks passed
@9999years 9999years deleted the evan/tui branch March 1, 2024 00:44
Copy link
Contributor

github-actions bot commented Mar 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Bug fixes or non-functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants