summaryrefslogtreecommitdiff
path: root/src/core/wee-config.c
blob: 4a8f07d965572d492b73913503a0df2639fde041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
/*
 * 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.c: WeeChat configuration 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 <sys/types.h>
#include <sys/stat.h>

#include "weechat.h"
#include "wee-config.h"
#include "wee-alias.h"
#include "wee-command.h"
#include "wee-config-file.h"
#include "wee-list.h"
#include "wee-log.h"
#include "wee-string.h"
#include "wee-util.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-keyboard.h"
#include "../gui/gui-status.h"
#include "../gui/gui-window.h"


/* config, look & feel section */

int cfg_look_color_real_white;
int cfg_look_save_on_exit;
int cfg_look_set_title;
int cfg_look_startup_logo;
int cfg_look_startup_version;
char *cfg_look_weechat_slogan;
int cfg_look_scroll_amount;
char *cfg_look_buffer_time_format;
int cfg_look_color_nicks_number;
int cfg_look_color_actions;
int cfg_look_nicklist;
int cfg_look_nicklist_position;
char *cfg_look_nicklist_position_values[] =
{ "left", "right", "top", "bottom", NULL };
int cfg_look_nicklist_min_size;
int cfg_look_nicklist_max_size;
int cfg_look_nicklist_separator;
int cfg_look_nickmode;
int cfg_look_nickmode_empty;
char *cfg_look_no_nickname;
char *cfg_look_prefix[GUI_CHAT_PREFIX_NUMBER];
int cfg_look_prefix_align;
char *cfg_look_prefix_align_values[] =
{ "none", "left", "right", NULL };
int cfg_look_prefix_align_max;
char *cfg_look_prefix_suffix;
int cfg_look_align_text_offset;
char *cfg_look_nick_completor;
char *cfg_look_nick_completion_ignore;
int cfg_look_nick_completion_smart;
int cfg_look_nick_complete_first;
int cfg_look_infobar;
char *cfg_look_infobar_time_format;
int cfg_look_infobar_seconds;
int cfg_look_infobar_delay_highlight;
int cfg_look_hotlist_names_count;
int cfg_look_hotlist_names_level;
int cfg_look_hotlist_names_length;
int cfg_look_hotlist_sort;
char *cfg_look_hotlist_sort_values[] =
{ "group_time_asc", "group_time_desc",
  "group_number_asc", "group_number_desc",
  "number_asc", "number_desc" };
int cfg_look_day_change;
char *cfg_look_day_change_time_format;
char *cfg_look_read_marker;
char *cfg_look_input_format;
int cfg_look_paste_max_lines;

