unsigned buf_byline(Buf* buf, unsigned pos, int count);
unsigned buf_getcol(Buf* buf, unsigned pos);
unsigned buf_setcol(Buf* buf, unsigned pos, unsigned col);
-char* buf_getstr(Buf* buf, unsigned beg, unsigned end);
-unsigned buf_putstr(Buf* buf, unsigned beg, unsigned end, char* str);
+void buf_lastins(Buf* buf, size_t* beg, size_t* end);
+void buf_loglock(Buf* buf);
/*
void buf_load(Buf* buf, char* path);
void view_setcursor(View* view, size_t row, size_t col);
void view_selext(View* view, size_t row, size_t col);
void view_selword(View* view, size_t row, size_t col);
+void view_selprev(View* view);
void view_select(View* view, size_t row, size_t col);
char* view_fetch(View* view, size_t row, size_t col);
void view_find(View* view, size_t row, size_t col);
}
return curr;
}
+
+void buf_lastins(Buf* buf, size_t* beg, size_t* end) {
+ Log* log = buf->undo;
+ while (log) {
+ if (log->insert)
+ break;
+ log = log->next;
+ }
+ if (log) {
+ *beg = log->data.ins.beg;
+ *end = log->data.ins.end;
+ }
+}
+
+void buf_loglock(Buf* buf) {
+ if (buf->undo)
+ buf->undo->locked = true;
+}
view->selection = sel;
}
+void view_selprev(View* view) {
+ Sel sel = view->selection;
+ buf_lastins(&(view->buffer), &sel.beg, &sel.end);
+ view->selection = sel;
+}
+
void view_select(View* view, size_t row, size_t col) {
view_setcursor(view, row, col);
Sel sel = view->selection;
}
void view_putstr(View* view, char* str) {
+ buf_loglock(&(view->buffer));
while (*str) {
Rune rune = 0;
size_t length = 0;
while (!utf8decode(&rune, &length, *str++));
view_insert(view, rune);
}
+ buf_loglock(&(view->buffer));
}
char* view_getstr(View* view, Sel* range) {
static void cursor_eol(void);
static void page_up(void);
static void page_dn(void);
+static void select_prev(void);
static void change_focus(void);
static void quit(void);
static void save(void);
{ KEY_END, cursor_eol },
{ KEY_PGUP, page_up },
{ KEY_PGDN, page_dn },
+ { KEY_ESCAPE, select_prev },
{ KEY_CTRL_T, change_focus },
{ KEY_CTRL_Q, quit },
{ KEY_CTRL_S, save },
view_scrollpage(currview(), +1);
}
+static void select_prev(void) {
+ view_selprev(currview());
+}
+
static void change_focus(void) {
Focused = (Focused == TAGS ? EDIT : TAGS);
}