-
-
Notifications
You must be signed in to change notification settings - Fork 6k
[RFC] Floating windows in TUI and Remote UI #6619
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
Conversation
hi, will this PR be merged? or, still wip? |
Is still WIP, many window commands can easily segfault, and the mouse is broken. Also we need a better redrawing strategy than "redraw the float everytime anything else is redrawn". Probabaly should use some buffering logic from #5686 |
Good to know that. I am waiting for it. |
Update: replaced fnew with api command:
mode supports anchor modes (will be relevant for UIs with different grid sizes in floats) as well making the window "unfocusable". It is still possible to make it current with api or number, but the user selecting it "by accident" with mouse or Also added very basic mouse support. |
I'd suggest "new" as the standard verb for creating things. Also in API functions we always spell "window" as
|
|
|
My point was primarily about operation strength, not grammar. Opening/Creating a new window or buffer (or channel) is a lot heavier than adding a new line (we call it [o]pen only because [n] was taken for [n]ext) or highlight, or allocating a new object in "many programming languages". These are all different verbs for a reason. (and if we're discussing common languages, |
Added
|
This PR is awesome, and I have a question about the floating window, I just see the doc what dese |
src/nvim/api/vim.c
Outdated
|
||
Window nvim_open_floating_window(Buffer buffer, | ||
Integer x, Integer y, Integer w, Integer h, | ||
Integer mode, Boolean enter, Error *err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvim_open_floating_win
Here "new" as the verb makes sense to me: |
The buffer list most definitely not an implementation detail: it is well known and used vim functionality that a buffer can be "listed" without actually being "opened". The API functions current operation is only to add/return a number in the buffer list, but "add" might not be the best either, as it can return an existing buffer. However, that is not necessarily the best operation, we could have a function that only creates a new (unnamed) buffer and fully allocates it (this special case might not need to make it temporarily displayed, as there is no swapfile, encoding errors, and probably we want no autocmds either) The current behavior makes sense in the "floating window" case given that it will immediately opened in a window anyway, at which point all the vim stuff happens. |
I have a suggestion: either make Or do the other thing: /// Open floating window
///
/// @param[in] buffer Buffer to display in that window.
/// @param[in] position Window position, pair of two integers which may be
/// negative.
/// @param[in] options Additional options:
/// Option | Type | Description
/// ------ | ---- | -----------
/// anchor | String | Make position be relative to the
/// | | given anchor: "type-pos" where "type"
/// | | is one of "screen", "editor_area",
/// | | "wm_window" and "pos" is one of "NW",
/// | | "NE", "SW" or "SE"; additionally
/// | | "cursor" position is supported.
/// | |
/// | | Defaults to "cursor".
/// | |
/// | | TUI only supports "editor_area-…" and
/// | | "cursor".
/// dimensions | pair of Integers | Dimensions in screen
/// | | cells, width x height.
/// | |
/// | | Defaults to either just
/// | | enough to show the
/// | | whole buffer contents
/// | | (not updated when
/// | | buffer contents
/// | | changes, call
/// | | `nvim_reconfigure_floating_window({dimensions: NIL})`
/// | | then), or just enough
/// | | to occupy all available
/// | | space, whichever is
/// | | lesser.
/// standalone | Boolean | Make window standalone.
/// | |
/// | | Defaults to false, may be
/// | | ignored in TUI.
/// focusable | Boolean | Make window not focusable, and
/// | | also ignore mouse events.
/// | |
/// | | Defaults to false.
/// position_type | String | Position type: either "cells"
/// | | (position in display cells) or
/// | | "pixels".
/// | |
/// | | Defaults to "cells" for
/// | | "editor_area-*" and "cursor"
/// | | anchors, "pixels" otherwise.
Window nvim_open_floating_window(Buffer buffer, ArrayOf(Integer) position,
Dictionary options, Error *const err)
/// Reconfigure floating window
///
/// @param[in] window Window to reconfigure.
/// @param[in] options @see nvim_open_floating_window()
/// Missing values mean “do not change option”, use NIL to
/// force defaults.
void nvim_reconfigure_floating_window(Window window, Dictionary options,
Error *const err) |
It's an irrelevant detail in the context of the API. When one creates a buffer one does not think "I want to add a buffer to the buffer list", only "I want a new buffer". |
Again, the name describes what the function does right now, which was the simplest thing to implement. The relevant change would be to change what the function actually does (fully allocate a buffer), which will be more involved but probably worth it in the long run. |
df20643
to
c702de6
Compare
I think a function for close preview window or close window without focus is needed. I can close the preview window by |
211d9a2
to
3eb676d
Compare
|
69b9ce8
to
71a5378
Compare
Working on the last issues, ci build is aalmost passing now. I plan to merge this today or tomorrow. It is usable enough as a MVP (as demonstrated by plugins adding support already). The API/functionality (and tests with them) can be expanded in follow-up PRs. |
3fcecb2
to
53d6a28
Compare
Co-Author: Dongdong Zhou <dzhou121@gmail.com>
Merged. Sorry for taking so long. I will lock this thread, as dealing with overlong github threads is a mess. Requests for additions/improvements (or bugs too minor to deserve their own issue) can be in #9421. Feel free to repeat stuff that is hidden somewhere in the middle of this thread and still are a concern. |
From the drawer of very naive and crazy stuff (one does not simply mess with window positioning and expect stuff to work). Partially based on @dzhou121 external ui stuff (crazy/naiveness mine)
do this in a script: