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 Cursor Trail Feature to Enhance Cursor Visibility #7970

Merged
merged 13 commits into from
Oct 18, 2024

Conversation

jinhwanlazy
Copy link
Contributor

@jinhwanlazy jinhwanlazy commented Oct 13, 2024

This pull request introduces a new feature that adds a trailing effect behind the cursor as it moves within the terminal window. The cursor trail enhances cursor visibility, making it easier to track cursor movement, especially during rapid navigation or in complex outputs. This feature is particularly beneficial when demonstrating tasks in the terminal, as it allows viewers to easily follow the cursor's movements.

related issue: #2460

video - cursor trail moves smoothly between kitty windows, tmux panes and vim splits.

cursor_trail_demo.mp4

Key Changes

  • New Configuration Option: enable_cursor_trail

    • Type: Boolean (yes or no)
    • Default: no
    • Description: Enables or disables the cursor trail effect. When set to yes, a trailing effect is rendered behind the cursor as it moves, creating a motion trail.
  • New Configuration Option: cursor_trail

    • Type: Positive Integer
    • Default: 0
    • Description: Set this to a value larger than zero to enable a “cursor trail” animation. This is an animation that shows a “trail” following the movement of the text cursor. It makes it easy to follow large cursor jumps and makes for a cool visual effect of the cursor zooming around the screen. The actual value of this option controls when the animation is trigerred. It is a number of milliseconds. The trail animation only follows cursors that have stayed in their position for longer than the specified number of milliseconds. This prevents trails from appearing for cursors that rapidly change their positions during UI updates in complex applications. See :opt:cursor_trail_decay to control the animation speed.
  • New Configuration Option: cursor_trail_decay

    • Type: Tuple of two positive floats
    • Default: 0.1 0.3
    • Description: Controls the decay times for the cursor trail effect when enable_cursor_trail is set to yes. This option accepts two positive float values specifying the fastest and slowest decay times in seconds. The first value corresponds to the fastest decay time (minimum), and the second value corresponds to the slowest decay time (maximum). The second value must be equal to or greater than the first value. Smaller values result in a faster decay of the cursor trail. Adjust these values to control how quickly the cursor trail fades away.

Implementation Details

  • Cursor Trail Concept

    • Instead of animating the cursor itself, this feature introduces the concept of a cursor trail. The trail constantly follows the current active cursor position, creating a visual path that enhances the user's ability to track cursor movement.
    • The existing cursor rendering logic remains mostly untouched, ensuring minimal impact on the current behavior.
  • CursorTrail Data Structure

    • The CursorTrail instance resides within the Tab structure, while the cursor itself is part of the Screen. This design choice allows the trail to represent cursor movements across different windows within a tab.
  • Rendering Logic

    • Added cursor_trail.c to handle the updating and rendering of the cursor trail.
    • Modified child-monitor.c and shader.c to integrate the cursor trail update and rendering into the existing rendering pipeline.
  • Trail Updating Rule

    • Implemented exponential ease-out animation for the trail movement towards the cursor, creating a smooth trailing effect without altering the cursor's own animation settings.
    • The trail only follows cursors that have stayed in their position longer than input_delay, which means it ignores fast-moving cursors. This prevents trails from appearing for cursors that rapidly change positions, such as those used for drawing UI elements in certain applications.
    • In most applications, this behavior works as intended, enhancing visibility without unnecessary trails.
    • Note: In Neovim, during sequential n commands, the trail may jump between the search bar and the search result. This appears to be an issue with Neovim's cursor handling, as running Neovim with nvim -u NONE does not exhibit this behavior.

video - bug in nvim(?)

cursor_trail_demo_vimsearch.mp4
  • Visual Artifacts
    • Cursor and Trail Visibility: Both the cursor and the trail are visible simultaneously. This is a key difference from Neovide's implementation, where the cursor itself is morphing.
    • Underlying Text Visibility: Fonts under the moving trail are not visible while the trail is present.

@kovidgoyal
Copy link
Owner

Fix the CI failures please. WIll review in detail when I have a moment. You can send some trivial PR that I will merge so that this PR does not need me to approve running CI for every change.

@kovidgoyal
Copy link
Owner

