[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ncurses bugs the output of the program I call
From: |
Grant Edwards |
Subject: |
Re: ncurses bugs the output of the program I call |
Date: |
Sat, 17 Sep 2011 02:13:49 +0000 (UTC) |
User-agent: |
slrn/0.9.9p1 (Linux) |
On 2011-09-16, LucasJA <address@hidden> wrote:
>> So you're collecting the output of ps in your program and then writing
>> it to the screen? It appears that curses doesn't do automatic
>> LF->CR/LF conversion on the strings you write to the screen. Have you
>> tried inserting a CR before each LF when you write the output?
>
> Actually I don't collect the output of ps. I let the called program
> to output on the screen for me, but it is outputting all messed up
> (as above).
That's not going to work (as you found out). Ncurses puts the tty in
to "raw" mode, which disables LF->CR/LF conversion. All Unix programs
that output text-mode stuff to stdout expect the terminal to be in
"cooked" or "canonical" mode so that newlines (LFs) get converted into
CR/LF pairs.
If you want to run programs like 'ps' and show the output in an
ncruses window, you need to use a pipe to collect the output and write
it to the window yourself, doing things like inserting CRs when you
see a LF.
--
Grant