0

Please stop marking this question as a duplicate, it's not a duplicate. Thanks. Consider the sequence of a, followed by \x1b[D ("cursor back"), followed by b. This would produce an output of just b.


I am looking to experiment with and create TUI applications (examples: less, vim), e.g. using ncurses style libraries or with raw application of escape sequences.

I've found that as a tmux user, tmux offers a very useful capture-pane feature which could be a good basis for a test framework that can use this as a form of "screenshot" functionality for test verification purposes. For example, rather than manually testing the output for correctness and, say, establishing a test that runs the program under test for a specific window size and then comparing the output with a rigid string compare, I could instead run it under tmux through a wide range of window dimensions and check the rendered state to satisfy requirements in a practical way.

Anyway, the point is that this seems to be the only way I know of to "resolve" a terminal byte stream into a terminal screen buffer. As great and versatile as tmux is, I'm somewhat hoping for a tool that provides this specific capability. Since I read some more today about what ptys are and how they work here, it does seem to me that this aspect of the system is in the purview of the terminal emulator, and something like tmux is rather unique in that it has to do it while not being a GUI application (which is a plus here).

Steven Lu
  • 2,282

1 Answers1

1

Pretty sure tmux is the only game in town because not only can it produce the state of the buffer, it can do it with all of the ANSI colors and styling applied, which is very useful for this testing purpose to validate that it all works properly. Indeed when attaching to an ongoing session, tmux would need to be able to do this internally, it would be silly to have to feed past history through the newly connected terminal session. So I'm just so glad that it's exposed via capture-pane.

Steven Lu
  • 2,282