1
1
* Compile with option --with-screen=ncurses
 * Added default init of colors (if color description is null)
 * Renamed some color pairs. All static color pairs now cached.
 * Fix cursor show in panel over selected files in b&w color scheme.
 * Fix editor highlight
 * Handle old-style colors definitions.
 * Fix showing box lines in onebyte codepages.
 * Fix segfault with:
 * mc -C 'menu=blue,white:'
 * Fix reading of color backgrounds from old-style color definition strings.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>

 * Fixed typos.
 * Added ACS_PLUS char and related stuff.
 * Changed order of colors.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>

 * Fixed pseudo-graphics drawing for S-Lang library and 8-bit locale.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Slava Zanko 2009-09-10 15:14:18 +03:00
родитель f9a7ea4c32
Коммит 2216332c0c
28 изменённых файлов: 556 добавлений и 348 удалений

Просмотреть файл

@ -1024,6 +1024,7 @@ void edit_free_syntax_rules (WEdit * edit)
}
MC_PTR_FREE (edit->rules);
tty_color_free_all_tmp();
}
/* returns -1 on file error, line number on error in file syntax */

Просмотреть файл

@ -4,11 +4,12 @@
[directory]
type=DIR
[stalelink]
type=STALE_LINK
[symlink]
type=SYMLINK
[stalelink]
type=STALE_LINK
[device]
type=DEVICE

Просмотреть файл

@ -23,12 +23,19 @@
markselect=yellow;cyan;
gauge=white;black
input=black;cyan
reverse=black;lightgray
[dialog]
_default_=black;lightgray
focus=black;cyan
hotnormal=blue;lightgray
hotfocus=blue;cyan
dfocus=black;cyan
dhotnormal=blue;lightgray
dhotfocus=blue;cyan
[error]
_default_=white;red
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=white;
@ -50,27 +57,23 @@
[menu]
_default_=white;cyan
entry=white;cyan
hot=yellow;cyan
selected=white;black
hotselected=yellow;black
menuhot=yellow;cyan
menusel=white;black
menuhotsel=yellow;black
[help]
_default_=black;lightgray
italic=red;lightgray
bold=blue;lightgray
link=black;cyan
slink=yellow;blue
helpitalic=red;lightgray
helpbold=blue;lightgray
helplink=black;cyan
helpslink=yellow;blue
[editor]
bold=yellow;blue
marked=black;cyan
whitespace=brightblue;blue
_default_=lightgray;blue
editbold=yellow;blue
editmarked=black;cyan
editwhitespace=brightblue;blue
linestate=white;cyan
[viewer]
underline=brightred;blue
[error]
_default_=white;red
hotnormal=yellow;red
hotfocus=yellow;lightgray
viewunderline=brightred;blue

Просмотреть файл

@ -23,12 +23,19 @@
markselect=yellow;cyan;
gauge=white;black
input=black;cyan
reverse=black;lightgray
[dialog]
_default_=black;lightgray
focus=black;cyan
hotnormal=blue;lightgray
hotfocus=blue;cyan
dfocus=black;cyan
dhotnormal=blue;lightgray
dhotfocus=blue;cyan
[error]
_default_=white;red
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=white;
@ -50,27 +57,23 @@
[menu]
_default_=white;cyan
entry=white;cyan
hot=yellow;cyan
selected=white;black
hotselected=yellow;black
menuhot=yellow;cyan
menusel=white;black
menuhotsel=yellow;black
[help]
_default_=black;lightgray
italic=red;lightgray
bold=blue;lightgray
link=black;cyan
slink=yellow;blue
helpitalic=red;lightgray
helpbold=blue;lightgray
helplink=black;cyan
helpslink=yellow;blue
[editor]
bold=yellow;blue
marked=black;cyan
whitespace=brightblue;blue
_default_=lightgray;blue
editbold=yellow;blue
editmarked=black;cyan
editwhitespace=brightblue;blue
linestate=white;cyan
[viewer]
underline=brightred;blue
[error]
_default_=white;red
hotnormal=yellow;red
hotfocus=yellow;lightgray
viewunderline=brightred;blue

Просмотреть файл

