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

Optionally include cursor in get-text --ansi #3625

Closed
copy opened this issue May 15, 2021 · 1 comment
Closed

Optionally include cursor in get-text --ansi #3625

copy opened this issue May 15, 2021 · 1 comment

Comments

@copy
Copy link
Contributor

copy commented May 15, 2021

Is your feature request related to a problem? Please describe.

I'm working on a tool to display local terminal contents on a website (like gotty, but more secure and optionally broadcasted through a server) by polling get-text --ansi. Here's a work in progress: https://copy.sh/stream-tty/. It works extremely well. The only missing bit is the cursor.

Describe the solution you'd like

I'd like for get-text to include the cursor styling via ansi codes. I don't care if it's enabled by default or if there is a new flag, but other users of get-text might have an opinion.

Describe alternatives you've considered

I've tested an alternative approach of a get-cursor api command. The main issue is latency: Every api call through the socket takes 70ms on my machine. Thus making two api calls (get-text and get-cursor) doubles the latency. Furthermore kitty already knows how to style the cursor and knows about line wrapping.

One downside of this approach is that not all cursor styles are renderable using ansi codes (e.g. blinking or the unfocused cursor shape). That's not an issue for my use-case.

Additional context

Here's a screenshot of kitty and a browser rendering it side-by-side with only the cursor missing on the right:

Screenshot_2021-05-14_21-01-01

@kovidgoyal
Copy link
Owner

First, the latency is just python startup time, write the get-text call in a compiled language via the remote control protocol and you will get just a few ms of latency, see the example and protocol description here, https://sw.kovidgoyal.net/kitty/rc_protocol.html

As for reporting cursor position, it should be a fairly trivial addition. Though if you want it in get-text it will be ANSI only which means you will get just the three cursor shapes (bar, block, underline) not cursor blinking/unfocused data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants