Closed glepnir closed 2 years ago
I'm not totally clear on what you're trying to do, but:
DSR
escape sequence (https://en.wikipedia.org/wiki/ANSI_escape_code, search for Device Status Report
) can be used to report the cursor position in most terminalsI'd also like to say that wezterm natively implements panes without the need for tmux, and natively supports sixel, iterm2 and kitty image protocols, so you could just emit the images inline and avoid a lot of this complication if you took tmux out of the stack!
natively supports sixel, iterm2 and kitty image protocols
this not work in neovim builtin vterm .
If you are doing things in wezterm's lua API, you can use pane:get_cursor_position to get the position inside a pane
maken sense .but how can i require wezterm in neovim lua .
If you are doing things in wezterm's lua API, you can use pane:get_cursor_position to get the position inside a pane
maken sense .but how can i require wezterm in neovim lua .
You mention NSCursor... so to answer above you cannot.... That function has nothing to do with the mouse....
First... Are you talking a bout the mouse cursor or the terminal input/blinking cursor? If you are using rust, just use that to query the mouse cursor position, then wezterm can report it's size and coordinates (or query from rust) and do some simple math ??
terminal input cursor
@wez I didn't find a good mac os accessibility lib in rust. Can wezterm provide some rust api? and you can test the built in image tool in neovim vterm. both of them not work
I don't understand exactly what you're trying to do, or in what context your code is running, so I don't know what is the best thing to do here.
@wez hmm sorry for my english .. because of the image preview tool not work in tmux .so I want use a gui window instead of. I know wezterm/kitty support pane window etc. but I used tmux 5 years. it's hard to change the habbit. currently code is simple. I want get the cursor pos. and do some math get the image x y
use std::env;
use fltk::{app, frame::Frame, image::SharedImage, prelude::*, window::Window};
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let pos_x = args[2].parse().unwrap();
let pos_y = args[3].parse().unwrap();
let app = app::App::default().with_scheme(app::Scheme::Gleam);
let mut win = Window::default()
.with_size(400, 400)
.with_pos(pos_x,pos_y);
let mut frame = Frame::default().size_of(&win);
let mut image = SharedImage::load(filename).unwrap();
image.scale(400, 400, true, true);
frame.set_image(Some(image));
win.make_resizable(false);
win.set_border(false);
win.end();
win.show();
app.run().unwrap();
}
In main
, I've extended some of the information available to the wezterm cli list
command; it is visible only when outputting json data:
; wezterm cli list --format json
[
{
"window_id": 0,
"tab_id": 0,
"pane_id": 0,
"workspace": "default",
"size": {
"rows": 24,
"cols": 80,
"pixel_width": 1040,
"pixel_height": 672,
"dpi": 124
},
"title": "wezterm cli list --format json -- wez@foo:~",
"cwd": "file://foo/home/wez/",
"cursor_x": 0,
"cursor_y": 2,
"cursor_shape": "Default",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0
}
]
The new information that I think will be helpful to you is:
pixel_width
and pixel_height
: are the dimensions of given pane, in pixels, independent of any display scaling set by the OSdpi
- the dpi of that pane, useful when considering how the OS might be scaling the displaycursor_x
and cursor_y
: the cell-based coordinates of the cursor within that paneleft_col
: the cell-based offset of the left of the pane, relative to the overall tab positiontop_row
: the cell-based offset of the top of the pane, relative to the overall tab positionThis data is produced by the multiplexer layer of wezterm, and as such, it doesn't have access to information that is specific to the GUI layer (because there may not even be a GUI!), so it is unable to return the window coordinates (which are not actually knowable on Wayland anyway!) or information like the height of a tab bar, window padding, or window client decoration padding that may also be a factor on Windows in certain configurations, or macOS systems with a "notch".
For your use case I would suggest shelling out to wezterm cli list --format json
and then finding the pane whose pane_id
matches the WEZTERM_PANE
environment variable. You should then be able to calculate the position you need, but you may need to hard code padding related offsets to the position to match your system/configuration.
You can use size.pixel_width / size.cols
to get the pixel width of a single cell, and size.pixel_height / size.rows
to get the cell pixel height.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Is your feature request related to a problem? Please describe. Thanks for your work on wezterm. I have a neovim plugin called dashboard-nvim .it can show image in neovim on linux by
ueberzug
. a tool that write in python useX11
to show image. so it can work in tmux. but in macos lots of cli tools can't work in tmux. check the discuss in kitty so I write a gui window that show image useRust
. I want it can work follow neovim window . The way I currently think of is to find the current cursor position to judge? Wezterm doesn't seem to use cacaco to create cursor on macos? NSCursor in appkit cannot be obtained. So I wonder if there is an api in wezterm to get the cursor's position on the screen? Sorry. This may be a reckless request.Describe the solution you'd like N/A
Describe alternatives you've considered N/A
Additional context N/A