-/* $OpenBSD: input.c,v 1.225 2024/06/24 08:30:50 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.226 2024/08/19 08:31:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
int utf8started;
int ch;
- int last;
+ struct utf8_data last;
int flags;
#define INPUT_DISCARD 0x1
+#define INPUT_LAST 0x2
const struct input_state *state;
input_clear(ictx);
- ictx->last = -1;
-
ictx->state = &input_state_ground;
ictx->flags = 0;
}
utf8_set(&ictx->cell.cell.data, ictx->ch);
screen_write_collect_add(sctx, &ictx->cell.cell);
- ictx->last = ictx->ch;
+
+ utf8_copy(&ictx->last, &ictx->cell.cell.data);
+ ictx->flags |= INPUT_LAST;
ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
break;
}
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
return (0);
}
break;
}
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
return (0);
}
if (n > m)
n = m;
- if (ictx->last == -1)
+ if (~ictx->flags & INPUT_LAST)
break;
- ictx->ch = ictx->last;
+ utf8_copy(&ictx->cell.cell.data, &ictx->last);
for (i = 0; i < n; i++)
- input_print(ictx);
+ screen_write_collect_add(sctx, &ictx->cell.cell);
break;
case INPUT_CSI_RCP:
input_restore_state(ictx);
}
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
return (0);
}
input_clear(ictx);
input_start_timer(ictx);
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
}
/* DCS terminator (ST) received. */
input_clear(ictx);
input_start_timer(ictx);
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
}
/* OSC terminator (ST) received. */
input_clear(ictx);
input_start_timer(ictx);
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
}
/* APC terminator (ST) received. */
input_clear(ictx);
input_start_timer(ictx);
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
}
/* Rename terminator (ST) received. */
struct screen_write_ctx *sctx = &ictx->ctx;
struct utf8_data *ud = &ictx->utf8data;
- ictx->last = -1;
+ ictx->flags &= ~INPUT_LAST;
if (!ictx->utf8started) {
if (utf8_open(ud, ictx->ch) != UTF8_MORE)
utf8_copy(&ictx->cell.cell.data, ud);
screen_write_collect_add(sctx, &ictx->cell.cell);
+ utf8_copy(&ictx->last, &ictx->cell.cell.data);
+ ictx->flags |= INPUT_LAST;
+
return (0);
}