Add historybuf_pop_line()

This commit is contained in:
Eddie Lebow 2021-03-09 23:33:50 -05:00
parent b76491ba82
commit 6c44b4f451
No known key found for this signature in database
GPG Key ID: 21A09CFD989FD546
2 changed files with 14 additions and 0 deletions

View File

@ -252,6 +252,19 @@ historybuf_add_line(HistoryBuf *self, const Line *line, ANSIBuf *as_ansi_buf) {
*attrptr(self, idx) = (line->continued & CONTINUED_MASK) | (line->has_dirty_text ? TEXT_DIRTY_MASK : 0); *attrptr(self, idx) = (line->continued & CONTINUED_MASK) | (line->has_dirty_text ? TEXT_DIRTY_MASK : 0);
} }
bool
historybuf_pop_line(HistoryBuf *self, Line *line) {
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;
}
static PyObject* static PyObject*
line(HistoryBuf *self, PyObject *val) { line(HistoryBuf *self, PyObject *val) {
#define line_doc "Return the line with line number val. This buffer grows upwards, i.e. 0 is the most recently added line" #define line_doc "Return the line with line number val. This buffer grows upwards, i.e. 0 is the most recently added line"

View File

@ -101,6 +101,7 @@ void linebuf_mark_line_as_not_continued(LineBuf *self, index_type y);
unsigned int linebuf_char_width_at(LineBuf *self, index_type x, index_type y); unsigned int linebuf_char_width_at(LineBuf *self, index_type x, index_type y);
void linebuf_refresh_sprite_positions(LineBuf *self); void linebuf_refresh_sprite_positions(LineBuf *self);
void historybuf_add_line(HistoryBuf *self, const Line *line, ANSIBuf*); void historybuf_add_line(HistoryBuf *self, const Line *line, ANSIBuf*);
bool historybuf_pop_line(HistoryBuf *, Line *);
void historybuf_rewrap(HistoryBuf *self, HistoryBuf *other, ANSIBuf*); void historybuf_rewrap(HistoryBuf *self, HistoryBuf *other, ANSIBuf*);
void historybuf_init_line(HistoryBuf *self, index_type num, Line *l); void historybuf_init_line(HistoryBuf *self, index_type num, Line *l);
CPUCell* historybuf_cpu_cells(HistoryBuf *self, index_type num); CPUCell* historybuf_cpu_cells(HistoryBuf *self, index_type num);