Added setting for ignoring some chars when completing nicks

This commit is contained in:
Sebastien Helleu 2005-10-28 13:07:32 +00:00
parent e26772dcdb
commit ee4f5716d3
24 changed files with 2234 additions and 2024 deletions

View File

@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2005-10-27
ChangeLog - 2005-10-28
Version 0.1.6 (under dev!):
* added setting for ignoring some chars when completing nicks
* fixed IRC message parser bug
* signal SIGPIPE is now ignored
* added partial match for highlights

View File

@ -316,6 +316,9 @@ Type: boolean (values: 'on' or 'off'), default value: 'off'@*
@item look_nick_completor
The string inserted after nick completion@*
Type: string (any string), default value: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: string (any string), default value: '[]-'@*
@item look_infobar
Enable info bar@*
Type: boolean (values: 'on' or 'off'), default value: 'on'@*

View File

@ -316,6 +316,9 @@ Type: boolean (values: 'on' or 'off'), default value: 'off'@*
@item look_nick_completor
The string inserted after nick completion@*
Type: string (any string), default value: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: string (any string), default value: '[]-'@*
@item look_infobar
Enable info bar@*
Type: boolean (values: 'on' or 'off'), default value: 'on'@*

View File

@ -317,6 +317,9 @@ Type: bool@'een (valeurs: 'on' ou 'off'), valeur par d@'efaut: 'off'@*
@item look_nick_completor
La cha@^ine affich@'ee apr@`es la compl@'etion des utilisateurs@*
Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '[]-'@*
@item look_infobar
Active la barre d'infos@*
Type: bool@'een (valeurs: 'on' ou 'off'), valeur par d@'efaut: 'on'@*

View File

@ -314,6 +314,9 @@ Type: boolean (values: 'on' or 'off'), default value: 'off'@*
@item look_nick_completor
The string inserted after nick completion@*
Type: string (any string), default value: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: string (any string), default value: '[]-'@*
@item look_infobar
Enable info bar@*
Type: boolean (values: 'on' or 'off'), default value: 'on'@*

508
po/cs.po

File diff suppressed because it is too large Load Diff

508
po/es.po

File diff suppressed because it is too large Load Diff

