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

screenchar()/screenstring() with multigrid #29135

Open
fredizzimo opened this issue Jun 1, 2024 · 2 comments · May be fixed by #29316
Open

screenchar()/screenstring() with multigrid #29135

fredizzimo opened this issue Jun 1, 2024 · 2 comments · May be fixed by #29316
Labels
bug issues reporting wrong behavior

Comments

@fredizzimo
Copy link
Contributor

Problem

When multigrid is enabled, the screenchar/screenstring functions do not return the correct data. See neovide/neovide#2569 for the original report.

Steps to reproduce

Modify the screenchar_spec.lua test to use multigrid and observe that it's failing.

Expected behavior

Multigrid should not affect the functionality of screenchar.

Neovim version (nvim -v)

NVIM v0.10.0

Vim (not Nvim) behaves the same?

N/A

Operating system/version

Arch Linux

Terminal name/version

Neovide 0.13.1

$TERM environment variable

xterm-256color

Installation

pacman

@bfredl
Copy link
Member

bfredl commented Jun 14, 2024

Multigrid should not affect the functionality of screenchar.

I am afraid this is impossible. The entire point of multigrid is to break the assumptions that positions form a single monospace grid, which is the assumption that screenchar/screenstring relies on. These functions historically always have exited for testing purposes, rather than ordinary use, and we have other ways to test multigrid state (use the RPC api just like in actual use).

Modify the screenchar_spec.lua test to use multigrid and observe that it's failing.

There is no point in ever wanting to do this when multigrid_spec.lua exists.

@fredizzimo
Copy link
Contributor Author

I am afraid this is impossible. The entire point of multigrid is to break the assumptions that positions form a single monospace grid, which is the assumption that screenchar/screenstring relies on.

Would it be possible to make this optional, or even per window like the documentation suggests?

UIs can set the grid size independently of how much space the window occupies on the global layout. So the UI could use a different font size per-window. Or reserve space around the border of the window for its own elements, such as scrollbars from the UI toolkit.

By default, the grid size is handled by Nvim and set to the outer grid size (i.e. the size of the window frame in Nvim) whenever the split is created

Neovide aims to be a drop-in replacement for the terminal mode Neovim, with a few enhanchements like smooth scrolling, simple animations, true transparency, shadows and so on. And for that we need the bullet point below of multigrid, but not necessary the other points

  • UIs receive updates on a separate grid for each window.

We probably want to enable custom and even variable fonts at some point, but that needs special consideration and perhaps new Neovim features, and it should never interfer with the base functionality like window navigation or break plugins. Especially variable fonts need a lot of thought, like how are the lines wrapped, the current protocol only sends the parts it thinks are visible, which makes it almost impossible to implement with the current protocol.

Running the compositor when multigrid is enabled would also allow issues like these to be resolved

These functions historically always have exited for testing purposes, rather than ordinary use, and we have other ways to test multigrid state (use the RPC api just like in actual use).

The API documentation does not specify that it's only for testing, and it's used in the wild by plugins that are broken in Neovide, for example https://github.com/luukvbaal/statuscol.nvim/blob/483b9a596dfd63d541db1aa51ee6ee9a1441c4cc/lua/statuscol.lua#L143.

I'm not a Neovim api expert, but I don't think there's a viable alternative for that functionality currently, and a plugin should not have to care about if multigrid is enabled or not, unless it's specifically written with multigrid in mind.

I think the above plugin might also be broken due to the mouse position issue, which also does not have a viable alternative when you click outside a window, like you need there. A responsive scrollbar also need to be able to track the mouse position globally, so this is not the only use case for it.

Modify the screenchar_spec.lua test to use multigrid and observe that it's failing.
There is no point in ever wanting to do this when multigrid_spec.lua exists.

Yes, you could copy paste the whole content of screenchar_spec.lua into multigrid_spec.lua, but I prefer to avoid code duplication and instead run the same test twice, once without and and once with multigrid to see that there are no regressions between the two, especially since it what's displayed on the screen is irrelevant for those tests.

@justinmk justinmk changed the title Screenchar/screenstring does not work with multigrid screenchar()/screenstring() with multigrid Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants