Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1676 | tullio | 1 | %---------------------------------------------------------------------------- |
2 | \chapter{The Console Library} |
||
3 | %---------------------------------------------------------------------------- |
||
4 | |||
5 | The output on the screen in text mode is supported by a group of functions that |
||
6 | act on the whole screen and modify, each time, the cursor's position. Since such |
||
7 | functions are not reentrant, they must be used in mutual exclusion. |
||
8 | |||
9 | In order to use the library for displaying on the screen, the |
||
10 | ``\texttt{cons.h}'' file must be included. This file contains the values for |
||
11 | the usable colors whose symbolic names are listed below: \texttt{BLACK, BLUE, |
||
12 | GREEN, CYAN, RED, MAGENTA, BROWN, GRAY, LIGHTGRAY, LIGHTBLUE, LIGHTGREEN, |
||
13 | LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE}. |
||
14 | |||
15 | Two global read-only variables \texttt{cons\_columns} and \texttt{cons\_rows} |
||
16 | contain the number of screen columns and the number of screen rows, |
||
17 | respectively. They can be used to write applications that are indipendent from |
||
18 | the screen dimensions. |
||
19 | |||
20 | \vspace{7mm} |
||
21 | |||
22 | \begin{intest} |
||
23 | CPUTC, CPUTS, CPRINTF \index{cputc()}\index{cputs()}\index{cprintf()} |
||
24 | \end{intest} |
||
25 | |||
26 | \begin{description} |
||
27 | \item [\textbf{void cputc(char c); }] |
||
28 | \item [\textbf{void cputs(char {*}s); }] |
||
29 | \item [\textbf{int cprintf(char {*}fmt,... ); }] |
||
30 | \item [\textbf{Description:}] \texttt{cputc}, \texttt{cupts} and \texttt{cprintf} are used |
||
31 | to print on the screen a character, a string, or a formatted string, |
||
32 | respectively. In the latter case, the standard C I/O formatting conventions are |
||
33 | used. |
||
34 | \item [\textbf{Warning:}]since these functions modify the cursor position, they are not |
||
35 | reentrant, and must be used in a mutually exclusive fashion. |
||
36 | \end{description} |
||
37 | |||
38 | \begin{intest} |
||
39 | PUTC\_XY, PUTS\_XY, PRINTF\_XY, GETC\_XY \index{putc\_xy()} \index{puts\_xy()} |
||
40 | \index{printf\_xy()} \index{getc\_xy()} |
||
41 | \end{intest} |
||
42 | |||
43 | \begin{description} |
||
44 | \item [\textbf{void putc\_xy(int x,int y,char attr,char c) }] |
||
45 | \item [\textbf{void puts\_xy(int x,int y,char attr,char {*}s) }] |
||
46 | \item [\textbf{int printf\_xy(int x,int y,char attr,char {*}fmt,...) }] |
||
47 | \item [\textbf{char getc\_xy(int x,int y,char {*}attr,char {*}c) }] |
||
48 | \item [\textbf{Description:}] These functions are similar to the previously defined ones; |
||
49 | the only difference is that since they're reentrant can be used concurrently by |
||
50 | multiple tasks (the others cannot be used for this purpose because they modify |
||
51 | the cursor's state). \texttt{getc\_xy} is used to read the charcater and its |
||
52 | attribute at a specific position on the screen. |
||
53 | \end{description} |
||
54 | |||
55 | \begin{intest} |
||
56 | CLEAR, \_CLEAR, SCROLL, \_SCROLL \index{clear()} \index{\_clear()} |
||
57 | \index{\_scroll()} |
||
58 | \end{intest} |
||
59 | |||
60 | \begin{description} |
||
61 | \item [\textbf{void \_clear(char c,char attr,int x1,int y1,int x2,int y2) }] |
||
62 | \item [\textbf{void clear(void) }] |
||
63 | \item [\textbf{void \_scroll(char attr,int x1,int y1,int x2,int y2) }] |
||
64 | \item [\textbf{void scroll(void) }] |
||
65 | \item [\textbf{Description:}] the \texttt{clear} and \texttt{scroll} functions are used |
||
66 | for clearing the screen and for scrolling it upwards. They are based on the |
||
67 | \texttt{\_clear()} and \texttt{\_scroll()} functions used for clearing or |
||
68 | scrolling a window (defined by \texttt{x1, y1, x2, y2}) by filling the area with |
||
69 | \texttt{attr} color and, in the case of \texttt{\_clear}, with character |
||
70 | \texttt{c} as well. |
||
71 | \end{description} |
||
72 | |||
73 | \begin{intest} |
||
74 | SET\_ACTIVE\_PAGE, SET\_VISUAL\_PAGE,\\ |
||
75 | GET\_ACTIVE\_PAGE, GET\_VISUAL\_PAGE |
||
76 | \index{set\_active\_page()} \index{set\_visual\_page()} |
||
77 | \index{get\_active\_page()} \index{get\_visual\_page()} |
||
78 | \end{intest} |
||
79 | |||
80 | \begin{description} |
||
81 | \item [\textbf{void set\_active\_page(int page) }] |
||
82 | \item [\textbf{void set\_visual\_page(int page) }] |
||
83 | \item [\textbf{int get\_active\_page(void) }] |
||
84 | \item [\textbf{int get\_visual\_page(void) }] |
||
85 | \item [\textbf{Description:}] The video cards working in text mode use the CGA hardware |
||
86 | scheme. In this scheme, every screen occupies 4000 bytes (80 columns x 25 rows; |
||
87 | each position is associated with two bytes, one for codifying the character and |
||
88 | another for codifying the color). The video card memory is in general bigger, |
||
89 | therefore multiple screen pages can be used simultaneously. The currently |
||
90 | visualized screen is called the \texttt{visual page}, whereas the screen the |
||
91 | output is directed to is called the \texttt{active page}. The cited functions |
||
92 | are essentially used for handling, at a given instant, the visual page or the |
||
93 | active page. SUGGESTION: if the active page or the visual page are modified, |
||
94 | they should be restored to the original (0) value on exit; the same is true for |
||
95 | the cursor. |
||
96 | \end{description} |
||
97 | |||
98 | \begin{intest} |
||
99 | PLACE, CURSOR, CURSOR\_INFO |
||
100 | \index{place()} \index{cursor()} \index{cursor\_info()} |
||
101 | \end{intest} |
||
102 | |||
103 | \begin{description} |
||
104 | \item [\textbf{void place(int x, int y) }] |
||
105 | \item [\textbf{void cursor(int start\_scanline, int end\_scanline) }] |
||
106 | \item [\textbf{void cursor\_info(int {*}x, int {*}y) }] |
||
107 | \item [\textbf{Description:}] These functions are used for handling the cursor. More |
||
108 | specifically, \texttt{place} sets the cursor position (\texttt{x} belongs to the |
||
109 | range 0\ldots{}79, \texttt{y} to 0\ldots{}24). |
||
110 | \end{description} |
||
111 | |||
112 | \begin{intest} |
||
113 | CURSOR\_BLOB, CURSOR\_STD, CURSOR\_OFF |
||
114 | \index{cursor\_blob()} \index{cursor\_std()} \index{cursor\_off()} |
||
115 | \end{intest} |
||
116 | |||
117 | \begin{description} |
||
118 | \item [\textbf{void cursor\_blob(void) }] |
||
119 | \item [\textbf{void cursor\_std(void) }] |
||
120 | \item [\textbf{void cursor\_off(void) }] |
||
121 | \item [\textbf{Description:}] These macros call the \texttt{cursor()} function to set the |
||
122 | cursor shape to be a big rectangle, the standard underscore, or invisible. |
||
123 | \end{description} |