1 /* *********************************************************** 2 * * 3 * Copyright, (C) Honeywell Bull Inc., 1987 * 4 * * 5 * Copyright, (C) Honeywell Information Systems Inc., 1986 * 6 * * 7 *********************************************************** */ 8 9 /* HISTORY COMMENTS: 10 1) change(86-08-26,Lee), approve(87-07-13,MCR7580), audit(87-07-13,Leskiw), 11 install(87-08-07,MR12.1-1072): 12 Created. 13 2) change(86-09-07,Lee), approve(87-07-13,MCR7580), audit(87-07-13,Leskiw), 14 install(87-08-07,MR12.1-1072): 15 Tab handling. 16 END HISTORY COMMENTS */ 17 18 /* : PROCEDURE FUNCTION (em_print_buff) 19 20 Displays the contents of a buffer to the display. Tabs are expanded according 21 to the position of the cursor on the screen. The size of the tabs are 22 determined by the 'em_tab_size' variable. Three print modes exist: 23 24 Printable ASCII only: any non-printable ascii characters. 25 26 Octal non-printables: any non-printable ascii characters are 27 displayed as 3 digit octal values preceeded by a backslash. 28 29 Any character: all characters are displayed with the machine's 30 character set. 31 32 NOTE: the linefeed, tab, backsapce and carriage return characters 33 are not treated as non-printable and are always processed. 34 35 The print mode is determined by the variable em_print_mode. 36 */ 37 38 #include <ctype.h> 39 #include <keydefs.h> 40 #include <emulator.h> 41 42 #if EM_DEBUG /* Do NOT compile if !EM_DEBUG */ 43 44 extern int em_print_mode; 45 extern int em_tab_size; 46 47 em_print_buff(data,datalen) 48 49 char *data; 50 int datalen; 51 { 52 int i; 53 54 for (i = 0; i < datalen; i++) 55 em_putch(data[i]); 56 } 57 58 /* : PROCEDURE FUNCTION (em_putch) 59 60 See above. 61 */ 62 63 em_putch(ch) 64 65 int ch; 66 { 67 int x, y; 68 int i,pad; 69 70 ch &= 0xff; 71 72 /* : filter and process printable control characters */ 73 74 switch (ch) { 75 case CR: 76 case LF: 77 case BS: 78 putch(ch); 79 return; 80 81 case TAB: 82 get_cursor_pos(&x,&y); 83 pad = em_tab_size - (y % em_tab_size); 84 for (i = 0; i < pad; i++) 85 putch(SPACE); 86 return; 87 88 } 89 90 /* : anything that filters through is ASCII data */ 91 92 switch(em_print_mode) { 93 case ASCII_ONLY: 94 if (isprint(ch)) 95 putch(ch); 96 break; 97 98 case NON_ASCII_OCTAL: 99 if (isprint(ch)) 100 putch(ch); 101 else 102 printf("\\%03o",ch); 103 break; 104 105 case ANY_CHAR: 106 putch(ch); 107 break; 108 } 109 } 110 111 #else 112 em_print_buff () 113 {} 114 em_putch () 115 {} 116 #endif 117 ^Z