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

Feature request: Ignore xterm alternate screen #94

Open
iskunk opened this issue Mar 21, 2022 · 0 comments
Open

Feature request: Ignore xterm alternate screen #94

iskunk opened this issue Mar 21, 2022 · 0 comments

Comments

@iskunk
Copy link

iskunk commented Mar 21, 2022

When I record terminal sessions using script(1), on occasion a full-screen ncurses-style dialog will pop up. This results in a big mess in the recorded session, with a large number of escapes for colors, cursor positioning, etc. However, none of that needs to be reflected in the final output, if all you want to see is the normal terminal buffer.

This file is a simple example. It is a terminal session recorded with script(1), in which I invoke a command dpkg-reconfigure tzdata that pops up an ncurses dialog. You can see the mess of escapes in the file, after the command is entered. I even navigated around the dialog a bit, just to make the mess even worse.

However, once I exit the dialog, the terminal looks like this:

root@xubuntu:/tmp# script typescript-dialog.txt 
Script started, output log file is 'typescript-dialog.txt'.
root@xubuntu:/tmp# 
root@xubuntu:/tmp# dpkg-reconfigure tzdata

Current default time zone: 'Etc/UTC'
Local time is now:      Mon Mar 21 17:21:29 UTC 2022.
Universal Time is now:  Mon Mar 21 17:21:29 UTC 2022.

root@xubuntu:/tmp# 
root@xubuntu:/tmp# 
exit
Script done.
root@xubuntu:/tmp# 

The dialog screens are no longer present in the terminal buffer, even if I scroll up. That is because the entire dialog interaction took place in the terminal's "alternative screen buffer," which is separate from the normal buffer. The normal buffer is what I would want to see in the final HTML output.

As documented here, the alternative screen buffer is enabled by ESC[?1049h, and disabled by ESC[?1049l. All that would be needed is to ignore everything between these two escapes.

(This could be made optional, but given that the alternative screen buffer is typically used by full-screen text UIs that aha can't meaningfully handle anyway, I don't think that anyone would want to turn it off.)

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

1 participant