Regarding the nvim issue, IIRC nvim uses synchronized updates. I havent looked at your code in detail to se eif it already does this, but it may be possible to work around it by only triggerring the trail based on cursor movements after the synchronized update is over (this is exposed in kitty as screen->paused_rendering

@jinhwanlazy
Copy link
Contributor Author

jinhwanlazy commented Oct 15, 2024

Thanks for the insight. I wasn't aware of the details surrounding synchronized updates and terminal modes, so this has been a great learning opportunity for me!

I tried monitoring the pause state and cursor visibility inside the update_cursor_trail function, like this:

    log_error("DECTCEM: %d", (int)WD.screen->modes.mDECTCEM);
    log_error("Pause_expires_at: %u", (unsigned int)WD.screen->paused_rendering.expires_at);

Here’s what I observed:

  1. During a regular search with /, for every new character input:
[1186.136] DECTCEM: 0
[1186.136] Pause_expires_at: 0
  1. During sequential search with n (the condition causing the issue):
[1400.140] DECTCEM: 1
[1400.140] Pause_expires_at: 0

It seems that Neovim doesn't trigger paused_rendering during searches, instead, it's controlling the visibility of the cursor. I considered using the DECTCEM state to decide whether to follow the cursor, as it seemed logically sensible, though it doesn't solve the issue. However, I encountered another problem: DECTCEM remains off while in Neovim's terminal mode. Since terminal mode is used not only for regular terminal usage but also by many plugins that implement floating windows inside Neovim, I can't rely on this state, as I want the trail to work in terminal mode as well.

  1. neovim terminal mode
[1518.859] DECTCEM: 0
[1518.859] Pause_expires_at: 0

@jinhwanlazy
Copy link
Contributor Author

I still believe this is a Neovim issue. I found that preventing the filetype.lua plugin (one of the default plugins) from loading resolves the problem. It is slowing down searching ui to update somehow. It's strange because this is a filetype plugin, and I wouldn't expect filetypes to have anything to do with searching.

@jinhwanlazy
Copy link
Contributor Author

FYI, the issue does not occur in VIM 9.1

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 15, 2024 via email

@jinhwanlazy
Copy link
Contributor Author

jinhwanlazy commented Oct 15, 2024

In general though, I think you should take synchronized updates into
account. That is cursor movement command received while paused_rendering
is enabled should not trigger trails. This is consistent with the
semantics of synchronized updates which is that nothing on screen should
change while rendering is paused for an update.

The commit I just pushed will do that. Can you suggest an app or a situation that triggers paused_rendering for an example? So that I can see it actually affecting the behavior of the trail.

Report it to neovim then,

I'll try that when I have a moment. Thanks for the insight again!

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 16, 2024 via email

@kovidgoyal kovidgoyal merged commit cbccda8 into kovidgoyal:master Oct 18, 2024
@kovidgoyal
Copy link
Owner

I have merged, so that your work can form the basis of further changes.

I have changed the cursor_trail option to allow specifying the wait time instead of using input_delay.

Some notes, please fix these in a new PR

When cursor=none (i.e. the cursor uses a reverse video effect the
trail color seems to be black). It should be the current cursor color or
perhaps the foreground color instead.

Move the calculation of the trail color into shader.c and pass a
reference to the currently active screen, if any to draw_trail. Use that
to calculate the color, see the pick_cursor_color() function or
alternately store the last rendered cursor color and re-use it.

As far as I can tell, the trail is drawn even when the cursor is hidden
by the application. Is this intentional?

Regarding paused_rendering. Currently as far as I can see, when
rendering is paused the cursor trail is not updated. This is correct,
but also the last cursor move time that you stored on the cursor object
should possibly be updated when rendering is unpaused. Essentially the
semantic should be as if all commands that happen during a paused
rendering all happen at the same instant, when the rendering is
unpaused. You can probably implement this by setting a flag on the
paused rendering object indicating cursor position was updated and if
that flag is set at unpause update the time.

@jinhwanlazy jinhwanlazy deleted the cursor_trail branch October 19, 2024 06:01
@jinhwanlazy
Copy link
Contributor Author

jinhwanlazy commented Oct 19, 2024

Thanks for merging and the great feedback! I'll dive into the points and address them in a new PR soon.

As far as I can tell, the trail is drawn even when the cursor is hidden
by the application. Is this intentional?

When cursor is hidden. The intended behavior of the trail is it still be visible until it reaches the last position where the cursor was visible, then vanishes. I think it feels more natural than it suddenly disappear in the middle of its transition.

Regarding paused_rendering. Currently as far as I can see, when
rendering is paused the cursor trail is not updated. This is correct,
but also the last cursor move time that you stored on the cursor object
should possibly be updated when rendering is unpaused. Essentially the
semantic should be as if all commands that happen during a paused
rendering all happen at the same instant, when the rendering is
unpaused. You can probably implement this by setting a flag on the
paused rendering object indicating cursor position was updated and if
that flag is set at unpause update the time.

Same as above, the idea is that when entering paused_rendering, the trail moves until it reaches the last known position of the cursor, stay there, and resume following once unpaused. So it shouldn't need to track cursor moves during the pause.

Let me know if you want me to rethink these behaviors!

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 19, 2024 via email

@mikesmithgh
Copy link
Contributor

kitty-trail.mp4

awesome work! just a video of me playing around 😂

cursor_trail 3000
cursor_trail_decay 1 2

@kovidgoyal
Copy link
Owner

Oh man now I need to play snake.

@BingCoke
Copy link

Thank you for creating the animation! It's really stunning, but in my view, there's a minor shortcoming that's quite bothersome. When the beam cursor moves over a very short distance, it can cause a trailing shadow, and even feel like it's vibrating, which is a bit dizzying to the eyes. For example, when I'm typing in insert mode in nvim and deleting text (this issue is particularly noticeable at such times).

2024-10-21.22-11-46.mov

@chaozwn
Copy link

chaozwn commented Oct 27, 2024

@BingCoke @chaozwn @benfrain @krbylit New changes are merged. Please try it. 🙏

  1. Added a new option cursor_trail_distance_threshold. The cursor trail will not be initiated when the cursor jump distance is below this threshold.
  2. Trail animation will not be visible within a window where the cursor is hidden (e.g. htop, yazi)

thank you so much. i will try it.

@benfrain
Copy link

@BingCoke @chaozwn @benfrain @krbylit New changes are merged. Please try it. 🙏

  1. Added a new option cursor_trail_distance_threshold. The cursor trail will not be initiated when the cursor jump distance is below this threshold.
  2. Trail animation will not be visible within a window where the cursor is hidden (e.g. htop, yazi)

Above it says that the new config option is enable_cursor_trail yes but that doesn't work on the nightly I just pulled down, I still need to use cursor_trail 3

@jinhwanlazy
Copy link
Contributor Author

Sorry for confusion. The option actually changed after we merged this PR.

I have changed the cursor_trail option to allow specifying the wait time instead of using input_delay.

I fixed the original PR description.

@BingCoke
Copy link

@BingCoke @chaozwn @benfrain @krbylit New changes are merged. Please try it. 🙏

  1. Added a new option cursor_trail_distance_threshold. The cursor trail will not be initiated when the cursor jump distance is below this threshold.
  2. Trail animation will not be visible within a window where the cursor is hidden (e.g. htop, yazi)

aaaaawesome!!! Thank you for your contribution to the animation, the current is incredibly smooth!

@leiserfg
Copy link
Contributor

@jinhwanlazy did you file the issue for neovim?

@WilliamAnimate
Copy link

resizing the terminal seems to trigger the trail

asdf.mp4

@kovidgoyal
Copy link
Owner

That is because the shell redraws the prompt on resize which involves cursor movement.

@jinhwanlazy
Copy link
Contributor Author

@jinhwanlazy did you file the issue for neovim?

@leiserfg Not yet. I tried --dump-commands as kovidgoyal suggested, but I got identical output with and without loading filetype.lua, even though the trail's behavior is different. I'm planning to profile commands with exact timestamps and read some Neovim code over the coming weekend.

@kuro337
Copy link

kuro337 commented Nov 10, 2024

For neovim I see an issue where if the cursor isn't on the first column and I navigate up/down - for some reason the updates are significantly slower

kitty_cursor_s.mov

@jinhwanlazy
Copy link
Contributor Author

For neovim I see an issue where if the cursor isn't on the first column and I navigate up/down - for some reason the updates are significantly slower

kitty_cursor_s.mov

Looks like the trail animation is blocking key input from what I see in the video, but I have no idea why that's happening.

Can you give me more details about your setup so I can try to reproduce this? Machine, OS, desktop environment, and your full kitty config would be helpful.

@kuro337
Copy link

kuro337 commented Nov 10, 2024

Seeing the same thing with zero config nvim and normal nvim, don't think it's related to any config/plugins -

nvim --version
NVIM v0.11.0-dev-996+g395f420fc
Build type: Release
LuaJIT 2.1.1727870382

# nvim build command  
git clone https://github.com/neovim/neovim.git && cd neovim
cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=Release -D ENABLE_WASMTIME=ON 
cmake --build .deps
cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=Release -D ENABLE_WASMTIME=ON
cmake --build build
sudo cmake --install build



kitty --version
kitty 0.37.0 created by Kovid Goyal

kitty.conf

# vim:fileencoding=utf-8:foldmethod=marker
include kitty-theme.conf
listen_on unix:/tmp/mykitty
allow_remote_control yes
editor nvim

#: Performance tuning {{{
repaint_delay 0
input_delay 0
sync_to_monitor no
macos_colorspace displayp3
text_composition_strategy 1.2 20
#: }}}

# shell_integration enabled
shell_integration no-cursor
macos_quit_when_last_window_closed no
macos_show_window_title_in none
macos_option_as_alt yes
cursor_blink_interval 0
initial_window_width 170c
initial_window_height 64c
enable_audio_bell no
strip_trailing_spaces smart
open_url_with default
update_check_interval 24
env LANG=en_US.UTF-8
env XDG_DATA_DIRS=/usr/local/share:/usr/share:/Users/kuro/.nix-profile/share:/nix/var/nix/profiles/default/share
env EDITOR=nvim
env VISUAL=nvim
env LC_CTYPE=UTF-8
confirm_os_window_close 1
map alt+r load_config_file
map alt+h toggle_layout stack
map opt+cmd+, debug_config
mouse_map left click ungrabbed mouse_handle_click prompt
mouse_map ctrl+left click ungrabbed mouse_handle_click link
map cmd+shift+t launch --cwd=current 
map cmd+shift+enter launch --cwd=current
map cmd+shift+w close_window
map cmd+shift+k launch --cwd=current --type=os-window
map cmd+] next_window
map cmd+shift+. move_tab_forward
map cmd+shift+, move_tab_backward
map ctrl+f   toggle_fullscreen
map cmd+shift+equal change_font_size current +1
map cmd+shift+minus change_font_size current -1
map cmd+shift+0 change_font_size current 0
map ctrl+k scroll_line_up
map shift+ctrl+k scroll_page_up
map ctrl+j scroll_line_down
map shift+ctrl+j scroll_page_down
map cmd+s send_text all \x1b:write\ \x0d
map cmd+shift+c copy_to_clipboard
map cmd+c send_text all \x1b[57376u
map cmd+1 next_window
map cmd+p show_first_command_output_on_screen
mouse_hide_wait -1.0 
font_size 18.0
draw_minimal_borders yes
# inactive_text_alpha 0.8
tab_bar_edge bottom
window_border_width 1px
window_margin_width 0
window_padding_width 7
active_tab_background #0f4b6e
inactive_tab_background #1e1f2e
active_tab_foreground   #e5e7eb
inactive_tab_foreground #7f8694
tab_bar_edge bottom
tab_bar_align left
tab_bar_style custom
tab_bar_min_tabs 1
tab_activity_symbol none
bell_on_tab no
tab_separator ""
tab_bar_margin_width 0.0
tab_bar_margin_height 0.0 0.0
tab_title_template "{f'{title[:30]}…' if title.rindex(title[-1]) + 1 > 30 else (title.center(6) if (title.rindex(title[-1]) + 1) % 2 == 0 else title.center(5))}"
active_tab_font_style italic
active_border_color none
inactive_border_color #717171
color0 #1E1E2E 
color15 #FFFFFF 
color16 #FFFF00  

# https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points
# Seti-UI + Custom
symbol_map U+e5fa-U+e6b5                                Symbols Nerd Font
# Devicons
symbol_map U+e700-U+e7c5                                Symbols Nerd Font
# Font Awesome
symbol_map U+ed00-U+f2ff                                Symbols Nerd Font
# Font Awesome Extension
symbol_map U+e200-U+e2a9                                Symbols Nerd Font
# Material Design Icons
symbol_map U+f0001-U+f1af0                              Symbols Nerd Font
# Weather
symbol_map U+e300-U+e3e3                                Symbols Nerd Font
# Octicons
symbol_map U+f400-U+f533,U+2665,U+26A1                  Symbols Nerd Font
# [Powerline Symbols]
symbol_map U+e0a0-U+e0a2,U+e0b0-U+e0b3                  Symbols Nerd Font
# Powerline Extra Symbols
symbol_map U+e0a3,U+e0b4-U+e0c8,U+e0ca,U+e0cc-U+e0d7    Symbols Nerd Font
# IEC Power Symbols
symbol_map U+23fb-U+23fe,U+2b58                         Symbols Nerd Font
# Font Logos (Formerly Font Linux)
symbol_map U+f300-U+f375                                Symbols Nerd Font
# Pomicons
symbol_map U+e000-U+e00a                                Symbols Nerd Font
# Codicons
symbol_map U+ea60-U+ec1e                                Symbols Nerd Font
# Additional sets
symbol_map U+276c-U+2771,U+2500-U+259f                 Symbols Nerd Font

#: }}}
#
# symbol_map U+f300-U+f313,U+e000-U+e00a,U+ea60-U+ebeb,U+e0a0-U+e0c8,U+e0ca,U+e0cc-U+e0d4,U+e200-U+e2a9,U+e300-U+e3e3,U+e5fa-U+e6b1,U+e700-U+e7c5,U+f000-U+f2e0,U+f300-U+f372,U+f400-U+f532,U+f0001-U+f1af0 Symbols Nerd Font Mono
#
#font_family family='SF Pro' 
font_family family='JetBrains Mono' postscript_name=JetBrainsMono-Regular
bold_font auto
italic_font auto
bold_italic_font auto
font_features JetBrainsMono-Regular +calt +zero +cv07
font_features JetBrainsMono-Italic +calt +zero 

cursor_trail 3
cursor_trail_decay 0.2 0.3
cursor_trail_start_threshold 3

arm64 m3 max

      System Version: macOS 15.2 (24C5073e)
      Kernel Version: Darwin 24.2.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 41 minutes, 33 seconds

@jinhwanlazy
Copy link
Contributor Author

@kuro337
I was able to reproduce the issue on my M2 MacBook. Here's the minimal config file that causes the problem:

repaint_delay 0
sync_to_monitor no
cursor_trail 3

Simply setting repaint_delay 1 will fix it for the memoment.
Make sure you completely close the Kitty app and reopen it, rather than applying the config with a shortcut.

@TRPB
Copy link

TRPB commented Nov 25, 2024

@jinhwanlazy thanks so much for this!

Is there any chance of adding an option to hide the cursor during the animation?

ie.

  • Cursor is hidden
  • Animation starts
  • Animation ends
  • Cursor is shown

That way the cursor would animate into position rather than instantly move but have a trail. Since kitty supports hiding the cursor for the blink animation I assume this is possible and fairly trivial to implement?

@jinhwanlazy
Copy link
Contributor Author

jinhwanlazy commented Nov 27, 2024

@TRPB Thanks for the suggestion! I understand that you're looking for a seamless experience similar to what Neovide provides, where the cursor itself appears to morph into position. That’s the essence of Neovide’s "animated cursor," which differs from the "cursor trail" implementation in Kitty.

Unfortunately, it’s not as straightforward as it might seem. Here’s what happens when we simply toggle cursor visibility:

cursor_trail_demo_hide_cursor_while_animation.mov

(Ignore the blinking artifact.)

The real issue is that the trail hides text underneath it, regardless of cursor visibility. This happens because the cursor trail is essentially rendered as a plain opaque quad. I had to use a trick like this to ensure the glyph remains visible on the cursor while the trail is moving:

if (cursor_edge_x[0] <= frag_pos.x && frag_pos.x <= cursor_edge_x[1] &&
cursor_edge_y[1] <= frag_pos.y && frag_pos.y <= cursor_edge_y[0]) {
discard;

It skips rendering on the cursor’s position. It would look even more awkward with this if the cursor is turned off.

I’ve spent some time thinking about how to achieve Neovide’s animated cursor look and feel. @kovidgoyal and @mxple had a great discussion about it even before I started working on this feature. See: #2460 (comment). It helped alot for me to start.

Here are the main options I’ve considered:

  1. Extend cell shaders to support arbitrary shapes. This would require minimal new code and likely have the least performance impact. However, it’s too intrusive for a feature not everyone wants or is willing to maintain.

  2. Redraw foreground text or images on top of the cursor trail. This involves minimal changes to the existing codebase but is fairly complex, and I’m concerned the added complexity could become a maintenance burden.

  3. Use a two-pass rendering approach. This would pass through foreground pixels on top of the cursor trail. While it might be simpler than the other two options, it would significantly hurt performance, making it impractical.

I’ll revisit this if I come up with a better way to implement it.

I looked into the cell shader and realized I might be able to reuse the sprite texture in the trail shader to pass through foreground colors. I’ll try implementing this idea soon.

@TRPB
Copy link

TRPB commented Nov 27, 2024

Thanks for looking into that so quickly! That's definitely a problem and not ideal, you're right, it's not as simple as I'd hoped it might be. Good effort so far!

Looking at neovide (just using it, not the code) it appears that the cursor trail is always below the text. Could you draw the cursor trail on a layer between the background and the text? I don't know how the terminal differentiates the parts but kitty knows to apply transparency to the background. Whether it's even feasible to put another drawn layer in-between the background and the text I have no idea.

Sorry for multiple requests but this is such an awesome feature. One other thing that would be nice is antialiasing on the trail. The lack of it is particularly apparent in your slowed down video. I would hope that it would be just enabling it as part of the shader but what do I know, I suggested hiding/showing the cursor should be "fairly trivial"

@jinhwanlazy
Copy link
Contributor Author

OK, that could be option 4. There are 3 main rendering methods implemented in kitty: one that draws every element (background, cursor, text, image, etc.) in a single draw call, which is supposed to be concise and fast, and the other 2 that draws them one by one, each is triggered when transparency and a background image is involved. I might be able to make kitty to use the latter methods and insert a draw call for cursor_trail between the background and text, specifically here:

kitty/kitty/shaders.c

Lines 898 to 899 in 8e388ac

bind_program(CELL_FG_PROGRAM);

The downside is this would mess with existing rendering logic, which I'm trying to avoid (Same reason as I'm unhappy with option 1). Resulting code would look messy unless some careful refactoring is done. e.g. the function should be renamed from draw_cells_interleaved to something like draw_cells_interleaved_and_trail_if_exist.

@kovidgoyal
Copy link
Owner

draw_cells_interleaved just means the cells are drawn in multiple passes
there is no need to rename it for cursor trail in particular, you just
need to update the logic in draw_cells to choose the correct draw method
and then insert an extra draw call to draw the cursor trail after
drawing the background and special cells.

@TRPB
Copy link

TRPB commented Nov 28, 2024

Looking again I don't think it will actually be quite that simple either, unfortunately. Because the character under the cursor is a different colour to the character before the cursor is over it. You original shader overlay might be better

For example, a white cursor with a white character under it like your video, the semicolon is a different colour before and after the cursor is on it

@jinhwanlazy
Copy link
Contributor Author

@kovidgoyal regarding your recent commit 4b12bff

Branches have an outsize penalty in shaders as does discard. We don't
need the check that the fragment is in the region anyway ans the
rendering pipeline takes care of that for us, I think. At least I can
see no visual difference with it removed.

@jinhwanlazy please review

These videos below are with and without your change.
For me, the difference is clearly visible. The text at the cursor is masked by the trail while it is moving in the version with the commit. I think it would be better to revert this change.

simplescreenrecorder-2024-12-12_10.08.16.mp4
simplescreenrecorder-2024-12-12_10.11.09.mp4

@kovidgoyal
Copy link
Owner

kovidgoyal commented Dec 12, 2024

If you want to restore it then implement it without using if and discard. Instead use step() to set a multiplier that will be zero outside the region and 1 inside and multiple the opacity by that.

@kovidgoyal
Copy link
Owner

And I will note that I cant see any difference in your videos. In both cases during the large horizontal movement text is obscured to the same extent.

I tested it with
kitty -o cursor_trail=3 -o "cursor_trail_decay=1 4"

so that it can be easily followed by eye. And the result are identical with and without the patch.

@kovidgoyal
Copy link
Owner

Ah never mind I think I got it, you mean you dont want the cursor trail drawn over the actual cursor position.

@kovidgoyal
Copy link
Owner

This should take care of it:
4839233

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.