510
po/fr.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -903,6 +903,75 @@ completion_command_arg (t_completion *completion, t_irc_channel *channel)
}
}
/*
* completion_is_only_alphanum: return 1 if there is only alpha/num chars
* in a string
*/
int
completion_is_only_alphanum (char *string)
{
while (string[0])
{
if (strchr (cfg_look_nick_completion_ignore, string[0]))
return 0;
string++;
}
return 1;
}
/*
* completion_strdup_alphanum: duplicate alpha/num chars in a string
*/
char *
completion_strdup_alphanum (char *string)
{
char *result, *pos;
result = (char *)malloc (strlen (string) + 1);
pos = result;
while (string[0])
{
if (!strchr (cfg_look_nick_completion_ignore, string[0]))
{
pos[0] = string[0];
pos++;
}
string++;
}
pos[0] = '\0';
return result;
}
/*
* completion_nickncmp: locale and case independent string comparison
* with max length for nicks (alpha or digits only)
*/
int
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]
|| !base_word || !nick || !base_word[0] || !nick[0]
|| (!completion_is_only_alphanum (base_word)))
return ascii_strncasecmp (base_word, nick, max);
base_word2 = completion_strdup_alphanum (base_word);
nick2 = completion_strdup_alphanum (nick);
return_cmp = ascii_strncasecmp (base_word2, nick2, strlen (base_word2));
free (base_word2);
free (nick2);
return return_cmp;
}
/*
* completion_nick: complete a nick
*/
@ -927,7 +996,7 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
other_completion = 0;
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
if (ascii_strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
if (completion_nickncmp (completion->base_word, ptr_nick->nick, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
@ -935,8 +1004,9 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
ptr_nick2 = ptr_nick2->next_nick)
{
if (ascii_strncasecmp (ptr_nick2->nick,
completion->base_word, length) == 0)
if (completion_nickncmp (completion->base_word,
ptr_nick2->nick,
length) == 0)
other_completion++;
}
if (other_completion == 0)

View File

@ -87,6 +87,7 @@ int cfg_look_nickmode;
int cfg_look_nickmode_empty;
char *cfg_look_no_nickname;
char *cfg_look_completor;
char *cfg_look_nick_completion_ignore;
int cfg_look_infobar;
char *cfg_look_infobar_timestamp;
int cfg_look_infobar_seconds;
@ -186,6 +187,10 @@ t_config_option weechat_options_look[] =
N_("the string inserted after nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
":", NULL, NULL, &cfg_look_completor, config_change_noop },
{ "look_nick_completion_ignore", N_("chars ignored for nick completion"),
N_("chars ignored for nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
"[]-", NULL, NULL, &cfg_look_nick_completion_ignore, config_change_noop },
{ "look_infobar", N_("enable info bar"),
N_("enable info bar"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,

View File

@ -100,6 +100,7 @@ extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern char *cfg_look_nick_completion_ignore;
extern int cfg_look_infobar;
extern char *cfg_look_infobar_timestamp;
extern int cfg_look_infobar_seconds;

View File

@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2005-10-27
ChangeLog - 2005-10-28
Version 0.1.6 (under dev!):
* added setting for ignoring some chars when completing nicks
* fixed IRC message parser bug
* signal SIGPIPE is now ignored
* added partial match for highlights

View File

@ -316,6 +316,9 @@ Type: boolean (values: 'on' or 'off'), default value: 'off'@*
@item look_nick_completor
The string inserted after nick completion@*
Type: string (any string), default value: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: string (any string), default value: '[]-'@*
@item look_infobar
Enable info bar@*
Type: boolean (values: 'on' or 'off'), default value: 'on'@*

View File

@ -316,6 +316,9 @@ Type: boolean (values: 'on' or 'off'), default value: 'off'@*
@item look_nick_completor
The string inserted after nick completion@*
Type: string (any string), default value: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: string (any string), default value: '[]-'@*
@item look_infobar
Enable info bar@*
Type: boolean (values: 'on' or 'off'), default value: 'on'@*

View File

@ -317,6 +317,9 @@ Type: bool@'een (valeurs: 'on' ou 'off'), valeur par d@'efaut: 'off'@*
@item look_nick_completor
La cha@^ine affich@'ee apr@`es la compl@'etion des utilisateurs@*
Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: cha@^ine (toute cha@^ine), valeur par d@'efaut: '[]-'@*
@item look_infobar
Active la barre d'infos@*
Type: bool@'een (valeurs: 'on' ou 'off'), valeur par d@'efaut: 'on'@*

View File

@ -314,6 +314,9 @@ Type: boolean (values: 'on' or 'off'), default value: 'off'@*
@item look_nick_completor
The string inserted after nick completion@*
Type: string (any string), default value: ':'@*
@item look_nick_completion_ignore
Chars ignored for nick completion@*
Type: string (any string), default value: '[]-'@*
@item look_infobar
Enable info bar@*
Type: boolean (values: 'on' or 'off'), default value: 'on'@*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -903,6 +903,75 @@ completion_command_arg (t_completion *completion, t_irc_channel *channel)
}
}
/*
* completion_is_only_alphanum: return 1 if there is only alpha/num chars
* in a string
*/
int
completion_is_only_alphanum (char *string)
{
while (string[0])
{
if (strchr (cfg_look_nick_completion_ignore, string[0]))
return 0;
string++;
}
return 1;
}
/*
* completion_strdup_alphanum: duplicate alpha/num chars in a string
*/
char *
completion_strdup_alphanum (char *string)
{
char *result, *pos;
result = (char *)malloc (strlen (string) + 1);
pos = result;
while (string[0])
{
if (!strchr (cfg_look_nick_completion_ignore, string[0]))
{
pos[0] = string[0];
pos++;
}
string++;
}
pos[0] = '\0';
return result;
}
/*
* completion_nickncmp: locale and case independent string comparison
* with max length for nicks (alpha or digits only)
*/
int
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]
|| !base_word || !nick || !base_word[0] || !nick[0]
|| (!completion_is_only_alphanum (base_word)))
return ascii_strncasecmp (base_word, nick, max);
base_word2 = completion_strdup_alphanum (base_word);
nick2 = completion_strdup_alphanum (nick);
return_cmp = ascii_strncasecmp (base_word2, nick2, strlen (base_word2));
free (base_word2);
free (nick2);
return return_cmp;
}
/*
* completion_nick: complete a nick
*/
@ -927,7 +996,7 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
other_completion = 0;
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
if (ascii_strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
if (completion_nickncmp (completion->base_word, ptr_nick->nick, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
@ -935,8 +1004,9 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
ptr_nick2 = ptr_nick2->next_nick)
{
if (ascii_strncasecmp (ptr_nick2->nick,
completion->base_word, length) == 0)
if (completion_nickncmp (completion->base_word,
ptr_nick2->nick,
length) == 0)
other_completion++;
}
if (other_completion == 0)

View File

@ -87,6 +87,7 @@ int cfg_look_nickmode;
int cfg_look_nickmode_empty;
char *cfg_look_no_nickname;
char *cfg_look_completor;
char *cfg_look_nick_completion_ignore;
int cfg_look_infobar;
char *cfg_look_infobar_timestamp;
int cfg_look_infobar_seconds;
@ -186,6 +187,10 @@ t_config_option weechat_options_look[] =
N_("the string inserted after nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
":", NULL, NULL, &cfg_look_completor, config_change_noop },
{ "look_nick_completion_ignore", N_("chars ignored for nick completion"),
N_("chars ignored for nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
"[]-", NULL, NULL, &cfg_look_nick_completion_ignore, config_change_noop },
{ "look_infobar", N_("enable info bar"),
N_("enable info bar"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,

View File

@ -100,6 +100,7 @@ extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern char *cfg_look_nick_completion_ignore;
extern int cfg_look_infobar;
extern char *cfg_look_infobar_timestamp;
extern int cfg_look_infobar_seconds;