bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: esc seq capture


From: james morris
Subject: Re: esc seq capture
Date: Tue, 2 Jun 2009 12:21:37 +0100 (BST)

On 1/6/2009, "Thomas Dickey" <address@hidden> wrote:
>>>> I've noticed i can do: some_ncurses_prog | tee its_output.txt
>>>>
>>>> what i'd like to do is for my program to captures the escape sequences
>>>> and other output from the ncurses library and output them into a bash
>>>> script interspersed with sleep commands.
>>>>
>>>> is there any way of getting at the escape sequences ncurses outputs to
>>>> the console/terminal to do this?
>>>
>>> The tput program does this.
>>
>> Ideally, when my program does mvwprintw(some_win, "some chars") it then
>> finds the effects (in the form of escape-seqs +any other output sent to
>> the terminal) that function call (or any other ncurses output func) had.
>> failing that, a screen dump (without saving to a file every frame)
>> consisting of escape-seqs+any other ouput??
>
>no - it doesn't do that. curses maintains a copy of the standard window
>stdscr called curscr, uses as a workspace an intermediate window called
>newscr.  (That's true of the SVR4- and X/Open flavors; the BSD flavor
>didn't have newscr).
>
>It updates curscr to match stdscr each time doupdate is called.
>Some of doupdate's functionality is in mvcur (move-cursor).
>
>But doupdate looks for isolated changes, and chooses (from known
>techniques) a least-costly one.  Then it updates that part of the screen,
>and looks for the next change (top-to-bottom, usually).
>
>The escape sequences are written using the library tputs or putp calls.
>You "could" have your own tputs - except that doing that's unreliable.


i don't think i've conveyed so well what i'm thinking about doing...

http://www.jwm-art.net/light.php?p=XorCurses

is a game i've written, it uses ncurses. if you redirect it's output
through the tee program while playing the game you get a large text file
mostly full of escape sequences. you can then display that using the cat
command but 5 minutes of playing xorcurses is over in a flash.

this gave me the idea modifying xorcurses so it can do what tee is doing,
but instead of a text file, it creates a bash script - xorcurses would
insert sleep commands appropriately so when the bash script runs, it
plays back the game at a similar rate.

so i was wondering how I could access the escape sequences (+ printable
chars) that ncurses generates while xorcurses is running so that
xorcurses could then spew it all out into said bash script along with
the sleep commands when refreshes occur?

(i realise using escapes it won't be portable across platforms).

i got thinking however, of the possibility of a more generic
curses-capture program (much like you can record you X desktop) with the
output format of the capture being the bash-scripts as described.
however, the first problem i've thought of is how a separate process
would know when ncurses did a refresh (so it could insert the sleep
command into the script)?

i'm not actually trying to code it right now, i'm just trying to get a
feel for the possibility of such a thing. what might be involved?
different approaches?

in the worst-case i'd have to go through all my code and wherever there
is a ncurses command, add my own to output to the script - translating
into escape sequences (or tputs) from what my program does - rather than
getting the escapes which ncurses has output.

one last idea was a screenshot of an ncurses program which generates it
as html.

james.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]