[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] getchar uden echo



In article <sslug@sslug> you wrote:
> Hvordan kan jeg lave en lille "line editor". Hvis jeg anvender getchar  
> (eller fgetc) echo-er  input til output. Samtidig spærrer funktionen for 
> output (fflush hjælper ikke).

Jeg ville nok se på ncurses.

Alternativ så kan du pille med  tcsetattr(),
se også  manual til stty.

jeg har lavet denne funktion:

#ifndef USE_WIN32
static struct termios saved_termios_data;
#endif

void tty_inputmode(int on) {
  /* no line buffering of input => no ICANON !!
     and no echo  */
#ifndef USE_WIN32
  int fd=1;
  if (on) {
    tcsetattr ( fd, TCSAFLUSH, &saved_termios_data );  
    /*tcsetattr ( fd, TCSADRAIN, &saved_termios_data );  */
    /*tcsetattr ( fd, TCSANOW, &saved_termios_data );   */
  } else /* off , restore state from on */ {
    static struct termios termios_data;
    tcgetattr ( fd , &saved_termios_data );
    termios_data= saved_termios_data;
    termios_data.c_lflag &= ~(ECHO | ICANON);
    tcsetattr ( fd, TCSAFLUSH, &termios_data );  
  }
#endif
}

Husk at kalde den med "off==0" når du afslutter!

Allerhelst lave så den også reagerer pænt på diverse interrupts
(HUP osv.), så der afsluttes ordentlig.
Ellers er en manuel "reset" kommando fra konsol/xterm nødvendig bagefter.


-- 
mvh Frank Damgaard  | http://home3.inet.tele.dk/frda/



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *