1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00

New config functions, almost entirely rewritten from scratch

This commit is contained in:
Sebastien Helleu
2007-12-01 00:35:57 +01:00
parent 32cc6ae5d8
commit 59fb878b77
45 changed files with 2625 additions and 2767 deletions
+3 -4
View File
@@ -16,10 +16,9 @@
SET(LIB_CORE_SRC weechat.c weechat.h wee-alias.c wee-alias.h wee-backtrace.c
wee-backtrace.h wee-command.c wee-command.h wee-config.c wee-config.h
wee-config-file.c wee-config-file.h wee-config-option.c wee-config-option.h
wee-hook.c wee-hook.h wee-input.c wee-input.h wee-list.c wee-list.h wee-log.c
wee-log.h wee-string.c wee-string.h wee-upgrade.c wee-upgrade.h wee-utf8.c
wee-utf8.h wee-util.c wee-util.h)
wee-config-file.c wee-config-file.h wee-hook.c wee-hook.h wee-input.c
wee-input.h wee-list.c wee-list.h wee-log.c wee-log.h wee-string.c wee-string.h
wee-upgrade.c wee-upgrade.h wee-utf8.c wee-utf8.h wee-util.c wee-util.h)
# Check for flock support
INCLUDE(CheckSymbolExists)
-2
View File
@@ -30,8 +30,6 @@ lib_weechat_core_a_SOURCES = weechat.c \
wee-config.h \
wee-config-file.c \
wee-config-file.h \
wee-config-option.c \
wee-config-option.h \
wee-hook.c \
wee-hook.h \
wee-input.c \
+1
View File
@@ -30,6 +30,7 @@
#include "wee-alias.h"
#include "wee-config.h"
#include "wee-string.h"
#include "../gui/gui-chat.h"
struct alias *weechat_alias = NULL;
+56 -70
View File
@@ -40,6 +40,7 @@
#include "wee-utf8.h"
#include "wee-list.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-history.h"
#include "../gui/gui-input.h"
#include "../gui/gui-keyboard.h"
@@ -1011,7 +1012,7 @@ command_history (struct t_gui_buffer *buffer,
/* make C compiler happy */
(void) argv_eol;
n_user = cfg_history_display_default;
n_user = CONFIG_INTEGER(config_history_display_default);
if (argc == 1)
{
@@ -1529,7 +1530,7 @@ command_save (struct t_gui_buffer *buffer,
(void) argv_eol;
/* save WeeChat configuration */
if (weechat_config_write () == 0)
if (config_weechat_write () == 0)
gui_chat_printf (NULL,
_("%sWeeChat configuration file saved"),
gui_chat_prefix[GUI_CHAT_PREFIX_INFO]);
@@ -1562,35 +1563,46 @@ command_set_display_option (struct t_config_option *option, char *prefix,
switch (option->type)
{
case OPTION_TYPE_BOOLEAN:
case CONFIG_OPTION_BOOLEAN:
gui_chat_printf (NULL, "%s%s%s%s = %s%s",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
(*((int *)(option->ptr_int))) ? "ON" : "OFF");
(CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
"ON" : "OFF");
break;
case OPTION_TYPE_INT:
gui_chat_printf (NULL, "%s%s%s%s = %s%d",
case CONFIG_OPTION_INTEGER:
if (option->string_values)
gui_chat_printf (NULL, "%s%s%s%s = %s%s",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
option->string_values[CONFIG_INTEGER(option)]);
else
gui_chat_printf (NULL, "%s%s%s%s = %s%d",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
CONFIG_INTEGER(option));
break;
case CONFIG_OPTION_STRING:
gui_chat_printf (NULL, "%s%s%s%s = \"%s%s%s\"",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
*((int *)(option->ptr_int)));
(option->value) ? CONFIG_STRING(option) : "",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
break;
case OPTION_TYPE_INT_WITH_STRING:
gui_chat_printf (NULL, "%s%s%s%s = %s%s",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
option->array_values[*((int *)(option->ptr_int))]);
break;
case OPTION_TYPE_COLOR:
color_name = gui_color_get_name (*((int *)(option->ptr_int)));
case CONFIG_OPTION_COLOR:
color_name = gui_color_get_name (CONFIG_COLOR(option));
gui_chat_printf (NULL, "%s%s%s%s = %s%s",
prefix,
(message) ? message : " ",
@@ -1599,53 +1611,39 @@ command_set_display_option (struct t_config_option *option, char *prefix,
GUI_COLOR(GUI_COLOR_CHAT_HOST),
(color_name) ? color_name : _("(unknown)"));
break;
case OPTION_TYPE_STRING:
if (*((char **)(option->ptr_string)))
gui_chat_printf (NULL, "%s%s%s%s = \"%s%s%s\"",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
*(option->ptr_string),
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
else
gui_chat_printf (NULL, "%s%s%s%s = \"\"",
prefix,
(message) ? message : " ",
option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
break;
}
}
/*
* command_set_display_option_list: display list of options
* Return: number of options displayed
* return: number of options displayed
*/
int
command_set_display_option_list (char **config_sections,
struct t_config_option **config_options,
command_set_display_option_list (struct t_config_file *config_file,
char *message, char *search)
{
int i, j, number_found, section_displayed;
int number_found, section_displayed;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
if (!config_sections || !config_options)
if (!config_file)
return 0;
number_found = 0;
for (i = 0; config_sections[i]; i++)
for (ptr_section = config_file->sections; ptr_section;
ptr_section = ptr_section->next_section)
{
if (config_options[i])
if (ptr_section->options)
{
section_displayed = 0;
for (j = 0; config_options[i][j].name; j++)
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
{
if ((!search) ||
((search) && (search[0])
&& (string_strcasestr (config_options[i][j].name, search))))
&& (string_strcasestr (ptr_option->name, search))))
{
if (!section_displayed)
{
@@ -1653,12 +1651,11 @@ command_set_display_option_list (char **config_sections,
gui_chat_printf (NULL, "%s[%s%s%s]",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
config_sections[i],
ptr_section->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
section_displayed = 1;
}
command_set_display_option (&config_options[i][j],
"", message);
command_set_display_option (ptr_option, "", message);
number_found++;
}
}
@@ -1688,10 +1685,10 @@ command_set (struct t_gui_buffer *buffer,
{
number_found = 0;
number_found += command_set_display_option_list (weechat_config_sections,
weechat_config_options,
number_found += command_set_display_option_list (weechat_config,
NULL,
(argc == 1) ? argv[0] : NULL);
(argc == 1) ?
argv[0] : NULL);
if (number_found == 0)
{
@@ -1728,9 +1725,7 @@ command_set (struct t_gui_buffer *buffer,
/* set option value */
if ((argc >= 3) && (string_strcasecmp (argv[1], "=") == 0))
{
ptr_option = config_option_section_option_search (weechat_config_sections,
weechat_config_options,
argv[0]);
ptr_option = config_file_search_option (weechat_config, NULL, argv[0]);
if (!ptr_option)
{
gui_chat_printf (NULL,
@@ -1740,27 +1735,18 @@ command_set (struct t_gui_buffer *buffer,
argv[0]);
return -1;
}
if (!ptr_option->handler_change)
{
gui_chat_printf (NULL,
_("%sError: option \"%s\" can not be "
"changed while WeeChat is "
"running"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[0]);
return -1;
}
value = string_remove_quotes (argv_eol[2], "'\"");
rc = config_option_set (ptr_option,
(value) ? value : argv_eol[2]);
rc = config_file_option_set (ptr_option,
(value) ? value : argv_eol[2]);
if (value)
free (value);
if (rc == 0)
if (rc > 0)
{
command_set_display_option (ptr_option,
gui_chat_prefix[GUI_CHAT_PREFIX_INFO],
_("Option changed: "));
(void) (ptr_option->handler_change());
if ((rc == 2) && (ptr_option->callback_change))
(void) (ptr_option->callback_change) ();
}
else
{
@@ -1785,7 +1771,7 @@ command_setp (struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *pos, *ptr_name, *value;
struct t_plugin_option *ptr_option;
struct t_config_option *ptr_option;
int number_found;
/* make C compiler happy */
@@ -1808,7 +1794,7 @@ command_setp (struct t_gui_buffer *buffer,
ptr_option->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
ptr_option->value,
(char *)ptr_option->value,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
number_found++;
}
@@ -2009,7 +1995,7 @@ command_upgrade (struct t_gui_buffer *buffer,
/* unload plugins, save config, then upgrade */
plugin_end ();
/*if (cfg_look_save_on_exit)
/*if (CONFIG_BOOLEAN(config_look_save_on_exit))
(void) config_write (NULL);
gui_main_end ();
fifo_remove ();
+811 -297
View File
File diff suppressed because it is too large Load Diff
+100 -16
View File
@@ -20,24 +20,108 @@
#ifndef __WEECHAT_CONFIG_FILE_H
#define __WEECHAT_CONFIG_FILE_H 1
#include "wee-config-option.h"
#define CONFIG_BOOLEAN(option) (*((char *)((option)->value)))
#define CONFIG_BOOLEAN_DEFAULT(option) (*((char *)((option)->default_value)))
typedef int (t_config_func_read_option) (struct t_config_option *, char *, char *);
typedef int (t_config_func_write_options) (FILE *, char *, struct t_config_option *);
#define CONFIG_INTEGER(option) (*((int *)((option)->value)))
#define CONFIG_INTEGER_DEFAULT(option) (*((int *)((option)->default_value)))
extern int config_file_read_option (struct t_config_option *, char *, char *);
extern int config_file_read (char **, struct t_config_option **,
t_config_func_read_option **,
t_config_func_read_option *,
t_config_func_write_options **,
char *);
#define CONFIG_STRING(option) ((char *)((option)->value))
#define CONFIG_STRING_DEFAULT(option) ((char *)((option)->default_value))
extern int config_file_write_options (FILE *, char *, struct t_config_option *);
extern int config_file_write_options_default_values (FILE *, char *,
struct t_config_option *);
extern int config_file_write_default (char **, struct t_config_option **,
t_config_func_write_options **, char *);
extern int config_file_write (char **, struct t_config_option **,
t_config_func_write_options **, char *);
#define CONFIG_COLOR(option) (*((int *)((option)->value)))
#define CONFIG_COLOR_DEFAULT(option) (*((int *)((option)->default_value)))
#define CONFIG_BOOLEAN_FALSE 0
#define CONFIG_BOOLEAN_TRUE 1
struct t_config_file
{
char *filename; /* config filename (without path)*/
FILE *file; /* file pointer */
struct t_config_section *sections; /* config sections */
struct t_config_section *last_section; /* last config section */
struct t_config_file *prev_config; /* link to previous config file */
struct t_config_file *next_config; /* link to next config file */
};
struct t_config_section
{
char *name; /* section name */
void (*callback_read) /* called when unknown option */
(struct t_config_file *, /* is read from config file */
char *, char *);
void (*callback_write) /* called to write special */
(struct t_config_file *); /* options in config file */
void (*callback_write_default) /* called to write default */
(struct t_config_file *); /* options in config file */
struct t_config_option *options; /* options in section */
struct t_config_option *last_option; /* last option in section */
struct t_config_section *prev_section; /* link to previous section */
struct t_config_section *next_section; /* link to next section */
};
enum t_config_option_type
{
CONFIG_OPTION_BOOLEAN = 0,
CONFIG_OPTION_INTEGER,
CONFIG_OPTION_STRING,
CONFIG_OPTION_COLOR,
};
struct t_config_option
{
char *name; /* name */
enum t_config_option_type type; /* type */
char *description; /* description */
char **string_values; /* allowed string values */
int min, max; /* min and max for value */
void *default_value; /* default value */
void *value; /* value */
void (*callback_change)(); /* called when value is changed */
struct t_config_option *prev_option; /* link to previous option */
struct t_config_option *next_option; /* link to next option */
};
extern struct t_config_file *config_file_new (char *);
extern struct t_config_section *config_file_new_section (struct t_config_file *,
char *,
void (*)(struct t_config_file *, char *, char *),
void (*)(struct t_config_file *),
void (*)(struct t_config_file *));
extern struct t_config_section *config_file_search_section (struct t_config_file *,
char *);
extern struct t_config_option *config_file_new_option_boolean (struct t_config_section *,
char *, char *,
int,
void (*)());
extern struct t_config_option *config_file_new_option_integer (struct t_config_section *,
char *, char *,
int, int, int,
void (*)());
extern struct t_config_option *config_file_new_option_integer_with_string (struct t_config_section *,
char *,
char *,
char *,
int,
void (*)());
extern struct t_config_option *config_file_new_option_string (struct t_config_section *,
char *, char *,
int, int,
char *, void (*)());
extern struct t_config_option *config_file_new_option_color (struct t_config_section *,
char *, char *,
int, char *,
void (*)());
extern struct t_config_option *config_file_search_option (struct t_config_file *,
struct t_config_section *,
char *);
extern int config_file_option_set (struct t_config_option *, char *);
extern int config_file_read (struct t_config_file *);
extern void config_file_write_line (struct t_config_file *, char *, char *);
extern int config_file_write (struct t_config_file *, int);
extern void config_file_print_stdout (struct t_config_file *);
extern void config_file_print_log ();
#endif /* wee-config-file.h */
-569
View File
@@ -1,569 +0,0 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* wee-config-option.c: manages WeeChat/protocols options */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "weechat.h"
#include "wee-config-option.h"
#include "wee-hook.h"
#include "wee-string.h"
#include "wee-utf8.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
/*
* config_option_get_pos_array_values: return position of a string in an array of values
* return -1 if not found, otherwise position
*/
int
config_option_get_pos_array_values (char **array, char *string)
{
int i;
i = 0;
while (array[i])
{
if (string_strcasecmp (array[i], string) == 0)
return i;
i++;
}
/* string not found in array */
return -1;
}
/*
* config_option_list_remove: remove an item from a list for an option
* (for options with value like: "abc:1,def:blabla")
*/
void
config_option_list_remove (char **string, char *item)
{
char *name, *pos, *pos2;
if (!string || !(*string))
return;
name = (char *) malloc (strlen (item) + 2);
strcpy (name, item);
strcat (name, ":");
pos = string_strcasestr (*string, name);
free (name);
if (pos)
{
pos2 = pos + strlen (item);
if (pos2[0] == ':')
{
pos2++;
if (pos2[0])
{
while (pos2[0] && (pos2[0] != ','))
pos2++;
if (pos2[0] == ',')
pos2++;
if (!pos2[0] && (pos != (*string)))
pos--;
strcpy (pos, pos2);
if (!(*string)[0])
{
free (*string);
*string = NULL;
}
else
(*string) = (char *) realloc (*string, strlen (*string) + 1);
}
}
}
}
/*
* config_option_list_set: set an item from a list for an option
* (for options with value like: "abc:1,def:blabla")
*/
void
config_option_list_set (char **string, char *item, char *value)
{
config_option_list_remove (string, item);
if (!(*string))
{
(*string) = (char *) malloc (strlen (item) + 1 + strlen (value) + 1);
(*string)[0] = '\0';
}
else
(*string) = (char *) realloc (*string,
strlen (*string) + 1 +
strlen (item) + 1 + strlen (value) + 1);
if ((*string)[0])
strcat (*string, ",");
strcat (*string, item);
strcat (*string, ":");
strcat (*string, value);
}
/*
* config_option_list_get_value: return position of item value in the list
* (for options with value like: "abc:1,def:blabla")
*/
void
config_option_list_get_value (char **string, char *item,
char **pos_found, int *length)
{
char *name, *pos, *pos2, *pos_comma;
*pos_found = NULL;
*length = 0;
if (!string || !(*string))
return;
name = (char *) malloc (strlen (item) + 2);
strcpy (name, item);
strcat (name, ":");
pos = string_strcasestr (*string, name);
free (name);
if (pos)
{
pos2 = pos + strlen (item);
if (pos2[0] == ':')
{
pos2++;
*pos_found = pos2;
pos_comma = strchr (pos2, ',');
if (pos_comma)
*length = pos_comma - pos2;
else
*length = strlen (pos2);
}
}
}
/*
* config_option_option_get_boolean_value: get boolean value with user text
* return: BOOL_FALSE or BOOL_TRUE
*/
int
config_option_option_get_boolean_value (char *text)
{
if ((string_strcasecmp (text, "on") == 0)
|| (string_strcasecmp (text, "yes") == 0)
|| (string_strcasecmp (text, "y") == 0)
|| (string_strcasecmp (text, "true") == 0)
|| (string_strcasecmp (text, "t") == 0)
|| (string_strcasecmp (text, "1") == 0))
return BOOL_TRUE;
if ((string_strcasecmp (text, "off") == 0)
|| (string_strcasecmp (text, "no") == 0)
|| (string_strcasecmp (text, "n") == 0)
|| (string_strcasecmp (text, "false") == 0)
|| (string_strcasecmp (text, "f") == 0)
|| (string_strcasecmp (text, "0") == 0))
return BOOL_FALSE;
/* invalid text */
return -1;
}
/*
* config_option_set: set new value for an option
* return: 0 if success
* -1 if error (bad value)
*/
int
config_option_set (struct t_config_option *option, char *value)
{
int int_value;
switch (option->type)
{
case OPTION_TYPE_BOOLEAN:
int_value = config_option_option_get_boolean_value (value);
switch (int_value)
{
case BOOL_TRUE:
*(option->ptr_int) = BOOL_TRUE;
break;
case BOOL_FALSE:
*(option->ptr_int) = BOOL_FALSE;
break;
default:
return -1;
}
break;
case OPTION_TYPE_INT:
int_value = atoi (value);
if ((int_value < option->min) || (int_value > option->max))
return -1;
*(option->ptr_int) = int_value;
break;
case OPTION_TYPE_INT_WITH_STRING:
int_value = config_option_get_pos_array_values (option->array_values,
value);
if (int_value < 0)
return -1;
*(option->ptr_int) = int_value;
break;
case OPTION_TYPE_STRING:
if ((option->max > 0) && (utf8_strlen (value) > option->max))
return -1;
if (*(option->ptr_string))
free (*(option->ptr_string));
*(option->ptr_string) = strdup (value);
break;
case OPTION_TYPE_COLOR:
if (!gui_color_assign (option->ptr_int, value))
return -1;
break;
}
hook_config_exec ("weechat", option->name, value);
return 0;
}
/*
* config_option_search: look for an option in a section and
* return pointer to this option
* If option is not found, NULL is returned
*/
struct t_config_option *
config_option_search (struct t_config_option *config_options, char *option_name)
{
int i;
for (i = 0; config_options[i].name; i++)
{
/* if option found, return pointer */
if (string_strcasecmp (config_options[i].name, option_name) == 0)
return &config_options[i];
}
/* option not found */
return NULL;
}
/*
* config_option_section_option_search: look for an option and return pointer to this option
* if option is not found, NULL is returned
*/
struct t_config_option *
config_option_section_option_search (char **config_sections,
struct t_config_option **config_options,
char *option_name)
{
int i;
struct t_config_option *ptr_option;
for (i = 0; config_sections[i]; i++)
{
if (config_options[i])
{
ptr_option = config_option_search (config_options[i],
option_name);
if (ptr_option)
return ptr_option;
}
}
/* option not found */
return NULL;
}
/*
* config_option_section_option_search_get_value: look for type and value of an option
* if option is not found, NULL is returned
*/
void
config_option_section_option_search_get_value (char **config_sections,
struct t_config_option **config_options,
char *option_name,
struct t_config_option **output_option,
void **output_option_value)
{
struct t_config_option *ptr_option;
void *ptr_value;
ptr_option = NULL;
ptr_value = NULL;
ptr_option = config_option_section_option_search (config_sections,
config_options,
option_name);
if (ptr_option)
{
switch (ptr_option->type)
{
case OPTION_TYPE_BOOLEAN:
case OPTION_TYPE_INT:
case OPTION_TYPE_INT_WITH_STRING:
case OPTION_TYPE_COLOR:
ptr_value = (void *)(ptr_option->ptr_int);
break;
case OPTION_TYPE_STRING:
ptr_value = (void *)(ptr_option->ptr_string);
break;
}
if (ptr_option)
{
*output_option = ptr_option;
*output_option_value = ptr_value;
}
}
}
/*
* config_option_section_option_set_value_by_name: set new value for an option (found by name)
* return: 0 if success
* -1 if bad value for option
* -2 if option is not found
*/
int
config_option_section_option_set_value_by_name (char **config_sections,
struct t_config_option **config_options,
char *option_name, char *value)
{
struct t_config_option *ptr_option;
ptr_option = config_option_section_option_search (config_sections,
config_options,
option_name);
if (ptr_option)
return config_option_set (ptr_option, value);
else
return -2;
}
/*
* config_option_section_get_index: get section index by name
* return -1 if section is not found
*/
int
config_option_section_get_index (char **config_sections, char *section_name)
{
int i;
for (i = 0; config_sections[i]; i++)
{
if (string_strcasecmp (config_sections[i], section_name) == 0)
return i;
}
/* option not found */
return -1;
}
/*
* config_option_section_get_name: get section name by option pointer
*/
char *
config_option_section_get_name (char **config_sections,
struct t_config_option **config_options,
struct t_config_option *ptr_option)
{
int i, j;
for (i = 0; config_sections[i]; i++)
{
for (j = 0; config_options[i][j].name; j++)
{
/* if option found, return pointer to section name */
if (ptr_option == &config_options[i][j])
return config_sections[i];
}
}
/* option not found */
return NULL;
}
/*
* config_option_section_option_set_default_values: initialize config options
* with default values
*/
void
config_option_section_option_set_default_values (char **config_sections,
struct t_config_option **config_options)
{
int i, j, int_value;
for (i = 0; config_sections[i]; i++)
{
if (config_options[i])
{
for (j = 0; config_options[i][j].name; j++)
{
switch (config_options[i][j].type)
{
case OPTION_TYPE_BOOLEAN:
case OPTION_TYPE_INT:
*config_options[i][j].ptr_int =
config_options[i][j].default_int;
break;
case OPTION_TYPE_INT_WITH_STRING:
int_value = config_option_get_pos_array_values (
config_options[i][j].array_values,
config_options[i][j].default_string);
if (int_value < 0)
gui_chat_printf (NULL,
_("Warning: unable to assign default int with "
"string (\"%s\")\n"),
config_options[i][j].default_string);
else
*config_options[i][j].ptr_int = int_value;
break;
case OPTION_TYPE_STRING:
*config_options[i][j].ptr_string =
strdup (config_options[i][j].default_string);
break;
case OPTION_TYPE_COLOR:
if (!gui_color_assign (config_options[i][j].ptr_int,
config_options[i][j].default_string))
gui_chat_printf (NULL,
_("Warning: unable to assign default color "
"(\"%s\")\n"),
config_options[i][j].default_string);
break;
}
}
}
}
}
/*
* config_option_print_stdout: print options on standard output
*/
void
config_option_print_stdout (char **config_sections,
struct t_config_option **config_options)
{
int i, j, k;
for (i = 0; config_sections[i]; i++)
{
if (config_options[i])
{
j = 0;
while (config_options[i][j].name)
{
string_iconv_fprintf (stdout,
"* %s:\n",
config_options[i][j].name);
switch (config_options[i][j].type)
{
case OPTION_TYPE_BOOLEAN:
string_iconv_fprintf (stdout, _(" . type: boolean\n"));
string_iconv_fprintf (stdout, _(" . values: 'on' or 'off'\n"));
string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
(config_options[i][j].default_int == BOOL_TRUE) ?
"on" : "off");
break;
case OPTION_TYPE_INT:
string_iconv_fprintf (stdout, _(" . type: integer\n"));
string_iconv_fprintf (stdout, _(" . values: between %d and %d\n"),
config_options[i][j].min,
config_options[i][j].max);
string_iconv_fprintf (stdout, _(" . default value: %d\n"),
config_options[i][j].default_int);
break;
case OPTION_TYPE_INT_WITH_STRING:
string_iconv_fprintf (stdout, _(" . type: string\n"));
string_iconv_fprintf (stdout, _(" . values: "));
k = 0;
while (config_options[i][j].array_values[k])
{
string_iconv_fprintf (stdout, "'%s'",
config_options[i][j].array_values[k]);
if (config_options[i][j].array_values[k + 1])
string_iconv_fprintf (stdout, ", ");
k++;
}
string_iconv_fprintf (stdout, "\n");
string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
(config_options[i][j].default_string) ?
config_options[i][j].default_string : _("empty"));
break;
case OPTION_TYPE_STRING:
switch (config_options[i][j].max)
{
case 0:
string_iconv_fprintf (stdout, _(" . type: string\n"));
string_iconv_fprintf (stdout, _(" . values: any string\n"));
break;
case 1:
string_iconv_fprintf (stdout, _(" . type: char\n"));
string_iconv_fprintf (stdout, _(" . values: any char\n"));
break;
default:
string_iconv_fprintf (stdout, _(" . type: string\n"));
string_iconv_fprintf (stdout, _(" . values: any string (limit: %d chars)\n"),
config_options[i][j].max);
break;
}
string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
(config_options[i][j].default_string) ?
config_options[i][j].default_string : _("empty"));
break;
case OPTION_TYPE_COLOR:
string_iconv_fprintf (stdout, _(" . type: color\n"));
string_iconv_fprintf (stdout, _(" . values: color (depends on GUI used)\n"));
string_iconv_fprintf (stdout, _(" . default value: '%s'\n"),
(config_options[i][j].default_string) ?
config_options[i][j].default_string : _("empty"));
break;
}
string_iconv_fprintf (stdout, _(" . description: %s\n"),
_(config_options[i][j].description));
string_iconv_fprintf (stdout, "\n");
j++;
}
}
}
}
-68
View File
@@ -1,68 +0,0 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_CONFIG_OPTION_H
#define __WEECHAT_CONFIG_OPTION_H 1
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
#define OPTION_TYPE_INT 2 /* values: from min to max */
#define OPTION_TYPE_INT_WITH_STRING 3 /* values: one from **array_values */
#define OPTION_TYPE_STRING 4 /* values: any string, may be empty */
#define OPTION_TYPE_COLOR 5 /* values: a color struct */
#define BOOL_FALSE 0
#define BOOL_TRUE 1
struct t_config_option
{
char *name;
char *description;
int type;
int min, max;
int default_int;
char *default_string;
char **array_values;
int *ptr_int;
char **ptr_string;
void (*handler_change)();
};
extern int config_option_get_pos_array_values (char **, char *);
extern void config_option_list_remove (char **, char *);
extern void config_option_list_set (char **, char *, char *);
extern void config_option_list_get_value (char **, char *, char **, int *);
extern int config_option_option_get_boolean_value (char *);
extern int config_option_set (struct t_config_option *, char *);
extern struct t_config_option *config_option_search (struct t_config_option *, char *);
extern struct t_config_option *config_option_section_option_search (char **,
struct t_config_option **,
char *);
extern void config_option_section_option_search_get_value (char **, struct t_config_option **,
char *, struct t_config_option **,
void **);
extern int config_option_section_option_set_value_by_name (char **,
struct t_config_option **,
char *, char *);
extern int config_option_section_get_index (char **, char *);
extern void config_option_section_option_set_default_values (char **,
struct t_config_option **);
extern void config_option_print_stdout (char **, struct t_config_option **);
#endif /* wee-config-option.h */
+926 -1031
View File
File diff suppressed because it is too large Load Diff
+147 -165
View File
@@ -20,183 +20,165 @@
#ifndef __WEECHAT_CONFIG_H
#define __WEECHAT_CONFIG_H 1
#include "wee-config-option.h"
#include "wee-config-file.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#define WEECHAT_CONFIG_NAME "weechat.rc"
#define WEECHAT_CONFIG_FILENAME "weechat.rc"
#define CFG_LOOK_NICKLIST_LEFT 0
#define CFG_LOOK_NICKLIST_RIGHT 1
#define CFG_LOOK_NICKLIST_TOP 2
#define CFG_LOOK_NICKLIST_BOTTOM 3
#define CONFIG_LOOK_NICKLIST_LEFT 0
#define CONFIG_LOOK_NICKLIST_RIGHT 1
#define CONFIG_LOOK_NICKLIST_TOP 2
#define CONFIG_LOOK_NICKLIST_BOTTOM 3
#define CFG_LOOK_PREFIX_ALIGN_NONE 0
#define CFG_LOOK_PREFIX_ALIGN_LEFT 1
#define CFG_LOOK_PREFIX_ALIGN_RIGHT 2
#define CONFIG_LOOK_PREFIX_ALIGN_NONE 0
#define CONFIG_LOOK_PREFIX_ALIGN_LEFT 1
#define CONFIG_LOOK_PREFIX_ALIGN_RIGHT 2
#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0
#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1
#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2
#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3
#define CFG_LOOK_HOTLIST_SORT_NUMBER_ASC 4
#define CFG_LOOK_HOTLIST_SORT_NUMBER_DESC 5
#define CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0
#define CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1
#define CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2
#define CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3
#define CONFIG_LOOK_HOTLIST_SORT_NUMBER_ASC 4
#define CONFIG_LOOK_HOTLIST_SORT_NUMBER_DESC 5
extern struct t_config_option weechat_options_look[];
extern int cfg_look_color_real_white;
extern int cfg_look_save_on_exit;
extern int cfg_look_set_title;
extern int cfg_look_startup_logo;
extern int cfg_look_startup_version;
extern char *cfg_look_weechat_slogan;
extern int cfg_look_one_server_buffer;
extern int cfg_look_open_near_server;
extern int cfg_look_scroll_amount;
extern char *cfg_look_buffer_time_format;
extern int cfg_look_color_nicks_number;
extern int cfg_look_color_actions;
extern int cfg_look_nicklist;
extern int cfg_look_nicklist_position;
extern int cfg_look_nicklist_min_size;
extern int cfg_look_nicklist_max_size;
extern int cfg_look_nicklist_separator;
extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_prefix[GUI_CHAT_PREFIX_NUMBER];
extern int cfg_look_prefix_align;
extern int cfg_look_prefix_align_max;
extern char *cfg_look_prefix_suffix;
extern int cfg_look_align_text_offset;
extern char *cfg_look_nick_completor;
extern char *cfg_look_nick_completion_ignore;
extern int cfg_look_nick_completion_smart;
extern int cfg_look_nick_complete_first;
extern int cfg_look_infobar;
extern char *cfg_look_infobar_time_format;
extern int cfg_look_infobar_seconds;
extern int cfg_look_infobar_delay_highlight;
extern int cfg_look_hotlist_names_count;
extern int cfg_look_hotlist_names_level;
extern int cfg_look_hotlist_names_length;
extern int cfg_look_hotlist_sort;
extern int cfg_look_day_change;
extern char *cfg_look_day_change_time_format;
extern char *cfg_look_read_marker;
extern char *cfg_look_input_format;
extern int cfg_look_paste_max_lines;
extern struct t_config_file *weechat_config;
extern struct t_config_option weechat_options_colors[];
extern int cfg_col_separator;
extern int cfg_col_title;
extern int cfg_col_title_bg;
extern int cfg_col_title_more;
extern int cfg_col_chat;
extern int cfg_col_chat_bg;
extern int cfg_col_chat_time;
extern int cfg_col_chat_time_delimiters;
extern int cfg_col_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
extern int cfg_col_chat_prefix_more;
extern int cfg_col_chat_prefix_suffix;
extern int cfg_col_chat_buffer;
extern int cfg_col_chat_server;
extern int cfg_col_chat_channel;
extern int cfg_col_chat_nick;
extern int cfg_col_chat_nick_self;
extern int cfg_col_chat_nick_other;
extern int cfg_col_chat_nick_colors[GUI_COLOR_NICK_NUMBER];
extern int cfg_col_chat_host;
extern int cfg_col_chat_delimiters;
extern int cfg_col_chat_highlight;
extern int cfg_col_chat_read_marker;
extern int cfg_col_chat_read_marker_bg;
extern int cfg_col_status;
extern int cfg_col_status_bg;
extern int cfg_col_status_delimiters;
extern int cfg_col_status_channel;
extern int cfg_col_status_data_msg;
extern int cfg_col_status_data_private;
extern int cfg_col_status_data_highlight;
extern int cfg_col_status_data_other;
extern int cfg_col_status_more;
extern int cfg_col_infobar;
extern int cfg_col_infobar_bg;
extern int cfg_col_infobar_delimiters;
extern int cfg_col_infobar_highlight;
extern int cfg_col_infobar_bg;
extern int cfg_col_input;
extern int cfg_col_input_bg;
extern int cfg_col_input_server;
extern int cfg_col_input_channel;
extern int cfg_col_input_nick;
extern int cfg_col_input_delimiters;
extern int cfg_col_input_text_not_found;
extern int cfg_col_input_actions;
extern int cfg_col_nicklist;
extern int cfg_col_nicklist_bg;
extern int cfg_col_nicklist_away;
extern int cfg_col_nicklist_prefix1;
extern int cfg_col_nicklist_prefix2;
extern int cfg_col_nicklist_prefix3;
extern int cfg_col_nicklist_prefix4;
extern int cfg_col_nicklist_prefix5;
extern int cfg_col_nicklist_more;
extern int cfg_col_nicklist_separator;
extern int cfg_col_info;
extern int cfg_col_info_bg;
extern int cfg_col_info_waiting;
extern int cfg_col_info_connecting;
extern int cfg_col_info_active;
extern int cfg_col_info_done;
extern int cfg_col_info_failed;
extern int cfg_col_info_aborted;
extern struct t_config_option *config_look_color_real_white;
extern struct t_config_option *config_look_save_on_exit;
extern struct t_config_option *config_look_set_title;
extern struct t_config_option *config_look_startup_logo;
extern struct t_config_option *config_look_startup_version;
extern struct t_config_option *config_look_weechat_slogan;
extern struct t_config_option *config_look_one_server_buffer;
extern struct t_config_option *config_look_open_near_server;
extern struct t_config_option *config_look_scroll_amount;
extern struct t_config_option *config_look_buffer_time_format;
extern struct t_config_option *config_look_color_nicks_number;
extern struct t_config_option *config_look_color_actions;
extern struct t_config_option *config_look_nicklist;
extern struct t_config_option *config_look_nicklist_position;
extern struct t_config_option *config_look_nicklist_min_size;
extern struct t_config_option *config_look_nicklist_max_size;
extern struct t_config_option *config_look_nicklist_separator;
extern struct t_config_option *config_look_nickmode;
extern struct t_config_option *config_look_nickmode_empty;
extern struct t_config_option *config_look_no_nickname;
extern struct t_config_option *config_look_prefix[];
extern struct t_config_option *config_look_prefix_align;
extern struct t_config_option *config_look_prefix_align_max;
extern struct t_config_option *config_look_prefix_suffix;
extern struct t_config_option *config_look_nick_completor;
extern struct t_config_option *config_look_nick_completion_ignore;
extern struct t_config_option *config_look_nick_completion_smart;
extern struct t_config_option *config_look_nick_complete_first;
extern struct t_config_option *config_look_infobar;
extern struct t_config_option *config_look_infobar_time_format;
extern struct t_config_option *config_look_infobar_seconds;
extern struct t_config_option *config_look_infobar_delay_highlight;
extern struct t_config_option *config_look_hotlist_names_count;
extern struct t_config_option *config_look_hotlist_names_level;
extern struct t_config_option *config_look_hotlist_names_length;
extern struct t_config_option *config_look_hotlist_sort;
extern struct t_config_option *config_look_day_change;
extern struct t_config_option *config_look_day_change_time_format;
extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_input_format;
extern struct t_config_option *config_look_paste_max_lines;
extern struct t_config_option weechat_options_history[];
extern int cfg_history_max_lines;
extern int cfg_history_max_commands;
extern int cfg_history_display_default;
extern struct t_config_option *config_color_separator;
extern struct t_config_option *config_color_title;
extern struct t_config_option *config_color_title_bg;
extern struct t_config_option *config_color_title_more;
extern struct t_config_option *config_color_chat;
extern struct t_config_option *config_color_chat_bg;
extern struct t_config_option *config_color_chat_time;
extern struct t_config_option *config_color_chat_time_delimiters;
extern struct t_config_option *config_color_chat_prefix[];
extern struct t_config_option *config_color_chat_prefix_more;
extern struct t_config_option *config_color_chat_prefix_suffix;
extern struct t_config_option *config_color_chat_buffer;
extern struct t_config_option *config_color_chat_server;
extern struct t_config_option *config_color_chat_channel;
extern struct t_config_option *config_color_chat_nick;
extern struct t_config_option *config_color_chat_nick_self;
extern struct t_config_option *config_color_chat_nick_other;
extern struct t_config_option *config_color_chat_nick_colors[];
extern struct t_config_option *config_color_chat_host;
extern struct t_config_option *config_color_chat_delimiters;
extern struct t_config_option *config_color_chat_highlight;
extern struct t_config_option *config_color_chat_read_marker;
extern struct t_config_option *config_color_chat_read_marker_bg;
extern struct t_config_option *config_color_status;
extern struct t_config_option *config_color_status_bg;
extern struct t_config_option *config_color_status_delimiters;
extern struct t_config_option *config_color_status_channel;
extern struct t_config_option *config_color_status_data_msg;
extern struct t_config_option *config_color_status_data_private;
extern struct t_config_option *config_color_status_data_highlight;
extern struct t_config_option *config_color_status_data_other;
extern struct t_config_option *config_color_status_more;
extern struct t_config_option *config_color_infobar;
extern struct t_config_option *config_color_infobar_bg;
extern struct t_config_option *config_color_infobar_delimiters;
extern struct t_config_option *config_color_infobar_highlight;
extern struct t_config_option *config_color_infobar_bg;
extern struct t_config_option *config_color_input;
extern struct t_config_option *config_color_input_bg;
extern struct t_config_option *config_color_input_server;
extern struct t_config_option *config_color_input_channel;
extern struct t_config_option *config_color_input_nick;
extern struct t_config_option *config_color_input_delimiters;
extern struct t_config_option *config_color_input_text_not_found;
extern struct t_config_option *config_color_input_actions;
extern struct t_config_option *config_color_nicklist;
extern struct t_config_option *config_color_nicklist_bg;
extern struct t_config_option *config_color_nicklist_away;
extern struct t_config_option *config_color_nicklist_prefix1;
extern struct t_config_option *config_color_nicklist_prefix2;
extern struct t_config_option *config_color_nicklist_prefix3;
extern struct t_config_option *config_color_nicklist_prefix4;
extern struct t_config_option *config_color_nicklist_prefix5;
extern struct t_config_option *config_color_nicklist_more;
extern struct t_config_option *config_color_nicklist_separator;
extern struct t_config_option *config_color_info;
extern struct t_config_option *config_color_info_bg;
extern struct t_config_option *config_color_info_waiting;
extern struct t_config_option *config_color_info_connecting;
extern struct t_config_option *config_color_info_active;
extern struct t_config_option *config_color_info_done;
extern struct t_config_option *config_color_info_failed;
extern struct t_config_option *config_color_info_aborted;
extern struct t_config_option weechat_options_proxy[];
extern int cfg_proxy_use;
extern int cfg_proxy_type;
extern char *cfg_proxy_type_values[];
extern int cfg_proxy_ipv6;
extern char *cfg_proxy_address;
extern int cfg_proxy_port;
extern char *cfg_proxy_username;
extern char *cfg_proxy_password;
extern struct t_config_option *config_history_max_lines;
extern struct t_config_option *config_history_max_commands;
extern struct t_config_option *config_history_display_default;
extern struct t_config_option weechat_options_plugins[];
extern char *cfg_plugins_path;
extern char *cfg_plugins_autoload;
extern char *cfg_plugins_extension;
extern struct t_config_option *config_proxy_use;
extern struct t_config_option *config_proxy_type;
extern struct t_config_option *config_proxy_ipv6;
extern struct t_config_option *config_proxy_address;
extern struct t_config_option *config_proxy_port;
extern struct t_config_option *config_proxy_username;
extern struct t_config_option *config_proxy_password;
extern char *weechat_config_sections[];
extern struct t_config_option *weechat_config_options[];
extern struct t_config_option *config_plugins_path;
extern struct t_config_option *config_plugins_autoload;
extern struct t_config_option *config_plugins_extension;
extern void weechat_config_change_noop ();
extern void weechat_config_change_save_on_exit ();
extern void weechat_config_change_title ();
extern void weechat_config_change_buffers ();
extern void weechat_config_change_buffer_content ();
extern void weechat_config_change_buffer_time_format ();
extern void weechat_config_change_hotlist ();
extern void weechat_config_change_read_marker ();
extern void weechat_config_change_prefix ();
extern void weechat_config_change_color ();
extern void weechat_config_change_nicks_colors ();
extern void config_change_noop ();
extern void config_change_save_on_exit ();
extern void config_change_title ();
extern void config_change_buffers ();
extern void config_change_buffer_content ();
extern void config_change_buffer_time_format ();
extern void config_change_hotlist ();
extern void config_change_read_marker ();
extern void config_change_prefix ();
extern void config_change_color ();
extern void config_change_nicks_colors ();
extern int weechat_config_read_alias (struct t_config_option *, char *, char *);
extern int weechat_config_read_key (struct t_config_option *, char *, char *);
extern int weechat_config_read ();
extern int weechat_config_write_alias (FILE *, char *, struct t_config_option *);
extern int weechat_config_write_keys (FILE *, char *, struct t_config_option *);
extern int weechat_config_write_alias_default_values (FILE *, char *,
struct t_config_option *);
extern int weechat_config_write_keys_default_values (FILE *, char *,
struct t_config_option *);
extern int weechat_config_write ();
extern void weechat_config_print_stdout ();
extern void config_weechat_init ();
extern int config_weechat_read ();
extern int config_weechat_write ();
extern void config_weechat_print_stdout ();
#endif /* wee-config.h */
+1
View File
@@ -33,6 +33,7 @@
#include "wee-config.h"
#include "wee-hook.h"
#include "wee-string.h"
#include "../gui/gui-chat.h"
#include "../plugins/plugin.h"
+6 -4
View File
@@ -157,15 +157,17 @@ util_search_full_lib_name (char *filename, char *sys_directory)
return strdup (filename);
length = strlen (filename) + 16;
if (cfg_plugins_extension && cfg_plugins_extension[0])
length += strlen (cfg_plugins_extension);
if (CONFIG_STRING(config_plugins_extension)
&& CONFIG_STRING(config_plugins_extension)[0])
length += strlen (CONFIG_STRING(config_plugins_extension));
name_with_ext = (char *)malloc (length);
if (!name_with_ext)
return strdup (filename);
strcpy (name_with_ext, filename);
if (!strchr (filename, '.')
&& cfg_plugins_extension && cfg_plugins_extension[0])
strcat (name_with_ext, cfg_plugins_extension);
&& CONFIG_STRING(config_plugins_extension)
&& CONFIG_STRING(config_plugins_extension)[0])
strcat (name_with_ext, CONFIG_STRING(config_plugins_extension));
/* try WeeChat user's dir */
length = strlen (weechat_home) + strlen (name_with_ext) +
+19 -13
View File
@@ -63,6 +63,7 @@
#include "wee-util.h"
#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-main.h"
#include "../gui/gui-keyboard.h"
@@ -129,7 +130,7 @@ weechat_display_config_options ()
/* TRANSLATORS: %s is "WeeChat" */
_("%s configuration options:\n"),
PACKAGE_NAME);
weechat_config_print_stdout ();
config_file_print_stdout (weechat_config);
}
/*
@@ -425,7 +426,7 @@ weechat_init_vars ()
void
weechat_welcome_message ()
{
if (cfg_look_startup_logo)
if (CONFIG_BOOLEAN(config_look_startup_logo))
{
gui_chat_printf (NULL,
"%s ___ __ ______________ _____ \n"
@@ -439,27 +440,31 @@ weechat_welcome_message ()
GUI_COLOR(GUI_COLOR_CHAT_NICK),
GUI_COLOR(GUI_COLOR_CHAT_NICK));
}
if (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0])
if (CONFIG_STRING(config_look_weechat_slogan)
&& CONFIG_STRING(config_look_weechat_slogan)[0])
{
gui_chat_printf (NULL, _("%sWelcome to %s%s%s, %s"),
(cfg_look_startup_logo) ? " " : "",
(CONFIG_BOOLEAN(config_look_startup_logo)) ?
" " : "",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
PACKAGE_NAME,
GUI_NO_COLOR,
cfg_look_weechat_slogan);
CONFIG_STRING(config_look_weechat_slogan));
}
if (cfg_look_startup_version)
if (CONFIG_BOOLEAN(config_look_startup_version))
{
gui_chat_printf (NULL, "%s%s%s%s, %s %s %s",
(cfg_look_startup_logo) ? " " : "",
(CONFIG_BOOLEAN(config_look_startup_logo)) ?
" " : "",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
PACKAGE_STRING,
GUI_NO_COLOR,
_("compiled on"), __DATE__, __TIME__);
}
if (cfg_look_startup_logo ||
(cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) ||
cfg_look_startup_version)
if (CONFIG_BOOLEAN(config_look_startup_logo) ||
(CONFIG_STRING(config_look_weechat_slogan)
&& CONFIG_STRING(config_look_weechat_slogan)[0]) ||
CONFIG_BOOLEAN(config_look_startup_version))
gui_chat_printf (NULL,
"%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-",
GUI_COLOR(GUI_COLOR_CHAT_NICK));
@@ -592,10 +597,11 @@ main (int argc, char *argv[])
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
weechat_init_vars (); /* initialize some variables */
gui_keyboard_init (); /* init keyb. (default key bindings)*/
config_weechat_init (); /* init options with default values */
weechat_parse_args (argc, argv); /* parse command line args */
weechat_create_home_dirs (); /* create WeeChat directories */
log_init (); /* init log file */
if (weechat_config_read () < 0) /* read WeeChat configuration */
if (config_weechat_read () < 0) /* read WeeChat configuration */
exit (EXIT_FAILURE);
command_index_build (); /* build cmd index for completion */
gui_main_init (); /* init WeeChat interface */
@@ -605,8 +611,8 @@ main (int argc, char *argv[])
plugin_init (auto_load_plugins); /* init plugin interface(s) */
gui_main_loop (); /* WeeChat main loop */
plugin_end (); /* end plugin interface(s) */
if (cfg_look_save_on_exit)
(void) weechat_config_write (NULL); /* save WeeChat config file */
if (CONFIG_BOOLEAN(config_look_save_on_exit))
(void) config_weechat_write (NULL); /* save WeeChat config file */
command_index_free (); /* free commands index */
gui_main_end (); /* shut down WeeChat GUI */
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */
+24 -19
View File
@@ -32,6 +32,7 @@
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-curses.h"
@@ -248,7 +249,7 @@ int
gui_chat_get_real_width (struct t_gui_window *window)
{
if (window->buffer->nicklist
&& (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_RIGHT))
&& (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_RIGHT))
return window->win_chat_width - 1;
else
return window->win_chat_width;
@@ -478,12 +479,13 @@ gui_chat_display_word (struct t_gui_window *window,
}
window->win_chat_cursor_x += length_align;
if (!simulate
&& (cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)
&& (cfg_look_prefix_suffix && cfg_look_prefix_suffix[0]))
&& (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (CONFIG_STRING(config_look_prefix_suffix)
&& CONFIG_STRING(config_look_prefix_suffix)[0]))
{
gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_SUFFIX);
gui_chat_display_word_raw (window, cfg_look_prefix_suffix, 1);
window->win_chat_cursor_x += gui_chat_strlen_screen (cfg_look_prefix_suffix);
gui_chat_display_word_raw (window, CONFIG_STRING(config_look_prefix_suffix), 1);
window->win_chat_cursor_x += gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix));
gui_chat_display_word_raw (window, str_space, 1);
window->win_chat_cursor_x += gui_chat_strlen_screen (str_space);
gui_chat_set_weechat_color (window, GUI_COLOR_CHAT);
@@ -572,23 +574,23 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
/* display prefix */
if (line->prefix
&& (line->prefix[0]
|| (cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)))
|| (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)))
{
if (!simulate)
gui_chat_reset_style (window);
if (cfg_look_prefix_align_max > 0)
if (CONFIG_INTEGER(config_look_prefix_align_max) > 0)
{
length_allowed =
(window->buffer->prefix_max_length <= cfg_look_prefix_align_max) ?
window->buffer->prefix_max_length : cfg_look_prefix_align_max;
(window->buffer->prefix_max_length <= CONFIG_INTEGER(config_look_prefix_align_max)) ?
window->buffer->prefix_max_length : CONFIG_INTEGER(config_look_prefix_align_max);
}
else
length_allowed = window->buffer->prefix_max_length;
num_spaces = length_allowed - line->prefix_length;
if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_RIGHT)
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_RIGHT)
{
for (i = 0; i < num_spaces; i++)
{
@@ -598,7 +600,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
}
}
/* not enough space to display full prefix ? => truncate it! */
if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (num_spaces < 0))
{
gui_chat_display_word (window, line, line->prefix,
@@ -618,7 +620,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
if (!simulate)
gui_chat_reset_style (window);
if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_LEFT)
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT)
{
for (i = 0; i < num_spaces; i++)
{
@@ -627,7 +629,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
simulate);
}
}
if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (num_spaces < 0))
{
if (!simulate)
@@ -642,12 +644,14 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
NULL, 1, num_lines, count, lines_displayed,
simulate);
}
if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)
&& (cfg_look_prefix_suffix && cfg_look_prefix_suffix[0]))
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (CONFIG_STRING(config_look_prefix_suffix)
&& CONFIG_STRING(config_look_prefix_suffix)[0]))
{
if (!simulate)
gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_SUFFIX);
gui_chat_display_word (window, line, cfg_look_prefix_suffix,
gui_chat_display_word (window, line,
CONFIG_STRING(config_look_prefix_suffix),
NULL, 1, num_lines, count,
lines_displayed, simulate);
gui_chat_display_word (window, line, str_space,
@@ -809,7 +813,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
}
else
{
if (cfg_look_read_marker && cfg_look_read_marker[0])
if (CONFIG_STRING(config_look_read_marker)
&& CONFIG_STRING(config_look_read_marker)[0])
{
/* display marker if line is matching user search */
if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
@@ -821,7 +826,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
GUI_COLOR_CHAT_READ_MARKER);
mvwprintw (GUI_CURSES(window)->win_chat,
read_marker_y, read_marker_x,
"%c", cfg_look_read_marker[0]);
"%c", CONFIG_STRING(config_look_read_marker)[0]);
}
}
else
@@ -834,7 +839,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
GUI_COLOR_CHAT_READ_MARKER);
mvwprintw (GUI_CURSES(window)->win_chat,
read_marker_y, read_marker_x,
"%c", cfg_look_read_marker[0]);
"%c", CONFIG_STRING(config_look_read_marker)[0]);
}
}
}
+61 -60
View File
@@ -32,6 +32,7 @@
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../gui-color.h"
#include "../gui-chat.h"
#include "gui-curses.h"
@@ -330,7 +331,7 @@ gui_color_init_pairs ()
init_pair (63, -1, -1);
/* white on default bg is default (-1) */
if (!cfg_look_color_real_white)
if (!CONFIG_BOOLEAN(config_look_color_real_white))
init_pair (COLOR_WHITE, -1, -1);
}
}
@@ -344,75 +345,75 @@ gui_color_init_weechat ()
{
int i;
gui_color[GUI_COLOR_SEPARATOR] = gui_color_build (GUI_COLOR_SEPARATOR, cfg_col_separator, cfg_col_separator);
gui_color[GUI_COLOR_SEPARATOR] = gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_separator));
gui_color[GUI_COLOR_TITLE] = gui_color_build (GUI_COLOR_TITLE, cfg_col_title, cfg_col_title_bg);
gui_color[GUI_COLOR_TITLE_MORE] = gui_color_build (GUI_COLOR_TITLE_MORE, cfg_col_title_more, cfg_col_title_bg);
gui_color[GUI_COLOR_TITLE] = gui_color_build (GUI_COLOR_TITLE, CONFIG_COLOR(config_color_title), CONFIG_COLOR(config_color_title_bg));
gui_color[GUI_COLOR_TITLE_MORE] = gui_color_build (GUI_COLOR_TITLE_MORE, CONFIG_COLOR(config_color_title_more), CONFIG_COLOR(config_color_title_bg));
gui_color[GUI_COLOR_CHAT] = gui_color_build (GUI_COLOR_CHAT, cfg_col_chat, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_TIME] = gui_color_build (GUI_COLOR_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_TIME_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, cfg_col_chat_time_delimiters, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_INFO] = gui_color_build (GUI_COLOR_CHAT_PREFIX_INFO, cfg_col_chat_prefix[GUI_CHAT_PREFIX_INFO], cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_ERROR] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ERROR, cfg_col_chat_prefix[GUI_CHAT_PREFIX_ERROR], cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_NETWORK] = gui_color_build (GUI_COLOR_CHAT_PREFIX_NETWORK, cfg_col_chat_prefix[GUI_CHAT_PREFIX_NETWORK], cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_ACTION] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ACTION, cfg_col_chat_prefix[GUI_CHAT_PREFIX_ACTION], cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_JOIN] = gui_color_build (GUI_COLOR_CHAT_PREFIX_JOIN, cfg_col_chat_prefix[GUI_CHAT_PREFIX_JOIN], cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_QUIT] = gui_color_build (GUI_COLOR_CHAT_PREFIX_QUIT, cfg_col_chat_prefix[GUI_CHAT_PREFIX_QUIT], cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_MORE] = gui_color_build (GUI_COLOR_CHAT_PREFIX_MORE, cfg_col_chat_prefix_more, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_PREFIX_SUFFIX] = gui_color_build (GUI_COLOR_CHAT_PREFIX_SUFFIX, cfg_col_chat_prefix_suffix, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_BUFFER] = gui_color_build (GUI_COLOR_CHAT_BUFFER, cfg_col_chat_buffer, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_SERVER] = gui_color_build (GUI_COLOR_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_CHANNEL] = gui_color_build (GUI_COLOR_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_NICK] = gui_color_build (GUI_COLOR_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_NICK_SELF] = gui_color_build (GUI_COLOR_CHAT_NICK_SELF, cfg_col_chat_nick_self, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_NICK_OTHER] = gui_color_build (GUI_COLOR_CHAT_NICK_OTHER, cfg_col_chat_nick_other, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT] = gui_color_build (GUI_COLOR_CHAT, CONFIG_COLOR(config_color_chat), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_TIME] = gui_color_build (GUI_COLOR_CHAT_TIME, CONFIG_COLOR(config_color_chat_time), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_TIME_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, CONFIG_COLOR(config_color_chat_time_delimiters), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_INFO] = gui_color_build (GUI_COLOR_CHAT_PREFIX_INFO, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_INFO]), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_ERROR] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ERROR, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR]), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_NETWORK] = gui_color_build (GUI_COLOR_CHAT_PREFIX_NETWORK, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_NETWORK]), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_ACTION] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ACTION, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_ACTION]), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_JOIN] = gui_color_build (GUI_COLOR_CHAT_PREFIX_JOIN, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_JOIN]), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_QUIT] = gui_color_build (GUI_COLOR_CHAT_PREFIX_QUIT, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_QUIT]), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_MORE] = gui_color_build (GUI_COLOR_CHAT_PREFIX_MORE, CONFIG_COLOR(config_color_chat_prefix_more), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_PREFIX_SUFFIX] = gui_color_build (GUI_COLOR_CHAT_PREFIX_SUFFIX, CONFIG_COLOR(config_color_chat_prefix_suffix), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_BUFFER] = gui_color_build (GUI_COLOR_CHAT_BUFFER, CONFIG_COLOR(config_color_chat_buffer), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_SERVER] = gui_color_build (GUI_COLOR_CHAT_SERVER, CONFIG_COLOR(config_color_chat_server), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_CHANNEL] = gui_color_build (GUI_COLOR_CHAT_CHANNEL, CONFIG_COLOR(config_color_chat_channel), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_NICK] = gui_color_build (GUI_COLOR_CHAT_NICK, CONFIG_COLOR(config_color_chat_nick), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_NICK_SELF] = gui_color_build (GUI_COLOR_CHAT_NICK_SELF, CONFIG_COLOR(config_color_chat_nick_self), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_NICK_OTHER] = gui_color_build (GUI_COLOR_CHAT_NICK_OTHER, CONFIG_COLOR(config_color_chat_nick_other), CONFIG_COLOR(config_color_chat_bg));
for (i = 0; i < GUI_COLOR_NICK_NUMBER; i++)
{
gui_color[GUI_COLOR_CHAT_NICK1 + i] = gui_color_build (GUI_COLOR_CHAT_NICK1 + i, cfg_col_chat_nick_colors[i], cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_NICK1 + i] = gui_color_build (GUI_COLOR_CHAT_NICK1 + i, CONFIG_COLOR(config_color_chat_nick_colors[i]), CONFIG_COLOR(config_color_chat_bg));
}
gui_color[GUI_COLOR_CHAT_HOST] = gui_color_build (GUI_COLOR_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_DELIMITERS, cfg_col_chat_delimiters, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg);
gui_color[GUI_COLOR_CHAT_READ_MARKER] = gui_color_build (GUI_COLOR_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg);
gui_color[GUI_COLOR_CHAT_HOST] = gui_color_build (GUI_COLOR_CHAT_HOST, CONFIG_COLOR(config_color_chat_host), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_DELIMITERS, CONFIG_COLOR(config_color_chat_delimiters), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, CONFIG_COLOR(config_color_chat_highlight), CONFIG_COLOR(config_color_chat_bg));
gui_color[GUI_COLOR_CHAT_READ_MARKER] = gui_color_build (GUI_COLOR_CHAT_READ_MARKER, CONFIG_COLOR(config_color_chat_read_marker), CONFIG_COLOR(config_color_chat_read_marker_bg));
gui_color[GUI_COLOR_STATUS] = gui_color_build (GUI_COLOR_STATUS, cfg_col_status, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS_DELIMITERS] = gui_color_build (GUI_COLOR_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS_CHANNEL] = gui_color_build (GUI_COLOR_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS_DATA_MSG] = gui_color_build (GUI_COLOR_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS_DATA_PRIVATE] = gui_color_build (GUI_COLOR_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS_DATA_HIGHLIGHT] = gui_color_build (GUI_COLOR_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS_DATA_OTHER] = gui_color_build (GUI_COLOR_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS_MORE] = gui_color_build (GUI_COLOR_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg);
gui_color[GUI_COLOR_STATUS] = gui_color_build (GUI_COLOR_STATUS, CONFIG_COLOR(config_color_status), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_STATUS_DELIMITERS] = gui_color_build (GUI_COLOR_STATUS_DELIMITERS, CONFIG_COLOR(config_color_status_delimiters), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_STATUS_CHANNEL] = gui_color_build (GUI_COLOR_STATUS_CHANNEL, CONFIG_COLOR(config_color_status_channel), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_STATUS_DATA_MSG] = gui_color_build (GUI_COLOR_STATUS_DATA_MSG, CONFIG_COLOR(config_color_status_data_msg), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_STATUS_DATA_PRIVATE] = gui_color_build (GUI_COLOR_STATUS_DATA_PRIVATE, CONFIG_COLOR(config_color_status_data_private), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_STATUS_DATA_HIGHLIGHT] = gui_color_build (GUI_COLOR_STATUS_DATA_HIGHLIGHT, CONFIG_COLOR(config_color_status_data_highlight), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_STATUS_DATA_OTHER] = gui_color_build (GUI_COLOR_STATUS_DATA_OTHER, CONFIG_COLOR(config_color_status_data_other), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_STATUS_MORE] = gui_color_build (GUI_COLOR_STATUS_MORE, CONFIG_COLOR(config_color_status_more), CONFIG_COLOR(config_color_status_bg));
gui_color[GUI_COLOR_INFOBAR] = gui_color_build (GUI_COLOR_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg);
gui_color[GUI_COLOR_INFOBAR_DELIMITERS] = gui_color_build (GUI_COLOR_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
gui_color[GUI_COLOR_INFOBAR_HIGHLIGHT] = gui_color_build (GUI_COLOR_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
gui_color[GUI_COLOR_INFOBAR] = gui_color_build (GUI_COLOR_INFOBAR, CONFIG_COLOR(config_color_infobar), CONFIG_COLOR(config_color_infobar_bg));
gui_color[GUI_COLOR_INFOBAR_DELIMITERS] = gui_color_build (GUI_COLOR_INFOBAR_DELIMITERS, CONFIG_COLOR(config_color_infobar_delimiters), CONFIG_COLOR(config_color_infobar_bg));
gui_color[GUI_COLOR_INFOBAR_HIGHLIGHT] = gui_color_build (GUI_COLOR_INFOBAR_HIGHLIGHT, CONFIG_COLOR(config_color_infobar_highlight), CONFIG_COLOR(config_color_infobar_bg));
gui_color[GUI_COLOR_INPUT] = gui_color_build (GUI_COLOR_INPUT, cfg_col_input, cfg_col_input_bg);
gui_color[GUI_COLOR_INPUT_SERVER] = gui_color_build (GUI_COLOR_INPUT_SERVER, cfg_col_input_server, cfg_col_input_bg);
gui_color[GUI_COLOR_INPUT_CHANNEL] = gui_color_build (GUI_COLOR_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
gui_color[GUI_COLOR_INPUT_NICK] = gui_color_build (GUI_COLOR_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
gui_color[GUI_COLOR_INPUT_DELIMITERS] = gui_color_build (GUI_COLOR_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
gui_color[GUI_COLOR_INPUT_TEXT_NOT_FOUND] = gui_color_build (GUI_COLOR_INPUT_TEXT_NOT_FOUND, cfg_col_input_text_not_found, cfg_col_input_bg);
gui_color[GUI_COLOR_INPUT_ACTIONS] = gui_color_build (GUI_COLOR_INPUT_ACTIONS, cfg_col_input_actions, cfg_col_input_bg);
gui_color[GUI_COLOR_INPUT] = gui_color_build (GUI_COLOR_INPUT, CONFIG_COLOR(config_color_input), CONFIG_COLOR(config_color_input_bg));
gui_color[GUI_COLOR_INPUT_SERVER] = gui_color_build (GUI_COLOR_INPUT_SERVER, CONFIG_COLOR(config_color_input_server), CONFIG_COLOR(config_color_input_bg));
gui_color[GUI_COLOR_INPUT_CHANNEL] = gui_color_build (GUI_COLOR_INPUT_CHANNEL, CONFIG_COLOR(config_color_input_channel), CONFIG_COLOR(config_color_input_bg));
gui_color[GUI_COLOR_INPUT_NICK] = gui_color_build (GUI_COLOR_INPUT_NICK, CONFIG_COLOR(config_color_input_nick), CONFIG_COLOR(config_color_input_bg));
gui_color[GUI_COLOR_INPUT_DELIMITERS] = gui_color_build (GUI_COLOR_INPUT_DELIMITERS, CONFIG_COLOR(config_color_input_delimiters), CONFIG_COLOR(config_color_input_bg));
gui_color[GUI_COLOR_INPUT_TEXT_NOT_FOUND] = gui_color_build (GUI_COLOR_INPUT_TEXT_NOT_FOUND, CONFIG_COLOR(config_color_input_text_not_found), CONFIG_COLOR(config_color_input_bg));
gui_color[GUI_COLOR_INPUT_ACTIONS] = gui_color_build (GUI_COLOR_INPUT_ACTIONS, CONFIG_COLOR(config_color_input_actions), CONFIG_COLOR(config_color_input_bg));
gui_color[GUI_COLOR_NICKLIST] = gui_color_build (GUI_COLOR_NICKLIST, cfg_col_nicklist, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_AWAY] = gui_color_build (GUI_COLOR_NICKLIST_AWAY, cfg_col_nicklist_away, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_PREFIX1] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX1, cfg_col_nicklist_prefix1, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_PREFIX2] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX2, cfg_col_nicklist_prefix2, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_PREFIX3] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX3, cfg_col_nicklist_prefix3, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_PREFIX4] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX4, cfg_col_nicklist_prefix4, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_PREFIX5] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX5, cfg_col_nicklist_prefix5, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_MORE] = gui_color_build (GUI_COLOR_NICKLIST_MORE, cfg_col_nicklist_more, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST_SEPARATOR] = gui_color_build (GUI_COLOR_NICKLIST_SEPARATOR, cfg_col_nicklist_separator, cfg_col_nicklist_bg);
gui_color[GUI_COLOR_NICKLIST] = gui_color_build (GUI_COLOR_NICKLIST, CONFIG_COLOR(config_color_nicklist), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_AWAY] = gui_color_build (GUI_COLOR_NICKLIST_AWAY, CONFIG_COLOR(config_color_nicklist_away), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_PREFIX1] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX1, CONFIG_COLOR(config_color_nicklist_prefix1), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_PREFIX2] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX2, CONFIG_COLOR(config_color_nicklist_prefix2), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_PREFIX3] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX3, CONFIG_COLOR(config_color_nicklist_prefix3), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_PREFIX4] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX4, CONFIG_COLOR(config_color_nicklist_prefix4), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_PREFIX5] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX5, CONFIG_COLOR(config_color_nicklist_prefix5), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_MORE] = gui_color_build (GUI_COLOR_NICKLIST_MORE, CONFIG_COLOR(config_color_nicklist_more), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_NICKLIST_SEPARATOR] = gui_color_build (GUI_COLOR_NICKLIST_SEPARATOR, CONFIG_COLOR(config_color_nicklist_separator), CONFIG_COLOR(config_color_nicklist_bg));
gui_color[GUI_COLOR_INFO] = gui_color_build (GUI_COLOR_INFO, cfg_col_info, cfg_col_info_bg);
gui_color[GUI_COLOR_INFO_WAITING] = gui_color_build (GUI_COLOR_INFO_WAITING, cfg_col_info_waiting, cfg_col_info_bg);
gui_color[GUI_COLOR_INFO_CONNECTING] = gui_color_build (GUI_COLOR_INFO_CONNECTING, cfg_col_info_connecting, cfg_col_info_bg);
gui_color[GUI_COLOR_INFO_ACTIVE] = gui_color_build (GUI_COLOR_INFO_ACTIVE, cfg_col_info_active, cfg_col_info_bg);
gui_color[GUI_COLOR_INFO_DONE] = gui_color_build (GUI_COLOR_INFO_DONE, cfg_col_info_done, cfg_col_info_bg);
gui_color[GUI_COLOR_INFO_FAILED] = gui_color_build (GUI_COLOR_INFO_FAILED, cfg_col_info_failed, cfg_col_info_bg);
gui_color[GUI_COLOR_INFO_ABORTED] = gui_color_build (GUI_COLOR_INFO_ABORTED, cfg_col_info_aborted, cfg_col_info_bg);
gui_color[GUI_COLOR_INFO] = gui_color_build (GUI_COLOR_INFO, CONFIG_COLOR(config_color_info), CONFIG_COLOR(config_color_info_bg));
gui_color[GUI_COLOR_INFO_WAITING] = gui_color_build (GUI_COLOR_INFO_WAITING, CONFIG_COLOR(config_color_info_waiting), CONFIG_COLOR(config_color_info_bg));
gui_color[GUI_COLOR_INFO_CONNECTING] = gui_color_build (GUI_COLOR_INFO_CONNECTING, CONFIG_COLOR(config_color_info_connecting), CONFIG_COLOR(config_color_info_bg));
gui_color[GUI_COLOR_INFO_ACTIVE] = gui_color_build (GUI_COLOR_INFO_ACTIVE, CONFIG_COLOR(config_color_info_active), CONFIG_COLOR(config_color_info_bg));
gui_color[GUI_COLOR_INFO_DONE] = gui_color_build (GUI_COLOR_INFO_DONE, CONFIG_COLOR(config_color_info_done), CONFIG_COLOR(config_color_info_bg));
gui_color[GUI_COLOR_INFO_FAILED] = gui_color_build (GUI_COLOR_INFO_FAILED, CONFIG_COLOR(config_color_info_failed), CONFIG_COLOR(config_color_info_bg));
gui_color[GUI_COLOR_INFO_ABORTED] = gui_color_build (GUI_COLOR_INFO_ABORTED, CONFIG_COLOR(config_color_info_aborted), CONFIG_COLOR(config_color_info_bg));
}
/*
+5 -3
View File
@@ -30,6 +30,7 @@
#include "../../core/wee-config.h"
#include "../../core/wee-string.h"
#include "../gui-infobar.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-curses.h"
@@ -64,7 +65,7 @@ gui_infobar_draw_time (struct t_gui_buffer *buffer)
0, 1,
"%02d:%02d",
local_time->tm_hour, local_time->tm_min);
if (cfg_look_infobar_seconds)
if (CONFIG_BOOLEAN(config_look_infobar_seconds))
wprintw (GUI_CURSES(ptr_win)->win_infobar,
":%02d",
local_time->tm_sec);
@@ -105,7 +106,8 @@ gui_infobar_draw (struct t_gui_buffer *buffer, int erase)
if (local_time)
{
strftime (text_time, sizeof (text_time),
cfg_look_infobar_time_format, local_time);
CONFIG_STRING(config_look_infobar_time_format),
local_time);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
GUI_COLOR_INFOBAR_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_infobar, "[");
@@ -114,7 +116,7 @@ gui_infobar_draw (struct t_gui_buffer *buffer, int erase)
wprintw (GUI_CURSES(ptr_win)->win_infobar,
"%02d:%02d",
local_time->tm_hour, local_time->tm_min);
if (cfg_look_infobar_seconds)
if (CONFIG_BOOLEAN(config_look_infobar_seconds))
wprintw (GUI_CURSES(ptr_win)->win_infobar,
":%02d",
local_time->tm_sec);
+2 -1
View File
@@ -32,6 +32,7 @@
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-input.h"
#include "../gui-color.h"
#include "../gui-keyboard.h"
#include "../gui-main.h"
#include "../gui-window.h"
@@ -90,7 +91,7 @@ gui_input_draw_prompt (struct t_gui_window *window)
return;
}
pos = cfg_look_input_format;
pos = CONFIG_STRING(config_look_input_format);
while (pos && pos[0])
{
switch (pos[0])
+3 -2
View File
@@ -31,6 +31,7 @@
#include "../../core/wee-utf8.h"
#include "../../core/wee-string.h"
#include "../gui-keyboard.h"
#include "../gui-color.h"
#include "../gui-input.h"
#include "../gui-completion.h"
#include "../gui-window.h"
@@ -218,10 +219,10 @@ gui_keyboard_read ()
{
/* detect user paste or large amount of text
if so, ask user what to do */
if (cfg_look_paste_max_lines > 0)
if (CONFIG_INTEGER(config_look_paste_max_lines) > 0)
{
paste_lines = gui_keyboard_get_paste_lines ();
if (paste_lines > cfg_look_paste_max_lines)
if (paste_lines > CONFIG_INTEGER(config_look_paste_max_lines))
{
gui_keyboard_paste_pending = 1;
gui_input_draw (gui_current_window->buffer, 1);
+10 -7
View File
@@ -36,12 +36,14 @@
#include "../../core/wee-utf8.h"
#include "../../core/wee-util.h"
#include "../../plugins/plugin.h"
#include "../gui-main.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-infobar.h"
#include "../gui-input.h"
#include "../gui-history.h"
#include "../gui-hotlist.h"
#include "../gui-keyboard.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-curses.h"
@@ -87,7 +89,7 @@ gui_main_init ()
gui_input_clipboard = NULL;
/* get time length */
gui_chat_time_length = util_get_time_length (cfg_look_buffer_time_format);
gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format));
/* create new window/buffer */
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
@@ -105,7 +107,7 @@ gui_main_init ()
else
gui_init_ok = 0;
if (cfg_look_set_title)
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_set ();
signal (SIGWINCH, gui_window_refresh_screen_sigwinch);
@@ -179,11 +181,12 @@ gui_main_loop ()
old_min = local_time->tm_min;
gui_infobar_draw (gui_current_window->buffer, 1);
if (cfg_look_day_change
if (CONFIG_BOOLEAN(config_look_day_change)
&& (local_time->tm_mday != old_day))
{
strftime (text_time, sizeof (text_time),
cfg_look_day_change_time_format, local_time);
CONFIG_STRING(config_look_day_change_time_format),
local_time);
text_time2 = string_iconv_to_internal (NULL, text_time);
gui_add_hotlist = 0;
for (ptr_buffer = gui_buffers; ptr_buffer;
@@ -208,7 +211,7 @@ gui_main_loop ()
old_sec = local_time->tm_sec;
/* display time in infobar (if seconds displayed) */
if (cfg_look_infobar_seconds)
if (CONFIG_BOOLEAN(config_look_infobar_seconds))
{
gui_infobar_draw_time (gui_current_window->buffer);
wmove (GUI_CURSES(gui_current_window)->win_input,
@@ -305,7 +308,7 @@ gui_main_end ()
gui_infobar_remove ();
/* reset title */
if (cfg_look_set_title)
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_reset ();
/* end of Curses output */
+39 -36
View File
@@ -30,6 +30,8 @@
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../gui-nicklist.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-curses.h"
@@ -91,39 +93,39 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
}
}
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM))
max_chars = max_length;
else
max_chars = ((cfg_look_nicklist_min_size > 0)
&& (max_length < cfg_look_nicklist_min_size)) ?
cfg_look_nicklist_min_size :
(((cfg_look_nicklist_max_size > 0)
&& (max_length > cfg_look_nicklist_max_size)) ?
cfg_look_nicklist_max_size : max_length);
max_chars = ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0)
&& (max_length < CONFIG_INTEGER(config_look_nicklist_min_size))) ?
CONFIG_INTEGER(config_look_nicklist_min_size) :
(((CONFIG_INTEGER(config_look_nicklist_max_size) > 0)
&& (max_length > CONFIG_INTEGER(config_look_nicklist_max_size))) ?
CONFIG_INTEGER(config_look_nicklist_max_size) : max_length);
if (cfg_look_nicklist_separator && has_colors ())
if (CONFIG_BOOLEAN(config_look_nicklist_separator) && has_colors ())
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
GUI_COLOR_NICKLIST_SEPARATOR);
switch (cfg_look_nicklist_position)
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CFG_LOOK_NICKLIST_LEFT:
case CONFIG_LOOK_NICKLIST_LEFT:
mvwvline (GUI_CURSES(ptr_win)->win_nick,
0, ptr_win->win_nick_width - 1, ACS_VLINE,
ptr_win->win_chat_height);
break;
case CFG_LOOK_NICKLIST_RIGHT:
case CONFIG_LOOK_NICKLIST_RIGHT:
mvwvline (GUI_CURSES(ptr_win)->win_nick,
0, 0, ACS_VLINE,
ptr_win->win_chat_height);
break;
case CFG_LOOK_NICKLIST_TOP:
case CONFIG_LOOK_NICKLIST_TOP:
mvwhline (GUI_CURSES(ptr_win)->win_nick,
ptr_win->win_nick_height - 1, 0, ACS_HLINE,
ptr_win->win_chat_width);
break;
case CFG_LOOK_NICKLIST_BOTTOM:
case CONFIG_LOOK_NICKLIST_BOTTOM:
mvwhline (GUI_CURSES(ptr_win)->win_nick,
0, 0, ACS_HLINE,
ptr_win->win_chat_width);
@@ -134,30 +136,31 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
GUI_COLOR_NICKLIST);
x = 0;
y = (cfg_look_nicklist_separator
&& (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ?
y = (CONFIG_BOOLEAN(config_look_nicklist_separator)
&& (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) ?
1 : 0;
max_y = 0;
switch (cfg_look_nicklist_position)
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CFG_LOOK_NICKLIST_LEFT:
case CFG_LOOK_NICKLIST_RIGHT:
case CONFIG_LOOK_NICKLIST_LEFT:
case CONFIG_LOOK_NICKLIST_RIGHT:
max_y = 0;
break;
case CFG_LOOK_NICKLIST_TOP:
case CONFIG_LOOK_NICKLIST_TOP:
max_y = ptr_win->win_nick_height -
cfg_look_nicklist_separator;
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
break;
case CFG_LOOK_NICKLIST_BOTTOM:
case CONFIG_LOOK_NICKLIST_BOTTOM:
max_y = ptr_win->win_nick_height;
break;
}
column = 0;
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM))
nicks_displayed = (ptr_win->win_width / (max_length + 2)) *
(ptr_win->win_nick_height - cfg_look_nicklist_separator);
(ptr_win->win_nick_height -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0));
else
nicks_displayed = ptr_win->win_nick_height;
@@ -172,16 +175,16 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
{
for (i = 0; i < nicks_displayed; i++)
{
switch (cfg_look_nicklist_position)
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CFG_LOOK_NICKLIST_LEFT:
case CONFIG_LOOK_NICKLIST_LEFT:
x = 0;
break;
case CFG_LOOK_NICKLIST_RIGHT:
x = cfg_look_nicklist_separator;
case CONFIG_LOOK_NICKLIST_RIGHT:
x = (CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0;
break;
case CFG_LOOK_NICKLIST_TOP:
case CFG_LOOK_NICKLIST_BOTTOM:
case CONFIG_LOOK_NICKLIST_TOP:
case CONFIG_LOOK_NICKLIST_BOTTOM:
x = column;
break;
}
@@ -253,7 +256,7 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
x++;
}
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
((cfg_irc_away_check > 0) && (ptr_nick->flags & IRC_NICK_AWAY)) ?
((config_irc_away_check > 0) && (ptr_nick->flags & IRC_NICK_AWAY)) ?
GUI_COLOR_WIN_NICK_AWAY : GUI_COLOR_WIN_NICK);*/
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
@@ -291,14 +294,14 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
break;
}
y++;
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM))
{
if (y >= max_y)
{
column += max_length + 2;
y = (cfg_look_nicklist_separator
&& (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ?
y = (CONFIG_BOOLEAN(config_look_nicklist_separator)
&& (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) ?
1 : 0;
}
}
+11 -9
View File
@@ -30,6 +30,7 @@
#include "../../core/wee-config.h"
#include "../../core/wee-utf8.h"
#include "../gui-status.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-hotlist.h"
#include "../gui-window.h"
@@ -121,22 +122,22 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase)
case GUI_HOTLIST_LOW:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_OTHER);
display_name = ((cfg_look_hotlist_names_level & 1) != 0);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 1) != 0);
break;
case GUI_HOTLIST_MSG:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_MSG);
display_name = ((cfg_look_hotlist_names_level & 2) != 0);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 2) != 0);
break;
case GUI_HOTLIST_PRIVATE:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_PRIVATE);
display_name = ((cfg_look_hotlist_names_level & 4) != 0);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 4) != 0);
break;
case GUI_HOTLIST_HIGHLIGHT:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_HIGHLIGHT);
display_name = ((cfg_look_hotlist_names_level & 8) != 0);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 8) != 0);
break;
default:
display_name = 0;
@@ -146,8 +147,9 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase)
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_hotlist->buffer->number);
if (display_name && (cfg_look_hotlist_names_count != 0)
&& (names_count < cfg_look_hotlist_names_count))
if (display_name
&& (CONFIG_INTEGER(config_look_hotlist_names_count) != 0)
&& (names_count < CONFIG_INTEGER(config_look_hotlist_names_count)))
{
names_count++;
@@ -157,12 +159,12 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase)
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
if (cfg_look_hotlist_names_length == 0)
if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0)
snprintf (format, sizeof (format) - 1, "%%s");
else
snprintf (format, sizeof (format) - 1,
"%%.%ds",
cfg_look_hotlist_names_length);
CONFIG_INTEGER(config_look_hotlist_names_length));
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
format,
ptr_hotlist->buffer->name);
@@ -179,7 +181,7 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase)
/* display lag */
/*if (GUI_SERVER(ptr_win->buffer))
{
if (GUI_SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show)
if (GUI_SERVER(ptr_win->buffer)->lag / 1000 >= config_irc_lag_min_show)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
+72 -51
View File
@@ -34,6 +34,8 @@
#include "../../core/wee-log.h"
#include "../../core/wee-string.h"
#include "../gui-window.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-hotlist.h"
#include "../gui-infobar.h"
#include "../gui-input.h"
@@ -206,18 +208,18 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
lines = 0;
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_LEFT) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_RIGHT))
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_LEFT) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_RIGHT))
{
if ((cfg_look_nicklist_min_size > 0)
&& (max_length < cfg_look_nicklist_min_size))
max_length = cfg_look_nicklist_min_size;
else if ((cfg_look_nicklist_max_size > 0)
&& (max_length > cfg_look_nicklist_max_size))
max_length = cfg_look_nicklist_max_size;
if ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0)
&& (max_length < CONFIG_INTEGER(config_look_nicklist_min_size)))
max_length = CONFIG_INTEGER(config_look_nicklist_min_size);
else if ((CONFIG_INTEGER(config_look_nicklist_max_size) > 0)
&& (max_length > CONFIG_INTEGER(config_look_nicklist_max_size)))
max_length = CONFIG_INTEGER(config_look_nicklist_max_size);
if (!force_calculate
&& (window->win_nick_width ==
max_length + 1 + cfg_look_nicklist_separator))
max_length + 1 + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0)))
return 0;
}
else
@@ -227,33 +229,36 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
lines = ((max_length + 2) * window->buffer->nicks_count) / width_used;
else
lines = (((max_length + 2) * window->buffer->nicks_count) / width_used) + 1;
if ((cfg_look_nicklist_max_size > 0)
&& (lines > cfg_look_nicklist_max_size))
lines = cfg_look_nicklist_max_size;
if ((cfg_look_nicklist_min_size > 0)
&& (lines < cfg_look_nicklist_min_size))
lines = cfg_look_nicklist_min_size;
max_height = (cfg_look_infobar) ?
if ((CONFIG_INTEGER(config_look_nicklist_max_size) > 0)
&& (lines > CONFIG_INTEGER(config_look_nicklist_max_size)))
lines = CONFIG_INTEGER(config_look_nicklist_max_size);
if ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0)
&& (lines < CONFIG_INTEGER(config_look_nicklist_min_size)))
lines = CONFIG_INTEGER(config_look_nicklist_min_size);
max_height = (CONFIG_BOOLEAN(config_look_infobar)) ?
window->win_height - 3 - 4 :
window->win_height - 2 - 4;
if (lines > max_height)
lines = max_height;
if (!force_calculate
&& (window->win_nick_height ==
lines + cfg_look_nicklist_separator))
lines + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0)))
return 0;
}
switch (cfg_look_nicklist_position)
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CFG_LOOK_NICKLIST_LEFT:
window->win_chat_x = window->win_x + max_length + 1 + cfg_look_nicklist_separator;
case CONFIG_LOOK_NICKLIST_LEFT:
window->win_chat_x = window->win_x + max_length + 1 +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_chat_y = window->win_y + 1;
window->win_chat_width = window->win_width - max_length - 1 - cfg_look_nicklist_separator;
window->win_chat_width = window->win_width - max_length - 1 -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x + 0;
window->win_nick_y = window->win_y + 1;
window->win_nick_width = max_length + 1 + cfg_look_nicklist_separator;
if (cfg_look_infobar)
window->win_nick_width = max_length + 1 +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
if (CONFIG_BOOLEAN(config_look_infobar))
{
window->win_chat_height = window->win_height - 4;
window->win_nick_height = window->win_height - 4;
@@ -265,14 +270,18 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
}
window->win_nick_num_max = window->win_nick_height;
break;
case CFG_LOOK_NICKLIST_RIGHT:
case CONFIG_LOOK_NICKLIST_RIGHT:
window->win_chat_x = window->win_x;
window->win_chat_y = window->win_y + 1;
window->win_chat_width = window->win_width - max_length - 1 - cfg_look_nicklist_separator;
window->win_nick_x = window->win_x + window->win_width - max_length - 1 - cfg_look_nicklist_separator;
window->win_chat_width = window->win_width - max_length - 1 -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x + window->win_width -
max_length - 1 -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_y = window->win_y + 1;
window->win_nick_width = max_length + 1 + cfg_look_nicklist_separator;
if (cfg_look_infobar)
window->win_nick_width = max_length + 1 +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
if (CONFIG_BOOLEAN(config_look_infobar))
{
window->win_chat_height = window->win_height - 4;
window->win_nick_height = window->win_height - 4;
@@ -284,35 +293,46 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
}
window->win_nick_num_max = window->win_nick_height;
break;
case CFG_LOOK_NICKLIST_TOP:
case CONFIG_LOOK_NICKLIST_TOP:
window->win_chat_x = window->win_x;
window->win_chat_y = window->win_y + 1 + lines + cfg_look_nicklist_separator;
window->win_chat_y = window->win_y + 1 + lines +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_chat_width = window->win_width;
if (cfg_look_infobar)
window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator - 1;
if (CONFIG_BOOLEAN(config_look_infobar))
window->win_chat_height = window->win_height - 3 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1;
else
window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator;
window->win_chat_height = window->win_height - 3 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x;
window->win_nick_y = window->win_y + 1;
window->win_nick_width = window->win_width;
window->win_nick_height = lines + cfg_look_nicklist_separator;
window->win_nick_height = lines +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2));
break;
case CFG_LOOK_NICKLIST_BOTTOM:
case CONFIG_LOOK_NICKLIST_BOTTOM:
window->win_chat_x = window->win_x;
window->win_chat_y = window->win_y + 1;
window->win_chat_width = window->win_width;
if (cfg_look_infobar)
window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator - 1;
if (CONFIG_BOOLEAN(config_look_infobar))
window->win_chat_height = window->win_height - 3 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1;
else
window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator;
window->win_chat_height = window->win_height - 3 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x;
if (cfg_look_infobar)
window->win_nick_y = window->win_y + window->win_height - 2 - lines - cfg_look_nicklist_separator - 1;
if (CONFIG_BOOLEAN(config_look_infobar))
window->win_nick_y = window->win_y + window->win_height -
2 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1;
else
window->win_nick_y = window->win_y + window->win_height - 2 - lines - cfg_look_nicklist_separator;
window->win_nick_y = window->win_y + window->win_height -
2 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_width = window->win_width;
window->win_nick_height = lines + cfg_look_nicklist_separator;
window->win_nick_height = lines +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2));
break;
}
@@ -325,7 +345,7 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
window->win_chat_x = window->win_x;
window->win_chat_y = window->win_y + 1;
window->win_chat_width = window->win_width;
if (cfg_look_infobar)
if (CONFIG_BOOLEAN(config_look_infobar))
window->win_chat_height = window->win_height - 4;
else
window->win_chat_height = window->win_height - 3;
@@ -346,7 +366,7 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
/* status window */
window->win_status_x = window->win_x;
if (cfg_look_infobar)
if (CONFIG_BOOLEAN(config_look_infobar))
window->win_status_y = window->win_y + window->win_height - 3;
else
window->win_status_y = window->win_y + window->win_height - 2;
@@ -354,7 +374,7 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
window->win_status_height = 1;
/* infobar window */
if (cfg_look_infobar)
if (CONFIG_BOOLEAN(config_look_infobar))
{
window->win_infobar_x = window->win_x;
window->win_infobar_y = window->win_y + window->win_height - 2;
@@ -424,7 +444,7 @@ gui_window_redraw_buffer (struct t_gui_buffer *buffer)
if (GUI_CURSES(ptr_win)->win_nick)
gui_nicklist_draw (buffer, 1);
gui_status_draw (buffer, 1);
if (cfg_look_infobar)
if (CONFIG_BOOLEAN(config_look_infobar))
gui_infobar_draw (buffer, 1);
gui_input_draw (buffer, 1);
}
@@ -494,7 +514,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
if (cfg_look_nicklist)
if (CONFIG_BOOLEAN(config_look_nicklist))
GUI_CURSES(window)->win_nick = newwin (window->win_nick_height,
window->win_nick_width,
window->win_nick_y,
@@ -513,7 +533,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
}
/* create status/infobar windows */
if (cfg_look_infobar)
if (CONFIG_BOOLEAN(config_look_infobar))
GUI_CURSES(window)->win_infobar = newwin (window->win_infobar_height,
window->win_infobar_width,
window->win_infobar_y,
@@ -616,8 +636,9 @@ gui_window_scroll_up (struct t_gui_window *window)
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
(window->start_line) ?
(-1) * cfg_look_scroll_amount :
(-1) * ( (window->win_chat_height - 1) + cfg_look_scroll_amount));
(-1) * CONFIG_INTEGER(config_look_scroll_amount) :
(-1) * ( (window->win_chat_height - 1) +
CONFIG_INTEGER(config_look_scroll_amount)));
gui_chat_draw (window->buffer, 0);
if (!window->scroll)
{
@@ -645,7 +666,7 @@ gui_window_scroll_down (struct t_gui_window *window)
{
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
cfg_look_scroll_amount);
CONFIG_INTEGER(config_look_scroll_amount));
/* check if we can display all */
ptr_line = window->start_line;
+1
View File
@@ -31,6 +31,7 @@
#include "../../core/wee-config.h"
#include "../../core/wee-utf8.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-gtk.h"
+1
View File
@@ -31,6 +31,7 @@
#include "../../core/wee-config.h"
#include "../../core/wee-string.h"
#include "../gui-color.h"
#include "../gui-chat.h"
#include "gui-gtk.h"
+1 -1
View File
@@ -29,7 +29,7 @@
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../gui-infobar.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-gtk.h"
+1 -1
View File
@@ -30,7 +30,7 @@
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-input.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-gtk.h"
+2 -2
View File
@@ -174,7 +174,7 @@ gui_main_init ()
else
gui_init_ok = 0;
if (cfg_look_set_title)
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_set ();
}
}
@@ -226,6 +226,6 @@ gui_main_end ()
gui_infobar_remove ();
/* reset title */
if (cfg_look_set_title)
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_title_reset ();
}
+5 -3
View File
@@ -30,6 +30,7 @@
#include "../../core/wee-config.h"
#include "../../core/wee-log.h"
#include "../gui-window.h"
#include "../gui-chat.h"
#include "../gui-hotlist.h"
#include "../gui-nicklist.h"
#include "../gui-main.h"
@@ -300,8 +301,9 @@ gui_window_scroll_up (struct t_gui_window *window)
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
(window->start_line) ?
(-1) * cfg_look_scroll_amount :
(-1) * ( (window->win_chat_height - 1) + cfg_look_scroll_amount));
(-1) * CONFIG_INTEGER(config_look_scroll_amount) :
(-1) * ( (window->win_chat_height - 1) +
CONFIG_INTEGER(config_look_scroll_amount)));
gui_chat_draw (window->buffer, 0);
gui_status_draw (window->buffer, 0);
}
@@ -324,7 +326,7 @@ gui_window_scroll_down (struct t_gui_window *window)
{
gui_chat_calculate_line_diff (window, &window->start_line,
&window->start_line_pos,
cfg_look_scroll_amount);
CONFIG_INTEGER(config_look_scroll_amount));
/* check if we can display all */
ptr_line = window->start_line;
+3 -2
View File
@@ -39,6 +39,7 @@
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
#include "gui-buffer.h"
#include "gui-chat.h"
#include "gui-completion.h"
#include "gui-history.h"
#include "gui-hotlist.h"
@@ -1387,8 +1388,8 @@ gui_action_scroll_unread (char *args)
if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
if (cfg_look_read_marker &&
cfg_look_read_marker[0] &&
if (CONFIG_STRING(config_look_read_marker) &&
CONFIG_STRING(config_look_read_marker)[0] &&
(gui_current_window->buffer->type == GUI_BUFFER_TYPE_FORMATED) &&
gui_current_window->buffer->last_read_line &&
gui_current_window->buffer->last_read_line != gui_current_window->buffer->last_line)
+3
View File
@@ -33,6 +33,9 @@
#include <ctype.h>
#include "../core/weechat.h"
#include "gui-buffer.h"
#include "gui-chat.h"
#include "gui-color.h"
#include "gui-completion.h"
#include "gui-history.h"
#include "gui-hotlist.h"
+19 -16
View File
@@ -35,6 +35,7 @@
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
#include "gui-chat.h"
#include "gui-color.h"
#include "gui-hotlist.h"
#include "gui-main.h"
#include "gui-status.h"
@@ -56,32 +57,32 @@ gui_chat_prefix_build ()
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_INFO),
cfg_look_prefix[GUI_CHAT_PREFIX_INFO]);
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_INFO]));
gui_chat_prefix[GUI_CHAT_PREFIX_INFO] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ERROR),
cfg_look_prefix[GUI_CHAT_PREFIX_ERROR]);
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ERROR]));
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_NETWORK),
cfg_look_prefix[GUI_CHAT_PREFIX_NETWORK]);
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_NETWORK]));
gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ACTION),
cfg_look_prefix[GUI_CHAT_PREFIX_ACTION]);
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ACTION]));
gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_JOIN),
cfg_look_prefix[GUI_CHAT_PREFIX_JOIN]);
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_JOIN]));
gui_chat_prefix[GUI_CHAT_PREFIX_JOIN] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_QUIT),
cfg_look_prefix[GUI_CHAT_PREFIX_QUIT]);
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_QUIT]));
gui_chat_prefix[GUI_CHAT_PREFIX_QUIT] = strdup (prefix);
}
@@ -210,13 +211,14 @@ gui_chat_get_time_string (time_t date)
int i, time_first_digit, time_last_digit, last_color;
struct tm *local_time;
if (!cfg_look_buffer_time_format
|| !cfg_look_buffer_time_format[0])
if (!CONFIG_STRING(config_look_buffer_time_format)
|| !CONFIG_STRING(config_look_buffer_time_format)[0])
return NULL;
local_time = localtime (&date);
if (strftime (text_time, sizeof (text_time),
cfg_look_buffer_time_format, local_time) == 0)
CONFIG_STRING(config_look_buffer_time_format),
local_time) == 0)
return NULL;
time_first_digit = -1;
@@ -325,17 +327,18 @@ gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
{
int length_suffix;
if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_NONE)
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)
return gui_chat_time_length + 1 + line->prefix_length + 2;
length_suffix = 0;
if (with_suffix)
{
if (cfg_look_prefix_suffix && cfg_look_prefix_suffix[0])
length_suffix = gui_chat_strlen_screen (cfg_look_prefix_suffix) + 1;
if (CONFIG_STRING(config_look_prefix_suffix)
&& CONFIG_STRING(config_look_prefix_suffix)[0])
length_suffix = gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix)) + 1;
}
if (cfg_look_prefix_align_max > 0)
return gui_chat_time_length + 1 + cfg_look_prefix_align_max +
if (CONFIG_INTEGER(config_look_prefix_align_max) > 0)
return gui_chat_time_length + 1 + CONFIG_INTEGER(config_look_prefix_align_max) +
length_suffix + 1;
else
return gui_chat_time_length + 1 + buffer->prefix_max_length +
@@ -434,8 +437,8 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
buffer->lines_count++;
/* remove one line if necessary */
if ((cfg_history_max_lines > 0)
&& (buffer->lines_count > cfg_history_max_lines))
if ((CONFIG_INTEGER(config_history_max_lines) > 0)
&& (buffer->lines_count > CONFIG_INTEGER(config_history_max_lines)))
{
if (buffer->last_line == buffer->lines)
buffer->last_line = NULL;
+10 -6
View File
@@ -47,16 +47,20 @@
int
gui_color_search_config (char *color_name)
{
int i;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
if (color_name)
{
i = 0;
while (weechat_options_colors[i].name)
ptr_section = config_file_search_section (weechat_config, "colors");
if (ptr_section)
{
if (string_strcasecmp (weechat_options_colors[i].name, color_name) == 0)
return weechat_options_colors[i].default_int;
i++;
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
{
if (string_strcasecmp (ptr_option->name, color_name) == 0)
return ptr_option->min;
}
}
}
+55 -63
View File
@@ -42,6 +42,7 @@
#include "../plugins/plugin.h"
#include "../plugins/plugin-config.h"
#include "gui-completion.h"
#include "gui-color.h"
#include "gui-keyboard.h"
@@ -203,7 +204,8 @@ gui_completion_is_only_alphanum (char *string)
{
while (string[0])
{
if (strchr (cfg_look_nick_completion_ignore, string[0]))
if (strchr (CONFIG_STRING(config_look_nick_completion_ignore),
string[0]))
return 0;
string++;
}
@@ -223,7 +225,8 @@ gui_completion_strdup_alphanum (char *string)
pos = result;
while (string[0])
{
if (!strchr (cfg_look_nick_completion_ignore, string[0]))
if (!strchr (CONFIG_STRING(config_look_nick_completion_ignore),
string[0]))
{
pos[0] = string[0];
pos++;
@@ -245,8 +248,8 @@ gui_completion_nickncmp (char *base_word, char *nick, int max)
char *base_word2, *nick2;
int return_cmp;
if (!cfg_look_nick_completion_ignore
|| !cfg_look_nick_completion_ignore[0]
if (!CONFIG_STRING(config_look_nick_completion_ignore)
|| !CONFIG_STRING(config_look_nick_completion_ignore)[0]
|| !base_word || !nick || !base_word[0] || !nick[0]
|| (!gui_completion_is_only_alphanum (base_word)))
return string_strncasecmp (base_word, nick, max);
@@ -600,7 +603,7 @@ gui_completion_list_add_channel_nicks (struct t_gui_completion *completion)
}
// add nicks speaking recently on this channel
if (cfg_look_nick_completion_smart)
if (CONFIG_BOOLEAN(config_look_nick_completion_smart))
{
for (ptr_weelist = ((t_irc_channel *)(completion->channel))->nicks_speaking;
ptr_weelist; ptr_weelist = ptr_weelist->next_weelist)
@@ -684,19 +687,18 @@ gui_completion_list_add_channel_nicks_hosts (struct t_gui_completion *completion
void
gui_completion_list_add_option (struct t_gui_completion *completion)
{
int i, j;
/* WeeChat options */
for (i = 0; weechat_config_sections[i]; i++)
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
for (ptr_section = weechat_config->sections; ptr_section;
ptr_section = ptr_section->next_section)
{
if (weechat_config_options[i])
for (ptr_option = ptr_section->options; ptr_option;
ptr_option = ptr_option->next_option)
{
for (j = 0; weechat_config_options[i][j].name; j++)
{
gui_completion_list_add (completion,
weechat_config_options[i][j].name,
0, WEELIST_POS_SORT);
}
gui_completion_list_add (completion,
ptr_option->name,
0, WEELIST_POS_SORT);
}
}
}
@@ -708,12 +710,13 @@ gui_completion_list_add_option (struct t_gui_completion *completion)
void
gui_completion_list_add_plugin_option (struct t_gui_completion *completion)
{
struct t_plugin_option *ptr_option;
struct t_config_option *ptr_option;
for (ptr_option = plugin_options; ptr_option;
ptr_option = ptr_option->next_option)
{
gui_completion_list_add (completion, ptr_option->name, 0, WEELIST_POS_SORT);
gui_completion_list_add (completion, ptr_option->name,
0, WEELIST_POS_SORT);
}
}
@@ -725,8 +728,8 @@ void
gui_completion_list_add_part (struct t_gui_completion *completion)
{
(void) completion;
/*if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0])
gui_completion_list_add (completion, cfg_irc_default_msg_part,
/*if (config_irc_default_msg_part && config_irc_default_msg_part[0])
gui_completion_list_add (completion, config_irc_default_msg_part,
0, WEELIST_POS_SORT);*/
}
@@ -755,8 +758,8 @@ void
gui_completion_list_add_quit (struct t_gui_completion *completion)
{
(void) completion;
/*if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0])
gui_completion_list_add (completion, cfg_irc_default_msg_quit,
/*if (config_irc_default_msg_quit && config_irc_default_msg_quit[0])
gui_completion_list_add (completion, config_irc_default_msg_quit,
0, WEELIST_POS_SORT);*/
}
@@ -806,7 +809,7 @@ gui_completion_list_add_topic (struct t_gui_completion *completion)
&& ((t_irc_channel *)(completion->channel))->topic
&& ((t_irc_channel *)(completion->channel))->topic[0])
{
if (cfg_irc_colors_send)
if (config_irc_colors_send)
string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)(completion->channel))->topic);
else
string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)(completion->channel))->topic, 0, 0);
@@ -826,65 +829,54 @@ gui_completion_list_add_topic (struct t_gui_completion *completion)
void
gui_completion_list_add_option_value (struct t_gui_completion *completion)
{
char *pos;
struct t_config_option *option;
void *option_value;
char option_string[2048];
char *pos, *color_name, option_string[2048];
struct t_config_option *ptr_option;
if (completion->args)
{
pos = strchr (completion->args, ' ');
if (pos)
pos[0] = '\0';
option = NULL;
option_value = NULL;
//config_option_search_option_value (completion->args, &option, &option_value);
config_option_section_option_search_get_value (weechat_config_sections,
weechat_config_options,
completion->args,
&option,
&option_value);
if (option && option_value)
ptr_option = config_file_search_option (weechat_config,
NULL,
completion->args);
if (ptr_option)
{
switch (option->type)
switch (ptr_option->type)
{
case OPTION_TYPE_BOOLEAN:
if (option_value && (*((int *)(option_value))))
case CONFIG_OPTION_BOOLEAN:
if (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE)
gui_completion_list_add (completion, "on",
0, WEELIST_POS_SORT);
else
gui_completion_list_add (completion, "off",
0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_INT:
snprintf (option_string, sizeof (option_string) - 1,
"%d", (option_value) ? *((int *)(option_value)) : option->default_int);
case CONFIG_OPTION_INTEGER:
if (ptr_option->string_values)
snprintf (option_string, sizeof (option_string) - 1,
"%s",
ptr_option->string_values[CONFIG_INTEGER(ptr_option)]);
else
snprintf (option_string, sizeof (option_string) - 1,
"%d", CONFIG_INTEGER(ptr_option));
gui_completion_list_add (completion, option_string,
0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_INT_WITH_STRING:
gui_completion_list_add (completion,
(option_value) ?
option->array_values[*((int *)(option_value))] :
option->array_values[option->default_int],
0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_COLOR:
gui_completion_list_add (completion,
(option_value) ?
gui_color_get_name (*((int *)(option_value))) :
option->default_string,
0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_STRING:
case CONFIG_OPTION_STRING:
snprintf (option_string, sizeof (option_string) - 1,
"\"%s\"",
((option_value) && (*((char **)(option_value)))) ?
*((char **)(option_value)) :
option->default_string);
CONFIG_STRING(ptr_option));
gui_completion_list_add (completion, option_string,
0, WEELIST_POS_SORT);
break;
case CONFIG_OPTION_COLOR:
color_name = gui_color_get_name (CONFIG_INTEGER(ptr_option));
if (color_name)
gui_completion_list_add (completion,
color_name,
0, WEELIST_POS_SORT);
break;
}
}
if (pos)
@@ -900,7 +892,7 @@ void
gui_completion_list_add_plugin_option_value (struct t_gui_completion *completion)
{
char *pos;
struct t_plugin_option *ptr_option;
struct t_config_option *ptr_option;
if (completion->args)
{
@@ -1443,7 +1435,7 @@ gui_completion_nick (struct t_gui_completion *completion)
}
// add nicks speaking recently on this channel
if (cfg_look_nick_completion_smart)
if (CONFIG_BOOLEAN(config_look_nick_completion_smart))
{
for (ptr_weelist = ((t_irc_channel *)(completion->channel))->nicks_speaking;
ptr_weelist; ptr_weelist = ptr_weelist->next_weelist)
@@ -1485,7 +1477,7 @@ gui_completion_nick (struct t_gui_completion *completion)
if (completion->word_found)
free (completion->word_found);
completion->word_found = strdup (ptr_weelist->data);
if (cfg_look_nick_complete_first)
if (CONFIG_BOOLEAN(config_look_nick_complete_first))
{
completion->position = -1;
return;
+44 -36
View File
@@ -30,6 +30,7 @@
#include "../core/wee-config.h"
#include "../core/wee-string.h"
#include "gui-history.h"
#include "gui-buffer.h"
struct t_gui_history *history_global = NULL;
@@ -43,46 +44,50 @@ int num_history_global = 0;
*/
void
gui_history_buffer_add (struct t_gui_buffer *buffer, char *string)
gui_history_buffer_add (void *buffer, char *string)
{
struct t_gui_buffer *ptr_buffer;
struct t_gui_history *new_history, *ptr_history;
ptr_buffer = (struct t_gui_buffer *)buffer;
if (!string)
return;
if (!buffer->history
|| (buffer->history
&& (string_strcasecmp (buffer->history->text, string) != 0)))
if (!ptr_buffer->history
|| (ptr_buffer->history
&& (string_strcasecmp (ptr_buffer->history->text,
string) != 0)))
{
new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history));
if (new_history)
{
new_history->text = strdup (string);
/*if (cfg_log_hide_nickserv_pwd)
/*if (config_log_hide_nickserv_pwd)
irc_display_hide_password (new_history->text, 1);*/
if (buffer->history)
buffer->history->prev_history = new_history;
if (ptr_buffer->history)
ptr_buffer->history->prev_history = new_history;
else
buffer->last_history = new_history;
new_history->next_history = buffer->history;
ptr_buffer->last_history = new_history;
new_history->next_history = ptr_buffer->history;
new_history->prev_history = NULL;
buffer->history = new_history;
buffer->num_history++;
ptr_buffer->history = new_history;
ptr_buffer->num_history++;
/* remove one command if necessary */
if ((cfg_history_max_commands > 0)
&& (buffer->num_history > cfg_history_max_commands))
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
&& (ptr_buffer->num_history > CONFIG_INTEGER(config_history_max_commands)))
{
ptr_history = buffer->last_history->prev_history;
if (buffer->ptr_history == buffer->last_history)
buffer->ptr_history = ptr_history;
buffer->last_history->prev_history->next_history = NULL;
if (buffer->last_history->text)
free (buffer->last_history->text);
free (buffer->last_history);
buffer->last_history = ptr_history;
buffer->num_history++;
ptr_history = ptr_buffer->last_history->prev_history;
if (ptr_buffer->ptr_history == ptr_buffer->last_history)
ptr_buffer->ptr_history = ptr_history;
ptr_buffer->last_history->prev_history->next_history = NULL;
if (ptr_buffer->last_history->text)
free (ptr_buffer->last_history->text);
free (ptr_buffer->last_history);
ptr_buffer->last_history = ptr_history;
ptr_buffer->num_history++;
}
}
}
@@ -108,7 +113,7 @@ gui_history_global_add (char *string)
if (new_history)
{
new_history->text = strdup (string);
/*if (cfg_log_hide_nickserv_pwd)
/*if (config_log_hide_nickserv_pwd)
irc_display_hide_password (new_history->text, 1);*/
if (history_global)
@@ -121,8 +126,8 @@ gui_history_global_add (char *string)
num_history_global++;
/* remove one command if necessary */
if ((cfg_history_max_commands > 0)
&& (num_history_global > cfg_history_max_commands))
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
&& (num_history_global > CONFIG_INTEGER(config_history_max_commands)))
{
ptr_history = history_global_last->prev_history;
if (history_global_ptr == history_global_last)
@@ -167,20 +172,23 @@ gui_history_global_free ()
*/
void
gui_history_buffer_free (struct t_gui_buffer *buffer)
gui_history_buffer_free (void *buffer)
{
struct t_gui_buffer *ptr_buffer;
struct t_gui_history *ptr_history;
while (buffer->history)
ptr_buffer = (struct t_gui_buffer *)buffer;
while (ptr_buffer->history)
{
ptr_history = buffer->history->next_history;
if (buffer->history->text)
free (buffer->history->text);
free (buffer->history);
buffer->history = ptr_history;
ptr_history = ptr_buffer->history->next_history;
if (ptr_buffer->history->text)
free (ptr_buffer->history->text);
free (ptr_buffer->history);
ptr_buffer->history = ptr_history;
}
buffer->history = NULL;
buffer->last_history = NULL;
buffer->ptr_history = NULL;
buffer->num_history = 0;
ptr_buffer->history = NULL;
ptr_buffer->last_history = NULL;
ptr_buffer->ptr_history = NULL;
ptr_buffer->num_history = 0;
}
+2 -2
View File
@@ -32,9 +32,9 @@ extern struct t_gui_history *history_global_last;
extern struct t_gui_history *history_global_ptr;
/* history functions (gui-history.c) */
extern void gui_history_buffer_add (struct t_gui_buffer *, char *);
extern void gui_history_buffer_add (void *, char *);
extern void gui_history_global_add (char *);
extern void gui_history_global_free ();
extern void gui_history_buffer_free (struct t_gui_buffer *);
extern void gui_history_buffer_free (void *);
#endif /* gui-history.h */
+8 -7
View File
@@ -31,6 +31,7 @@
#include "../core/wee-log.h"
#include "../core/wee-util.h"
#include "gui-hotlist.h"
#include "gui-buffer.h"
#include "gui-window.h"
@@ -70,9 +71,9 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h
{
struct t_gui_hotlist *ptr_hotlist;
switch (cfg_look_hotlist_sort)
switch (CONFIG_INTEGER(config_look_hotlist_sort))
{
case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC:
case CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC:
for (ptr_hotlist = hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
@@ -83,7 +84,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h
return ptr_hotlist;
}
break;
case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC:
case CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC:
for (ptr_hotlist = hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
@@ -94,7 +95,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h
return ptr_hotlist;
}
break;
case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC:
case CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC:
for (ptr_hotlist = hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
@@ -104,7 +105,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h
return ptr_hotlist;
}
break;
case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC:
case CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC:
for (ptr_hotlist = hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
@@ -114,7 +115,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h
return ptr_hotlist;
}
break;
case CFG_LOOK_HOTLIST_SORT_NUMBER_ASC:
case CONFIG_LOOK_HOTLIST_SORT_NUMBER_ASC:
for (ptr_hotlist = hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
@@ -122,7 +123,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h
return ptr_hotlist;
}
break;
case CFG_LOOK_HOTLIST_SORT_NUMBER_DESC:
case CONFIG_LOOK_HOTLIST_SORT_NUMBER_DESC:
for (ptr_hotlist = hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
+7 -5
View File
@@ -242,13 +242,15 @@ gui_input_complete (struct t_gui_buffer *buffer)
{
if (strncmp (utf8_add_offset (buffer->input_buffer,
buffer->input_buffer_pos),
cfg_look_nick_completor, strlen (cfg_look_nick_completor)) != 0)
gui_input_insert_string (buffer, cfg_look_nick_completor,
CONFIG_STRING(config_look_nick_completor),
strlen (CONFIG_STRING(config_look_nick_completor))) != 0)
gui_input_insert_string (buffer,
CONFIG_STRING(config_look_nick_completor),
buffer->input_buffer_pos);
else
buffer->input_buffer_pos += utf8_strlen (cfg_look_nick_completor);
buffer->input_buffer_pos += utf8_strlen (CONFIG_STRING(config_look_nick_completor));
if (buffer->completion->position >= 0)
buffer->completion->position += strlen (cfg_look_nick_completor);
buffer->completion->position += strlen (CONFIG_STRING(config_look_nick_completor));
if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer,
buffer->input_buffer_pos)] != ' ')
gui_input_insert_string (buffer, " ",
@@ -315,7 +317,7 @@ gui_input_get_prompt_length (struct t_gui_buffer *buffer)
}
length = 0;
pos = cfg_look_input_format;
pos = CONFIG_STRING(config_look_input_format);
while (pos && pos[0])
{
switch (pos[0])
-5
View File
@@ -20,11 +20,6 @@
#ifndef __WEECHAT_GUI_MAIN_H
#define __WEECHAT_GUI_MAIN_H 1
/* main variables */
extern int gui_init_ok;
extern int gui_ok;
/* main functions (GUI dependent) */
extern void gui_main_loop ();
+1
View File
@@ -38,6 +38,7 @@
#include "../core/wee-log.h"
#include "../core/wee-utf8.h"
#include "gui-window.h"
#include "gui-chat.h"
#include "gui-input.h"
#include "gui-hotlist.h"
#include "gui-status.h"
+3
View File
@@ -20,6 +20,9 @@
#ifndef __WEECHAT_GUI_WINDOW_H
#define __WEECHAT_GUI_WINDOW_H 1
extern int gui_init_ok;
extern int gui_ok;
/* window structures */
struct t_gui_window
+36 -46
View File
@@ -41,6 +41,7 @@
#include "../core/wee-utf8.h"
#include "../core/wee-util.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-infobar.h"
#include "../gui/gui-input.h"
#include "../gui/gui-keyboard.h"
@@ -1110,26 +1111,22 @@ plugin_api_get_config_str_value (struct t_config_option *option)
switch (option->type)
{
case OPTION_TYPE_BOOLEAN:
return (*((int *)(option->ptr_int))) ?
case CONFIG_OPTION_BOOLEAN:
return (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
strdup ("on") : strdup ("off");
break;
case OPTION_TYPE_INT:
snprintf (buf_temp, sizeof (buf_temp), "%d",
*((int *)(option->ptr_int)));
case CONFIG_OPTION_INTEGER:
if (option->string_values)
snprintf (buf_temp, sizeof (buf_temp), "%s",
option->string_values[CONFIG_INTEGER(option)]);
else
snprintf (buf_temp, sizeof (buf_temp), "%d",
CONFIG_INTEGER(option));
return strdup (buf_temp);
break;
case OPTION_TYPE_INT_WITH_STRING:
return strdup (option->array_values[*((int *)(option->ptr_int))]);
break;
case OPTION_TYPE_STRING:
return (*((char **)(option->ptr_string))) ?
strdup (*((char **)(option->ptr_string))) : strdup ("");
break;
case OPTION_TYPE_COLOR:
color_name = gui_color_get_name (*((int *)(option->ptr_int)));
case CONFIG_OPTION_STRING:
return strdup (CONFIG_STRING(option));
case CONFIG_OPTION_COLOR:
color_name = gui_color_get_name (CONFIG_INTEGER(option));
return (color_name) ? strdup (color_name) : strdup ("");
break;
}
/* should never be executed! */
@@ -1137,7 +1134,7 @@ plugin_api_get_config_str_value (struct t_config_option *option)
}
/*
* plugin_api_config_get: get value of a config option
* plugin_api_config_get: get value of a WeeChat config option
*/
char *
@@ -1147,11 +1144,9 @@ plugin_api_config_get (struct t_weechat_plugin *plugin, char *option_name)
/* make C compiler happy */
(void) plugin;
/* search a WeeChat command */
ptr_option = config_option_section_option_search (weechat_config_sections,
weechat_config_options,
option_name);
/* search WeeChat config option */
ptr_option = config_file_search_option (weechat_config, NULL, option_name);
if (ptr_option)
return plugin_api_get_config_str_value (ptr_option);
@@ -1168,6 +1163,7 @@ plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name,
char *value)
{
struct t_config_option *ptr_option;
int rc;
/* make C compiler happy */
(void) plugin;
@@ -1175,22 +1171,16 @@ plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name,
if (!option_name || !value)
return 0;
/* search and set WeeChat option if found */
ptr_option = config_option_section_option_search (weechat_config_sections,
weechat_config_options,
option_name);
/* search and set WeeChat config option if found */
ptr_option = config_file_search_option (weechat_config, NULL, option_name);
if (ptr_option)
{
if (ptr_option->handler_change)
{
if (config_option_set (ptr_option, value) == 0)
{
(void) (ptr_option->handler_change());
return 1;
}
}
else
rc = config_file_option_set (ptr_option, value);
if ((rc == 2) && (ptr_option->callback_change))
(void) (ptr_option->callback_change) ();
if (rc == 0)
return 0;
return 1;
}
/* failed to set config option */
@@ -1202,16 +1192,16 @@ plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name,
*/
char *
plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option)
plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option_name)
{
struct t_plugin_option *ptr_plugin_option;
struct t_config_option *ptr_option;
if (!option)
if (!option_name)
return NULL;
ptr_plugin_option = plugin_config_search (plugin->name, option);
if (ptr_plugin_option)
return (ptr_plugin_option->value) ? strdup (ptr_plugin_option->value) : NULL;
ptr_option = plugin_config_search (plugin->name, option_name);
if (ptr_option)
return (ptr_option->value) ? strdup (ptr_option->value) : NULL;
/* option not found */
return NULL;
@@ -1222,13 +1212,13 @@ plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option)
*/
int
plugin_api_plugin_config_set (struct t_weechat_plugin *plugin, char *option,
char *value)
plugin_api_plugin_config_set (struct t_weechat_plugin *plugin,
char *option_name, char *value)
{
if (!option)
if (!option_name)
return 0;
if (plugin_config_set (plugin->name, option, value))
if (plugin_config_set (plugin->name, option_name, value))
{
plugin_config_write ();
return 1;
+104 -117
View File
@@ -37,20 +37,9 @@
#include "plugin-config.h"
struct t_plugin_option *plugin_options = NULL;
struct t_plugin_option *last_plugin_option = NULL;
char *plugin_config_sections[] =
{ "plugin", NULL };
struct t_config_option *plugin_config_options[] =
{ NULL, NULL };
t_config_func_read_option *plugin_config_read_functions[] =
{ plugin_config_read_option, NULL };
t_config_func_write_options *plugin_config_write_functions[] =
{ plugin_config_write_options, NULL };
struct t_config_file *plugin_config = NULL;
struct t_config_option *plugin_options = NULL;
struct t_config_option *last_plugin_option = NULL;
/*
@@ -58,17 +47,17 @@ t_config_func_write_options *plugin_config_write_functions[] =
* This function should not be called directly.
*/
struct t_plugin_option *
plugin_config_search_internal (char *option)
struct t_config_option *
plugin_config_search_internal (char *option_name)
{
struct t_plugin_option *ptr_plugin_option;
struct t_config_option *ptr_option;
for (ptr_plugin_option = plugin_options; ptr_plugin_option;
ptr_plugin_option = ptr_plugin_option->next_option)
for (ptr_option = plugin_options; ptr_option;
ptr_option = ptr_option->next_option)
{
if (string_strcasecmp (ptr_plugin_option->name, option) == 0)
if (string_strcasecmp (ptr_option->name, option_name) == 0)
{
return ptr_plugin_option;
return ptr_option;
}
}
@@ -80,36 +69,36 @@ plugin_config_search_internal (char *option)
* plugin_config_search: search a plugin option
*/
struct t_plugin_option *
plugin_config_search (char *plugin_name, char *option)
struct t_config_option *
plugin_config_search (char *plugin_name, char *option_name)
{
char *internal_option;
struct t_plugin_option *ptr_plugin_option;
struct t_config_option *ptr_option;
internal_option = (char *)malloc (strlen (plugin_name) +
strlen (option) + 2);
strlen (option_name) + 2);
if (!internal_option)
return NULL;
strcpy (internal_option, plugin_name);
strcat (internal_option, ".");
strcat (internal_option, option);
strcat (internal_option, option_name);
ptr_plugin_option = plugin_config_search_internal (internal_option);
ptr_option = plugin_config_search_internal (internal_option);
free (internal_option);
return ptr_plugin_option;
return ptr_option;
}
/*
* plugin_config_find_pos: find position for a plugin option (for sorting options)
*/
struct t_plugin_option *
struct t_config_option *
plugin_config_find_pos (char *name)
{
struct t_plugin_option *ptr_option;
struct t_config_option *ptr_option;
for (ptr_option = plugin_options; ptr_option;
ptr_option = ptr_option->next_option)
@@ -117,6 +106,8 @@ plugin_config_find_pos (char *name)
if (string_strcasecmp (name, ptr_option->name) < 0)
return ptr_option;
}
/* position not found (we will add to the end of list) */
return NULL;
}
@@ -129,33 +120,33 @@ plugin_config_find_pos (char *name)
int
plugin_config_set_internal (char *option, char *value)
{
struct t_plugin_option *ptr_plugin_option, *pos_option;
struct t_config_option *ptr_option, *pos_option;
int rc;
rc = 0;
ptr_plugin_option = plugin_config_search_internal (option);
if (ptr_plugin_option)
ptr_option = plugin_config_search_internal (option);
if (ptr_option)
{
if (!value || !value[0])
{
/* remove option from list */
if (ptr_plugin_option->prev_option)
(ptr_plugin_option->prev_option)->next_option =
ptr_plugin_option->next_option;
if (ptr_option->prev_option)
(ptr_option->prev_option)->next_option =
ptr_option->next_option;
else
plugin_options = ptr_plugin_option->next_option;
if (ptr_plugin_option->next_option)
(ptr_plugin_option->next_option)->prev_option =
ptr_plugin_option->prev_option;
plugin_options = ptr_option->next_option;
if (ptr_option->next_option)
(ptr_option->next_option)->prev_option =
ptr_option->prev_option;
rc = 1;
}
else
{
/* replace old value by new one */
if (ptr_plugin_option->value)
free (ptr_plugin_option->value);
ptr_plugin_option->value = strdup (value);
if (ptr_option->value)
free (ptr_option->value);
ptr_option->value = strdup (value);
rc = 1;
}
}
@@ -163,43 +154,50 @@ plugin_config_set_internal (char *option, char *value)
{
if (value && value[0])
{
ptr_plugin_option = (struct t_plugin_option *)malloc (sizeof (struct t_plugin_option));
if (ptr_plugin_option)
ptr_option = (struct t_config_option *)malloc (sizeof (struct t_config_option));
if (ptr_option)
{
/* create new option */
ptr_plugin_option->name = strdup (option);
string_tolower (ptr_plugin_option->name);
ptr_plugin_option->value = strdup (value);
ptr_option->name = strdup (option);
string_tolower (ptr_option->name);
ptr_option->type = CONFIG_OPTION_STRING;
ptr_option->description = NULL;
ptr_option->string_values = NULL;
ptr_option->min = 0;
ptr_option->max = 0;
ptr_option->default_value = NULL;
ptr_option->value = strdup (value);
ptr_option->callback_change = NULL;
if (plugin_options)
{
pos_option = plugin_config_find_pos (ptr_plugin_option->name);
pos_option = plugin_config_find_pos (ptr_option->name);
if (pos_option)
{
/* insert option into the list (before option found) */
ptr_plugin_option->prev_option = pos_option->prev_option;
ptr_plugin_option->next_option = pos_option;
ptr_option->prev_option = pos_option->prev_option;
ptr_option->next_option = pos_option;
if (pos_option->prev_option)
pos_option->prev_option->next_option = ptr_plugin_option;
pos_option->prev_option->next_option = ptr_option;
else
plugin_options = ptr_plugin_option;
pos_option->prev_option = ptr_plugin_option;
plugin_options = ptr_option;
pos_option->prev_option = ptr_option;
}
else
{
/* add option to the end */
ptr_plugin_option->prev_option = last_plugin_option;
ptr_plugin_option->next_option = NULL;
last_plugin_option->next_option = ptr_plugin_option;
last_plugin_option = ptr_plugin_option;
ptr_option->prev_option = last_plugin_option;
ptr_option->next_option = NULL;
last_plugin_option->next_option = ptr_option;
last_plugin_option = ptr_option;
}
}
else
{
ptr_plugin_option->prev_option = NULL;
ptr_plugin_option->next_option = NULL;
plugin_options = ptr_plugin_option;
last_plugin_option = ptr_plugin_option;
ptr_option->prev_option = NULL;
ptr_option->next_option = NULL;
plugin_options = ptr_option;
last_plugin_option = ptr_option;
}
rc = 1;
}
@@ -220,19 +218,19 @@ plugin_config_set_internal (char *option, char *value)
*/
int
plugin_config_set (char *plugin_name, char *option, char *value)
plugin_config_set (char *plugin_name, char *option_name, char *value)
{
char *internal_option;
int return_code;
internal_option = (char *)malloc (strlen (plugin_name) +
strlen (option) + 2);
strlen (option_name) + 2);
if (!internal_option)
return 0;
strcpy (internal_option, plugin_name);
strcat (internal_option, ".");
strcat (internal_option, option);
strcat (internal_option, option_name);
return_code = plugin_config_set_internal (internal_option, value);
free (internal_option);
@@ -247,76 +245,67 @@ plugin_config_set (char *plugin_name, char *option, char *value)
* -2 = bad format/value
*/
int
plugin_config_read_option (struct t_config_option *options,
void
plugin_config_read_option (struct t_config_file *config_file,
char *option_name, char *value)
{
char *value2;
/* make C compiler happy */
(void) options;
(void) config_file;
if (option_name)
{
value2 = string_iconv_to_internal (NULL, value);
plugin_config_set_internal (option_name,
(value2) ? value2 : value);
if (value2)
free (value2);
}
else
{
/* does nothing for new [plugin] section */
}
value2 = string_iconv_to_internal (NULL, value);
plugin_config_set_internal (option_name,
(value2) ? value2 : value);
if (value2)
free (value2);
}
/*
* plugin_config_write_options: write plugin options in configuration file
*/
void
plugin_config_write_options (struct t_config_file *config_file)
{
struct t_config_option *ptr_option;
/* all ok */
return 0;
}
for (ptr_option = plugin_options; ptr_option;
ptr_option = ptr_option->next_option)
{
config_file_write_line (config_file,
ptr_option->name,
ptr_option->value);
}
}
/*
* plugin_config_read: read WeeChat plugins configuration file
* return: 0 = successful
* -1 = config file file not found
* -2 = error in config file
* -3 = not enough memory
*/
int
plugin_config_read ()
{
return config_file_read (plugin_config_sections, plugin_config_options,
plugin_config_read_functions,
plugin_config_read_option,
NULL,
WEECHAT_PLUGIN_CONFIG_NAME);
}
/*
* plugin_config_write_options: write plugin options in configuration file
* Return: 0 = successful
* -1 = write error
*/
int
plugin_config_write_options (FILE *file, char *section_name,
struct t_config_option *options)
{
/* make C compiler happy */
(void) options;
struct t_plugin_option *ptr_plugin_option;
string_iconv_fprintf (file, "\n[%s]\n", section_name);
for (ptr_plugin_option = plugin_options; ptr_plugin_option;
ptr_plugin_option = ptr_plugin_option->next_option)
if (!plugin_config)
{
string_iconv_fprintf (file, "%s = \"%s\"\n",
ptr_plugin_option->name,
ptr_plugin_option->value);
plugin_config = config_file_new (PLUGIN_CONFIG_FILENAME);
if (plugin_config)
{
config_file_new_section (plugin_config, "plugin",
&plugin_config_read_option,
&plugin_config_write_options,
NULL);
}
}
/* all ok */
return 0;
if (!plugin_config)
return -3;
return config_file_read (plugin_config);
}
/*
@@ -329,7 +318,5 @@ int
plugin_config_write ()
{
log_printf (_("Saving plugins configuration to disk\n"));
return config_file_write (plugin_config_sections, plugin_config_options,
plugin_config_write_functions,
WEECHAT_PLUGIN_CONFIG_NAME);
return config_file_write (plugin_config, 0);
}
+5 -17
View File
@@ -20,28 +20,16 @@
#ifndef __WEECHAT_PLUGIN_CONFIG_H
#define __WEECHAT_PLUGIN_CONFIG_H 1
#include "../core/wee-config-option.h"
#define PLUGIN_CONFIG_FILENAME "plugins.rc"
#define WEECHAT_PLUGIN_CONFIG_NAME "plugins.rc"
extern struct t_config_file *plugin_config;
extern struct t_config_option *plugin_options;
struct t_plugin_option
{
char *name; /* option name in config file */
char *value; /* value of option */
struct t_plugin_option *prev_option; /* link to previous option */
struct t_plugin_option *next_option; /* link to next option */
};
extern struct t_plugin_option *plugin_options;
extern struct t_plugin_option *plugin_config_search_internal (char *);
extern struct t_plugin_option *plugin_config_search (char *, char *);
extern struct t_config_option *plugin_config_search_internal (char *);
extern struct t_config_option *plugin_config_search (char *, char *);
extern int plugin_config_set_internal (char *, char *);
extern int plugin_config_set (char *, char *, char *);
extern int plugin_config_read_option (struct t_config_option *, char *, char *);
extern int plugin_config_read ();
extern int plugin_config_write_options (FILE *, char *,
struct t_config_option *);
extern int plugin_config_write ();
#endif /* plugin-config.h */
+1 -1
View File
@@ -588,7 +588,7 @@ plugin_list_print_log ()
switch (ptr_var->type)
{
case PLUGIN_LIST_VAR_INTEGER:
log_printf (" value (int). . . . . : %d\n", *((int *)ptr_var->value));
log_printf (" value (integer). . . : %d\n", *((int *)ptr_var->value));
break;
case PLUGIN_LIST_VAR_STRING:
log_printf (" value (string) . . . : '%s'\n", (char *)ptr_var->value);
+16 -10
View File
@@ -338,12 +338,14 @@ plugin_auto_load_file (struct t_weechat_plugin *plugin, char *filename)
/* make C compiler happy */
(void) plugin;
if (cfg_plugins_extension && cfg_plugins_extension[0])
if (CONFIG_STRING(config_plugins_extension)
&& CONFIG_STRING(config_plugins_extension)[0])
{
pos = strstr (filename, cfg_plugins_extension);
pos = strstr (filename, CONFIG_STRING(config_plugins_extension));
if (pos)
{
if (string_strcasecmp (pos, cfg_plugins_extension) == 0)
if (string_strcasecmp (pos,
CONFIG_STRING(config_plugins_extension)) == 0)
plugin_load (filename);
}
}
@@ -362,22 +364,26 @@ plugin_auto_load ()
char *ptr_home, *dir_name, *plugins_path, *plugins_path2;
char *list_plugins, *pos, *pos2;
if (cfg_plugins_autoload && cfg_plugins_autoload[0])
if (CONFIG_STRING(config_plugins_autoload)
&& CONFIG_STRING(config_plugins_autoload)[0])
{
if (string_strcasecmp (cfg_plugins_autoload, "*") == 0)
if (string_strcasecmp (CONFIG_STRING(config_plugins_autoload),
"*") == 0)
{
/* auto-load plugins in WeeChat home dir */
if (cfg_plugins_path && cfg_plugins_path[0])
if (CONFIG_STRING(config_plugins_path)
&& CONFIG_STRING(config_plugins_path)[0])
{
ptr_home = getenv ("HOME");
plugins_path = string_replace (cfg_plugins_path, "~", ptr_home);
plugins_path = string_replace (CONFIG_STRING(config_plugins_path),
"~", ptr_home);
plugins_path2 = string_replace ((plugins_path) ?
plugins_path : cfg_plugins_path,
plugins_path : CONFIG_STRING(config_plugins_path),
"%h", weechat_home);
plugin_exec_on_files (NULL,
(plugins_path2) ?
plugins_path2 : ((plugins_path) ?
plugins_path : cfg_plugins_path),
plugins_path : CONFIG_STRING(config_plugins_path)),
&plugin_auto_load_file);
if (plugins_path)
free (plugins_path);
@@ -397,7 +403,7 @@ plugin_auto_load ()
}
else
{
list_plugins = strdup (cfg_plugins_autoload);
list_plugins = strdup (CONFIG_STRING(config_plugins_autoload));
if (list_plugins)
{
pos = list_plugins;