Cleanup previous merge

This commit is contained in:
Kovid Goyal 2021-03-17 13:43:26 +05:30
parent d61c4a9569
commit 071986138b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 18 additions and 32 deletions

View File

@ -254,14 +254,10 @@ historybuf_add_line(HistoryBuf *self, const Line *line, ANSIBuf *as_ansi_buf) {
bool
historybuf_pop_line(HistoryBuf *self, Line *line) {
if (self->count <= 0)
return false;
if (self->count <= 0) return false;
index_type idx = (self->start_of_data + self->count - 1) % self->ynum;
init_line(self, idx, line);
self->count--;
return true;
}

View File

@ -327,11 +327,11 @@ is_continued(LineBuf *self, PyObject *val) {
}
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++)
linebuf_continued_lines_count(const LineBuf *self, const index_type stop_before_line) {
index_type count = 0;
for (index_type i = 0; i < self->ynum && i < stop_before_line; i++) {
if (self->line_attrs[i] & CONTINUED_MASK) count++;
}
return count;
}

View File

@ -91,7 +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);
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 *);

View File

@ -248,25 +248,15 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
if (OPT(scrollback_fill_enlarged_window)) {
int lines_to_fill = (lines - self->main_linebuf->ynum) \
+ (linebuf_continued_lines_count(self->main_linebuf, y) - linebuf_continued_lines_count(n, y));
while (lines_to_fill > 0) {
if (self->historybuf->count <= 0) break;
unsigned int top = 0, bottom = lines-1;
linebuf_reverse_index(n, top, bottom);
y++;
INDEX_GRAPHICS(1);
int lines_to_fill = (lines - self->main_linebuf->ynum) + (
linebuf_continued_lines_count(self->main_linebuf, self->cursor->y) - linebuf_continued_lines_count(n, y));
const unsigned int top = 0, bottom = lines-1;
Line last_history_line = {.xnum=self->historybuf->xnum};
bool line_popped = historybuf_pop_line(self->historybuf, &last_history_line);
if (!line_popped)
break;
while (lines_to_fill-- > 0) {
if (!historybuf_pop_line(self->historybuf, &last_history_line)) break;
linebuf_reverse_index(n, top, bottom);
INDEX_GRAPHICS(1);
linebuf_add_line_to_top(n, &last_history_line);
lines_to_fill--;
}
}

View File

@ -91,7 +91,7 @@ class BaseTest(TestCase):
options = Options(merge_configs(defaults._asdict(), final_options))
set_options(options)
def create_screen(self, cols=5, lines=5, scrollback=5, cell_width=10, cell_height=20, options=None, content=tuple()):
def create_screen(self, cols=5, lines=5, scrollback=5, cell_width=10, cell_height=20, options=None, content=()):
self.set_options(options)
c = Callbacks()
s = Screen(c, lines, cols, scrollback, cell_width, cell_height, 0, c)

View File

@ -304,7 +304,7 @@ class TestScreen(BaseTest):
self.ae(x_before, s.cursor.x)
def test_scrollback_fill_after_resize(self):
def prepare_screen(content=tuple()):
def prepare_screen(content=()):
return self.create_screen(
lines=5,
cols=5,