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
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
|
= WeeChat developer's guide
:author: Sébastien Helleu
:email: flashcode@flashtux.org
:lang: en
This manual documents WeeChat chat client, it is part of WeeChat.
Latest version of this document can be found on
https://weechat.org/doc/[this page ^↗^^].
[[introduction]]
== Introduction
WeeChat (Wee Enhanced Environment for Chat) is a free chat client, fast and
light, designed for many operating systems.
This manual documents WeeChat internals:
* repositories
* coding rules
* core internals
* plugin internals
* how to contribute to WeeChat.
[[repositories]]
== Repositories
WeeChat repositories are on GitHub organization
https://github.com/weechat[weechat ^↗^^].
List of repositories:
weechat::
core repository with source code and documentation
scripts::
the _official_ scripts submitted on weechat.org
weechat.org::
source of https://weechat.org/[WeeChat website ^↗^^]
weercd::
IRC testing server
qweechat::
Qt remote GUI for WeeChat.
This manual documents only _weechat_ repository.
[[overview]]
=== Overview
The main WeeChat directories are:
[width="100%",cols="2m,3",options="header"]
|===
| Directory | Description
| src/ | Root of sources.
| core/ | Core functions: entry point, internal structures.
| hook/ | Hook functions.
| gui/ | Functions for buffers, windows, ... (used by all interfaces).
| curses/ | Curses interface.
| headless/ | Headless mode (no interface).
| normal/ | Curses interface.
| plugins/ | Plugin and scripting API.
| alias/ | Alias plugin.
| buflist/ | Buflist plugin.
| charset/ | Charset plugin.
| exec/ | Exec plugin.
| fifo/ | Fifo plugin (FIFO pipe used to remotely send commands to WeeChat).
| fset/ | Fset (Fast Set) plugin.
| guile/ | Guile (scheme) scripting API.
| irc/ | IRC (Internet Relay Chat) plugin.
| javascript/ | JavaScript scripting API.
| logger/ | Logger plugin (write messages displayed to files).
| lua/ | Lua scripting API.
| perl/ | Perl scripting API.
| php/ | PHP scripting API.
| python/ | Python scripting API.
| relay/ | Relay plugin (irc proxy + relay for remote interfaces).
| ruby/ | Ruby scripting API.
| script/ | Script manager.
| spell/ | Spell plugin.
| tcl/ | Tcl scripting API.
| trigger/ | Trigger plugin.
| typing/ | Typing plugin.
| xfer/ | Xfer plugin (IRC DCC file/chat).
| tests/ | Tests.
| scripts/ | Scripting API tests.
| python/ | Python scripts to generate and run the scripting API tests.
| unit/ | Unit tests.
| core/ | Unit tests for core functions.
| gui/ | Unit tests for interfaces functions.
| plugins/ | Unit tests for plugins.
| irc/ | Unit tests for IRC plugin.
| trigger/ | Unit tests for trigger plugin.
| doc/ | Documentation.
| po/ | Translations files (gettext).
| debian/ | Debian packaging.
|===
[[sources]]
=== Sources
[[sources_core]]
==== Core
WeeChat "core" is located in following directories:
* _src/core/_: core functions (for data manipulation)
* _src/gui/_: functions about interface (buffers, windows, ...)
[width="100%",cols="2m,3",options="header"]
|===
| Path/file | Description
| core/ | Core functions: entry point, internal structures.
| core-arraylist.c | Array lists.
| core-backtrace.c | Display a backtrace after a crash.
| core-calc.c | Calculate result of expressions.
| core-command.c | WeeChat core commands.
| core-completion.c | Default completions.
| core-config-file.c | Configuration file management.
| core-config.c | Configuration options for WeeChat core (file weechat.conf).
| core-crypto.c | Cryptographic functions.
| core-debug.c | Some debug functions.
| core-doc.c | Build of files for documentation.
| core-dir.c | Directory/file functions.
| core-eval.c | Evaluation of expressions with references to internal vars.
| core-hashtable.c | Hashtables.
| core-hdata.c | Hdata (direct access to data using hashtables).
| core-hook.c | Hooks.
| core-infolist.c | Infolists (lists with objects data).
| core-input.c | Input of commands/text.
| core-list.c | Sorted lists.
| core-log.c | Write to WeeChat log file (weechat.log).
| core-network.c | Network functions (connection to servers/proxies).
| core-proxy.c | Proxy management.
| core-secure.c | Secured data functions.
| core-secure-buffer.c | Secured data buffer.
| core-secure-config.c | Secured data options (file sec.conf).
| core-signal.c | Signal functions.
| core-string.c | Functions on strings.
| core-sys.c | System functions.
| core-upgrade-file.c | Internal upgrade system.
| core-upgrade.c | Upgrade for WeeChat core (buffers, lines, history, ...).
| core-url.c | URL transfer (using libcurl).
| core-utf8.c | UTF-8 functions.
| core-util.c | Some other functions.
| core-version.c | Functions for WeeChat version.
| weechat.c | Main functions: command line options, startup.
| hook/ | Hook functions.
| hook-command-run.c | Hook "command_run".
| hook-command.c | Hook "command".
| hook-completion.c | Hook "completion".
| hook-config.c | Hook "config".
| hook-connect.c | Hook "connect".
| hook-fd.c | Hook "fd".
| hook-focus.c | Hook "focus".
| hook-hdata.c | Hook "hdata".
| hook-hsignal.c | Hook "hsignal".
| hook-info-hashtable.c | Hook "info_hashtable".
| hook-info.c | Hook "info".
| hook-infolist.c | Hook "infolist".
| hook-line.c | Hook "line".
| hook-modifier.c | Hook "modifier".
| hook-print.c | Hook "print".
| hook-process.c | Hook "process".
| hook-signal.c | Hook "signal".
| hook-timer.c | Hook "timer".
| hook-url.c | Hook "url".
| gui/ | Functions for buffers, windows, ... (used by all interfaces).
| gui-bar-item.c | Bar items.
| gui-bar-window.c | Bar windows.
| gui-bar.c | Bars.
| gui-buffer.c | Buffers.
| gui-chat.c | Chat functions (display message, ...).
| gui-color.c | Color functions.
| gui-completion.c | Completion on command line.
| gui-cursor.c | Cursor mode (free movement of cursor).
| gui-filter.c | Filters.
| gui-focus.c | Functions about focus (for cursor mode and mouse).
| gui-history.c | Commands/text saved in buffers.
| gui-hotlist.c | Hotlist management (list of buffers with activity).
| gui-input.c | Input functions (input bar).
| gui-key.c | Keyboard functions.
| gui-layout.c | Layout.
| gui-line.c | Lines in buffers.
| gui-mouse.c | Mouse.
| gui-nick.c | Nick functions.
| gui-nicklist.c | Nicklist in buffers.
| gui-window.c | Windows.
| curses/ | Curses interface.
| gui-curses-bar-window.c | Display in bar windows.
| gui-curses-chat.c | Display in chat area (messages).
| gui-curses-color.c | Color functions.
| gui-curses-key.c | Keyboard functions (default keys, read of input).
| gui-curses-main.c | WeeChat main loop (waiting for keyboard/network events).
| gui-curses-mouse.c | Mouse.
| gui-curses-term.c | Functions about terminal.
| gui-curses-window.c | Windows.
| headless/ | Headless mode (no interface).
| main.c | Entry point for headless mode.
| ncurses-fake.c | Fake ncurses library.
| normal/ | Curses interface.
| main.c | Entry point for Curses interface.
|===
[[sources_plugins]]
==== Plugins
[width="100%",cols="2m,3",options="header"]
|===
| Path/file | Description
| plugins/ | Root of plugins.
| plugin.c | Plugins management (load/unload dynamic C libraries).
| plugin-api.c | Extra functions for plugin API (wrapper around WeeChat core functions).
| plugin-api-info.c | Extra info/infolist functions for plugin API.
| plugin-config.c | Plugin configuration options (file plugins.conf).
| plugin-script.c | Common functions used by script plugins.
| plugin-script-api.c | Script API functions: wrappers around some plugin API functions.
| plugin-script-config.c | Script plugin configuration options (files python.conf, perl.conf, ...).
| weechat-plugin.h | Header designed to be distributed with WeeChat plugins, in order to compile them.
| alias/ | Alias plugin.
| alias.c | Main alias functions.
| alias-command.c | Alias commands.
| alias-completion.c | Alias completions.
| alias-config.c | Alias config options (file alias.conf).
| alias-info.c | Alias info/infolists/hdata.
| spell/ | Spell checker plugin.
| spell.c | Main spell checker functions.
| spell-bar-item.c | Spell checker bar items.
| spell-command.c | Spell checker commands.
| spell-completion.c | Spell checker completions.
| spell-config.c | Spell checker config options (file spell.conf).
| spell-info.c | Spell checker info/infolists/hdata.
| spell-speller.c | Spellers management.
| buflist/ | Buflist plugin.
| buflist.c | Main buflist functions.
| buflist-bar-item.c | Buflist bar items.
| buflist-command.c | Buflist commands.
| buflist-completion.c | Buflist completions.
| buflist-config.c | Buflist config options (file buflist.conf).
| buflist-info.c | Buflist info/infolists/hdata.
| buflist-mouse.c | Buflist mouse actions.
| charset/ | Charset plugin.
| charset.c | Charset functions.
| exec/ | Exec plugin.
| exec.c | Main exec functions.
| exec-buffer.c | Exec buffer.
| exec-command.c | Exec commands.
| exec-completion.c | Exec completions.
| exec-config.c | Exec config options (file exec.conf).
| fifo/ | Fifo plugin.
| fifo.c | Main fifo functions.
| fifo-command.c | Fifo commands.
| fifo-config.c | Fifo config options (file fifo.conf).
| fifo-info.c | Fifo info/infolists/hdata.
| fset/ | Fset plugin.
| fset.c | Main fset functions.
| fset-bar-item.c | Fset bar items.
| fset-buffer.c | Fset buffer.
| fset-command.c | Fset commands.
| fset-completion.c | Fset completions.
| fset-config.c | Fset config options (file fset.conf).
| fset-info.c | Fset info/infolists/hdata.
| fset-mouse.c | Fset mouse actions.
| fset-option.c | Fset options management.
| guile/ | Guile (scheme) plugin.
| weechat-guile.c | Main guile functions (load/unload scripts, execute guile code).
| weechat-guile-api.c | Guile scripting API functions.
| irc/ | IRC (Internet Relay Chat) plugin.
| irc.c | Main IRC functions.
| irc-bar-item.c | IRC bar items.
| irc-batch.c | IRC batched events.
| irc-buffer.c | IRC buffers.
| irc-channel.c | IRC channels.
| irc-color.c | IRC colors.
| irc-command.c | IRC commands.
| irc-completion.c | IRC completions.
| irc-config.c | IRC config options (file irc.conf).
| irc-ctcp.c | IRC CTCP.
| irc-debug.c | IRC debug functions.
| irc-ignore.c | IRC Ignore.
| irc-info.c | IRC info/infolists/hdata.
| irc-input.c | Input of commands/text.
| irc-join.c | Functions for list of channels to join.
| irc-list.c | Buffer for reply to /list command.
| irc-message.c | Functions to manipulate IRC messages.
| irc-mode.c | Functions about channel/nick modes.
| irc-modelist.c | IRC channel mode lists (+b, +e, +I, ...).
| irc-msgbuffer.c | Target buffer for IRC messages.
| irc-nick.c | IRC nicks.
| irc-notify.c | IRC notify lists.
| irc-protocol.c | IRC protocol (RFCs 1459/2810/2811/2812/2813/7194).
| irc-raw.c | IRC raw buffer.
| irc-redirect.c | Redirection of IRC command output.
| irc-sasl.c | SASL authentication with IRC server.
| irc-server.c | I/O communication with IRC server.
| irc-tag.c | Functions to manipulate IRC message tags.
| irc-typing.c | Typing status.
| irc-upgrade.c | Save/restore of IRC data when upgrading WeeChat.
| javascript/ | JavaScript plugin.
| weechat-js.cpp | Main JavaScript functions (load/unload scripts, execute JavaScript code).
| weechat-js-api.cpp | JavaScript scripting API functions.
| weechat-js-v8.cpp | JavaScript v8 functions.
| logger/ | Logger plugin.
| logger.c | Main logger functions.
| logger-backlog.c | Logger backlog functions.
| logger-buffer.c | Logger buffer list management.
| logger-command.c | Logger commands.
| logger-config.c | Logger config options (file logger.conf).
| logger-info.c | Logger info/infolists/hdata.
| logger-tail.c | Functions to get last lines of a file.
| lua/ | Lua plugin.
| weechat-lua.c | Main lua functions (load/unload scripts, execute lua code).
| weechat-lua-api.c | Lua scripting API functions.
| perl/ | Perl plugin.
| weechat-perl.c | Main perl functions (load/unload scripts, execute perl code).
| weechat-perl-api.c | Perl scripting API functions.
| php/ | PHP plugin.
| weechat-php.c | Main PHP functions (load/unload scripts, execute PHP code).
| weechat-php-api.c | PHP scripting API functions.
| python/ | Python plugin.
| weechat-python.c | Main python functions (load/unload scripts, execute python code).
| weechat-python-api.c | Python scripting API functions.
| relay/ | Relay plugin (IRC proxy and relay for remote interfaces).
| relay.c | Main relay functions.
| relay-auth.c | Clients authentication.
| relay-buffer.c | Relay buffer.
| relay-client.c | Clients of relay.
| relay-command.c | Relay commands.
| relay-completion.c | Relay completions.
| relay-config.c | Relay config options (file relay.conf).
| relay-http.c | HTTP functions.
| relay-info.c | Relay info/infolists/hdata.
| relay-network.c | Network functions for relay.
| relay-raw.c | Relay raw buffer.
| relay-remote.c | Relay remote.
| relay-server.c | Relay server.
| relay-upgrade.c | Save/restore of relay data when upgrading WeeChat.
| relay-websocket.c | WebSocket server functions (RFC 6455).
| api/ | Relay for remote interfaces (using HTTP REST API).
| relay-api.c | Main API functions for HTTP REST API.
| relay-api-msg.c | Send JSON messages to clients.
| relay-api-protocol.c | HTTP REST API protocol.
| remote/ | Relay remote functions, specific to API.
| relay-remote-event.c | Process events received from relay remote.
| relay-remote-network.c | Network functions for relay remote.
| irc/ | IRC proxy.
| relay-irc.c | Main IRC proxy functions.
| weechat/ | Relay for remote interfaces (using "weechat" binary protocol).
| relay-weechat.c | Relay for remote interfaces (main functions).
| relay-weechat-msg.c | Send binary messages to clients.
| relay-weechat-nicklist.c | Nicklist functions.
| relay-weechat-protocol.c | Read commands from clients.
| ruby/ | Ruby plugin.
| weechat-ruby.c | Main ruby functions (load/unload scripts, execute ruby code).
| weechat-ruby-api.c | Ruby scripting API functions.
| script/ | Script manager.
| script.c | Main functions for script manager.
| script-action.c | Actions on scripts (load/unload, install/remove, ...).
| script-buffer.c | Buffer for script manager.
| script-command.c | Commands for script manager.
| script-completion.c | Completions for script manager.
| script-config.c | Config options for script manager (file script.conf).
| script-info.c | Script manager info/infolists/hdata.
| script-mouse.c | Script mouse actions.
| script-repo.c | Download and read repository file.
| tcl/ | Tcl plugin.
| weechat-tcl.c | Main tcl functions (load/unload scripts, execute tcl code).
| weechat-tcl-api.c | Tcl scripting API functions.
| trigger/ | Trigger plugin.
| trigger.c | Main trigger functions.
| trigger-buffer.c | Trigger buffer.
| trigger-callback.c | Trigger callbacks.
| trigger-command.c | Trigger commands.
| trigger-completion.c | Trigger completions.
| trigger-config.c | Trigger config options (file trigger.conf).
| typing/ | Typing plugin.
| typing.c | Main typing functions.
| typing-bar-item.c | Typing bar items.
| typing-config.c | Typing config options (file typing.conf).
| typing-status.c | Messages typing status on buffers.
| xfer/ | Xfer plugin (IRC DCC file/chat).
| xfer.c | Main xfer functions.
| xfer-buffer.c | Xfer buffer.
| xfer-chat.c | DCC chat.
| xfer-command.c | Xfer commands.
| xfer-completion.c | Xfer completions.
| xfer-config.c | Xfer config options (file xfer.conf).
| xfer-dcc.c | DCC file transfer.
| xfer-file.c | File functions for xfer.
| xfer-info.c | Xfer info/infolists/hdata.
| xfer-network.c | Network functions for xfer.
| xfer-upgrade.c | Save/restore of xfer data when upgrading WeeChat.
|===
[[sources_tests]]
==== Tests
[width="100%",cols="2m,3",options="header"]
|===
| Path/file | Description
| tests/ | Root of tests.
| tests.cpp | Program used to run all tests.
| tests-record.cpp | Record and search in messages displayed.
| scripts/ | Root of scripting API tests.
| test-scripts.cpp | Program used to run the scripting API tests.
| python/ | Python scripts to generate and run the scripting API tests.
| testapigen.py | Python script generating scripts in all languages to test the scripting API.
| testapi.py | Python script with scripting API tests, used by script testapigen.py.
| unparse.py | Convert Python code to other languages, used by script testapigen.py.
| unit/ | Root of unit tests.
| test-plugins.cpp | Tests: plugins.
| test-plugin-api-info.cpp | Tests: plugin API info functions.
| test-plugin-config.cpp | Tests: plugin config functions.
| core/ | Root of unit tests for core.
| test-core-arraylist.cpp | Tests: arraylists.
| test-core-calc.cpp | Tests: calculation of expressions.
| test-core-command.cpp | Tests: commands.
| test-core-config-file.cpp | Tests: configuration files.
| test-core-crypto.cpp | Tests: cryptographic functions.
| test-core-dir.cpp | Tests: directory/file functions.
| test-core-eval.cpp | Tests: evaluation of expressions.
| test-core-hashtble.cpp | Tests: hashtables.
| test-core-hdata.cpp | Tests: hdata.
| test-core-hook.cpp | Tests: hooks.
| test-core-infolist.cpp | Tests: infolists.
| test-core-list.cpp | Tests: lists.
| test-core-network.cpp | Tests: network functions.
| test-core-secure.cpp | Tests: secured data.
| test-core-signal.cpp | Tests: signals.
| test-core-string.cpp | Tests: strings.
| test-core-url.cpp | Tests: URLs.
| test-core-utf8.cpp | Tests: UTF-8.
| test-core-util.cpp | Tests: utility functions.
| test-core-sys.cpp | Tests: system functions.
| hook/ | Root of unit tests for hooks.
| test-hook-command.cpp | Tests: hooks "command".
| test-hook-command-run.cpp | Tests: hooks "command_run".
| test-hook-completion.cpp | Tests: hooks "completion".
| test-hook-config.cpp | Tests: hooks "config".
| test-hook-connect.cpp | Tests: hooks "connect".
| test-hook-fd.cpp | Tests: hooks "fd".
| test-hook-focus.cpp | Tests: hooks "focus".
| test-hook-hdata.cpp | Tests: hooks "hdata".
| test-hook-hsignal.cpp | Tests: hooks "hsignal".
| test-hook-info-hashtable.cpp | Tests: hooks "info_hashtable".
| test-hook-info.cpp | Tests: hooks "info".
| test-hook-infolist.cpp | Tests: hooks "infolist".
| test-hook-line.cpp | Tests: hooks "line".
| test-hook-modifier.cpp | Tests: hooks "modifier".
| test-hook-print.cpp | Tests: hooks "print".
| test-hook-process.cpp | Tests: hooks "process".
| test-hook-signal.cpp | Tests: hooks "signal".
| test-hook-timer.cpp | Tests: hooks "timer".
| test-hook-url.cpp | Tests: hooks "url".
| gui/ | Root of unit tests for interfaces.
| test-gui-bar-window.cpp | Tests: bar window functions.
| test-gui-buffer.cpp | Tests: buffer functions.
| test-gui-chat.cpp | Tests: chat functions.
| test-gui-color.cpp | Tests: colors.
| test-gui-filter.cpp | Tests: filters.
| test-gui-hotlist.cpp | Tests: hotlist functions.
| test-gui-input.cpp | Tests: input functions.
| test-gui-key.cpp | Tests: keys.
| test-gui-line.cpp | Tests: lines.
| test-gui-nick.cpp | Tests: nicks.
| test-gui-nicklist.cpp | Tests: nicklist functions.
| curses/ | Root of unit tests for Curses interface.
| test-gui-curses-mouse.cpp | Tests: mouse (Curses interface).
| plugins/ | Root of unit tests for plugins.
| irc/ | Root of unit tests for IRC plugin.
| test-irc-batch.cpp | Tests: IRC batched events.
| test-irc-buffer.cpp | Tests: IRC buffers.
| test-irc-channel.cpp | Tests: IRC channels.
| test-irc-color.cpp | Tests: IRC colors.
| test-irc-command.cpp | Tests: IRC commands.
| test-irc-config.cpp | Tests: IRC configuration.
| test-irc-ctcp.cpp | Tests: IRC CTCP.
| test-irc-ignore.cpp | Tests: IRC ignores.
| test-irc-info.cpp | Tests: IRC info.
| test-irc-join.cpp | Tests: IRC join functions.
| test-irc-list.cpp | Tests: IRC buffer for reply to /list command.
| test-irc-message.cpp | Tests: IRC messages.
| test-irc-mode.cpp | Tests: IRC modes.
| test-irc-nick.cpp | Tests: IRC nicks.
| test-irc-protocol.cpp | Tests: IRC protocol.
| test-irc-sasl.cpp | Tests: SASL authentication with IRC protocol.
| test-irc-server.cpp | Tests: IRC server.
| test-irc-tag.cpp | Tests: IRC message tags.
| logger/ | Root of unit tests for logger plugin.
| test-logger.cpp | Tests: logger.
| test-logger-backlog.cpp | Tests: logger backlog.
| test-logger-tail.cpp | Tests: logger tail functions.
| trigger/ | Root of unit tests for trigger plugin.
| test-trigger.cpp | Tests: triggers.
| test-trigger-config.cpp | Tests: trigger configuration.
| typing/ | Root of unit tests for typing plugin.
| test-typing.cpp | Tests: typing.
| test-typing-status.cpp | Tests: typing status.
| relay/ | Root of unit tests for Relay plugin.
| test-relay-auth.cpp | Tests: clients authentication.
| test-relay-http.cpp | Tests: HTTP functions for Relay plugin.
| test-relay-remote.cpp | Tests: remote functions for Relay plugin.
| test-relay-websocket.cpp | Tests: websocket functions for Relay plugin.
| api/ | Root of unit tests for Relay "api" protocol.
| test-relay-api.cpp | Tests: Relay "api" protocol: general functions.
| test-relay-api-msg.cpp | Tests: Relay "api" protocol: messages.
| test-relay-api-protocol.cpp | Tests: Relay "api" protocol: protocol.
| irc/ | Root of unit tests for Relay "irc" protocol.
| test-relay-irc.cpp | Tests: Relay "irc" protocol.
| xfer/ | Root of unit tests for Xfer plugin.
| test-xfer-file.cpp | Tests: file functions.
| test-xfer-network.cpp | Tests: network functions.
|===
[[documentation_translations]]
=== Documentation / translations
Documentation files:
[width="100%",cols="2m,3",options="header"]
|===
| Path/file | Description
| doc/ | Documentation.
| docinfo.html | Asciidoctor style.
| XX/ | Documentation for language XX (languages: en, fr, de, it, ...).
| weechat.1.XX.adoc | Man page (`man weechat`).
| weechat_dev.XX.adoc | link:weechat_dev.en.html[Developer's guide ^↗^^] (this document).
| weechat_faq.XX.adoc | link:weechat_faq.en.html[FAQ ^↗^^].
| weechat_plugin_api.XX.adoc | link:weechat_plugin_api.en.html[Plugin API reference ^↗^^].
| weechat_quickstart.XX.adoc | link:weechat_quickstart.en.html[Quickstart guide ^↗^^].
| weechat_relay_protocol.XX.adoc | link:weechat_relay_protocol.en.html[Relay protocol ^↗^^] (for remote interfaces).
| weechat_scripting.XX.adoc | link:weechat_scripting.en.html[Scripting guide ^↗^^].
| weechat_user.XX.adoc | link:weechat_user.en.html[User's guide ^↗^^].
| includes/ | Files included in documentation.
| cmdline_options.XX.adoc | Command-line options (file included in man pages and user's guide).
| man.XX.adoc | Part of man pages: plugin options, files and copyright.
|===
Translations for WeeChat and plugins are done with gettext, files are in _po/_
directory:
[width="100%",cols="2m,3",options="header"]
|===
| Path/file | Description
| po/ | Translation files (gettext).
| XX.po | Translations for language XX (fr, de, it, ...), base language is English.
| weechat.pot | Template for translations (auto-built).
|===
[[coding_rules]]
== Coding rules
[[coding_general_rules]]
=== General rules
* In source code, your comments, variable names, .. must be written in English
*only* (no other language is allowed).
* Use a copyright header in each new source file with:
** short description of file (one line),
** date,
** name,
** e-mail,
** license.
Example in C:
[source,c]
----
/*
* weechat.c - core functions for WeeChat
*
* Copyright (C) 2024 Your Name <your@email.com>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat 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.
*
* WeeChat 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 WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
----
[[coding_c_style]]
=== C style
Some basic rules you *must* follow when you write C code:
* Use 4 spaces for indentation (no tabs).
* Try to not exceed 80 chars by line, except if this is needed to increase readability.
* Use comments `+/* comment */+` (not C99-style comments like `+// comment+`).
* Add a comment before any function, to explain what it does (always use a
multi-line comment, even if description is very short).
Example:
[source,c]
----
/*
* Checks if a string with boolean value is valid.
*
* Returns:
* 1: boolean value is valid
* 0: boolean value is NOT valid
*/
int
foo ()
{
int i;
/* one line comment */
i = 1;
/*
* multi-line comment: this is a very long description about next block
* of code
*/
i = 2;
printf ("%d\n", i);
}
----
* Use explicit variable names, for example "nicks_count" instead of "n" or "nc".
Exception: in `for` loops, where variables like "i" or "n" are OK.
* Initialize local variables after declaration, in body of function, example:
[source,c]
----
void
foo ()
{
int nick_count, buffer_count;
nick_count = 0;
buffer_count = 1;
/* ... */
}
----
* Use parentheses to explicitly show how expression is evaluated, even if
they are not required, for example: write `+x + (y * z)+` instead of `+x + y * z+`.
* Place curly brackets `+{ }+` alone on lines, and indent them with number of
spaces used for line above opening curly bracket (the `if` in example):
[source,c]
----
if (nicks_count == 1)
{
/* something */
}
----
* Use empty lines to separate many different blocks inside functions, and if
possible add a comment for each one, like this:
[source,c]
----
/*
* Sends a message from out queue.
*/
void
irc_server_outqueue_send (struct t_irc_server *server)
{
/* ... */
/* send signal with command that will be sent to server */
irc_server_send_signal (server, "irc_out",
server->outqueue[priority]->command,
server->outqueue[priority]->message_after_mod,
NULL);
tags_to_send = irc_server_get_tags_to_send (server->outqueue[priority]->tags);
irc_server_send_signal (server, "irc_outtags",
server->outqueue[priority]->command,
server->outqueue[priority]->message_after_mod,
(tags_to_send) ? tags_to_send : "");
if (tags_to_send)
free (tags_to_send);
/* send command */
irc_server_send (server, server->outqueue[priority]->message_after_mod,
strlen (server->outqueue[priority]->message_after_mod));
server->last_user_message = time_now;
/* start redirection if redirect is set */
if (server->outqueue[priority]->redirect)
{
irc_redirect_init_command (server->outqueue[priority]->redirect,
server->outqueue[priority]->message_after_mod);
}
/* ... */
}
----
* Indent the `if` conditions, and use parentheses around conditions with an
operator (not needed for single boolean), like this:
[source,c]
----
if (something)
{
/* something */
}
else
{
/* something else */
}
if (my_boolean1 && my_boolean2 && (i == 10)
&& ((buffer1 != buffer2) || (window1 != window2)))
{
/* something */
}
else
{
/* something else */
}
----
* Indent the `switch` statements like this:
[source,c]
----
switch (string[0])
{
case 'A': /* first case */
foo ("abc", "def");
break;
case 'B': /* second case */
bar (1, 2, 3);
break;
default: /* other cases */
baz ();
break;
}
----
* Use `typedef` for function prototypes but not for structures:
[source,c]
----
typedef int (t_hook_callback_fd)(void *data, int fd);
struct t_hook_fd
{
t_hook_callback_fd *callback; /* fd callback */
int fd; /* socket or file descriptor */
int flags; /* fd flags (read,write,..) */
int error; /* contains errno if error occurred */
/* with fd */
};
/* ... */
struct t_hook_fd *new_hook_fd;
new_hook_fd = malloc (sizeof (*new_hook_fd));
----
* This Lisp code can be used in your _~/.emacs.el_ to indent properly if you are
using Emacs as text editor:
[source,lisp]
----
(add-hook 'c-mode-common-hook
'(lambda ()
(c-toggle-hungry-state t)
(c-set-style "k&r")
(setq c-basic-offset 4)
(c-tab-always-indent t)
(c-set-offset 'case-label '+)))
----
[[coding_python_style]]
=== Python style
See https://www.python.org/dev/peps/pep-0008/[PEP 8 ^↗^^].
[[core_internals]]
== Core internals
[[naming_convention]]
=== Naming convention
[[naming_convention_files]]
==== Files
File names are composed by letters and hyphens, with format: _xxx-yyyyy.[ch]_,
where _xxx_ is directory/component (can be abbreviation) and _yyyyy_ a name for
the file.
The main file of a directory may have same name as directory, for example
_irc.c_ in irc plugin.
Examples:
[width="100%",cols="2m,3",options="header"]
|===
| Directory | Files
| src/core/ | weechat.c, core-backtrace.c, core-command.c, ...
| src/gui/ | gui-bar.c, gui-bar-item.c, gui-bar-window.c, ...
| src/gui/curses/ | gui-curses-bar.c, gui-curses-bar-window.c, gui-curses-chat.c, ...
| src/plugins/ | plugin.c, plugin-api.c, plugin-api-info.c, plugin-config.c, plugin-script.c, ...
| src/plugins/irc/ | irc.c, irc-bar-item.c, irc-buffer.c, ...
| src/plugins/python/ | weechat-python.c, weechat-python-api.c, ...
|===
The headers of C files have same name as file, for example _core-command.h_ for
file _core-command.c_.
[[naming_convention_structures]]
==== Structures
Structures have name _t_X_Y_ or _t_X_Y_Z_:
* _X_: directory/component (can be abbreviation)
* _Y_: end of file name
* _Z_: name for structure (optional)
Example: an IRC nick (from _src/plugins/irc/irc-nick.h_):
[source,c]
----
struct t_irc_nick
{
char *name; /* nickname */
char *host; /* full hostname */
char *prefixes; /* string with prefixes enabled for nick */
char prefix[2]; /* current prefix (higher prefix set in */
/* prefixes) */
int away; /* 1 if nick is away */
char *color; /* color for nickname in chat window */
struct t_irc_nick *prev_nick; /* link to previous nick on channel */
struct t_irc_nick *next_nick; /* link to next nick on channel */
};
----
[[naming_convention_variables]]
==== Variables
Global variables (outside functions) have name _X_Y_Z_:
* _X_: directory/component (can be abbreviation)
* _Y_: end of file name
* _Z_: name for variable
Exception are variables for "last" node of a list, name is _last_X_ (where
_X_ is name of variable, using singular form).
Example: windows (from _src/gui/gui-window.c_):
[source,c]
----
struct t_gui_window *gui_windows = NULL; /* first window */
struct t_gui_window *last_gui_window = NULL; /* last window */
struct t_gui_window *gui_current_window = NULL; /* current window */
----
There is no naming convention for local variables (in functions). The only
recommendation is that name is explicit (not too short). +
Nevertheless, pointers to structures are often named _ptr_xxxx_, for example a
pointer on a _struct t_gui_buffer *_ will be: _*ptr_buffer_.
[[naming_convention_functions]]
==== Functions
Naming convention for functions is the same as
<<naming_convention_variables,variables>>.
Example: creation of a new window (from _src/gui/gui-window.c_):
[source,c]
----
/*
* Creates a new window.
*
* Returns pointer to new window, NULL if error.
*/
struct t_gui_window *
gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
int x, int y, int width, int height,
int width_pct, int height_pct)
{
/* ... */
return new_window;
}
----
[[single_thread]]
=== Single thread
WeeChat is single threaded. That means every part of code should execute very
fast, and that calls to functions like `sleep` are *strictly forbidden* (it is
true for WeeChat core, but also C plugins and scripts).
If for some reasons you have to sleep a while, use `hook_timer` with a callback.
[[doubly_linked_lists]]
=== Doubly linked lists
Most of WeeChat lists are doubly linked lists: each node has pointer to previous
and next node.
Example: list of buffers (from _src/gui/gui-buffer.h_):
[source,c]
----
struct t_gui_buffer
{
/* data */
/* ... */
struct t_gui_buffer *prev_buffer; /* link to previous buffer */
struct t_gui_buffer *next_buffer; /* link to next buffer */
};
----
Then the two list pointers, to the head and tail of list:
[source,c]
----
struct t_gui_buffer *gui_buffers = NULL; /* first buffer */
struct t_gui_buffer *last_gui_buffer = NULL; /* last buffer */
----
[[color_codes_in_strings]]
=== Color codes in strings
WeeChat uses own color codes in strings to display attributes (bold,
underline, ...) and colors on screen.
All attributes/colors are prefixed with a char in string, which can be:
* _0x19_: color code (followed by color code(s))
* _0x1A_: set attribute (followed by raw attribute on one char)
* _0x1B_: remove attribute (followed by raw attribute on one char)
* _0x1C_: reset (nothing after)
Possible colors are:
* standard color: optional attributes + number on 2 digits
* extended color: `+@+` + optional attributes + number on 5 digits
In following table, these conventions are used:
* `STD`: standard color (2 digits)
* `(ATTR)STD`: standard color with optional attributes (attributes + 2 digits)
* `EXT`: extended color (`+@+` + 5 digits)
* `(ATTR)EXT`: extended color with optional attributes (`+@+` + attributes + 5 digits)
* `(ATTR)`: one or more attribute chars:
** `+%+`: blink
** `+.+`: "dim" (half bright)
** `+*+`: bold
** `+!+`: reverse
** `+/+`: italic
** `+_+`: underline
** `+|+`: keep attributes
* `(a)`: one raw attribute char:
** _0x01_: bold
** _0x02_: reverse
** _0x03_: italic
** _0x04_: underline
** _0x05_: blink
** _0x06_: "dim" (half bright)
All combinations are summarized in this table:
[width="100%",cols="4,3,2,8",options="header"]
|===
| Code | Example | Areas | Description
| [hex]#19# + `STD` | [hex]#19# `+01+` | chat + bars | Set attributes and color using option, see table below.
| [hex]#19# + `EXT` | [hex]#19# `+@00001+` | chat | Set color with a ncurses pair (used only on `/color` buffer).
| [hex]#19# + `F` + `(ATTR)STD` | [hex]#19# `+F*05+` | chat + bars | Set foreground (WeeChat color).
| [hex]#19# + `F` + `(ATTR)EXT` | [hex]#19# `+F@00214+` | chat + bars | Set foreground (extended color).
| [hex]#19# + `B` + `STD` | [hex]#19# `+B05+` | chat + bars | Set background (WeeChat color).
| [hex]#19# + `B` + `EXT` | [hex]#19# `+B@00124+` | chat + bars | Set background (extended color).
| [hex]#19# + `*` + `(ATTR)STD` | [hex]#19# `+*05+` | chat + bars | Set foreground (WeeChat color).
| [hex]#19# + `*` + `(ATTR)EXT` | [hex]#19# `+*@00214+` | chat + bars | Set foreground (extended color).
| [hex]#19# + `*` + `(ATTR)STD` + `,` + `STD` ^(1)^ | [hex]#19# `+*08,05+` | chat + bars | Set foreground/background (WeeChat colors).
| [hex]#19# + `*` + `(ATTR)STD` + `,` + `EXT` ^(1)^ | [hex]#19# `+*01,@00214+` | chat + bars | Set foreground (WeeChat color) and background (extended color).
| [hex]#19# + `*` + `(ATTR)EXT` + `,` + `STD` ^(1)^ | [hex]#19# `+*@00214,05+` | chat + bars | Set foreground (extended color) and background (WeeChat color).
| [hex]#19# + `*` + `(ATTR)EXT` + `,` + `EXT` ^(1)^ | [hex]#19# `+*@00214,@00017+` | chat + bars | Set foreground/background (extended colors).
| [hex]#19# + `*` + `(ATTR)STD` + `~` + `STD` | [hex]#19# `+*08~05+` | chat + bars | Set foreground/background (WeeChat colors).
| [hex]#19# + `*` + `(ATTR)STD` + `~` + `EXT` | [hex]#19# `+*01~@00214+` | chat + bars | Set foreground (WeeChat color) and background (extended color).
| [hex]#19# + `*` + `(ATTR)EXT` + `~` + `STD` | [hex]#19# `+*@00214~05+` | chat + bars | Set foreground (extended color) and background (WeeChat color).
| [hex]#19# + `*` + `(ATTR)EXT` + `~` + `EXT` | [hex]#19# `+*@00214~@00017+` | chat + bars | Set foreground/background (extended colors).
| [hex]#19# + `b` + `F` | [hex]#19# `+bF+` | bars | Set bar foreground color.
| [hex]#19# + `b` + `D` | [hex]#19# `+bD+` | bars | Set bar delimiter color.
| [hex]#19# + `b` + `B` | [hex]#19# `+bB+` | bars | Set bar background color.
| [hex]#19# + `b` + `_` | [hex]#19# `+b_+` | input bar | Start input char (used only in item "input_text").
| [hex]#19# + `b` + `-` | [hex]#19# `+b-+` | input bar | Start input hidden char (used only in item "input_text").
| [hex]#19# + `b` + `#` | [hex]#19# `+b#+` | input bar | Move cursor char (used only in item "input_text").
| [hex]#19# + `b` + `i` | [hex]#19# `+bi+` | bars | Start item.
| [hex]#19# + `b` + `l` (lower L) | [hex]#19# `+bl+` | bars | Start line item.
| [hex]#19# + `E` | [hex]#19# `+E+` | chat + bars | Emphasize text _(WeeChat ≥ 0.4.2)_.
| [hex]#19# + [hex]#1C# | [hex]#19# [hex]#1C# | chat + bars | Reset color (keep attributes).
| [hex]#1A# + `(a)` | [hex]#1A# [hex]#01# | chat + bars | Set attribute.
| [hex]#1B# + `(a)` | [hex]#1B# [hex]#01# | chat + bars | Remove attribute.
| [hex]#1C# | [hex]#1C# | chat + bars | Reset attributes and color.
|===
[NOTE]
^(1)^ The use of comma as separator was used until WeeChat 2.5. +
With WeeChat ≥ 2.6, a tilde is used to separate foreground from background
color. If you are developing a WeeChat relay client and want to be compatible
with all WeeChat versions, you should support both separators (for example if a
user with WeeChat ≤ 2.5 runs `/upgrade` to a version ≥ 2.6, both separators
could be used at same time in buffers).
Color codes using options (see _t_gui_color_enum_, in file
_src/gui/gui-color.h_):
[width="80%",cols="^1m,10",options="header"]
|===
| Code | Option
| 00 | weechat.color.separator
| 01 | weechat.color.chat
| 02 | weechat.color.chat_time
| 03 | weechat.color.chat_time_delimiters
| 04 | weechat.color.chat_prefix_error
| 05 | weechat.color.chat_prefix_network
| 06 | weechat.color.chat_prefix_action
| 07 | weechat.color.chat_prefix_join
| 08 | weechat.color.chat_prefix_quit
| 09 | weechat.color.chat_prefix_more
| 10 | weechat.color.chat_prefix_suffix
| 11 | weechat.color.chat_buffer
| 12 | weechat.color.chat_server
| 13 | weechat.color.chat_channel
| 14 | weechat.color.chat_nick
| 15 | weechat.color.chat_nick_self
| 16 | weechat.color.chat_nick_other
| 17 | _(not used any more since WeeChat 0.3.4)_
| 18 | _(not used any more since WeeChat 0.3.4)_
| 19 | _(not used any more since WeeChat 0.3.4)_
| 20 | _(not used any more since WeeChat 0.3.4)_
| 21 | _(not used any more since WeeChat 0.3.4)_
| 22 | _(not used any more since WeeChat 0.3.4)_
| 23 | _(not used any more since WeeChat 0.3.4)_
| 24 | _(not used any more since WeeChat 0.3.4)_
| 25 | _(not used any more since WeeChat 0.3.4)_
| 26 | _(not used any more since WeeChat 0.3.4)_
| 27 | weechat.color.chat_host
| 28 | weechat.color.chat_delimiters
| 29 | weechat.color.chat_highlight
| 30 | weechat.color.chat_read_marker
| 31 | weechat.color.chat_text_found
| 32 | weechat.color.chat_value
| 33 | weechat.color.chat_prefix_buffer
| 34 | weechat.color.chat_tags _(WeeChat ≥ 0.3.6)_
| 35 | weechat.color.chat_inactive_window _(WeeChat ≥ 0.3.6)_
| 36 | weechat.color.chat_inactive_buffer _(WeeChat ≥ 0.3.6)_
| 37 | weechat.color.chat_prefix_buffer_inactive_buffer _(WeeChat ≥ 0.3.6)_
| 38 | weechat.color.chat_nick_offline _(WeeChat ≥ 0.3.9)_
| 39 | weechat.color.chat_nick_offline_highlight _(WeeChat ≥ 0.3.9)_
| 40 | weechat.color.chat_nick_prefix _(WeeChat ≥ 0.4.1)_
| 41 | weechat.color.chat_nick_suffix _(WeeChat ≥ 0.4.1)_
| 42 | weechat.color.emphasized _(WeeChat ≥ 0.4.2)_
| 43 | weechat.color.chat_day_change _(WeeChat ≥ 0.4.2)_
| 44 | weechat.color.chat_value_null _(WeeChat ≥ 1.4)_
| 45 | weechat.color.chat_status_disabled _(WeeChat ≥ 4.0.0)_
| 46 | weechat.color.chat_status_enabled _(WeeChat ≥ 4.0.0)_
|===
WeeChat colors are:
[width="80%",cols="^1m,10",options="header"]
|===
| Code | Color
| 00 | Default (terminal foreground/background)
| 01 | Black
| 02 | Dark gray
| 03 | Dark red
| 04 | Light red
| 05 | Dark green
| 06 | Light green
| 07 | Brown
| 08 | Yellow
| 09 | Dark blue
| 10 | Light blue
| 11 | Dark magenta
| 12 | Light magenta
| 13 | Dark cyan
| 14 | Light cyan
| 15 | Gray
| 16 | White
|===
Examples of color codes:
[width="100%",cols="1,2",options="header"]
|===
| Code | Description
| [hex]#19# `+01+` | Color of option "01" (chat text)
| [hex]#19# `+*08,03+` | Yellow on red
| [hex]#19# `+*@00214+` | Orange (extended color 214)
| [hex]#19# `+*@*_00214,@00017+` | Bold underlined orange (214) on dark blue (17)
| [hex]#1A# `+_+` | Set underline
| [hex]#1B# `+_+` | Remove underline
| [hex]#1C# | Reset attributes and color
|===
[[plugin_internals]]
== Plugin internals
The file _src/plugins/weechat-plugin.h_ defines and exports all functions
available in the API.
A structure called _t_weechat_plugin_ is used to store info about plugin
(filename, name, author, description, ...) and all API functions, as pointers
to WeeChat functions.
Then some macros are defined to call these functions.
For example, function _hook_timer_ is defined in structure _t_weechat_plugin_
like this:
[source,c]
----
struct t_hook *(*hook_timer) (struct t_weechat_plugin *plugin,
long interval,
int align_second,
int max_calls,
int (*callback)(void *data,
int remaining_calls),
void *callback_data);
----
And the macro used to call this function is:
[source,c]
----
#define weechat_hook_timer(__interval, __align_second, __max_calls, \
__callback, __data) \
weechat_plugin->hook_timer(weechat_plugin, __interval, \
__align_second, __max_calls, \
__callback, __data)
----
So in a plugin, the call to function will be for example:
[source,c]
----
server->hook_timer_sasl = weechat_hook_timer (timeout * 1000,
0, 1,
&irc_server_timer_sasl_cb,
server);
----
[[contribute]]
== Contribute to WeeChat
[[git_repository]]
=== Git repository
Git repository is on https://github.com/weechat/weechat[GitHub ^↗^^].
Any patch for bug or new feature must be done on master branch, preferred way
is a GitHub pull request. A patch can also be sent by e-mail
(made with `git diff` or `git format-patch`).
Format of commit message is the following (with automatic close of a GitHub issue):
----
component: fix a problem (closes #123)
----
Where _component_ is one of following:
[width="100%",cols="1m,4m,5",options="header"]
|===
| Component | Files | Description
| core
| AUTHORS.md +
CHANGELOG.md +
CONTRIBUTING.md +
.github/FUNDING.yml +
.github/ISSUE_TEMPLATE/* +
icons/* +
po/* +
README.md +
UPGRADING.md +
src/core/* +
src/gui/* +
version.sh +
weechat.desktop
| WeeChat core
| build
| CMakeLists.txt +
cmake/* +
tools/* +
weechat.cygport.in
| Build
| ci
| .github/workflows/*
| Continuous integration
| debian
| debian-devel/* +
debian-stable/*
| Debian packaging
| tests
| tests/*
| Tests
| doc
| doc/*
| General doc updates, for example build
| doc/man
| doc/xx/weechat.1.xx.adoc +
doc/xx/weechat-headless.1.xx.adoc
| Man pages
| doc/faq
| doc/xx/weechat_faq.xx.adoc
| Frequently asked questions (FAQ)
| doc/quickstart
| doc/xx/weechat_quickstart.xx.adoc
| Quickstart guide
| doc/user
| doc/xx/weechat_user.xx.adoc
| User's guide
| doc/scripting
| doc/xx/weechat_scripting.xx.adoc
| Scripting guide
| doc/api
| doc/xx/weechat_plugin_api.xx.adoc
| Plugin API reference
| doc/relay
| doc/xx/weechat_relay_protocol.xx.adoc
| Relay protocol
| doc/dev
| doc/xx/weechat_dev.en.adoc
| Developer's guide
| irc +
python +
relay +
…
| src/plugins/<name>/*
| Plugin
|===
Some rules to follow:
* Use only English.
* Use infinitive form of verb.
* If commit is related to a GitHub issue, write it in parenthesis after
the message, with this format: `(issue #123)` or `(closes #123)` to close it.
Examples of commit messages:
----
core: add callback "nickcmp" for nick comparison in buffers
core: update Japanese translations
doc/user: add chapter on typing extension
irc: add command /unquiet (closes #36)
python: fix crash when unloading a script without pointer to interpreter
ruby: add detection of ruby version 1.9.3 in CMake
----
[[translations]]
=== Translations
[[gettext]]
==== Gettext
Gettext files are in directory _po/_.
If you want to initialize a new language, use command `msginit`. For example to
create a file which is ready to translate to Dutch:
----
$ cd po
$ msginit -i weechat.pot -l nl_NL -o nl.po
----
Base language for WeeChat is English, so you must of course perfectly understand
English in order to translate to your language.
After changes in sources, you can regenerate all translations files: run this
command in the CMake "build" directory:
----
$ make translations && make update-po
----
Then you can edit .po files (if you can translate in a language).
When done, you *have* to check your file with
https://github.com/flashcode/msgcheck[msgcheck ^↗^^]:
----
$ msgcheck.py xx.po
----
And then you can recompile WeeChat to use the new translations.
[[asciidoc]]
==== Asciidoc
Asciidoc files are in directory _doc/XX/_ where _XX_ is language (en, fr, de,
it, ...).
First make a copy of an English asciidoc file (in directory _doc/en/_), then
work on it.
The translations missing in files are indicated by this string:
----
// TRANSLATION MISSING
----
You must translate whole file except links and special keywords for notes,
warnings, ... These words must be kept unchanged:
----
[[link_name]]
<<link_name>>
[NOTE]
[TIP]
[IMPORTANT]
[WARNING]
[CAUTION]
----
When there is a name after `+<<link_name>>+`, then you must translate it:
----
<<link_name,this text must be translated>>
----
|