Synopsis: Printing on your local printer from the MUD. October 96 Date: Sun, 13 Oct 1996 19:27:32 +0100 (MET) From: erwin@pip.dknet.dk To: MERC/Envy Mailing List Subject: Printing from the MUD Here's a little thing I suddenly felt like sharing with the list :) Printing from the MUD. Many terminal programs support a certain ANSI control sequence which will send everything sent to the program to the printer. This can easily be made into a command which lets you print output of any command from the MUD onto your local printer. Very handy, for printing something like list of all mobs in the area, or some long note. The command itself is very simple, but you need to make some changes a few other places: send_to_char(): in Envy/MERC (but not in ROM, there you have to explicitly call page_to_char()), this one automatically pages output. Check there, if ch->pcdata->pagelen is 0, which would mean disable paging (important, as you don't want the pager to kick in when sending text to the printer). If that number is 0, just call write_to_buffer() directly, rather than str_dup the string and put it in showstr_head. While disabling paging, you might want to check how large a text your write_to_buffer() can handle at one time without crashing. Anyway, once you add disabling of paging, the print command could look something like this: /* These to are from pine's print.c */ #define ANSI_BEGIN_PRINT "\e[5i" #define ANSI_FORM_FEED "\f" #define ANSI_STOP_PRINT "\e[4i" void do_print (CHAR_DATA *ch, char *argument) { bool had_color; int old_pagelen; CHAR_DATA *wch; if (IS_NPC(ch) || !ch->desc) return; if (!argument[0]) { send_to_char ("Print what (e.g. PRINT WHO)?\n\r",ch); return; } old_pagelen = ch->pcdata->pagelen; if IS_SET(ch->act, PLR_COLOR) had_color = TRUE; else had_color = FALSE; ch->pcdata->pagelen = 0; /* Disable paging! */ REMOVE_BIT (ch->act, PLR_COLOR); send_to_char (ANSI_BEGIN_PRINT, ch); interpret (ch,argument); /* We need here to make sure that ch still exists, to avoid stupid * users crashing the MUD by typing e.g. PRINT QUIT */ for (wch = char_list; wch; wch = wch->next) if (wch == ch) break; if (!wch) return; if (wch->desc) { send_to_char (ANSI_FORM_FEED, ch); send_to_char (ANSI_STOP_PRINT, ch); } ch->pcdata->pagelen = old_pagelen; if (had_color) SET_BIT (ch->act, PLR_COLOR); send_to_char ("Printed.\n\r",ch); } Start out with saving the state of the color variable (whatever it is called in your setup), the old pagelen, and disable both paging and color. Then send the start-print code, execute the command, send a form free and send the stop-print code. I found the above codes by looking in pine's source code. Here's what my help file looks like: 0 PRINT PRINTING HARDCOPY~ Syntax: print PRINT is used to print the output of a command on your printer. is any command you could use normally. Paging and color are disabled for the duration of that command. The escape code for printing has to be supported by your terminal in order for this to work. The MUD simply sends the escape code [5i to begin printing, and appends to the output a Form Feed and the escape code to end printing, [4i. Not all terminals support this. The documentation from pine 3.91 which uses this feature says: 1. Printer attached to IBM PC or compatible, MacIntosh This may not work with all attached printers, and will depend on the terminal emulation/communications software in use. It is known to work with Kermit and the latest UW version of NCSA telnet on Macs and PCs, Versaterm Pro on Macs, and WRQ Reflections on PCs. Pine and Pico are trademarks of the University of Washington. ~ zMUD does not support this feature, but the author said he'd add it to his list. ============================================================================== Erwin Andreasen Viby J, Denmark Computer Science Student at Aarhus Business erwin@pip.dknet.dk College ==============================================================================