size_t buf_selbeg(Buf* buf);
size_t buf_selsz(Buf* buf);
+void buf_selln(Buf* buf);
void buf_selclr(Buf* buf, int dir);
bool buf_insel(Buf* buf, size_t off);
char* buf_fetch(Buf* buf, bool (*isword)(Rune), size_t off);
return sel.end - sel.beg;
}
+void buf_selln(Buf* buf) {
+ /* swap the direction of the selection so beg < end */
+ if (buf->selection.beg > buf->selection.end) {
+ size_t off = buf->selection.beg;
+ buf->selection.beg = buf->selection.end;
+ buf->selection.end = off;
+ }
+
+ /* Expand the selection to completely select the lines covered */
+ buf->selection.beg = buf_bol(buf, buf->selection.beg);
+ if (!buf_iseol(buf, buf->selection.end-1) || buf->selection.end == buf->selection.beg) {
+ buf->selection.end = buf_eol(buf, buf->selection.end);
+ buf->selection.end = buf_byrune(buf, buf->selection.end, RIGHT);
+ }
+}
+
void buf_selclr(Buf* buf, int dir) {
if (dir > 0)
buf->selection.beg = buf->selection.end;
void view_setln(View* view, size_t line) {
buf_setln(BUF, line);
view->sync_flags |= CENTER;
+ buf_selln(BUF);
}
void view_undo(View* view) {
/* Keyboard and Tag Handlers
******************************************************************************/
static void select_line(char* arg) {
- Buf* buf = win_buf(FOCUSED);
- /* swap the direction of the selection so beg < end */
- if (buf->selection.beg > buf->selection.end) {
- size_t off = buf->selection.beg;
- buf->selection.beg = buf->selection.end;
- buf->selection.end = off;
- }
-
- /* Expand the selection to completely select the lines covered */
- buf->selection.beg = buf_bol(buf, buf->selection.beg);
- if (!buf_iseol(buf, buf->selection.end-1) || buf->selection.end == buf->selection.beg) {
- buf->selection.end = buf_eol(buf, buf->selection.end);
- buf->selection.end = buf_byrune(buf, buf->selection.end, RIGHT);
- }
+ buf_selln(win_buf(FOCUSED));
}
static void join_lines(char* arg) {