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
|
include <ctype.h>
include "../curses.h"
# PS_WRITE -- Write a string on the physical screen
#
# B.Simon 18-Jan-89 Original
# B.Simon 26-Sep-90 Updated to use screen buffer
procedure ps_write (row, col, ncols, str, att)
int row # i: Starting row
int col # i: Starting column
int ncols # i: Number of columns to write
char str[ARB] # i: String to write
int att # i: Attribute
#--
include "screen.com"
char blank
int colstart, colend, idxstart, idxend, idx
pointer scr
data blank / ' ' /
bool ttygetb()
int strlen()
pointer ps_screen()
begin
# Don't try to print if string is entirely off the screen
if (row < 1 || row > lines || col > cols)
return
# Compute the portion of the string that is on the screen
colstart = max (col, 1)
colend = min (ncols, strlen(str)) + col - 1
colend = min (colend, cols)
if (colend == cols && row == lines) {
if (ttygetb (term, "am"))
colend = colend - 1
}
if (colend < colstart)
return
idxstart = colstart - col + 1
idxend = colend - col + 1
# Move the cursor to the position of the first printed character
call ps_setcur (row, colstart)
# Print the string with the proper attribute
# All non-printing characters are printed as blanks
if (att != A_NORM)
call ps_sendcap ("so", 1)
scr = ps_screen (row, colstart)
do idx = idxstart, idxend {
if (IS_PRINT(str[idx])) {
call putc (ttyout, str[idx])
Memc[scr] = str[idx] + att
} else {
call putc (ttyout, blank)
Memc[scr] = blank + att
}
scr = scr + 1
}
if (att != A_NORM)
call ps_sendcap ("se", 1)
call ps_updcur (row, colend + 1)
end
|