aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-25 22:05:04 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-25 22:05:04 -0400
commit4bdb4a0d8b0762faff0be5a415f3b97f5685c635 (patch)
treecb01fd4c2af84952db59c3b43fcb21682c78c39d
parent4b4622f260eb6c051404bd04395752e774d30c6c (diff)
downloadrunes-4bdb4a0d8b0762faff0be5a415f3b97f5685c635.tar.gz
runes-4bdb4a0d8b0762faff0be5a415f3b97f5685c635.zip
implement insert/delete characters
-rw-r--r--src/screen.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/screen.c b/src/screen.c
index 94e70f9..5eef957 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -201,9 +201,15 @@ void runes_screen_kill_line_backward(RunesTerm *t)
void runes_screen_insert_characters(RunesTerm *t, int count)
{
- UNUSED(t);
- UNUSED(count);
- fprintf(stderr, "insert_characters nyi\n");
+ RunesScreen *scr = &t->scr;
+ struct runes_row *row = &scr->rows[scr->cur.row];
+
+ memmove(
+ &row->cells[scr->cur.col + count], &row->cells[scr->cur.col],
+ (scr->max.col - scr->cur.col - count) * sizeof(struct runes_cell));
+ memset(
+ &row->cells[scr->cur.col], 0,
+ count * sizeof(struct runes_cell));
}
void runes_screen_insert_lines(RunesTerm *t, int count)
@@ -215,9 +221,15 @@ void runes_screen_insert_lines(RunesTerm *t, int count)
void runes_screen_delete_characters(RunesTerm *t, int count)
{
- UNUSED(t);
- UNUSED(count);
- fprintf(stderr, "delete_characters nyi\n");
+ RunesScreen *scr = &t->scr;
+ struct runes_row *row = &scr->rows[scr->cur.row];
+
+ memmove(
+ &row->cells[scr->cur.col], &row->cells[scr->cur.col + count],
+ (scr->max.col - scr->cur.col - count) * sizeof(struct runes_cell));
+ memset(
+ &row->cells[scr->max.col - count], 0,
+ count * sizeof(struct runes_cell));
}
void runes_screen_delete_lines(RunesTerm *t, int count)