From d743aff4bc09b866b9fbe4ed06ba24ddc52e2481 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 17 Mar 2021 22:02:47 +0530 Subject: [PATCH] Make the code to copy lines into linebufs general --- kitty/line-buf.c | 6 +++--- kitty/lineops.h | 2 +- kitty/screen.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kitty/line-buf.c b/kitty/line-buf.c index 67ef730ac..e31d2d111 100644 --- a/kitty/line-buf.c +++ b/kitty/line-buf.c @@ -406,10 +406,10 @@ delete_lines(LineBuf *self, PyObject *args) { } void -linebuf_add_line_to_top(LineBuf *self, Line *line) { - init_line(self, self->line, self->line_map[0]); +linebuf_copy_line_to(LineBuf *self, Line *line, index_type where) { + init_line(self, self->line, self->line_map[where]); copy_line(line, self->line); - self->line_attrs[0] = TEXT_DIRTY_MASK | (line->continued ? CONTINUED_MASK : 0); + self->line_attrs[where] = TEXT_DIRTY_MASK | (line->continued ? CONTINUED_MASK : 0); } static PyObject* diff --git a/kitty/lineops.h b/kitty/lineops.h index 7e81c2bf2..2481f1cb4 100644 --- a/kitty/lineops.h +++ b/kitty/lineops.h @@ -94,7 +94,7 @@ void linebuf_clear_line(LineBuf *self, index_type y); unsigned int linebuf_continued_lines_count(const LineBuf *, const index_type); void linebuf_insert_lines(LineBuf *self, unsigned int num, unsigned int y, unsigned int bottom); void linebuf_delete_lines(LineBuf *self, index_type num, index_type y, index_type bottom); -void linebuf_add_line_to_top(LineBuf *, Line *); +void linebuf_copy_line_to(LineBuf *, Line *, index_type); void linebuf_set_attribute(LineBuf *, unsigned int , unsigned int ); void linebuf_rewrap(LineBuf *self, LineBuf *other, index_type *, index_type *, HistoryBuf *, index_type *, index_type *, ANSIBuf*); void linebuf_mark_line_dirty(LineBuf *self, index_type y); diff --git a/kitty/screen.c b/kitty/screen.c index b5bf807e4..d88b6b92f 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -329,7 +329,7 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) { while (lines_to_fill-- > 0) { if (!historybuf_pop_line(self->historybuf, self->alt_linebuf->line)) break; INDEX_DOWN; - linebuf_add_line_to_top(self->main_linebuf, self->alt_linebuf->line); + linebuf_copy_line_to(self->main_linebuf, self->alt_linebuf->line, 0); } } return true;