Esempio n. 1
0
static void
load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg)
{
    gchar **profile_keys, **keys;

    if (section_name == NULL)
        return;

    keys = mc_config_get_keys (cfg, section_name, NULL);

    for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
    {
        gchar **values;

        values = mc_config_get_string_list (cfg, section_name, *profile_keys, NULL);
        if (values != NULL)
        {
            int action;

            action = keybind_lookup_action (*profile_keys);
            if (action > 0)
            {
                gchar **curr_values;

                for (curr_values = values; *curr_values != NULL; curr_values++)
                    keybind_cmd_bind (keymap, *curr_values, action);
            }

            g_strfreev (values);
        }
    }

    g_strfreev (keys);
}
Esempio n. 2
0
static void
load_keys_from_section (const char *terminal, mc_config_t * cfg)
{
    char *section_name;
    gchar **profile_keys, **keys;
    char *valcopy, *value;
    long key_code;

    if (terminal == NULL)
        return;

    section_name = g_strconcat ("terminal:", terminal, (char *) NULL);
    keys = mc_config_get_keys (cfg, section_name, NULL);

    for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
    {
        /* copy=other causes all keys from [terminal:other] to be loaded. */
        if (g_ascii_strcasecmp (*profile_keys, "copy") == 0)
        {
            valcopy = mc_config_get_string (cfg, section_name, *profile_keys, "");
            load_keys_from_section (valcopy, cfg);
            g_free (valcopy);
            continue;
        }

        key_code = lookup_key (*profile_keys, NULL);
        if (key_code != 0)
        {
            gchar **values;

            values = mc_config_get_string_list (cfg, section_name, *profile_keys, NULL);
            if (values != NULL)
            {
                gchar **curr_values;

                for (curr_values = values; *curr_values != NULL; curr_values++)
                {
                    valcopy = convert_controls (*curr_values);
                    define_sequence (key_code, valcopy, MCKEY_NOACTION);
                    g_free (valcopy);
                }

                g_strfreev (values);
            }
            else
            {
                value = mc_config_get_string (cfg, section_name, *profile_keys, "");
                valcopy = convert_controls (value);
                define_sequence (key_code, valcopy, MCKEY_NOACTION);
                g_free (valcopy);
                g_free (value);
            }
        }
    }
    g_strfreev (keys);
    g_free (section_name);
}
Esempio n. 3
0
static void
load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg)
{
    gchar **profile_keys, **keys;
    gchar **values, **curr_values;
    char *valcopy, *value;
    int action;
    gsize len, values_len;

    if (section_name == NULL)
        return;

    profile_keys = keys = mc_config_get_keys (cfg, section_name, &len);

    while (*profile_keys != NULL)
    {
        curr_values = values =
                          mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);

        action = keybind_lookup_action (*profile_keys);

        if (action > 0)
        {
            if (curr_values != NULL)
            {
                while (*curr_values != NULL)
                {
                    valcopy = convert_controls (*curr_values);
                    keybind_cmd_bind (keymap, valcopy, action);
                    g_free (valcopy);
                    curr_values++;
                }
            }
            else
            {
                value = mc_config_get_string (cfg, section_name, *profile_keys, "");
                valcopy = convert_controls (value);
                /* define_sequence (key_code, valcopy, MCKEY_NOACTION); */
                g_free (valcopy);
                g_free (value);
            }
        }

        profile_keys++;
        g_strfreev (values);
    }
    g_strfreev (keys);
}
Esempio n. 4
0
static gboolean
mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
{
    mc_fhl_filter_t *mc_filter;
    gchar **exts, **exts_orig;
    gsize exts_size;
    GString *buf;

    exts_orig = exts =
        mc_config_get_string_list (fhl->config, group_name, "extensions", &exts_size);

    if (exts_orig == NULL || exts_orig[0] == NULL)
    {
        g_strfreev (exts_orig);
        return FALSE;
    }

    buf = g_string_sized_new (64);
    for (exts = exts_orig; *exts != NULL; exts++)
    {
        char *esc_ext;

        esc_ext = strutils_regex_escape (*exts);
        if (buf->len != 0)
            g_string_append_c (buf, '|');
        g_string_append (buf, esc_ext);
        g_free (esc_ext);
    }
    g_strfreev (exts_orig);

    g_string_prepend (buf, ".*\\.(");
    g_string_append (buf, ")$");

    mc_filter = g_new0 (mc_fhl_filter_t, 1);
    mc_filter->type = MC_FLHGH_T_FREGEXP;
    mc_filter->search_condition = mc_search_new (buf->str, -1);
    mc_filter->search_condition->is_case_sensitive =
        mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE);
    mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;

    mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
    g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
    g_string_free (buf, TRUE);
    return TRUE;
}
Esempio n. 5
0
static mc_skin_color_t *
mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
    gsize items_count;
    gchar **values;
    mc_skin_color_t *mc_skin_color, *tmp;

    values = mc_config_get_string_list (mc_skin->config, group, key, &items_count);
    if (values == NULL || values[0] == NULL)
    {
        g_strfreev (values);
        return NULL;
    }

    mc_skin_color = g_try_new0 (mc_skin_color_t, 1);
    if (mc_skin_color == NULL)
    {
        g_strfreev (values);
        return NULL;
    }

    tmp = mc_skin_color_get_with_defaults (group, "_default_");
    mc_skin_color->fgcolor = (items_count > 0 && values[0][0]) ? g_strstrip (g_strdup (values[0])) :
        (tmp != NULL) ? g_strdup (tmp->fgcolor) : NULL;
    mc_skin_color->bgcolor = (items_count > 1 && values[1][0]) ? g_strstrip (g_strdup (values[1])) :
        (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL;
    mc_skin_color->attrs = (items_count > 2 && values[2][0]) ? g_strstrip (g_strdup (values[2])) :
        (tmp != NULL) ? g_strdup (tmp->attrs) : NULL;

    g_strfreev (values);

    mc_skin_color->pair_index =
        tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor,
                                   mc_skin_color->attrs, FALSE);

    return mc_skin_color;
}
Esempio n. 6
0
static void
load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg)
{
    gchar **profile_keys, **keys;
    gsize len;

    if (section_name == NULL)
        return;

    profile_keys = keys = mc_config_get_keys (cfg, section_name, &len);

    while (*profile_keys != NULL)
    {
        gchar **values, **curr_values;

        curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &len);

        if (curr_values != NULL)
        {
            int action;

            action = keybind_lookup_action (*profile_keys);
            if (action > 0)
                while (*curr_values != NULL)
                {
                    keybind_cmd_bind (keymap, *curr_values, action);
                    curr_values++;
                }

            g_strfreev (values);
        }

        profile_keys++;
    }

    g_strfreev (keys);
}