Name | Executed | Routines | % | Executed | Lines | % | Unexecuted |
/home/matt/eu/rds/include/std/graphics.e | 0 | 8 | 0.00% | 6 | 32 | 18.75% | 26 |
Routine | Executed | Lines | Unexecuted | |
bk_color() | 0 | 6 | 0.00% | 6 |
text_color() | 0 | 6 | 0.00% | 6 |
scroll() | 0 | 3 | 0.00% | 3 |
wrap() | 0 | 3 | 0.00% | 3 |
boolean() | 0 | 2 | 0.00% | 2 |
get_position() | 0 | 2 | 0.00% | 2 |
graphics_mode() | 0 | 2 | 0.00% | 2 |
mode() | 0 | 2 | 0.00% | 2 |
# | Executed | |
1 | -- (c) Copyright - See License.txt | |
2 | -- | |
3 | --**** | |
4 | -- == Graphics - Cross Platform | |
5 | -- | |
6 | -- < | |
7 | -- | |
8 | namespace graphics | |
9 | ||
10 | constant | |
11 | 1 | M_GRAPHICS_MODE = 5, |
12 | 1 | M_WRAP = 7, |
13 | 1 | M_SCROLL = 8, |
14 | 1 | M_SET_T_COLOR = 9, |
15 | 1 | M_SET_B_COLOR = 10, |
16 | 1 | M_GET_POSITION = 25 |
17 | ||
18 | public include std/console.e | |
19 | ||
20 | --**** | |
21 | -- === Routines | |
22 | -- | |
23 | ||
24 | --**** | |
25 | -- Signature: | |
26 | -- | |
27 | -- | |
28 | -- Parameters: | |
29 | -- # ##row## : an integer, the index of the row to position the cursor on. | |
30 | -- # ##column## : an integer, the index of the column to position the cursor on. | |
31 | -- | |
32 | -- Description: | |
33 | -- Set the cursor to line ##row##, column ##column##, where the top left corner of the screen is line 1, | |
34 | -- column 1. The next character displayed on the screen will be printed at this location. | |
35 | -- ##position##() will report an error if the location is off the screen. | |
36 | -- The //Windows// console does not check for rows, as the physical height of the | |
37 | -- console may be vastly less than its logical height. | |
38 | -- | |
39 | -- Example 1: | |
40 | -- | |
41 | -- position(2,1) | |
42 | -- -- the cursor moves to the beginning of the second line from the top | |
43 | -- | |
44 | -- See Also: | |
45 | -- [[:get_position]] | |
46 | ||
47 | --** | |
48 | -- Return the current line and column position of the cursor | |
49 | -- | |
50 | -- Returns: | |
51 | -- A **sequence**, ##{line, column}##, the current position of the text mode cursor. | |
52 | -- | |
53 | -- Comments: | |
54 | -- The coordinate system for displaying text is different from the one for displaying pixels. | |
55 | -- Pixels are displayed such that the top-left is (x=0,y=0) and the first coordinate controls | |
56 | -- the horizontal, left-right location. In pixel-graphics modes you can display both text and | |
57 | -- pixels. ##get_position##() returns the current line and column for the text that you are | |
58 | -- displaying, not the pixels that you may be plotting. There is no corresponding routine for | |
59 | -- getting the current pixel position, because there is not such a thing. | |
60 | -- | |
61 | -- See Also: | |
62 | -- [[:position]] | |
63 | ||
64 | 0 | |
65 | 0 | return machine_func(M_GET_POSITION, 0) |
66 | end function | |
67 | ||
68 | public include std/graphcst.e | |
69 | ||
70 | --** | |
71 | -- Set the foreground text color. | |
72 | -- | |
73 | -- Parameters: | |
74 | -- # ##c## : the new text color. Add ##BLINKING## to get blinking text in some modes. | |
75 | -- | |
76 | -- Comments: | |
77 | -- Text that you print after calling ##[[:text_color]]##() will have the desired color. | |
78 | -- | |
79 | -- When your program terminates, the last color that you selected and actually printed on the | |
80 | -- screen will remain in effect. Thus you may have to print something, maybe just ##'\n'##, | |
81 | -- in ##WHITE## to restore white text, especially if you are at the bottom line of the | |
82 | -- screen, ready to scroll up. | |
83 | -- | |
84 | -- Example: | |
85 | -- | |
86 | -- text_color(BRIGHT_BLUE) | |
87 | -- | |
88 | -- | |
89 | -- See Also: | |
90 | -- [[:bk_color]] , [[:clear_screen]] | |
91 | ||
92 | 0 | |
93 | -- set the foreground text color to c - text or graphics modes | |
94 | -- add 16 to get blinking | |
95 | 0 | c = and_bits(c, 0x1F) |
96 | 0 | ifdef OSX then |
97 | c = true_color[c+1] | |
98 | elsifdef UNIX then | |
99 | 0 | c = true_color[c+1] |
100 | end ifdef | |
101 | 0 | machine_proc(M_SET_T_COLOR, c) |
102 | 0 | end procedure |
103 | ||
104 | --** | |
105 | -- Set the background color to one of the 16 standard colors. | |
106 | -- | |
107 | -- Parameters: | |
108 | -- # ##c## : the new text color. Add ##BLINKING## to get blinking text in some modes. | |
109 | -- | |
110 | -- Comments: | |
111 | -- To restore the original background color when your program finishes, | |
112 | -- e.g. ##0 - BLACK##, you must call ##[[:bk_color]](0)##. If the cursor is at the bottom | |
113 | -- line of the screen, you may have to actually print something before terminating your | |
114 | -- program. Printing ##'\n'## may be enough. | |
115 | -- | |
116 | -- Example: | |
117 | -- | |
118 | -- bk_color(BLACK) | |
119 | -- | |
120 | -- | |
121 | -- See Also: | |
122 | -- [[:text_color]] | |
123 | ||
124 | 0 | |
125 | -- set the background color to c - text or graphics modes | |
126 | 0 | c = and_bits(c, 0x1F) |
127 | 0 | ifdef OSX then |
128 | c = true_color[c+1] | |
129 | elsifdef UNIX then | |
130 | 0 | c = true_color[c+1] |
131 | end ifdef | |
132 | 0 | machine_proc(M_SET_B_COLOR, c) |
133 | 0 | end procedure |
134 | ||
135 | 0 | |
136 | 0 | return n = n = 1 |
137 | end type | |
138 | ||
139 | --** | |
140 | -- Determine whether text will wrap when hitting the rightmost column. | |
141 | -- | |
142 | -- Parameters: | |
143 | -- # ##on## : a boolean, 0 to truncate text, nonzero to wrap. | |
144 | -- | |
145 | -- Comments: | |
146 | -- By default text will wrap. | |
147 | -- | |
148 | -- Use ##wrap##() in text modes or pixel-graphics modes when you are displaying long | |
149 | -- lines of text. | |
150 | -- | |
151 | -- Example: | |
152 | -- | |
153 | -- puts(1, repeat('x', 100) & "\n\n") | |
154 | -- -- now have a line of 80 'x' followed a line of 20 more 'x' | |
155 | -- wrap(0) | |
156 | -- puts(1, repeat('x', 100) & "\n\n") | |
157 | -- -- creates just one line of 80 'x' | |
158 | -- | |
159 | -- | |
160 | -- See Also: | |
161 | -- [[:puts]], [[:position]] | |
162 | ||
163 | 0 | |
164 | 0 | machine_proc(M_WRAP, on) |
165 | 0 | end procedure |
166 | ||
167 | --** | |
168 | -- Scroll a region of text on the screen. | |
169 | -- | |
170 | -- Parameters: | |
171 | -- # ##amount## : an integer, the number of lines by which to scroll. This is >0 to scroll up and <0 to scroll down. | |
172 | -- # ##top_line## : the 1-based number of the topmost line to scroll. | |
173 | -- # ##bottom_line## : the 1-based number of the bottom-most line to scroll. | |
174 | -- | |
175 | -- Comments: | |
176 | -- inclusive. New blank lines will | |
177 | -- appear at the top or bottom. | |
178 | -- | |
179 | -- You could perform the scrolling operation using a series of calls to ##[:puts]]()##, | |
180 | -- but ##scroll##() is much faster. | |
181 | -- | |
182 | -- The position of the cursor after scrolling is not defined. | |
183 | -- | |
184 | -- Example 1: | |
185 | -- ##bin/ed.ex## | |
186 | -- | |
187 | -- See Also: | |
188 | -- [[:clear_screen]], [[:text_rows]] | |
189 | ||
190 | 0 | |
191 | positive_int top_line, | |
192 | positive_int bottom_line) | |
193 | 0 | machine_proc(M_SCROLL, {amount, top_line, bottom_line}) |
194 | 0 | end procedure |
195 | ||
196 | --**** | |
197 | -- === Graphics Modes | |
198 | ||
199 | 0 | |
200 | 0 | return (x >= -3 and x <= 19) or (x >= 256 and x <= 263) |
201 | end type | |
202 | ||
203 | --** | |
204 | -- Attempt to set up a new graphics mode. | |
205 | -- | |
206 | -- Parameters: | |
207 | -- # ##m## : an integer, ignored. | |
208 | -- | |
209 | -- Returns: | |
210 | -- An **integer**, always returns zero. | |
211 | -- | |
212 | -- Comments: | |
213 | -- * This has no effect on Unix platforms. | |
214 | -- * On Windows, it causes a console to be shown if one has not already been created. | |
215 | -- See Also: | |
216 | -- [[:video_config]] | |
217 | ||
218 | 0 | |
219 | 0 | return machine_func(M_GRAPHICS_MODE, m) |
220 | end function |