]> git.neil.brown.name Git - edlib.git/commitdiff
Introduce ThisPane
authorNeilBrown <neil@brown.name>
Wed, 25 Nov 2015 08:52:38 +0000 (19:52 +1100)
committerNeilBrown <neil@brown.name>
Wed, 25 Nov 2015 09:07:19 +0000 (20:07 +1100)
This is similar to "OtherPane" but find the current tile.

popup uses this if it want to make a popup that is over a doc instead of
over the display.

This removes another use of ->point

Signed-off-by: NeilBrown <neil@brown.name>
lib-popup.c
lib-tile.c

index 096a0234c8d248f501add2a7281f9c1fd434ffbb..25b6fb0492d1b09ff089733db6b4029f9c3ca40f 100644 (file)
@@ -135,23 +135,18 @@ DEF_CMD(popup_attach)
 
        if (!style)
                style = "D3";
+
        if (strchr(style, 'D')) {
-               struct cmd_info ci2 = {0};
                int x = 0, y = 0;
                pane_to_root(ci->focus, &x, &y, &z, NULL, NULL);
                ci2.key = "global-key-root";
-               ci2.focus = ci->focus;
-               if (!key_handle_focus(&ci2))
-                       return 0;
-               root = ci2.focus;
-       } else {
-               p = ci->focus;
-               while (p && !p->point)
-                       p = p->parent;
-               if (!p || !p->parent)
-                       return 0;
-               root = p->parent;
-       }
+       } else
+               ci2.key = "ThisPane";
+       ci2.focus = ci->focus;
+
+       if (!key_handle_focus(&ci2))
+               return 0;
+       root = ci2.focus;
 
        ppi->target = ci->focus;
        ppi->popup = pane_register(root, z, &popup_handle, ppi, NULL);
@@ -178,6 +173,7 @@ DEF_CMD(popup_attach)
                p = doc_attach_view(ppi->popup, dp, NULL);
        }
        pane_focus(p);
+       memset(&ci2, 0, sizeof(ci2));
        ci2.key = "local-set-key";
        ci2.focus = p;
        ci2.str = "popup:quote";
index 1c190b5165df2105411e8a4a0cd1d3ea3f143898..e71e5c26235c232ef1cf86576ae1c65855d78162 100644 (file)
@@ -572,12 +572,19 @@ DEF_CMD(tile_other)
        return 1;
 }
 
+DEF_CMD(tile_this)
+{
+       ci->focus = ci->home;
+       return 1;
+}
+
 void edlib_init(struct editor *ed)
 {
        tile_map = key_alloc();
 
        key_add(tile_map, "WindowOP", &tile_command);
        key_add(tile_map, "OtherPane", &tile_other);
+       key_add(tile_map, "ThisPane", &tile_this);
 
        key_add(ed->commands, "attach-tile", &tile_attach);
 }