void view_putstr(View* view, char* str);
char* view_getstr(View* view, Sel* sel);
char* view_getcmd(View* view);
+char* view_getword(View* view);
char* view_getctx(View* view);
void view_selctx(View* view);
void view_scroll(View* view, int move);
void view_jumpto(View* view, bool extsel, size_t off);
void view_scrollto(View* view, size_t csr);
Rune view_getrune(View* view);
+void view_selectall(View* view);
+void view_selectobj(View* view, bool (*istype)(Rune));
/* Command Executions
*****************************************************************************/
}
}
+void view_selectall(View* view) {
+ view->selection = (Sel){ .beg = 0, .end = buf_end(&(view->buffer)) };
+ view->sync_needed = true;
+}
+
+void view_selectobj(View* view, bool (*istype)(Rune)) {
+ buf_getword(&(view->buffer), istype, &(view->selection));
+ view->sync_needed = true;
+}
+
static void move_selection(View* view, bool extsel, Sel* sel, int move, movefn_t bything) {
view->sync_needed = true;
if (num_selected(*sel) && !extsel) {
Keys = bindings;
CurrFont = x11_font_load(FontString);
View* view = win_view(TAGS);
- view->buffer.gapstart = view->buffer.bufstart;
- view->buffer.gapend = view->buffer.bufend;
- view->selection = (Sel){0,0,0};
view_putstr(view, TagString);
view_selprev(view); // clear the selection
buf_logclear(&(view->buffer));
uint64_t now = getmillis();
if (!win_buf(EDIT)->modified || (now-before) <= (uint64_t)ClickTime)
exit(0);
-// else
-// view_append(win_view(TAGS), "File is modified.");
before = now;
}
}
static void select_all(char* arg) {
- View* view = win_view(FOCUSED);
- view_jumpto(view, false, buf_end(&(view->buffer)));
- view->selection.beg = 0;
+ view_selectall(win_view(FOCUSED));
}
static void join_lines(char* arg) {
/* now perform the cut */
char* str = view_getstr(view, NULL);
x11_sel_set(CLIPBOARD, str);
- if (str && *str) {
- delete(arg);
- if (view->selection.end == buf_end(&(view->buffer)))
- view_delete(view, LEFT, false);
- }
+ if (str && *str) delete(arg);
}
void paste(char* arg) {
/* get the selection that the command will operate on */
if (op && op != '<' && op != '!' && 0 == view_selsize(win_view(EDIT)))
- win_view(EDIT)->selection = (Sel){ .beg = 0, .end = buf_end(win_buf(EDIT)) };
+ view_selectall(win_view(EDIT));
char* input = view_getstr(win_view(EDIT), NULL);
size_t len = (input ? strlen(input) : 0);
View *tags = win_view(TAGS), *edit = win_view(EDIT), *curr = win_view(FOCUSED);
static void complete(char* arg) {
View* view = win_view(FOCUSED);
- buf_getword(&(view->buffer), risword, &(view->selection));
- view->selection.end = buf_byrune(&(view->buffer), view->selection.end, RIGHT);
+ view_selectobj(view, risword);
+ view_byrune(view, RIGHT, true);
cmd_execwitharg(CMD_COMPLETE, view_getstr(view, NULL));
}
if (x11_keymodsset(ModShift)) {
view_byline(view, UP, false);
view_bol(view, false);
- if (view->selection.end == 0) {
- view_insert(view, true, '\n');
- view->selection = (Sel){0,0,0};
- return;
- }
}
view_eol(view, false);
view_insert(view, true, '\n');