## STAGING
+* tide: refactor selection handling and column tracking out of view.c
* all: eliminate multiple return statements and other lint
* tide: byrune, byword, byline functions should be hidden in buf.c
* tide: column tracking should be hidden in buf.c
return (sel.end < sel.beg ? selswap(sel) : sel);
}
+static void selset(Buf* buf, Sel sel)
+{
+ buf->selection = sel;
+ buf_getcol(buf);
+}
+
+
static void putch(Buf* buf, char b, Sel* p_sel)
{
if (b != '\r')
{
sel = selswap(sel);
}
- buf->selection = sel;
+ selset(buf, sel);
}
int buf_save(Buf* buf, char* path)
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;
+ selset(buf, sel);
}
static void selblock(Buf* buf, Rune first, Rune last)
{
selline(buf);
}
-
else if (selquote(buf, '"') || selquote(buf, '`') || selquote(buf, '\''))
{
; /* condition performs selection */
sel.end = buf_eol(buf, sel.end);
sel.end = buf_byrune(buf, sel.end, RIGHT);
}
- buf->selection = sel;
+ selset(buf, sel);
}
void buf_selclr(Buf* buf, int dir)
{
sel.end = sel.beg;
}
- buf->selection = sel;
+ selset(buf, sel);
}
bool buf_insel(Buf* buf, size_t off)
if (buf_selsz(BUF) && !extsel)
{
buf_selclr(BUF, move);
- buf_getcol(BUF);
if (bything == buf_byline)
{
CSRPOS = bything(BUF, CSRPOS, move);
{
buf_selclr(BUF, (move < 0 ? LEFT : RIGHT));
}
-
- /* only update column if not moving vertically */
- if (bything != buf_byline)
- {
- buf_getcol(BUF);
- }
}
}