aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tbi/win.h
blob: 404cdd1a801b2db489d87e1b24558634e8a0c6d2 (plain)
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
#ifndef UFM_TBI_WINDOW_H
#define UFM_TBI_WINDOW_H

/*
	Window - rectangular area of the screen with which you can work as a separate
	screen (display text, clear, etc). The output should be carried out only in
	the specified rectangular area of the screen

	NOTE: SimpleTextOut.h has defined box-drawing character ("BOXDRAW_*", for
	example BOXDRAW_VERTICAL)
*/

#include <Uefi.h>

struct screen;

struct window {
	struct screen *scr; // parent screen

	INT32 curx, cury; // current cursor position
	INT32 begx, begy; // screen coords of upper left corner
	INT32 width, height; // window size

	CHAR16 **text; // the actual text of whole screen
	/* ATTRIBUTES:
	Bits 0..3 are the foreground color.
	Bits 4..6 are the background color.
	ALl other bits are undefined and must be zero */
	INT32 **attr;

	INT32 cur_attr;
};

/*
 * Creates a window with given parameters
 *
 * s: the information of the screen
 * ncols: the number of columns
 * nlines: the number of lines
 * begin_x: the column coordinate (starts from 0) of upper left corner of the window
 * begin_y: the line coordinate (starts from 0) of upper left corner of the window
 *
 * return: A pointer to the allocated structure or NULL if allocation fails
*/
struct window *newwin(struct screen *s,
	INT32 ncols, INT32 nlines, INT32 begin_x, INT32 begin_y);

/*
 * Deletes the window, frees the structure
 *
 * w: the window on which to operate
 *
 * return: VOID
*/
VOID delwin(struct window *w);

/*
 * Sets the current attributes of the given window
 *
 * w: the window on which to operate
 * attr: the attributes
 *
 * return: VOID
*/
VOID wattrset(struct window *w, INT32 attr);

/*
 * Resets the current attributes of the given window to standard screen
 * attributes
 *
 * w: the window on which to operate
 *
 * return: VOID
*/
VOID wattroff(struct window *w);

/*
 * Moves cursor position to specified coordinates
 *
 * w: the window on which to operate
 * x: the X(column) coordinate
 * y: the Y(row) coordinate
 *
 * return: FALSE upon failure and TRUE upon successful completion
*/
BOOLEAN wmove(struct window *w, INT32 x, INT32 y);

/*
 * Draws a box around the edges of a window
 *
 * w: the window on which to operate
 * ls: the left side character
 * rs: the right side character
 * ts: the top side character
 * bs: the bottom side character
 * tl: the top left corner character
 * tr: the top right corner character
 * bl: the bottom left corner character
 * br: the bottom right corner character
 *
 * return: FALSE upon failure and TRUE upon successful completion
*/
BOOLEAN wborder(struct window *w, CHAR16 ls, CHAR16 rs, CHAR16 ts,
	CHAR16 bs, CHAR16 tl, CHAR16 tr, CHAR16 bl, CHAR16 br);

/*
 * Moves to specified coordinates, draws a horizontal line using ch
 * starting at (x, y) in the window. The current cursor position is 
 * not changed.
 *
 * w: the window on which to operate
 * x: the X(column) coordinate for the start of the line
 * y: the Y(row) coordinate for the start of the line
 * ch: the character used to draw the line
 * n: the maximum number of chars in the line
 *
 * return: FALSE upon failure and TRUE upon successful completion
*/
BOOLEAN mvwhline(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 n);

/*
 * Moves to specified coordinates, draws a vertical line using ch
 * starting at (x, y) in the window. The current cursor position is 
 * not changed.
 *
 * w: the window on which to operate
 * x: the X(column) coordinate for the start of the line
 * y: the Y(row) coordinate for the start of the line
 * ch: the character used to draw the line
 * n: the maximum number of chars in the line
 *
 * return: FALSE upon failure and TRUE upon successful completion
*/
BOOLEAN mvwvline(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 n);

#endif /* UFM_TBI_WINDOW_H */