void view_indent(View* view, int dir);
size_t view_selsize(View* view);
void view_selprev(View* view);
-void view_setcursor(View* view, size_t row, size_t col);
-void view_selext(View* view, size_t row, size_t col);
+void view_setcursor(View* view, size_t row, size_t col, bool extsel);
void view_selextend(View* view, size_t row, size_t col);
void view_selword(View* view, size_t row, size_t col);
void view_select(View* view, size_t row, size_t col);
void view_byrune(View* view, int move, bool extsel) {
move_selection(view, extsel, &(view->selection), move, buf_byrune);
- view->sync_needed = true;
}
void view_byword(View* view, int move, bool extsel) {
move_selection(view, extsel, &(view->selection), move, buf_byword);
- view->sync_needed = true;
}
void view_byline(View* view, int move, bool extsel) {
move_selection(view, extsel, &(view->selection), move, buf_byline);
- view->sync_needed = true;
-}
-
-void view_setcursor(View* view, size_t row, size_t col) {
- size_t off = getoffset(view, row, col);
- if (off != SIZE_MAX)
- view_jumpto(view, false, off);
}
-void view_selext(View* view, size_t row, size_t col) {
+void view_setcursor(View* view, size_t row, size_t col, bool extsel) {
size_t off = getoffset(view, row, col);
if (off != SIZE_MAX)
- view_jumpto(view, true, off);
+ view_jumpto(view, extsel, off);
}
void view_selword(View* view, size_t row, size_t col) {
buf_loglock(&(view->buffer));
if (row != SIZE_MAX && col != SIZE_MAX)
- view_setcursor(view, row, col);
+ view_setcursor(view, row, col, false);
Sel sel = view->selection;
buf_getword(&(view->buffer), risbigword, &(sel));
sel.end++;
void view_select(View* view, size_t row, size_t col) {
buf_loglock(&(view->buffer));
- view_setcursor(view, row, col);
+ view_setcursor(view, row, col, false);
Sel sel = view->selection;
select_context(view, risword, &sel);
view->selection = sel;
}
static void move_selection(View* view, bool extsel, Sel* sel, int move, movefn_t bything) {
+ view->sync_needed = true;
if (num_selected(*sel) && !extsel) {
selswap(sel);
if (move == RIGHT || move == DOWN)
Regions[EDIT].clrcsr = Colors[ClrEditCsr];
}
-void win_load(char* path) {
- View* view = win_view(EDIT);
- view_init(view, path, view->buffer.errfn);
- path = view->buffer.path;
-}
-
void win_save(char* path) {
View* view = win_view(EDIT);
if (!path) path = view->buffer.path;
}
void win_loop(void) {
- /* simulate an initial resize and map the window */
- XConfigureEvent ce;
- ce.type = ConfigureNotify;
- ce.width = X.width;
- ce.height = X.height;
- XSendEvent(X.display, X.self, False, StructureNotifyMask, (XEvent *)&ce);
XMapWindow(X.display, X.self);
-
while (Running) {
bool pending = job_poll(ConnectionNumber(X.display), Timeout);
int nevents = XEventsQueued(X.display, QueuedAfterFlush);
size_t row = (y-Regions[Focused].y) / x11_font_height(CurrFont);
size_t col = (x-Regions[Focused].x) / x11_font_width(CurrFont);
if (win_btnpressed(MouseLeft))
- view_selext(win_view(Focused), row, col);
+ view_setcursor(win_view(Focused), row, col, true);
}
static void onmousebtn(int btn, bool pressed, int x, int y) {
before = now;
if (count == 1) {
- if (x11_keymodsset(ModShift))
- view_selext(win_view(id), row, col);
- else
- view_setcursor(win_view(id), row, col);
+ view_setcursor(win_view(id), row, col, x11_keymodsset(ModShift));
} else if (count == 2) {
view_select(win_view(id), row, col);
} else if (count == 3) {
else
strconcat(currpath, fname, 0);
chdir(currdir);
- win_load(currpath);
+ view_init(win_view(EDIT), currpath, ondiagmsg);
} else {
chdir(origdir);
- win_load(path);
+ view_init(win_view(EDIT), path, ondiagmsg);
}
/* cleanup */