endwin() after using ncurses deletes screen

endwin() after using ncurses deletes screen

Post by Roland Rieg » Fri, 03 Aug 2001 22:17:33



Hi *,

I am writing a ncurses programm and am having the following problem:
After the program has called endwin(), the screen content is cleared and
restored with the content of before the program start.
I would like to have endwin not to clear the screen. How do I do this?

Thank you for any help,
Roland

A main.cpp snippet:

int main(int argc, char *argv[])
{

//[...]

//handle interrrupt signals
signal(SIGINT, finish);
signal(SIGTERM, finish);

//initialize ncurses
WINDOW *window = initscr();

//[...]

//stop ncurses
endwin();

return EXIT_SUCCESS;

Quote:}

void finish(int signal)
{

//stop ncurses
endwin();

exit(0);

Quote:}

 
 
 

endwin() after using ncurses deletes screen

Post by Andrew Giert » Fri, 03 Aug 2001 23:08:12


 Roland> Hi *,

 Roland> I am writing a ncurses programm and am having the following
 Roland> problem: After the program has called endwin(), the screen
 Roland> content is cleared and restored with the content of before
 Roland> the program start.  I would like to have endwin not to clear
 Roland> the screen. How do I do this?

This is a function of the terminal description (termcap/terminfo).
The particular terminal type you're using has a termcap/terminfo entry
that incorporates, in the control sequences that curses uses on startup
and exit, commands to the terminal to switch to an alternate screen.
Some people prefer this, so as not to lose the output of commands, etc.,
when they run a full-screen program.

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
                           or <URL: http://www.whitefang.com/unix/>

 
 
 

endwin() after using ncurses deletes screen

Post by Roland Rieg » Sat, 04 Aug 2001 06:47:56



> This is a function of the terminal description (termcap/terminfo).
> The particular terminal type you're using has a termcap/terminfo entry
> that incorporates, in the control sequences that curses uses on startup
> and exit, commands to the terminal to switch to an alternate screen.
> Some people prefer this, so as not to lose the output of commands, etc.,
> when they run a full-screen program.

Thank you for your answer, Andrew!

One little question remains:
Isn't termcap a little bit outdated? I have heard it is integrated
into ncurses now. I have searched on groups.google.com and many people
say it's obsolete. But others advice people in answers how to use it.

Thanks for any clarification,
Roland

 
 
 

endwin() after using ncurses deletes screen

Post by Casper H.S. Dik - Network Security Engine » Sat, 04 Aug 2001 18:05:57


