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

save/load cursor ANSI sequence #112

Open
RiccaDS opened this issue Feb 25, 2023 · 2 comments
Open

save/load cursor ANSI sequence #112

RiccaDS opened this issue Feb 25, 2023 · 2 comments

Comments

@RiccaDS
Copy link

RiccaDS commented Feb 25, 2023

I am programming in Python with outputs on LXTerminals. I am not very used to CLI output. I read that there should exist ANSI escape sequences such as "\033[s" for saving the cursor position and "\033[u" to reload the position. These two don't seem to work and I am testing some other escape sequences but I am having other problems. Is there a reference for supported sequences? or do you know something more about this?

@FinboySlick
Copy link
Contributor

LXTerminal uses VTE so this is what should be parsing your escape sequences. Quick search for documentation on VTE escape sequences hasn't yielded much useful information however.

I have tested the ones you mentioned with bash like this and it seems to work, at least on a per-line basis:

printf "hello\033[s\ngood day\033[unight\n"
hello
good night

As you can see, it prints 'hello', saves the current position (6), then it prints 'good day', restores the position, and when it prints 'night' it overwrites 'day' since 'hello' was 5 characters long.

I do not know if that's the expected behaviour however.

@RiccaDS
Copy link
Author

RiccaDS commented Feb 26, 2023

Yes you are right, it works on a per-line basis. I was working on multiline strings however (omitted this sorry). I am having a hard time ereasing multiline strings and rewriting on them. I seem to be able to use \033[A to jump up one line. However it sometimes seem to have a weird/inconsistent behavior. I don't know if this is due to some error in my code(very possible) or what. I wasn't able to debug however, it was getting too complicated so the save position escape sequence would have proved to be useful. But it doesn't work on multiline however. I don't know, I am now working with curses because I don't seem to be able to win over the CLI too easily unless I find something else. Despite curses has it's own difficulties.

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

No branches or pull requests

2 participants