diff --git a/kitty/line-buf.c b/kitty/line-buf.c index 434d813d9..b0372436e 100644 --- a/kitty/line-buf.c +++ b/kitty/line-buf.c @@ -326,6 +326,15 @@ is_continued(LineBuf *self, PyObject *val) { Py_RETURN_FALSE; } +unsigned int +linebuf_continued_lines_count(LineBuf *self, index_type stop_at_line) { + unsigned int count = 0; + for (unsigned int i = 0; i < self->ynum && i < stop_at_line; i++) + if (self->line_attrs[i] & CONTINUED_MASK) count++; + + return count; +} + void linebuf_insert_lines(LineBuf *self, unsigned int num, unsigned int y, unsigned int bottom) { index_type i; diff --git a/kitty/lineops.h b/kitty/lineops.h index 6c58f61dd..63a0d2c34 100644 --- a/kitty/lineops.h +++ b/kitty/lineops.h @@ -91,6 +91,7 @@ void linebuf_clear(LineBuf *, char_type ch); void linebuf_index(LineBuf* self, index_type top, index_type bottom); void linebuf_reverse_index(LineBuf *self, index_type top, index_type bottom); void linebuf_clear_line(LineBuf *self, index_type y); +unsigned int linebuf_continued_lines_count(LineBuf *, 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 *);