[[ Reply by email or post, don't do both ]]


>One little question remains:
>Isn't termcap a little bit outdated? I have heard it is integrated
>into ncurses now. I have searched on groups.google.com and many people
>say it's obsolete. But others advice people in answers how to use it.

That sounds very much like a discussion about libtermcap rather
than "termcap/terminfo".  Both SVR4 curses and ncurses integrate the
termcap/terminfo functionality into a single library.

But termcap/terminfo is still a necessary component as it is required
to describe terminal types to curses.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

endwin() after using ncurses deletes screen

Post by Thomas Dicke » Sun, 05 Aug 2001 02:47:08




>  Roland> Hi *,
>  Roland> I am writing a ncurses programm and am having the following
>  Roland> problem: After the program has called endwin(), the screen
>  Roland> content is cleared and restored with the content of before
>  Roland> the program start.  I would like to have endwin not to clear
>  Roland> the screen. How do I do this?
> This is a function of the terminal description (termcap/terminfo).
> The particular terminal type you're using has a termcap/terminfo entry
> that incorporates, in the control sequences that curses uses on startup
> and exit, commands to the terminal to switch to an alternate screen.
> Some people prefer this, so as not to lose the output of commands, etc.,
> when they run a full-screen program.

usually xterm -

        Why doesn't the screen clear when running vi?
        http://dickey.his.com/xterm/xterm.faq.html#xterm_tite

--

http://dickey.his.com
ftp://dickey.his.com

 
 
 

endwin() after using ncurses deletes screen

Post by Roland Riege » Sun, 05 Aug 2001 18:07:25




>>One little question remains:
>>Isn't termcap a little bit outdated? I have heard it is integrated
>>into ncurses now. I have searched on groups.google.com and many people
>>say it's obsolete. But others advice people in answers how to use it.

> That sounds very much like a discussion about libtermcap rather
> than "termcap/terminfo".  Both SVR4 curses and ncurses integrate the
> termcap/terminfo functionality into a single library.

> But termcap/terminfo is still a necessary component as it is required
> to describe terminal types to curses.

> Casper

Thanks Casper for clarifying this!

I just wondered why so many current programms are using these functions if
this technique is consedered obsolete.

Thanks again,
Roland

 
 
 

endwin() after using ncurses deletes screen

Post by Roland Riege » Sun, 05 Aug 2001 18:12:22


[...]

Quote:> usually xterm -

>       Why doesn't the screen clear when running vi?
>       http://dickey.his.com/xterm/xterm.faq.html#xterm_tite

Thanks Thomas for the link.

I will dive into that,
Roland

 
 
 

endwin() after using ncurses deletes screen

Post by Thomas Dicke » Mon, 06 Aug 2001 00:53:33



> I just wondered why so many current programms are using these functions if
> this technique is consedered obsolete.

curses is oriented to full-screen programs (and normally clears the screen on
initialization), while some applications use the same information for things
like command-line editing, not full-screen.  In those cases, there's usually
little incentive to change from termcap to terminfo (though recently someone
pointed out that the legacy interface for tgetent is broken in the latest specs
- HPUX 11.x for instance - making it undesirable to use termcap on those
systems).

--

http://dickey.his.com
ftp://dickey.his.com

 
 
 

endwin() after using ncurses deletes screen

Post by Roland Riege » Mon, 06 Aug 2001 02:20:08




>> I just wondered why so many current programms are using these functions
if
>> this technique is consedered obsolete.

> curses is oriented to full-screen programs (and normally clears the
screen on
> initialization), while some applications use the same information for
things
> like command-line editing, not full-screen.  In those cases, there's
usually
> little incentive to change from termcap to terminfo (though recently
someone
> pointed out that the legacy interface for tgetent is broken in the latest
specs
> - HPUX 11.x for instance - making it undesirable to use termcap on those
> systems).

OK, thank you Thomas!

So it seems it is quite "legal" to use ;-)

I must admit that I am only in the beginning of understanding this whole
ncurses/termcap/terminfo stuff.

I stumbled across ncurses for my first application in C++ as I needed some
control over screen output (nload,
http://www.roland-riegel.de/nload/index_en.html, displays network traffic).
I noticed that after finishing my program in xterm the console was
restored, but not after using it in a non-xterm shell.
Normally this wouldn't bother me at all, but I have included a command line
switch for only displaying the provided information once and immediatly
exiting. But if the screen is cleared after the exit, this has no sense at
all...

Roland

--
SuSE Linux 7.2 (i386)
Registered Linux user #214199 (see http://counter.li.org)

Homepage: http://www.roland-riegel.de

 
 
 

1. terminal I/O after leaving ncurses with endwin()

I am trying to port applications that were running under SCO 3.2 to
linux.  The applications go in and out of curses when interacting with the
user.  Upon leaving curses with and endwin(), the application is unable to
output to the user on stdout, but is able to output on stderr.  When the
program exits, the output that was written to stdout is then displayed on
the terminal.  I have tried to set the terminal attributes after endwin()
with no luck.  I have tried to flush the output with no luck.  I have
included a small sample program the demonstrates this problem. Any help
would be appricated.  Thanx.

OS:   Madrak distrubtion of Linux 6.0.  2.2.9-19mdk kernel
cc:   pgcc 2.91.66 (egcs-1.1.2 release)

#include <curses.h>
#include <stdio.h>
#inlucde <stdlib.h>
#include <termios.h>
#include <unistd.h>

main()
{
    char input[80];
    struct termios stdout_settings;

    tcgetattr(1, &stdout_settings); /* Get terminal settings */
    fprintf (stdout, "starting curses...\n");
    sleep(1);
    initscr();                      /* Start curses */
    clear();
    move(0,0);
    addstr("A string output from curses.. Will wait a few seconds...");
    refresh();
    sleep(3);                       /* Wait for a few */
    endwin();
    tcsetattr(1, TCSANOW, &stdout_settings);   /* failed workaround */
    fprintf (stdout, "stdout: After endwin()..  press return to continue\n");
    fprintf (stderr, "stderr: After endwin()..  press return to continue\n");
    fgets(input, sizeof(input)-1, stdin);
    exit(0);
    /* After exit, the user will see the above stdout message... arghhh! */
Brad

2. modem setup

3. NCURSES: delwin before endwin?

4. Why swap partition not swap file?

5. Informix problems afters Y2K Solaris 2.5 patch

6. How to link with shared libs?

7. callback, ppp, and morning-afters

8. How do I toggle VCs and Xsessions from an Xsession?

9. ncurses: problem with screen update

10. Ncurses: how not to erase screen?

11. Ncurses applications and screen mangling?

12. NCURSES 4.1 - full screen terminal interface library

13. ncurses; SCREEN and WINDOW