summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2016-05-07 16:07:40 -0400
committerJesse Luehrs <doy@tozt.net>2016-05-07 16:07:40 -0400
commita3c4f0490c7c70c05de42148d9aedf16149edb58 (patch)
treec1392e74750a6c6aba28d5f37cffb68ef35a2959
parentdc2fffbd1a8763fe7228c119ba2a709e57bc73da (diff)
downloadlibvt100-a3c4f0490c7c70c05de42148d9aedf16149edb58.tar.gz
libvt100-a3c4f0490c7c70c05de42148d9aedf16149edb58.zip
allow the cursor to go off the end of the line
vt100_screen_move_to clamps the cursor to being within the screen, but when drawing text to the screen, the cursor is allowed to move to one past the last column, and not wrap until the next character is written (in this case, the cursor is still drawn in the last column, but the internal terminal state is different). updating the row and column manually allows us to position the column outside of the normal bounds (which we otherwise don't want to allow vt100_screen_move_to to do).
-rw-r--r--src/screen.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/screen.c b/src/screen.c
index afae515..8862fa1 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -149,15 +149,15 @@ void vt100_screen_visual_bell(VT100Screen *vt)
void vt100_screen_show_string_ascii(VT100Screen *vt, char *buf, size_t len)
{
size_t i;
- int col = vt->grid->cur.col;
if (len) {
vt->dirty = 1;
- if (col > 0) {
+ if (vt->grid->cur.col > 0) {
struct vt100_cell *cell;
- cell = vt100_screen_cell_at(vt, vt->grid->cur.row, col - 1);
+ cell = vt100_screen_cell_at(
+ vt, vt->grid->cur.row, vt->grid->cur.col - 1);
if (cell->is_wide) {
cell->len = 1;
cell->contents[0] = ' ';
@@ -168,33 +168,33 @@ void vt100_screen_show_string_ascii(VT100Screen *vt, char *buf, size_t len)
for (i = 0; i < len; ++i) {
struct vt100_cell *cell;
- if (col >= vt->grid->max.col) {
+ if (vt->grid->cur.col >= vt->grid->max.col) {
vt100_screen_row_at(vt, vt->grid->cur.row)->wrapped = 1;
vt100_screen_move_down_or_scroll(vt);
- col = 0;
+ vt->grid->cur.col = 0;
}
- cell = vt100_screen_cell_at(vt, vt->grid->cur.row, col++);
+ cell = vt100_screen_cell_at(vt, vt->grid->cur.row, vt->grid->cur.col);
+ vt->grid->cur.col++;
cell->len = 1;
cell->contents[0] = buf[i];
cell->attrs = vt->attrs;
cell->is_wide = 0;
}
- vt100_screen_move_to(vt, vt->grid->cur.row, col);
}
void vt100_screen_show_string_utf8(VT100Screen *vt, char *buf, size_t len)
{
char *c = buf, *next;
- int col = vt->grid->cur.col;
if (len) {
vt->dirty = 1;
- if (col > 0) {
+ if (vt->grid->cur.col > 0) {
struct vt100_cell *cell;
- cell = vt100_screen_cell_at(vt, vt->grid->cur.row, col - 1);
+ cell = vt100_screen_cell_at(
+ vt, vt->grid->cur.row, vt->grid->cur.col - 1);
if (cell->is_wide) {
cell->len = 1;
cell->contents[0] = ' ';
@@ -217,9 +217,9 @@ void vt100_screen_show_string_utf8(VT100Screen *vt, char *buf, size_t len)
|| ctype == G_UNICODE_NON_SPACING_MARK;
if (is_combining) {
- if (col > 0) {
+ if (vt->grid->cur.col > 0) {
cell = vt100_screen_cell_at(
- vt, vt->grid->cur.row, col - 1);
+ vt, vt->grid->cur.row, vt->grid->cur.col - 1);
}
else if (vt->grid->cur.row > 0 && vt100_screen_row_at(vt, vt->grid->cur.row - 1)->wrapped) {
cell = vt100_screen_cell_at(
@@ -243,19 +243,20 @@ void vt100_screen_show_string_utf8(VT100Screen *vt, char *buf, size_t len)
}
}
else {
- if (col + (is_wide ? 2 : 1) > vt->grid->max.col) {
+ if (vt->grid->cur.col + (is_wide ? 2 : 1) > vt->grid->max.col) {
vt100_screen_row_at(vt, vt->grid->cur.row)->wrapped = 1;
vt100_screen_move_down_or_scroll(vt);
- col = 0;
+ vt->grid->cur.col = 0;
}
- cell = vt100_screen_cell_at(vt, vt->grid->cur.row, col);
+ cell = vt100_screen_cell_at(
+ vt, vt->grid->cur.row, vt->grid->cur.col);
cell->is_wide = is_wide;
cell->len = next - c;
memcpy(cell->contents, c, cell->len);
cell->attrs = vt->attrs;
- col += is_wide ? 2 : 1;
+ vt->grid->cur.col += is_wide ? 2 : 1;
}
c = next;
@@ -263,7 +264,6 @@ void vt100_screen_show_string_utf8(VT100Screen *vt, char *buf, size_t len)
break;
}
}
- vt100_screen_move_to(vt, vt->grid->cur.row, col);
}
void vt100_screen_move_to(VT100Screen *vt, int row, int col)