@ -89,7 +89,7 @@ mc_fhl_new (gboolean need_auto_fill)
return NULL;
}
if (!mc_fhl_parce_ini_file (fhl)) {
if (!mc_fhl_parse_ini_file (fhl)) {
mc_fhl_free (&fhl);
return NULL;
}

Просмотреть файл

@ -28,7 +28,7 @@ void mc_fhl_free (mc_fhl_t **);
int mc_fhl_get_color (mc_fhl_t *, file_entry *);
gboolean mc_fhl_read_ini_file (mc_fhl_t *, const gchar *);
gboolean mc_fhl_parce_ini_file (mc_fhl_t *);
gboolean mc_fhl_parse_ini_file (mc_fhl_t *);
void mc_fhl_clear (mc_fhl_t *);
#endif

Просмотреть файл

@ -1,6 +1,6 @@
/*
File highlight plugin.
Reading and parce rules from ini-files
Reading and parse rules from ini-files
Copyright (C) 2009 The Free Software Foundation, Inc.
@ -49,7 +49,7 @@ extern mc_skin_t mc_skin__default;
/* --------------------------------------------------------------------------------------------- */
static void
mc_fhl_parce_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const gchar * group_name)
{
(void) fhl;
mc_filter->color_pair_index = mc_skin_color_get("filehighlight", group_name);
@ -58,7 +58,7 @@ mc_fhl_parce_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parce_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
{
mc_fhl_filter_t *mc_filter;
@ -90,7 +90,7 @@ mc_fhl_parce_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
mc_filter = g_new0 (mc_fhl_filter_t, 1);
mc_filter->type = MC_FLHGH_T_FTYPE;
mc_filter->file_type = (mc_flhgh_ftype_type) i;
mc_fhl_parce_fill_color_info (mc_filter, fhl, group_name);
mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
return TRUE;
@ -99,7 +99,7 @@ mc_fhl_parce_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parce_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
{
mc_fhl_filter_t *mc_filter;
gchar *regexp = mc_config_get_string (fhl->config, group_name, "regexp", "");
@ -115,7 +115,7 @@ mc_fhl_parce_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
mc_filter->search_condition->is_case_sentitive = TRUE;
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;
mc_fhl_parce_fill_color_info (mc_filter, fhl, group_name);
mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
g_free (regexp);
return TRUE;
@ -125,7 +125,7 @@ mc_fhl_parce_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parce_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
{
mc_fhl_filter_t *mc_filter;
gchar **exts, **exts_orig;
@ -165,7 +165,7 @@ mc_fhl_parce_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
mc_filter->search_condition->is_case_sentitive = TRUE;
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;
mc_fhl_parce_fill_color_info (mc_filter, fhl, group_name);
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;
@ -239,7 +239,7 @@ mc_fhl_init_from_standart_files (mc_fhl_t * fhl)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_fhl_parce_ini_file (mc_fhl_t * fhl)
mc_fhl_parse_ini_file (mc_fhl_t * fhl)
{
gchar **group_names, **orig_group_names;
gsize ftype_names_size;
@ -256,14 +256,14 @@ mc_fhl_parce_ini_file (mc_fhl_t * fhl)
while (*group_names) {
if (mc_config_has_param (fhl->config, *group_names, "type")) {
/* parce filetype filter */
mc_fhl_parce_get_file_type_id (fhl, *group_names);
/* parse filetype filter */
mc_fhl_parse_get_file_type_id (fhl, *group_names);
} else if (mc_config_has_param (fhl->config, *group_names, "regexp")) {
/* parce regexp filter */
mc_fhl_parce_get_regexp (fhl, *group_names);
/* parse regexp filter */
mc_fhl_parse_get_regexp (fhl, *group_names);
} else if (mc_config_has_param (fhl->config, *group_names, "extensions")) {
/* parce extensions filter */
mc_fhl_parce_get_extensions (fhl, *group_names);
/* parse extensions filter */
mc_fhl_parse_get_extensions (fhl, *group_names);
}
group_names++;
}

Просмотреть файл

@ -40,6 +40,7 @@
#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,6 +684,11 @@ load_setup (void)
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)

1
src/skin/BUGS.txt Обычный файл
Просмотреть файл

@ -0,0 +1 @@
1) CHECK in ncurses !!!

Просмотреть файл

@ -32,6 +32,8 @@
#include "../src/global.h"
#include "../src/setup.h"
#include "skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/
@ -40,68 +42,117 @@
/*** file scope type declarations ****************************************************************/
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}
};
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static void
configure_colors_string (const char *the_color_string)
static gboolean
mc_skin_colors_old_transform(const char *old_color, const char **group, const char **key)
{
/*
const size_t map_len = color_map_len ();
int index;
size_t i;
char **color_strings, **p;
if (old_color == NULL)
return FALSE;
if (!the_color_string)
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;
}
}
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_colors_old_configure_one (mc_skin_t *mc_skin, const char *the_color_string)
{
gchar **colors, **orig_colors;
gchar **key_val;
const gchar *skin_group, *skin_key;
gchar *skin_val;
if (the_color_string == NULL)
return;
color_strings = g_strsplit (the_color_string, ":", -1);
orig_colors = colors = g_strsplit (the_color_string, ":", -1);
if (colors == NULL)
return;
p = color_strings;
for(;*colors; colors++)
{
key_val = g_strsplit_set (*colors, "=,", 3);
while ((p != NULL) && (*p != NULL)) {
char **cfb;
if (!key_val)
continue;
// color, fore, back
// cfb[0] - entry name
// cfb[1] - fore color
// cfb[2] - back color
char *e;
cfb = g_strsplit_set (*p, "=,", 3);
p++;
if (cfb[0] == NULL) {
g_strfreev (cfb);
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);
// append '=' to the entry name
e = g_strdup_printf ("%s=", cfb[0]);
g_free (cfb[0]);
cfb[0] = e;
g_free(skin_val);
for (i = 0; i < map_len; i++)
if (color_map [i].name != NULL) {
size_t klen = strlen (color_map [i].name);
if (strncmp (cfb[0], color_map [i].name, klen) == 0) {
if ((cfb[1] != NULL) && (*cfb[1] != '\0'))
get_color (cfb[1], &color_map [i].fg);
if ((cfb[2] != NULL) && (*cfb[2] != '\0'))
get_color (cfb[2], &color_map [i].bg);
break;
g_strfreev (key_val);
}
}
g_strfreev (cfb);
}
g_strfreev (color_strings);
*/
g_strfreev (orig_colors);
}
/* --------------------------------------------------------------------------------------------- */
@ -109,12 +160,12 @@ configure_colors_string (const char *the_color_string)
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_colors_old_configure (void)
mc_skin_colors_old_configure (mc_skin_t *mc_skin)
{
configure_colors_string (setup_color_string);
configure_colors_string (term_color_string);
configure_colors_string (getenv ("MC_COLOR_TABLE"));
configure_colors_string (command_line_colors);
mc_skin_colors_old_configure_one (mc_skin, setup_color_string);
mc_skin_colors_old_configure_one (mc_skin, term_color_string);
mc_skin_colors_old_configure_one (mc_skin, getenv ("MC_COLOR_TABLE"));
mc_skin_colors_old_configure_one (mc_skin, command_line_colors);
}
/* --------------------------------------------------------------------------------------------- */

Просмотреть файл

@ -48,18 +48,18 @@ int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT];
/* --------------------------------------------------------------------------------------------- */
inline static gchar *
mc_skin_color_make_hash_key(const gchar *group, const gchar *key)
mc_skin_color_make_hash_key (const gchar * group, const gchar * key)
{
return g_strdup_printf("%s.%s", group, 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)
mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gchar *key_name;
mc_skin_color_t * mc_skin_color;
mc_skin_color_t *mc_skin_color;
if (group == NULL || key == NULL)
return NULL;
@ -67,9 +67,9 @@ mc_skin_color_get_from_hash(mc_skin_t *mc_skin, const gchar *group, const gchar
if (mc_skin == NULL)
mc_skin = &mc_skin__default;
key_name = mc_skin_color_make_hash_key(group, key);
key_name = mc_skin_color_make_hash_key (group, key);
mc_skin_color = (mc_skin_color_t *) g_hash_table_lookup (mc_skin->colors, (gpointer) key_name);
g_free(key_name);
g_free (key_name);
return mc_skin_color;
}
@ -77,7 +77,7 @@ mc_skin_color_get_from_hash(mc_skin_t *mc_skin, const gchar *group, const gchar
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_remove_from_hash(mc_skin_t *mc_skin, const gchar *group, const gchar *key)
mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gchar *key_name;
if (group == NULL || key == NULL)
@ -86,24 +86,24 @@ mc_skin_color_remove_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);
key_name = mc_skin_color_make_hash_key (group, key);
g_hash_table_remove (mc_skin->colors, (gpointer) key_name);
g_free(key_name);
g_free (key_name);
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_add_to_hash(mc_skin_t *mc_skin, const gchar *group, const gchar *key, mc_skin_color_t *mc_skin_color)
mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key,
mc_skin_color_t * mc_skin_color)
{
gchar *key_name;
key_name = mc_skin_color_make_hash_key(group, key);
key_name = mc_skin_color_make_hash_key (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);
}
@ -113,26 +113,26 @@ mc_skin_color_add_to_hash(mc_skin_t *mc_skin, const gchar *group, const gchar *k
/* --------------------------------------------------------------------------------------------- */
static mc_skin_color_t *
mc_skin_color_get_with_defaults(const gchar *group, const gchar *name)
mc_skin_color_get_with_defaults (const gchar * group, const gchar * name)
{
mc_skin_color_t *mc_skin_color;
mc_skin_color = mc_skin_color_get_from_hash(NULL, group, name);
mc_skin_color = mc_skin_color_get_from_hash (NULL, group, name);
if (mc_skin_color != NULL)
return mc_skin_color;
mc_skin_color = mc_skin_color_get_from_hash(NULL, group, "_default_");
mc_skin_color = mc_skin_color_get_from_hash (NULL, group, "_default_");
if (mc_skin_color != NULL)
return mc_skin_color;
mc_skin_color = mc_skin_color_get_from_hash(NULL, "core", "_default_");
mc_skin_color = mc_skin_color_get_from_hash (NULL, "core", "_default_");
return mc_skin_color;
}
/* --------------------------------------------------------------------------------------------- */
static mc_skin_color_t *
mc_skin_color_get_from_ini_file(mc_skin_t *mc_skin, const gchar *group, const gchar *key)
mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gsize items_count;
gchar **values;
@ -140,52 +140,47 @@ mc_skin_color_get_from_ini_file(mc_skin_t *mc_skin, const gchar *group, const gc
values = mc_config_get_string_list (mc_skin->config, group, key, &items_count);
if (values == NULL || *values == NULL)
{
if (values == NULL || *values == NULL) {
if (values)
g_strfreev(values);
g_strfreev (values);
return NULL;
}
mc_skin_color = g_new0(mc_skin_color_t,1);
if (mc_skin_color == NULL)
{
g_strfreev(values);
mc_skin_color = g_new0 (mc_skin_color_t, 1);
if (mc_skin_color == NULL) {
g_strfreev (values);
return NULL;
}
switch (items_count)
{
switch (items_count) {
case 0:
tmp = mc_skin_color_get_with_defaults(group, "_default_");
if (tmp)
{
mc_skin_color->fgcolor = g_strdup(tmp->fgcolor);
mc_skin_color->bgcolor = g_strdup(tmp->bgcolor);
}
else
{
g_strfreev(values);
g_free(mc_skin_color);
tmp = mc_skin_color_get_with_defaults (group, "_default_");
if (tmp) {
mc_skin_color->fgcolor = g_strdup (tmp->fgcolor);
mc_skin_color->bgcolor = g_strdup (tmp->bgcolor);
} else {
g_strfreev (values);
g_free (mc_skin_color);
return NULL;
}
break;
case 1:
mc_skin_color->fgcolor = (values[0]) ? g_strdup(values[0]) : NULL;
tmp = mc_skin_color_get_with_defaults(group, "_default_");
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);
mc_skin_color->bgcolor = g_strdup (tmp->bgcolor);
else
mc_skin_color->bgcolor = NULL;
break;
case 2:
mc_skin_color->fgcolor = (values[0]) ? g_strdup(values[0]) : NULL;
mc_skin_color->bgcolor = (values[1]) ? g_strdup(values[1]) : NULL;
mc_skin_color->fgcolor = (values[0]) ? g_strdup (values[0]) : NULL;
mc_skin_color->bgcolor = (values[1]) ? g_strdup (values[1]) : NULL;
break;
}
g_strfreev (values);
mc_skin_color->pair_index = tty_try_alloc_color_pair (mc_skin_color->fgcolor, mc_skin_color->bgcolor);
mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);
return mc_skin_color;
}
@ -193,38 +188,73 @@ mc_skin_color_get_from_ini_file(mc_skin_t *mc_skin, const gchar *group, const gc
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_set_default_for_terminal(mc_skin_t *mc_skin)
mc_skin_color_set_default_for_terminal (mc_skin_t * mc_skin)
{
mc_skin_color_t *mc_skin_color;
mc_skin_color = g_new0(mc_skin_color_t,1);
mc_skin_color = g_new0 (mc_skin_color_t, 1);
if (mc_skin_color == NULL)
return;
mc_skin_color->fgcolor = g_strdup("default");
mc_skin_color->bgcolor = g_strdup("default");
mc_skin_color->pair_index = tty_try_alloc_color_pair (mc_skin_color->fgcolor, mc_skin_color->bgcolor);
mc_skin_color_add_to_hash(mc_skin, "skin", "terminal_default_color", mc_skin_color);
mc_skin_color->fgcolor = g_strdup ("default");
mc_skin_color->bgcolor = g_strdup ("default");
mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);
mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color);
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_cache_init(void)
mc_skin_color_cache_init (void)
{
DEFAULT_COLOR = mc_skin_color_get("skin", "terminal_default_color");
NORMAL_COLOR = mc_skin_color_get("core", "_default_");
MARKED_COLOR = mc_skin_color_get("core", "marked");
SELECTED_COLOR = mc_skin_color_get("core", "selected");
REVERSE_COLOR = mc_skin_color_get("core", "reverse");
DEFAULT_COLOR = mc_skin_color_get ("skin", "terminal_default_color");
NORMAL_COLOR = mc_skin_color_get ("core", "_default_");
MARKED_COLOR = mc_skin_color_get ("core", "marked");
SELECTED_COLOR = mc_skin_color_get ("core", "selected");
REVERSE_COLOR = mc_skin_color_get ("core", "reverse");
MARKED_SELECTED_COLOR = mc_skin_color_get ("core", "markselect");
ERROR_COLOR = mc_skin_color_get ("error", "_default_");
MENU_ENTRY_COLOR = mc_skin_color_get ("menu", "_default_");
COLOR_NORMAL = mc_skin_color_get ("dialog", "_default_");
COLOR_FOCUS = mc_skin_color_get ("dialog", "dfocus");
COLOR_HOT_NORMAL = mc_skin_color_get ("dialog", "dhotnormal");
COLOR_HOT_FOCUS = mc_skin_color_get ("dialog", "dhotfocus");
VIEW_UNDERLINED_COLOR = mc_skin_color_get ("viewer", "viewunderline");
MENU_SELECTED_COLOR = mc_skin_color_get ("menu", "menusel");
MENU_HOT_COLOR = mc_skin_color_get ("menu", "menuhot");
MENU_HOTSEL_COLOR = mc_skin_color_get ("menu", "menuhotsel");
HELP_NORMAL_COLOR = mc_skin_color_get ("help", "_default_");
HELP_ITALIC_COLOR = mc_skin_color_get ("help", "helpitalic");
HELP_BOLD_COLOR = mc_skin_color_get ("help", "helpbold");
HELP_LINK_COLOR = mc_skin_color_get ("help", "helplink");
HELP_SLINK_COLOR = mc_skin_color_get ("help", "helpslink");
GAUGE_COLOR = mc_skin_color_get ("core", "gauge");
INPUT_COLOR = mc_skin_color_get ("core", "input");
EDITOR_NORMAL_COLOR = mc_skin_color_get ("editor", "_default_");
EDITOR_BOLD_COLOR = mc_skin_color_get ("editor", "editbold");
EDITOR_MARKED_COLOR = mc_skin_color_get ("editor", "editmarked");
EDITOR_WHITESPACE_COLOR = mc_skin_color_get ("editor", "editwhitespace");
ERROR_HOT_NORMAL = mc_skin_color_get ("error", "errdhotnormal");
ERROR_HOT_FOCUS = mc_skin_color_get ("error", "errdhotfocus");
LINE_STATE_COLOR = mc_skin_color_get ("editor", "linestate");
}
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_skin_color_check_inisection(const gchar *group)
mc_skin_color_check_inisection (const gchar * group)
{
if (strcasecmp("skin",group) == 0)
if (strcasecmp ("skin", group) == 0)
return FALSE;
if (strcasecmp("lines",group) == 0)
if (strcasecmp ("lines", group) == 0)
return FALSE;
return TRUE;
@ -233,12 +263,12 @@ mc_skin_color_check_inisection(const gchar *group)
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_check_bw_mode(mc_skin_t *mc_skin)
mc_skin_color_check_bw_mode (mc_skin_t * mc_skin)
{
gsize items_count;
gchar **groups, **orig_groups;
if (! mc_args__disable_colors)
if (!mc_args__disable_colors)
return;
orig_groups = groups = mc_config_get_groups (mc_skin->config, &items_count);
@ -247,15 +277,14 @@ mc_skin_color_check_bw_mode(mc_skin_t *mc_skin)
return;
for(;*groups; groups++)
{
if (!mc_skin_color_check_inisection(*groups))
for (; *groups; groups++) {
if (!mc_skin_color_check_inisection (*groups))
continue;
mc_config_del_group (mc_skin->config, *groups);
}
g_strfreev(orig_groups);
mc_skin_hardcoded_blackwhite_colors(mc_skin);
g_strfreev (orig_groups);
mc_skin_hardcoded_blackwhite_colors (mc_skin);
}
/* --------------------------------------------------------------------------------------------- */
@ -263,69 +292,65 @@ mc_skin_color_check_bw_mode(mc_skin_t *mc_skin)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_color_parce_ini_file(mc_skin_t *mc_skin)
mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
{
gsize items_count;
gchar **groups, **orig_groups;
gchar **keys, **orig_keys;
mc_skin_color_t *mc_skin_color;
mc_skin_color_check_bw_mode(mc_skin);
mc_skin_color_check_bw_mode (mc_skin);
orig_groups = groups = mc_config_get_groups (mc_skin->config, &items_count);
if (groups == NULL || *groups == NULL)
{
if (groups == NULL || *groups == NULL) {
if (groups)
g_strfreev(groups);
g_strfreev (groups);
return FALSE;
}
/* as first, need to set up default colors */
mc_skin_color_set_default_for_terminal(mc_skin);
mc_skin_color = mc_skin_color_get_from_ini_file(mc_skin, "core", "_default_");
mc_skin_color_set_default_for_terminal (mc_skin);
mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, "core", "_default_");
if (mc_skin_color == NULL)
return FALSE;
mc_skin_color_add_to_hash(mc_skin, "core", "_default_", mc_skin_color);
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++)
{
if (!mc_skin_color_check_inisection(*groups))
for (; *groups; 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)
{
orig_keys = keys = mc_config_get_keys (mc_skin->config, *groups, &items_count);
if (keys == NULL || *keys == NULL) {
if (keys)
g_strfreev(keys);
g_strfreev (keys);
continue;
}
for(;*keys; keys++)
{
mc_skin_color = mc_skin_color_get_from_ini_file(mc_skin, *groups, *keys);
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);
mc_skin_color_add_to_hash (mc_skin, *groups, *keys, mc_skin_color);
}
g_strfreev(orig_keys);
g_strfreev (orig_keys);
}
g_strfreev(orig_groups);
g_strfreev (orig_groups);
mc_skin_color_cache_init();
mc_skin_color_cache_init ();
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
int
mc_skin_color_get(const gchar *group, const gchar *name)
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);
mc_skin_color = mc_skin_color_get_with_defaults (group, name);
if (mc_skin_color == NULL)
return 0;

Просмотреть файл

@ -115,12 +115,14 @@ mc_skin_init(void)
mc_skin_reinit();
mc_skin_set_hardcoded_skin(&mc_skin__default);
}
mc_skin_colors_old_configure (&mc_skin__default);
if (! mc_skin_ini_file_parce(&mc_skin__default))
if (! mc_skin_ini_file_parse(&mc_skin__default))
{
mc_skin_reinit();
mc_skin_set_hardcoded_skin(&mc_skin__default);
(void) mc_skin_ini_file_parce(&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;
}

Просмотреть файл

@ -1,6 +1,6 @@
/*
Skins engine.
Reading and parce ini-files
Reading and parse ini-files
Copyright (C) 2009 The Free Software Foundation, Inc.
@ -117,13 +117,13 @@ mc_skin_ini_file_load (mc_skin_t *mc_skin)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_ini_file_parce(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_parce_ini_file(mc_skin))
if (! mc_skin_color_parse_ini_file(mc_skin))
return FALSE;
mc_skin_lines_parce_ini_file(mc_skin);
mc_skin_lines_parse_ini_file(mc_skin);
return TRUE;
}

Просмотреть файл

@ -3,8 +3,6 @@
/*** typedefs(not structures) and defined constants **********************************************/
#define MC_SKIN_COLOR_CACHE_COUNT 5
/*** enums ***************************************************************************************/
/*** structures declarations (and typedefs of structures)*****************************************/
@ -23,16 +21,16 @@ extern mc_skin_t mc_skin__default;
gboolean mc_skin_ini_file_load(mc_skin_t *);
gboolean mc_skin_ini_file_parce(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_parce_colors(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_lines_parce_ini_file(mc_skin_t *);
void mc_skin_colors_old_configure (mc_skin_t *);
#endif

Просмотреть файл

@ -56,7 +56,7 @@ mc_skin_lines_srt_to_char (char* str)
res = g_utf8_get_char_validated (str, -1);
if ( res < 0 ) {
return (int) *str;
return (unsigned char) str[0];
} else {
return res;
}
@ -71,7 +71,22 @@ mc_skin_lines_load_frm(mc_skin_t *mc_skin, const char *name)
char *frm_val = NULL;
frm_val = mc_config_get_string(mc_skin->config, "Lines", name, " ");
ret = mc_skin_lines_srt_to_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;
}
return ret;
}
@ -80,12 +95,13 @@ mc_skin_lines_load_frm(mc_skin_t *mc_skin, const char *name)
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_lines_parce_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)
}
else if (mc_args__ugly_line_drawing)
{
mc_skin_hardcoded_ugly_lines(mc_skin);
}
@ -101,6 +117,7 @@ mc_skin_lines_parce_ini_file(mc_skin_t *mc_skin)
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");
}

Просмотреть файл

@ -15,55 +15,54 @@
#define NORMAL_COLOR mc_skin_color__cache[1]
#define MARKED_COLOR mc_skin_color__cache[2]
#define SELECTED_COLOR mc_skin_color__cache[3]
#define REVERSE_COLOR mc_skin_color__cache[4]
#define MARKED_SELECTED_COLOR mc_skin_color_get("core", "markselect")
#define ERROR_COLOR mc_skin_color_get("error", "_default_")
#define MENU_ENTRY_COLOR mc_skin_color_get("menu", "_default_")
#define MARKED_SELECTED_COLOR mc_skin_color__cache[4]
#define REVERSE_COLOR mc_skin_color__cache[5]
/* Dialog colors */
#define COLOR_NORMAL mc_skin_color_get("dialog", "_default_")
#define COLOR_FOCUS mc_skin_color_get("dialog", "focus")
#define COLOR_HOT_NORMAL mc_skin_color_get("dialog", "hotnormal")
#define COLOR_HOT_FOCUS mc_skin_color_get("dialog", "hotfocus")
#define COLOR_NORMAL mc_skin_color__cache[6]
#define COLOR_FOCUS mc_skin_color__cache[7]
#define COLOR_HOT_NORMAL mc_skin_color__cache[8]
#define COLOR_HOT_FOCUS mc_skin_color__cache[9]
#define VIEW_UNDERLINED_COLOR mc_skin_color_get("viewer", "underline")
#define MENU_SELECTED_COLOR mc_skin_color_get("menu", "selected")
#define MENU_HOT_COLOR mc_skin_color_get("menu", "hot")
#define MENU_HOTSEL_COLOR mc_skin_color_get("menu", "hotselected")
/* Error dialog colors */
#define ERROR_COLOR mc_skin_color__cache[10]
#define ERROR_HOT_NORMAL mc_skin_color__cache[11]
#define ERROR_HOT_FOCUS mc_skin_color__cache[12]
#define HELP_NORMAL_COLOR mc_skin_color_get("help", "_default_")
#define HELP_ITALIC_COLOR mc_skin_color_get("help", "italic")
#define HELP_BOLD_COLOR mc_skin_color_get("help", "bold")
#define HELP_LINK_COLOR mc_skin_color_get("help", "link")
#define HELP_SLINK_COLOR mc_skin_color_get("help", "slink")
/* Menu colors */
#define MENU_ENTRY_COLOR mc_skin_color__cache[13]
#define MENU_SELECTED_COLOR mc_skin_color__cache[14]
#define MENU_HOT_COLOR mc_skin_color__cache[15]
#define MENU_HOTSEL_COLOR mc_skin_color__cache[16]
/*
* This should be selectable independently. Default has to be black background
* foreground does not matter at all.
*/
#define GAUGE_COLOR mc_skin_color_get("core", "gauge")
#define INPUT_COLOR mc_skin_color_get("core", "input")
#define GAUGE_COLOR mc_skin_color__cache[17]
#define INPUT_COLOR mc_skin_color__cache[18]
#define HELP_NORMAL_COLOR mc_skin_color__cache[19]
#define HELP_ITALIC_COLOR mc_skin_color__cache[20]
#define HELP_BOLD_COLOR mc_skin_color__cache[21]
#define HELP_LINK_COLOR mc_skin_color__cache[22]
#define HELP_SLINK_COLOR mc_skin_color__cache[23]
#define VIEW_UNDERLINED_COLOR mc_skin_color__cache[24]
/*
* editor colors - only 4 for normal, search->found, select, and whitespace
* respectively
* Last is defined to view color.
*/
#define EDITOR_NORMAL_COLOR mc_skin_color_get("editor", "_default_")
#define EDITOR_BOLD_COLOR mc_skin_color_get("editor", "bold")
#define EDITOR_MARKED_COLOR mc_skin_color_get("editor", "marked")
#define EDITOR_WHITESPACE_COLOR mc_skin_color_get("editor", "whitespace")
#define EDITOR_NORMAL_COLOR mc_skin_color__cache[25]
#define EDITOR_BOLD_COLOR mc_skin_color__cache[26]
#define EDITOR_MARKED_COLOR mc_skin_color__cache[27]
#define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[28]
/* color of left 8 char status per line */
#define LINE_STATE_COLOR mc_skin_color_get("editor", "linestate")
/* Error dialog colors */
#define ERROR_HOT_NORMAL mc_skin_color_get("error", "hotnormal")
#define ERROR_HOT_FOCUS mc_skin_color_get("error", "hotfocus")
#define LINE_STATE_COLOR mc_skin_color__cache[29]
#define MC_SKIN_COLOR_CACHE_COUNT 30
/*** enums ***************************************************************************************/
@ -83,6 +82,7 @@ typedef struct mc_skin_struct{
/*** global variables defined in .c file *********************************************************/
extern int mc_skin_color__cache[];
extern mc_skin_t mc_skin__default;
/*** declarations of public functions ************************************************************/
@ -91,5 +91,6 @@ void mc_skin_deinit(void);
int mc_skin_color_get(const gchar *, const gchar *);
void mc_skin_lines_parse_ini_file(mc_skin_t *);
#endif

Просмотреть файл

@ -19,7 +19,6 @@
extern gboolean use_colors;
extern gboolean mc_tty_color_disable;
#ifdef HAVE_SLANG
# define CTYPE const char *
#else
@ -32,6 +31,7 @@ typedef struct mc_color_pair_struct {
int ifg;
int ibg;
int pair_index;
gboolean is_temp;
} mc_color_pair_t;
typedef enum

Просмотреть файл

@ -36,8 +36,6 @@
#include "../../src/tty/color.h" /* variables */
#include "../../src/tty/color-internal.h"
int attr_pairs [MAX_PAIRS];
void
mc_tty_color_init_lib (gboolean disable, gboolean force)
{
@ -56,9 +54,16 @@ mc_tty_color_init_lib (gboolean disable, gboolean force)
void
mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *mc_color_pair)
{
if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE)
{
/* TODO: !!!!! */
}
else
{
init_pair (mc_color_pair->pair_index,
mc_color_pair->ifg,
mc_color_pair->ibg == 0 ? -1 : mc_color_pair->ibg);
}
}
void

Просмотреть файл

@ -11,10 +11,11 @@
gboolean tty_use_colors ();
#define MY_COLOR_PAIR(x) (COLOR_PAIR (x) | attr_pairs [x])
#define IF_COLOR(co, bw) (tty_use_colors () ? MY_COLOR_PAIR (co) : bw)
//#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)
*/

Просмотреть файл

@ -113,6 +113,7 @@ mc_tty_color_init_lib (gboolean disable, gboolean force)
void
mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *mc_color_pair)
{
const char *fg, *bg;
if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE)
{
switch(mc_color_pair->ifg)
@ -134,10 +135,11 @@ mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *mc_color_pair)
);
break;
case SPEC_A_BOLD_REVERSE:
mc_tty_color_pair_init_special(
mc_color_pair,
"white", "black",
"white", "black",
"white", "white",
"white", "white",
SLTT_BOLD_MASK | SLTT_REV_MASK
);
break;
@ -153,7 +155,11 @@ mc_tty_color_try_alloc_pair_lib (mc_color_pair_t *mc_color_pair)
}
else
{
SLtt_set_color (mc_color_pair->pair_index, (char *) "", (char *) mc_color_pair->cfg, (char *) mc_color_pair->cbg);
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);
}
}

