]> git.mdlowis.com Git - projs/tide.git/commitdiff
tweaked copy command to select current line if nothing selected
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 18 May 2017 02:16:17 +0000 (22:16 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 18 May 2017 02:16:17 +0000 (22:16 -0400)
inc/shortcuts.h
lib/buf.c

index 91e1e42c93600bf51f0fe7d05afc102110e4b0df..0756d7370699dde7d9c59fc3a11470476726195c 100644 (file)
@@ -1,3 +1,9 @@
+static void select_line(void) {
+    View* view = win_view(FOCUSED);
+    view_eol(view, false);
+    view_selctx(view);
+}
+
 static void delete(void) {
     bool byword = x11_keymodsset(ModCtrl);
     view_delete(win_view(FOCUSED), RIGHT, byword);
@@ -8,14 +14,11 @@ static void onpaste(char* text) {
 }
 
 static void cut(void) {
-    View* view = win_view(FOCUSED);
     /* select the current line if no selection */
-    if (!view_selsize(view)) {
-        view_eol(view, false);
-        view_selctx(view);
-    }
+    if (!view_selsize(win_view(FOCUSED)))
+        select_line();
     /* now perform the cut */
-    char* str = view_getstr(view, NULL);
+    char* str = view_getstr(win_view(FOCUSED), NULL);
     x11_sel_set(CLIPBOARD, str);
     if (str && *str) delete();
 }
@@ -25,6 +28,9 @@ static void paste(void) {
 }
 
 static void copy(void) {
+    /* select the current line if no selection */
+    if (!view_selsize(win_view(FOCUSED)))
+        select_line();
     char* str = view_getstr(win_view(FOCUSED), NULL);
     x11_sel_set(CLIPBOARD, str);
 }
index e5afc32924f11ae75cec47422dcd4afa44136541..00655f14f8624967f29295c64627aaccd2407345 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -198,6 +198,7 @@ static size_t next_size(size_t curr) {
     int size = 1;
     while(size < curr)
         size = (size << 1);
+    return size;
 }
 
 unsigned buf_load(Buf* buf, char* path) {