From d4ce900ed5fc6a15b71421d1a65b374366983f9a Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 26 Oct 2021 21:28:29 +0300 Subject: tbi/win: make mvwhline(), mvwvline() --- lib/tbi/win.c | 36 ++++++++++++++++++++++++++++++++++++ lib/tbi/win.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/lib/tbi/win.c b/lib/tbi/win.c index 4acc23f..3486c7a 100644 --- a/lib/tbi/win.c +++ b/lib/tbi/win.c @@ -150,3 +150,39 @@ BOOLEAN wborder(struct window *w, CHAR16 ls, CHAR16 rs, CHAR16 ts, return TRUE; } +BOOLEAN mvwhline(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 n) +{ + UINTN i, length; + ASSERT(w != NULL); + CHECK_POSITION(w, x, y); + + length = w->width - x; + if(length > n) + length = n; + + length += x; + for(i = x; i < length; i++) { + w->text[y][i] = ch; + w->attr[y][i] = w->cur_attr; + } + return TRUE; +} + +BOOLEAN mvwvline(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 n) +{ + UINTN i, length; + ASSERT(w != NULL); + CHECK_POSITION(w, x, y); + + length = w->height - y; + if(length > n) + length = n; + + length += y; + for(i = y; i < length; i++) { + w->text[i][x] = ch; + w->attr[i][x] = w->cur_attr; + } + return TRUE; +} + diff --git a/lib/tbi/win.h b/lib/tbi/win.h index eddda05..404cdd1 100644 --- a/lib/tbi/win.h +++ b/lib/tbi/win.h @@ -103,4 +103,34 @@ BOOLEAN wmove(struct window *w, INT32 x, INT32 y); 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 */ -- cgit v1.2.3-18-g5258