static unsigned scroll_dn(View* view);
static void sync_center(View* view, size_t csr);
static size_t getoffset(View* view, size_t row, size_t col);
+static void sync_line_numbers(View* view);
void view_init(View* view, char* file, void (*errfn)(char*)) {
if (view->nrows) {
return found;
}
-static void update_lines(View* view) {
- if (!view->nrows ||
- view->selection.beg <= view->rows[0]->off ||
- view->selection.end <= view->rows[0]->off)
- view->sync_lines = true;
-}
-
void view_insert(View* view, bool indent, Rune rune) {
/* ignore non-printable control characters */
if (!isspace(rune) && rune < 0x20)
return;
-
- update_lines(view);
-
+ sync_line_numbers(view);
if (num_selected(view->selection)) {
Sel sel = view->selection;
selswap(&sel);
}
void view_delete(View* view, int dir, bool byword) {
- update_lines(view);
-
+ sync_line_numbers(view);
Sel* sel = &(view->selection);
if (sel->beg == sel->end)
(byword ? view_byword : view_byrune)(view, dir, true);
return buf_end(&(view->buffer));
return pos;
}
+
+static void sync_line_numbers(View* view) {
+ if (!view->nrows ||
+ view->selection.beg <= view->rows[0]->off ||
+ view->selection.end <= view->rows[0]->off)
+ view->sync_lines = true;
+}