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

[Feature Request] Toggle ligatures in alternate-screen mode apps #5403

Closed
LunarLambda opened this issue May 10, 2024 · 3 comments
Closed

[Feature Request] Toggle ligatures in alternate-screen mode apps #5403

LunarLambda opened this issue May 10, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@LunarLambda
Copy link

Many programming fonts that feature ligatures don't generally look great when applied to typical line-based terminal output like shells, package managers etc. They do however tend to work much better in TUI/ncurses apps like vim, lazygit, mc, etc.

Those apps use a control sequence to enter the "alternate screen" mode, which does not have scrollback. This allows those apps to preserve the previous terminal output on exit. (smcup/rmcup control sequences).

It would be awesome if wezterm was able to toggle font features (or possibly even fonts) when entering/exiting the alternate screen mode, so that I could have e.g. ligatures ON in vim, but ligatures OFF otherwise.

Maybe this is something that can already be implemented in Lua, I'm not sure.

@LunarLambda LunarLambda added the enhancement New feature or request label May 10, 2024
@wez
Copy link
Owner

wez commented May 13, 2024

I'm not going to build this into wezterm.
Look at https://wezfurlong.org/wezterm/config/lua/window/set_config_overrides.html for an example of defining a key assignment that can enable/disable ligatures.

Look at https://wezfurlong.org/wezterm/config/lua/pane/is_alt_screen_active.html for a way to determine is the alt screen is active.

You could combine those and use them in your https://wezfurlong.org/wezterm/config/lua/window-events/update-status.html to get something like the effect you're asking about.

@wez wez closed this as completed May 13, 2024
@LunarLambda
Copy link
Author

Cool, I will take a look. thank you!

@LunarLambda
Copy link
Author

LunarLambda commented May 14, 2024

the following does not appear to work

local w = require 'wezterm'

w.on('update-status', function(window, pane)
    local wo = window:get_config_overrides() or {}

    if pane:is_alt_screen_active() then
        print('on')
        wo.harfbuzz_features = { 'calt=1' }
    else
        print('off')
        wo.harfbuzz_features = { 'calt=0' }
    end

    window:set_config_overrides(wo)
end)

ligatures simply stayu always enabled. font setting is:

    font = w.font_with_fallback {
        {
            family = 'Berkeley Mono',
            harfbuzz_features = { },
        },
        {
            family = 'FiraCode Retina',
            harfbuzz_features = { 'ss03', 'ss05' }
        },
    },

The event does not seem to fire as documented:

13:41:57.465  INFO   logging > lua: off
13:41:57.537  INFO   logging > lua: off
13:41:57.622  INFO   logging > lua: off
13:41:57.715  INFO   logging > lua: off
13:41:57.761  INFO   logging > lua: off
13:41:57.886  INFO   logging > lua: off
13:41:57.925  INFO   logging > lua: off
13:41:58.923  INFO   logging > lua: off
13:41:59.621  INFO   logging > lua: off

is it not intended to run every 1000ms by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants