[Top][All Lists]

[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!!

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

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

        /* another attempt */

   getsyx(cur_y, cur_x);
   cur_state = curs_set(0);
   pipe = popen("lpr", "w");
   if (pipe == NULL) {
   } 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);
   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]