From: Michael D. Lowis Date: Mon, 9 Apr 2018 12:53:03 +0000 (-0400) Subject: merge changes X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0e56e4ead4b8bcd1f6495dd7fc52a2ac86b118cc;p=projs%2Ftide.git merge changes --- 0e56e4ead4b8bcd1f6495dd7fc52a2ac86b118cc diff --cc lib/buf.c index 222d238,45e6562..84713ae --- a/lib/buf.c +++ b/lib/buf.c @@@ -272,8 -279,10 +280,10 @@@ void buf_selctx(Buf* buf, bool (*isword 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 @@@ -417,16 -426,16 +427,24 @@@ bool buf_insel(Buf* buf, size_t off) 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;