Add plain text printer output

This commit is contained in:
David Schmidt 2011-01-09 17:27:11 +00:00
parent f695a3ace2
commit 357870d575
2 changed files with 22 additions and 2 deletions

View File

@ -248,7 +248,7 @@ Cfg_menu g_cfg_printer_menu[] = {
KNMP(g_printer), CFGTYPE_INT },
{ "Printer DPI,60,60x60 dpi,180,180x180 dpi,360,360x360 dpi",
KNMP(g_printer_dpi), CFGTYPE_INT },
{ "Printer Output Type,bmp,Windows Bitmap,ps,Postscript (B&W),printer,Direct to host printer",
{ "Printer Output Type,bmp,Windows Bitmap,ps,Postscript (B&W),printer,Direct to host printer,text,Text file",
KNMP(g_printer_output), CFGTYPE_STR },
{ "Multipage Files? (PS Only),0,No,1,Yes",
KNMP(g_printer_multipage), CFGTYPE_INT },

View File

@ -49,6 +49,13 @@
static CPrinter* defaultPrinter = NULL;
static FILE *textPrinterFile = NULL;
#ifdef WIN32
const char* const textPrinterFileName = ".\\printer.txt";
#else
const char* const textPrinterFileName = "./printer.txt";
#endif
#define PARAM16(I) (params[I+1]*256+params[I])
#define PIXX ((Bitu)floor(curX*dpi+0.5))
#define PIXY ((Bitu)floor(curY*dpi+0.5))
@ -1262,6 +1269,12 @@ void CPrinter::newPage(bool save, bool resetx)
{
*((Bit8u*)page->pixels+i)=i;
}*/
if (strcasecmp(output, "text") == 0) { /* Text file */
if (textPrinterFile) {
fclose(textPrinterFile);
textPrinterFile = NULL;
}
}
}
void CPrinter::printChar(Bit8u ch)
@ -1273,7 +1286,14 @@ void CPrinter::printChar(Bit8u ch)
if (msb == 0) ch &= 0x7F;
if (msb == 1) ch |= 0x80;
}
if (strcasecmp(output, "text") == 0) {
if (!textPrinterFile) {
textPrinterFile = fopen(textPrinterFileName,"ab");
}
fprintf(textPrinterFile,"%c",ch);
fflush(textPrinterFile);
return;
}
// Are we currently printing a bit graphic?
if (bitGraph.remBytes > 0) {
printBitGraph(ch);