Make the tracker state change function re-useable
This commit is contained in:
parent
a8616f8598
commit
1ad4d52659
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "data-types.h"
|
||||
#include "tracker.h"
|
||||
#include <structmember.h>
|
||||
|
||||
#define RESET_STATE_VARS(self) \
|
||||
@ -60,37 +61,6 @@ reset(ChangeTracker *self) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static inline void tracker_cursor_changed(ChangeTracker *self) {
|
||||
self->cursor_changed = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
|
||||
static inline void tracker_line_added_to_history(ChangeTracker *self) {
|
||||
self->history_line_added_count++;
|
||||
self->dirty = true;
|
||||
}
|
||||
|
||||
static inline void tracker_update_screen(ChangeTracker *self) {
|
||||
self->screen_changed = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
|
||||
static inline void tracker_update_line_range(ChangeTracker *self, unsigned int first_line, unsigned int last_line) {
|
||||
if (!self->screen_changed) {
|
||||
for (unsigned int i = first_line; i <= MIN(self->ynum - 1, last_line); i++) self->changed_lines[i] = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tracker_update_cell_range(ChangeTracker *self, unsigned int line, unsigned int first_cell, unsigned int last_cell) {
|
||||
if (!self->screen_changed && line < self->ynum && !self->changed_lines[line]) {
|
||||
self->lines_with_changed_cells[line] = true;
|
||||
unsigned int base = line * self->xnum;
|
||||
for (unsigned int i = first_cell; i <= MIN(self->xnum - 1, last_cell); i++) self->changed_cells[base + i] = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
cursor_changed(ChangeTracker *self) {
|
||||
#define cursor_changed_doc ""
|
||||
|
||||
39
kitty/tracker.h
Normal file
39
kitty/tracker.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* tracker.h
|
||||
* Copyright (C) 2016 Kovid Goyal <kovid at kovidgoyal.net>
|
||||
*
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
static inline void tracker_cursor_changed(ChangeTracker *self) {
|
||||
self->cursor_changed = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
|
||||
static inline void tracker_line_added_to_history(ChangeTracker *self) {
|
||||
self->history_line_added_count++;
|
||||
self->dirty = true;
|
||||
}
|
||||
|
||||
static inline void tracker_update_screen(ChangeTracker *self) {
|
||||
self->screen_changed = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
|
||||
static inline void tracker_update_line_range(ChangeTracker *self, unsigned int first_line, unsigned int last_line) {
|
||||
if (!self->screen_changed) {
|
||||
for (unsigned int i = first_line; i <= MIN(self->ynum - 1, last_line); i++) self->changed_lines[i] = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tracker_update_cell_range(ChangeTracker *self, unsigned int line, unsigned int first_cell, unsigned int last_cell) {
|
||||
if (!self->screen_changed && line < self->ynum && !self->changed_lines[line]) {
|
||||
self->lines_with_changed_cells[line] = true;
|
||||
unsigned int base = line * self->xnum;
|
||||
for (unsigned int i = first_cell; i <= MIN(self->xnum - 1, last_cell); i++) self->changed_cells[base + i] = true;
|
||||
self->dirty = true;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user