From 642e48ad0625a65eec5ca216bb8d6ef5db7d457d Mon Sep 17 00:00:00 2001 From: Joursoir Date: Mon, 25 Oct 2021 17:30:37 +0000 Subject: tbi/win: make wborder() --- lib/tbi/win.c | 26 ++++++++++++++++++++++++++ lib/tbi/win.h | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/lib/tbi/win.c b/lib/tbi/win.c index 49ca9d7..4acc23f 100644 --- a/lib/tbi/win.c +++ b/lib/tbi/win.c @@ -124,3 +124,29 @@ BOOLEAN wmove(struct window *w, INT32 x, INT32 y) return TRUE; } +BOOLEAN wborder(struct window *w, CHAR16 ls, CHAR16 rs, CHAR16 ts, + CHAR16 bs, CHAR16 tl, CHAR16 tr, CHAR16 bl, CHAR16 br) +{ + INT32 i, endx, endy; + ASSERT(w != NULL); + + endx = w->width - 1; + endy = w->height - 1; + + for(i = 0; i <= endx; i++) { + SET_WINDOW_CHAR2(w, i, 0, ts); + SET_WINDOW_CHAR2(w, i, endy, bs); + } + + for(i = 0; i <= endy; i++) { + SET_WINDOW_CHAR2(w, 0, i, ls); + SET_WINDOW_CHAR2(w, endx, i, rs); + } + + SET_WINDOW_CHAR2(w, 0, 0, tl); + SET_WINDOW_CHAR2(w, endx, 0, tr); + SET_WINDOW_CHAR2(w, 0, endy, bl); + SET_WINDOW_CHAR2(w, endx, endy, br); + return TRUE; +} + diff --git a/lib/tbi/win.h b/lib/tbi/win.h index 9057369..eddda05 100644 --- a/lib/tbi/win.h +++ b/lib/tbi/win.h @@ -85,4 +85,22 @@ VOID wattroff(struct window *w); */ 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); + #endif /* UFM_TBI_WINDOW_H */ -- cgit v1.2.3-18-g5258