1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
/* $Id: printer.c,v 1.8 2011/12/06 01:52:06 tom Exp $ */
#include <vttest.h>
#include <esc.h>
static int pex_mode;
static int pff_mode;
static int started;
static int assigned;
static int margin_lo;
static int margin_hi;
static void
setup_printout(MENU_ARGS, int visible, const char *whole)
{
margin_lo = 7;
margin_hi = max_lines - 5;
vt_clear(2);
cup(1, 1);
println(the_title);
println("Test screen for printing. We will set scrolling margins at");
printf("lines %d and %d, and write a test pattern there.\n", margin_lo, margin_hi);
printf("The test pattern should be %s.\n", visible
? "visible"
: "invisible");
printf("The %s should be in the printer's output.\n", whole);
decstbm(margin_lo, margin_hi);
cup(margin_lo, 1);
}
static void
test_printout(void)
{
int row, col;
vt_move(margin_hi, 1);
for (row = 0; row < max_lines; row++) {
printf("%3d:", row);
for (col = 0; col < min_cols - 5; col++) {
printf("%c", ((row + col) % 26) + 'a');
}
printf("\n");
}
}
static void
cleanup_printout(void)
{
decstbm(0, 0);
vt_move(max_lines - 2, 1);
}
static int
tst_Assign(MENU_ARGS)
{
mc_printer_assign(assigned = !assigned);
return MENU_HOLD;
}
static int
tst_DECPEX(MENU_ARGS)
{
decpex(pex_mode = !pex_mode);
return MENU_HOLD;
}
static int
tst_DECPFF(MENU_ARGS)
{
decpff(pff_mode = !pff_mode);
return MENU_HOLD;
}
static int
tst_Start(MENU_ARGS)
{
mc_printer_start(started = !started);
return MENU_HOLD;
}
static int
tst_autoprint(MENU_ARGS)
{
setup_printout(PASS_ARGS, TRUE, "scrolling region");
mc_autoprint(TRUE);
test_printout();
mc_autoprint(FALSE);
cleanup_printout();
return MENU_HOLD;
}
static int
tst_printer_controller(MENU_ARGS)
{
setup_printout(PASS_ARGS, FALSE, "scrolling region");
mc_printer_controller(TRUE);
test_printout();
mc_printer_controller(FALSE);
cleanup_printout();
return MENU_HOLD;
}
static int
tst_print_all_pages(MENU_ARGS)
{
setup_printout(PASS_ARGS, TRUE, "contents of all pages");
test_printout();
mc_print_all_pages();
cleanup_printout();
return MENU_HOLD;
}
static int
tst_print_cursor(MENU_ARGS)
{
int row;
setup_printout(PASS_ARGS, TRUE, "reverse of the scrolling region");
test_printout();
for (row = margin_hi; row >= margin_lo; row--) {
vt_move(row, 1);
mc_print_cursor_line();
}
cleanup_printout();
return MENU_HOLD;
}
static int
tst_print_display(MENU_ARGS)
{
setup_printout(PASS_ARGS, TRUE, "whole display");
test_printout();
mc_print_composed();
cleanup_printout();
return MENU_HOLD;
}
static int
tst_print_page(MENU_ARGS)
{
setup_printout(PASS_ARGS, TRUE,
pex_mode
? "whole page"
: "scrolling region");
test_printout();
mc_print_page();
cleanup_printout();
return MENU_HOLD;
}
int
tst_printing(MENU_ARGS)
{
static char pex_mesg[80];
static char pff_mesg[80];
static char assign_mesg[80];
static char start_mesg[80];
/* *INDENT-OFF* */
static MENU my_menu[] = {
{ "Exit", 0 },
{ assign_mesg, tst_Assign },
{ start_mesg, tst_Start },
{ pex_mesg, tst_DECPEX },
{ pff_mesg, tst_DECPFF },
{ "Test Auto-print mode (MC - DEC private mode)", tst_autoprint },
{ "Test Printer-controller mode (MC)", tst_printer_controller },
{ "Test Print-page (MC)", tst_print_page },
{ "Test Print composed main-display (MC)", tst_print_display },
{ "Test Print all pages (MC)", tst_print_all_pages },
{ "Test Print cursor line (MC)", tst_print_cursor },
{ "", 0 }
};
/* *INDENT-ON* */
do {
sprintf(pex_mesg, "%s Printer-Extent mode (DECPEX)", STR_ENABLE(pex_mode));
sprintf(pff_mesg, "%s Print Form Feed Mode (DECPFF)", STR_ENABLE(pff_mode));
strcpy(assign_mesg, assigned
? "Release printer (MC)"
: "Assign printer to active session (MC)");
sprintf(start_mesg, "%s printer-to-host session (MC)", STR_START(started));
vt_clear(2);
__(title(0), printf("Printing-Control Tests"));
__(title(2), println("Choose test type:"));
} while (menu(my_menu));
if (pex_mode)
decpex(pex_mode = 0);
if (pff_mode)
decpex(pff_mode = 0);
if (assigned)
mc_printer_start(assigned = 0);
if (started)
mc_printer_start(started = 0);
return MENU_NOHOLD;
}
|