]> git.neil.brown.name Git - edlib.git/commitdiff
Send point as ci->mark for events from keyboard or mouse.
authorNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 05:52:43 +0000 (16:52 +1100)
committerNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 06:16:25 +0000 (17:16 +1100)
I am deprecating ->pointp, but sometimes I need that mark.

Signed-off-by: NeilBrown <neil@brown.name>
core-keymap.c
core.h
display-ncurses.c

index d31f8ad9009f3be8e6f9238c3e9a61ed97e13a8f..380f1bc88c7ab8f454d324dc0c8bf47d2a12f8aa 100644 (file)
@@ -329,7 +329,7 @@ int key_handle(struct cmd_info *ci)
        return ret;
 }
 
-int key_handle_focus(struct cmd_info *ci)
+static int __key_handle_focus(struct cmd_info *ci, int savepoint)
 {
        /* Handle this in the focus pane, so x,y are irrelevant */
        struct pane *p = ci->focus;
@@ -339,13 +339,24 @@ int key_handle_focus(struct cmd_info *ci)
                if (p->point && !ci->pointp)
                        ci->pointp = &p->point;
                p = p->focus;
+               if (savepoint && p->point)
+                       ci->mark = &p->point->m;
        }
        ci->focus = p;
        ci->comm = NULL;
        return key_handle(ci);
 }
 
-int key_handle_xy(struct cmd_info *ci)
+int key_handle_focus(struct cmd_info *ci)
+{
+       return __key_handle_focus(ci, 0);
+}
+int key_handle_focus_point(struct cmd_info *ci)
+{
+       return __key_handle_focus(ci, 1);
+}
+
+static int __key_handle_xy(struct cmd_info *ci, int savepoint)
 {
        /* Handle this in child with x,y co-ords */
        struct pane *p = ci->focus;
@@ -372,6 +383,8 @@ int key_handle_xy(struct cmd_info *ci)
                x -= chld->x;
                y -= chld->y;
                p = chld;
+               if (savepoint && p->point)
+                       ci->mark = &p->point->m;
        }
        ci->x = x;
        ci->y = y;
@@ -379,3 +392,12 @@ int key_handle_xy(struct cmd_info *ci)
        ci->comm = NULL;
        return key_handle(ci);
 }
+
+int key_handle_xy(struct cmd_info *ci)
+{
+       return __key_handle_xy(ci, 0);
+}
+int key_handle_xy_point(struct cmd_info *ci)
+{
+       return __key_handle_xy(ci, 1);
+}
diff --git a/core.h b/core.h
index 6524fb1e4688c77ed81f9048ee45b1da4781f984..a6b8f5a57a96d6ef0e105d73b765c037dd64d435 100644 (file)
--- a/core.h
+++ b/core.h
@@ -276,6 +276,8 @@ void key_free(struct map *m);
 int key_handle(struct cmd_info *ci);
 int key_handle_focus(struct cmd_info *ci);
 int key_handle_xy(struct cmd_info *ci);
+int key_handle_focus_point(struct cmd_info *ci);
+int key_handle_xy_point(struct cmd_info *ci);
 int key_lookup(struct map *m, struct cmd_info *ci);
 struct command *key_lookup_cmd(struct map *m, char *c);
 void key_add(struct map *map, char *k, struct command *comm);
index 4753fdea469c328028893860b4eb49c872557eb6..d4165e8ce8cb01fcf09eb26adb3bcb80008e5813 100644 (file)
@@ -355,7 +355,7 @@ static void send_key(int keytype, wint_t c, struct pane *p)
        dd->dpy.mode = dd->dpy.next_mode;
        dd->dpy.numeric = NO_NUMERIC;
        dd->dpy.extra = 0;
-       key_handle_focus(&ci);
+       key_handle_focus_point(&ci);
 }
 
 static void do_send_mouse(struct pane *p, int x, int y, char *cmd)
@@ -373,7 +373,7 @@ static void do_send_mouse(struct pane *p, int x, int y, char *cmd)
        dd->dpy.mode = dd->dpy.next_mode;
        dd->dpy.numeric = NO_NUMERIC;
        dd->dpy.extra = 0;
-       key_handle_xy(&ci);
+       key_handle_xy_point(&ci);
 }
 
 static void send_mouse(MEVENT *mev, struct pane *p)