Skip to content

Commit c24e80e

Browse files
installer box drawing
1 parent 49987dd commit c24e80e

23 files changed

Lines changed: 568 additions & 220 deletions

BOOTFLOW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ After filesystems are ready, `init_process()` loads the first userland BASIC pro
133133
void init_process()
134134
{
135135
process_by_pid = hashmap_new(...);
136-
process_t* init = proc_load("/programs/init", current_console, 0, "/");
136+
process_t* init = proc_load("/programs/init", 0, "/");
137137
if (!init) {
138138
preboot_fail("/programs/init missing or invalid!\n");
139139
}

include/basic/context.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ typedef struct basic_ctx {
204204
*/
205205
struct ub_var_double_array* double_array_variables;
206206

207-
/**
208-
* @brief Console object used for I/O operations in the program.
209-
*/
210-
struct console* cons;
211-
212207
/**
213208
* @brief Expected return type of the function being executed.
214209
*
@@ -308,7 +303,7 @@ typedef struct basic_ctx {
308303
* @param error Pointer to store any error messages.
309304
* @return A pointer to the initialized `basic_ctx` context.
310305
*/
311-
struct basic_ctx* basic_init(const char *program, console* cons, uint32_t pid, const char* file, char** error);
306+
struct basic_ctx* basic_init(const char *program, uint32_t pid, const char* file, char** error);
312307

313308
/**
314309
* @brief Destroy the BASIC context and free associated resources.

include/homer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
#pragma once
77

8-
#define PANIC_BANNER setforeground(current_console, COLOUR_LIGHTYELLOW); \
8+
#define PANIC_BANNER setforeground(COLOUR_LIGHTYELLOW); \
99
kprintf("\n\
1010
___ _____ \n\
1111
.'/,-Y\" \"~-. \n\
@@ -23,7 +23,7 @@
2323
Y \\ /\n\
2424
| \"x______.^ \n\
2525
| \\ \n\
26-
\n"); setforeground(current_console, COLOUR_LIGHTWHITE);\
26+
\n"); setforeground(COLOUR_LIGHTWHITE);\
2727
kprintf("This is a fatal system error and your system has been halted.\n\
28-
"); setforeground(current_console, COLOUR_LIGHTRED);
28+
"); setforeground(COLOUR_LIGHTRED);
2929

include/input.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* @param cons Console to read input from.
5555
* @return 1 if a full line is available, 0 otherwise.
5656
*/
57-
size_t kinput(size_t maxlen, console* cons);
57+
size_t kinput(size_t maxlen);
5858

5959
/**
6060
* @brief Free the internal input buffer associated with a console.
@@ -66,7 +66,7 @@ size_t kinput(size_t maxlen, console* cons);
6666
*
6767
* @param cons Console whose input buffer should be freed.
6868
*/
69-
void kfreeinput(console* cons);
69+
void kfreeinput();
7070

7171
/**
7272
* @brief Retrieve the accumulated input string for a console.
@@ -76,4 +76,4 @@ void kfreeinput(console* cons);
7676
*
7777
* @warning Do not free the returned pointer directly; use @ref kfreeinput().
7878
*/
79-
char* kgetinput(console* cons);
79+
char* kgetinput();

include/installer.h

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@
4141
*/
4242
#define EFI_FAT_IMAGE "/efi.fat"
4343

44+
/* Print format for “one glyph” */
45+
#define GLYPH_FMT "%s"
46+
47+
/* Double box line-drawing: UTF-8 (U+2550..U+255D) */
48+
#define CP437_DBL_H "\xE2\x95\x90" /* U+2550 ═ */
49+
#define CP437_DBL_V "\xE2\x95\x91" /* U+2551 ║ */
50+
#define CP437_DBL_TL "\xE2\x95\x94" /* U+2554 ╔ */
51+
#define CP437_DBL_TR "\xE2\x95\x97" /* U+2557 ╗ */
52+
#define CP437_DBL_BL "\xE2\x95\x9A" /* U+255A ╚ */
53+
#define CP437_DBL_BR "\xE2\x95\x9D" /* U+255D ╝ */
54+
55+
/* Block fills: UTF-8 (U+2588, U+258C, U+2590) */
56+
#define CP437_BLOCK_FULL "\xE2\x96\x88" /* U+2588 █ */
57+
#define CP437_BLOCK_HALF_LEFT "\xE2\x96\x8C" /* U+258C ▌ */
58+
#define CP437_BLOCK_HALF_RIGHT "\xE2\x96\x90" /* U+2590 ▐ */
59+
4460
/**
4561
* @brief Mapping of a GPT GUID to user-facing labels
4662
*/
@@ -182,7 +198,7 @@ void centre_text(const char* format, ...) PRINTF_LIKE(1,2);
182198
*
183199
* @param warning_message Message to display
184200
*/
185-
void warning(const char* warning_message);
201+
void warning(const char* warning_message, const char* subtitle);
186202

187203
/**
188204
* @brief Align a 64-bit value up to the nearest multiple
@@ -261,3 +277,83 @@ bool prepare_rfs_partition(storage_device_t* dev);
261277
* @return true if a summary was produced, false on low-level failure
262278
*/
263279
bool probe_device_summary(const storage_device_t *dev, char *out, size_t out_len, bool *usable);
280+
281+
/**
282+
* @brief Draw a double-line CP437 box at a given position.
283+
*
284+
* Draws a rectangular box using DOS CP437 double line drawing characters.
285+
* The box is clipped to the current text grid. The interior is left untouched.
286+
* On completion, the cursor is restored to its original position.
287+
*
288+
* @param x Left column (0-based).
289+
* @param y Top row (0-based).
290+
* @param width Box width in character cells (must be >= 2 after clipping).
291+
* @param height Box height in character cells (must be >= 2 after clipping).
292+
*/
293+
void draw_box_cp437_double(uint64_t x, uint64_t y, uint64_t width, uint64_t height);
294+
295+
/**
296+
* @brief Draw a centred double-line CP437 box.
297+
*
298+
* Computes coordinates to centre a box of the requested dimensions
299+
* in the current text area. The actual box position and clipped size
300+
* are written back to the provided pointers.
301+
*
302+
* @param req_w Requested width in character cells.
303+
* @param req_h Requested height in character cells.
304+
* @param out_x Pointer to store the top-left x position.
305+
* @param out_y Pointer to store the top-left y position.
306+
* @param out_w Pointer to store the actual width drawn.
307+
* @param out_h Pointer to store the actual height drawn.
308+
*/
309+
void draw_box_cp437_double_center(uint64_t req_w, uint64_t req_h, uint64_t *out_x, uint64_t *out_y, uint64_t *out_w, uint64_t *out_h);
310+
311+
/**
312+
* @brief Draw a bordered CP437 progress bar at (x, y).
313+
*
314+
* Renders a 3-row widget:
315+
* row 0: top border
316+
* row 1: fill area (blocks)
317+
* row 2: bottom border
318+
*
319+
* Width includes the border; the interior fill width is (width - 2).
320+
* Percent is clamped to [0, 100]. The bar uses half-cell resolution.
321+
*
322+
* @param x Left column (0-based).
323+
* @param y Top row (0-based).
324+
* @param width Total width in character cells (must be >= 3 after clipping).
325+
* @param percent Completion percent (0..100).
326+
*/
327+
void draw_progress_bar_cp437(uint64_t x, uint64_t y, uint64_t width, uint64_t percent);
328+
329+
/**
330+
* @brief Draw a bordered single-line CP437 text box.
331+
*
332+
* Draws a 3-row box (top border, text row, bottom border) at (x, y) with the
333+
* given total width. The interior row is filled with the provided text. If the
334+
* text does not fit, it is truncated and an ellipsis "..." is appended when
335+
* there is room (inner width >= 3). The cursor position is restored on exit.
336+
*
337+
* @param x Left column (0-based).
338+
* @param y Top row (0-based).
339+
* @param width Total box width in cells (must be >= 3 after clipping).
340+
* @param text NUL-terminated string to render inside the box (may be NULL).
341+
*/
342+
void draw_text_box_cp437(uint64_t x, uint64_t y, uint64_t width, const char *text);
343+
344+
345+
/**
346+
* @brief Draw a centred single-line CP437 text box.
347+
*
348+
* Thin wrapper around draw_text_box_cp437(). When the text fits, it is padded
349+
* with leading spaces so that it appears centred within the box. When it does
350+
* not fit, the truncation/ellipsis logic of draw_text_box_cp437() applies.
351+
*
352+
* @param x Left column (0-based).
353+
* @param y Top row (0-based).
354+
* @param width Total box width in cells (must be >= 3 after clipping).
355+
* @param text NUL-terminated string to render inside the box (may be NULL).
356+
*/
357+
void draw_text_box_cp437_center(uint64_t x, uint64_t y, uint64_t width, const char *text);
358+
359+
void new_page(const char* title);

include/keyboard.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#pragma once
2020

21+
#include <stdnoreturn.h>
22+
2123
/**
2224
* @brief Delay before held keys begin to auto-repeat.
2325
*
@@ -89,7 +91,7 @@ void init_keyboard();
8991
* @return ASCII character or extended key constant,
9092
* or 255 if no input is available.
9193
*/
92-
unsigned char kgetc(console* cons);
94+
unsigned char kgetc();
9395

9496
/**
9597
* @brief Tests if the CTRL key is currently held down.
@@ -121,4 +123,6 @@ bool caps_lock_on();
121123

122124
void load_keymap_from_string(const char* text);
123125

124-
bool key_waiting();
126+
bool key_waiting();
127+
128+
_Noreturn void reboot(void);

include/taskswitch.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ typedef struct process_t {
7575
const char* name; /**< Filename of program */
7676
uint64_t size; /**< Size of program in bytes */
7777
const char* csd; /**< Current selected directory */
78-
struct console* cons; /**< Associated console */
7978
struct basic_ctx* code; /**< BASIC interpreter context */
8079
struct process_t* prev; /**< Previous process in doubly linked list */
8180
struct process_t* next; /**< Next process in doubly linked list */
@@ -126,7 +125,7 @@ typedef struct idle_timer {
126125
* @param csd Current selected directory
127126
* @return process_t* Pointer to new process details
128127
*/
129-
process_t* proc_load(const char* fullpath, struct console* cons, pid_t parent_pid, const char* csd);
128+
process_t* proc_load(const char* fullpath, pid_t parent_pid, const char* csd);
130129

131130
/**
132131
* @brief Find a process by PID.

include/video.h

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -72,39 +72,14 @@
7272
/** @brief Default text colour (white on black). */
7373
#define DEFAULT_COLOUR COLOUR_WHITE
7474

75-
/**
76-
* @struct console
77-
* @brief Represents a text-mode console buffer.
78-
*
79-
* Low-level output functions (e.g. put(), putstring()) operate
80-
* against a console instance. Only one console is active at a time.
81-
*/
82-
typedef struct {
83-
char dirty; /**< Marks console as modified (needs redraw). */
84-
uint8_t x; /**< Current cursor X position. */
85-
uint8_t y; /**< Current cursor Y position. */
86-
uint8_t attributes; /**< Text attributes (e.g. colours). */
87-
uint8_t last; /**< Last character written. */
88-
char* internalbuffer; /**< Optional backing buffer for console text. */
89-
char* buffer; /**< External buffer, if used. */
90-
size_t bufcnt; /**< Buffer size or counter. */
91-
} console;
92-
9375
/* -------------------------------------------------------------------------- */
9476
/* Console text functions */
9577
/* -------------------------------------------------------------------------- */
9678

9779
/**
9880
* @brief Clear the screen and reset cursor to (0,0).
99-
* @param c Target console.
100-
*/
101-
void clearscreen(console* c);
102-
103-
/**
104-
* @brief Set the software cursor to the console's current (x,y).
105-
* @param c Target console.
10681
*/
107-
void setcursor(console* c);
82+
void clearscreen();
10883

10984
/**
11085
* @brief Write a null-terminated string to the console.
@@ -115,7 +90,7 @@ void setcursor(console* c);
11590
* @param c Target console.
11691
* @param message String to display.
11792
*/
118-
void putstring(console* c, const char* message);
93+
void putstring(const char* message);
11994

12095
/**
12196
* @brief Write a string to the debug port (0xE9) only.
@@ -128,10 +103,9 @@ void dputstring(const char* message);
128103
*
129104
* Cursor is advanced after output, and the screen may scroll.
130105
*
131-
* @param c Target console.
132106
* @param n Character to display.
133107
*/
134-
void put(console* c, const char n);
108+
void put(const char n);
135109

136110
/**
137111
* @brief Write a single character directly to the debug port (0xE9).
@@ -150,17 +124,15 @@ void init_console();
150124

151125
/**
152126
* @brief Set the background colour for subsequent text.
153-
* @param c Target console.
154127
* @param background VGA colour index (0–15).
155128
*/
156-
void setbackground(console* c, unsigned char background);
129+
void setbackground(unsigned char background);
157130

158131
/**
159132
* @brief Set the foreground (text) colour for subsequent output.
160-
* @param c Target console.
161133
* @param foreground VGA colour index (0–15).
162134
*/
163-
void setforeground(console* c, unsigned char foreground);
135+
void setforeground(unsigned char foreground);
164136

165137
/* -------------------------------------------------------------------------- */
166138
/* Screen geometry and framebuffer */
@@ -278,11 +250,3 @@ void set_video_dirty_area(int64_t start, int64_t end);
278250

279251
const char* ansi_colour(char *out, size_t out_len, unsigned char vga_colour, bool background);
280252

281-
/* -------------------------------------------------------------------------- */
282-
/* Globals */
283-
/* -------------------------------------------------------------------------- */
284-
285-
/**
286-
* @brief Pointer to the currently active console.
287-
*/
288-
extern console* current_console;

os/programs/charmap.rrbasic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FOR C = &20 TO &7F
1+
FOR C = &20 TO &7E
22
COLOR 8
33
PRINT ~C; ": ";
44
COLOR 15

0 commit comments

Comments
 (0)