-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhu_lib.h
134 lines (94 loc) · 3.13 KB
/
hu_lib.h
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
//
// Copyright (C) 1993-1996 Id Software, Inc.
// Copyright (C) 2023 Frenkel Smeijers
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __HULIB__
#define __HULIB__
// foreground screen number
#define FG 0
// font stuff
#define HU_CHARERASE KEY_BACKSPACE
#define HU_MAXLINES 4
#define HU_MAXLINELENGTH 80
//
// Typedefs of widgets
//
// Text Line widget
// (parent of Scrolling Text and Input Text widgets)
typedef struct
{
// left-justified position of scrolling text window
int32_t x, y;
patch_t **f; // font
int32_t sc; // start character
char l[HU_MAXLINELENGTH+1]; // line of text
int32_t len; // current line length
// whether this line needs to be udpated
int32_t needsupdate;
} hu_textline_t;
// Scrolling Text window widget
// (child of Text Line widget)
typedef struct
{
hu_textline_t l[HU_MAXLINES]; // text lines to draw
int32_t h; // height in lines
int32_t cl; // current line number
// pointer to boolean stating whether to update window
boolean *on;
boolean laston; // last value of *->on.
} hu_stext_t;
// Input Text Line widget
// (child of Text Line widget)
typedef struct
{
hu_textline_t l; // text line to input on
// left margin past which I am not to delete characters
int32_t lm;
// pointer to boolean stating whether to update window
boolean *on;
boolean laston; // last value of *->on;
} hu_itext_t;
//
// Widget creation, access, and update routines
//
//
// textline code
//
void HUlib_initTextLine(hu_textline_t *t, int32_t x, int32_t y, patch_t **f, int32_t sc);
void HUlib_addCharToTextLine(hu_textline_t *t, char ch);
// draws tline
void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor);
// erases text line
void HUlib_eraseTextLine(hu_textline_t *l);
//
// Scrolling Text window widget routines
//
void HUlib_initSText(hu_stext_t *s, int32_t x, int32_t y, int32_t h, patch_t **font, int32_t startchar, boolean *on);
void HUlib_addMessageToSText (hu_stext_t *s, char *prefix, char *msg);
// draws stext
void HUlib_drawSText(hu_stext_t *s);
// erases all stext lines
void HUlib_eraseSText(hu_stext_t *s);
// Input Text Line widget routines
void HUlib_initIText(hu_itext_t *it, int32_t x, int32_t y, patch_t **font, int32_t startchar, boolean *on);
// resets line and left margin
void HUlib_resetIText(hu_itext_t *it);
// whether eaten
boolean HUlib_keyInIText(hu_itext_t *it, uint8_t ch);
void HUlib_drawIText(hu_itext_t *it);
// erases all itext lines
void HUlib_eraseIText(hu_itext_t *it);
#endif