NetBSD-Bugs archive

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

Re: lib/57867: Why does cbreak or raw affect terminal output differently?



The following reply was made to PR lib/57867; it has been noted by GNATS.

From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: lib/57867: Why does cbreak or raw affect terminal output
 differently?
Date: Wed, 24 Jan 2024 05:00:56 +0300

 On Wed, Jan 24, 2024 at 01:00:04 +0000, RVP wrote:
 
 >  behaviour re: input mode; but, for output, does curses behave
 >  differently between cbreak() and raw()? If yes, what are the
 >  differences in behaviour?
 
 It was not clear from the original question if input was involved,
 presumably yes, so there may be differences.
 
 I can't quite remember all the nuances, so when I need to, I check
 this table from SCO UNIX Development System, User Interface Guide:
 
  Input                                  Characters
 Options                 Interpreted             Uninterpreted
 
 Normal                  interrupt, quit
 'out of ETI             stripping
 state'                  <CR> to <NL>
                         echoing
                         erase, kill
                         EOF
 
 Normal                  echoing (simulated)     All else undefined.
 ETI 'start up
 state'
 
 cbreak()                interrupt, quit         erase, kill
 and echo()              stripping               EOF
                         echoing
 
 cbreak()                interrupt, quit         echoing
 and noecho()            stripping               erase, kill
                                                 EOF
 
 
 nocbreak()              break, quit             echoing
 and noecho()            stripping
                         erase, kill
                         EOF
 
 nocbreak()                      See caution below.
 and echo()
 
 
 nl()                    <CR> to <NL>
 nonl()                                          <CR> to <NL>
 
 raw()                                           break, quit
 (instead of                                     stripping
 cbreak())
 
 Figure 2-1 Input option settings for ETI programs
 
 Every curses program accepting input should set some input options
 because the default settings cannot be guaranteed to be consistent for
 all terminals.  The combination of noecho() and cbreak() is most
 common in interactive screen management programs.  noecho can prevent
 characters from being echoed at the current character position.
 Instead the program might have them echo at the bottom of the screen
 instead.  When noecho() turns off echoing, normal erase and kill
 processing is still on.  The routine cbreak() can cause these
 characters to be uninterpreted.
 
 Do not use the combination of nocbreak() and echo().  If you use it in
 a program and also use getch(), the program will go in and out of
 cbreak() mode to get each character.  Depending on the state of the
 tty driver when each character is typed, the program may produce
 undesirable output.  To prevent the terminal from being set
 incorrectly, routines could be written that contain all the desired
 settings.  Suggestions are provided in the section "Ensuring the
 correct terminal settings" later in this chapter.
 
 -uwe
 


Home | Main Index | Thread Index | Old Index