Просмотреть файл

@ -35,9 +35,8 @@ gboolean tty_use_colors ();
#define COLOR_PAIR(x) x
#define IF_COLOR(co, bw) (tty_use_colors () ? COLOR_PAIR (co) : bw)
/*
#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))
*/

Просмотреть файл

@ -44,6 +44,9 @@
char *command_line_colors = NULL;
static char *tty_color_defaults__fg = NULL;
static char *tty_color_defaults__bg = NULL;
/* Set if we are actually using colors */
gboolean use_colors = FALSE;
@ -54,7 +57,6 @@ gboolean use_colors = FALSE;
/*** file scope variables ************************************************************************/
static GHashTable *mc_tty_color__hashtable = NULL;
static int mc_tty_color__count = 0;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -74,6 +76,53 @@ mc_tty_color_hash_destroy_value (gpointer data)
g_free(mc_color_pair);
}
/* --------------------------------------------------------------------------------------------- */
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;
return (mc_color_pair->is_temp == is_temp_color);
}
/* --------------------------------------------------------------------------------------------- */
static void
tty_color_free_all(gboolean is_temp_color)
{
g_hash_table_foreach_remove (mc_tty_color__hashtable, tty_color_free_condition_cb, (gpointer) is_temp_color);
}
/* --------------------------------------------------------------------------------------------- */
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;
if (cp == mc_color_pair->pair_index)
return TRUE;
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
static int
tty_color_get_next__color_pair_number()
{
int cp_count = g_hash_table_size (mc_tty_color__hashtable);
int cp=0;
for (cp = 0; cp < cp_count; cp++){
if (g_hash_table_find (mc_tty_color__hashtable, tty_color_get_next_cpn_cb, (gpointer) cp) == NULL)
return cp;
}
return cp;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -82,7 +131,6 @@ void
tty_init_colors (gboolean disable, gboolean force)
{
mc_tty_color_init_lib (disable, force);
mc_tty_color__count = 0;
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);
@ -93,6 +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);
g_hash_table_destroy (mc_tty_color__hashtable);
}
@ -106,12 +157,19 @@ tty_use_colors (void)
/* --------------------------------------------------------------------------------------------- */
int tty_try_alloc_color_pair (const char *fg, const char *bg)
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;
const char *c_fg, *c_bg;
if (fg == NULL)
fg = tty_color_defaults__fg;
if(bg == NULL)
{
bg = tty_color_defaults__bg;
}
c_fg = mc_tty_color_get_valid_name(fg);
c_bg = mc_tty_color_get_valid_name(bg);
@ -133,11 +191,12 @@ int tty_try_alloc_color_pair (const char *fg, const char *bg)
return 0;
}
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->pair_index = mc_tty_color__count++;
mc_color_pair->pair_index = tty_color_get_next__color_pair_number();
mc_tty_color_try_alloc_pair_lib (mc_color_pair);
@ -148,6 +207,13 @@ 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);
@ -168,3 +234,31 @@ void tty_set_normal_attrs (void)
}
/* --------------------------------------------------------------------------------------------- */
void
tty_color_free_all_tmp(void)
{
tty_color_free_all(TRUE);
}
/* --------------------------------------------------------------------------------------------- */
void
tty_color_free_all_non_tmp(void)
{
tty_color_free_all(FALSE);
}
/* --------------------------------------------------------------------------------------------- */
void
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;
}
/* --------------------------------------------------------------------------------------------- */

