diff --git a/misc/filehighlight.ini b/misc/filehighlight.ini index 9776d45a8..0a08067af 100644 --- a/misc/filehighlight.ini +++ b/misc/filehighlight.ini @@ -27,9 +27,6 @@ [archive] extensions=gz;bz2;tar;tgz;rpm;Z;rar;zip;arj;cab;lzh;lha;zoo;arc;ark;xz;tbz;tbz2; -[hidden] - regexp=^\\..* - [doc] extensions=txt;doc;rtf;diz;ctl;me;ps;pdf;xml;xsd;xslt;dtd;html;shtml;htm;mail;msg;lsm;po;nroff;man;tex;sgml;css;text;letter;chm diff --git a/misc/skins/default.ini b/misc/skins/default.ini index 38c49f925..ec22f14ab 100644 --- a/misc/skins/default.ini +++ b/misc/skins/default.ini @@ -47,7 +47,6 @@ core=red; temp=gray; archive=brightmagenta; - hidden=black; doc=brown; source=cyan; media=green; diff --git a/misc/skins/far.ini b/misc/skins/far.ini index 0a091360a..a4951bded 100644 --- a/misc/skins/far.ini +++ b/misc/skins/far.ini @@ -47,7 +47,6 @@ core=red; temp=gray; archive=brightmagenta; - hidden=black; doc=brown; source=cyan; media=green; diff --git a/src/mcconfig/get.c b/src/mcconfig/get.c index f18adc028..8a1a449aa 100644 --- a/src/mcconfig/get.c +++ b/src/mcconfig/get.c @@ -87,6 +87,7 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group, GIConv conv; GString *buffer; gchar *ret; + const char *_system_codepage = str_detect_termencoding(); if (!mc_config || !group || !param) return def ? g_strdup (def) : NULL; @@ -102,10 +103,10 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group, if (!ret) ret = def ? g_strdup (def) : NULL; - if (utf8_display) + if (str_isutf8 (_system_codepage)) return ret; - conv = str_crt_conv_from ("UTF-8"); + conv = g_iconv_open (_system_codepage, "UTF-8"); if (conv == INVALID_CONV) return ret; @@ -126,6 +127,31 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group, /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +gchar * +mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group, + const gchar * param, const gchar * def) +{ + gchar *ret; + + if (!mc_config || !group || !param) + return def ? g_strdup (def) : NULL; + + if (! mc_config_has_param(mc_config, group, param)) + { + mc_config_set_string (mc_config, group, param, def ? def : ""); + return def ? g_strdup (def) : NULL; + } + + ret = g_key_file_get_string (mc_config->handle, group, param, NULL); + + if (!ret) + ret = def ? g_strdup (def) : NULL; + + return ret; +} + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + gboolean mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar * param, gboolean def) diff --git a/src/mcconfig/mcconfig.h b/src/mcconfig/mcconfig.h index 563c8dc7c..bf98b4937 100644 --- a/src/mcconfig/mcconfig.h +++ b/src/mcconfig/mcconfig.h @@ -49,6 +49,9 @@ gchar **mc_config_get_keys (mc_config_t *, const gchar *, gsize *); gchar *mc_config_get_string (mc_config_t *, const gchar *, const gchar *, const gchar *); +gchar *mc_config_get_string_raw (mc_config_t *, const gchar *, const gchar *, + const gchar *); + gboolean mc_config_get_bool (mc_config_t *, const gchar *, const gchar *, gboolean); diff --git a/src/setup.c b/src/setup.c index c24d87382..7e54650ac 100644 --- a/src/setup.c +++ b/src/setup.c @@ -40,7 +40,6 @@ #include "main.h" #include "tree.h" /* xtree_mode */ #include "../src/mcconfig/mcconfig.h" -#include "../src/skin/skin.h" #include "setup.h" #include "../src/viewer/mcviewer.h" /* For the externs */ #include "hotlist.h" /* load/save/done hotlist */ @@ -683,12 +682,6 @@ load_setup (void) if ( get_codepage_id( display_codepage ) ) utf8_display = str_isutf8 (get_codepage_id( display_codepage )); #endif /* HAVE_CHARSET */ - - /* - WARNING! We need to reinitialize 'Skin lines' again! - Because need to init systemCodepage parameter as well. - */ - mc_skin_lines_parse_ini_file(&mc_skin__default); } #if defined(USE_VFS) && defined (USE_NETCODE) diff --git a/src/skin/BUGS.txt b/src/skin/BUGS.txt deleted file mode 100644 index fc96006c5..000000000 --- a/src/skin/BUGS.txt +++ /dev/null @@ -1 +0,0 @@ -1) CHECK in ncurses !!! diff --git a/src/skin/colors-old.c b/src/skin/colors-old.c index 3c195174e..9c656552a 100644 --- a/src/skin/colors-old.c +++ b/src/skin/colors-old.c @@ -27,7 +27,7 @@ #include #include -#include /* size_t */ +#include /* size_t */ #include "../src/tty/color.h" #include "../src/global.h" @@ -42,48 +42,45 @@ /*** file scope type declarations ****************************************************************/ -typedef struct mc_skin_colors_old_struct -{ +typedef struct mc_skin_colors_old_struct { const char *old_color; const char *group; const char *key; - } mc_skin_colors_old_t; /*** file scope variables ************************************************************************/ -mc_skin_colors_old_t old_colors[] = -{ - {"normal","core","_default_"}, - {"selected","ore","selected"}, - {"marked","core","marked"}, - {"markselect","core","markselect"}, - {"errors","error","_default_"}, - {"menu","menu","_default_"}, - {"reverse","core","reverse"}, - {"dnormal","dialog","_default_"}, - {"dfocus","dialog","dfocus"}, - {"dhotnormal","dialog","dhotnormal"}, - {"dhotfocus","dialog","dhotfocus"}, - {"viewunderline","viewer","viewunderline"}, - {"menuhot","menu","menuhot"}, - {"menusel","menu","menusel"}, - {"menuhotsel","menu","menuhotsel"}, - {"helpnormal","help","_default_"}, - {"helpitalic","help","helpitalic"}, - {"helpbold","help","helpbold"}, - {"helplink","help","helplink"}, - {"helpslink","help","helpslink"}, - {"gauge","core","gauge"}, - {"input","core","input"}, - {"editnormal","editor","_default_"}, - {"editbold","editor","editbold"}, - {"editmarked","editor","editmarked"}, - {"editwhitespace","editor","editwhitespace"}, - {"editlinestate","editor","linestate"}, - {"errdhotnormal","error","errdhotnormal"}, - {"errdhotfocus","error","errdhotfocus"}, - {NULL,NULL,NULL} +mc_skin_colors_old_t old_colors[] = { + {"normal", "core", "_default_"}, + {"selected", "ore", "selected"}, + {"marked", "core", "marked"}, + {"markselect", "core", "markselect"}, + {"errors", "error", "_default_"}, + {"menu", "menu", "_default_"}, + {"reverse", "core", "reverse"}, + {"dnormal", "dialog", "_default_"}, + {"dfocus", "dialog", "dfocus"}, + {"dhotnormal", "dialog", "dhotnormal"}, + {"dhotfocus", "dialog", "dhotfocus"}, + {"viewunderline", "viewer", "viewunderline"}, + {"menuhot", "menu", "menuhot"}, + {"menusel", "menu", "menusel"}, + {"menuhotsel", "menu", "menuhotsel"}, + {"helpnormal", "help", "_default_"}, + {"helpitalic", "help", "helpitalic"}, + {"helpbold", "help", "helpbold"}, + {"helplink", "help", "helplink"}, + {"helpslink", "help", "helpslink"}, + {"gauge", "core", "gauge"}, + {"input", "core", "input"}, + {"editnormal", "editor", "_default_"}, + {"editbold", "editor", "editbold"}, + {"editmarked", "editor", "editmarked"}, + {"editwhitespace", "editor", "editwhitespace"}, + {"editlinestate", "editor", "linestate"}, + {"errdhotnormal", "error", "errdhotnormal"}, + {"errdhotfocus", "error", "errdhotfocus"}, + {NULL, NULL, NULL} }; @@ -91,24 +88,19 @@ mc_skin_colors_old_t old_colors[] = /* --------------------------------------------------------------------------------------------- */ static gboolean -mc_skin_colors_old_transform(const char *old_color, const char **group, const char **key) +mc_skin_colors_old_transform (const char *old_color, const char **group, const char **key) { int index; - if (old_color == NULL) - return FALSE; - - for (index=0; old_colors[index].old_color;index++) - { - if (strcasecmp(old_color,old_colors[index].old_color) == 0) - { - if (group) - *group = old_colors[index].group; - - if (key) - *key = old_colors[index].key; - return TRUE; - } + if (old_color != NULL) + for (index = 0; old_colors[index].old_color; index++) { + if (strcasecmp (old_color, old_colors[index].old_color) == 0) { + if (group != NULL) + *group = old_colors[index].group; + if (key != NULL) + *key = old_colors[index].key; + return TRUE; + } } return FALSE; } @@ -116,7 +108,7 @@ mc_skin_colors_old_transform(const char *old_color, const char **group, const ch /* --------------------------------------------------------------------------------------------- */ static void -mc_skin_colors_old_configure_one (mc_skin_t *mc_skin, const char *the_color_string) +mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_string) { gchar **colors, **orig_colors; gchar **key_val; @@ -124,33 +116,32 @@ mc_skin_colors_old_configure_one (mc_skin_t *mc_skin, const char *the_color_stri gchar *skin_val; if (the_color_string == NULL) - return; + return; orig_colors = colors = g_strsplit (the_color_string, ":", -1); if (colors == NULL) - return; + return; - for(;*colors; colors++) - { - key_val = g_strsplit_set (*colors, "=,", 3); + for (; *colors; colors++) { + key_val = g_strsplit_set (*colors, "=,", 3); - if (!key_val) - continue; + if (!key_val) + continue; - if(key_val[1] == NULL || !mc_skin_colors_old_transform(key_val[0], &skin_group, &skin_key)) - { - g_strfreev (key_val); - continue; - } - if (key_val[2] != NULL) - skin_val = g_strdup_printf("%s;%s",key_val[1],key_val[2]); - else - skin_val = g_strdup_printf("%s;",key_val[1]); - mc_config_set_string(mc_skin->config, skin_group, skin_key, skin_val); + if (key_val[1] == NULL + || !mc_skin_colors_old_transform (key_val[0], &skin_group, &skin_key)) { + g_strfreev (key_val); + continue; + } + if (key_val[2] != NULL) + skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]); + else + skin_val = g_strdup_printf ("%s;", key_val[1]); + mc_config_set_string (mc_skin->config, skin_group, skin_key, skin_val); - g_free(skin_val); + g_free (skin_val); - g_strfreev (key_val); + g_strfreev (key_val); } g_strfreev (orig_colors); } @@ -160,7 +151,7 @@ mc_skin_colors_old_configure_one (mc_skin_t *mc_skin, const char *the_color_stri /* --------------------------------------------------------------------------------------------- */ void -mc_skin_colors_old_configure (mc_skin_t *mc_skin) +mc_skin_colors_old_configure (mc_skin_t * mc_skin) { mc_skin_colors_old_configure_one (mc_skin, setup_color_string); mc_skin_colors_old_configure_one (mc_skin, term_color_string); @@ -169,4 +160,3 @@ mc_skin_colors_old_configure (mc_skin_t *mc_skin) } /* --------------------------------------------------------------------------------------------- */ - diff --git a/src/skin/colors.c b/src/skin/colors.c index d7eb87b2d..40d02a4f4 100644 --- a/src/skin/colors.c +++ b/src/skin/colors.c @@ -45,20 +45,11 @@ int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT]; /*** file scope variables ************************************************************************/ /*** file scope functions ************************************************************************/ -/* --------------------------------------------------------------------------------------------- */ - -inline static gchar * -mc_skin_color_make_hash_key (const gchar * group, const gchar * key) -{ - return g_strdup_printf ("%s.%s", group, key); -} - -/* --------------------------------------------------------------------------------------------- */ static mc_skin_color_t * mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key) { - gchar *key_name; + gchar key_name[BUF_TINY]; mc_skin_color_t *mc_skin_color; if (group == NULL || key == NULL) @@ -67,30 +58,29 @@ mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gch if (mc_skin == NULL) mc_skin = &mc_skin__default; - key_name = mc_skin_color_make_hash_key (group, key); + g_snprintf (key_name, sizeof (key_name), "%s.%s", group, key); mc_skin_color = (mc_skin_color_t *) g_hash_table_lookup (mc_skin->colors, (gpointer) key_name); - g_free (key_name); return mc_skin_color; } /* --------------------------------------------------------------------------------------------- */ +#if 0 static void mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key) { - gchar *key_name; + gchar key_name[BUF_TINY]; if (group == NULL || key == NULL) return; if (mc_skin == NULL) mc_skin = &mc_skin__default; - key_name = mc_skin_color_make_hash_key (group, key); + g_snprintf (key_name, sizeof (key_name), "%s.%s", group, key); g_hash_table_remove (mc_skin->colors, (gpointer) key_name); - g_free (key_name); } - +#endif /* --------------------------------------------------------------------------------------------- */ static void @@ -99,13 +89,12 @@ mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar { gchar *key_name; - key_name = mc_skin_color_make_hash_key (group, key); + key_name = g_strdup_printf ("%s.%s", group, key); if (key_name == NULL) return; - if (g_hash_table_lookup (mc_skin->colors, (gpointer) key_name) != NULL) { + if (g_hash_table_lookup (mc_skin->colors, (gpointer) key_name) != NULL) g_hash_table_remove (mc_skin->colors, (gpointer) key_name); - } g_hash_table_insert (mc_skin->colors, (gpointer) key_name, (gpointer) mc_skin_color); } @@ -141,7 +130,7 @@ mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const values = mc_config_get_string_list (mc_skin->config, group, key, &items_count); if (values == NULL || *values == NULL) { - if (values) + if (values != NULL) g_strfreev (values); return NULL; } @@ -166,11 +155,7 @@ mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const case 1: mc_skin_color->fgcolor = (values[0]) ? g_strdup (values[0]) : NULL; tmp = mc_skin_color_get_with_defaults (group, "_default_"); - if (tmp) - mc_skin_color->bgcolor = g_strdup (tmp->bgcolor); - else - - mc_skin_color->bgcolor = NULL; + mc_skin_color->bgcolor = (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL; break; case 2: mc_skin_color->fgcolor = (values[0]) ? g_strdup (values[0]) : NULL; @@ -251,10 +236,8 @@ mc_skin_color_cache_init (void) static gboolean mc_skin_color_check_inisection (const gchar * group) { - if (strcasecmp ("skin", group) == 0) - return FALSE; - - if (strcasecmp ("lines", group) == 0) + if ((strcasecmp ("skin", group) == 0) + || (strcasecmp ("lines", group) == 0)) return FALSE; return TRUE; @@ -276,12 +259,9 @@ mc_skin_color_check_bw_mode (mc_skin_t * mc_skin) if (groups == NULL) return; - - for (; *groups; groups++) { - if (!mc_skin_color_check_inisection (*groups)) - continue; - - mc_config_del_group (mc_skin->config, *groups); + for (; *groups != NULL; groups++) { + if (mc_skin_color_check_inisection (*groups)) + mc_config_del_group (mc_skin->config, *groups); } g_strfreev (orig_groups); mc_skin_hardcoded_blackwhite_colors (mc_skin); @@ -304,7 +284,7 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin) orig_groups = groups = mc_config_get_groups (mc_skin->config, &items_count); if (groups == NULL || *groups == NULL) { - if (groups) + if (groups != NULL) g_strfreev (groups); return FALSE; } @@ -315,25 +295,24 @@ mc_skin_color_parse_ini_file (mc_skin_t * mc_skin) if (mc_skin_color == NULL) return FALSE; - tty_color_set_defaults(mc_skin_color->fgcolor, mc_skin_color->bgcolor); + tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor); mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color); - for (; *groups; groups++) { + for (; *groups != NULL; groups++) { if (!mc_skin_color_check_inisection (*groups)) continue; orig_keys = keys = mc_config_get_keys (mc_skin->config, *groups, &items_count); if (keys == NULL || *keys == NULL) { - if (keys) + if (keys != NULL) g_strfreev (keys); continue; } for (; *keys; keys++) { mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, *groups, *keys); - if (mc_skin_color == NULL) - continue; - mc_skin_color_add_to_hash (mc_skin, *groups, *keys, mc_skin_color); + if (mc_skin_color != NULL) + mc_skin_color_add_to_hash (mc_skin, *groups, *keys, mc_skin_color); } g_strfreev (orig_keys); } @@ -351,10 +330,8 @@ mc_skin_color_get (const gchar * group, const gchar * name) mc_skin_color_t *mc_skin_color; mc_skin_color = mc_skin_color_get_with_defaults (group, name); - if (mc_skin_color == NULL) - return 0; - return mc_skin_color->pair_index; + return (mc_skin_color != NULL) ? mc_skin_color->pair_index : 0; } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/skin/common.c b/src/skin/common.c index f7d4aba26..9545a36b4 100644 --- a/src/skin/common.c +++ b/src/skin/common.c @@ -49,10 +49,10 @@ static gboolean mc_skin_is_init = FALSE; /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ -static void +static inline void mc_skin_hash_destroy_key (gpointer data) { - g_free(data); + g_free (data); } /* --------------------------------------------------------------------------------------------- */ @@ -69,33 +69,33 @@ mc_skin_hash_destroy_value (gpointer data) /* --------------------------------------------------------------------------------------------- */ static char * -mc_skin_get_default_name(void) +mc_skin_get_default_name (void) { char *tmp_str; /* from command line */ if (mc_args__skin != NULL) - return g_strdup(mc_args__skin); + return g_strdup (mc_args__skin); /* from envirovement variable */ tmp_str = getenv ("MC_SKIN"); if (tmp_str != NULL) - return g_strdup(tmp_str); + return g_strdup (tmp_str); /* from config. Or 'default' if no present in config */ - return mc_config_get_string(mc_main_config, CONFIG_APP_SECTION, "skin" , "default"); + return mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "skin", "default"); } /* --------------------------------------------------------------------------------------------- */ static void -mc_skin_reinit(void) +mc_skin_reinit (void) { - mc_skin_deinit(); - mc_skin__default.name = mc_skin_get_default_name(); + mc_skin_deinit (); + mc_skin__default.name = mc_skin_get_default_name (); mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, - mc_skin_hash_destroy_key, - mc_skin_hash_destroy_value); + mc_skin_hash_destroy_key, + mc_skin_hash_destroy_value); } /* --------------------------------------------------------------------------------------------- */ @@ -103,26 +103,24 @@ mc_skin_reinit(void) /* --------------------------------------------------------------------------------------------- */ void -mc_skin_init(void) +mc_skin_init (void) { - mc_skin__default.name = mc_skin_get_default_name(); + mc_skin__default.name = mc_skin_get_default_name (); mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, - mc_skin_hash_destroy_key, - mc_skin_hash_destroy_value); + mc_skin_hash_destroy_key, + mc_skin_hash_destroy_value); - if (! mc_skin_ini_file_load(&mc_skin__default)) - { - mc_skin_reinit(); - mc_skin_set_hardcoded_skin(&mc_skin__default); + if (!mc_skin_ini_file_load (&mc_skin__default)) { + mc_skin_reinit (); + mc_skin_set_hardcoded_skin (&mc_skin__default); } mc_skin_colors_old_configure (&mc_skin__default); - if (! mc_skin_ini_file_parse(&mc_skin__default)) - { - mc_skin_reinit(); - mc_skin_set_hardcoded_skin(&mc_skin__default); - mc_skin_colors_old_configure (&mc_skin__default); - (void) mc_skin_ini_file_parse(&mc_skin__default); + if (!mc_skin_ini_file_parse (&mc_skin__default)) { + mc_skin_reinit (); + mc_skin_set_hardcoded_skin (&mc_skin__default); + mc_skin_colors_old_configure (&mc_skin__default); + (void) mc_skin_ini_file_parse (&mc_skin__default); } mc_skin_is_init = TRUE; } @@ -130,19 +128,18 @@ mc_skin_init(void) /* --------------------------------------------------------------------------------------------- */ void -mc_skin_deinit(void) +mc_skin_deinit (void) { - g_free(mc_skin__default.name); + g_free (mc_skin__default.name); mc_skin__default.name = NULL; g_hash_table_destroy (mc_skin__default.colors); mc_skin__default.colors = NULL; - g_free(mc_skin__default.description); + g_free (mc_skin__default.description); mc_skin__default.description = NULL; - if (mc_skin__default.config) - { + if (mc_skin__default.config) { mc_config_deinit (mc_skin__default.config); mc_skin__default.config = NULL; } diff --git a/src/skin/hc-skins.c b/src/skin/hc-skins.c index efc198e17..12c72cd71 100644 --- a/src/skin/hc-skins.c +++ b/src/skin/hc-skins.c @@ -50,66 +50,66 @@ /* --------------------------------------------------------------------------------------------- */ void -mc_skin_hardcoded_blackwhite_colors(mc_skin_t *mc_skin) +mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin) { - mc_config_set_string(mc_skin->config, "core", "_default_", "default;default"); - mc_config_set_string(mc_skin->config, "core", "selected", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "core", "marked", "A_BOLD"); - mc_config_set_string(mc_skin->config, "core", "markselect", "A_BOLD_REVERSE"); - mc_config_set_string(mc_skin->config, "core", "reverse", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "dialog", "_default_", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "dialog", "focus", "A_BOLD"); - mc_config_set_string(mc_skin->config, "menu", "entry", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "menu", "selected", "A_BOLD"); - mc_config_set_string(mc_skin->config, "help", "_default_", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "help", "italic", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "help", "bold", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "help", "slink", "A_BOLD"); - mc_config_set_string(mc_skin->config, "editor", "bold", "A_BOLD"); - mc_config_set_string(mc_skin->config, "editor", "marked", "A_REVERSE"); - mc_config_set_string(mc_skin->config, "viewer", "underline", "A_UNDERLINE"); - mc_config_set_string(mc_skin->config, "error", "_default_", "A_BOLD"); - + mc_config_set_string (mc_skin->config, "core", "_default_", "default;default"); + mc_config_set_string (mc_skin->config, "core", "selected", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "core", "marked", "A_BOLD"); + mc_config_set_string (mc_skin->config, "core", "markselect", "A_BOLD_REVERSE"); + mc_config_set_string (mc_skin->config, "core", "reverse", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "dialog", "_default_", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "dialog", "focus", "A_BOLD"); + mc_config_set_string (mc_skin->config, "menu", "entry", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "menu", "selected", "A_BOLD"); + mc_config_set_string (mc_skin->config, "help", "_default_", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "help", "italic", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "help", "bold", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "help", "slink", "A_BOLD"); + mc_config_set_string (mc_skin->config, "editor", "bold", "A_BOLD"); + mc_config_set_string (mc_skin->config, "editor", "marked", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "viewer", "underline", "A_UNDERLINE"); + mc_config_set_string (mc_skin->config, "error", "_default_", "A_BOLD"); + } /* --------------------------------------------------------------------------------------------- */ void -mc_skin_hardcoded_space_lines(mc_skin_t *mc_skin) +mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin) { - set_lines("lefttop", " "); - set_lines("righttop", " "); - set_lines("centertop", " "); - set_lines("centerbottom", " "); - set_lines("leftbottom", " "); - set_lines("rightbottom", " "); - set_lines("leftmiddle", " "); - set_lines("rightmiddle", " "); - set_lines("centermiddle", " "); - set_lines("horiz", " "); - set_lines("vert", " "); - set_lines("thinhoriz", " "); - set_lines("thinvert", " "); + set_lines ("lefttop", " "); + set_lines ("righttop", " "); + set_lines ("centertop", " "); + set_lines ("centerbottom", " "); + set_lines ("leftbottom", " "); + set_lines ("rightbottom", " "); + set_lines ("leftmiddle", " "); + set_lines ("rightmiddle", " "); + set_lines ("centermiddle", " "); + set_lines ("horiz", " "); + set_lines ("vert", " "); + set_lines ("thinhoriz", " "); + set_lines ("thinvert", " "); } /* --------------------------------------------------------------------------------------------- */ void -mc_skin_hardcoded_ugly_lines(mc_skin_t *mc_skin) +mc_skin_hardcoded_ugly_lines (mc_skin_t * mc_skin) { - set_lines("lefttop", "+"); - set_lines("righttop", "+"); - set_lines("centertop", "-"); - set_lines("centerbottom", "-"); - set_lines("leftbottom", "+"); - set_lines("rightbottom", "+"); - set_lines("leftmiddle", "|"); - set_lines("rightmiddle", "|"); - set_lines("centermiddle", "+"); - set_lines("horiz", "-"); - set_lines("vert", "|"); - set_lines("thinhoriz", "-"); - set_lines("thinvert", "|"); + set_lines ("lefttop", "+"); + set_lines ("righttop", "+"); + set_lines ("centertop", "-"); + set_lines ("centerbottom", "-"); + set_lines ("leftbottom", "+"); + set_lines ("rightbottom", "+"); + set_lines ("leftmiddle", "|"); + set_lines ("rightmiddle", "|"); + set_lines ("centermiddle", "+"); + set_lines ("horiz", "-"); + set_lines ("vert", "|"); + set_lines ("thinhoriz", "-"); + set_lines ("thinvert", "|"); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/skin/ini-file.c b/src/skin/ini-file.c index 148f2e35c..1affeedce 100644 --- a/src/skin/ini-file.c +++ b/src/skin/ini-file.c @@ -45,32 +45,28 @@ /* --------------------------------------------------------------------------------------------- */ static gboolean -mc_skin_ini_file_load_search_in_dir (mc_skin_t *mc_skin, const gchar *base_dir) +mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir) { char *file_name, *file_name2; file_name = g_build_filename (base_dir, "skins", mc_skin->name, NULL); - if (exist_file (file_name)){ - mc_skin->config = mc_config_init (file_name); - g_free(file_name); - if (mc_skin->config == NULL) - return FALSE; - return TRUE; + if (exist_file (file_name)) { + mc_skin->config = mc_config_init (file_name); + g_free (file_name); + return (mc_skin->config != NULL); } - g_free(file_name); + g_free (file_name); - file_name2 = g_strdup_printf("%s.ini",mc_skin->name); + file_name2 = g_strdup_printf ("%s.ini", mc_skin->name); file_name = g_build_filename (base_dir, "skins", file_name2, NULL); - g_free(file_name2); + g_free (file_name2); - if (exist_file (file_name)){ - mc_skin->config = mc_config_init (file_name); - g_free(file_name); - if (mc_skin->config == NULL) - return FALSE; - return TRUE; + if (exist_file (file_name)) { + mc_skin->config = mc_config_init (file_name); + g_free (file_name); + return (mc_skin->config != NULL); } - g_free(file_name); + g_free (file_name); return FALSE; } @@ -79,36 +75,32 @@ mc_skin_ini_file_load_search_in_dir (mc_skin_t *mc_skin, const gchar *base_dir) /* --------------------------------------------------------------------------------------------- */ gboolean -mc_skin_ini_file_load (mc_skin_t *mc_skin) +mc_skin_ini_file_load (mc_skin_t * mc_skin) { char *file_name, *user_home_dir; - file_name = g_path_get_basename(mc_skin->name); + file_name = g_path_get_basename (mc_skin->name); - if (strcmp(file_name, mc_skin->name) != 0 ) - { - g_free(file_name); - if (!g_path_is_absolute (mc_skin->name)) - return FALSE; - mc_skin->config = mc_config_init (mc_skin->name); - if (mc_skin->config == NULL) - return FALSE; - return TRUE; + if (strcmp (file_name, mc_skin->name) != 0) { + g_free (file_name); + if (!g_path_is_absolute (mc_skin->name)) + return FALSE; + mc_skin->config = mc_config_init (mc_skin->name); + return (mc_skin->config != NULL); } - g_free(file_name); + g_free (file_name); /* ~/.mc/skins/ */ user_home_dir = concat_dir_and_file (home_dir, MC_BASE); - if (mc_skin_ini_file_load_search_in_dir (mc_skin, user_home_dir)) - { - g_free(user_home_dir); - return TRUE; + if (mc_skin_ini_file_load_search_in_dir (mc_skin, user_home_dir)) { + g_free (user_home_dir); + return TRUE; } - g_free(user_home_dir); + g_free (user_home_dir); /* /etc/mc/skins/ */ if (mc_skin_ini_file_load_search_in_dir (mc_skin, mc_home)) - return TRUE; + return TRUE; /* /usr/share/mc/skins/ */ return mc_skin_ini_file_load_search_in_dir (mc_skin, mc_home_alt); @@ -117,13 +109,14 @@ mc_skin_ini_file_load (mc_skin_t *mc_skin) /* --------------------------------------------------------------------------------------------- */ gboolean -mc_skin_ini_file_parse(mc_skin_t *mc_skin) +mc_skin_ini_file_parse (mc_skin_t * mc_skin) { - mc_skin->description = mc_config_get_string (mc_skin->config, "skin", "description", "- no description -"); - if (! mc_skin_color_parse_ini_file(mc_skin)) - return FALSE; + mc_skin->description = + mc_config_get_string (mc_skin->config, "skin", "description", "- no description -"); + if (!mc_skin_color_parse_ini_file (mc_skin)) + return FALSE; - mc_skin_lines_parse_ini_file(mc_skin); + mc_skin_lines_parse_ini_file (mc_skin); return TRUE; } @@ -131,15 +124,14 @@ mc_skin_ini_file_parse(mc_skin_t *mc_skin) /* --------------------------------------------------------------------------------------------- */ void -mc_skin_set_hardcoded_skin(mc_skin_t *mc_skin) +mc_skin_set_hardcoded_skin (mc_skin_t * mc_skin) { - mc_skin->config = mc_config_init (NULL); + mc_skin->config = mc_config_init (NULL); - mc_config_set_string(mc_skin->config, "skin", "description", "hardcoded skin"); + mc_config_set_string (mc_skin->config, "skin", "description", "hardcoded skin"); - mc_skin_hardcoded_ugly_lines(mc_skin); - mc_skin_hardcoded_blackwhite_colors(mc_skin); + mc_skin_hardcoded_ugly_lines (mc_skin); + mc_skin_hardcoded_blackwhite_colors (mc_skin); } /* --------------------------------------------------------------------------------------------- */ - diff --git a/src/skin/internal.h b/src/skin/internal.h index a9de9dc18..4310724cb 100644 --- a/src/skin/internal.h +++ b/src/skin/internal.h @@ -1,13 +1,17 @@ #ifndef MC__SKIN_INTERNAL_H #define MC__SKIN_INTERNAL_H +#include "../../src/global.h" + +#include "skin.h" + /*** typedefs(not structures) and defined constants **********************************************/ /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ -typedef struct mc_skin_color_struct{ +typedef struct mc_skin_color_struct { gchar *fgcolor; gchar *bgcolor; int pair_index; @@ -19,17 +23,16 @@ extern mc_skin_t mc_skin__default; /*** declarations of public functions ************************************************************/ +gboolean mc_skin_ini_file_load (mc_skin_t *); +gboolean mc_skin_ini_file_parse (mc_skin_t *); +void mc_skin_set_hardcoded_skin (mc_skin_t *); -gboolean mc_skin_ini_file_load(mc_skin_t *); -gboolean mc_skin_ini_file_parse(mc_skin_t *); -void mc_skin_set_hardcoded_skin(mc_skin_t *); +gboolean mc_skin_ini_file_parse_colors (mc_skin_t *); +gboolean mc_skin_color_parse_ini_file (mc_skin_t *); -gboolean mc_skin_ini_file_parse_colors(mc_skin_t *); - - -void mc_skin_hardcoded_ugly_lines(mc_skin_t *); -void mc_skin_hardcoded_space_lines(mc_skin_t *); -void mc_skin_hardcoded_blackwhite_colors(mc_skin_t *); +void mc_skin_hardcoded_ugly_lines (mc_skin_t *); +void mc_skin_hardcoded_space_lines (mc_skin_t *); +void mc_skin_hardcoded_blackwhite_colors (mc_skin_t *); void mc_skin_colors_old_configure (mc_skin_t *); diff --git a/src/skin/lines.c b/src/skin/lines.c index e9f0aa526..0472eec87 100644 --- a/src/skin/lines.c +++ b/src/skin/lines.c @@ -44,47 +44,47 @@ /*** file scope variables ************************************************************************/ /*** file scope functions ************************************************************************/ -/* --------------------------------------------------------------------------------------------- */ static int -mc_skin_lines_srt_to_char (char* str) -{ - int res = -1; - - if (!str) - return (int) ' '; - res = g_utf8_get_char_validated (str, -1); - - if ( res < 0 ) { - return (unsigned char) str[0]; - } else { - return res; - } -} - -/* --------------------------------------------------------------------------------------------- */ - -static int -mc_skin_lines_load_frm(mc_skin_t *mc_skin, const char *name) +mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name) { int ret; char *frm_val = NULL; - frm_val = mc_config_get_string(mc_skin->config, "Lines", name, " "); - ret = mc_skin_lines_srt_to_char (frm_val); + frm_val = mc_config_get_string_raw (mc_skin->config, "Lines", name, " "); + ret = mc_tty_normalize_lines_char (frm_val); g_free (frm_val); switch (ret) { - case 0x80: ret = ACS_HLINE; break; - case 0x81: ret = ACS_VLINE; break; - case 0x82: ret = ACS_ULCORNER; break; - case 0x83: ret = ACS_URCORNER; break; - case 0x84: ret = ACS_LLCORNER; break; - case 0x85: ret = ACS_LRCORNER; break; - case 0x86: ret = ACS_LTEE; break; - case 0x87: ret = ACS_RTEE; break; - case 0x8a: ret = ACS_PLUS; break; - default: break; + case 0x80: + ret = ACS_HLINE; + break; + case 0x81: + ret = ACS_VLINE; + break; + case 0x82: + ret = ACS_ULCORNER; + break; + case 0x83: + ret = ACS_URCORNER; + break; + case 0x84: + ret = ACS_LLCORNER; + break; + case 0x85: + ret = ACS_LRCORNER; + break; + case 0x86: + ret = ACS_LTEE; + break; + case 0x87: + ret = ACS_RTEE; + break; + case 0x8a: + ret = ACS_PLUS; + break; + default: + break; } return ret; @@ -95,32 +95,28 @@ mc_skin_lines_load_frm(mc_skin_t *mc_skin, const char *name) /* --------------------------------------------------------------------------------------------- */ void -mc_skin_lines_parse_ini_file(mc_skin_t *mc_skin) +mc_skin_lines_parse_ini_file (mc_skin_t * mc_skin) { - if (mc_args__slow_terminal) - { - mc_skin_hardcoded_space_lines(mc_skin); - } - else if (mc_args__ugly_line_drawing) - { - mc_skin_hardcoded_ugly_lines(mc_skin); + if (mc_args__slow_terminal) { + mc_skin_hardcoded_space_lines (mc_skin); + } else if (mc_args__ugly_line_drawing) { + mc_skin_hardcoded_ugly_lines (mc_skin); } - mc_tty_ugly_frm[MC_TTY_FRM_horiz] = mc_skin_lines_load_frm(mc_skin, "horiz"); - mc_tty_ugly_frm[MC_TTY_FRM_vert] = mc_skin_lines_load_frm(mc_skin, "vert"); - mc_tty_ugly_frm[MC_TTY_FRM_lefttop] = mc_skin_lines_load_frm(mc_skin, "lefttop"); - mc_tty_ugly_frm[MC_TTY_FRM_righttop] = mc_skin_lines_load_frm(mc_skin, "righttop"); - mc_tty_ugly_frm[MC_TTY_FRM_leftbottom] = mc_skin_lines_load_frm(mc_skin, "leftbottom"); - mc_tty_ugly_frm[MC_TTY_FRM_rightbottom] = mc_skin_lines_load_frm(mc_skin, "rightbottom"); - mc_tty_ugly_frm[MC_TTY_FRM_thinvert] = mc_skin_lines_load_frm(mc_skin, "thinvert"); - mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz] = mc_skin_lines_load_frm(mc_skin, "thinhoriz"); - mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle] = mc_skin_lines_load_frm(mc_skin, "rightmiddle"); - mc_tty_ugly_frm[MC_TTY_FRM_centertop] = mc_skin_lines_load_frm(mc_skin, "centertop"); - mc_tty_ugly_frm[MC_TTY_FRM_centerbottom] = mc_skin_lines_load_frm(mc_skin, "centerbottom"); - mc_tty_ugly_frm[MC_TTY_FRM_centermiddle] = mc_skin_lines_load_frm(mc_skin, "centermiddle"); - mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle] = mc_skin_lines_load_frm(mc_skin, "leftmiddle"); + mc_tty_ugly_frm[MC_TTY_FRM_horiz] = mc_skin_lines_load_frm (mc_skin, "horiz"); + mc_tty_ugly_frm[MC_TTY_FRM_vert] = mc_skin_lines_load_frm (mc_skin, "vert"); + mc_tty_ugly_frm[MC_TTY_FRM_lefttop] = mc_skin_lines_load_frm (mc_skin, "lefttop"); + mc_tty_ugly_frm[MC_TTY_FRM_righttop] = mc_skin_lines_load_frm (mc_skin, "righttop"); + mc_tty_ugly_frm[MC_TTY_FRM_leftbottom] = mc_skin_lines_load_frm (mc_skin, "leftbottom"); + mc_tty_ugly_frm[MC_TTY_FRM_rightbottom] = mc_skin_lines_load_frm (mc_skin, "rightbottom"); + mc_tty_ugly_frm[MC_TTY_FRM_thinvert] = mc_skin_lines_load_frm (mc_skin, "thinvert"); + mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz] = mc_skin_lines_load_frm (mc_skin, "thinhoriz"); + mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle] = mc_skin_lines_load_frm (mc_skin, "rightmiddle"); + mc_tty_ugly_frm[MC_TTY_FRM_centertop] = mc_skin_lines_load_frm (mc_skin, "centertop"); + mc_tty_ugly_frm[MC_TTY_FRM_centerbottom] = mc_skin_lines_load_frm (mc_skin, "centerbottom"); + mc_tty_ugly_frm[MC_TTY_FRM_centermiddle] = mc_skin_lines_load_frm (mc_skin, "centermiddle"); + mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle] = mc_skin_lines_load_frm (mc_skin, "leftmiddle"); } /* --------------------------------------------------------------------------------------------- */ - diff --git a/src/skin/skin.h b/src/skin/skin.h index aa6d18f8c..11412096c 100644 --- a/src/skin/skin.h +++ b/src/skin/skin.h @@ -1,6 +1,8 @@ #ifndef MC__SKIN_H #define MC__SKIN_H +#include "../../src/global.h" + #include "../../src/mcconfig/mcconfig.h" #include "../src/tty/color.h" @@ -69,14 +71,11 @@ /*** structures declarations (and typedefs of structures)*****************************************/ -typedef struct mc_skin_struct{ +typedef struct mc_skin_struct { gchar *name; gchar *description; - mc_config_t *config; - GHashTable *colors; - } mc_skin_t; /*** global variables defined in .c file *********************************************************/ @@ -86,11 +85,11 @@ extern mc_skin_t mc_skin__default; /*** declarations of public functions ************************************************************/ -void mc_skin_init(void); -void mc_skin_deinit(void); +void mc_skin_init (void); +void mc_skin_deinit (void); -int mc_skin_color_get(const gchar *, const gchar *); +int mc_skin_color_get (const gchar *, const gchar *); -void mc_skin_lines_parse_ini_file(mc_skin_t *); +void mc_skin_lines_parse_ini_file (mc_skin_t *); #endif diff --git a/src/tty/Makefile.am b/src/tty/Makefile.am index cb536c46e..713ce0513 100644 --- a/src/tty/Makefile.am +++ b/src/tty/Makefile.am @@ -7,7 +7,7 @@ if USE_SCREEN_SLANG tty-slang.c tty-slang.h else TTY_SCREEN_SRC = \ - color-ncurses.c color-ncurses.h \ + color-ncurses.c \ tty-ncurses.c tty-ncurses.h endif diff --git a/src/tty/color-internal.c b/src/tty/color-internal.c index 08c9c7f49..763c364ee 100644 --- a/src/tty/color-internal.c +++ b/src/tty/color-internal.c @@ -26,7 +26,7 @@ #include -#include /* size_t */ +#include /* strcmp */ #include "../../src/tty/color.h" /* colors and attributes */ #include "../../src/tty/color-internal.h" @@ -63,7 +63,7 @@ mc_tty_color_table_t const color_table [] = { { "brightcyan", COLOR_CYAN | A_BOLD }, { "lightgray", COLOR_WHITE }, { "white", COLOR_WHITE | A_BOLD }, - { "default", 0 }, /* default color of the terminal */ + { "default", -1 }, /* default color of the terminal */ /* special colors */ { "A_REVERSE", SPEC_A_REVERSE }, { "A_BOLD", SPEC_A_BOLD}, @@ -80,36 +80,28 @@ mc_tty_color_table_t const color_table [] = { /* --------------------------------------------------------------------------------------------- */ const char * -mc_tty_color_get_valid_name(const char *color_name) +tty_color_get_valid_name (const char *color_name) { - size_t i; + int i; - if (color_name == NULL) - return NULL; - - for (i=0; color_table [i].name != NULL; i++) - if (strcmp (color_name, color_table [i].name) == 0) { - return color_table [i].name; - break; - } + if (color_name != NULL) + for (i = 0; color_table [i].name != NULL; i++) + if (strcmp (color_name, color_table [i].name) == 0) + return color_table [i].name; return NULL; } /* --------------------------------------------------------------------------------------------- */ int -mc_tty_color_get_index_by_name(const char *color_name) +tty_color_get_index_by_name (const char *color_name) { - size_t i; + int i; - if (color_name == NULL) - return -1; - - for (i=0; color_table [i].name != NULL; i++) - if (strcmp (color_name, color_table [i].name) == 0) { - return color_table [i].value; - break; - } + if (color_name != NULL) + for (i = 0; color_table [i].name != NULL; i++) + if (strcmp (color_name, color_table [i].name) == 0) + return color_table [i].value; return -1; } diff --git a/src/tty/color-internal.h b/src/tty/color-internal.h index 6281c1030..20331a98f 100644 --- a/src/tty/color-internal.h +++ b/src/tty/color-internal.h @@ -19,12 +19,6 @@ extern gboolean use_colors; extern gboolean mc_tty_color_disable; -#ifdef HAVE_SLANG -# define CTYPE const char * -#else -# define CTYPE int -#endif /* HAVE_SLANG */ - typedef struct mc_color_pair_struct { const char *cfg; const char *cbg; @@ -32,23 +26,22 @@ typedef struct mc_color_pair_struct { int ibg; int pair_index; gboolean is_temp; -} mc_color_pair_t; +} tty_color_pair_t; typedef enum { - SPEC_A_REVERSE = -100, - SPEC_A_BOLD = -101, - SPEC_A_BOLD_REVERSE = -102, - SPEC_A_UNDERLINE = -103 -} mc_tty_color_special_t; + SPEC_A_REVERSE = -100, + SPEC_A_BOLD = -101, + SPEC_A_BOLD_REVERSE = -102, + SPEC_A_UNDERLINE = -103 +} tty_special_color_t; -const char *mc_tty_color_get_valid_name(const char *); -int mc_tty_color_get_index_by_name(const char *); +const char *tty_color_get_valid_name (const char *); +int tty_color_get_index_by_name (const char *); -void mc_tty_color_init_lib (gboolean, gboolean); -void mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *); -void mc_tty_color_set_lib (int); -void mc_tty_color_set_normal_attrs_lib (void); -void mc_tty_color_lowlevel_set_lib (int); +void tty_color_init_lib (gboolean, gboolean); +void tty_color_deinit_lib (void); + +void tty_color_try_alloc_pair_lib (tty_color_pair_t *); #endif /* MC_COLOR_INTERNAL_H */ diff --git a/src/tty/color-ncurses.c b/src/tty/color-ncurses.c index 692d2403b..183165ea2 100644 --- a/src/tty/color-ncurses.c +++ b/src/tty/color-ncurses.c @@ -36,50 +36,202 @@ #include "../../src/tty/color.h" /* variables */ #include "../../src/tty/color-internal.h" +/*** global variables ****************************************************************************/ + +/*** file scope macro definitions ****************************************************************/ + +/*** file scope type declarations ****************************************************************/ + +/*** file scope variables ************************************************************************/ + +static GHashTable *mc_tty_color_color_pair_attrs = NULL; + +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +static inline void +mc_tty_color_attr_destroy_cb (gpointer data) +{ + g_free (data); +} + +/* --------------------------------------------------------------------------------------------- */ + +static int +mc_tty_color_save_attr_lib (int color_pair, int color_attr) +{ + int *attr, *key; + attr = g_new0(int,1); + if (attr == NULL) + return color_attr; + + key = g_new0(int,1); + if (key == NULL) + { + g_free(attr); + return color_attr; + } + memcpy(key,&color_pair,sizeof(int)); + + if (color_attr != -1) + *attr = color_attr & (A_BOLD | A_REVERSE | A_UNDERLINE); + g_hash_table_replace (mc_tty_color_color_pair_attrs, (gpointer) key, (gpointer) attr); + return color_attr & (~(*attr)); +} + +/* --------------------------------------------------------------------------------------------- */ + +static int +color_get_attr (int color_pair) +{ + int *fnd; + + if (mc_tty_color_color_pair_attrs == NULL) + return 0; + + fnd = (int *) g_hash_table_lookup (mc_tty_color_color_pair_attrs, (gpointer) &color_pair); + return (fnd != NULL) ? *fnd : 0; +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_tty_color_pair_init_special(tty_color_pair_t *mc_color_pair, + int fg1, int bg1, + int fg2, int bg2, + int mask) +{ + if (has_colors ()) + { + if (!mc_tty_color_disable) + { + init_pair( + mc_color_pair->pair_index, + mc_tty_color_save_attr_lib (mc_color_pair->pair_index, fg1 | mask ), + bg1); + } + else + { + init_pair( + mc_color_pair->pair_index, + mc_tty_color_save_attr_lib (mc_color_pair->pair_index, fg2 | mask ), + bg2); + } + } +#if 0 + else + { + SLtt_set_mono (mc_color_pair->pair_index, NULL, mask); + } +#endif +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + void -mc_tty_color_init_lib (gboolean disable, gboolean force) +tty_color_init_lib (gboolean disable, gboolean force) { (void) force; if (has_colors () && !disable) { - use_colors = TRUE; - start_color (); use_default_colors (); - } + + mc_tty_color_color_pair_attrs = g_hash_table_new_full + (g_int_hash, + g_int_equal, + mc_tty_color_attr_destroy_cb, + mc_tty_color_attr_destroy_cb + ); } +/* --------------------------------------------------------------------------------------------- */ + void -mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *mc_color_pair) +tty_color_deinit_lib (void) +{ + g_hash_table_destroy (mc_tty_color_color_pair_attrs); + mc_tty_color_color_pair_attrs = NULL; +} + +/* --------------------------------------------------------------------------------------------- */ + +void +tty_color_try_alloc_pair_lib (tty_color_pair_t *mc_color_pair) { if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE) { -/* TODO: !!!!! */ + switch(mc_color_pair->ifg) + { + case SPEC_A_REVERSE: + mc_tty_color_pair_init_special( + mc_color_pair, + COLOR_BLACK, COLOR_WHITE, + COLOR_BLACK, COLOR_WHITE | A_BOLD, + A_REVERSE + ); + break; + case SPEC_A_BOLD: + mc_tty_color_pair_init_special( + mc_color_pair, + COLOR_WHITE, COLOR_BLACK, + COLOR_WHITE, COLOR_BLACK, + A_BOLD + ); + break; + case SPEC_A_BOLD_REVERSE: + + mc_tty_color_pair_init_special( + mc_color_pair, + COLOR_WHITE, COLOR_WHITE, + COLOR_WHITE, COLOR_WHITE, + A_BOLD | A_REVERSE + ); + break; + case SPEC_A_UNDERLINE: + mc_tty_color_pair_init_special( + mc_color_pair, + COLOR_WHITE, COLOR_BLACK, + COLOR_WHITE, COLOR_BLACK, + A_UNDERLINE + ); + break; + } } else { init_pair (mc_color_pair->pair_index, - mc_color_pair->ifg, - mc_color_pair->ibg == 0 ? -1 : mc_color_pair->ibg); + mc_tty_color_save_attr_lib (mc_color_pair->pair_index, mc_color_pair->ifg) & COLOR_WHITE, + mc_color_pair->ibg & COLOR_WHITE); } } -void -mc_tty_color_set_lib (int color) -{ - attrset (color); -} +/* --------------------------------------------------------------------------------------------- */ void -mc_tty_color_lowlevel_set_lib (int color) +tty_setcolor (int color) { - attrset (MY_COLOR_PAIR (color)); + attrset (COLOR_PAIR (color) | color_get_attr (color)); } +/* --------------------------------------------------------------------------------------------- */ + void -mc_tty_color_set_normal_attrs_lib (void) +tty_lowlevel_setcolor (int color) +{ + attrset (COLOR_PAIR (color) | color_get_attr (color)); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +tty_set_normal_attrs (void) { standend (); } + +/* --------------------------------------------------------------------------------------------- */ diff --git a/src/tty/color-ncurses.h b/src/tty/color-ncurses.h deleted file mode 100644 index 219c00a14..000000000 --- a/src/tty/color-ncurses.h +++ /dev/null @@ -1,22 +0,0 @@ - -/** \file color-ncurses.h - * \brief Header: NCurses-specific color setup - */ - -#ifndef MC_COLOR_NCURSES_H -#define MC_COLOR_NCURSES_H - -#include "../../src/tty/tty-ncurses.h" /* NCurses headers */ - -gboolean tty_use_colors (); - - -//#define MY_COLOR_PAIR(x) (COLOR_PAIR (x) | attr_pairs [x]) -#define MY_COLOR_PAIR(x) COLOR_PAIR (x) - -/* -#define IF_COLOR(co, bw) (tty_use_colors () ? MY_COLOR_PAIR (co) : bw) -#define MARKED_SELECTED_COLOR IF_COLOR (4, A_REVERSE | A_BOLD) -*/ - -#endif /* MC_COLOR_NCURSES_H */ diff --git a/src/tty/color-slang.c b/src/tty/color-slang.c index e79932b3e..e186554ec 100644 --- a/src/tty/color-slang.c +++ b/src/tty/color-slang.c @@ -78,10 +78,10 @@ has_colors (gboolean disable, gboolean force) } static void -mc_tty_color_pair_init_special(mc_color_pair_t *mc_color_pair, - const char *fg1, const char *bg1, - const char *fg2, const char *bg2, - SLtt_Char_Type mask) +mc_tty_color_pair_init_special (tty_color_pair_t *mc_color_pair, + const char *fg1, const char *bg1, + const char *fg2, const char *bg2, + SLtt_Char_Type mask) { if (SLtt_Use_Ansi_Colors != 0) { @@ -101,7 +101,7 @@ mc_tty_color_pair_init_special(mc_color_pair_t *mc_color_pair, } void -mc_tty_color_init_lib (gboolean disable, gboolean force) +tty_color_init_lib (gboolean disable, gboolean force) { /* FIXME: if S-Lang is used, has_colors() must be called regardless of whether we are interested in its result */ @@ -111,7 +111,12 @@ mc_tty_color_init_lib (gboolean disable, gboolean force) } void -mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *mc_color_pair) +tty_color_deinit_lib (void) +{ +} + +void +tty_color_try_alloc_pair_lib (tty_color_pair_t *mc_color_pair) { const char *fg, *bg; if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE) @@ -155,16 +160,14 @@ mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *mc_color_pair) } else { - fg = (mc_color_pair->cfg) ? mc_color_pair->cfg : "default"; bg = (mc_color_pair->cbg) ? mc_color_pair->cbg : "default"; - SLtt_set_color (mc_color_pair->pair_index, (char *) "", (char *) fg, (char *) bg); } } void -mc_tty_color_set_lib (int color) +tty_setcolor (int color) { if (!SLtt_Use_Ansi_Colors) SLsmg_set_color (color); @@ -173,19 +176,21 @@ mc_tty_color_set_lib (int color) SLsmg_set_color (A_BOLD); else SLsmg_set_color ((color & (~A_BOLD)) + 8); - } else + } else if (color == A_REVERSE) + SLsmg_set_color (A_REVERSE); + else SLsmg_set_color (color); } /* Set colorpair by index, don't interpret S-Lang "emulated attributes" */ void -mc_tty_color_lowlevel_set_lib (int color) +tty_lowlevel_setcolor (int color) { SLsmg_set_color (color & 0x7F); } void -mc_tty_color_set_normal_attrs_lib (void) +tty_set_normal_attrs (void) { SLsmg_normal_video (); } diff --git a/src/tty/color-slang.h b/src/tty/color-slang.h index dde7633d8..f8ac42970 100644 --- a/src/tty/color-slang.h +++ b/src/tty/color-slang.h @@ -31,13 +31,4 @@ enum { # define A_NORMAL 0x00 #endif -gboolean tty_use_colors (); - -#define COLOR_PAIR(x) x - -/* -#define IF_COLOR(co, bw) (tty_use_colors () ? COLOR_PAIR (co) : bw) -#define MARKED_SELECTED_COLOR IF_COLOR (4, (SLtt_Use_Ansi_Colors ? A_BOLD_REVERSE : A_REVERSE | A_BOLD)) -*/ - #endif /* MC_COLOR_SLANG_H */ diff --git a/src/tty/color.c b/src/tty/color.c index 9d9a9cdad..e48d9cf3f 100644 --- a/src/tty/color.c +++ b/src/tty/color.c @@ -61,19 +61,19 @@ static GHashTable *mc_tty_color__hashtable = NULL; /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ -static void -mc_tty_color_hash_destroy_key (gpointer data) +static inline void +color_hash_destroy_key (gpointer data) { - g_free(data); + g_free (data); } /* --------------------------------------------------------------------------------------------- */ static void -mc_tty_color_hash_destroy_value (gpointer data) +color_hash_destroy_value (gpointer data) { - mc_color_pair_t *mc_color_pair = (mc_color_pair_t *) data; - g_free(mc_color_pair); + tty_color_pair_t *mc_color_pair = (tty_color_pair_t *) data; + g_free (mc_color_pair); } /* --------------------------------------------------------------------------------------------- */ @@ -82,7 +82,7 @@ static gboolean tty_color_free_condition_cb (gpointer key, gpointer value, gpointer user_data) { gboolean is_temp_color = (gboolean) user_data; - mc_color_pair_t *mc_color_pair = (mc_color_pair_t *) value; + tty_color_pair_t *mc_color_pair = (tty_color_pair_t *) value; return (mc_color_pair->is_temp == is_temp_color); } @@ -100,7 +100,7 @@ static gboolean tty_color_get_next_cpn_cb (gpointer key, gpointer value, gpointer user_data) { int cp = (int) user_data; - mc_color_pair_t *mc_color_pair = (mc_color_pair_t *) value; + tty_color_pair_t *mc_color_pair = (tty_color_pair_t *) value; if (cp == mc_color_pair->pair_index) return TRUE; @@ -130,10 +130,10 @@ tty_color_get_next__color_pair_number() void tty_init_colors (gboolean disable, gboolean force) { - mc_tty_color_init_lib (disable, force); + tty_color_init_lib (disable, force); mc_tty_color__hashtable = g_hash_table_new_full (g_str_hash, g_str_equal, - mc_tty_color_hash_destroy_key, - mc_tty_color_hash_destroy_value); + color_hash_destroy_key, + color_hash_destroy_value); } /* --------------------------------------------------------------------------------------------- */ @@ -141,8 +141,9 @@ tty_init_colors (gboolean disable, gboolean force) void tty_colors_done (void) { - g_free(tty_color_defaults__fg); - g_free(tty_color_defaults__bg); + tty_color_deinit_lib (); + g_free (tty_color_defaults__fg); + g_free (tty_color_defaults__bg); g_hash_table_destroy (mc_tty_color__hashtable); } @@ -157,10 +158,11 @@ tty_use_colors (void) /* --------------------------------------------------------------------------------------------- */ -int tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_color) +int +tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_color) { gchar *color_pair; - mc_color_pair_t *mc_color_pair; + tty_color_pair_t *mc_color_pair; const char *c_fg, *c_bg; if (fg == NULL) @@ -170,21 +172,21 @@ int tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_ { bg = tty_color_defaults__bg; } - c_fg = mc_tty_color_get_valid_name(fg); - c_bg = mc_tty_color_get_valid_name(bg); + c_fg = tty_color_get_valid_name (fg); + c_bg = tty_color_get_valid_name (bg); - color_pair = g_strdup_printf("%s.%s",c_fg,c_bg); + color_pair = g_strdup_printf ("%s.%s",c_fg,c_bg); if (color_pair == NULL) return 0; - mc_color_pair = (mc_color_pair_t *) g_hash_table_lookup (mc_tty_color__hashtable, (gpointer) color_pair); + mc_color_pair = (tty_color_pair_t *) g_hash_table_lookup (mc_tty_color__hashtable, (gpointer) color_pair); if (mc_color_pair != NULL){ g_free(color_pair); return mc_color_pair->pair_index; } - mc_color_pair = g_new0(mc_color_pair_t,1); + mc_color_pair = g_new0 (tty_color_pair_t, 1); if (mc_color_pair == NULL) { g_free(color_pair); @@ -194,11 +196,11 @@ int tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_ mc_color_pair->is_temp = is_temp_color; mc_color_pair->cfg = c_fg; mc_color_pair->cbg = c_bg; - mc_color_pair->ifg = mc_tty_color_get_index_by_name(c_fg); - mc_color_pair->ibg = mc_tty_color_get_index_by_name(c_bg); + mc_color_pair->ifg = tty_color_get_index_by_name (c_fg); + mc_color_pair->ibg = tty_color_get_index_by_name (c_bg); mc_color_pair->pair_index = tty_color_get_next__color_pair_number(); - mc_tty_color_try_alloc_pair_lib (mc_color_pair); + tty_color_try_alloc_pair_lib (mc_color_pair); g_hash_table_insert (mc_tty_color__hashtable, (gpointer) color_pair, (gpointer) mc_color_pair); @@ -207,34 +209,14 @@ int tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_ /* --------------------------------------------------------------------------------------------- */ -int tty_try_alloc_color_pair (const char *fg, const char *bg) +int +tty_try_alloc_color_pair (const char *fg, const char *bg) { return tty_try_alloc_color_pair2 (fg, bg, TRUE); } /* --------------------------------------------------------------------------------------------- */ -void tty_setcolor (int color) -{ - mc_tty_color_set_lib (color); -} - -/* --------------------------------------------------------------------------------------------- */ - -void tty_lowlevel_setcolor (int color) -{ - mc_tty_color_lowlevel_set_lib(color); -} - -/* --------------------------------------------------------------------------------------------- */ - -void tty_set_normal_attrs (void) -{ - mc_tty_color_set_normal_attrs_lib(); -} - -/* --------------------------------------------------------------------------------------------- */ - void tty_color_free_all_tmp(void) { @@ -252,13 +234,13 @@ tty_color_free_all_non_tmp(void) /* --------------------------------------------------------------------------------------------- */ void -tty_color_set_defaults( const char *fgcolor, const char *bgcolor) +tty_color_set_defaults (const char *fgcolor, const char *bgcolor) { g_free(tty_color_defaults__fg); g_free(tty_color_defaults__fg); - tty_color_defaults__fg = (fgcolor)? g_strdup(fgcolor):NULL; - tty_color_defaults__bg = (bgcolor)? g_strdup(bgcolor):NULL; + tty_color_defaults__fg = (fgcolor != NULL) ? g_strdup (fgcolor) : NULL; + tty_color_defaults__bg = (bgcolor != NULL) ? g_strdup (bgcolor) : NULL; } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/tty/color.h b/src/tty/color.h index a244c1f8e..c586d8de2 100644 --- a/src/tty/color.h +++ b/src/tty/color.h @@ -17,7 +17,7 @@ #ifdef HAVE_SLANG # include "../../src/tty/color-slang.h" #else -# include "../../src/tty/color-ncurses.h" +# include "../../src/tty/tty-ncurses.h" #endif extern char *command_line_colors; @@ -29,14 +29,14 @@ gboolean tty_use_colors (void); int tty_try_alloc_color_pair (const char *, const char *); int tty_try_alloc_color_pair2 (const char *, const char *, gboolean); -void tty_color_free_all_tmp(void); -void tty_color_free_all_non_tmp(void); +void tty_color_free_all_tmp (void); +void tty_color_free_all_non_tmp (void); void tty_setcolor (int color); void tty_lowlevel_setcolor (int color); void tty_set_normal_attrs (void); -void tty_color_set_defaults( const char *, const char *); +void tty_color_set_defaults (const char *, const char *); #define ALLOC_COLOR_PAIR_INDEX 1 diff --git a/src/tty/tty-ncurses.c b/src/tty/tty-ncurses.c index c70cf3c26..f26bf24a4 100644 --- a/src/tty/tty-ncurses.c +++ b/src/tty/tty-ncurses.c @@ -43,8 +43,7 @@ #endif #include "../../src/tty/tty-internal.h" /* slow_tty */ -#include "../../src/tty/tty.h" /* tty_draw_box_slow */ -#include "../../src/tty/color-ncurses.h" +#include "../../src/tty/tty.h" #include "../../src/tty/color-internal.h" #include "../../src/tty/win.h" @@ -67,7 +66,58 @@ /*** file scope functions **********************************************/ +/* --------------------------------------------------------------------------------------------- */ /*** public functions **************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +int +mc_tty_normalize_lines_char(const char *ch) +{ + int i; + struct mc_tty_lines_struct { + const char *line; + int line_code; + } const lines_codes[] = + { + {"┌", ACS_BSSB}, + {"┐", ACS_BBSS}, + {"└", ACS_SSBB}, + {"┘", ACS_SBBS}, + {"├", ACS_SBSS}, + {"┤", ACS_SSSB}, + {"┬", ACS_BSSS}, + {"┴", ACS_SSBS}, + {"─", ACS_BSBS}, + {"│", ACS_SBSB}, + {"┼", ACS_SSSS}, + {"╔", ACS_BSSB | A_BOLD}, + {"╗", ACS_BBSS | A_BOLD}, + {"╤", ACS_BSSS | A_BOLD}, + {"╧", ACS_SSBS | A_BOLD}, + {"╚", ACS_SSBB | A_BOLD}, + {"╝", ACS_SBBS | A_BOLD}, + {"╟", ACS_SSSB | A_BOLD}, + {"╢", ACS_SBSS | A_BOLD}, + {"═", ACS_BSBS | A_BOLD}, + {"║", ACS_SBSB | A_BOLD}, + {NULL,0} + }; + + if (ch == NULL) + return (int) ' '; + + for(i=0;lines_codes[i].line;i++) + { + if (strcmp(ch,lines_codes[i].line) == 0) + return lines_codes[i].line_code; + } + + return (int) ' '; + +} + +/* --------------------------------------------------------------------------------------------- */ + void tty_init (gboolean slow, gboolean ugly_lines) @@ -193,9 +243,8 @@ tty_getyx (int *py, int *px) void tty_draw_hline (int y, int x, int ch, int len) { - if (ch == ACS_HLINE) { + if (ch == ACS_HLINE) ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]; - } if ((y >= 0) && (x >= 0)) move (y, x); @@ -206,33 +255,14 @@ tty_draw_hline (int y, int x, int ch, int len) void tty_draw_vline (int y, int x, int ch, int len) { + if (ch == ACS_VLINE) + ch = mc_tty_ugly_frm[MC_TTY_FRM_thinvert]; + if ((y >= 0) && (x >= 0)) move (y, x); vline (ch, len); } -void -tty_draw_box (int y, int x, int rows, int cols) -{ - -#define waddc(_y, _x, c) move (_y, _x); addch (c) - waddc (y, x, mc_tty_ugly_frm[MC_TTY_FRM_lefttop]); - hline (mc_tty_ugly_frm[MC_TTY_FRM_horiz], cols - 2); - waddc (y + rows - 1, x, mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]); - hline (mc_tty_ugly_frm[MC_TTY_FRM_horiz], cols - 2); - - waddc (y, x + cols - 1, mc_tty_ugly_frm[MC_TTY_FRM_righttop]); - waddc (y + rows - 1, x + cols - 1, mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]); - - move (y + 1, x); - vline (mc_tty_ugly_frm[MC_TTY_FRM_vert], rows - 2); - - move (y + 1, x + cols - 1); - vline (mc_tty_ugly_frm[MC_TTY_FRM_vert], rows - 2); -#undef waddc - -} - void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch) { @@ -269,14 +299,6 @@ tty_print_anychar (int c) { unsigned char str[6 + 1]; - if (c == ACS_RTEE ) { - c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle]; - } - - if (c == ACS_LTEE ) { - c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle]; - } - if ( c > 255 ) { int res = g_unichar_to_utf8 (c, (char *)str); if ( res == 0 ) { @@ -285,7 +307,7 @@ tty_print_anychar (int c) } else { str[res] = '\0'; } - addstr (str_term_form (str)); + addstr (str_term_form ((char *)str)); } else { addch (c); } @@ -294,6 +316,25 @@ tty_print_anychar (int c) void tty_print_alt_char (int c) { + if (c == ACS_VLINE) + c = mc_tty_ugly_frm[MC_TTY_FRM_thinvert]; + else if (c == ACS_HLINE) + c = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]; + else if (c == ACS_LTEE) + c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle]; + else if (c == ACS_RTEE) + c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle]; + else if (c == ACS_ULCORNER) + c = mc_tty_ugly_frm[MC_TTY_FRM_lefttop]; + else if (c == ACS_LLCORNER) + c = mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]; + else if (c == ACS_URCORNER) + c = mc_tty_ugly_frm[MC_TTY_FRM_righttop]; + else if (c == ACS_LRCORNER) + c = mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]; + else if (c == ACS_PLUS) + c = mc_tty_ugly_frm[MC_TTY_FRM_centermiddle]; + addch (c); } diff --git a/src/tty/tty-slang.c b/src/tty/tty-slang.c index 53bed9328..b16763b8e 100644 --- a/src/tty/tty-slang.c +++ b/src/tty/tty-slang.c @@ -44,7 +44,7 @@ #include "../../src/global.h" #include "../../src/tty/tty-internal.h" /* slow_tty */ -#include "../../src/tty/tty.h" /* tty_draw_box_slow */ +#include "../../src/tty/tty.h" #include "../../src/tty/color-slang.h" #include "../../src/tty/color-internal.h" #include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */ @@ -191,8 +191,56 @@ load_terminfo_keys (void) do_define_key (key_table [i].key_code, key_table [i].key_name); } -/*** public functions **************************************************/ +static char * +mc_tty_normalize_from_utf8 (const char *str) +{ + GIConv conv; + GString *buffer; + const char *_system_codepage = str_detect_termencoding(); + if (str_isutf8 (_system_codepage)) + return g_strdup(str); + + conv = g_iconv_open (_system_codepage, "UTF-8"); + if (conv == INVALID_CONV) + return g_strdup(str); + + buffer = g_string_new (""); + + if (str_convert (conv, str, buffer) == ESTR_FAILURE) + { + g_string_free(buffer, TRUE); + str_close_conv (conv); + return g_strdup(str); + } + str_close_conv (conv); + + return g_string_free(buffer, FALSE); +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions **************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +int +mc_tty_normalize_lines_char(const char *str) +{ + char *str2; + int res; + + if (!str) + return (int) ' '; + str2 = mc_tty_normalize_from_utf8 (str); + res = g_utf8_get_char_validated (str2, -1); + + if (res < 0) + res = (unsigned char) str2[0]; + g_free(str2); + + return res; +} + +/* --------------------------------------------------------------------------------------------- */ void tty_init (gboolean slow, gboolean ugly_lines) { @@ -439,13 +487,6 @@ tty_draw_vline (int y, int x, int ch, int len) SLsmg_gotorc (y, x); } -void -tty_draw_box (int y, int x, int rows, int cols) -{ - /* this fix slang drawing stickchars bug */ - tty_draw_box_slow (y, x, rows, cols); -} - void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch) { diff --git a/src/tty/tty.c b/src/tty/tty.c index 9b3c56f85..44479faf4 100644 --- a/src/tty/tty.c +++ b/src/tty/tty.c @@ -133,7 +133,7 @@ tty_print_one_vline (void) } void -tty_draw_box_slow (int y, int x, int ys, int xs) +tty_draw_box (int y, int x, int ys, int xs) { tty_draw_vline (y, x, mc_tty_ugly_frm[MC_TTY_FRM_vert], ys); tty_draw_vline (y, x + xs - 1, mc_tty_ugly_frm[MC_TTY_FRM_vert], ys); diff --git a/src/tty/tty.h b/src/tty/tty.h index 69d310835..0e239c518 100644 --- a/src/tty/tty.h +++ b/src/tty/tty.h @@ -74,7 +74,6 @@ extern void tty_print_one_hline (void); extern void tty_draw_hline (int y, int x, int ch, int len); extern void tty_draw_vline (int y, int x, int ch, int len); extern void tty_draw_box (int y, int x, int rows, int cols); -extern void tty_draw_box_slow (int y, int x, int ys, int xs); extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch); extern int mc_tty_ugly_frm[]; @@ -107,4 +106,6 @@ extern void tty_beep (void); extern void tty_refresh (void); extern void tty_setup_sigwinch (void (*handler) (int)); +extern int mc_tty_normalize_lines_char(const char *); + #endif /* MC_TTY_H */