[Github-comments] [geany/geany] Geany's context again (#1836)

aplsimple notifications at xxxxx
Mon Apr 23 18:51:43 UTC 2018


The modifications below provide:
1. While calling the popup menu:
   - all find and context menu items are enabled if there is a selected text / caret-set word and there is a defined context action
   - if there is a defined context action and no selected text/word, the find items are disabled and the context item is enabled
   - if there is a selected text/word and no defined context action,the  find items are enabled and the context item is disabled
   - if there is no selected text/word and no defined context action, the find items  and the context item are disabled
2. While pressing a context hotkey:
   - if there is a defined context action, the context action is executed
3. The context action string can contain the %f, %d, %e, %p, &l wildcards.

**ui_utils.h**

    void ui_update_popup_goto_items(gchar* enable);

**ui_utils.c**

    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');
    }


**keybindings.c**

    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);


**editor.c**


    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);


**callbacks.c**

    {
        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);


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/1836#issuecomment-383682065
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20180423/fed4e37f/attachment.html>


More information about the Github-comments mailing list