summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-08 16:28:37 -0400
committerIan Moffett <ian@osmora.org>2025-07-08 16:28:37 -0400
commit376ec65578576f6ff955373ea68539b57d23a012 (patch)
tree50c75320038a289ca17f64948ae7ee767af49a2d
parentb4cf1f4c82dd837804b57ba01b35c283bff266e6 (diff)
kernel: cons: Use glyph relative pos in cons attr
- Make curs_col/curs_row reference console_attr.cursor_x/cursor_y - Console cursor x/y attributes reflect x/y multiplied by glyph dimensions Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/dev/cons/cons.c8
-rw-r--r--sys/include/dev/cons/cons.h5
2 files changed, 7 insertions, 6 deletions
diff --git a/sys/dev/cons/cons.c b/sys/dev/cons/cons.c
index 5a59e3d..7407ec1 100644
--- a/sys/dev/cons/cons.c
+++ b/sys/dev/cons/cons.c
@@ -500,17 +500,17 @@ ctl_attr_write(struct ctlfs_dev *cdp, struct sio_txn *sio)
sio->len = sizeof(*attrp);
}
- memcpy(attrp, sio->buf, sio->len);
spinlock_acquire(&scr->lock);
+ HIDE_CURSOR(scr);
+ memcpy(attrp, sio->buf, sio->len);
/* Clip the x/y positions */
if (attrp->cursor_x >= scr->ncols)
- attrp->cursor_x = scr->ncols - 1;
+ attrp->cursor_x = scr->ncols - FONT_WIDTH;
if (attrp->cursor_y >= scr->nrows)
- attrp->cursor_y = scr->nrows - 1;
+ attrp->cursor_y = scr->nrows - FONT_HEIGHT;
/* Update cursor */
- HIDE_CURSOR(scr);
scr->curs_col = attrp->cursor_x;
scr->curs_row = attrp->cursor_y;
scr->ch_col = attrp->cursor_x;
diff --git a/sys/include/dev/cons/cons.h b/sys/include/dev/cons/cons.h
index bc868b4..7c4e41a 100644
--- a/sys/include/dev/cons/cons.h
+++ b/sys/include/dev/cons/cons.h
@@ -63,14 +63,15 @@ struct cons_screen {
uint32_t ncols;
uint32_t ch_col; /* Current col */
uint32_t ch_row; /* Current row */
- uint32_t curs_col; /* Cursor col */
- uint32_t curs_row; /* Cursor row */
struct cons_buf *ib; /* Input buffer */
struct cons_buf **ob; /* Output buffers */
struct cons_char last_chr;
struct spinlock lock;
};
+#define curs_col attr.cursor_x
+#define curs_row attr.cursor_y
+
void cons_init(void);
void cons_expose(void);
void cons_update_color(struct cons_screen *scr, uint32_t fg, uint32_t bg);