bug-ncurses
[Top][All Lists]
Advanced

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

printing the screen


From: Peter Jay Salzman
Subject: printing the screen
Date: Wed, 22 Aug 2001 10:39:47 -0700
User-agent: Mutt/1.3.20i

dear all,

i'm trying to implement a print function for one of my ncurses programs.
what i'd like is to simply print the entire screen.

i made two attempts, both listed below.  they both print garbage.

if someone has any suggestions or comments on how to make this work,
i'm definitely all ears.

thank you!!
pete





void print_screen(char (*win3)[INPUT_SZ]) {
   FILE *pipe;
   int row, col, cur_x, cur_y, cur_state, err=0;

        /*        quick and dirty attempt
   scr_dump("/tmp/linux-crypt.screendump");
   system("lpr /tmp/linux-crypt.screendump");
        */

        /* another attempt */

   getsyx(cur_y, cur_x);
   cur_state = curs_set(0);
   fflush(stdout);
   pipe = popen("lpr", "w");
   if (pipe == NULL) {
      err=1;
   } else {
      for (row=0; row < LINES; ++row) {
         for (col=0; col < COLS; ++col) {
            fputc(A_CHARTEXT & mvinch(row,col), pipe);
         }
         fputc('\n', pipe);
      }
      if(pclose(pipe)==-1) err=2;
      setsyx(cur_y, cur_x);
      curs_set(cur_state);
      refresh();
   }
   switch(err) {
      case 0:  pushWin3(win3, "Screen printed?");      break;
      case 1:  pushWin3(win3, "popen() failed.");      break;
      case 2:  pushWin3(win3, "pclose() failed.");     break;
      default: pushWin3(win3, "I shouldn't be here!"); break;
   }

}




reply via email to

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