Просмотреть файл

@ -27,10 +27,17 @@ void tty_colors_done (void);
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_setcolor (int color);
void tty_lowlevel_setcolor (int color);
void tty_set_normal_attrs (void);
void tty_color_set_defaults( const char *, const char *);
#define ALLOC_COLOR_PAIR_INDEX 1
#endif /* MC_COLOR_H */

Просмотреть файл

@ -65,24 +65,6 @@
/*** file scope variables **********************************************/
static const struct {
int acscode;
int character;
} acs_approx [] = {
{ 'q', '-' }, /* ACS_HLINE */
{ 'x', '|' }, /* ACS_VLINE */
{ 'l', '+' }, /* ACS_ULCORNER */
{ 'k', '+' }, /* ACS_URCORNER */
{ 'm', '+' }, /* ACS_LLCORNER */
{ 'j', '+' }, /* ACS_LRCORNER */
{ 'a', '#' }, /* ACS_CKBOARD */
{ 'u', '+' }, /* ACS_RTEE */
{ 't', '+' }, /* ACS_LTEE */
{ 'w', '+' }, /* ACS_TTEE */
{ 'v', '+' }, /* ACS_BTEE */
{ 'n', '+' }, /* ACS_PLUS */
{ 0, 0 } };
/*** file scope functions **********************************************/
/*** public functions **************************************************/
@ -115,11 +97,6 @@ tty_init (gboolean slow, gboolean ugly_lines)
keypad (stdscr, TRUE);
nodelay (stdscr, FALSE);
if (ugly_lines) {
int i;
for (i = 0; acs_approx[i].acscode != 0; i++)
acs_map[acs_approx[i].acscode] = acs_approx[i].character;
}
}
void
@ -217,7 +194,7 @@ void
tty_draw_hline (int y, int x, int ch, int len)
{
if (ch == ACS_HLINE) {
ch = ugly_frm_thinhoriz;
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
}
if ((y >= 0) && (x >= 0))
@ -237,22 +214,23 @@ tty_draw_vline (int y, int x, int ch, int 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, ACS_ULCORNER);
hline (ACS_HLINE, cols - 2);
waddc (y + rows - 1, x, ACS_LLCORNER);
hline (ACS_HLINE, cols - 2);
waddc (y, x + cols - 1, ACS_URCORNER);
waddc (y + rows - 1, x + cols - 1, ACS_LRCORNER);
#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 (ACS_VLINE, rows - 2);
vline (mc_tty_ugly_frm[MC_TTY_FRM_vert], rows - 2);
move (y + 1, x + cols - 1);
vline (ACS_VLINE, rows - 2);
vline (mc_tty_ugly_frm[MC_TTY_FRM_vert], rows - 2);
#undef waddc
}
void
@ -292,11 +270,11 @@ tty_print_anychar (int c)
unsigned char str[6 + 1];
if (c == ACS_RTEE ) {
c = ugly_frm_rightmiddle;
c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle];
}
if (c == ACS_LTEE ) {
c = ugly_frm_leftmiddle;
c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle];
}
if ( c > 255 ) {

Просмотреть файл

@ -387,9 +387,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)) {
y = SLsmg_get_row ();
@ -413,6 +412,9 @@ 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)) {
y = SLsmg_get_row ();
x = SLsmg_get_column ();
@ -466,22 +468,27 @@ void
tty_print_char (int c)
{
SLsmg_write_char ((SLwchar_Type) ((unsigned int) c));
/* FIXME: or SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), c); ? */
}
void
tty_print_alt_char (int c)
{
if (c == ACS_RTEE) {
c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle];
#define DRAW(x, y) (x == y) \
? SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), x) \
: SLsmg_write_char ((unsigned int) y)
switch (c) {
case ACS_VLINE: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_thinvert]); break;
case ACS_HLINE: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]); break;
case ACS_LTEE: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle]); break;
case ACS_RTEE: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle]); break;
case ACS_ULCORNER: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_lefttop]); break;
case ACS_LLCORNER: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]); break;
case ACS_URCORNER: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_righttop]); break;
case ACS_LRCORNER: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]); break;
case ACS_PLUS: DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_centermiddle]); break;
default: SLsmg_write_char ((unsigned int) c);
}
if (c == ACS_LTEE) {
c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle];
}
tty_print_char (c);
#undef DRAW
}
void

