fixed misalignment. added print screen.

This commit is contained in:
chombier 2001-06-18 09:12:18 +00:00
parent a06acceb16
commit b951e4c27e
1 changed files with 108 additions and 43 deletions

View File

@ -175,9 +175,9 @@ void printPages(TPPrPort prPort, THPrint PrRecHandle, Str255 Title, short column
OSErr sts; OSErr sts;
long dummyCount; long dummyCount;
char tmp[100]; /* only for debugging */ char tmp[100]; /* only for debugging */
char stupidarray[160]; /* used in menuseg for finding string widths */ char stupidarray[256]; /* used in menuseg for finding string widths */
for (v=0; v<150; v++) stupidarray[v]='W'; /* Set up the width array */ for (v=0; v<256; v++) stupidarray[v]='W'; /* Set up the width array */
indent = ((*PrRecHandle)->prInfo.iHRes * 180)/254; /* 1.8 centimeters left margin */ indent = ((*PrRecHandle)->prInfo.iHRes * 180)/254; /* 1.8 centimeters left margin */
if (-PAPRECT.left > indent) if (-PAPRECT.left > indent)
@ -252,22 +252,36 @@ void printPages(TPPrPort prPort, THPrint PrRecHandle, Str255 Title, short column
lines++; /* one blank line after title line */ lines++; /* one blank line after title line */
} }
if (charh!=NULL) { /* print from handle */ if ( charh != NULL ) { /* print from handle */
while (lines <= maxlines && count<charlen) { while ( lines <= maxlines && count < charlen ) {
scount=0; scount = 0;
while ((count<charlen) && (*charp++!='\r')) { count++; scount++; } while ( count < charlen ) {
MoveTo(indent,lines++*pFheight); if ( scount > columns ) {
if (scount>0) // eat next char if CR
DrawText(start, 0, scount); if (*charp == '\r') {
count++; ++charp;
start=charp; ++count;
}
break;
}
++count;
if ( *charp++ == '\r' ) {
break;
}
++scount;
}
MoveTo( indent, lines++ * pFheight );
if ( scount > 0 ) {
DrawText( start, 0, scount );
}
start = charp;
} }
} else { /* print from file */ } else { /* print from file */
while (lines <= maxlines && count<charlen) { while (lines <= maxlines && count<charlen) {
rdy = 0; rdy = 0;
scount = 0; scount = 0;
while ((count<charlen) && (!rdy)) { while ( count < charlen && !rdy ) {
if (scount > 250) if ( scount > 250 || scount > columns )
nextchar = ascLF; nextchar = ascLF;
switch (nextchar) { switch (nextchar) {
case ascCR: case ascCR:
@ -280,25 +294,27 @@ void printPages(TPPrPort prPort, THPrint PrRecHandle, Str255 Title, short column
rdy=1; rdy=1;
break; break;
default: default:
buf[scount++]=nextchar; buf[scount++] = nextchar;
count++; count++;
dummyCount=1; dummyCount = 1;
if ((sts=FSRead (refNum,&dummyCount,&nextchar)) != noErr) if ((sts = FSRead (refNum,&dummyCount,&nextchar)) != noErr) {
{ sprintf(tmp,"FSRead: ERROR %d",sts); putln(tmp); } sprintf(tmp,"FSRead: ERROR %d",sts);
putln(tmp);
}
break; break;
} }
} }
MoveTo(indent,lines*pFheight); MoveTo(indent, lines * pFheight);
if (scount>0) if (scount > 0)
DrawText(start, 0, scount); DrawText(start, 0, scount);
if (nextchar==ascLF) if ( nextchar == ascLF )
lines++; /* LF -> new line */ lines++; /* LF -> new line */
if (nextchar==ascFF) if ( nextchar == ascFF )
if (screens[theScreen].ignoreff) // RAB BetterTelnet 1.0fc8 if (screens[theScreen].ignoreff) // RAB BetterTelnet 1.0fc8
lines++; lines++;
else else
lines = maxlines+1; /* FF -> new page */ lines = maxlines+1; /* FF -> new page */
dummyCount=1; dummyCount = 1;
if ((sts=FSRead (refNum,&dummyCount,&nextchar)) != noErr) if ((sts=FSRead (refNum,&dummyCount,&nextchar)) != noErr)
{ sprintf(tmp,"FSRead: ERROR %d",sts); putln(tmp); } { sprintf(tmp,"FSRead: ERROR %d",sts); putln(tmp); }
count++; count++;
@ -311,47 +327,77 @@ void printPages(TPPrPort prPort, THPrint PrRecHandle, Str255 Title, short column
HUnlock(charh); HUnlock(charh);
} }
/* printText - Print the text selected on the screen /* printText - Print the text selected on the screen
* vs - which vs to print from */ * vs - which vs to print from */
void printText void printText
( (
short vs, /* Which screen to print */ short vs, /* screen to use for window size */
Handle charh, /* text to display */
Str255 Title, /* The title string */ Str255 Title, /* The title string */
short scrn short scrn /* screen to use for fonts etc... */
) )
{ {
char **charh; /* The character handle */
TPrStatus prStatus; /* Status record */ TPrStatus prStatus; /* Status record */
TPPrPort prPort; /* the Printer port */ TPPrPort prPort; /* the Printer port */
THPrint PrRecHandle; /* our print record handle */ THPrint PrRecHandle; /* our print record handle */
charh = RSGetTextSel(vs,0); /* Get the characters to print */
if ( charh==0L)
return; /* don't print anything.... */
PrRecHandle = PrintSetupRecord(); PrRecHandle = PrintSetupRecord();
setLastCursor(theCursors[normcurs]); setLastCursor(theCursors[normcurs]);
if (PrJobDialog(PrRecHandle)) { /* Cancel the print if FALSE */ if (PrJobDialog(PrRecHandle)) { /* Cancel the print if FALSE */
prPort=PrOpenDoc(PrRecHandle,0L,0L); prPort = PrOpenDoc(PrRecHandle, 0L, 0L);
if (PrError() == 0) { if (PrError() == 0) {
printPages( prPort, PrRecHandle, Title, VSmaxwidth(vs), charh, (short) -1, TRUE,scrn); printPages( prPort, PrRecHandle, Title, VSmaxwidth(vs), charh, (short) -1, TRUE, scrn);
}
PrCloseDoc(prPort);
if (((*PrRecHandle)->prJob.bJDocLoop == bSpoolLoop) && (PrError()==0))
PrPicFile(PrRecHandle,0L,0L,0L,&prStatus); /* Spool the print */
} }
HPurge(charh); /* Kill the printed chars */ if ( prPort ) {
PrCloseDoc(prPort);
if (((*PrRecHandle)->prJob.bJDocLoop == bSpoolLoop) && (PrError()==0))
PrPicFile(PrRecHandle,0L,0L,0L,&prStatus); /* Spool the print */
}
}
updateCursor(1); updateCursor(1);
DisposeHandle((Handle)PrRecHandle); DisposeHandle((Handle)PrRecHandle);
} }
/* printScreen - Print the current screen */
void printScreen
(
short vs, /* Which screen to print */
Str255 Title, /* The title string */
short scrn
)
{
char **charh;
charh = RSGetTextScreen(vs, 0, 0); /* Get the characters to print, including spaces */
if ( charh ) {
printText(vs, charh, Title, scrn);
DisposeHandle(charh);
}
}
/* printText - Print the text selected on the screen
* vs - which vs to print from */
void printSel
(
short vs, /* Which screen to print */
Str255 Title, /* The title string */
short scrn
)
{
char **charh;
charh = RSGetTextSel(vs, 0, 0); /* Get the characters to print, including spaces */
if ( charh ) {
printText(vs, charh, Title, scrn);
DisposeHandle(charh);
}
}
void PrintPageSetup(void) void PrintPageSetup(void)
{ {
THPrint PrRecHandle; /* our print record handle */ THPrint PrRecHandle; /* our print record handle */
@ -377,6 +423,25 @@ void PrintPageSetup(void)
PrClose(); PrClose();
} }
void PrintScreen(void)
{
short i;
PrOpen();
i=RGgetdnum(FrontWindow());
if (i>-1)
printGraph( i); /* Print Graphics */
else
if ( (i=RSfindvwind(FrontWindow())) >-1 ) {
Str255 Title;
GetWTitle( FrontWindow(), Title);
printScreen(i, Title,scrn); /* Print Text selection */
}
PrClose();
}
void PrintSelection(void) void PrintSelection(void)
{ {
short i; short i;
@ -391,7 +456,7 @@ void PrintSelection(void)
Str255 Title; Str255 Title;
GetWTitle( FrontWindow(), Title); GetWTitle( FrontWindow(), Title);
printText(i, Title,scrn); /* Print Text selection */ printSel(i, Title,scrn); /* Print Text selection */
} }
PrClose(); PrClose();
} }