<p>The modifications below provide:</p>
<ol>
<li>While calling the popup menu:
<ul>
<li>all find and context menu items are enabled if there is a selected text / caret-set word and there is a defined context action</li>
<li>if there is a defined context action and no selected text/word, the find items are disabled and the context item is enabled</li>
<li>if there is a selected text/word and no defined context action,the  find items are enabled and the context item is disabled</li>
<li>if there is no selected text/word and no defined context action, the find items  and the context item are disabled</li>
</ul>
</li>
<li>While pressing a context hotkey:
<ul>
<li>if there is a defined context action, the context action is executed</li>
</ul>
</li>
<li>The context action string can contain the %f, %d, %e, %p, &l wildcards.</li>
</ol>
<p><strong>ui_utils.h</strong></p>
<pre><code>void ui_update_popup_goto_items(gchar* enable);
</code></pre>
<p><strong>ui_utils.c</strong></p>
<pre><code>void ui_update_popup_goto_items(gchar* enable)
{
    guint i, len;
    len = G_N_ELEMENTS(widgets.popup_goto_items);
    for (i = 0; i < len; i++)
        ui_widget_set_sensitive(widgets.popup_goto_items[i], enable[i]=='1');
}
</code></pre>
<p><strong>keybindings.c</strong></p>
<pre><code>case GEANY_KEYS_EDITOR_CONTEXTACTION:
    //if (check_current_word(doc, FALSE))
        on_context_action1_activate(GTK_MENU_ITEM(ui_lookup_widget(main_widgets.editor_menu,
            "context_action1")), NULL);
</code></pre>
<p><strong>editor.c</strong></p>
<pre><code>gchar cangos[64];//never reachable maximum
for (gint i=0; i<64; i++) cangos[i]=(can_goto?'1':'0'); //apl
gchar* command;
if (doc->file_type != NULL &&
!EMPTY(doc->file_type->context_action_cmd))
    command = g_strdup(doc->file_type->context_action_cmd);
else
    command = g_strdup(tool_prefs.context_action_cmd);
cangos[1] = (G_LIKELY(!EMPTY(command))?'1':'0'); //flag the context action
g_free(command);

ui_update_popup_goto_items(cangos);
</code></pre>
<p><strong>callbacks.c</strong></p>
<pre><code>{
    editor_find_current_word_sciwc(doc->editor, -1,
        editor_info.current_word, GEANY_MAX_WORD_LENGTH);
    word = g_strdup(editor_info.current_word);
}
<..>
    gchar *command_tmp = g_strdup(command); //==
    gchar *command_line = build_replace_placeholder(doc, command_tmp); //==
    g_free(command_tmp); //==

    utils_str_replace_all(&command_line, "%s", word);
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1836#issuecomment-383682065">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ6YSyNkVjg9Jo6ENV0ULjlRy6g7qks5triK_gaJpZM4Td5qs">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABDrJywjJ2RBje8z29YdpShYCTHst0goks5triK_gaJpZM4Td5qs.gif" height="1" width="1" alt="" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/1836#issuecomment-383682065"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@aplsimple in #1836: The modifications below provide:\r\n1. While calling the popup menu:\r\n   - all find and context menu items are enabled if there is a selected text / caret-set word and there is a defined context action\r\n   - if there is a defined context action and no selected text/word, the find items are disabled and the context item is enabled\r\n   - if there is a selected text/word and no defined context action,the  find items are enabled and the context item is disabled\r\n   - if there is no selected text/word and no defined context action, the find items  and the context item are disabled\r\n2. While pressing a context hotkey:\r\n   - if there is a defined context action, the context action is executed\r\n3. The context action string can contain the %f, %d, %e, %p, \u0026l wildcards.\r\n\r\n**ui_utils.h**\r\n\r\n    void ui_update_popup_goto_items(gchar* enable);\r\n\r\n**ui_utils.c**\r\n\r\n    void ui_update_popup_goto_items(gchar* enable)\r\n    {\r\n        guint i, len;\r\n        len = G_N_ELEMENTS(widgets.popup_goto_items);\r\n        for (i = 0; i \u003c len; i++)\r\n            ui_widget_set_sensitive(widgets.popup_goto_items[i], enable[i]=='1');\r\n    }\r\n\r\n\r\n**keybindings.c**\r\n\r\n    case GEANY_KEYS_EDITOR_CONTEXTACTION:\r\n        //if (check_current_word(doc, FALSE))\r\n            on_context_action1_activate(GTK_MENU_ITEM(ui_lookup_widget(main_widgets.editor_menu,\r\n                \"context_action1\")), NULL);\r\n\r\n\r\n**editor.c**\r\n\r\n\r\n    gchar cangos[64];//never reachable maximum\r\n    for (gint i=0; i\u003c64; i++) cangos[i]=(can_goto?'1':'0'); //apl\r\n    gchar* command;\r\n    if (doc-\u003efile_type != NULL \u0026\u0026\r\n    !EMPTY(doc-\u003efile_type-\u003econtext_action_cmd))\r\n        command = g_strdup(doc-\u003efile_type-\u003econtext_action_cmd);\r\n    else\r\n        command = g_strdup(tool_prefs.context_action_cmd);\r\n    cangos[1] = (G_LIKELY(!EMPTY(command))?'1':'0'); //flag the context action\r\n    g_free(command);\r\n    \r\n    ui_update_popup_goto_items(cangos);\r\n\r\n\r\n**callbacks.c**\r\n\r\n    {\r\n        editor_find_current_word_sciwc(doc-\u003eeditor, -1,\r\n            editor_info.current_word, GEANY_MAX_WORD_LENGTH);\r\n        word = g_strdup(editor_info.current_word);\r\n    }\r\n    \u003c..\u003e\r\n        gchar *command_tmp = g_strdup(command); //==\r\n        gchar *command_line = build_replace_placeholder(doc, command_tmp); //==\r\n        g_free(command_tmp); //==\r\n\r\n        utils_str_replace_all(\u0026command_line, \"%s\", word);\r\n"}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1836#issuecomment-383682065"}}}</script>