Просмотреть файл

@ -25,6 +25,7 @@ enum {
#define ACS_LLCORNER SLSMG_LLCORN_CHAR
#define ACS_URCORNER SLSMG_URCORN_CHAR
#define ACS_LRCORNER SLSMG_LRCORN_CHAR
#define ACS_PLUS SLSMG_PLUS_CHAR
#define COLS SLtt_Screen_Cols
#define LINES SLtt_Screen_Rows

Просмотреть файл

@ -123,13 +123,13 @@ tty_got_interrupt(void)
void
tty_print_one_hline (void)
{
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
}
void
tty_print_one_vline (void)
{
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
}
void
@ -140,11 +140,11 @@ tty_draw_box_slow (int y, int x, int ys, int xs)
tty_draw_hline (y, x, mc_tty_ugly_frm[MC_TTY_FRM_horiz], xs);
tty_draw_hline (y + ys - 1, x, mc_tty_ugly_frm[MC_TTY_FRM_horiz], xs);
tty_gotoyx (y, x);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
tty_gotoyx (y + ys - 1, x);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
tty_gotoyx (y, x + xs - 1);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
tty_gotoyx (y + ys - 1, x + xs - 1);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
}

Просмотреть файл

@ -92,6 +92,7 @@ typedef enum{
MC_TTY_FRM_centerbottom,
MC_TTY_FRM_leftmiddle,
MC_TTY_FRM_rightmiddle,
MC_TTY_FRM_centermiddle,
MC_TTY_FRM_MAX
} mc_tty_frm_t;