From de90650e3b00d3a879a061245bef5661a4b1dc82 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 11 Jan 2017 23:14:40 -0500 Subject: [PATCH] ctrl+d should select the command under cursor if nothing selected --- inc/edit.h | 1 + lib/view.c | 7 +++++++ xedit.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/edit.h b/inc/edit.h index f4aa893..f5e2de8 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -165,6 +165,7 @@ void view_redo(View* view); void view_putstr(View* view, char* str); void view_append(View* view, char* str); char* view_getstr(View* view, Sel* sel); +char* view_getcmd(View* view); char* view_getctx(View* view); void view_scroll(View* view, int move); void view_scrollpage(View* view, int move); diff --git a/lib/view.c b/lib/view.c index e5e486e..c51a1f5 100644 --- a/lib/view.c +++ b/lib/view.c @@ -541,6 +541,13 @@ char* view_getstr(View* view, Sel* range) { return str; } +char* view_getcmd(View* view) { + Sel sel = view->selection; + buf_getword(&(view->buffer), riscmd, &sel); + sel.end++; + return view_getstr(view, &sel); +} + char* view_getctx(View* view) { if (0 == num_selected(view->selection)) { selcontext(view, &(view->selection)); diff --git a/xedit.c b/xedit.c index c5fc344..a794466 100644 --- a/xedit.c +++ b/xedit.c @@ -552,7 +552,7 @@ static void search(void) { } static void execute(void) { - char* str = view_getstr(currview(), NULL); + char* str = view_getcmd(currview()); if (str) exec(str); free(str); } -- 2.54.0