Scroll images with text

This commit is contained in:
Kovid Goyal 2017-10-05 20:23:32 +05:30
parent a4e7985fb0
commit 689227dce4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 27 additions and 5 deletions

View File

@ -620,6 +620,31 @@ grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float scree
// }}}
// Image lifetime/scrolling {{{
void
grman_scroll_images(GraphicsManager *self, int32_t amt, int32_t limit) {
Image *img; ImageRef *ref;
size_t i, j;
if (self->image_count) {
for (i = 0; i < self->image_count; i++) { img = self->images + i; for (j = 0; j < img->refcnt; j++) { ref = img->refs + j;
ref->start_row += amt;
if (ref->start_row < limit) {
// TODO: remove refs that have scrolled beyond limit
}
}}
self->layers_dirty = true;
}
}
void
grman_clear(GraphicsManager UNUSED *self) {
// TODO: Implement this
}
// }}}
const char*
grman_handle_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_t *payload, Cursor *c, bool *is_dirty) {
Image *image;
@ -647,11 +672,6 @@ grman_handle_command(GraphicsManager *self, const GraphicsCommand *g, const uint
return ret;
}
void
grman_clear(GraphicsManager UNUSED *self) {
// TODO: Implement this
}
// Boilerplate {{{
static PyObject *

View File

@ -79,3 +79,4 @@ GraphicsManager* grman_realloc(GraphicsManager *, index_type lines, index_type c
void grman_clear(GraphicsManager*);
const char* grman_handle_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_t *payload, Cursor *c, bool *is_dirty);
bool grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float screen_left, float screen_top, float dx, float dy, unsigned int num_cols, unsigned int num_rows);
void grman_scroll_images(GraphicsManager *self, int32_t amt, int32_t limit);

View File

@ -654,6 +654,7 @@ screen_cursor_to_column(Screen *self, unsigned int column) {
#define INDEX_UP \
linebuf_index(self->linebuf, top, bottom); \
grman_scroll_images(self->grman, -1, self->linebuf == self->main_linebuf ? -self->historybuf->ynum : 0); \
if (self->linebuf == self->main_linebuf && bottom == self->lines - 1) { \
/* Only add to history when no page margins have been set */ \
linebuf_init_line(self->linebuf, bottom); \