void view_putstr(View* view, char* str);
char* view_getstr(View* view, Sel* sel);
void view_scroll(View* view, int move);
+void view_scrollpage(View* view, int move);
/* Command Executions
*****************************************************************************/
char utf[UTF_MAX] = {0};
size_t len = 0;
char* str = NULL;
- for (; sel.beg <= sel.end; sel.beg++) {
+ for (; sel.beg < sel.end; sel.beg++) {
Rune rune = buf_get(buf, sel.beg);
if (rune == RUNE_CRLF) {
str = realloc(str, len + 2);
}
void view_scroll(View* view, int move) {
- if (move < 0)
- scroll_up(view);
- else
- scroll_dn(view);
+ int dir = (move < 0 ? -1 : 1);
+ move *= dir;
+ for (int i = 0; i < move; i++) {
+ if (dir < 0)
+ scroll_up(view);
+ else
+ scroll_dn(view);
+ }
+}
+
+void view_scrollpage(View* view, int move) {
+ move = (move < 0 ? -1 : 1) * view->nrows;
+ view_scroll(view, move);
}
view_eol(currview());
}
+static void page_up(void) {
+ view_scrollpage(currview(), -1);
+}
+
+static void page_dn(void) {
+ view_scrollpage(currview(), +1);
+}
+
static void change_focus(void) {
if (Focused == TAGS) {
if (TagWinExpanded) {
static void cut(void) {
char* str = view_getstr(currview(), NULL);
- cmdwrite(CopyCmd, str);
+ if (str && *str) {
+ cmdwrite(CopyCmd, str);
+ delete();
+ }
free(str);
- delete();
}
static void copy(void) {
+ if (str && *str)
char* str = view_getstr(currview(), NULL);
- cmdwrite(CopyCmd, str);
+ cmdwrite(CopyCmd, str);
free(str);
}
static void mouse_middle(enum RegionId id, size_t count, size_t row, size_t col) {
if (MouseBtns[MOUSE_BTN_LEFT].pressed)
- puts("cut");
- // cut();
+ cut();
else
puts("exec");
// view_exec(getview(id), row, col);
static void mouse_right(enum RegionId id, size_t count, size_t row, size_t col) {
if (MouseBtns[MOUSE_BTN_LEFT].pressed)
- puts("paste");
- // paste();
+ paste();
else
puts("find");
// view_find(getview(id), row, col);
{ KEY_RIGHT, cursor_right },
{ KEY_HOME, cursor_bol },
{ KEY_END, cursor_eol },
+ { KEY_PGUP, page_up },
+ { KEY_PGDN, page_dn },
{ KEY_CTRL_T, change_focus },
{ KEY_CTRL_Q, quit },
{ KEY_CTRL_S, save },