This manual documents WeeChat chat client, it is part of WeeChat.
Latest version of this document can be found on this page ↗.
1. 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.
2. Repositories
WeeChat repositories are on GitHub organization weechat ↗.
List of repositories:
- weechat
-
core repository with source code and documentation
- scripts
-
the official scripts submitted on weechat.org
- weechat.org
-
source of WeeChat website ↗
- weercd
-
IRC testing server
- qweechat
-
Qt remote GUI for WeeChat.
This manual documents only weechat repository.
2.1. Overview
The main WeeChat directories are:
Directory | Description |
---|---|
|
Root of sources. |
|
Core functions: entry point, internal structures. |
|
Hook functions. |
|
Functions for buffers, windows, … (used by all interfaces). |
|
Curses interface. |
|
Headless mode (no interface). |
|
Curses interface. |
|
Plugin and scripting API. |
|
Alias plugin. |
|
Buflist plugin. |
|
Charset plugin. |
|
Exec plugin. |
|
Fifo plugin (FIFO pipe used to remotely send commands to WeeChat). |
|
Fset (Fast Set) plugin. |
|
Guile (scheme) scripting API. |
|
IRC (Internet Relay Chat) plugin. |
|
JavaScript scripting API. |
|
Logger plugin (write messages displayed to files). |
|
Lua scripting API. |
|
Perl scripting API. |
|
PHP scripting API. |
|
Python scripting API. |
|
Relay plugin (irc proxy + relay for remote interfaces). |
|
Ruby scripting API. |
|
Script manager. |
|
Spell plugin. |
|
Tcl scripting API. |
|
Trigger plugin. |
|
Typing plugin. |
|
Xfer plugin (IRC DCC file/chat). |
|
Tests. |
|
Scripting API tests. |
|
Python scripts to generate and run the scripting API tests. |
|
Unit tests. |
|
Unit tests for core functions. |
|
Unit tests for interfaces functions. |
|
Unit tests for plugins. |
|
Unit tests for IRC plugin. |
|
Unit tests for trigger plugin. |
|
Documentation. |
|
Translations files (gettext). |
|
Debian packaging. |
2.2. Sources
Core
WeeChat "core" is located in following directories:
-
src/core/: core functions (for data manipulation)
-
src/gui/: functions about interface (buffers, windows, …)
Path/file | Description |
---|---|
|
Core functions: entry point, internal structures. |
|
Array lists. |
|
Display a backtrace after a crash. |
|
Calculate result of expressions. |
|
WeeChat core commands. |
|
Default completions. |
|
Configuration file management. |
|
Configuration options for WeeChat core (file weechat.conf). |
|
Cryptographic functions. |
|
Some debug functions. |
|
Build of files for documentation. |
|
Directory/file functions. |
|
Evaluation of expressions with references to internal vars. |
|
Hashtables. |
|
Hdata (direct access to data using hashtables). |
|
Hooks. |
|
Infolists (lists with objects data). |
|
Input of commands/text. |
|
Sorted lists. |
|
Write to WeeChat log file (weechat.log). |
|
Network functions (connection to servers/proxies). |
|
Proxy management. |
|
Secured data functions. |
|
Secured data buffer. |
|
Secured data options (file sec.conf). |
|
Signal functions. |
|
Functions on strings. |
|
System functions. |
|
Internal upgrade system. |
|
Upgrade for WeeChat core (buffers, lines, history, …). |
|
URL transfer (using libcurl). |
|
UTF-8 functions. |
|
Some other functions. |
|
Functions for WeeChat version. |
|
Main functions: command line options, startup. |
|
Hook functions. |
|
Hook "command_run". |
|
Hook "command". |
|
Hook "completion". |
|
Hook "config". |
|
Hook "connect". |
|
Hook "fd". |
|
Hook "focus". |
|
Hook "hdata". |
|
Hook "hsignal". |
|
Hook "info_hashtable". |
|
Hook "info". |
|
Hook "infolist". |
|
Hook "line". |
|
Hook "modifier". |
|
Hook "print". |
|
Hook "process". |
|
Hook "signal". |
|
Hook "timer". |
|
Hook "url". |
|
Functions for buffers, windows, … (used by all interfaces). |
|
Bar items. |
|
Bar windows. |
|
Bars. |
|
Buffers. |
|
Chat functions (display message, …). |
|
Color functions. |
|
Completion on command line. |
|
Cursor mode (free movement of cursor). |
|
Filters. |
|
Functions about focus (for cursor mode and mouse). |
|
Commands/text saved in buffers. |
|
Hotlist management (list of buffers with activity). |
|
Input functions (input bar). |
|
Keyboard functions. |
|
Layout. |
|
Lines in buffers. |
|
Mouse. |
|
Nick functions. |
|
Nicklist in buffers. |
|
Windows. |
|
Curses interface. |
|
Display in bar windows. |
|
Display in chat area (messages). |
|
Color functions. |
|
Keyboard functions (default keys, read of input). |
|
WeeChat main loop (waiting for keyboard/network events). |
|
Mouse. |
|
Functions about terminal. |
|
Windows. |
|
Headless mode (no interface). |
|
Entry point for headless mode. |
|
Fake ncurses library. |
|
Curses interface. |
|
Entry point for Curses interface. |
Plugins
Path/file | Description |
---|---|
|
Root of plugins. |
|
Plugins management (load/unload dynamic C libraries). |
|
Extra functions for plugin API (wrapper around WeeChat core functions). |
|
Extra info/infolist functions for plugin API. |
|
Plugin configuration options (file plugins.conf). |
|
Common functions used by script plugins. |
|
Script API functions: wrappers around some plugin API functions. |
|
Script plugin configuration options (files python.conf, perl.conf, …). |
|
Header designed to be distributed with WeeChat plugins, in order to compile them. |
|
Alias plugin. |
|
Main alias functions. |
|
Alias commands. |
|
Alias completions. |
|
Alias config options (file alias.conf). |
|
Alias info/infolists/hdata. |
|
Spell checker plugin. |
|
Main spell checker functions. |
|
Spell checker bar items. |
|
Spell checker commands. |
|
Spell checker completions. |
|
Spell checker config options (file spell.conf). |
|
Spell checker info/infolists/hdata. |
|
Spellers management. |
|
Buflist plugin. |
|
Main buflist functions. |
|
Buflist bar items. |
|
Buflist commands. |
|
Buflist completions. |
|
Buflist config options (file buflist.conf). |
|
Buflist info/infolists/hdata. |
|
Buflist mouse actions. |
|
Charset plugin. |
|
Charset functions. |
|
Exec plugin. |
|
Main exec functions. |
|
Exec buffer. |
|
Exec commands. |
|
Exec completions. |
|
Exec config options (file exec.conf). |
|
Fifo plugin. |
|
Main fifo functions. |
|
Fifo commands. |
|
Fifo config options (file fifo.conf). |
|
Fifo info/infolists/hdata. |
|
Fset plugin. |
|
Main fset functions. |
|
Fset bar items. |
|
Fset buffer. |
|
Fset commands. |
|
Fset completions. |
|
Fset config options (file fset.conf). |
|
Fset info/infolists/hdata. |
|
Fset mouse actions. |
|
Fset options management. |
|
Guile (scheme) plugin. |
|
Main guile functions (load/unload scripts, execute guile code). |
|
Guile scripting API functions. |
|
IRC (Internet Relay Chat) plugin. |
|
Main IRC functions. |
|
IRC bar items. |
|
IRC batched events. |
|
IRC buffers. |
|
IRC channels. |
|
IRC colors. |
|
IRC commands. |
|
IRC completions. |
|
IRC config options (file irc.conf). |
|
IRC CTCP. |
|
IRC debug functions. |
|
IRC Ignore. |
|
IRC info/infolists/hdata. |
|
Input of commands/text. |
|
Functions for list of channels to join. |
|
Buffer for reply to /list command. |
|
Functions to manipulate IRC messages. |
|
Functions about channel/nick modes. |
|
IRC channel mode lists (+b, +e, +I, …). |
|
Target buffer for IRC messages. |
|
IRC nicks. |
|
IRC notify lists. |
|
IRC protocol (RFCs 1459/2810/2811/2812/2813/7194). |
|
IRC raw buffer. |
|
Redirection of IRC command output. |
|
SASL authentication with IRC server. |
|
I/O communication with IRC server. |
|
Functions to manipulate IRC message tags. |
|
Typing status. |
|
Save/restore of IRC data when upgrading WeeChat. |
|
JavaScript plugin. |
|
Main JavaScript functions (load/unload scripts, execute JavaScript code). |
|
JavaScript scripting API functions. |
|
JavaScript v8 functions. |
|
Logger plugin. |
|
Main logger functions. |
|
Logger backlog functions. |
|
Logger buffer list management. |
|
Logger commands. |
|
Logger config options (file logger.conf). |
|
Logger info/infolists/hdata. |
|
Functions to get last lines of a file. |
|
Lua plugin. |
|
Main lua functions (load/unload scripts, execute lua code). |
|
Lua scripting API functions. |
|
Perl plugin. |
|
Main perl functions (load/unload scripts, execute perl code). |
|
Perl scripting API functions. |
|
PHP plugin. |
|
Main PHP functions (load/unload scripts, execute PHP code). |
|
PHP scripting API functions. |
|
Python plugin. |
|
Main python functions (load/unload scripts, execute python code). |
|
Python scripting API functions. |
|
Relay plugin (IRC proxy and relay for remote interfaces). |
|
Main relay functions. |
|
Clients authentication. |
|
Relay buffer. |
|
Clients of relay. |
|
Relay commands. |
|
Relay completions. |
|
Relay config options (file relay.conf). |
|
Relay info/infolists/hdata. |
|
Network functions for relay. |
|
Relay raw buffer. |
|
Relay server. |
|
Save/restore of relay data when upgrading WeeChat. |
|
WebSocket server functions (RFC 6455). |
|
IRC proxy. |
|
Main IRC proxy functions. |
|
Relay for remote interfaces. |
|
Relay for remote interfaces (main functions). |
|
Send binary messages to clients. |
|
Nicklist functions. |
|
Read commands from clients. |
|
Ruby plugin. |
|
Main ruby functions (load/unload scripts, execute ruby code). |
|
Ruby scripting API functions. |
|
Script manager. |
|
Main functions for script manager. |
|
Actions on scripts (load/unload, install/remove, …). |
|
Buffer for script manager. |
|
Commands for script manager. |
|
Completions for script manager. |
|
Config options for script manager (file script.conf). |
|
Script manager info/infolists/hdata. |
|
Script mouse actions. |
|
Download and read repository file. |
|
Tcl plugin. |
|
Main tcl functions (load/unload scripts, execute tcl code). |
|
Tcl scripting API functions. |
|
Trigger plugin. |
|
Main trigger functions. |
|
Trigger buffer. |
|
Trigger callbacks. |
|
Trigger commands. |
|
Trigger completions. |
|
Trigger config options (file trigger.conf). |
|
Typing plugin. |
|
Main typing functions. |
|
Typing bar items. |
|
Typing config options (file typing.conf). |
|
Messages typing status on buffers. |
|
Xfer plugin (IRC DCC file/chat). |
|
Main xfer functions. |
|
Xfer buffer. |
|
DCC chat. |
|
Xfer commands. |
|
Xfer completions. |
|
Xfer config options (file xfer.conf). |
|
DCC file transfer. |
|
File functions for xfer. |
|
Xfer info/infolists/hdata. |
|
Network functions for xfer. |
|
Save/restore of xfer data when upgrading WeeChat. |
Tests
Path/file | Description |
---|---|
|
Root of tests. |
|
Program used to run all tests. |
|
Record and search in messages displayed. |
|
Root of scripting API tests. |
|
Program used to run the scripting API tests. |
|
Python scripts to generate and run the scripting API tests. |
|
Python script generating scripts in all languages to test the scripting API. |
|
Python script with scripting API tests, used by script testapigen.py. |
|
Convert Python code to other languages, used by script testapigen.py. |
|
Root of unit tests. |
|
Tests: plugins. |
|
Tests: plugin API info functions. |
|
Tests: plugin config functions. |
|
Root of unit tests for core. |
|
Tests: arraylists. |
|
Tests: calculation of expressions. |
|
Tests: commands. |
|
Tests: configuration files. |
|
Tests: cryptographic functions. |
|
Tests: directory/file functions. |
|
Tests: evaluation of expressions. |
|
Tests: hashtables. |
|
Tests: hdata. |
|
Tests: hooks. |
|
Tests: infolists. |
|
Tests: lists. |
|
Tests: network functions. |
|
Tests: secured data. |
|
Tests: signals. |
|
Tests: strings. |
|
Tests: URLs. |
|
Tests: UTF-8. |
|
Tests: utility functions. |
|
Tests: system functions. |
|
Root of unit tests for hooks. |
|
Tests: hooks "command". |
|
Root of unit tests for interfaces. |
|
Tests: bar window functions. |
|
Tests: buffer functions. |
|
Tests: chat functions. |
|
Tests: colors. |
|
Tests: filters. |
|
Tests: input functions. |
|
Tests: keys. |
|
Tests: lines. |
|
Tests: nicks. |
|
Root of unit tests for plugins. |
|
Root of unit tests for IRC plugin. |
|
Tests: IRC batched events. |
|
Tests: IRC buffers. |
|
Tests: IRC channels. |
|
Tests: IRC colors. |
|
Tests: IRC configuration. |
|
Tests: IRC CTCP. |
|
Tests: IRC ignores. |
|
Tests: IRC info. |
|
Tests: IRC join functions. |
|
Tests: IRC buffer for reply to /list command. |
|
Tests: IRC messages. |
|
Tests: IRC modes. |
|
Tests: IRC nicks. |
|
Tests: IRC protocol. |
|
Tests: SASL authentication with IRC protocol. |
|
Tests: IRC server. |
|
Tests: IRC message tags. |
|
Root of unit tests for logger plugin. |
|
Tests: logger. |
|
Tests: logger backlog. |
|
Tests: logger tail functions. |
|
Root of unit tests for trigger plugin. |
|
Tests: triggers. |
|
Tests: trigger configuration. |
|
Root of unit tests for typing plugin. |
|
Tests: typing. |
|
Tests: typing status. |
|
Root of unit tests for Relay plugin. |
|
Tests: clients authentication. |
|
Root of unit tests for Relay "irc" protocol. |
|
Tests: Relay "irc" protocol. |
|
Root of unit tests for Xfer plugin. |
|
Tests: file functions. |
|
Tests: network functions. |
2.3. Documentation / translations
Documentation files:
Path/file | Description |
---|---|
|
Documentation. |
|
Asciidoctor style. |
|
Documentation for language XX (languages: en, fr, de, it, …). |
|
Man page ( |
|
Developer’s guide ↗ (this document). |
|
|
|
|
|
|
|
Relay protocol ↗ (for remote interfaces). |
|
|
|
|
|
Files included in documentation. |
|
Command-line options (file included in man pages and user’s guide). |
|
Part of man pages: plugin options, files and copyright. |
Translations for WeeChat and plugins are done with gettext, files are in po/ directory:
Path/file | Description |
---|---|
|
Translation files (gettext). |
|
Translations for language XX (fr, de, it, …), base language is English. |
|
Template for translations (auto-built). |
3. Coding rules
3.1. 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:
/*
* 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/>.
*/
3.2. C style
Some basic rules you must follow when you write C code:
-
Use 4 spaces for indentation. Don’t use tabs, they are evil.
-
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:
/*
* 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:
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 ofx + y * z
. -
Place curly brackets
{ }
alone on lines, and indent them with number of spaces used for line above opening curly bracket (theif
in example):
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:
/*
* 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:
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:
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:
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:
(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 '+)))
3.3. Python style
See PEP 8 ↗.
4. Core internals
4.1. Naming convention
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:
Directory | Files |
---|---|
|
weechat.c, wee-backtrace.c, wee-command.c, … |
|
gui-bar.c, gui-bar-item.c, gui-bar-window.c, … |
|
gui-curses-bar.c, gui-curses-bar-window.c, gui-curses-chat.c, … |
|
plugin.c, plugin-api.c, plugin-api-info.c, plugin-config.c, plugin-script.c, … |
|
irc.c, irc-bar-item.c, irc-buffer.c, … |
|
weechat-python.c, weechat-python-api.c, … |
The headers of C files have same name as file, for example wee-command.h for file wee-command.c.
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):
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 */
};
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):
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.
Functions
Naming convention for functions is the same as variables.
Example: creation of a new window (from src/gui/gui-window.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;
}
4.2. 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.
4.3. 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):
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:
struct t_gui_buffer *gui_buffers = NULL; /* first buffer */
struct t_gui_buffer *last_gui_buffer = NULL; /* last buffer */
4.4. 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:
Code | Example | Areas | Description |
---|---|---|---|
19 + |
19 |
chat + bars |
Set attributes and color using option, see table below. |
19 + |
19 |
chat |
Set color with a ncurses pair (used only on |
19 + |
19 |
chat + bars |
Set foreground (WeeChat color). |
19 + |
19 |
chat + bars |
Set foreground (extended color). |
19 + |
19 |
chat + bars |
Set background (WeeChat color). |
19 + |
19 |
chat + bars |
Set background (extended color). |
19 + |
19 |
chat + bars |
Set foreground (WeeChat color). |
19 + |
19 |
chat + bars |
Set foreground (extended color). |
19 + |
19 |
chat + bars |
Set foreground/background (WeeChat colors). |
19 + |
19 |
chat + bars |
Set foreground (WeeChat color) and background (extended color). |
19 + |
19 |
chat + bars |
Set foreground (extended color) and background (WeeChat color). |
19 + |
19 |
chat + bars |
Set foreground/background (extended colors). |
19 + |
19 |
chat + bars |
Set foreground/background (WeeChat colors). |
19 + |
19 |
chat + bars |
Set foreground (WeeChat color) and background (extended color). |
19 + |
19 |
chat + bars |
Set foreground (extended color) and background (WeeChat color). |
19 + |
19 |
chat + bars |
Set foreground/background (extended colors). |
19 + |
19 |
bars |
Set bar foreground color. |
19 + |
19 |
bars |
Set bar delimiter color. |
19 + |
19 |
bars |
Set bar background color. |
19 + |
19 |
input bar |
Start input char (used only in item "input_text"). |
19 + |
19 |
input bar |
Start input hidden char (used only in item "input_text"). |
19 + |
19 |
input bar |
Move cursor char (used only in item "input_text"). |
19 + |
19 |
bars |
Start item. |
19 + |
19 |
bars |
Start line item. |
19 + |
19 |
chat + bars |
Emphasize text (WeeChat ≥ 0.4.2). |
19 + 1C |
19 1C |
chat + bars |
Reset color (keep attributes). |
1A + |
1A 01 |
chat + bars |
Set attribute. |
1B + |
1B 01 |
chat + bars |
Remove attribute. |
1C |
1C |
chat + bars |
Reset attributes and color. |
(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):
Code | Option |
---|---|
|
weechat.color.separator |
|
weechat.color.chat |
|
weechat.color.chat_time |
|
weechat.color.chat_time_delimiters |
|
weechat.color.chat_prefix_error |
|
weechat.color.chat_prefix_network |
|
weechat.color.chat_prefix_action |
|
weechat.color.chat_prefix_join |
|
weechat.color.chat_prefix_quit |
|
weechat.color.chat_prefix_more |
|
weechat.color.chat_prefix_suffix |
|
weechat.color.chat_buffer |
|
weechat.color.chat_server |
|
weechat.color.chat_channel |
|
weechat.color.chat_nick |
|
weechat.color.chat_nick_self |
|
weechat.color.chat_nick_other |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
(not used any more since WeeChat 0.3.4) |
|
weechat.color.chat_host |
|
weechat.color.chat_delimiters |
|
weechat.color.chat_highlight |
|
weechat.color.chat_read_marker |
|
weechat.color.chat_text_found |
|
weechat.color.chat_value |
|
weechat.color.chat_prefix_buffer |
|
weechat.color.chat_tags (WeeChat ≥ 0.3.6) |
|
weechat.color.chat_inactive_window (WeeChat ≥ 0.3.6) |
|
weechat.color.chat_inactive_buffer (WeeChat ≥ 0.3.6) |
|
weechat.color.chat_prefix_buffer_inactive_buffer (WeeChat ≥ 0.3.6) |
|
weechat.color.chat_nick_offline (WeeChat ≥ 0.3.9) |
|
weechat.color.chat_nick_offline_highlight (WeeChat ≥ 0.3.9) |
|
weechat.color.chat_nick_prefix (WeeChat ≥ 0.4.1) |
|
weechat.color.chat_nick_suffix (WeeChat ≥ 0.4.1) |
|
weechat.color.emphasized (WeeChat ≥ 0.4.2) |
|
weechat.color.chat_day_change (WeeChat ≥ 0.4.2) |
|
weechat.color.chat_value_null (WeeChat ≥ 1.4) |
|
weechat.color.chat_status_disabled (WeeChat ≥ 4.0.0) |
|
weechat.color.chat_status_enabled (WeeChat ≥ 4.0.0) |
WeeChat colors are:
Code | Color |
---|---|
|
Default (terminal foreground/background) |
|
Black |
|
Dark gray |
|
Dark red |
|
Light red |
|
Dark green |
|
Light green |
|
Brown |
|
Yellow |
|
Dark blue |
|
Light blue |
|
Dark magenta |
|
Light magenta |
|
Dark cyan |
|
Light cyan |
|
Gray |
|
White |
Examples of color codes:
Code | Description |
---|---|
19 |
Color of option "01" (chat text) |
19 |
Yellow on red |
19 |
Orange (extended color 214) |
19 |
Bold underlined orange (214) on dark blue (17) |
1A |
Set underline |
1B |
Remove underline |
1C |
Reset attributes and color |
5. 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:
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:
#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:
server->hook_timer_sasl = weechat_hook_timer (timeout * 1000,
0, 1,
&irc_server_timer_sasl_cb,
server);
6. Contribute to WeeChat
6.1. Git repository
Git repository is on 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:
Component | Files | Description |
---|---|---|
|
|
WeeChat core |
|
|
Build |
|
|
Continuous integration |
|
|
Debian packaging |
|
|
Tests |
|
|
General doc updates, for example build |
|
|
Man pages |
|
|
Frequently asked questions (FAQ) |
|
|
Quickstart guide |
|
|
User’s guide |
|
|
Scripting guide |
|
|
Plugin API reference |
|
|
Relay protocol |
|
|
Developer’s guide |
|
|
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
6.2. Translations
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 msgcheck ↗:
$ msgcheck.py xx.po
And then you can recompile WeeChat to use the new translations.
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>>