Skip to content

Conversation

@Yukaii
Copy link
Contributor

@Yukaii Yukaii commented Jun 24, 2025

Make the cursor trail animation work in the Kitty terminal. The Ghostty terminal is also adding support for cursor shaders.

Demo

set-option -add global ui_options terminal_cursor_native=true
2025-06-24.8.39.24.mp4

}
// Check if we should skip drawing the primary cursor (for terminal cursor native mode)
const bool skip_primary_cursor = TerminalUI::has_instance() &&
TerminalUI::instance().is_cursor_native();
Copy link
Owner

Choose a reason for hiding this comment

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

I wonder about this, I dont like highlighters knowing anything about TerminalUI, I think we could just let users override the PrimaryCursor face in their config to default,default to get the same outcome (and keep the door open for more effects based of primary cursor face).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops not fixed. I'll look into other impelmentation later 😂

@Yukaii Yukaii force-pushed the feature/native-cursor branch from 5feef81 to ae47b93 Compare June 26, 2025 09:53
Copy link
Owner

@mawww mawww left a comment

Choose a reason for hiding this comment

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

I think this change can be made much smaller, essentially just reacting inside set_ui_options. We probably can just always emit the right escape sequence in there regardless of if it is redundant or not.

@Yukaii Yukaii force-pushed the feature/native-cursor branch from ae47b93 to ca6a580 Compare June 27, 2025 15:00
@Yukaii Yukaii changed the title feat(terminal): add option for native terminal cursor rendering feat(terminal): support native terminal cursor rendering Jun 27, 2025
@Yukaii
Copy link
Contributor Author

Yukaii commented Jun 27, 2025

Have removed all the unnecessary changes. Thanks for the quick review!

m_padding_fill = find("terminal_padding_fill").map(to_bool).value_or(false);

// Emit cursor show sequence
write(STDOUT_FILENO, "\033[?25h");
Copy link
Owner

Choose a reason for hiding this comment

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

I did not mean to always enable it, I think we still want to have the terminal_native_cursor option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! I've reverted that removal commit.

Copy link
Owner

@mawww mawww left a comment

Choose a reason for hiding this comment

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

Could you remove the comment and update the doc/pages/options.asciidoc file as well to document this new ui_option ?

if (new_cursor_native != m_terminal_cursor_native)
{
m_terminal_cursor_native = new_cursor_native;
// Emit cursor visibility command when the option changes
Copy link
Owner

Choose a reason for hiding this comment

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

that comment does not add much value, it seems to just describe what the code obviously does.


Codepoint m_padding_char = '~';
bool m_padding_fill = false;
bool m_terminal_cursor_native = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

can probably remove the "terminal_" part from the variable name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it 👍🏼

if (new_cursor_native != m_terminal_cursor_native)
{
m_terminal_cursor_native = new_cursor_native;
write(STDOUT_FILENO, m_terminal_cursor_native ? "\033[?25h" : "\033[?25l");
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this means that the PrimaryCursor face will be overridden by the color used by the terminal emulator,
and that cursor shapes (blinking etc) will be visible.

On a related note, I like that Neovim changes the cursor to a vertical line while in insert mode; Maybe Kakoune can achieve this even with its software cursor.

Copy link
Owner

Choose a reason for hiding this comment

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

PrimaryCursor will still be applied, then on top of it the native cursor effect from the terminal, I suspect most users will want to override PrimaryCursor to default,default.

@mawww mawww merged commit bc9dd1a into mawww:master Jun 28, 2025
2 of 6 checks passed
@Yukaii Yukaii deleted the feature/native-cursor branch June 28, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants