From fbdfec3cb1a2b9eaf383dd47fa1d54ccf501f4fa Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 25 Apr 2014 00:22:39 -0400 Subject: implement some of the screen clearing functions --- src/screen.c | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/src/screen.c b/src/screen.c index b8e903a..3d358b7 100644 --- a/src/screen.c +++ b/src/screen.c @@ -87,38 +87,68 @@ void runes_screen_move_to(RunesTerm *t, int row, int col) void runes_screen_clear_screen(RunesTerm *t) { - UNUSED(t); - fprintf(stderr, "clear_screen nyi\n"); + RunesScreen *scr = &t->scr; + int r; + + for (r = 0; r < scr->max.row; ++r) { + memset( + scr->rows[r].cells, 0, scr->max.col * sizeof(struct runes_cell)); + } } void runes_screen_clear_screen_forward(RunesTerm *t) { - UNUSED(t); - fprintf(stderr, "clear_screen_forward nyi\n"); + RunesScreen *scr = &t->scr; + int r; + + memset( + &scr->rows[scr->cur.row].cells[scr->cur.col], 0, + (scr->max.col - scr->cur.col) * sizeof(struct runes_cell)); + for (r = scr->cur.row + 1; r < scr->max.row; ++r) { + memset( + scr->rows[r].cells, 0, scr->max.col * sizeof(struct runes_cell)); + } } void runes_screen_clear_screen_backward(RunesTerm *t) { - UNUSED(t); - fprintf(stderr, "clear_screen_backward nyi\n"); + RunesScreen *scr = &t->scr; + int r; + + for (r = 0; r < scr->cur.row - 1; ++r) { + memset( + scr->rows[r].cells, 0, scr->max.col * sizeof(struct runes_cell)); + } + memset( + scr->rows[scr->cur.row].cells, 0, + scr->cur.col * sizeof(struct runes_cell)); } void runes_screen_kill_line(RunesTerm *t) { - UNUSED(t); - fprintf(stderr, "kill_line nyi\n"); + RunesScreen *scr = &t->scr; + + memset( + scr->rows[scr->cur.row].cells, 0, + scr->max.col * sizeof(struct runes_cell)); } void runes_screen_kill_line_forward(RunesTerm *t) { - UNUSED(t); - fprintf(stderr, "kill_line_forward nyi\n"); + RunesScreen *scr = &t->scr; + + memset( + &scr->rows[scr->cur.row].cells[scr->cur.col], 0, + (scr->max.col - scr->cur.col) * sizeof(struct runes_cell)); } void runes_screen_kill_line_backward(RunesTerm *t) { - UNUSED(t); - fprintf(stderr, "kill_line_backward nyi\n"); + RunesScreen *scr = &t->scr; + + memset( + scr->rows[scr->cur.row].cells, 0, + scr->cur.col * sizeof(struct runes_cell)); } void runes_screen_insert_characters(RunesTerm *t, int count) -- cgit v1.2.3