From: NeilBrown Date: Wed, 25 Nov 2015 08:52:38 +0000 (+1100) Subject: Introduce ThisPane X-Git-Tag: lca2016~235 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=d718a70eaa727908fca63864375fb03eb49dabad;p=edlib.git Introduce ThisPane 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 --- diff --git a/lib-popup.c b/lib-popup.c index 096a0234..25b6fb04 100644 --- a/lib-popup.c +++ b/lib-popup.c @@ -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"; diff --git a/lib-tile.c b/lib-tile.c index 1c190b51..e71e5c26 100644 --- a/lib-tile.c +++ b/lib-tile.c @@ -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); }