wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
18.15k stars 810 forks source link

Add option to disable ligatures on current "paragraph" under cursor #4797

Open erratic-pattern opened 10 months ago

erratic-pattern commented 10 months ago

First of all, I just want to say thank you for making a great terminal emulator! I've been on the search for a new terminal emulator for a while now, and wezterm seems to "just work" and checks all the boxes for "must haves". Also having Fira Code with devicons pre-bundled is fantastic as this is exactly the setup I use.

Context

One of the features of Kitty that I really liked was the ability to disable ligatures under the cursor. I had always liked the way ligatures look when reading code but editing them always felt awkward, as they are multiple characters visually represented as a single character. Having this option basically converts me from a non-ligature user into a ligature user.

The lack of this feature isn't a dealbreaker for me however - as it's pretty much non-existent in most terminal emulators as far as I can tell - but it basically means that I will most likely return to not using ligatures. Kitty's lack of good tmux support is a much larger dealbreaker for me, and so I find myself here.

I saw your comment on this closed issue explaining your rationale for not wanting to support this feature. I think you make a lot of great points that I had not considered as someone who knows almost nothing about font shaping or bidirectional text. Since Kitty does not support BIDI/RTL I imagine this is a major reason it can support this kind of conditional ligature option.

Proposal

Is it possible that a line-based or "paragraph"-based solution would simplify the complexities of handling BIDI as well as reduce performance costs associated with recomputing shaping info on the fly? With this approach, all text in the current paragraph (or perhaps line if there is no BIDI paragraph separators) under the cursor would have ligatures disabled. You would only need to recompute shaping upon entering/exiting a paragraph/line

Additionally, adding a delay before recomputing shaping could improve performance, as "smooth scrolling" cursor movements (or the user pressing and holding up/down arrow keys to scroll through lines of text) would potentially incur a lot of useless re-computations if there is no delay.

Closing Thoughts & Contributing

I do not know very much about bidirectional text or font shaping, so I'd appreciate your input here if there are any other ways to make a feature like this performant, simpler to maintain, and BIDI compatible. I'd also be happy to try implementing this feature, as it would be a great way to learn about these things.

wez commented 10 months ago

Thanks for the suggestion; unfortunately it doesn't really solve any of the key reasons why I'm not in favor of this feature; while it potentially solves some of the performance concerns for moving left/right within a single paragraph, it still harms up/down performance and has all of the other drawbacks.