selblock(buf, '[', ']');
else if (r == '{' || r == '}')
selblock(buf, '{', '}');
+ else if (r == '<' || r == '>')
+ selblock(buf, '<', '>');
else if (buf->selection.end == bol || r == '\n')
- buf_selline(buf);
+ selline(buf);
else if (risword(r))
buf_selword(buf, isword);
else
return (off >= sel.beg && off < sel.end);
}
+ char* buf_fetch(Buf* buf, bool (*isword)(Rune), size_t off) {
+ if (!buf_insel(buf, off)) {
+ buf->selection = (Sel){ .beg = off, .end = off };
+ buf_selword(buf, isword);
+ }
+ return buf_gets(buf);
+ }
+
/******************************************************************************/
+static void selline(Buf* buf) {
+ Sel sel = getsel(buf);
+ sel.beg = buf_bol(buf, sel.end);
+ sel.end = buf_eol(buf, sel.end);
+ sel.end = buf_byrune(buf, sel.end, RIGHT);
+ buf->selection = sel;
+}
+
static void selblock(Buf* buf, Rune first, Rune last) {
Sel sel = getsel(buf);
int balance = 0, dir;