struct t_config_option weechat_options_look[] =
{ { "look_color_real_white",
    N_("if set, uses real white color, disabled by default for terms with "
       "white background (if you never use white background, you should turn "
       "on this option to see real white instead of default term foreground "
       "color)"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
    &cfg_look_color_real_white, NULL, weechat_config_change_color },
    { "look_save_on_exit",
    N_("save configuration file on exit"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_save_on_exit, NULL, weechat_config_change_save_on_exit },
  { "look_set_title",
    N_("set title for window (terminal for Curses GUI) with name and version"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_set_title, NULL, weechat_config_change_title },
  { "look_startup_logo",
    N_("display WeeChat logo at startup"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_startup_logo, NULL, weechat_config_change_noop },
  { "look_startup_version",
    N_("display WeeChat version at startup"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_startup_version, NULL, weechat_config_change_noop },
  { "look_weechat_slogan",
    N_("WeeChat slogan (if empty, slogan is not used)"),
    OPTION_TYPE_STRING, 0, 0, 0, "the geekest IRC client!", NULL,
    NULL, &cfg_look_weechat_slogan, weechat_config_change_noop },
  { "look_scroll_amount",
    N_("how many lines to scroll by with scroll_up and scroll_down"),
    OPTION_TYPE_INT, 1, INT_MAX, 3, NULL, NULL,
    &cfg_look_scroll_amount, NULL, weechat_config_change_buffer_content },
  { "look_buffer_time_format",
    N_("time format for buffers"),
    OPTION_TYPE_STRING, 0, 0, 0, "[%H:%M:%S]", NULL,
    NULL, &cfg_look_buffer_time_format, weechat_config_change_buffer_time_format },
  { "look_color_nicks_number",
    N_("number of colors to use for nicks colors"),
    OPTION_TYPE_INT, 1, 10, 10, NULL, NULL,
    &cfg_look_color_nicks_number, NULL, weechat_config_change_nicks_colors },
  { "look_color_actions",
    N_("display actions with different colors"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_color_actions, NULL, weechat_config_change_noop },
  { "look_nicklist",
    N_("display nicklist window (for channel windows)"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_nicklist, NULL, weechat_config_change_buffers },
  { "look_nicklist_position",
    N_("nicklist position (top, left, right (default), bottom)"),
    OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "right", cfg_look_nicklist_position_values,
    &cfg_look_nicklist_position, NULL, weechat_config_change_buffers },
  { "look_nicklist_min_size",
    N_("min size for nicklist (width or height, depending on look_nicklist_position "
       "(0 = no min size))"),
    OPTION_TYPE_INT, 0, 100, 0, NULL, NULL,
    &cfg_look_nicklist_min_size, NULL, weechat_config_change_buffers },
  { "look_nicklist_max_size",
    N_("max size for nicklist (width or height, depending on look_nicklist_position "
       "(0 = no max size; if min = max and > 0, then size is fixed))"),
    OPTION_TYPE_INT, 0, 100, 0, NULL, NULL,
    &cfg_look_nicklist_max_size, NULL, weechat_config_change_buffers },
  { "look_nicklist_separator",
    N_("separator between chat and nicklist"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_nicklist_separator, NULL, weechat_config_change_buffers },
  { "look_no_nickname",
    N_("text to display instead of nick when not connected"),
    OPTION_TYPE_STRING, 0, 0, 0, "-cmd-", NULL,
    NULL, &cfg_look_no_nickname, weechat_config_change_buffer_content },
  { "look_nickmode",
    N_("display nick mode ((half)op/voice) before each nick"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_nickmode, NULL, weechat_config_change_buffers },
  { "look_nickmode_empty",
    N_("display space if nick mode is not (half)op/voice"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
    &cfg_look_nickmode_empty, NULL, weechat_config_change_buffers },
  { "look_prefix_info",
    N_("prefix for info messages"),
    OPTION_TYPE_STRING, 0, 0, 0, "-=-", NULL,
    NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_INFO], weechat_config_change_prefix },
  { "look_prefix_error",
    N_("prefix for error messages"),
    OPTION_TYPE_STRING, 0, 0, 0, "=!=", NULL,
    NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_ERROR], weechat_config_change_prefix },
  { "look_prefix_network",
    N_("prefix for network messages"),
    OPTION_TYPE_STRING, 0, 0, 0, "-@-", NULL,
    NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_NETWORK], weechat_config_change_prefix },
  { "look_prefix_action",
    N_("prefix for action messages"),
    OPTION_TYPE_STRING, 0, 0, 0, "-*-", NULL,
    NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_ACTION], weechat_config_change_prefix },
  { "look_prefix_join",
    N_("prefix for join messages"),
    OPTION_TYPE_STRING, 0, 0, 0, "-->", NULL,
    NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_JOIN], weechat_config_change_prefix },
  { "look_prefix_quit",
    N_("prefix for quit messages"),
    OPTION_TYPE_STRING, 0, 0, 0, "<--", NULL,
    NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_QUIT], weechat_config_change_prefix },
  { "look_prefix_align",
    N_("prefix alignment (none, left, right))"),
    OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "right", cfg_look_prefix_align_values,
    &cfg_look_prefix_align, NULL, weechat_config_change_buffers },
  { "look_prefix_align_max",
    N_("max size for prefix (0 = no max size)"),
    OPTION_TYPE_INT, 0, 64, 0, NULL, NULL,
    &cfg_look_prefix_align_max, NULL, weechat_config_change_buffers },
  { "look_prefix_suffix",
    N_("string displayed after prefix"),
    OPTION_TYPE_STRING, 0, 0, 0, "|", NULL,
    NULL, &cfg_look_prefix_suffix, weechat_config_change_buffers },
  { "look_align_text_offset",
    N_("offset for aligning lines of messages (except first lines), default "
       "is -1 (align after prefix), a null or positive value is offset after "
       "beginning of line"),
    OPTION_TYPE_INT, -1, 64, -1, NULL, NULL,
    &cfg_look_align_text_offset, NULL, weechat_config_change_buffers },
  { "look_nick_completor",
    N_("the string inserted after nick completion"),
    OPTION_TYPE_STRING, 0, 0, 0, ":", NULL,
    NULL, &cfg_look_nick_completor, weechat_config_change_noop },
  { "look_nick_completion_ignore",
    N_("chars ignored for nick completion"),
    OPTION_TYPE_STRING, 0, 0, 0, "[]-^", NULL,
    NULL, &cfg_look_nick_completion_ignore, weechat_config_change_noop },
  { "look_nick_completion_smart",
    N_("smart completion for nicks (completes with last speakers first)"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_nick_completion_smart, NULL, weechat_config_change_noop },
  { "look_nick_complete_first",
    N_("complete only with first nick found"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
    &cfg_look_nick_complete_first, NULL, weechat_config_change_noop },
  { "look_infobar",
    N_("enable info bar"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_infobar, NULL, weechat_config_change_buffers },
  { "look_infobar_time_format",
    N_("time format for time in infobar"),
    OPTION_TYPE_STRING, 0, 0, 0, "%B, %A %d %Y", NULL,
    NULL, &cfg_look_infobar_time_format, weechat_config_change_buffer_content },
  { "look_infobar_seconds",
    N_("display seconds in infobar time"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_infobar_seconds, NULL, weechat_config_change_buffer_content },
  { "look_infobar_delay_highlight",
    N_("delay (in seconds) for highlight messages in infobar "
       "(0 = disable highlight notifications in infobar)"),
    OPTION_TYPE_INT, 0, INT_MAX, 7, NULL, NULL,
    &cfg_look_infobar_delay_highlight, NULL, weechat_config_change_noop },
  { "look_hotlist_names_count",
    N_("max number of names in hotlist (0 = no name displayed, only buffer numbers)"),
    OPTION_TYPE_INT, 0, 32, 3, NULL, NULL,
    &cfg_look_hotlist_names_count, NULL, weechat_config_change_buffer_content },
  { "look_hotlist_names_level",
    N_("level for displaying names in hotlist (combination of: 1=join/part, "
       "2=message, 4=private, 8=highlight, for example: 12=private+highlight)"),
    OPTION_TYPE_INT, 1, 15, 12, NULL, NULL,
    &cfg_look_hotlist_names_level, NULL, weechat_config_change_buffer_content },
  { "look_hotlist_names_length",
    N_("max length of names in hotlist (0 = no limit)"),
    OPTION_TYPE_INT, 0, 32, 0, NULL, NULL,
    &cfg_look_hotlist_names_length, NULL, weechat_config_change_buffer_content },
  { "look_hotlist_sort",
    N_("hotlist sort type (group_time_asc (default), group_time_desc, "
       "group_number_asc, group_number_desc, number_asc, number_desc)"),
    OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "group_time_asc", cfg_look_hotlist_sort_values,
    &cfg_look_hotlist_sort, NULL, weechat_config_change_hotlist },
  { "look_day_change",
    N_("display special message when day changes"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
    &cfg_look_day_change, NULL, weechat_config_change_noop },
  { "look_day_change_time_format",
    N_("time format for date displayed when day changed"),
    OPTION_TYPE_STRING, 0, 0, 0, "%a, %d %b %Y", NULL,
    NULL, &cfg_look_day_change_time_format, weechat_config_change_noop },
  { "look_read_marker",
    N_("use a marker on servers/channels to show first unread line"),
    OPTION_TYPE_STRING, 0, 1, 0, " ", NULL,
    NULL, &cfg_look_read_marker, weechat_config_change_read_marker },
  { "look_input_format",
    N_("format for input prompt ('%c' is replaced by channel or server, "
       "'%n' by nick and '%m' by nick modes)"),
    OPTION_TYPE_STRING, 0, 0, 0, "[%n(%m)] ", NULL,
    NULL, &cfg_look_input_format, weechat_config_change_buffer_content },
  { "look_paste_max_lines",
    N_("max number of lines for paste without asking user (0 = disable this feature)"),
    OPTION_TYPE_INT, 0, INT_MAX, 3, NULL, NULL,
    &cfg_look_paste_max_lines, NULL, weechat_config_change_noop },
  { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};

/* config, colors section */

int cfg_col_separator;
int cfg_col_title;
int cfg_col_title_bg;
int cfg_col_title_more;
int cfg_col_chat;
int cfg_col_chat_bg;
int cfg_col_chat_time;
int cfg_col_chat_time_delimiters;
int cfg_col_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
int cfg_col_chat_prefix_more;
int cfg_col_chat_prefix_suffix;
int cfg_col_chat_buffer;
int cfg_col_chat_server;
int cfg_col_chat_channel;
int cfg_col_chat_nick;
int cfg_col_chat_nick_self;
int cfg_col_chat_nick_other;
int cfg_col_chat_nick_colors[GUI_COLOR_NICK_NUMBER];
int cfg_col_chat_host;
int cfg_col_chat_delimiters;
int cfg_col_chat_highlight;
int cfg_col_chat_read_marker;
int cfg_col_chat_read_marker_bg;
int cfg_col_status;
int cfg_col_status_bg;
int cfg_col_status_delimiters;
int cfg_col_status_channel;
int cfg_col_status_data_msg;
int cfg_col_status_data_private;
int cfg_col_status_data_highlight;
int cfg_col_status_data_other;
int cfg_col_status_more;
int cfg_col_infobar;
int cfg_col_infobar_bg;
int cfg_col_infobar_delimiters;
int cfg_col_infobar_highlight;
int cfg_col_infobar_bg;
int cfg_col_input;
int cfg_col_input_bg;
int cfg_col_input_server;
int cfg_col_input_channel;
int cfg_col_input_nick;
int cfg_col_input_delimiters;
int cfg_col_input_text_not_found;
int cfg_col_input_actions;
int cfg_col_nicklist;
int cfg_col_nicklist_bg;
int cfg_col_nicklist_away;
int cfg_col_nicklist_prefix1;
int cfg_col_nicklist_prefix2;
int cfg_col_nicklist_prefix3;
int cfg_col_nicklist_prefix4;
int cfg_col_nicklist_prefix5;
int cfg_col_nicklist_more;
int cfg_col_nicklist_separator;
int cfg_col_info;
int cfg_col_info_bg;
int cfg_col_info_waiting;
int cfg_col_info_connecting;
int cfg_col_info_active;
int cfg_col_info_done;
int cfg_col_info_failed;
int cfg_col_info_aborted;

struct t_config_option weechat_options_colors[] =
{ /* general color settings */
  { "col_separator",
    N_("color for window separators (when splited)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_SEPARATOR, "blue", NULL,
    &cfg_col_separator, NULL, weechat_config_change_color },
  
  /* title window */
  { "col_title",
    N_("color for title bar"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_TITLE, "default", NULL,
    &cfg_col_title, NULL, weechat_config_change_color },
  { "col_title_bg",
    N_("background color for title bar"),
    OPTION_TYPE_COLOR, 0, 0, -1, "blue", NULL,
    &cfg_col_title_bg, NULL, weechat_config_change_color },
  { "col_title_more",
    N_("color for '+' when scrolling title"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_TITLE_MORE, "lightmagenta", NULL,
    &cfg_col_title_more, NULL, weechat_config_change_color },
  
  /* chat window */
  { "col_chat",
    N_("color for chat text"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT, "default", NULL,
    &cfg_col_chat, NULL, weechat_config_change_color },
  { "col_chat_bg",
    N_("background for chat text"),
    OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
    &cfg_col_chat_bg, NULL, weechat_config_change_color },
  { "col_chat_time",
    N_("color for time in chat window"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_TIME, "default", NULL,
    &cfg_col_chat_time, NULL, weechat_config_change_color },
  { "col_chat_time_delimiters",
    N_("color for time delimiters)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_TIME_DELIMITERS, "brown", NULL,
    &cfg_col_chat_time_delimiters, NULL, weechat_config_change_color },
  { "col_chat_prefix_info",
    N_("color for info prefix"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_INFO, "lightcyan", NULL,
    &cfg_col_chat_prefix[GUI_CHAT_PREFIX_INFO], NULL, weechat_config_change_color },
  { "col_chat_prefix_error",
    N_("color for error prefix"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_ERROR, "yellow", NULL,
    &cfg_col_chat_prefix[GUI_CHAT_PREFIX_ERROR], NULL, weechat_config_change_color },
  { "col_chat_prefix_network",
    N_("color for network prefix"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_NETWORK, "lightmagenta", NULL,
    &cfg_col_chat_prefix[GUI_CHAT_PREFIX_NETWORK], NULL, weechat_config_change_color },
  { "col_chat_prefix_action",
    N_("color for action prefix"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_ACTION, "white", NULL,
    &cfg_col_chat_prefix[GUI_CHAT_PREFIX_ACTION], NULL, weechat_config_change_color },
  { "col_chat_prefix_join",
    N_("color for join prefix"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_JOIN, "lightgreen", NULL,
    &cfg_col_chat_prefix[GUI_CHAT_PREFIX_JOIN], NULL, weechat_config_change_color },
  { "col_chat_prefix_quit",
    N_("color for quit prefix"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_QUIT, "lightred", NULL,
    &cfg_col_chat_prefix[GUI_CHAT_PREFIX_QUIT], NULL, weechat_config_change_color },
  { "col_chat_prefix_more",
    N_("color for '+' when prefix is too long"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_MORE, "lightmagenta", NULL,
    &cfg_col_chat_prefix_more, NULL, weechat_config_change_color },
  { "col_chat_prefix_suffix",
    N_("color for text after prefix"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_SUFFIX, "green", NULL,
    &cfg_col_chat_prefix_suffix, NULL, weechat_config_change_color },
  { "col_chat_buffer",
    N_("color for buffer names"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_BUFFER, "white", NULL,
    &cfg_col_chat_buffer, NULL, weechat_config_change_color },
  { "col_chat_server",
    N_("color for server names"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_SERVER, "brown", NULL,
    &cfg_col_chat_server, NULL, weechat_config_change_color },
  { "col_chat_channel",
    N_("color for channel names"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_CHANNEL, "white", NULL,
    &cfg_col_chat_channel, NULL, weechat_config_change_color },
  { "col_chat_nick",
    N_("color for nicks"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK, "lightcyan", NULL,
    &cfg_col_chat_nick, NULL, weechat_config_change_color },
  { "col_chat_nick_self",
    N_("color for local nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK_SELF, "white", NULL,
    &cfg_col_chat_nick_self, NULL, weechat_config_change_color },
  { "col_chat_nick_other",
    N_("color for other nick in private buffer"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK_OTHER, "default", NULL,
    &cfg_col_chat_nick_other, NULL, weechat_config_change_color },
  { "col_chat_nick_color1",
    N_("color #1 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK1, "cyan", NULL,
    &cfg_col_chat_nick_colors[0], NULL, weechat_config_change_color },
  { "col_chat_nick_color2",
    N_("color #2 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK2, "magenta", NULL,
    &cfg_col_chat_nick_colors[1], NULL, weechat_config_change_color },
  { "col_chat_nick_color3",
    N_("color #3 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK3, "green", NULL,
    &cfg_col_chat_nick_colors[2], NULL, weechat_config_change_color },
  { "col_chat_nick_color4",
    N_("color #4 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK4, "brown", NULL,
    &cfg_col_chat_nick_colors[3], NULL, weechat_config_change_color },
  { "col_chat_nick_color5",
    N_("color #5 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK5, "lightblue", NULL,
    &cfg_col_chat_nick_colors[4], NULL, weechat_config_change_color },
  { "col_chat_nick_color6",
    N_("color #6 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK6, "default", NULL,
    &cfg_col_chat_nick_colors[5], NULL, weechat_config_change_color },
  { "col_chat_nick_color7",
    N_("color #7 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK7, "lightcyan", NULL,
    &cfg_col_chat_nick_colors[6], NULL, weechat_config_change_color },
  { "col_chat_nick_color8",
    N_("color #8 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK8, "lightmagenta", NULL,
    &cfg_col_chat_nick_colors[7], NULL, weechat_config_change_color },
  { "col_chat_nick_color9",
    N_("color #9 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK9, "lightgreen", NULL,
    &cfg_col_chat_nick_colors[8], NULL, weechat_config_change_color },
  { "col_chat_nick_color10",
    N_("color #10 for nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK10, "blue", NULL,
    &cfg_col_chat_nick_colors[9], NULL, weechat_config_change_color },
  { "col_chat_host",
    N_("color for hostnames"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_HOST, "cyan", NULL,
    &cfg_col_chat_host, NULL, weechat_config_change_color },
  { "col_chat_delimiters",
    N_("color for delimiters"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_DELIMITERS, "green", NULL,
    &cfg_col_chat_delimiters, NULL, weechat_config_change_color },
  { "col_chat_highlight",
    N_("color for highlighted nick"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_HIGHLIGHT, "yellow", NULL,
    &cfg_col_chat_highlight, NULL, weechat_config_change_color },
  { "col_chat_read_marker",
    N_("color for unread data marker"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_READ_MARKER, "yellow", NULL,
    &cfg_col_chat_read_marker, NULL, weechat_config_change_color },
  { "col_chat_read_marker_bg",
    N_("background color for unread data marker"),
    OPTION_TYPE_COLOR, 0, 0, -1, "magenta", NULL,
    &cfg_col_chat_read_marker_bg, NULL, weechat_config_change_color },
  
  /* status window */
  { "col_status",
    N_("color for status bar"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS, "default", NULL,
    &cfg_col_status, NULL, weechat_config_change_color },
  { "col_status_bg",
    N_("background color for status bar"),
    OPTION_TYPE_COLOR, 0, 0, -1, "blue", NULL,
    &cfg_col_status_bg, NULL, weechat_config_change_color },
  { "col_status_delimiters",
    N_("color for status bar delimiters"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DELIMITERS, "cyan", NULL,
    &cfg_col_status_delimiters, NULL, weechat_config_change_color },
  { "col_status_channel",
    N_("color for current channel in status bar"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_CHANNEL, "white", NULL,
    &cfg_col_status_channel, NULL, weechat_config_change_color },
  { "col_status_data_msg",
    N_("color for window with new messages (status bar)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_MSG, "yellow", NULL,
    &cfg_col_status_data_msg, NULL, weechat_config_change_color },
  { "col_status_data_private",
    N_("color for window with private message (status bar)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_PRIVATE, "lightmagenta", NULL,
    &cfg_col_status_data_private, NULL, weechat_config_change_color },
  { "col_status_data_highlight",
    N_("color for window with highlight (status bar)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_HIGHLIGHT, "lightred", NULL,
    &cfg_col_status_data_highlight, NULL, weechat_config_change_color },
  { "col_status_data_other",
    N_("color for window with new data (not messages) (status bar)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_OTHER, "default", NULL,
    &cfg_col_status_data_other, NULL, weechat_config_change_color },
  { "col_status_more",
    N_("color for window with new data (status bar)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_MORE, "white", NULL,
    &cfg_col_status_more, NULL, weechat_config_change_color },
  
  /* infobar window */
  { "col_infobar",
    N_("color for info bar text"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR, "black", NULL,
    &cfg_col_infobar, NULL, weechat_config_change_color },
  { "col_infobar_bg",
    N_("background color for info bar text"),
    OPTION_TYPE_COLOR, 0, 0, -1, "cyan", NULL,
    &cfg_col_infobar_bg, NULL, weechat_config_change_color },
  { "col_infobar_delimiters",
    N_("color for infobar delimiters"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR_DELIMITERS, "blue", NULL,
    &cfg_col_infobar_delimiters, NULL, weechat_config_change_color },
  { "col_infobar_highlight",
    N_("color for info bar highlight notification"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR_HIGHLIGHT, "white", NULL,
    &cfg_col_infobar_highlight, NULL, weechat_config_change_color },
  
  /* input window */
  { "col_input",
    N_("color for input text"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT, "default", NULL,
    &cfg_col_input, NULL, weechat_config_change_color },
  { "col_input_bg",
    N_("background color for input text"),
    OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
    &cfg_col_input_bg, NULL, weechat_config_change_color },
  { "col_input_server",
    N_("color for input text (server name)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_SERVER, "brown", NULL,
    &cfg_col_input_server, NULL, weechat_config_change_color },
  { "col_input_channel",
    N_("color for input text (channel name)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_CHANNEL, "white", NULL,
    &cfg_col_input_channel, NULL, weechat_config_change_color },
  { "col_input_nick",
    N_("color for input text (nick name)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_NICK, "lightcyan", NULL,
    &cfg_col_input_nick, NULL, weechat_config_change_color },
  { "col_input_delimiters",
    N_("color for input text (delimiters)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_DELIMITERS, "cyan", NULL,
    &cfg_col_input_delimiters, NULL, weechat_config_change_color },
  { "col_input_text_not_found",
    N_("color for text not found"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_TEXT_NOT_FOUND, "red", NULL,
    &cfg_col_input_text_not_found, NULL, weechat_config_change_color },
  { "col_input_actions",
    N_("color for actions in input window"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_ACTIONS, "lightgreen", NULL,
    &cfg_col_input_actions, NULL, weechat_config_change_color },
  
  /* nicklist window */
  { "col_nicklist",
    N_("color for nicklist"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST, "default", NULL,
    &cfg_col_nicklist, NULL, weechat_config_change_color },
  { "col_nicklist_bg",
    N_("background color for nicklist"),
    OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
    &cfg_col_nicklist_bg, NULL, weechat_config_change_color },
  { "col_nicklist_away",
    N_("color for away nicknames"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_AWAY, "cyan", NULL,
    &cfg_col_nicklist_away, NULL, weechat_config_change_color },
  { "col_nicklist_prefix1",
    N_("color for prefix 1"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX1, "lightgreen", NULL,
    &cfg_col_nicklist_prefix1, NULL, weechat_config_change_color },
  { "col_nicklist_prefix2",
    N_("color for prefix 2"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX2, "lightmagenta", NULL,
    &cfg_col_nicklist_prefix2, NULL, weechat_config_change_color },
  { "col_nicklist_prefix3",
    N_("color for prefix 3"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX3, "yellow", NULL,
    &cfg_col_nicklist_prefix3, NULL, weechat_config_change_color },
  { "col_nicklist_prefix4",
    N_("color for prefix 4"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX4, "blue", NULL,
    &cfg_col_nicklist_prefix4, NULL, weechat_config_change_color },
  { "col_nicklist_prefix5",
    N_("color for prefix 5"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX5, "brown", NULL,
    &cfg_col_nicklist_prefix5, NULL, weechat_config_change_color },
  { "col_nicklist_more",
    N_("color for '+' when scrolling nicks (nicklist)"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_MORE, "lightmagenta", NULL,
    &cfg_col_nicklist_more, NULL, weechat_config_change_color },
  { "col_nicklist_separator",
    N_("color for nicklist separator"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_SEPARATOR, "blue", NULL,
    &cfg_col_nicklist_separator, NULL, weechat_config_change_color },

  /* status info (for example: file transfers) */
  { "col_info",
    N_("color for status info"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO, "default", NULL,
    &cfg_col_info, NULL, weechat_config_change_color },
  { "col_info_bg",
    N_("background color for status info"),
    OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL,
    &cfg_col_info_bg, NULL, weechat_config_change_color },
  { "col_info_waiting",
    N_("color for \"waiting\" status info"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_WAITING, "lightcyan", NULL,
    &cfg_col_info_waiting, NULL, weechat_config_change_color },
  { "col_info_connecting",
    N_("color for \"connecting\" status info"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_CONNECTING, "yellow", NULL,
    &cfg_col_info_connecting, NULL, weechat_config_change_color },
  { "col_info_active",
    N_("color for \"active\" status info"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_ACTIVE, "lightblue", NULL,
    &cfg_col_info_active, NULL, weechat_config_change_color },
  { "col_info_done",
    N_("color for \"done\" status info"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_DONE, "lightgreen", NULL,
    &cfg_col_info_done, NULL, weechat_config_change_color },
  { "col_info_failed",
    N_("color for \"failed\" status info"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_FAILED, "lightred", NULL,
    &cfg_col_info_failed, NULL, weechat_config_change_color },
  { "col_info_aborted",
    N_("color for \"aborted\" status info"),
    OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_ABORTED, "lightred", NULL,
    &cfg_col_info_aborted, NULL, weechat_config_change_color },
  
  { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};

/* config, history section */

int cfg_history_max_lines;
int cfg_history_max_commands;
int cfg_history_display_default;

struct t_config_option weechat_options_history[] =
{ { "history_max_lines",
    N_("maximum number of lines in history "
    "for one server/channel/private window (0 = unlimited)"),
    OPTION_TYPE_INT, 0, INT_MAX, 4096, NULL, NULL,
    &cfg_history_max_lines, NULL, weechat_config_change_noop },
  { "history_max_commands",
    N_("maximum number of user commands in history (0 = unlimited)"),
    OPTION_TYPE_INT, 0, INT_MAX, 100, NULL, NULL,
    &cfg_history_max_commands, NULL, weechat_config_change_noop },
  { "history_display_default",
    N_("maximum number of commands to display by default in history listing "
       "(0 = unlimited)"),
    OPTION_TYPE_INT, 0, INT_MAX, 5, NULL, NULL,
    &cfg_history_display_default, NULL, weechat_config_change_noop },
  { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};

/* config, log section */

int cfg_log_plugin_msg;
char *cfg_log_path;
char *cfg_log_time_format;

struct t_config_option weechat_options_log[] =
{ { "log_plugin_msg",
    N_("log messages from plugins"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
    &cfg_log_plugin_msg, NULL, weechat_config_change_noop },
  { "log_path",
    N_("path for WeeChat log files ('%h' will be replaced by WeeChat home, "
       "~/.weechat by default)"),
    OPTION_TYPE_STRING, 0, 0, 0, "%h/logs/", NULL,
    NULL, &cfg_log_path, weechat_config_change_noop },
  { "log_time_format",
    N_("time format for log (see man strftime for date/time specifiers)"),
    OPTION_TYPE_STRING, 0, 0, 0, "%Y %b %d %H:%M:%S", NULL,
    NULL, &cfg_log_time_format, weechat_config_change_noop },
  { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};

/* config, proxy section */

int cfg_proxy_use;
int cfg_proxy_type;
int cfg_proxy_ipv6;
char *cfg_proxy_type_values[] =
{ "http", "socks4", "socks5", NULL };
char *cfg_proxy_address;
int cfg_proxy_port;
char *cfg_proxy_username;
char *cfg_proxy_password;

struct t_config_option weechat_options_proxy[] =
{ { "proxy_use",
    N_("use a proxy server to connect to irc server"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
    &cfg_proxy_use, NULL, weechat_config_change_noop },
  { "proxy_type",
    N_("proxy type (http (default), socks4, socks5)"),
    OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "http", cfg_proxy_type_values,
    &cfg_proxy_type, NULL, weechat_config_change_noop },
  { "proxy_ipv6",
    N_("connect to proxy in ipv6"),
    OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
    &cfg_proxy_ipv6, NULL, weechat_config_change_noop },
  { "proxy_address",
    N_("proxy server address (IP or hostname)"),
    OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
    NULL, &cfg_proxy_address, weechat_config_change_noop },
  { "proxy_port",
    N_("port for connecting to proxy server"),
    OPTION_TYPE_INT, 0, 65535, 3128, NULL, NULL,
    &cfg_proxy_port, NULL, weechat_config_change_noop },
  { "proxy_username",
    N_("username for proxy server"),
    OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
    NULL, &cfg_proxy_username, weechat_config_change_noop },
  { "proxy_password",
    N_("password for proxy server"),
    OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
    NULL, &cfg_proxy_password, weechat_config_change_noop },
  { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};

/* config, plugins section */

char *cfg_plugins_path;
char *cfg_plugins_autoload;
char *cfg_plugins_extension;

struct t_config_option weechat_options_plugins[] =
{ { "plugins_path",
    N_("path for searching plugins ('%h' will be replaced by WeeChat home, "
       "~/.weechat by default)"),
    OPTION_TYPE_STRING, 0, 0, 0, "%h/plugins", NULL,
    NULL, &cfg_plugins_path, weechat_config_change_noop },
  { "plugins_autoload",
    N_("comma separated list of plugins to load automatically at startup, "
       "\"*\" means all plugins found "
       "(names may be partial, for example \"perl\" is ok for \"perl.so\")"),
    OPTION_TYPE_STRING, 0, 0, 0, "*", NULL,
    NULL, &cfg_plugins_autoload, weechat_config_change_noop },
  { "plugins_extension",
    N_("standard plugins extension in filename, used for autoload "
       "(if empty, then all files are loaded when autoload is \"*\")"),
    OPTION_TYPE_STRING, 0, 0, 0,
#ifdef WIN32
    ".dll",
#else
    ".so",
#endif
    NULL,
    NULL, &cfg_plugins_extension, weechat_config_change_noop },
  { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};

char *weechat_config_sections[] =
{ "look", "colors",
  "history", "log",
  "proxy", "plugins",
  "alias", "keys",
  NULL
};

struct t_config_option *weechat_config_options[] =
{ weechat_options_look, weechat_options_colors,
  weechat_options_history, weechat_options_log,
  weechat_options_proxy, weechat_options_plugins,
  NULL, NULL,
  NULL
};

t_config_func_read_option *weechat_config_read_functions[] =
{ config_file_read_option, config_file_read_option,
  config_file_read_option, config_file_read_option,
  config_file_read_option, config_file_read_option,
  weechat_config_read_alias, weechat_config_read_key,
  NULL
};

t_config_func_write_options *weechat_config_write_functions[] =
{ config_file_write_options, config_file_write_options,
  config_file_write_options, config_file_write_options,
  config_file_write_options, config_file_write_options,
  weechat_config_write_alias, weechat_config_write_keys,
  NULL
};

t_config_func_write_options *weechat_config_write_default_functions[] =
{ config_file_write_options_default_values, config_file_write_options_default_values,
  config_file_write_options_default_values, config_file_write_options_default_values,
  config_file_write_options_default_values, config_file_write_options_default_values,
  weechat_config_write_alias_default_values, weechat_config_write_keys_default_values,
  NULL
};


/*
 * weechat_config_change_noop: called when an option is changed by /set command
 *                             and that no special action is needed after that
 */

void
weechat_config_change_noop ()
{
    /* do nothing */
}

/*
 * weechat_config_change_save_on_exit: called when "save_on_exit" flag is changed
 */

void
weechat_config_change_save_on_exit ()
{
    if (!cfg_look_save_on_exit)
    {
        gui_chat_printf (NULL, "\n");
        gui_chat_printf (NULL,
                         _("Warning: you should now issue /save to write "
                           "\"save_on_exit\" option in configuration file.\n"));
    }
}

/*
 * weechat_config_change_title: called when title is changed
 */

void
weechat_config_change_title ()
{
    if (cfg_look_set_title)
	gui_window_title_set ();
    else
	gui_window_title_reset ();
}

/*
 * weechat_config_change_buffers: called when buffers change (for example nicklist)
 */

void
weechat_config_change_buffers ()
{
    gui_window_refresh_windows ();
}

/*
 * weechat_config_change_buffer_content: called when content of a buffer changes
 */

void
weechat_config_change_buffer_content ()
{
    gui_window_redraw_buffer (gui_current_window->buffer);
}

/*
 * weechat_config_change_buffer_time_format: called when buffer time format changes
 */

void
weechat_config_change_buffer_time_format ()
{
    gui_chat_time_length = util_get_time_length (cfg_look_buffer_time_format);
    gui_chat_change_time_format ();
    gui_window_redraw_buffer (gui_current_window->buffer);
}

/*
 * weechat_config_change_hotlist: called when hotlist changes
 */

void
weechat_config_change_hotlist ()
{
    gui_hotlist_resort ();
    gui_status_draw (gui_current_window->buffer, 1);
}

/*
 * weechat_config_change_read_marker: called when read marker is changed
 */

void
weechat_config_change_read_marker ()
{
    gui_window_redraw_all_buffers ();
}

/*
 * weechat_config_change_prefix: called when a prefix is changed
 */

void
weechat_config_change_prefix ()
{
    int i;
    
    for (i = 0; i < GUI_CHAT_PREFIX_NUMBER; i++)
    {
        if (gui_chat_prefix[i])
            free (gui_chat_prefix[i]);
    }
    gui_chat_prefix_build ();
}

/*
 * weechat_config_change_color: called when a color is changed by /set command
 */

void
weechat_config_change_color ()
{
    gui_color_init_pairs ();
    gui_color_rebuild_weechat ();
    gui_window_refresh_windows ();
}

/*
 * weechat_config_change_nicks_colors: called when number of nicks color changed
 */

void
weechat_config_change_nicks_colors ()
{
    struct t_gui_buffer *ptr_buffer;
    struct t_gui_nick *ptr_nick;

    for (ptr_buffer = gui_buffers; ptr_buffer;
         ptr_buffer = ptr_buffer->next_buffer)
    {
        if (ptr_buffer->nicks)
        {
            for (ptr_nick = ptr_buffer->nicks; ptr_nick;
                 ptr_nick = ptr_nick->next_nick)
            {
                //gui_nick_find_color (ptr_nick);
            }   
        }
    }
}

/*
 * weechat_config_read_alias: read an alias in configuration file
 *                            Return:  0 = successful
 *                                    -1 = option not found
 *                                    -2 = bad format/value
 */

int
weechat_config_read_alias (struct t_config_option *options,
                           char *option_name, char *value)
{
    /* make C compiler happy */
    (void) options;
    
    if (option_name)
    {
        /* create new alias */
        if (alias_new (option_name, value))
            weelist_add (&weechat_index_commands,
                         &weechat_last_index_command,
                         option_name,
                         WEELIST_POS_SORT);
        else
            return -2;
    }
    else
    {
        /* does nothing for new [alias] section */
    }
    
    /* all ok */
    return 0;
}

/*
 * weechat_config_read_key: read a key in configuration file
 *                          Return:  0 = successful
 *                                  -1 = option not found
 *                                  -2 = bad format/value
 */

int
weechat_config_read_key (struct t_config_option *options,
                         char *option_name, char *value)
{
    /* make C compiler happy */
    (void) options;
    
    if (option_name)
    {
        if (value[0])
        {
            /* bind key (overwrite any binding with same key) */
            gui_keyboard_bind (option_name, value);
        }
        else
        {
            /* unbin key if no value given */
            gui_keyboard_unbind (option_name);
        }
    }
    else
    {
        /* does nothing for new [key] section */
    }
    
    /* all ok */
    return 0;
}

/*
 * weechat_config_read: read WeeChat configuration file
 *                      return:  0 = successful
 *                              -1 = configuration file file not found
 *                              -2 = error in configuration file
 */

int
weechat_config_read ()
{
    return config_file_read (weechat_config_sections, weechat_config_options,
                             weechat_config_read_functions,
                             config_file_read_option,
                             weechat_config_write_default_functions,
                             WEECHAT_CONFIG_NAME);
}

/*
 * weechat_config_write_alias: write alias section in configuration file
 *                             Return:  0 = successful
 *                                     -1 = write error
 */

int
weechat_config_write_alias (FILE *file, char *section_name,
                            struct t_config_option *options)
{
    struct alias *ptr_alias;
    
    /* make C compiler happy */
    (void) options;
    
    string_iconv_fprintf (file, "\n[%s]\n", section_name);
    
    for (ptr_alias = weechat_alias; ptr_alias;
         ptr_alias = ptr_alias->next_alias)
    {
        string_iconv_fprintf (file, "%s = \"%s\"\n",
                              ptr_alias->name, ptr_alias->command);
    }
    
    /* all ok */
    return 0;
}

/*
 * weechat_config_write_keys: write alias section in configuration file
 *                            Return:  0 = successful
 *                                    -1 = write error
 */

int
weechat_config_write_keys (FILE *file, char *section_name,
                           struct t_config_option *options)
{
    t_gui_key *ptr_key;
    char *expanded_name, *function_name;
    
    /* make C compiler happy */
    (void) options;
    
    string_iconv_fprintf (file, "\n[%s]\n", section_name);
    
    for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
    {
        expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
        if (ptr_key->function)
        {
            function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
            if (function_name)
                string_iconv_fprintf (file, "%s = \"%s%s%s\"\n",
                                      (expanded_name) ? expanded_name : ptr_key->key,
                                      function_name,
                                      (ptr_key->args) ? " " : "",
                                      (ptr_key->args) ? ptr_key->args : "");
        }
        else
            string_iconv_fprintf (file, "%s = \"%s\"\n",
                                  (expanded_name) ? expanded_name : ptr_key->key,
                                  ptr_key->command);
        if (expanded_name)
            free (expanded_name);
    }
    
    /* all ok */
    return 0;
}

/*
 * weechat_config_write_alias_default_values: write alias section with default values
 *                                            in configuration file
 *                                            Return:  0 = successful
 *                                                    -1 = write error
 */

int
weechat_config_write_alias_default_values (FILE *file, char *section_name,
                                           struct t_config_option *options)
{
    /* make C compiler happy */
    (void) options;
    
    string_iconv_fprintf (file, "\n[%s]\n", section_name);
    
    string_iconv_fprintf (file, "SAY = \"msg *\"\n");
    string_iconv_fprintf (file, "BYE = \"quit\"\n");
    string_iconv_fprintf (file, "EXIT = \"quit\"\n");
    string_iconv_fprintf (file, "SIGNOFF = \"quit\"\n");
    string_iconv_fprintf (file, "C = \"clear\"\n");
    string_iconv_fprintf (file, "CL = \"clear\"\n");
    string_iconv_fprintf (file, "CLOSE = \"buffer close\"\n");
    string_iconv_fprintf (file, "CHAT = \"dcc chat\"\n");
    string_iconv_fprintf (file, "IG = \"ignore\"\n");
    string_iconv_fprintf (file, "J = \"join\"\n");
    string_iconv_fprintf (file, "K = \"kick\"\n");
    string_iconv_fprintf (file, "KB = \"kickban\"\n");
    string_iconv_fprintf (file, "LEAVE = \"part\"\n");
    string_iconv_fprintf (file, "M = \"msg\"\n");
    string_iconv_fprintf (file, "MUB = \"unban *\"\n");
    string_iconv_fprintf (file, "N = \"names\"\n");
    string_iconv_fprintf (file, "Q = \"query\"\n");
    string_iconv_fprintf (file, "T = \"topic\"\n");
    string_iconv_fprintf (file, "UB = \"unban\"\n");
    string_iconv_fprintf (file, "UNIG = \"unignore\"\n");
    string_iconv_fprintf (file, "W = \"who\"\n");
    string_iconv_fprintf (file, "WC = \"window merge\"\n");
    string_iconv_fprintf (file, "WI = \"whois\"\n");
    string_iconv_fprintf (file, "WW = \"whowas\"\n");
    
    /* all ok */
    return 0;
}

/*
 * weechat_config_write_keys_default_values: write keys section with default values
 *                                           in configuration file 
 *                                           Return:  0 = successful
 *                                                   -1 = write error
 */

int
weechat_config_write_keys_default_values (FILE *file, char *section_name,
                                          struct t_config_option *options)
{
    t_gui_key *ptr_key;
    char *expanded_name, *function_name;
    
    /* make C compiler happy */
    (void) options;
    
    string_iconv_fprintf (file, "\n[%s]\n", section_name);
    
    for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
    {
        expanded_name = gui_keyboard_get_expanded_name (ptr_key->key);
        if (ptr_key->function)
        {
            function_name = gui_keyboard_function_search_by_ptr (ptr_key->function);
            if (function_name)
                string_iconv_fprintf (file, "%s = \"%s%s%s\"\n",
                                      (expanded_name) ? expanded_name : ptr_key->key,
                                      function_name,
                                      (ptr_key->args) ? " " : "",
                                      (ptr_key->args) ? ptr_key->args : "");
        }
        else
            string_iconv_fprintf (file, "%s = \"%s\"\n",
                                  (expanded_name) ? expanded_name : ptr_key->key,
                                  ptr_key->command);
        if (expanded_name)
            free (expanded_name);
    }
    
    /* all ok */
    return 0;
}

/*
 * weechat_config_write: write WeeChat configuration file
 *                       return:  0 if ok
 *                              < 0 if error
 */

int
weechat_config_write ()
{
    weechat_log_printf (_("Saving WeeChat configuration to disk\n"));
    return config_file_write (weechat_config_sections, weechat_config_options,
                              weechat_config_write_functions,
                              WEECHAT_CONFIG_NAME);
}

/*
 * weechat_config_print_stdout: print WeeChat options on standard output
 */

void
weechat_config_print_stdout ()
{
    config_option_print_stdout (weechat_config_sections,
                                weechat_config_options);
}