[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printing the screen
From: |
Thomas Dickey |
Subject: |
Re: printing the screen |
Date: |
Wed, 22 Aug 2001 16:59:48 -0400 |
User-agent: |
Mutt/1.2.5i |
On Wed, Aug 22, 2001 at 10:39:47AM -0700, Peter Jay Salzman wrote:
>
> 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.
just reading the code, it looks like it would work - the only thing
I see that might go wrong is if your A_CHARTEXT is setup for the
wide-char config (so that would be 0xffff, not good for a mask to fputc).
> void print_screen(char (*win3)[INPUT_SZ]) {
> FILE *pipe;
> int row, col, cur_x, cur_y, cur_state, err=0;
>
> 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;
> }
>
> }
--
Thomas E. Dickey <address@hidden>
http://dickey.his.com
ftp://dickey.his.com