-
Notifications
You must be signed in to change notification settings - Fork 15
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
Please expose current cursor position and current character attributes #72
Comments
Hi @diggernet, thanks for the suggestions! I'm currently focused on making the library run smoothly with Godot 4, but will consider them.
Data from the terminal comes via the
libtsm has
While this would avoid the awkwardness of using signals, I'm not sure how feasible it would be for
Taking a quick look at libtsm.h, I don't see any methods that would easily expose the attributes, but would certainly prioritize adding support for the |
Yes please on Godot 4. :) Godot-xterm is actually the only reason I am currently using 3.5. I suppose I should mention why your project is so preferable to competitors: Clear separation of Terminal and PTY. I mean, the editor plugin is awesome, but I don't currently need or want a command shell in a project. There all I want is a UI control that is a screen emulator I can send data to. Anyway, back on topic... It would be helpful to also have get_cursor_pos(), but I think I can make do for now until #73 is resolved. Definitely agree there's no pressing need to modify the behavior of write(). Using data_sent should be good enough. Looking at tsm-vte.c, it appears the data of interest is in cattr. But as you say, how to expose it is an open question. |
I walked through tsm-vte.c for DECRQSS to see how much of the flow is present. The gaps seem surprisingly small. The flow from that is approximately:
NOTE 1: There needs to be dsc_len and dsc_arg, similar to osc_len and osc_arg, with their values reset in do_clear(). Or perhaps the OSC vars can simply be reused here. NOTE 2: This is a DCS command, not CSI, but I don't see any reason not to reuse the csi_flags as the code is already set up to do. NOTE 3: ACTION_DCS_START needs to trigger a function that will store the current char (in this case 'q') somewhere. That will be used later to distinguish between DCS commands (u, q, t, Q, p, etc). NOTE 4: ACTION_DCS_COLLECT needs to trigger a do_dcs_collect() similar to do_osc_collect(). Or perhaps the OSC function can simply be reused here. NOTE 5: ACTION_DCS_END needs to trigger a do_dcs() function. For DECRQSS, do_dcs() would check that csi_flags == CSI_CASH and the char stored in NOTE 3 is 'q', in which case it would call a dcs_decrqss() function. That function would check the string stored in NOTE 4 to determine the request. Finally, seeing the 'm' it would build and return an appropriate SGR string representing the data in cattrs, similar to the existing csi_dsr() function. I'm working on a PR for the above. See what you think of it. But I'm not set up to do any testing, so please don't just trust my work. :) |
|
Excellent! Looking forward to the Godot4 release. |
So first I need the ability to read the current cursor position from the terminal.
A couple of ideas for how it could be done:
Both of those would be useful in different ways, but I think either one could do the job.
The other request is a way to read the current character attributes (SGR). That is, the fg/bg/bold/etc values that are in effect and will be used on the next write().
As above, this could be done by:
Of course, the implementation ideas above are just my uninformed thoughts. There's a lot I really don't understand about how this is implemented, so you might easily have a better approach.
The text was updated successfully, but these errors were encountered: