101 |
*/ |
*/ |
102 |
|
|
103 |
void |
void |
104 |
completion_build_list (t_completion *completion, void *channel) |
completion_build_list (t_completion *completion, void *server, void *channel) |
105 |
{ |
{ |
106 |
t_weelist *ptr_list; |
t_weelist *ptr_list; |
107 |
int i, j; |
int i, j, length; |
108 |
t_irc_server *ptr_server; |
t_irc_server *ptr_server; |
109 |
t_irc_channel *ptr_channel; |
t_irc_channel *ptr_channel; |
110 |
t_irc_nick *ptr_nick; |
t_irc_nick *ptr_nick; |
155 |
"notify"); |
"notify"); |
156 |
return; |
return; |
157 |
} |
} |
158 |
|
if (ascii_strcasecmp (completion->base_command, "charset") == 0) |
159 |
|
{ |
160 |
|
if (completion->base_command_arg == 1) |
161 |
|
{ |
162 |
|
weelist_add (&completion->completion_list, |
163 |
|
&completion->last_completion, |
164 |
|
"decode_iso"); |
165 |
|
weelist_add (&completion->completion_list, |
166 |
|
&completion->last_completion, |
167 |
|
"decode_utf"); |
168 |
|
weelist_add (&completion->completion_list, |
169 |
|
&completion->last_completion, |
170 |
|
"encode"); |
171 |
|
} |
172 |
|
else if (completion->base_command_arg == 2) |
173 |
|
{ |
174 |
|
if (!server) |
175 |
|
{ |
176 |
|
completion_stop (completion); |
177 |
|
return; |
178 |
|
} |
179 |
|
pos = strchr (completion->args, ' '); |
180 |
|
if (pos) |
181 |
|
pos[0] = '\0'; |
182 |
|
string2 = NULL; |
183 |
|
if (ascii_strcasecmp (completion->args, "decode_iso") == 0) |
184 |
|
{ |
185 |
|
config_option_list_get_value (&(((t_irc_server *)server)->charset_decode_iso), |
186 |
|
(channel) ? ((t_irc_channel *)channel)->name : "server", |
187 |
|
&string, &length); |
188 |
|
if (string && (length > 0)) |
189 |
|
{ |
190 |
|
string2 = strdup (string); |
191 |
|
string2[length] = '\0'; |
192 |
|
} |
193 |
|
} |
194 |
|
else if (ascii_strcasecmp (completion->args, "decode_utf") == 0) |
195 |
|
{ |
196 |
|
config_option_list_get_value (&(((t_irc_server *)server)->charset_decode_utf), |
197 |
|
(channel) ? ((t_irc_channel *)channel)->name : "server", |
198 |
|
&string, &length); |
199 |
|
if (string && (length > 0)) |
200 |
|
{ |
201 |
|
string2 = strdup (string); |
202 |
|
string2[length] = '\0'; |
203 |
|
} |
204 |
|
} |
205 |
|
else if (ascii_strcasecmp (completion->args, "encode") == 0) |
206 |
|
{ |
207 |
|
config_option_list_get_value (&(((t_irc_server *)server)->charset_encode), |
208 |
|
(channel) ? ((t_irc_channel *)channel)->name : "server", |
209 |
|
&string, &length); |
210 |
|
if (string && (length > 0)) |
211 |
|
{ |
212 |
|
string2 = strdup (string); |
213 |
|
string2[length] = '\0'; |
214 |
|
} |
215 |
|
} |
216 |
|
|
217 |
|
if (string2) |
218 |
|
{ |
219 |
|
weelist_add (&completion->completion_list, |
220 |
|
&completion->last_completion, |
221 |
|
string2); |
222 |
|
free (string2); |
223 |
|
} |
224 |
|
else |
225 |
|
completion_stop (completion); |
226 |
|
|
227 |
|
if (pos) |
228 |
|
pos[0] = ' '; |
229 |
|
} |
230 |
|
else |
231 |
|
completion_stop (completion); |
232 |
|
return; |
233 |
|
} |
234 |
if ((ascii_strcasecmp (completion->base_command, "clear") == 0) |
if ((ascii_strcasecmp (completion->base_command, "clear") == 0) |
235 |
&& (completion->base_command_arg == 1)) |
&& (completion->base_command_arg == 1)) |
236 |
{ |
{ |
748 |
string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)channel)->topic); |
string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)channel)->topic); |
749 |
else |
else |
750 |
string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)channel)->topic, 0); |
string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)channel)->topic, 0); |
751 |
string2 = weechat_convert_encoding ((local_utf8) ? |
string2 = channel_iconv_decode ((t_irc_server *)server, |
752 |
cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, |
(t_irc_channel *)channel, |
753 |
(cfg_look_charset_internal && cfg_look_charset_internal[0]) ? |
(string) ? string : ((t_irc_channel *)channel)->topic); |
|
cfg_look_charset_internal : local_charset, |
|
|
(string) ? string : ((t_irc_channel *)channel)->topic); |
|
754 |
weelist_add (&completion->completion_list, |
weelist_add (&completion->completion_list, |
755 |
&completion->last_completion, |
&completion->last_completion, |
756 |
(string2) ? string2 : ((t_irc_channel *)channel)->topic); |
(string2) ? string2 : ((t_irc_channel *)channel)->topic); |
771 |
*/ |
*/ |
772 |
|
|
773 |
void |
void |
774 |
completion_find_context (t_completion *completion, void *channel, char *buffer, |
completion_find_context (t_completion *completion, void *server, void *channel, |
775 |
int size, int pos) |
char *buffer, int size, int pos) |
776 |
{ |
{ |
777 |
int i, command, command_arg, pos_start, pos_end; |
int i, command, command_arg, pos_start, pos_end; |
778 |
|
|
882 |
for (i = pos_start; i <= pos_end; i++) |
for (i = pos_start; i <= pos_end; i++) |
883 |
completion->base_command[i - pos_start] = buffer[i]; |
completion->base_command[i - pos_start] = buffer[i]; |
884 |
completion->base_command[pos_end - pos_start + 1] = '\0'; |
completion->base_command[pos_end - pos_start + 1] = '\0'; |
885 |
completion_build_list (completion, channel); |
completion_build_list (completion, server, channel); |
886 |
} |
} |
887 |
} |
} |
888 |
|
|
1140 |
*/ |
*/ |
1141 |
|
|
1142 |
void |
void |
1143 |
completion_search (t_completion *completion, void *channel, |
completion_search (t_completion *completion, void *server, void *channel, |
1144 |
char *buffer, int size, int pos) |
char *buffer, int size, int pos) |
1145 |
{ |
{ |
1146 |
char *old_word_found; |
char *old_word_found; |
1149 |
if (pos != completion->position) |
if (pos != completion->position) |
1150 |
{ |
{ |
1151 |
completion->word_found = NULL; |
completion->word_found = NULL; |
1152 |
completion_find_context (completion, channel, buffer, size, pos); |
completion_find_context (completion, server, channel, buffer, size, pos); |
1153 |
} |
} |
1154 |
|
|
1155 |
/* completion */ |
/* completion */ |