aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-12-10 21:14:43 +0300
committerJoursoir <chat@joursoir.net>2021-12-10 21:14:43 +0300
commit0fbd4f2423d3f09764d0f0b31131683dc7522092 (patch)
treefee162033fc2881d642e4e863f6b48dbe702a399
parent235d3f2db54d1f745dca618ed2ca236cf6e84245 (diff)
downloadufm-0fbd4f2423d3f09764d0f0b31131683dc7522092.tar.gz
ufm-0fbd4f2423d3f09764d0f0b31131683dc7522092.tar.bz2
ufm-0fbd4f2423d3f09764d0f0b31131683dc7522092.zip
tbi/win: make waddch(), mvwaddch()
-rw-r--r--Library/UefiShellUfmCommandLib/tbi/win.c31
-rw-r--r--Library/UefiShellUfmCommandLib/tbi/win.h26
2 files changed, 57 insertions, 0 deletions
diff --git a/Library/UefiShellUfmCommandLib/tbi/win.c b/Library/UefiShellUfmCommandLib/tbi/win.c
index bada79e..13183b2 100644
--- a/Library/UefiShellUfmCommandLib/tbi/win.c
+++ b/Library/UefiShellUfmCommandLib/tbi/win.c
@@ -216,6 +216,37 @@ BOOLEAN whline(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 attr, UINTN
return TRUE;
}
+VOID waddch(struct window *w, CHAR16 ch, INT32 attr)
+{
+ INT32 x = w->curx
+ INT32 y = w->cury;
+
+ if(x >= w->width) {
+ w->curx = 0;
+ if(++w->cury >= w->height)
+ w->cury = 0;
+ }
+ else
+ w->curx += 1;
+
+ if(ch != 0)
+ w->text[y][x] = ch;
+ if(attr != -1)
+ w->attr[y][x] = attr;
+}
+
+BOOLEAN mvwaddch(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 attr)
+{
+ BOOLEAN moved;
+
+ moved = wmove(w, x, y);
+ if(moved == FALSE)
+ return FALSE;
+
+ waddch(w, ch, attr);
+ return TRUE;
+}
+
UINTN EFIAPI wprintf(struct window *w, CONST CHAR16 *fmt, ...)
{
VA_LIST arg;
diff --git a/Library/UefiShellUfmCommandLib/tbi/win.h b/Library/UefiShellUfmCommandLib/tbi/win.h
index a5aacce..3efa3c1 100644
--- a/Library/UefiShellUfmCommandLib/tbi/win.h
+++ b/Library/UefiShellUfmCommandLib/tbi/win.h
@@ -158,6 +158,32 @@ BOOLEAN wvline(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 attr, UINTN
BOOLEAN whline(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 attr, UINTN n);
/*
+ * Puts the character and attributes on the cursor coordinates of the
+ * given window. Doesn't support control characters
+ *
+ * w: the window on which to operate
+ * ch: the character used to print. If 0, then a char won't changed
+ * attr: the attributes used to print. If -1, then attrs won't changed
+ *
+ * return: FALSE upon failure and TRUE upon successful completion
+*/
+VOID waddch(struct window *w, CHAR16 ch, INT32 attr);
+
+/*
+ * Moves to specified coordinates, puts the character and attributes into the
+ * given window. Doesn't support control characters
+ *
+ * w: the window on which to operate
+ * x: the X(column) coordinate to move
+ * y: the Y(row) coordinate to move
+ * ch: the character used to print. If 0, then a char won't changed
+ * attr: the attributes used to print. If -1, then attrs won't changed
+ *
+ * return: FALSE upon failure and TRUE upon successful completion
+*/
+BOOLEAN mvwaddch(struct window *w, INT32 x, INT32 y, CHAR16 ch, INT32 attr);
+
+/*
* Prints formatted output on the cursor coordinates
*
* w: the window on which to operate