Questo manuale documenta il client di chat WeeChat, ed è parte del programma stesso.

La versione più recente di questo documento si trova qui: http://www.weechat.org/doc

1. Introduzione

WeeChat (Wee Enhanced Environment for Chat) è un client di chat libero, veloce e leggero, realizzato per molti sistemi operativi.

Questo manuale documenta le API per i plugin di WeeChat, utilizzate dai plugin C per interagire con il core di WeeChat.

2. Plugin in WeeChat

Un plugin è un programma C che può richiamare le funzioni di WeeChat definite in un’interfaccia.

Questo programma C non richiede i sorgenti di WeeChat per essere compilato e può essere caricato dinamicamente in WeeChat con il comano /plugin.

Il plugin deve essere una libreria dinamica, per essere caricato dinamicamente dal del sistema operativo. In GNU/Linux, il file ha estensione ".so", ".dll" in Windows.

Il plugin deve includere il file "weechat-plugin.h" (disponibile nel codice sorgente di WeeChat). Il file definisce strutture e tipi utilizzati per comunicare con WeeChat.

2.1. Macro

Il plugin deve utilizzare alcune macro (per definire alcune variabili):

WEECHAT_PLUGIN_NAME("nome")

nome del plugin

WEECHAT_PLUGIN_DESCRIPTION("descrizione")

breve descrizione del plugin

WEECHAT_PLUGIN_VERSION("1.0")

versione del plugin

WEECHAT_PLUGIN_LICENSE("GPL3")

licenza del plugin

2.2. Funzioni principali

Il plugin deve usare due funzioni:

2.2.1. weechat_plugin_init

Questa funzione viene chiamata quando il plugin è caricato. da WeeChat.

Prototipo:

int weechat_plugin_init (struct t_weechat_plugin *plugin,
                         int argc, char *argv[]);

Argomenti:

Valori restituiti:

2.2.2. weechat_plugin_end

Questa funzione viene chiamata quando il plugin viene disattivato da WeeChat.

Prototipo:

int weechat_plugin_end (struct t_weechat_plugin *plugin);

Argomenti:

Valori restituiti:

2.3. Compilazione del plugin

La compilazione non richiede i sorgenti di WeeChat, è richiesto solo il file weechat-plugin.h.

Per compilare un plugin che ha un file "tizio.c" (in GNU/Linux):

$ gcc -fPIC -Wall -c tizio.c
$ gcc -shared -fPIC -o libtizio.so tizio.o

2.4. Caricamento del plugin

Copiare il file libtizio.so nella cartella plugin di sistema (ad esempio /usr/local/lib/weechat/plugins) oppure nella cartella plugin dell’utente (ad esempio /home/xxx/.weechat/plugins).

In WeeChat:

/plugin load tizio

2.5. Plugin di esempio

Un esempio completo di plugin, che aggiunge un comando /double: visualizza due volte gli argomenti nel buffer corrente, oppure esegue un comando due volte (ok, non sarà molto utile, ma è solo un esempio!):

#include <stdlib.h>

#include "weechat-plugin.h"

WEECHAT_PLUGIN_NAME("double");
WEECHAT_PLUGIN_DESCRIPTION("Test plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("Sebastien Helleu <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION("0.1");
WEECHAT_PLUGIN_LICENSE("GPL3");

struct t_weechat_plugin *weechat_plugin = NULL;


/* callback per il comando "/double" */

int
command_double_cb (void *data, struct t_gui_buffer *buffer, int argc,
                   char **argv, char **argv_eol)
{
    /* fa felice il compilatore C */
    (void) data;
    (void) buffer;
    (void) argv;

    if (argc > 1)
    {
        weechat_command (NULL, argv_eol[1]);
        weechat_command (NULL, argv_eol[1]);
    }

    return WEECHAT_RC_OK;
}

int
weechat_plugin_init (struct t_weechat_plugin *plugin,
                     int argc, char *argv[])
{
    weechat_plugin = plugin;

    weechat_hook_command ("double",
                          "Visualizza due volte un messaggio "
                          "oppure esegue un comando due volte",
                          "messaggio | comando",
                          "messaggio: messaggio da visualizzare due volte\n"
                          "comando: comando da eseguire due volte",
                          NULL,
                          &command_double_cb, NULL);

    return WEECHAT_RC_OK;
}

int
weechat_plugin_end (struct t_weechat_plugin *plugin)
{
    /* fa felice il compilatore C */
    (void) plugin;

    return WEECHAT_RC_OK;
}

3. Plugin API

I capitoli seguenti descrivono le funzioni nelle API, organizzate in categorie.

Per ogni funzione, viene fornita:

3.1. Plugin

Funzioni per ottenere informazioni sui plugin.

3.1.1. weechat_plugin_get_name

Ottiene il nome del plugin.

Prototipo:

const char *weechat_plugin_get_name (struct t_weechat_plugin *plugin);

Argomenti:

Valore restituito:

Esempio in C:

const char *name = weechat_plugin_get_name (plugin);

Script (Python):

# prototipo
name = weechat.plugin_get_name(plugin)

# esempio
plugin = weechat.buffer_get_pointer(weechat.current_buffer(), "plugin")
name = weechat.plugin_get_name(plugin)

3.2. Stringhe

Molte delle funzioni stringa che seguono sono già disponibili tramite funzioni standard in C, ma si raccomanda di utilizzare le funzioni in questa API perché compatibili con UTF-8 e il locale.

3.2.1. weechat_charset_set

Imposta il nuovo set caratteri del nuovo plugin (il set caratteri predefinito è UTF-8, così se il plugin usa UTF-8 non è necessario chiamare questa funzione).

Prototipo:

void weechat_charset_set (const char *charset);

Argomenti:

Esempio in C:

weechat_charset_set (plugin, "iso-8859-1");

Script (Python):

# prototipo
weechat.charset_set(charset)

# esempio
weechat.charset_set("iso-8859-1")

3.2.2. weechat_iconv_to_internal

Converte le stringhe per il set caratteri interno di WeeChat (UTF-8).

Prototipo:

char *weechat_iconv_to_internal (const char *charset, const char *string);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_iconv_to_internal (plugin, "iso-8859-1", "iso string: é à");
/* ... */
free (str);

Script (Python):

# prototipo
str = weechat.iconv_to_internal(charset, string)

# esempio
str = weechat.iconv_to_internal("iso-8859-1", "iso string: é à")

3.2.3. weechat_iconv_from_internal

Converte la stringa dal set caratteri interno di WeeChat (UTF-8) in un’altra.

Prototipo:

char *weechat_iconv_from_internal (const char *charset, const char *string);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_iconv_from_internal ("iso-8859-1", "utf-8 string: é à");
/* ... */
free (str);

Script (Python):

# prototipo
str = weechat.iconv_from_internal(charset, string)

# esempio
str = weechat.iconv_from_internal("iso-8859-1", "utf-8 string: é à")

3.2.4. weechat_gettext

Restituisce la stringa tradotta (dipende dalla lingua).

Prototipo:

const char *weechat_gettext (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_gettext ("hello");

Script (Python):

# prototipo
str = weechat.gettext(string)

# esempio
str = weechat.gettext("hello")

3.2.5. weechat_ngettext

Restituisce la stringa tradotta, utilizzando il singolare o il plurale, in base all’argomento count (contatore).

Prototipo:

const char *weechat_ngettext (const char *string, const char *plural,
                              int count);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_ngettext ("file", "files", num_files);

Script (Python):

# prototipo
str = weechat.ngettext(string, plural, count)

# esempio
num_files = 2
str = weechat.ngettext("file", "files", num_files)

3.2.6. weechat_strndup

Restituisce una stringa duplicata, con un massimo di caratteri impostato su chars.

Prototipo:

char *weechat_strndup (const char *string, int length);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
/* ... */
free (str);

3.2.7. weechat_string_tolower

Converte una stringa UTF-8 in minuscolo.

Prototipo:

void weechat_string_tolower (const char *string);

Argomenti:

Esempio in C:

char *str = "AbCdé";
weechat_string_tolower (str); /* str ora è: "abcdé" */

3.2.8. weechat_string_toupper

Converte una stringa UTF-8 in maiuscolo.

Prototipo:

void weechat_string_toupper (const char *string);

Argomenti:

Esempio in C:

char *str = "AbCdé";
weechat_string_tolower (str); /* str ora è: "ABCDé" */

3.2.9. weechat_strcasecmp

Confronta stringa indipendente da caso (maiuscole o minuscole) e da locale.

Prototipo:

int weechat_strcasecmp (const char *string1, const char *string2);

Argomenti:

Valore restituito:

Esempio in C:

int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */

3.2.10. weechat_strncasecmp

Confronta stringa indipendente da caso (maiuscole o minuscole) e da locale, per un numero max di caratteri.

Prototipo:

int weechat_strncasecmp (const char *string1, const char *string2, int max);

Argomenti:

Valore restituito:

Esempio in C:

int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */

3.2.11. weechat_strcmp_ignore_chars

Confronta una stringa locale (ed opzionalmente indipendente da maiuscole/minuscole), ignorando alcuni caratteri.

Prototipo:

int weechat_strcmp_ignore_chars (const char *string1, const char *string2,
                                 const char *chars_ignored,
                                 int case_sensitive);

Argomenti:

Valore restituito:

Esempio in C:

int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */

3.2.12. weechat_strcasestr

Cerca una stringa indipendente da locale e caso esatto (maiuscole/minuscole).

Prototipo:

char *weechat_strcasestr (const char *string, const char *search);

Argomenti:

Valore restituito:

Esempio in C:

char *pos = weechat_strcasestr ("aBcDeF", "de"); /* risultato: puntatore a "DeF" */

3.2.13. weechat_string_match

Verifica se una stringa coincide ad una mask.

Prototipo:

int weechat_string_match (const char *string, const char *mask,
                          int case_sensitive);

Argomenti:

Valore restituito:

Esempio in C:

int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
int match4 = weechat_string_match ("abcdef", "*de*", 0); /* == 1 */

Script (Python):

# prototipo
match = weechat.string_match(string, mask, case_sensitive)

# esempio
match1 = weechat.string_match("abcdef", "abc*", 0) # 1
match2 = weechat.string_match("abcdef", "*dd*", 0) # 0
match3 = weechat.string_match("abcdef", "*def", 0) # 1
match4 = weechat.string_match("abcdef", "*de*", 0) # 1

3.2.14. weechat_string_replace

Sostituisce tutte le ricorrenze di una stringa con un’altra.

Prototipo:

char *weechat_string_replace (const char *string, const char *search,
                              const char *replace);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
/* ... */
free (str);

3.2.15. weechat_string_expand_home

Novità nella versione 0.3.3.

Sostituisce la ~ iniziale con la stringa con la cartella home. Se la stringa non inizia con ~, viene restituita la stessa stringa.

Prototipo:

char *weechat_string_expand_home (const char *path);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_string_expand_home ("~/file.txt");
/* result: "/home/xxx/file.txt" */
/* ... */
free (str);

3.2.16. weechat_string_remove_quotes

Rimuove le virgolette all’inizio e alla fine della stringa (ignora gli spazi se presenti prima delle prime virgolette o dopo le ultime virgolette).

Prototipo:

char *weechat_string_remove_quotes (const char *string, const char *quotes);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_string_remove_quotes (string, " 'Non posso' ", "'");
/* risultato: "Non posso" */
/* ... */
free (str);

3.2.17. weechat_string_strip

Rimuove i caratteri ad inizio/fine della stringa.

Prototipo:

char *weechat_string_strip (const char *string, int left, int right,
                            const char *chars);

Argomenti:

Valore restituito:

Esempio in C:

char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* risultato: ".abc" */
/* ... */
free (str);

3.2.18. weechat_string_has_highlight

Controlla se una stringa ha uno o più eventi, usando la lista di parole per gli eventi.

Prototipo:

int weechat_string_has_highlight (const char *string,
                                  const char highlight_words);

Argomenti:

Valore restituito:

Esempio in C:

int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */

Script (Python):

# prototipo
highlight = weechat.string_has_highlight(string, highlight_words)

# esempio
highlight = weechat.string_has_highlight("my test string", "test,word2") # 1

3.2.19. weechat_string_mask_to_regex

Restituisce una espressione regolare con una mask, dove l’unico carattere speciale è "*". Tutti gli altri caratteri speciali per le espressioni regolari non vengono riconosciuti.

Prototipo:

char *weechat_string_mask_to_regex (const char *mask);

Argomenti:

Valore restituito:

Esempio in C:

char *str_regex = weechat_string_mask_to_regex ("test*mask");
/* result: "test.*mask" */
/* ... */
free (str_regex);

Script (Python):

# prototipo
regex = weechat.string_mask_to_regex(mask)

# esempio
regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"

3.2.20. weechat_string_split

Divide una stringa in base a uno o più delimitatori.

Prototipo:

char **weechat_string_split (const char *string, const char *separators,
                             int keep_eol, int num_items_max,
                             int *num_items);

Argomenti:

Valore restituito:

Esempi:

char **argv;
int argc;
argv = weechat_string_split ("abc de  fghi", " ", 0, 0, &argc);
/* result: argv[0] == "abc"
           argv[1] == "de"
           argv[2] == "fghi"
           argv[3] == NULL
           argc == 3
*/
weechat_string_free_split (argv);

argv = weechat_string_split ("abc de  fghi", " ", 1, 0, &argc);
/* result: argv[0] == "abc de  fghi"
           argv[1] == "de  fghi"
           argv[2] == "fghi"
           argv[3] == NULL
           argc == 3
*/
weechat_string_free_split (argv);

3.2.21. weechat_string_free_split

Libera la memoria usata per la divisione di una stringa.

Prototipo:

void weechat_string_free_split (char **split_string);

Argomenti:

Esempio in C:

char *argv;
int argc;
argv = weechat_string_split (string, " ", 0, 0, &argc);
/* ... */
weechat_string_free_split (argv);

3.2.22. weechat_string_build_with_split_string

Compila una stringa con una stringa divisa.

Prototipo:

char *weechat_string_build_with_split_string (char **split_string,
                                              const char *separator);

Argomenti:

Valore restituito:

Esempio in C:

char **argv;
int argc;
argv = weechat_string_split ("abc def ghi", " ", 0, 0, &argc);
char *str = weechat_string_build_with_split_string (argv, ";");
/* str == "abc;def;ghi" */
/* ... */
free (str);

3.2.23. weechat_string_split_command

Divide una lista di comandi separata da separator (che può essere omesso aggiungendo "\" nella stringa).

Prototipo:

char **weechat_string_split_command (const char *command, char separator);

Argomenti:

Valore restituito:

Esempio in C:

char **argv = weechat_string_split_command ("/command1 arg;/command2", ';');
/* result: argv[0] == "/command1 arg"
           argv[1] == "/command2"
*/
weechat_free_split_command (argv);

3.2.24. weechat_string_free_split_command

Libera la memoria utilizzata dalla divisione di un comando.

Prototipo:

void weechat_string_free_split_command (char **split_command);

Argomenti:

Esempio in C:

char **argv = weechat_string_split_command ("/command1 arg;/command2", ';');
/* ... */
weechat_free_split_command (argv);

3.2.25. weechat_string_format_size

Compila una stringa con un file di dimensione fissa ed una unità tradotta nella lingua locale.

Prototipo:

char *weechat_string_format_size (unsigned long size);

Argomenti:

Valore restituito:

Esempi in C:

/* esempi in lingua inglese */

char *str = weechat_string_format_size (0); /* str == "0 byte" */
/* ... */
free (str);

char *str = weechat_string_format_size (200); /* str == "200 bytes" */
/* ... */
free (str);

char *str = weechat_string_format_size (1536); /* str == "1.5 KB" */
/* ... */
free (str);

char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
/* ... */
free (str);

3.2.26. weechat_string_remove_color

Rimuove i colori di WeeChat da una stringa.

Prototipo:

char *weechat_string_remove_color (const char *string,
                                   const char *replacement);

Argomenti:

Valore restituito:

Esempi:

/* rimuove i codici colore */
char *str = weechat_string_remove_color (my_string1, NULL);
/* ... */
free (str);

/* sostituisce i codici colore con "?" */
char *str = weechat_string_remove_color (my_string2, "?");
/* ... */
free (str);

Script (Python):

# prototipo
str = weechat.string_remove_color(string, replacement)

# esempio
str = weechat.string_remove_color(my_string, "?")

3.2.27. weechat_string_encode_base64

Novità nella versione 0.3.2.

Codifica una stringa in base64.

Prototype:

void weechat_string_encode_base64 (const char *from, int length, char *to);

Argomenti:

Esempio in C:

char *string = "abcdefgh", result[128];
weechat_string_encode_base64 (string, strlen (string), result);
/* result == "YWJjZGVmZ2g=" */

3.2.28. weechat_string_decode_base64

Novità nella versione 0.3.2.

Decodifica una stringa in base64.

Prototipo:

int weechat_string_decode_base64 (const char *from, char *to);

Argomenti:

Valore restituito:

Esempio in C:

char *string = "YWJjZGVmZ2g=", result[128];
int length;
length = weechat_string_decode_base64 (string, result);
/* length == 8, result == "abcdefgh" */

3.2.29. weechat_string_is_command_char

Novità nella versione 0.3.2.

Verifica che il primo carattere della stringa sia un carattere comando (il comando carattere predefinito è /).

Prototype:

int weechat_string_is_command_char (const char *string);

Argomenti:

Valore restituito:

C examples:

int command_char1 = weechat_string_is_command_char ("/test"); /* == 1 */
int command_char2 = weechat_string_is_command_char ("test");  /* == 0 */

Script (Python):

# prototype
is_cmdchar = weechat.string_is_command_char(string)

# examples
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test")  # == 0

3.2.30. weechat_string_input_for_buffer

Novità nella versione 0.3.2.

Restituisce il puntatore al testo in input per il buffer (puntatore all’interno dell’argomento "string"), oppure NULL se è un comando.

Prototype:

const char *weechat_string_input_for_buffer (const char *string);

Argomenti:

Valore restituito:

C examples:

const char *str1 = weechat_string_input_for_buffer ("test");   /* "test"  */
const char *str2 = weechat_string_input_for_buffer ("/test");  /* NULL    */
const char *str3 = weechat_string_input_for_buffer ("//test"); /* "/test" */

Script (Python):

# prototype
str = weechat.string_input_for_buffer(string)

# examples
str1 = weechat.string_input_for_buffer("test")   # "test"
str2 = weechat.string_input_for_buffer("/test")  # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"

3.3. UTF-8

Alcune funzioni stringa UTF-8.

3.3.1. weechat_utf8_has_8bits

Verifica che una stringa abbia caratteri a 8-bit.

Prototipo:

int weechat_utf8_has_8bits (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_utf8_has_8bits (string))
{
    /* ... */
}

3.3.2. weechat_utf8_is_valid

Verifica che una stringa sia valida in UTF-8.

Prototipo:

int weechat_utf8_is_valid (const char *string, char **error);

Argomenti:

Valore restituito:

Esempio in C:

char *error;
if (weechat_utf8_is_valid (string, &error))
{
    /* ... */
}
else
{
    /* "error" punta al primo carattere non valido */
}

3.3.3. weechat_utf8_normalize

Normalizza le stringhe UTF-8: rimuove i caratteri non UTF-8 e li sostituisce con un carattere.

Prototipo:

void weechat_utf8_normalize (const char *string, char replacement);

Argomenti:

Esempio in C:

weechat_utf8_normalize (string, '?');

3.3.4. weechat_utf8_prev_char

Restituisce il puntatore al carattere UTF-8 precedente in una stringa.

Prototipo:

char *weechat_utf8_prev_char (const char *string_start, const char *string);

Argomenti:

Valore restituito:

Esempio in C:

char *prev_char = weechat_utf8_prev_char (string, ptr_in_string);

3.3.5. weechat_utf8_next_char

Restituisce il puntatore al successivo carattere UTF-8 in una stringa.

Prototipo:

char *weechat_utf8_next_char (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

char *next_char = weechat_utf8_next_char (string);

3.3.6. weechat_utf8_char_int

Restituisce un carattere UTF-8 come intero.

Prototipo:

int weechat_utf8_char_int (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

int char_int = weechat_utf8_char_int ("être"); /* "ê" come intero */

3.3.7. weechat_utf8_char_size

Restituisce la dimensione di un carattere UTF-8 (in byte).

Prototipo:

int weechat_utf8_char_size (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

int char_size = weechat_utf8_char_size ("être"); /* == 2 */

3.3.8. weechat_utf8_strlen

Restituisce la lunghezza della stringa UTF-8 (nei caratteri UTF-8).

Prototipo:

int weechat_utf8_strlen (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

int length = weechat_utf8_strlen ("chêne"); /* == 5 */

3.3.9. weechat_utf8_strnlen

Restituisce la lunghezza della stringa UTF-8 (in caratteri UTF-8), per un massimo di bytes nella stringa.

Prototipo:

int weechat_utf8_strnlen (const char *string, int bytes);

Argomenti:

Valore restituito:

Esempio in C:

int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */

3.3.10. weechat_utf8_strlen_screen

Restituisce il numero di caratteri necessari per visualizzare la stringa UTF-8 su schermo.

Prototipo:

int weechat_utf8_strlen_screen (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */

3.3.11. weechat_utf8_charcmp

Confronta due caratteri UTF-8.

Prototipo:

int weechat_utf8_charcmp (const char *string1, const char *string2);

Argomenti:

Valore restituito:

Esempio in C:

int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */

3.3.12. weechat_utf8_charcasecmp

Confronta due caratteri UTF-8, ignorando maiuscole/minuscole.

Prototipo:

int weechat_utf8_charcasecmp (const char *string1, const char *string2);

Argomenti:

Valore restituito:

Esempio in C:

int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */

3.3.13. weechat_utf8_char_size_screen

Restituisce il numero di caratteri necessari per visualizzare il carattere UTF-8 sullo schermo.

Prototipo:

int weechat_utf8_char_size_screen (const char *string);

Argomenti:

Valore restituito:

Esempio in C:

int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */

3.3.14. weechat_utf8_add_offset

Si sposta in avanti di N caratteri in una stringa UTF-8.

Prototipo:

char *weechat_utf8_add_offset (const char *string, int offset);

Argomenti:

Valore restituito:

Esempio in C:

char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */

3.3.15. weechat_utf8_real_pos

Restituisce la posizione reale nella stringa UTF-8.

Prototipo:

int weechat_utf8_real_pos (const char *string, int pos);

Argomenti:

Valore restituito:

Esempio in C:

int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */

3.3.16. weechat_utf8_pos

Restituisce la posizione nella stringa UTF-8.

Prototipo:

int weechat_utf8_pos (const char *string, int real_pos);

Argomenti:

Valore restituito:

Esempio in C:

int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */

3.3.17. weechat_utf8_strndup

Restituisce la stringa duplicata, di lunghezza massima lenght.

Prototipo:

char *weechat_utf8_strndup (const char *string, int length);

Argomenti:

Valore restituito:

Esempio in C:

char *string = weechat_utf8_strndup ("chêne", 3); /* restituisce "chê" */
/* ... */
free (string);

3.4. Cartelle

Alcune funzioni legate alle cartelle.

3.4.1. weechat_mkdir_home

Crea una cartella nella home di WeeChat.

Prototipo:

int weechat_mkdir_home (char *directory, int mode);

Argomenti:

Valore restituito:

Esempio in C:

if (!weechat_mkdir_home ("temp", 0755))
{
    /* errore */
}

Script (Python):

# prototipo
weechat.mkdir_home(directory, mode)

# esempio
weechat.mkdir_home("temp", 0755)

3.4.2. weechat_mkdir

Crea una cartella.

Prototipo:

int weechat_mkdir (char *directory, int mode);

Argomenti:

Valore restituito:

Esempio in C:

if (!weechat_mkdir ("/tmp/mydir", 0755))
{
    /* errore */
}

Script (Python):

# prototipo
weechat.mkdir(directory, mode)

# esempio
weechat.mkdir("/tmp/mydir", 0755)

3.4.3. weechat_mkdir_parents

Crea una cartella e le cartelle genitore se necessario.

Prototipo:

int weechat_mkdir_parents (char *directory, int mode);

Argomenti:

Valore restituito:

Esempio in C:

if (!weechat_mkdir_parents ("/tmp/my/dir", 0755))
{
    /* errore */
}

Script (Python):

# prototipo
weechat.mkdir_parents(directory, mode)

# esempio
weechat.mkdir_parents("/tmp/my/dir", 0755)

3.4.4. weechat_exec_on_files

Cerca i file in una cartella ed esegue una callback su ogni file.

Prototipo:

void weechat_exec_on_files (const char *directory,
                            int hidden_files,
                            void *data,
                            void (*callback)(void *data,
                                             const char *filename));

Argomenti:

Esempio in C:

void callback (void *data, const char *filename)
{
    /* ... */
}
...
weechat_exec_on_files ("/tmp", 0, NULL, &callback);

3.4.5. weechat_file_get_content

Novità nella versione 0.3.1.

Ottiene il contenuto del file di testo in una stringa.

Prototipo:

char *weechat_file_get_content (const char *filename);

Argomenti:

Valore restituito:

Esempio in C:

char *content;

content = weechat_file_get_content ("/tmp/test.txt");
/* ... */
free (content);

3.5. Utilità

Alcune funzioni utili.

3.5.1. weechat_util_timeval_cmp

Confronta due strutture "timeval".

Prototipo:

int weechat_util_timeval_cmp (struct timeval *tv1, struct timeval *tv2);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_util_timeval_cmp (&tv1, &tv2) > 0)
{
    /* tv1 > tv2 */
}

3.5.2. weechat_util_timeval_diff

Restituisce la differenza (in millisecondi) tra due strutture "timeval".

Prototipo:

long weechat_util_timeval_diff (struct timeval *tv1, struct timeval *tv2);

Argomenti:

Valore restituito:

Esempio in C:

long diff = weechat_util_timeval_diff (&tv1, &tv2);

3.5.3. weechat_util_timeval_add

Aggiungi intervallo (in millisecondi) ad una struttura timeval.

Prototipo:

void weechat_util_timeval_add (struct timeval *tv, long interval);

Argomenti:

Esempio in C:

weechat_util_timeval_add (&tv, 2000); /* aggiunge 2 secondi */

3.5.4. weechat_util_get_time_string

Novità nella versione 0.3.2.

Riceve data/ora come stringa compilata con "strftime".

Prototipo:

char *weechat_util_get_time_string (const time_t *date);

Argomenti:

Esempio in C:

time_t date = time (NULL);
weechat_printf (NULL, "date: %s",
                weechat_util_get_time_string (&date));

3.6. Elenchi ordinati

Funzioni lista ordinata.

3.6.1. weechat_list_new

Crea una nuova lista.

Prototipo:

struct t_weelist *weechat_list_new ();

Valore restituito:

Esempio in C:

struct t_weelist *list = weechat_list_new ();

Script (Python):

# prototipo
list = weechat.list_new()

# esempio
list = weechat.list_new()

3.6.2. weechat_list_add

Aggiunge un elemento in una lista.

Prototipo:

struct t_weelist_item *weechat_list_add (struct t_weelist *weelist,
                                         const char *data,
                                         const char *where,
                                         void *user_data);

Argomenti:

Valore restituito:

Esempio in C:

struct t_weelist_item *my_item =
    weechat_list_add (list, "my data", WEECHAT_LIST_POS_SORT, NULL);

Script (Python):

# prototipo
item = weechat.list_add(list, data, where, user_data)

# esempio
item = weechat.list_add(list, "my data", weechat.WEECHAT_LIST_POS_SORT, "")

Cerca un elemento nella lista.

Prototipo:

struct t_weelist_item *weechat_list_search (struct t_weelist *weelist,
                                            const char *data);

Argomenti:

Valore restituito:

Esempio in C:

struct t_weelist_item *item = weechat_list_search (list, "my data");

Script (Python):

# prototipo
item = weechat.list_search(list, data)

# esempio
item = weechat.list_search(list, "my data")

3.6.4. weechat_list_casesearch

Cerca un elemento nella lista, senza effettuare una ricerca esatta.

Prototipo:

struct t_weelist_item *weechat_list_casesearch (struct t_weelist *weelist,
                                                const char *data);

Argomenti:

Valore restituito:

Esempio in C:

struct t_weelist_item *item = weechat_list_casesearch (list, "my data");

Script (Python):

# prototipo
item = weechat.list_casesearch(list, data)

# esempio
item = weechat.list_casesearch(list, "my data")

3.6.5. weechat_list_get

Restituisce un elemento in una lista in base alla sua posizione.

Prototipo:

struct t_weelist_item *weechat_list_get (struct t_weelist *weelist,
                                         int position);

Argomenti:

Valore restituito:

Esempio in C:

struct t_weelist_item *item = weechat_list_get (list, 0); /* primo elemento */

Script (Python):

# prototipo
item = weechat.list_get(list, position)

# esempio
item = weechat.list_get(list, 0)

3.6.6. weechat_list_set

Imposta un nuovo valore per un elemento.

Prototipo:

void weechat_list_set (struct t_weelist_item *item, const char *value);

Argomenti:

Esempio in C:

weechat_list_set (item, "nuovi dati");

Script (Python):

# prototipo
weechat.list_set(item, value)

# esempio
weechat.list_set(item, "nuovi dati")

3.6.7. weechat_list_next

Restituisce l’elemento successivo nella lista.

Prototipo:

struct t_weelist_item *weechat_list_next (struct t_weelist_item *item);

Argomenti:

Valore restituito:

Esempio in C:

struct t_weelist_item *next_item = weechat_list_next (item);

Script (Python):

# prototipo
item = weechat.list_next(item)

# esempio
item = weechat.list_next(item)

3.6.8. weechat_list_prev

Restituisce l’elemento precedente nella lista.

Prototipo:

struct t_weelist_item *weechat_list_prev (struct t_weelist_item *item);

Argomenti:

Valore restituito:

Esempio in C:

struct t_weelist_item *prev_item = weechat_list_prev (item);

Script (Python):

# prototipo
item = weechat.list_prev(item)

# esempio
item = weechat.list_prev(item)

3.6.9. weechat_list_string

Restituisce il valore stringa di un elemento.

Prototipo:

const char *weechat_list_string (struct t_weelist_item *item);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "valore dell'elemento: %s", weechat_list_string (item));

Script (Python):

# prototipo
value = weechat.list_string(item)

# esempio
weechat.prnt("", "valore dell'elemento: %s" % weechat.list_string(item))

3.6.10. weechat_list_size

Restituisce la dimensione della lista (numero di elementi).

Prototipo:

char *weechat_list_size (struct t_weelist *weelist);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "dimensione della lista: %d", weechat_list_size (list));

Script (Python):

# prototipo
size = weechat.list_size(list)

# esempio
weechat.prnt("", "dimensione della lista: %d" % weechat.list_size(list))

3.6.11. weechat_list_remove

Rimuove un elemento in una lista.

Prototipo:

void weechat_list_remove (struct t_weelist *weelist,
                          struct t_weelist_item *item);

Argomenti:

Esempio in C:

weechat_list_remove (list, item);

Script (Python):

# prototipo
weechat.list_remove(list, item)

# esempio
weechat.list_remove(list, item)

3.6.12. weechat_list_remove_all

Rimuove tutti gli elementi in una lista.

Prototipo:

void weechat_list_remove_all (struct t_weelist *weelist);

Argomenti:

Esempio in C:

weechat_list_remove_all (list);

Script (Python):

# prototipo
weechat.list_remove_all(list)

# esempio
weechat.list_remove_all(list)

3.6.13. weechat_list_free

Libera una lista.

Prototipo:

void weechat_list_free (struct t_weelist *weelist);

Argomenti:

Esempio in C:

weechat_list_free (list);

Script (Python):

# prototipo
weechat.list_free(list)

# esempio
weechat.list_free(list)

3.7. Tabelle hash

Funzioni per le tabelle hash.

3.7.1. weechat_hashtable_new

Novità nella versione 0.3.3.

Crea una nuova tabella hash.

Prototipo:

struct t_hashtable *weechat_hashtable_new (int size,
                                           const char *type_keys,
                                           const char *type_values,
                                           unsigned int (*callback_hash_key)(struct t_hashtable *hashtable,
                                                                             const void *key),
                                           int (*callback_keycmp)(struct t_hashtable *hashtable,
                                                                  const void *key1,
                                                                  const void *key2));

Arguments:

Valore restituito:

Esempio in C:

struct t_hashtable *hashtable = weechat_hashtable_new (8,
                                                       WEECHAT_HASHTABLE_STRING,
                                                       WEECHAT_HASHTABLE_STRING,
                                                       NULL,
                                                       NULL);

3.7.2. weechat_hashtable_set_with_size

Novità nella versione 0.3.3.

Aggiunge o aggiorna un elemento nella tabella hash con la dimensione per la chiave ed il valore.

Prototipo:

int weechat_hashtable_set_with_size (struct t_hashtable *hashtable,
                                     void *key, int key_size,
                                     void *value, int value_size);

Arguments:

Valore restituito:

Esempio in C:

weechat_hashtable_set_with_size (hashtable, "my_key", 0,
                                 my_buffer, sizeof (my_buffer_struct));

3.7.3. weechat_hashtable_set

Novità nella versione 0.3.3.

Aggiunge o aggiorna un elemento nella tabella hash.

Prototipo:

int weechat_hashtable_set (struct t_hashtable *hashtable,
                           void *key, void *value);

Argomenti:

Valore restituito:

Esempio in C:

weechat_hashtable_set (hashtable, "my_key", "my_value");

3.7.4. weechat_hashtable_get

Novità nella versione 0.3.3.

Ottiene il valore associato ad una chiave in una tabella hash.

Prototipo:

void *weechat_hashtable_get (struct t_hashtable *hashtable, void *key);

Argomenti:

Valore restituito:

Esempio in C:

void *value = weechat_hashtable_get (hashtable, "my_key");

3.7.5. weechat_hashtable_map

Novità nella versione 0.3.3.

Chiama una funzione su tutte le voci della tabella hash.

Prototipo:

void hashtable_map (struct t_hashlist *hashlist,
                    int (*callback_map)(void *data,
                                        struct t_hashtable *hashtable,
                                        const void *key,
                                        const void *value),
                    void *callback_map_data);

Argomenti:

Esempio in C:

void
map_cb (void *data, struct t_hashtable *hashtable,
        const void *key, const void *value)
{
    /* display key and value (they are both strings here) */
    weechat_printf (NULL, "key: '%s', value: '%s'",
                    (const char *)key,
                    (const char *)value);
}
/* ... */
weechat_hashtable_map (hashtable, &map_cb, NULL);

3.7.6. weechat_hashtable_get_integer

Novità nella versione 0.3.3.

Restituisce un valore intero per la proprietà di una tabella hash.

Prototipo:

int weechat_hashtable_get_integer (struct t_hashtable *hashtable,
                                   void *property);

Argomenti:

Valore restituito:

Esempio in C:

int items_count = weechat_hashtable_get_integer (hashtable, "items_count");

3.7.7. weechat_hashtable_add_to_infolist

Novità nella versione 0.3.3.

Aggiunge elementi della tabella hash ad un elemento della lista info.

Prototipo:

int weechat_hashtable_add_to_infolist (struct t_hashtable *hashtable,
                                       struct t_infolist_item *infolist_item,
                                       const char *prefix);

Argomenti:

Valore restituito:

Esempio in C:

weechat_hashtable_add_to_infolist (hashtable, infolist_item, "testhash");

/* se la tabella hash contiene:
     "key1" => "value 1"
     "key2" => "value 2"
   allora le seguenti variabili verranno aggiunti all'elemento  della lista info:
     "testhash_name_00001"  = "key1"
     "testhash_value_00001" = "value 1"
     "testhash_name_00002"  = "key2"
     "testhash_value_00002" = "value 2"
*/

3.7.8. weechat_hashtable_remove

Novità nella versione 0.3.3.

Rimuove un elemento in una tabella hash.

Prototipo:

void weechat_hashtable_remove (struct t_hashtable *hashtable, const void *key);

Argomenti:

Esempio in C:

weechat_hashtable_remove (hashtable, "my_key");

3.7.9. weechat_hashtable_remove_all

Novità nella versione 0.3.3.

Rimuove tutti gli elementi in una tabella hash.

Prototipo:

void weechat_hashtable_remove_all (struct t_hashtable *hashtable);

Argomenti:

Esempio in C:

weechat_hashtable_remove_all (hashtable);

3.7.10. weechat_hashtable_free

Novità nella versione 0.3.3.

Libera una tabella hash.

Prototipo:

void weechat_hashtable_free (struct t_hashtable *hashtable);

Argomenti:

Esempio in C:

weechat_hashtable_free (hashtable);

3.8. File di configurazione

Funzioni per i file di configurazione.

3.8.1. weechat_config_new

Crea un nuovo file di configurazione.

Prototipo:

struct t_config_file *weechat_config_new (const char *name,
                                          int (*callback_reload)(void *data,
                                                                 struct t_config_file *config_file),
                                          void *callback_reload_data);

Argomenti:

Valore restituito:

Note
Il file NON viene creato su disco da questa funzione. Verrà creato chiamando la funzione weechat_write_config. Si dovrebbe chiamare questa funzione solo dopo aver aggiunto alcune sezioni (con weechat_config_new_section) e le opzioni (con weechat_config_new_option).

Esempio in C:

int
my_config_reload_cb (void *data, struct t_config_file *config_file)
{
    /* ... */

    return WEECHAT_RC_OK;
}

struct t_config_file *config_file = weechat_config_new ("test",
                                                        &my_config_reload_cb,
                                                        NULL);

Script (Python):

# prototipo
config_file = weechat.config_new(name, calback_reload, callback_reload_data)

# esempio
def my_config_reload_cb(data, config_file):
    # ...
    return weechat.WEECHAT_RC_OK

config_file = weechat.config_new("test", "my_config_reload_cb", "")

3.8.2. weechat_config_new_section

Crea una nuova sezione nel file di configurazione.

Prototipo:

struct t_config_section *weechat_config_new_section (
    struct t_config_file *config_file,
    const char *name,
    int user_can_add_options,
    int user_can_delete_options,
    int (*callback_read)(void *data,
                         struct t_config_file *config_file,
                         struct t_config_section *section,
                         const char *option_name,
                         const char *value),
    void *callback_read_data,
    int (*callback_write)(void *data,
                          struct t_config_file *config_file,
                          const char *section_name),
    void *callback_write_data,
    int (*callback_write_default)(void *data,
                                  struct t_config_file *config_file,
                                  const char *section_name);
    void *callback_write_default_data,
    int (*callback_create_option)(void *data,
                                  struct t_config_file *config_file,
                                  struct t_config_section *section,
                                  const char *option_name,
                                  const char *value),
    void *callback_create_option_data,
    int (*callback_delete_option)(void *data,
                                  struct t_config_file *config_file,
                                  struct t_config_section *section,
                                  struct t_config_option *option),
    void *callback_delete_option_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_section_read_cb (void *data, struct t_config_file *config_file,
                    struct t_config_section *section, const char *option_name,
                    const char *value)
{
    /* ... */

    return WEECHAT_RC_OK;
}

int
my_section_write_cb (void *data, struct t_config_file *config_file,
                     const char *section_name)
{
    /* ... */

    return WEECHAT_CONFIG_WRITE_OK;
    /* return WEECHAT_CONFIG_WRITE_ERROR; */
}

int
my_section_write_default_cb (void *data, struct t_config_file *config_file,
                             const char *section_name)
{
    /* ... */

    return WEECHAT_CONFIG_WRITE_OK;
    /* return WEECHAT_CONFIG_WRITE_ERROR; */
}

int
my_section_create_option_cb (void *data, struct t_config_file *config_file,
                             struct t_config_section *section,
                             const char *option_name, const char *value)
{
    /* ... */

    return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
    /* return WEECHAT_CONFIG_OPTION_SET_ERROR; */
}

int
my_section_delete_option_cb (void *data, struct t_config_file *config_file,
                             struct t_config_section *section,
                             struct t_config_option *option)
{
    /* ... */

    return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
    /* return WEECHAT_CONFIG_OPTION_UNSET_ERROR; */
}

/* sezione standard, l'utente non può aggiungere/rimuovere opzioni */
struct t_config_section *new_section1 =
    weechat_config_new_section (config_file, "section1", 0, 0,
                                NULL, NULL, /* read callback */
                                NULL, NULL, /* write callback */
                                NULL, NULL, /* write default callback */
                                NULL, NULL, /* create option callback */
                                NULL, NULL); /* delete option callback */

/* sezione speciale, l'utente può aggiungere/eliminare opzioni, e le
   opzioni necessitano di un callback per essere lette/scritte */
struct t_config_section *new_section2 =
    weechat_config_new_section (config_file, "section2", 1, 1,
                                &my_section_read_cb, NULL,
                                &my_section_write_cb, NULL,
                                &my_section_write_default_cb, NULL,
                                &my_section_create_option_cb, NULL,
                                &my_section_delete_option_cb, NULL);

Script (Python):

# prototipo
section = weechat.config_new_section(config_file, name,
    user_can_add_options, user_can_delete_options,
    callback_read, callback_read_data,
    callback_write, callback_write_data,
    callback_create_option, callback_create_option_data,
    callback_delete_option, callback_delete_option_data)

# esempio
def my_section_read_cb(data, config_file, section, option_name, value):
    # ...
    return weechat.WEECHAT_RC_OK

def my_section_write_cb(data, config_file, section_name):
    # ...
    return weechat.WEECHAT_CONFIG_WRITE_OK

def my_section_write_default_cb(data, config_file, section_name):
    # ...
    return weechat.WEECHAT_CONFIG_WRITE_OK

def my_section_create_option_cb(data, config_file, section, option_name, value):
    # ...
    return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE

def my_section_delete_option_cb(data, config_file, section, option):
    # ...
    return weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED

section = weechat.config_new_section(config_file, "section1", 1, 1,
    "my_section_read_cb", "",
    "my_section_write_cb", "",
    "my_section_write_default_cb", "",
    "my_section_create_option_cb", "",
    "my_section_delete_option_cb", "")

3.8.3. weechat_config_search_section

Cerca una sezione in un file di configurazione.

Prototipo:

struct t_config_section *weechat_config_search_section (
    struct t_config_file *config_file,
    const char *section_name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_config_section *section = weechat_config_search_section (config_file,
                                                                  "section");

Script (Python):

# prototipo
section = weechat.config_search_section(config_file, section_name)

# esempio
section = weechat.config_search_section(config_file, "section")

3.8.4. weechat_config_new_option

Crea una nuova opzione nella sezione di un file di configurazione.

Prototipo:

struct t_config_option *weechat_config_new_option (
    struct t_config_file *config_file,
    struct t_config_section *section,
    const char *name,
    const char *type,
    const char *description,
    const char *string_values,
    int min,
    int max,
    const char *default_value,
    const char *value,
    int null_value_allowed,
    int (*callback_check_value)(void *data,
                                struct t_config_option *option,
                                const char *value),
    void *callback_check_value_data,
    int (*callback_change)(void *data,
                           struct t_config_option *option),
    void *callback_change_data,
    int (*callback_delete)(void *data,
                           struct t_config_option *option),
    void *callback_delete_data);

Argomenti:

Valore restituito:

alla nuova opzione nella sezione, NULL in caso di errore

Esempio in C:

/* booleano */
struct t_config_option *option1 =
    weechat_config_new_option (config_file, section, "option1", "boolean",
                               "My option, type boolean"
                               NULL, /* valori stringa */
                               0, 0, /* min, max */
                               "on", /* predefinito */
                               "on", /* valore */
                               0, /* null value allowed */
                               NULL, NULL, /* verifica callback */
                               NULL, NULL, /* modifica callback */
                               NULL, NULL); /* elimina callback */

/* intero */
struct t_config_option *option2 =
    weechat_config_new_option (config_file, section, "option2", "integer",
                               "My option, type integer"
                               NULL, /* string values */
                               0, 100, /* min, max */
                               "15", /* default */
                               "15", /* value */
                               0, /* null value allowed */
                               NULL, NULL, /* verifica callback */
                               NULL, NULL, /* modifica callback */
                               NULL, NULL); /* elimina callback */

/* intero (con valori stringa) */
struct t_config_option *option3 =
    weechat_config_new_option (config_file, section, "option3", "integer",
                               "My option, type integer (with string values)"
                               "top|bottom|left|right", /* string values */
                               0, 0, /* min, max */
                               "bottom", /* predefinito */
                               "bottom", /* valoree */
                               0, /* null value allowed */
                               NULL, NULL, /* verifica callback */
                               NULL, NULL, /* modifica callback */
                               NULL, NULL); /* elimina callback */

/* stringa */
struct t_config_option *option4 =
    weechat_config_new_option (config_file, section, "option4", "string",
                               "My option, type string"
                               NULL, /* valori stringa */
                               0, 0, /* min, max */
                               "test", /* predefinito */
                               "test", /* valore */
                               1, /* valore null consentito */
                               NULL, NULL, /* verifica callback */
                               NULL, NULL, /* modifica callback */
                               NULL, NULL); /* elimina callback */

/* colore */
struct t_config_option *option5 =
    weechat_config_new_option (config_file, section, "option5", "color",
                               "My option, type color"
                               NULL, /* valori stringa */
                               0, 0, /* min, max */
                               "lightblue", /* predefinito */
                               "lightblue", /* valore */
                               0, /* valore null consentito */
                               NULL, NULL, /* verifica callback */
                               NULL, NULL, /* modifica callback */
                               NULL, NULL); /* elimina callback */

Script (Python):

# prototipo
option = weechat.config_new_option(config_file, section, name, type, description,
    string_values, min, max, default_value, value, null_value_allowed,
    callback_check_value, callback_check_value_data,
    callback_change, callback_change_data,
    callback_delete, callback_delete_data)

# esempio
def option4_check_value_cb(data, option, value):
    # ...
    return weechat.WEECHAT_RC_OK

def option4_change_cb(data, option):
    # ...
    return weechat.WEECHAT_RC_OK

def option4_delete_cb(data, option):
    # ...
    return weechat.WEECHAT_RC_OK

option1 = weechat.config_new_option(config_file, section, "option1", "boolean",
    "My option, type boolean",
    "", 0, 0, "on", "on", 0,
    "", "",
    "", "",
    "", "")

option2 = weechat.config_new_option(config_file, section, "option2", "integer",
    "My option, type integer",
    "", 0, 100, "15", "15", 0,
    "", "",
    "", "",
    "", "")

option3 = weechat.config_new_option(config_file, section, "option3", "integer",
    "My option, type integer (with string values)",
    "top|bottom|left|right",
    0, 0, "bottom", "bottom", 0,
    "", "",
    "", "",
    "", "")

option4 = weechat.config_new_option(config_file, section, "option4", "string",
    "My option, type string",
    "", 0, 0, "test", "test", 1,
    "option4_check_value_cb", ""
    "option4_change_cb", "",
    "option4_delete_cb", "")

option5 = weechat.config_new_option(config_file, section, "option5", "color",
    "My option, type color",
    "", 0, 100, "lightblue", "lightblue", 0,
    "", "",
    "", "",
    "", "")

3.8.5. weechat_config_search_option

Cerca un’opzione nella sezione di un file di configurazione.

Prototipo:

struct t_config_option *weechat_config_search_option (
    struct t_config_file *config_file,
    struct t_config_section *section,
    const char *option_name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_config_option *option =
    weechat_config_search_option (config_file, section, "option");

Script (Python):

# prototipo
option = weechat.config_search_option(config_file, section, option_name)

# esempio
option = weechat.config_search_option(config_file, section, "option")

3.8.6. weechat_config_search_section_option

Cerca una sezione ed un’opzione in un file di configurazione o sezione.

Prototipo:

void weechat_config_search_section_option (struct t_config_file *config_file,
                                           struct t_config_section *section,
                                           const char *option_name,
                                           struct t_config_section **section_found,
                                           struct t_config_option **option_found);

Arguments:

Esempio in C:

struct t_config_section *ptr_section;
struct t_config_option *ptr_option;

weechat_config_search_section_option(config_file,
                                     section,
                                     "option",
                                     &ptr_section,
                                     &ptr_option);
if (ptr_option)
{
    /* opzione trovata */
}
else
{
    /* opzione non trovata */
}

3.8.7. weechat_config_search_with_string

Cerca un’opzione con il nome completo.

Prototipo:

void weechat_config_search_with_string (const char *option_name,
                                        struct t_config_file **config_file,
                                        struct t_config_section **section,
                                        struct t_config_option **option);

Argomenti:

Esempio in C:

struct t_config_file *ptr_config_file;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;

weechat_config_search_with_string ("file.section.option",
                                   &ptr_config_file,
                                   &ptr_section,
                                   &ptr_option);
if (ptr_option)
{
    /* opzione trovata */
}
else
{
    /* opzione non trovata */
}

3.8.8. weechat_config_string_to_boolean

Verifica se un testo è "vero" o "falso", come valore booleano.

Prototipo:

int weechat_config_string_to_boolean (const char *text);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_config_string_to_boolean (option_value))
{
    /* il valore è "true" */
}
else
{
    /* il valore è "false" */
}

Script (Python):

# prototipo
value = weechat.config_string_to_boolean(text)

# esempio
if weechat.config_string_to_boolean(text):
    # ...

3.8.9. weechat_config_option_reset

Resetta un’opzione al proprio valore predefinito.

Prototipo:

int weechat_config_option_reset (struct t_config_option *option,
                                 int run_callback);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_option_reset (option, 1))
{
    case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_ERROR:
        /* .... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_option_reset(option, run_callback)

# esempio
rc = weechat.config_option_reset(option, 1)
if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
    # ...

3.8.10. weechat_config_option_set

Imposta un nuovo valore per l’opzione.

Prototipo:

int weechat_config_option_set (struct t_config_option *option,
                               const char *value, int run_callback);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_option_set (option, "new_value", 1))
{
    case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_ERROR:
        /* .... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_option_set(option, value, run_callback)

# esempio
rc = weechat.config_option_set(option, "new_value", 1)
if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
    # ...

3.8.11. weechat_config_option_set_null

Imposta null (valore non definito) per un’opzione.

Prototipo:

int weechat_config_option_set_null (struct t_config_option *option,
                                    int run_callback);

Argomenti:

Note
È possibile impostare il valore a null solo se è consentito per l’opzione (consultare weechat_config_new_option).

Valore restituito:

Esempio in C:

switch (weechat_config_option_set_null (option, 1))
{
    case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_ERROR:
        /* .... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_option_set_null(option, run_callback)

# esempio
rc = weechat.config_option_set_null(option, 1)
if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
    # ...

3.8.12. weechat_config_option_unset

Rimuove/ripristina un’opzione.

Prototipo:

int weechat_config_option_unset (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_option_unset (option))
{
    case WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
        /* .... */
        break;
    case WEECHAT_CONFIG_OPTION_UNSET_ERROR:
        /* .... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_option_unset(option)

# esempio
rc = weechat.config_option_unset(option)
if rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR:
    # ...

3.8.13. weechat_config_option_rename

Rinomina un’opzione.

Prototipo:

void weechat_config_option_rename (struct t_config_option *option,
                                   const char *new_name);

Argomenti:

Esempio in C:

weechat_config_option_rename (option, "new_name");

Script (Python):

# prototipo
weechat.config_option_rename(option, new_name)

# esempio
weechat.config_option_rename(option, "new_name")

3.8.14. weechat_config_option_get_pointer

Restituisce un puntatore alla proprietà di un’opzione.

Prototipo:

void *weechat_config_option_get_pointer (struct t_config_option *option,
                                         const char *property);

Argomenti:

Valore restituito:

Esempio in C:

char *description = weechat_config_option_get_pointer (option, "description");

3.8.15. weechat_config_option_is_null

Verifica se un opzione è "null" (valore non definito).

Prototipo:

int weechat_config_option_is_null (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_config_option_is_null (option))
{
    /* il valore è "null" */
}
else
{
    /* il valore non è "null" */
}

Script (Python):

# prototipo
weechat.config_option_is_null(option)

# esempio
if weechat.config_option_is_null(option):
    # ...

3.8.16. weechat_config_option_default_is_null

Verifica che il valore predefinito di un’opzione sia "null" (valore non definito).

Prototipo:

int weechat_config_option_default_is_null (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_config_option_default_is_null (option))
{
    /* il valore predefinito è "null" */
}
else
{
    /* il valore predefinito non è "null" */
}

Script (Python):

# prototipo
weechat.config_option_default_is_null(option)

# esempio
if weechat.config_option_default_is_null(option):
    # ...

3.8.17. weechat_config_boolean

Restituisce il valore bool di un’opzione.

Prototipo:

int weechat_config_boolean (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_config_boolean (option))
{
    /* il valore è "true" */
}
else
{
    /* il valore è "false" */
}

Script (Python):

# prototipo
value = weechat.config_option_boolean(option)

# esempio
if weechat.config_option_boolean(option):
    # ...

3.8.18. weechat_config_boolean_default

Restituisce il valore bool predefinito di un’opzione.

Prototipo:

int weechat_config_boolean_default (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_config_boolean_default (option))
{
    /* il valore è "true" */
}
else
{
    /* il valore è "false" */
}

Script (Python):

# prototipo
value = weechat.config_option_boolean_default(option)

# esempio
if weechat.config_option_boolean_default(option):
    # ...

3.8.19. weechat_config_integer

Restituisce il valore intero di un’opzione.

Prototipo:

int weechat_config_integer (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

int value = weechat_config_integer (option);

Script (Python):

# prototipo
value = weechat.config_option_integer(option)

# esempio
if weechat.config_option_integer(option):
    # ...

3.8.20. weechat_config_integer_default

Restituisce il valore intero predefinito di un’opzione.

Prototipo:

int weechat_config_integer_default (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

int value = weechat_config_integer_default (option);

Script (Python):

# prototipo
value = weechat.config_option_integer_default(option)

# esempio
if weechat.config_option_integer_default(option):
    # ...

3.8.21. weechat_config_string

Restituisce il valore stringa di un’opzione.

Prototipo:

const char *weechat_config_string (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

const char *value = weechat_config_string (option);

Script (Python):

# prototipo
value = weechat.config_option_string(option)

# esempio
value = weechat.config_option_string(option):

3.8.22. weechat_config_string_default

Restituisce il valore stringa predefinito di un’opzione.

Prototipo:

const char *weechat_config_integer_default (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

const char *value = weechat_config_string_default (option);

Script (Python):

# prototipo
value = weechat.config_option_string_default(option)

# esempio
value = weechat.config_option_string_default(option):

3.8.23. weechat_config_color

Restituisce il valore colore di un’opzione.

Prototipo:

const char *weechat_config_color (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

const char *color = weechat_config_color (option);

Script (Python):

# prototipo
value = weechat.config_option_color(option)

# esempio
value = weechat.config_option_color(option):

3.8.24. weechat_config_color_default

Restituisce il valore colore predefinito di un’opzione.

Prototipo:

const char *weechat_config_color_default (struct t_config_option *option);

Argomenti:

Valore restituito:

Esempio in C:

const char *color = weechat_config_color_default (option);

Script (Python):

# prototipo
value = weechat.config_option_color_default(option)

# esempio
value = weechat.config_option_color_default(option):

3.8.25. weechat_config_write_option

Scrive una riga nel file di configurazione con l’opzione ed il suo valore (questa funzione dovrebbe essere chiamata solo nelle callback "write" o "write_default" per una sezione).

Prototipo:

void weechat_config_write_option (struct t_config_file *config_file,
                                  struct t_config_option *option);

Argomenti:

Esempio in C:

int
my_section_write_cb (void *data, struct t_config_file *config_file,
                     const char *section_name)
{
    weechat_config_write_line (config_file, "my_section", NULL);

    weechat_config_write_option (config_file, option);

    return WEECHAT_RC_OK;
}

Script (Python):

# prototipo
weechat.config_write_option(config_file, option)

# esempio
def my_section_write_cb(data, config_file, section_name):
    weechat.config_write_line(config_file, "my_section", "")
    weechat.config_write_option(config_file, option)
    return weechat.WEECHAT_RC_OK

3.8.26. weechat_config_write_line

Scrive una riga nel file di configurazione (questa funzione dovrebbe essere chiamata solo nelle callback "write" o "write_default" per una sezione).

Prototipo:

void weechat_config_write_line (struct t_config_file *config_file,
                                const char *option_name,
                                const char *value, ...);

Argomenti:

Esempio in C:

int
my_section_write_cb (void *data, struct t_config_file *config_file,
                     const char *section_name)
{
    weechat_config_write_line (config_file, "my_section", NULL);

    weechat_config_write_line (config_file, "option", "%s;%d",
                               "value", 123);

    return WEECHAT_RC_OK;
}

Script (Python):

# prototipo
weechat.config_write_line(config_file, option_name, value)

# esempio
def my_section_write_cb(data, config_file, section_name):
    weechat.config_write_line(config_file, "my_section", "")
    weechat.config_write_line(config_file, "option", "value")
    return weechat.WEECHAT_RC_OK

3.8.27. weechat_config_write

Scrive il file di configurazione su disco.

Prototipo:

int weechat_config_write (struct t_config_file *config_file);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_write (config_file))
{
    case WEECHAT_CONFIG_WRITE_OK:
        /* ... */
        break;
    case WEECHAT_CONFIG_WRITE_MEMORY_ERROR:
        /* ... */
        break;
    case WEECHAT_CONFIG_WRITE_ERROR:
        /* ... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_write(config_file)

# esempio
rc = weechat.config_write(config_file)
if rc == weechat.WEECHAT_CONFIG_WRITE_OK:
    # ...
elif rc == weechat.WEECHAT_CONFIG_WRITE_MEMORY_ERROR:
    # ...
elif rc == weechat.WEECHAT_CONFIG_WRITE_ERROR:
    # ...

3.8.28. weechat_config_read

Legge il file di configurazione da disco.

Prototipo:

int weechat_config_read (struct t_config_file *config_file);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_read (config_file))
{
    case WEECHAT_CONFIG_READ_OK:
        /* ... */
        break;
    case WEECHAT_CONFIG_READ_MEMORY_ERROR:
        /* ... */
        break;
    case WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
        /* ... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_read(config_file)

# esempio
rc = weechat.config_read(config_file)
if rc == weechat.WEECHAT_CONFIG_READ_OK:
    # ...
elif rc == weechat.WEECHAT_CONFIG_READ_MEMORY_ERROR:
    # ...
elif rc == weechat.WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
    # ...

3.8.29. weechat_config_reload

Ricarica il file di configurazione da disco.

Prototipo:

int weechat_config_reload (struct t_config_file *config_file);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_reload (config_file))
{
    case WEECHAT_CONFIG_READ_OK:
        /* ... */
        break;
    case WEECHAT_CONFIG_READ_MEMORY_ERROR:
        /* ... */
        break;
    case WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
        /* ... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_reload(config_file)

# esempio
rc = weechat.config_reload(config_file)
if rc == weechat.WEECHAT_CONFIG_READ_OK:
    # ...
elif rc == weechat.WEECHAT_CONFIG_READ_MEMORY_ERROR:
    # ...
elif rc == weechat.WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
    # ...

3.8.30. weechat_config_option_free

Libera un’opzione.

Prototipo:

void weechat_config_option_free (struct t_config_option *option);

Argomenti:

Esempio in C:

weechat_config_option_free (option);

Script (Python):

# prototipo
weechat.config_option_free(option)

# esempio
weechat.config_option_free(option)

3.8.31. weechat_config_section_free_options

Libera tutte le opzioni in una sessione.

Prototipo:

void weechat_config_section_free_options (struct t_config_section *section);

Argomenti:

Esempio in C:

weechat_config_section_free_options (section);

Script (Python):

# prototipo
weechat.config_section_free_options(section)

# esempio
weechat.config_section_free_options(section)

3.8.32. weechat_config_section_free

Libera una sezione.

Prototipo:

void weechat_config_section_free (struct t_config_option *option);

Argomenti:

Esempio in C:

weechat_config_section_free (section);

Script (Python):

# prototipo
weechat.config_section_free(section)

# esempio
weechat.config_section_free(section)

3.8.33. weechat_config_free

Libera un file di configurazione.

Prototipo:

void weechat_config_free (struct t_config_file *config_file);

Argomenti:

Esempio in C:

weechat_config_free (config_file);

Script (Python):

# prototipo
weechat.config_free(config_file)

# esempio
weechat.config_free(config_file)

3.8.34. weechat_config_get

Cerca un’opzione con il nome completo.

Prototipo:

struct t_config_option *weechat_config_get (const char *option_name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_config_option *option = weechat_config_get ("weechat.look.item_time_format");

Script (Python):

# prototipo
option = weechat.config_get(option_name)

# esempio
option = weechat.config_get("weechat.look.item_time_format")

3.8.35. weechat_config_get_plugin

Cerca un’opzione nei file di configurazione dei plugin (plugins.conf).

Prototipo:

const char *weechat_config_get_plugin (const char *option_name);

Argomenti:

Valore restituito:

Esempio in C:

/* se il plugin corrente è "test", allora cerca il valore
   dell'opzione "plugins.var.test.option" nel file plugins.conf */
char *value = weechat_config_get_plugin ("option");

Script (Python):

# prototipo
value = weechat.config_get_plugin(option_name)

# esempio
value = weechat.config_get_plugin("option")

3.8.36. weechat_config_is_set_plugin

Verifica se un’opzione è impostata nel file di configurazione dei plugin (plugins.conf).

Prototipo:

int weechat_config_is_set_plugin (const char *option_name);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_config_is_set_plugin ("option"))
{
    /* l'opzione è impostata */
}
else
{
    /* l'opzione non esiste */
}

Script (Python):

# prototipo
value = weechat.config_is_set_plugin(option_name)

# esempio
if weechat.config_is_set_plugin("option"):
    # l'opzione è impostata
    # ...
else:
    # l'opzione non esiste
    # ...

3.8.37. weechat_config_set_plugin

Imposta il nuovo valore per l’opzione nel file di configurazione dei plugin (plugins.conf).

Prototipo:

int weechat_config_set_plugin (const char *option_name, const char *value);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_set_plugin ("option", "test_value"))
{
    case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
        /* ... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
        /* ... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND:
        /* ... */
        break;
    case WEECHAT_CONFIG_OPTION_SET_ERROR:
        /* ... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_set_plugin(option_name, value)

# esempio
rc = weechat.config_is_set_plugin("option", "test_value")
if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
    # ...

3.8.38. weechat_config_unset_plugin

Disattiva l’opzione nel file di configurazione dei plugin (plugins.conf).

Prototipo:

int weechat_config_unset_plugin (const char *option_name);

Argomenti:

Valore restituito:

Esempio in C:

switch (weechat_config_unset_plugin ("option"))
{
    case WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
        /* ... */
        break;
    case WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
        /* ... */
        break;
    case WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
        /* ... */
        break;
    case WEECHAT_CONFIG_OPTION_UNSET_ERROR:
        /* ... */
        break;
}

Script (Python):

# prototipo
rc = weechat.config_unset_plugin(option_name)

# esempio
rc = weechat.config_unset_plugin("option")
if rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
    # ...
elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR:
    # ...

3.9. Visualizzazione

Funzioni per visualizzare il testo nei buffer.

3.9.1. weechat_prefix

Restituisce un prefisso.

Prototipo:

const char *weechat_prefix (const char *prefix);

Argomenti:

Prefisso Valore Colore Descrizione

error

 =!=    

giallo

messaggio di errore

network

 --     

magenta

messaggio dalla rete

action

 *      

bianco

azione automatica

join

 -->    

verde chiaro

qualcuno entra nella chat corrente

quit

 <--    

rosso chiaro

qualcuno lascia la chat corrente

Note
Valori e colori possono essere personalizzati con il comando /set.

Valore restituito:

Esempio in C:

weechat_printf (NULL, "%sQuesto è un errore...", weechat_prefix ("error"));

Script (Python):

# prototipo
value = weechat.prefix(prefix)

# esempio
weechat.prnt("", "%sQuesto è un errore..." % weechat.prefix("error"))

3.9.2. weechat_color

Restituisce una codice colore stringa da visualizzare.

Prototipo:

const char *weechat_color (const char *color_name);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "Color: %sblue %sdefault color %syellow on red",
                weechat_color ("blue"),
                weechat_color ("chat"),
                weechat_color ("yellow,red"));

Script (Python):

# prototipo
value = weechat.color(color_name)

# esempio
weechat.prnt("", "%sColor: %sblue %sdefault color %syellow on red"
    % (weechat.color("blue"), weechat.color("chat"), weechat.color("yellow,red")))

3.9.3. weechat_printf

Visualizza un messaggio su un buffer.

Prototipo:

void weechat_printf (struct t_gui_buffer *buffer, const char *message, ...);

Argomenti:

Esempio in C:

weechat_printf (NULL, "Benvenuto sul buffer di WeeChat");
weechat_printf (buffer, "Benvenuto su questo buffer");

Script (Python):

# prototipo
weechat.prnt(buffer, message)

# esempio
weechat.prnt("", "Benvenuto sul buffer di WeeChat")
weechat.prnt(buffer, "Benvenuto su questo buffer")
Note
La funzione è chiamata "print" negli script ("prnt" in Python).

3.9.4. weechat_printf_date

Visualizza un messaggio sul buffer, utilizzando una data personalizzata.

Prototipo:

void weechat_printf_date (struct t_gui_buffer *buffer, time_t date,
                          const char *message, ...);

Argomenti:

Esempio in C:

weechat_printf_date (NULL, time (NULL) - 120, "Ciao, 2 minuti fa");

3.9.5. weechat_printf_tags

Visualizza un messaggio sul buffer, utilizzando tag personalizzati.

Prototipo:

void weechat_printf_tags (struct t_gui_buffer *buffer, const char *tags,
                          const char *message, ...);

Argomenti:

Esempio in C:

weechat_printf_tags (NULL, "notify_message",
                     "Messaggio con tag 'notify_message'");

3.9.6. weechat_printf_date_tags

Visualizza un messaggio sul buffer, usando tag e data personalizzati.

Prototipo:

void weechat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
                               const char *tags, const char *message, ...);

Argomenti:

Esempio in C:

weechat_printf_date_tags (NULL, time (NULL) - 120, "notify_message",
                          "Messaggio 2 minuti fa, con tag 'notify_message'");

Script (Python):

# prototipo
weechat.prnt_date_tags(buffer, date, tags, message)

# esempio
time = int(time.time())
weechat.prnt_date_tags("", time - 120, "notify_message",
    "Messaggio 2 minuti fa, con tag 'notify_message'")
Note
La funzione è chiamata "print_date_tags" negli script ("prnt_date_tags" in Python).

3.9.7. weechat_printf_y

Visualizza un messaggio sulla riga di un buffer con contenuto libero.

Prototipo:

void weechat_printf_y (struct t_gui_buffer *buffer, int y,
                       const char *message, ...);

Argomenti:

Esempio in C:

weechat_printf_y (buffer, 2, "Mio messaggio sulla terza riga");

Script (Python):

# prototipo
weechat.prnt_y(buffer, y, message)

# esempio
weechat.prnt_y("", 2, "Mio messaggio sulla terza riga")
Note
La funzione è chiamata "print_y" negli script ("prnt_y in Python).

3.9.8. weechat_log_printf

Scrive un messaggio nel file di log di WeeChat (weechat.log).

Prototipo:

void weechat_log_printf (const char *message, ...);

Argomenti:

Esempio in C:

weechat_log_printf ("Mio messaggio nel file di log");

Script (Python):

# prototipo
weechat.log_print(message)

# esempio
weechat.log_print("Mio messaggio nel file di log")
Note
La funzione è chiamata "log_print" negli script.

3.10. Hook

3.10.1. weechat_hook_command

Hook su un comando.

Prototipo:

struct t_hook *weechat_hook_command (const char *command,
                                     const char *description,
                                     const char *args,
                                     const char *args_description,
                                     const char *completion,
                                     int (*callback)(void *data,
                                                     struct t_gui_buffer *buffer,
                                                     int argc,
                                                     char **argv,
                                                     char **argv_eol),
                                     void *callback_data);

Argomenti:

I codici predefiniti per il completamento sono:

Plugin Nome Descrizione

alias

alias

elenco di alias

aspell

aspell_langs

elenco di lingue supportate per aspell

irc

irc_channel

canale IRC corrente

irc

irc_channel_nicks_hosts

nick e host del canale IRC corrente

irc

irc_channel_topic

argomento del canale IRC attivo

irc

irc_channels

canali su tutti i server IRC

irc

irc_ignores_numbers

numero di ignore definiti

irc

irc_msg_part

messaggio di uscita predefinito per il canale IRC

irc

irc_privates

privati su tutti i server IRC

irc

irc_server

server IRC corrente

irc

irc_server_channels

canali sul server IRC corrente

irc

irc_server_nick

nick sul server IRC corrente

irc

irc_server_nicks

nick su tutti i canali del server IRC corrente

irc

irc_server_privates

privati sul server IRC corrente

irc

irc_servers

server IRC (nomi interni)

irc

nick

nick del canale IRC corrente

lua

lua_script

elenco degli script

perl

perl_script

elenco degli script

python

python_script

elenco degli script

relay

relay_free_port

prima porta libera per il plugin relay

relay

relay_protocol_name

protocollo.nome possibile per il plugin relay

relay

relay_relays

protocollo.nome dei relay correnti per il plugin relay

ruby

ruby_script

elenco degli script

tcl

tcl_script

elenco degli script

weechat

bars_names

nomi delle barre

weechat

bars_options

opzioni per le barre

weechat

buffer_properties_get

proprietà che possono essere lette su un buffer

weechat

buffer_properties_set

proprietà che possono essere impostate su un buffer

weechat

buffers_names

nomi dei buffer

weechat

buffers_numbers

numeri dei buffer

weechat

buffers_plugins_names

nomi dei buffer (inclusi i nomi plugin)

weechat

commands

comandi (weechat e plugin)

weechat

config_files

file di configurazione

weechat

config_option_values

valori per una opzione di configurazione

weechat

config_options

opzioni di configurazione

weechat

filename

nome file

weechat

filters_names

nomi dei filtri

weechat

infolists

nomi degli hook liste info

weechat

infos

nomi degli hook sulle info

weechat

keys_codes

codici tasti

weechat

keys_codes_for_reset

codici tasti che possono essere ripristinati (tasti aggiunti, ridefiniti o rimossi)

weechat

nicks

nick nella lista nick del buffer corrente

weechat

plugins_commands

comandi definiti dai plugin

weechat

plugins_names

nomi dei plugin

weechat

proxies_names

nomi dei proxy

weechat

proxies_options

opzioni per i proxy

weechat

weechat_commands

comandi di weechat

xfer

nick

nick della chat DCC

Codici speciali:

Valore restituito:

Esempio in C:

int
my_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
               char **argv, char **argv_eol)
{
    /* ... */
    return WEECHAT_RC_OK;
}

/* questo esempio si ispira al comando /filter */
struct t_hook *my_command_hook =
    weechat_hook_command (/* nome comando */
                          "myfilter",
                          /* description */
                          "description of myfilter",
                          /* args */
                          "[list] | [enable|disable|toggle [name]] | "
                          "[add name plugin.buffer tags regex] | "
                          "[del name|-all]",
                          /* args description */
                          "description of arguments...",
                          /* completion */
                          "list"
                          " || enable %(filters_names)"
                          " || disable %(filters_names)"
                          " || toggle %(filters_names)"
                          " || add %(filters_names) %(buffers_plugins_names)|*"
                          " || del %(filters_names)|-all",
                          /* callback */
                          &my_command_cb,
                          /* callback_data */
                          NULL);

Ad esempio, se il comando chiamato è /comando abc def ghi, allora argv e argv_eol contengono i seguenti valori:

Script (Python):

# prototipo
hook = weechat.hook_command(command, description, args, args_description,
    completion, callback, callback_data)

# esempio
def my_command_cb(data, buffer, args):
    # ...
    return weechat.WEECHAT_RC_OK

hook = weechat.hook_command("myfilter", "descrizione di myfilter",
    "[list] | [enable|disable|toggle [name]] | "
    "[add name plugin.buffer tags regex] | "
    "[del name|-all]",
    "description of arguments...",
    "list"
    " || enable %(filters_names)"
    " || disable %(filters_names)"
    " || toggle %(filters_names)"
    " || add %(filters_names) %(buffers_plugins_names)|*"
    " || del %(filters_names)|-all",
    "my_command_cb", "")

3.10.2. weechat_hook_command_run

Hook su un comando quando eseguito da WeeChat.

Prototipo:

struct t_hook *weechat_hook_command_run (const char *command,
                                         int (*callback)(void *data,
                                                         struct t_gui_buffer *buffer,
                                                         const char *command),
                                         void *callback_data);

Argomenti:

Note
La callback può restituire WEECHAT_RC_OK o WEECHAT_RC_OK_EAT (il comando non verrà eseguito da WeeChat dopo la callback).

Valore restituito:

Esempio in C:

int
my_command_run_cb (void *data, struct t_gui_buffer *buffer,
                   const char *command)
{
    weechat_printf (NULL,
                    "Vuoi completare? Sto mangiando il completamento, ahah!);
    return WEECHAT_RC_OK_EAT;
}

struct t_hook *my_command_run_hook =
    weechat_hook_command_run ("/input complete*",
                              &my_command_run_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_command_run(command, callback, callback_data)

# esempio
def my_command_run_cb(data, buffer, command):
    weechat.prnt("". "Vuoi completare? Sto mangiando il completamento, ahah!")
    return weechat.WEECHAT_RC_OK_EAT

hook = weechat.hook_command_run("/input complete*", "my_command_run_cb", "")

3.10.3. weechat_hook_timer

Hook sul timer.

Prototipo:

struct t_hook *weechat_hook_timer (long interval,
                                   const char *align_second,
                                   const char *max_calls,
                                   int (*callback)(void *data,
                                                   int remaining_calls),
                                   void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_timer_cb (void *data, int remaining_calls)
{
    /* ... */
    return WEECHAT_RC_OK;
}

/* timer chiamato ogni 20 secondi */
struct t_hook *my_timer_hook =
    weechat_hook_timer (20 * 1000, 0, 0, &my_timer_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_timer(interval, align_second, max_calls, callback, callback_data)

# esempio
def my_timer_cb(data, remaining_calls):
    # ...
    return weechat.WEECHAT_RC_OK

# timer chiamato ogni 20 secondi
hook = weechat.hook_timer(20 * 1000, 0, 0, "my_timer_cb", "")

3.10.4. weechat_hook_fd

Hook su un descrittore file (file oppure socket).

Prototipo:

struct t_hook *weechat_hook_fd (int fd,
                                int flag_read,
                                int flag_write,
                                int flag_exception,
                                int (*callback)(void *data,
                                                int fd),
                                void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_fd_cb (void *data, int fd)
{
    /* ... */
    return WEECHAT_RC_OK;
}

int sock = socket (AF_INET, SOCK_STREAM, 0);
/* imposta le opzioni del socket */
/* ... */
struct t_hook *my_fd_hook = weechat_hook_fd (sock, 1, 0, 0, &my_fd_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_fd(fd, flag_read, flag_write, flag_exception, callback, callback_data)

# esempio
def my_fd_cb(data, fd):
    # ...
    return weechat.WEECHAT_RC_OK

sock = ...
hook = weechat.hook_fd(sock, 1, 0, 0, "my_fd_cb", "")

3.10.5. weechat_hook_process

Hook su un processo (lanciato con un fork), e cattura l’output.

Prototipo:

struct t_hook *weechat_hook_process (const char *command,
                                     int timeout,
                                     int (*callback)(void *data,
                                                     const char *command,
                                                     int return_code,
                                                     const char *out,
                                                     const char *err),
                                     void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_process_cb (void *data, const char *command, int return_code,
               const char *out, const char *err)
{
    if (return_code == WEECHAT_HOOK_PROCESS_ERROR)
    {
        weechat_printf (NULL, "Errore con il comando '%s'", command);
        return WEECHAT_RC_OK;
    }

    if (return_code >= 0)
    {
        weechat_printf (NULL, "return_code = %d", return_code);
    }

    if (out)
    {
        weechat_printf (NULL, "stdout: %s", out);
    }

    if (err)
    {
        weechat_printf (NULL, "stderr: %s", err);
    }

    return WEECHAT_RC_OK;
}

struct t_hook *my_process_hook = weechat_hook_process ("ls", 5000,
                                                       &my_process_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_process(command, timeout, callback, callback_data)

# esempio
def my_process_cb(data, command, return_code, out, err):
    if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR:
        weechat.prnt("", "Error with command '%s'" % command)
        return weechat.WEECHAT_RC_OK
    if return_code >= 0:
        weechat.prnt("", "return_code = %d" % return_code)
    if out != "":
        weechat.prnt("", "stdout: %s" % out)
    if err != "":
        weechat.prnt("", "stderr: %s" % err)
    return weechat.WEECHAT_RC_OK

hook = weechat.hook_process("ls", 5000, "my_process_cb", "")

3.10.6. weechat_hook_connect

Hook su una connessione (connessione in secondo piano ad un host remoto).

Prototipo:

struct t_hook *weechat_hook_connect (const char *proxy,
                                     const char *address,
                                     int port,
                                     int sock,
                                     int ipv6,
                                     void *gnutls_sess,
                                     void *gnutls_cb,
                                     int gnutls_dhkey_size,
                                     const char *local_hostname,
                                     int (*callback)(void *data,
                                                     int status,
                                                     int gnutls_rc,
                                                     const char *error,
                                                     const char *ip_address),
                                     void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_connect_cb (void *data, int status, int gnutls_rc, const char *error,
               const char *ip_address)
{
    switch (status)
    {
        case WEECHAT_HOOK_CONNECT_OK:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_PROXY_ERROR:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR:
            /* ... */
            break;
        case WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
            /* ... */
            break;
    }
    return WEECHAT_RC_OK;
}

struct t_hook *my_connect_hook = weechat_hook_connect (NULL,
                                                       "my.server.org", 1234,
                                                       sock, 0,
                                                       NULL, NULL, 0, /* GnuTLS */
                                                       NULL,
                                                       &my_connect_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_connect(proxy, address, port, sock, ipv6, local_hostname,
    callback, callback_data)

# esempio
def my_connect_cb(data, status, gnutls_rc, error, ip_address):
    if status == WEECHAT_HOOK_CONNECT_OK:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_PROXY_ERROR:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR:
        # ...
    elif status == WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
        # ...
    return weechat.WEECHAT_RC_OK

hook = weechat.hook_connect("", "my.server.org", 1234, sock, 0, "",
                            "my_connect_cb", "")

3.10.7. weechat_hook_print

Hook su un messaggio stampato.

Prototipo:

struct t_hook *weechat_hook_print (struct t_gui_buffer *buffer,
                                   const char *tags,
                                   const char *message,
                                   int strip_colors,
                                   int (*callback)(void *data,
                                                   struct t_gui_buffer *buffer,
                                                   time_t date,
                                                   int tags_count,
                                                   const char **tags,
                                                   int displayed,
                                                   int highlight,
                                                   const char *prefix,
                                                   const char *message),
                                   void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
             int tags_count, const char **tags,
             int displayed, int highlight,
             const char *prefix, const char *message)
{
    /* ... */
    return WEECHAT_RC_OK;
}

/* cattura tutti i messaggi, su tutti i buffer, senza colore */
struct t_hook *my_print_hook =
    weechat_hook_print (NULL, NULL, NULL, 1, &my_print_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_print(buffer, tags, message, strip_colors, callback, callback_data)

# esempio
def my_print_cb(data, buffer, date, tags, displayed, highlight, prefix, message):
    # ...
    return weechat.WEECHAT_RC_OK

# cattura tutti i messaggi, su tutti i buffer, senza colore
hook = weechat.hook_print("", "", "", 1, "my_print_cb", "")

3.10.8. weechat_hook_signal

Hook su un segnale.

Prototipo:

struct t_hook *weechat_hook_signal (const char *signal,
                                    int (*callback)(void *data,
                                                    const char *signal,
                                                    const char *type_data,
                                                    void *signal_data),
                                    void *callback_data);

Argomenti:

Plugin Segnale Argomenti Descrizione

irc

xxx,irc_in_yyy (1)

string: messaggio

messaggio irc dal server (prima di essere utilizzato dal plugin irc, il segnale viene inviato solo se il messaggio non viene ignorato)

irc

xxx,irc_in2_yyy (1)

string: messaggio

messaggio irc dal server (dopo essere stato utilizzato dal plugin irc, il segnale viene inviato solo se il messaggio non viene ignorato)

irc

xxx,irc_raw_in_yyy (1)

string: messaggio

messaggio irc dal server (prima di essere utilizzato dal plugin irc, il segnale viene inviato anche se il messaggio è stato ignorato)

irc

xxx,irc_raw_in2_yyy (1)

string: messaggio

messaggio irc dal server (dopo essere stato utilizzato dal plugin irc, il segnale viene inviato anche se il messaggio è stato ignorato)

irc

xxx,irc_out_yyy 1

string: messaggio

messaggio irc inviato al server

irc

irc_ctcp

string: messaggio

CTCP ricevuto

irc

irc_dcc

string: messaggio

nuova DCC

irc

irc_pv

string: messaggio

messaggio privato ricevuto

irc

irc_channel_opened

puntatore: buffer

canale aperto

irc

irc_pv_opened

puntatore: buffer

chat privata aperta

irc

irc_server_connecting

string: nome server

connessione al server

irc

irc_server_connected

string: nome server

connesso al server

irc

irc_server_disconnected

string: nome server

disconnesso dal server

irc

irc_ignore_removing

puntatore: ignore

rimozione dell’ignore

irc

irc_ignore_removed

-

ignore rimosso

logger

logger_start

puntatore: buffer avvia il logging per il buffer

logger

logger_stop

puntatore: buffer

ferma il logging per il buffer

logger

logger_backlog

puntatore: buffer

visualizza log precedenti per il buffer

weechat

buffer_closing

puntatore: buffer

chiusura del buffer

weechat

buffer_closed

puntatore: buffer

buffer chiuso

weechat

buffer_lines_hidden

puntatore: buffer

righe nascoste nel buffer

weechat

buffer_localvar_added

puntatore: buffer

variabili locali aggiunte

weechat

buffer_localvar_changed

puntatore: buffer

variabili locali modificate

weechat

buffer_localvar_removed

puntatore: buffer

variabili locali rimosse

weechat

buffer_moved

puntatore: buffer

buffer spostato

weechat

buffer_opened

puntatore: buffer

buffer aperto

weechat

buffer_renamed

puntatore: buffer

buffer rinominato

weechat

buffer_switch

puntatore: buffer

passaggio tra buffer

weechat

buffer_title_changed

puntatore: buffer

titolo del buffer modificato

weechat

buffer_type_changed

puntatore: buffer

tipo di buffer modificato

weechat

debug_dump

-

richiesta di dump

weechat

day_changed

string: nuova data, formato: "2010-01-31"

data di sistema modificata

weechat

filter_added

puntatore: filtro filtro aggiunto

weechat

filter_removing

puntatore: filtro

rimozione del filtro

weechat

filter_removed

-

filtro rimosso

weechat

filter_enabled

-

filtri abilitati

weechat

filter_disabled

-

filtri disabilitati

weechat

hotlist_changed

-

hotlist modificata

weechat

input_paste_pending

-

incolla testo in attesa

weechat

input_search

-

ricerca testo nel buffer

weechat

input_text_changed

-

testo in input modificato

weechat

input_text_cursor_moved

-

cursore del testo di input spostato

weechat

key_pressed

string: tasto digitato

tasto digitato

weechat

nicklist_group_added

string: buffer pointer + "," + group name

group added in nicklist

weechat

nicklist_group_removed

string: buffer pointer + "," + group name

group removed from nicklist

weechat

nicklist_nick_added

string: buffer pointer + "," + nick name

nick added in nicklist

weechat

nicklist_nick_removed

string: buffer pointer + "," + nick name

nick removed from nicklist

weechat

partial_completion

-

completamento parziale avvenuto

weechat

quit

string: argomenti per /quit

comando /quit digitato dall’utente

weechat

upgrade

-

comando /upgrade digitato dall’utente

weechat

weechat_highlight

string: messaggio con prefisso

evento accaduto

weechat

weechat_pv

string: messaggio con prefisso

messaggio privato visualizzato

weechat

window_scrolled

puntatore: finestra

scroll nella finestra

weechat

window_unzooming

puntatore: finestra corrente

minimizzazione della finestra

weechat

window_unzoomed

puntatore: finestra corrente

window unzoomed finestra minimizzata

weechat

window_zooming

puntatore: finestra corrente

massimizzazione della finestra

weechat

window_zoomed

puntatore: finestra corrente

finestra massimizzata

xfer

xfer_add

puntatore: lista info con info per xfer

nuovo xfer

xfer

xfer_send_ready

puntatore: lista info xon info per xfer

xfer pronto

xfer

xfer_accept_resume

puntatore: lista info con info per xfer

xfer accetta la ripresa

xfer

xfer_send_accept_resume

puntatore: lista info con info per xfer

xfer accetta la ripresa (invio)

xfer

xfer_start_resume

puntatore: lista info con info per xfer

avvia ripresa

xfer

xfer_resume_ready

puntatore: lista info con info per xfer

ripresa xfer pronta

xfer

xfer_ended

Note
(1) xxx è il nome del server IRC, yyy è il nome del comando IRC.

Valore restituito:

Esempio in C:

int
my_signal_cb (void *data, const char *signal, const char *type_data,
              void *signal_data)
{
    /* ... */
    return WEECHAT_RC_OK;
}

/* cattura il segnale "quit" */
struct t_hook *my_signal_hook = weechat_hook_signal ("quit",
                                                     &my_signal_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_signal(signal, callback, callback_data)

# esempio
def my_signal_cb(data, signal, signal_data):
    # ...
    return weechat.WEECHAT_RC_OK

# cattura il segnale "quit"
hook = weechat.hook_signal("quit", "my_signal_cb", "")

3.10.9. weechat_hook_signal_send

Invia un segnale.

Prototipo:

void weechat_hook_signal_send (const char *signal, const char *type_data,
                               void *signal_data);

Argomenti:

Esempio in C:

weechat_hook_signal_send ("my_signal", WEECHAT_HOOK_SIGNAL_STRING, my_string);

Script (Python):

# prototipo
weechat.hook_signal_send(signal, type_data, signal_data)

# esempio
weechat.hook_signal_send("my_signal", weechat.WEECHAT_HOOK_SIGNAL_STRING, my_string)

3.10.10. weechat_hook_config

Hook su un’opzione di configurazione.

Prototipo:

struct t_hook *weechat_hook_config (const char *option,
                                    int (*callback)(void *data,
                                                    const char *option,
                                                    const char *value),
                                    void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_config_cb (void *data, const char *option, const char *value)
{
    /* ... */
    return WEECHAT_RC_OK;
}

/* cattura le modifiche dell'opzione "weechat.look.item_time_format" */
struct t_hook *my_config_hook = weechat_hook_config ("weechat.look.item_time_format",
                                                     &my_config_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_config(option, callback, callback_data)

# esempio
def my_config_cb(data, option, value):
    # ...
    return weechat.WEECHAT_RC_OK

# cattura le modifiche dell'opzione "weechat.look.item_time_format"
hook = weechat.hook_config("weechat.look.item_time_format", "my_config_cb", "")

3.10.11. weechat_hook_completion

Hook su un completamento.

Prototipo:

struct t_hook *weechat_hook_completion (const char *completion_item,
                                        const char *description,
                                        int (*callback)(void *data,
                                                        const char *completion_item,
                                                        struct t_gui_buffer *buffer,
                                                        struct t_gui_completion *completion),
                                        void *callback_data);

Argomenti:

Note
I nomi del completamento sono globali (condivisi tra WeeChat e plugin). Si raccomanda pertanto di scegliere un nome con un prefisso unico, come "plugin_xxx" (dove "xxx" è il nome del proprio elemento).

Valore restituito:

Esempio in C:

int
my_completion_cb (void *data, const char *completion_item,
                  struct t_gui_buffer *buffer,
                  struct t_gui_completion *completion)
{
    weechat_hook_completion_list_add (completion, "word1",
                                      0, WEECHAT_LIST_POS_SORT);
    weechat_hook_completion_list_add (completion, "test_word2",
                                      0, WEECHAT_LIST_POS_SORT);
    return WEECHAT_RC_OK;
}

struct t_hook *my_completion_hook = weechat_hook_completion ("plugin_item",
                                                             "my custom completion!",
                                                             &my_completion_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_completion(completion_item, description, callback, callback_data)

# esempio
def my_completion_cb(data, completion_item, buffer, completion):
    weechat.hook_completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
    weechat.hook_completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
    return weechat.WEECHAT_RC_OK

hook = weechat.hook_completion("plugin_item", "my custom completion!",
                               "my_completion_cb", "")

3.10.12. weechat_hook_completion_list_add

Aggiunge una parola per il completamento.

Prototipo:

void weechat_hook_completion_list_add (struct t_gui_completion *completion,
                                       const char *word,
                                       int nick_completion,
                                       const char *where);

Argomenti:

Esempio in C: consultare weechat_hook_completion.

Script (Python):

# prototipo
weechat.hook_completion_list_add(completion, word, nick_completion, where)

# esempio: consultare function hook_completion precedente

3.10.13. weechat_hook_modifier

Hook su un modificatore.

Prototipo:

struct t_hook *weechat_hook_modifier (const char *modifier,
                                      char *(*callback)(void *data,
                                                        const char *modifier,
                                                        const char *modifier_data,
                                                        const char *string),
                                      void *callback_data);

Argomenti:

Plugin Modificatore Dati modificatore Stringa Output

charset

charset_decode

plugin.buffer_name

qualsiasi stringa

stringa codificata dal set caratteri trovato per plugin/buffer in UTF-8

charset

charset_encode

plugin.buffer_name

qualsiasi stringa

stringa codificata da UTF-8 al set caratteri trovato per il plugin/buffer

irc

irc_color_decode

"1" per mantenere i colori, "0" per rimuovere i colori

qualsiasi stringa

stringa con i codici colori di Weechat, o senza colore

irc

irc_color_encode

"1" per mantenere i colori, "0" per rimuovere i colori

qualsiasi stringa

stringa con i codici colori IRC, o senza colore

irc

irc_in_xxx 1

nome server

contenuto del messaggio ricevuto dal server IRC

nuovo contenuto del messaggio

irc

irc_out_xxx 1

nome server

contenuto del messaggio che sta per essere inviato al server IRC

nuovo contenuto del messaggio

weechat

bar_condition_yyy 2

stringa con puntatore alla finestra ("0x123..")

stringa vuota

"1" per visualizzare la barra, "0" per nasconderla

weechat

history_add

stringa con puntatore al buffer ("0x123..")

input buffer (from user) to add in command history (buffer and global)

string added to command history

weechat

input_text_content

stringa con puntatore al buffer ("0x123..")

input buffer (dall’utente)

nuovo contenuto del buffer di input

weechat

input_text_display

stringa con puntatore al buffer ("0x123..")

buffer di input (dall’utente), senza tag di cursore

nuovo contenuto del buffer di input, solo per visualizzazione (il buffer di input non è modificato)

weechat

input_text_display_with_cursor

stringa con puntatore al buffer ("0x123..")

buffer di input (dall’utente), con tag di cursore

nuovo contenuto del buffer di input, solo per la visualizzazione (buffer di input non è modificato)

weechat

weechat_print

plugin;buffer_name;tags

messaggio stampato

nuovo messaggio stampato

Note
1 xxx è il nome del comando IRC.
2 yyy è il nome della barra.

Valore restituito:

Esempio in C:

char *
my_modifier_cb (void *data, const char *modifier,
                const char *modifier_data,
                const char *string)
{
    char *result;
    int length;

    if (!string)
        return NULL;

    length = strlen (string) + 5;
    result = malloc (length);
    if (result)
    {
        /* aggiunge "xxx" ad ogni messaggio stampato */
        snprintf (result, length, "%s xxx", string);
    }

    return result;
}

struct t_hook *my_modifier_hook = weechat_hook_modifier ("weechat_print",
                                                         &my_modifier_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_modifier(modifier, callback, callback_data)

# esempio
def my_modifier_cb(data, modifier, modifier_data, string):
    return "%s xxx" % string

hook = weechat.hook_modifier("weechat_print", "my_modifier_cb", "")

3.10.14. weechat_hook_modifier_exec

Esegue modificatore(i).

Prototipo:

char *weechat_hook_modifier_exec (const char *modifier,
                                  const char *modifier_data,
                                  const char *string);

Argomenti:

Valore restituito:

Esempio in C:

char *new_string = weechat_hook_modifier_exec ("my_modifier",
                                               my_data, my_string);

Script (Python):

# prototipo
weechat.hook_modifier_exec(modifier, modifier_data, string)

# esempio
weechat.hook_modifier_exec("my_modifier", my_data, my_string)

3.10.15. weechat_hook_info

Hook su una informazione.

Prototipo:

struct t_hook *weechat_hook_info (const char *info_name,
                                  const char *description,
                                  const char *args_description,
                                  const char *(*callback)(void *data,
                                                          const char *info_name,
                                                          const char *arguments),
                                  void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

const char *
my_info_cb (void *data, const char *info_name, const char *arguments)
{
    /* ... */
    return pointer_to_string;
}

/* aggiunge informazione "my_info" */
struct t_hook *my_info_hook = weechat_hook_info ("my_info",
                                                 "Some info",
                                                 "Info about arguments",
                                                 &my_info_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_info(info_name, description, args_description, callback, callback_data)

# esempio
def my_info_cb(data, info_name, arguments):
    return "some_info"

hook = weechat.hook_info("my_info", "Some info", "Info about arguments",
                         "my_info_cb", "")

3.10.16. weechat_hook_infolist

Hook su una lista info: la callback restituisce il puntatore alla lista info richiesta.

Prototipo:

struct t_hook *weechat_hook_infolist (const char *infolist_name,
                                      const char *description,
                                      const char *pointer_description,
                                      const char *args_description,
                                      const char *(*callback)(void *data,
                                                              const char *infolist_name,
                                                              void *pointer,
                                      const char *arguments),
                                      void *callback_data);

Argomenti:

Valore restituito:

Esempio in C:

struct t_infolist *
my_infolist_cb (void *data, const char *infolist_name, void *pointer,
                const char *arguments)
{
    struct t_infolist *my_infolist;

    /* compila lista info */
    /* ... */

    return my_infolist;
}

/* aggiunge lista info "my_infolist" */
struct t_hook *my_infolist = weechat_hook_infolist ("my_infolist",
                                                    "Infolist with some data",
                                                    "Info about pointer",
                                                    "Info about arguments",
                                                    &my_infolist_cb, NULL);

Script (Python):

# prototipo
hook = weechat.hook_infolist(infolist_name, description, pointer_description,
                             args_description, callback, callback_data)

# esempio
def my_infolist_cb(data, infolist_name, pointer, arguments):
    # build infolist
    # ...
    return my_infolist

hook = weechat.hook_infolist("my_infolist", "Infolist with some data",
                             "Info about pointer", "Info about arguments",
                             "my_infolist_cb", "")

3.10.17. weechat_unhook

Rimuove un hook.

Prototipo:

void weechat_unhook (struct t_hook *hook);

Argomenti:

Esempio in C:

struct t_hook *my_hook = weechat_hook_command ( /* ... */ );
/* ... */
weechat_unhook (my_hook);

Script (Python):

# prototipo
weechat.unhook(hook)

# esempio
weechat.unhook(my_hook)

3.10.18. weechat_unhook_all

Rimuove l’hook in qualsiasi punto in cui è stato attivato dal plugin corrente.

Prototipo:

void weechat_unhook_all ();

Esempio in C:

weechat_unhook_all ();

Script (Python):

# prototipo
weechat.unhook_all()

# esempio
weechat.unhook_all()

3.11. Buffer

Funzioni per creare/richiedere/chiudere buffer.

3.11.1. weechat_buffer_new

Apre un nuovo buffer.

Prototipo:

struct t_gui_buffer *weechat_buffer_new (const char *name,
                                         int (*input_callback)(void *data,
                                                               struct t_gui_buffer *buffer,
                                                               const char *input_data),
                                         void *input_callback_data,
                                         int (*close_callback)(void *data,
                                                               struct t_gui_buffer *buffer),
                                         void *close_callback_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_input_cb (void *data, struct t_gui_buffer *buffer, const char *input_data)
{
    weechat_printf (buffer, "Testo: %s", input_data);
    return WEECHAT_RC_OK;
}

int
my_close_cb (void *data, struct t_gui_buffer *buffer)
{
    weechat_printf (NULL, "Il buffer '%s' verrà chiuso!",
                    weechat_buffer_get_string (buffer, "name"));
    return WEECHAT_RC_OK;
}

struct t_gui_buffer *my_buffer = weechat_buffer_new ("my_buffer",
                                                     &my_input_cb, NULL,
                                                     &my_close_cb, NULL);

Script (Python):

# prototipo
buffer = weechat.buffer_new(name, input_callback, input_callback_data,
    close_callback, close_callback_data)

# esempio
def my_input_cb(data, buffer, input_data):
    weechat.prnt(buffer, "Testo: %s" % input_data)
    return weechat.WEECHAT_RC_OK

def my_close_cb(data, buffer):
    weechat.prnt("", "Il buffer '%s' verrà chiuso!" % weechat.buffer_get_string(buffer, "name"))
    return weechat.WEECHAT_RC_OK

buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")

3.11.2. weechat_current_buffer

Restituisce il puntatore al buffer corrente (buffer visualizzato nella finestra corrente).

Prototipo:

struct t_gui_buffer *weechat_current_buffer ();

Valore restituito:

Esempio in C:

weechat_printf (weechat_current_buffer (), "Testo sul buffer corrente");

Script (Python):

# prototipo
buffer = weechat.current_buffer()

# esempio
weechat.prnt(weechat.current_buffer(), "Testo sul buffer corrente")

Cerca un buffer tramite plugin e/o nome.

Prototipo:

struct t_gui_buffer *weechat_buffer_search (const char *plugin,
                                            const char *name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_gui_buffer *my_buffer = weechat_buffer_search ("my_plugin",
                                                        "my_buffer");

Script (Python):

# prototipo
buffer = weechat.buffer_search(plugin, name)

# esempio
buffer = weechat.buffer_search("my_plugin", "my_buffer")

3.11.4. weechat_buffer_search_main

Cerca nel buffer principale di WeeChat (per primo nel buffer core, il primo visualizzato all’avvio di WeeChat).

Prototipo:

struct t_gui_buffer *weechat_buffer_search_main ();

Valore restituito:

Esempio in C:

struct t_gui_buffer *weechat_buffer = weechat_buffer_search_main ();

Script (Python):

# prototipo
buffer = weechat.buffer_search_main()

# esempio
buffer = weechat.buffer_search_main()

3.11.5. weechat_buffer_clear

Pulisce il contenuto del buffer.

Prototipo:

void weechat_buffer_clear (struct t_gui_buffer *buffer);

Argomenti:

Esempio in C:

struct t_gui_buffer *my_buffer = weechat_buffer_search ("my_plugin",
                                                        "my_buffer");
if (my_buffer)
{
    weechat_buffer_clear (my_buffer);
}

Script (Python):

# prototipo
weechat.buffer_clear(buffer)

# esempio
buffer = weechat.buffer_search("my_plugin", "my_buffer")
if buffer != "":
    weechat.buffer_clear(buffer)

3.11.6. weechat_buffer_close

Chiude un buffer.

Prototipo:

void weechat_buffer_close (struct t_gui_buffer *buffer);

Argomenti:

Esempio in C:

struct t_gui_buffer *my_buffer = weechat_buffer_new ("my_buffer",
                                                     &my_input_cb, NULL,
                                                     &my_close_cb, NULL);
/* ... */
weechat_buffer_close (my_buffer);

Script (Python):

# prototipo
weechat.buffer_close(buffer)

# esempio
buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")
# ...
weechat.buffer_close(buffer)

3.11.7. weechat_buffer_merge

Unisce un buffer in un altro: entrambi i buffer esistono separatamente, ma con lo stesso numero, e WeeChat visualizzerà le righe di entrambi i buffer (righe mischiate).

Prototipo:

void weechat_buffer_merge (struct t_gui_buffer *buffer,
                           struct t_gui_buffer *target_buffer);

Argomenti:

Esempio in C:

/* merge current buffer with weechat "core" buffer */
weechat_buffer_merge (weechat_current_buffer (),
                      weechat_buffer_search_main ());

Script (Python):

# prototipo
weechat.buffer_merge(buffer, target_buffer)

# esempio
# merge current buffer with WeeChat "core" buffer
weechat.buffer_merge(weechat.current_buffer(), weechat.buffer_search_main())

3.11.8. weechat_buffer_unmerge

Stacca un buffer da un gruppo di buffer uniti.

Prototipo:

void weechat_buffer_unmerge (struct t_gui_buffer *buffer,
                             int number);

Argomenti:

Esempio in C:

weechat_buffer_unmerge (weechat_current_buffer (), 1);

Script (Python):

# prototipo
weechat.buffer_unmerge(buffer, number)

# esempio
weechat.buffer_unmerge(weechat.current_buffer(), 1)

3.11.9. weechat_buffer_get_integer

Restituisce il valore intero della proprietà di un buffer.

Prototipo:

int weechat_buffer_get_integer (struct t_gui_buffer *buffer,
                                const char *property);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "my buffer number is: %d",
                weechat_buffer_get_integer (my_buffer, "number"));

Script (Python):

# prototipo
value = weechat.buffer_get_integer(buffer, property)

# esempio
weechat.prnt("", "my buffer number is: %d" % weechat.buffer_get_integer(my_buffer, "number"))

3.11.10. weechat_buffer_get_string

Restituisce il valore stringa di una proprietà del buffer.

Prototipo:

const char *weechat_buffer_get_string (struct t_gui_buffer *buffer,
                                       const char *property);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "name / short name of buffer are: %s / %s",
                weechat_buffer_get_string (my_buffer, "name"),
                weechat_buffer_get_string (my_buffer, "short_name"));

Script (Python):

# prototipo
value = weechat.buffer_get_string(buffer, property)

# esempio
weechat.prnt("", "name / short name of buffer are: %s / %s"
    % (weechat.buffer_get_string(my_buffer, "name"),
    weechat.buffer_get_string(my_buffer, "short_name")))

3.11.11. weechat_buffer_get_pointer

Restituisce il valore puntatore della proprietà di un buffer.

Prototipo:

const char *weechat_buffer_pointer (struct t_gui_buffer *buffer,
                                    const char *property);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "plugin pointer of my buffer: %lx",
                weechat_buffer_get_pointer (my_buffer, "plugin"));

Script (Python):

# prototipo
value = weechat.buffer_get_pointer(buffer, property)

# esempio
weechat.prnt("", "plugin pointer of my buffer: %lx" % weechat.buffer_get_pointer(my_buffer, "plugin"))

3.11.12. weechat_buffer_set

Imposta il valore stringa della proprietà di un buffer.

Prototipo:

void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
                         const char *value);

Argomenti:

Nome Valore Descrizione

hotlist

"+", "-", WEECHAT_HOTLIST_LOW, WEECHAT_HOTLIST_MESSAGE, WEECHAT_HOTLIST_PRIVATE, WEECHAT_HOTLIST_HIGHLIGHT

"+": abilita hotlist (impostazione globale , il puntatore al buffer pointer non è utilizzato)
"-": disabilita hotlist (impostazione globale, il puntatore al buffer non è utilizzato)
priorità: aggiunge il buffer alla hotlist con questa proprietà

unread

-

imposta l’evidenziatore di lettura dopo l’ultima riga del buffer

display

"1", "auto"

"1": passa a questo buffer nella finestra corrente
"auto": passa a questo buffer nella finestra corrente, l’evidenziatore di lettura non viene resettato

number

numero

sposta buffer a questo numero

name

qualsiasi stringa

imposta nuovo nome per il buffer

short_name

qualsiasi stringa

imposta nuovo nome breve per il buffer

type

"formatted" oppure "free"

imposta tipo per il: "formatted" (per stampare i messaggi di chat), oppure "free" (per contenuto libero)

notify

"0", "1", "2", "3"

imposta il livello di notifica per il buffer: "0" = non aggiungere alla hotlist, "1" = aggiungere solo per gli eventi, "2" = aggiungere per eventi e messaggi, "3" = aggiungere per tutti i messaggi

title

qualsiasi stringa

imposta nuovo titolo per il buffer

time_for_each_line

"0" oppure "1"

"0" per nascondere l’orario in tutte le righe del buffer, "1" per visualizzarlo su tutte le righe (predefinito per un nuovo buffer)

nicklist

"0" oppure "1"

"0" per rimuovere la lista nick per il buffer, "1" per aggiungere la lista nick per il buffer

nicklist_case_sensitive

"0" oppure "1"

"0" per avere una lista nick case insenstive (maiuscole/minuscole ignorate), "1" per avere una lista nick case sensitive (maiuscole/minuscole non ignorate)

nicklist_display_groups

"0" oppure "1"

"0" per nascondere i gruppi nella lista nick, "1" per visualizzare i gruppi della lista nick

highlight_words

"-" oppure elenco di parole separato da virgole

"-" è un valore speciale per disabilitare qualsiasi evento su questo buffer, o un elenco di parole separate da virgole da evidenziare in questo buffer, ad esempio: "abc,def,ghi"

highlight_words_add

elenco di parole separate da virgole

elenco di parole separate da virgole da evidenziare in questo buffer, queste parole vengono aggiunte alle parole evidenziate esistenti nel buffer

highlight_words_del

elenco di parole separate da virgole

elenco di parole separate da virgole da rimuovere dalle parole evidenziate nel buffer

highlight_tags

elenco separato da virgole di tag

elenco separato da virgole di tag da evidenziare in questo buffer

key_bind_xxx

qualsiasi stringa

assegna un nuovo tasto xxx, specifico per questo buffer, il valore è il comando da eseguire per questo tasto

key_unbind_xxx

-

rimuove l’assegnazione del tasto xxx per questo buffer

input

qualsiasi stringa

imposta un nuovo valore per l’input del buffer

input_pos

posizione

imposta la posizione del cursore per l’input del buffer

input_get_unknown_commands

"0" oppure "1"

"0" per disabilitare i comandi sconosciuti per questo buffer (comportamento predefinito), "1" per ricevere i comandi sconosciuti, ad esempio se l’utente digita "/unknowncmd", verrà ricevuto dal buffer (nessun errore riguardo il comando sconosciuto)

localvar_set_xxx

qualsiasi stringa

imposta il nuovo valore per la variabile locale xxx (la variabile verrà creata se non esiste)

localvar_del_xxx

-

rimuove la variabile locale xxx

Esempio in C:

/* disabilita hotlist (per tutti i buffer) */
weechat_buffer_set (NULL, "hotlist", "-");

/* abilita nuovamente hotlist */
weechat_buffer_set (NULL, "hotlist", "+");

/* cambia il nome buffer */
weechat_buffer_set (my_buffer, "name", "my_new_name");

/* aggiunge una nuova variabile locale "tizio" con il valore "abc" */
weechat_buffer_set (my_buffer, "localvar_set_tizio", "abc");

/* rimuove la variabile locale "tizio" */
weechat_buffer_set (my_buffer, "localvar_del_tizio", NULL);

Script (Python):

# prototipo
weechat.buffer_set(buffer, property, value)

# esempi

# disabilita hotlist (per tutti i buffer)
weechat.buffer_set("", "hotlist", "-")

# abilita nuovamente hotlist
weechat.buffer_set("", "hotlist", "+")

# cambia il nome buffer
weechat.buffet_set(my_buffer, "name", "my_new_name")

# aggiunge una nuova variabile locale "tizio" con il valore "abc"
weechat.buffet_set(my_buffer, "localvar_set_tizio", "abc")

# rimuove la variabile locale "tizio"
weechat.buffet_set(my_buffer, "localvar_del_tizio", "")

3.11.13. weechat_buffer_set_pointer

Imposta il valore puntatore per la proprietà di un buffer.

Prototipo:

void weechat_buffer_set_pointer (struct t_gui_buffer *buffer, const char *property,
                                 void *pointer);

Argomenti:

Esempio in C:

int
my_close_cb (void *data, struct t_gui_buffer *buffer)
{
    /* ... */
    return WEECHAT_RC_OK;
}

weechat_buffer_set_pointer (my_buffer, "close_callback", &my_close_cb);

3.11.14. weechat_buffer_string_replace_local_var

Sostituisce le variabili globali in una stringa con i loro valori, utilizzando le variabili del buffer locale.

Prototipo:

char *weechat_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
                                               const char *string);

Argomenti:

Valore restituito:

Esempio in C:

weechat_buffer_set (my_buffer, "localvar_set_toto", "abc");

char *str = weechat_buffer_string_replace_local_var (my_buffer,
                                                     "test with $toto");
/* str contiene "test with abc" */

Script (Python):

# prototipo
value = weechat.buffer_string_replace_local_var(buffer, string)

# esempio
weechat.buffer_set(my_buffer, "localvar_set_toto", "abc")
str = weechat.buffer_string_replace_local_var(my_buffer, "test with $toto")
# str contains "test with abc"

3.12. Finestre

Funzioni per richiedere finestre.

3.12.1. weechat_current_window

Restituisce il puntatore alla finestra corrente

Prototipo:

struct t_gui_window *weechat_current_window ();

Valore restituito:

Esempio in C:

struct t_gui_window *current_window = weechat_current_window ();

Script (Python):

# prototipo
window = weechat.current_window()

# esempio
current_window = weechat.current_window()

3.12.2. weechat_window_get_integer

Restituisce il valore intero della proprietà di una finestra.

Prototipo:

int weechat_window_get_integer (struct t_gui_window *window,
                                const char *property);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "current window is at position (x,y): (%d,%d)",
                weechat_window_get_integer (weechat_current_window (), "win_x"),
                weechat_window_get_integer (weechat_current_window (), "win_y"));

Script (Python):

# prototipo
value = weechat.window_get_integer(window, property)

# esempio
weechat.prnt("", "current window is at position (x,y): (%d,%d)"
    % (weechat.window_get_integer(weechat.current_window(), "win_x"),
    weechat.window_get_integer(weechat.current_window(), "win_y")))

3.12.3. weechat_window_get_string

Restituisce il valore stringa della proprietà di una finestra.

Note
La funzione non è utilizzata oggi, è riservata per una versione futura.

Prototipo:

int weechat_window_get_string (struct t_gui_window *window,
                               const char *property);

Argomenti:

Valore restituito:

3.12.4. weechat_window_get_pointer

Restituisce il valore puntatore della proprietà di una finestra.

Prototipo:

void *weechat_window_get_pointer (struct t_gui_window *window,
                                  const char *property);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL,
                "buffer displayed in current window: %lx",
                weechat_window_get_pointer (weechat_current_window (), "buffer"));

Script (Python):

# prototipo
value = weechat.window_get_pointer(window, property)

# esempio
weechat.prnt("", "buffer displayed in current window: %lx"
    % weechat.window_get_pointer(weechat.current_window(), "buffer"))

3.12.5. weechat_window_set_title

Imposta il titolo per il terminale.

Prototipo:

void weechat_window_set_title (const char *title);

Argomenti:

Esempio in C:

weechat_window_set_title ("nuovo titolo qui");

Script (Python):

# prototipo
weechat.window_set_title(window, title)

# esempio
weechat.window_set_title("nuovo titolo qui")

3.13. Lista nick

Funzioni per il buffer nicklist.

3.13.1. weechat_nicklist_add_group

Aggiunge un gruppo in una lista nick.

Prototipo:

struct t_gui_nick_group *weechat_nicklist_add_group (struct t_gui_buffer *buffer,
                                                     struct t_gui_nick_group *parent_group,
                                                     const char *name,
                                                     const char *color,
                                                     int visible);

Argomenti:

Note
Il nome del gruppo può iniziare con uno o più numeri, seguiti da una pipe, e infine dal nome del gruppo. Quando questa stringa si trova all’inizio, viene utilizzata per ordinare i gruppi nella lista nick. Ad esempio i gruppi "1|test" e "2|abc" verranno visualizzati in quest’ordine: prima "test" poi "abc".

Valore restituito:

Esempio in C:

struct t_gui_nick_group *my_group =
    weechat_nicklist_add_group (my_buffer,
                                my_parent_group,
                                "test_group",
                                "weechat.color.nicklist_group",
                                1);

Script (Python):

# prototipo
group = weechat.nicklist_add_group(buffer, parent_group, name, color, visible)

# esempio
group = weechat.nicklist_add_group(my_buffer, my_parent_group, "test_group",
    "weechat.color.nicklist_group", 1)

3.13.2. weechat_nicklist_search_group

Cerca un gruppo in una lista nick.

Prototipo:

struct t_gui_nick_group *weechat_nicklist_search_group (struct t_gui_buffer *buffer,
                                                        struct t_gui_nick_group *from_group,
                                                        const char *name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
                                                                    NULL, "test_group");

Script (Python):

# prototipo
group = weechat.nicklist_search_group(buffer, from_group, name)

# esempio
group = weechat.nicklist_search_group(my_buffer, "", "test_group")

3.13.3. weechat_nicklist_add_nick

Aggiunge un nick in un gruppo.

Prototipo:

struct t_gui_nick_group *weechat_nicklist_add_nick (struct t_gui_buffer *buffer,
                                                    struct t_gui_nick_group *group,
                                                    const char *name,
                                                    const char *color,
                                                    const char *prefix,
                                                    const char *prefix_color,
                                                    int visible);

Argomenti:

Valore restituito:

Esempio in C:

struct t_gui_nick *my_nick =
    weechat_nicklist_add_nick (my_buffer, my_group,
                               "test_nick",
                               (nick_away) ? "weechat.color.nicklist_away" : "bar_fg",
                               "@", "lightgreen",
                               1);

Script (Python):

# prototipo
nick = weechat.nicklist_add_nick(buffer, group, name, color, prefix, prefix_color, visible)

# esempio
if nick_away:
    color = "weechat.color.nicklist_away"
else:
    color = "bar_fg"
nick = weechat.nicklist_add_nick(my_buffer, my_group, "test_nick", color, "@", "lightgreen", 1)

3.13.4. weechat_nicklist_search_nick

Cerca un nick nella lista nick.

Prototipo:

struct t_gui_nick *weechat_nicklist_search_nick (struct t_gui_buffer *buffer,
                                                 struct t_gui_nick_group *from_group,
                                                 const char *name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
                                                            NULL, "test_nick");

Script (Python):

# prototipo
nick = weechat.nicklist_search_nick(buffer, from_group, name)

# esempio
nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")

3.13.5. weechat_nicklist_remove_group

Rimuove un gruppo da una lista nick.

Prototipo:

void weechat_nicklist_remove_group (struct t_gui_buffer *buffer,
                                    struct t_gui_nick_group *group);

Argomenti:

Esempio in C:

weechat_nicklist_remove_group (my_buffer, my_group);

Script (Python):

# prototipo
weechat.nicklist_remove_group(buffer, group)

# esempio
weechat.nicklist_remove_group(my_buffer, my_group)

3.13.6. weechat_nicklist_remove_nick

Rimuove un nick dalla lista nick.

Prototipo:

void weechat_nicklist_remove_nick (struct t_gui_buffer *buffer,
                                   struct t_gui_nick *nick);

Argomenti:

Esempio in C:

weechat_nicklist_remove_nick (my_buffer, my_nick);

Script (Python):

# prototipo
weechat.nicklist_remove_nick(buffer, nick)

# esempio
weechat.nicklist_remove_nick(my_buffer, my_nick)

3.13.7. weechat_nicklist_remove_all

Rimuove tutti i gruppi/nick da una lista nick.

Prototipo:

void weechat_nicklist_remove_all (struct t_gui_buffer *buffer);

Argomenti:

Esempio in C:

weechat_nicklist_remove_all (my_buffer);

Script (Python):

# prototipo
weechat.nicklist_remove_all(buffer)

# esempio
weechat.nicklist_remove_all(my_buffer)

3.14. Barre

Funzioni per le barre.

Cerca un elemento barra.

Prototipo:

struct t_gui_bar_item *weechat_bar_item_search (const char *name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_gui_bar_item *bar_item = weechat_bar_item_search ("myitem");

Script (Python):

# prototipo
bar_item = weechat.bar_item_search(name)

# esempio
bar_item = weechat.bar_item_search("myitem")

3.14.2. weechat_bar_item_new

Crea un nuovo elemento barra.

Prototipo:

struct t_gui_bar_item *weechat_bar_item_new (const char *name,
                                             char *(build_callback)(void *data,
                                                                    struct t_gui_bar_item *item,
                                                                    struct t_gui_window *window),
                                             void *build_callback_data);

Argomenti:

Valore restituito:

Esempio in C:

char *
my_build_callback (void *data,
                   struct t_gui_bar_item *item,
                   struct t_gui_window *window)
{
    return strdup ("my content");
}

struct t_gui_bar_item *my_item = weechat_bar_item_new ("myitem",
                                                       &my_build_callback,
                                                       NULL);

Script (Python):

# prototipo
bar_item = weechat.bar_item_new(name, build_callback, build_callback_data)

# esempio
def my_build_callback(data, item, window):
    return "my content"

bar_item = weechat.bar_item_new("myitem", "my_build_callback", "")

3.14.3. weechat_bar_item_update

Aggiorna il contenuto dell’elemento barra, chiamando la callback che lo ha compilato.

Prototipo:

void weechat_bar_item_update (const char *name);

Argomenti:

Esempio in C:

weechat_bar_item_update ("myitem");

Script (Python):

# prototipo
weechat.bar_item_update(name)

# esempio
weechat.bar_item_update("myitem")

3.14.4. weechat_bar_item_remove

Rimuove un elemento barra.

Prototipo:

void weechat_bar_item_remove (struct t_gui_bar_item *item);

Argomenti:

Esempio in C:

weechat_bar_item_remove (&my_item);

Script (Python):

# prototipo
weechat.bar_item_remove(item)

# esempio
weechat.bar_item_remove(myitem)

Cerca una barra.

Prototipo:

struct t_gui_bar *weechat_bar_search (const char *name);

Argomenti:

Valore restituito:

Esempio in C:

struct t_gui_bar *bar = weechat_bar_search ("mybar");

Script (Python):

# prototipo
bar = weechat.bar_search(name)

# esempio
bar = weechat.bar_search("mybar")

3.14.6. weechat_bar_new

Crea una nuova barra.

Prototipo:

struct t_gui_bar *weechat_bar_new (const char *name,
                                   const char *hidden,
                                   const char *priority,
                                   const char *type,
                                   const char *condition,
                                   const char *position,
                                   const char *filling_top_bottom,
                                   const char *filling_left_right,
                                   const char *size,
                                   const char *size_max,
                                   const char *color_fg,
                                   const char *color_delim,
                                   const char *color_bg,
                                   const char *separator,
                                   const char *items);

Argomenti:

Valore restituito:

Esempio in C:

struct t_gui_bar *my_bar = weechat_bar_new ("mybar",
                                            "off",
                                            100,
                                            "window",
                                            "",
                                            "top",
                                            "horizontal",
                                            "vertical",
                                            "0",
                                            "5",
                                            "default",
                                            "cyan",
                                            "blue",
                                            "off",
                                            "time,buffer_number+buffer_name");

Script (Python):

# prototipo
bar = weechat.bar_new(name, hidden, priority, type, condition, position,
    filling_top_bottom, filling_left_right, size, size_max,
    color_fg, color_delim, color_bg, separator, items)

# esempio
bar = weechat.bar_new("mybar", "off", 100, "window", "", "top", "horizontal", "vertical",
    "0", "5", "default", "cyan", "blue", "off", "time,buffer_number+buffer_name")

3.14.7. weechat_bar_set

Imposta un nuovo valore per la proprietà di una barra.

Prototipo:

int weechat_bar_set (struct t_gui_bar *bar, const char *property,
                     const char *value);

Argomenti:

Valore restituito:

Esempio in C:

weechat_bar_set (mybar, "position", "bottom");

Script (Python):

# prototipo
weechat.bar_set(bar, property, value)

# esempio
weechat.bar_set(my_bar, "position", "bottom")

3.14.8. weechat_bar_update

Aggiorna il contenuto di una barra su schermo.

Prototipo:

void weechat_bar_update (const char *name);

Argomenti:

Esempio in C:

weechat_bar_update ("mybar");

Script (Python):

# prototipo
weechat.bar_update(name)

# esempio
weechat.bar_update("mybar")

3.14.9. weechat_bar_remove

Rimuove una barra.

Prototipo:

void weechat_bar_remove (struct t_gui_bar *bar);

Argomenti:

Esempio in C:

weechat_bar_remove (mybar);

Script (Python):

# prototipo
weechat.bar_remove(bar)

# esempio
weechat.bar_remove(my_bar)

3.15. Comandi

Funzioni per eseguire comandi di WeeChat.

3.15.1. weechat_command

Esegue un comando.

Prototipo:

void weechat_command (struct t_gui_buffer *buffer, const char *command);

Argomenti:

Esempio in C:

weechat_command (weechat_buffer_search ("irc", "freenode.#weechat"),
                 "/whois FlashCode");

Script (Python):

# prototipo
weechat.command(buffer, command)

# esempio
weechat.command(weechat.buffer_search("irc", "freenode.#weechat"), "/whois FlashCode")

3.16. Network

Funzioni di rete.

3.16.1. weechat_network_pass_proxy

Stabilisce una connessione/autenticazione con un proxy.

Prototipo:

int weechat_network_pass_proxy (const char *proxy,
                                int sock,
                                const char *address,
                                int port);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_network_pass_proxy ("my_proxy", sock, "irc.freenode.net", 6667))
{
    /* OK */
}
else
{
    /* errore */
}

3.16.2. weechat_network_connect_to

Stabilisce una connessione con un host remoto.

Prototipo:

int weechat_network_connect_to (const char *proxy,
                                int sock,
                                unsigned long address,
                                int port);

Argomenti:

Valore restituito:

Esempio in C:

struct sockaddr_in addr;
socklen_t length;
unsigned long address;

memset (&addr, 0, sizeof (struct sockaddr_in));
length = sizeof (addr);
getsockname (sock, (struct sockaddr *) &addr, &length);
addr.sin_family = AF_INET;
address = ntohl (addr.sin_addr.s_addr);

if (weechat_network_connect_to (NULL, sock, address, 6667))
{
    /* OK */
}
else
{
    /* errore */
}

3.17. Info

Funzioni per ottenere info.

3.17.1. weechat_info_get

Restituisce informazioni da WeeChat o da un plugin.

Prototipo:

const char *weechat_info_get (const char *info_name, const char *arguments);

Argomenti:

Plugin Nome Descrizione Argomenti

fifo

fifo_filename

nome della pipe FIFO

-

irc

irc_buffer

ottiene puntatore al buffer per un server/canale/nick IRC

server,canale,nick (canale e nick sono opzionali)

irc

irc_is_channel

1 se la stringa è nome valido di un canale IRC

nome canale

irc

irc_is_nick

1 se la stringa è un nick IRC valido

nick

irc

irc_nick

ottiene nick corrente su un server

nome server

irc

irc_nick_color

ottiene il codice del colore del nick

nick

irc

irc_nick_color_name

ottiene il nome del colore del nick

nick

irc

irc_nick_from_host

ottiene nick dall’host IRC

host IRC (come :nick!nome@server.com)

irc

irc_server_isupport

1 se il server supporta questa caratteristica (dal messaggio IRC 005)

server,caratteristica

irc

irc_server_isupport_value

valore della caratteristica, se supportata dal servre (dal messaggio IRC 005)

server,caratteristica

weechat

charset_internal

set caratteri interno di WeeChat

-

weechat

charset_terminal

set caratteri terminale

-

weechat

date

data di compilazione di WeeChat

-

weechat

dir_separator

separatore cartella

-

weechat

filters_enabled

1 se i filtri sono abilitati

-

weechat

inactivity

inattività della tastiera (secondi)

-

weechat

version

versione di WeeChat

-

weechat

version_number

versione di WeeChat (come numero)

-

weechat

weechat_dir

cartella WeeChat

-

weechat

weechat_libdir

cartella "lib" di WeeChat

-

weechat

weechat_localedir

cartella "locale" di WeeChat

-

weechat

weechat_sharedir

cartella "share" di WeeChat

-

weechat

weechat_site

sito di WeeChat

-

weechat

weechat_site_download

sito di WeeChat, pagina di download

-

Valore restituito:

Esempio in C:

weechat_printf (NULL, "Current WeeChat version is: %s (compiled on %s)",
                weechat_info_get ("version", NULL),
                weechat_info_get ("date", NULL));
weechat_printf (NULL, "WeeChat home is: %s",
                weechat_info_get ("weechat_dir", NULL));

Script (Python):

# prototipo
value = weechat.info_get(info_name, arguments)

# esempio
weechat.prnt("", "Current WeeChat version is: %s (compiled on %s)"
    % (weechat.info_get("version", ""), weechat.info_get("date", ""))
weechat.prnt("", "WeeChat home is: %s" % weechat.info_get("weechat_dir"))

3.18. Liste info

Una lista info è una lista di "elementi". Ciascun elemento contiene delle variabili.

Ad esempio, la lista info "irc_server" ha N elementi (N è il numero di server IRC definiti). Per ogni elemento, esistono variabili come "name", "buffer", "is connected",…

Ogni variabile ha un tipo e un valore. I tipi possibili sono:

3.18.1. weechat_infolist_new

Crea una nuova lista info.

Prototipo:

struct t_infolist *weechat_infolist_new ();

Valore restituito:

Esempio in C:

struct t_infolist *infolist = weechat_infolist_new ();

Script (Python):

# prototipo
infolist = weechat.infolist_new()

# esempio
infolist = weechat.infolist_new()

3.18.2. weechat_infolist_new_item

Aggiunge un elemento alla lista info.

Prototipo:

struct t_infolist_item *weechat_infolist_new_item (struct t_infolist *infolist);

Argomenti:

Valore restituito:

Esempio in C:

struct t_infolist_item *item = weechat_infolist_new_item (infolist);

Script (Python):

# prototipo
item = weechat.infolist_new_item(infolist)

# esempio
item = weechat.infolist_new_item(infolist)

3.18.3. weechat_infolist_new_var_integer

Aggiunge una variabile intera ad un elemento della lista info.

Prototipo:

struct t_infolist_var *weechat_infolist_new_var_integer (struct t_infolist_item *item,
                                                         const char *name,
                                                         int value);

Argomenti:

Valore restituito:

Esempio in C:

struct t_infolist_var *var = weechat_infolist_new_var_integer (item,
                                                               "my_integer",
                                                               123);

Script (Python):

# prototipo
var = weechat.infolist_new_var_integer(item, name, value)

# esempio
var = weechat.infolist_new_var_integer(item, "my_integer", 123)

3.18.4. weechat_infolist_new_var_string

Aggiunge una variabile stringa ad un elemento della lista info.

Prototipo:

struct t_infolist_var *weechat_infolist_new_var_string (struct t_infolist_item *item,
                                                        const char *name,
                                                        const char *value);

Argomenti:

Valore restituito:

Esempio in C:

struct t_infolist_var *var = weechat_infolist_new_var_string (item,
                                                              "my_string",
                                                              "value");

Script (Python):

# prototipo
var = weechat.infolist_new_var_string(item, name, value)

# esempio
var = weechat.infolist_new_var_string(item, "my_string", "value")

3.18.5. weechat_infolist_new_var_pointer

Aggiunge una variabile puntatore ad un elemento della lista info.

Prototipo:

struct t_infolist_var *weechat_infolist_new_var_pointer (struct t_infolist_item *item,
                                                         const char *name,
                                                         void *pointer);

Argomenti:

Valore restituito:

Esempio in C:

struct t_infolist_var *var = weechat_infolist_new_var_pointer (item,
                                                               "my_pointer",
                                                               &pointer);

Script (Python):

# prototipo
var = weechat.infolist_new_var_pointer(item, name, pointer)

# esempio
var = weechat.infolist_new_var_pointer(item, "my_pointer", pointer)

3.18.6. weechat_infolist_new_var_buffer

Aggiunge una variabile puntatore ad un elemento della lista info.

Prototipo:

struct t_infolist_var *weechat_infolist_new_var_buffer (struct t_infolist_item *item,
                                                        const char *name,
                                                        void *pointer,
                                                        int size);

Argomenti:

Valore restituito:

Esempio in C:

char buffer[256];
/* ... */
struct t_infolist_var *var = weechat_infolist_new_variable_buffer (item,
                                                                   "my_buffer",
                                                                   &buffer,
                                                                   sizeof (buffer));

3.18.7. weechat_infolist_new_var_time

Aggiunge una variabile tempo ad un elemento della lista info.

Prototipo:

struct t_infolist_var *weechat_infolist_new_var_time (struct t_infolist_item *item,
                                                      const char *name,
                                                      time_t time);

Argomenti:

Valore restituito:

Esempio in C:

struct t_infolist_var *var = weechat_infolist_new_variable_time (item,
                                                                 "my_time",
                                                                 time (NULL));

Script (Python):

# prototipo
var = weechat.infolist_new_var_time(item, name, time)

# esempio
var = weechat.infolist_new_var_time(item, "my_time", int(time.time()))

3.18.8. weechat_infolist_get

Restituisce una lista info da WeeChat o da un plugin.

Prototipo:

struct t_infolist *weechat_infolist_get (const char *infolist_name,
                                         void *pointer,
                                         const char *arguments);

Argomenti:

Plugin Nome Descrizione Puntatore Argomenti

alias

alias

elenco di alias

puntatore all’alias (opzionale)

nome alias (può iniziare o terminare con "*" come carattere jolly) (opzionale)

irc

irc_channel

elenco dei canali per un server IRC

puntatore al canale (opzionale)

nome server

irc

irc_ignore

elenco di ignore IRC

puntatore all’ignore (opzionale)

-

irc

irc_nick

elenco dei nick per un canale IRC

puntatore al nick (opzionale)

server,canale,nick (canale e nick sono opzionali)

irc

irc_server

elenco di server IRC

puntatore al server (opzionale)

nome server (può iniziare o terminare con "*" come carattere jolly) (opzionale)

logger

logger_buffer

elenco dei buffer logger

puntatore al logger (opzionale)

-

lua

lua_script

elenco degli script

puntatore allo script (opzionale)

nome script (può iniziare o terminare con "*" come carattere jolly) (opzionale)

perl

perl_script

elenco degli script

puntatore allo script (opzionale)

nome script (può iniziare o terminare con "*" come carattere jolly) (opzionale)

python

python_script

elenco degli script

puntatore allo script (opzionale)

nome script (può iniziare o terminare con "*" come carattere jolly) (opzionale)

relay

relay

elenco di client relay

puntatore al relay (opzionale)

-

ruby

ruby_script

elenco degli script

puntatore allo script (opzionale)

nome script (può iniziare o terminare con "*" come carattere jolly) (opzionale)

tcl

tcl_script

elenco degli script

puntatore allo script (opzionale)

nome script (può iniziare o terminare con "*" come carattere jolly) (opzionale)

weechat

bar

elenco delle barre

puntatore alla barra (opzionale)

nome barra (può iniziare o terminare con "*" come carattere jolly (opzionale)

weechat

bar_item

elenco degli elementi barra

puntatore all’elemento della barra (opzionale)

nome dell’elemento della barra (può iniziare o terminare con "*" come carattere jolly) (opzionale)

weechat

bar_window

elenco delle finestre barra

puntatore alla finestra della barra (opzionale)

-

weechat

buffer

elenco dei buffer

puntatore al buffer (opzionale)

nome buffer (può iniziare o terminare con "*" come carattere jolly) (opzionale)

weechat

buffer_lines

righe di un buffer

puntatore al buffer

-

weechat

filter

elenco dei filtri

-

nome filtro (può iniziare o terminare con "*" come carattere jolly) (opzionale)

weechat

history

cronologia dei comandi

puntatore al buffer (se non impostato, restituisce la cronologia globale) (opzionale)

-

weechat

hook

elenco di hook

-

tipo hook: comando, timer, … (opzionale)

weechat

hotlist

elenco dei buffer nella hotlist

-

-

weechat

key

elenco di tasti associati

-

-

weechat

nicklist

nick nella lista nick per un buffer

puntatore al buffer

nick_xxx o group_xxx per ottenere solo xxx di nick/group (opzionale)

weechat

option

elenco delle opzioni

-

nome opzione (può iniziare o terminare con "*" come carattere jolly) (opzionale)

weechat

plugin

elenco dei plugin

puntatore al plugin (opzionale)

nome plugin (può iniziare o terminare con "*" come carattere jolly) (opzionale)

weechat

window

elenco delle finestre

puntatore alla finestra (opzionale)

nome finestra (può iniziare o terminare con "*" come carattere jolly) (opzionale)

xfer

xfer

lista di xfer

puntatore a xfer (opzionale)

-

Valore restituito:

Esempio in C:

struct t_infolist *infolist = weechat_infolist_get ("irc_server", NULL, NULL);

Script (Python):

# prototipo
infolist = weechat.infolist_get(infolist_name, pointer, arguments)

# esempio
infolist = weechat.infolist_get("irc_server, "", "")

3.18.9. weechat_infolist_next

Sposta "cursor" all’elemento successivo nella lista info. La prima chiamata a questa funzione per una lista info sposta il cursore al primo elemento nella lista info.

Prototipo:

int weechat_infolist_next (struct t_infolist *infolist);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_infolist_next (infolist))
{
    /* legge variabili nell'elemento... */
}
else
{
    /* nessun altro elemento disponibile */
}

Script (Python):

# prototipo
rc = weechat.infolist_next(infolist)

# esempio
rc = weechat.infolist_next(infolist)
if rc:
    # legge variabili nell'elemento...
else:
    # nessun altro elemento disponibile

3.18.10. weechat_infolist_prev

Sposta "cursor" all’elemento precedente nella lista info. La prima chiamata a questa funzione per una lista info sposta il cursore all’ultimo elemento.

Prototipo:

int weechat_infolist_prev (struct t_infolist *infolist);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_infolist_prev (infolist))
{
    /* legge variabili nell'elemento... */
}
else
{
    /* nessun altro elemento disponibile */
}

Script (Python):

# prototipo
rc = weechat.infolist_prev(infolist)

# esempio
rc = weechat.infolist_prev(infolist)
if rc:
    # read variables in item...
else:
    # no more item available

3.18.11. weechat_infolist_reset_item_cursor

Ripristina "cursor" per la lista info.

Prototipo:

void weechat_infolist_reset_item_cursor (struct t_infolist *infolist);

Argomenti:

Esempio in C:

weechat_infolist_reset_item_cursor (infolist);

Script (Python):

# prototipo
weechat.infolist_reset_item_cursor(infolist)

# esempio
weechat.infolist_reset_item_cursor(infolist)

3.18.12. weechat_infolist_fields

Restituisce una lista di campi per l’elemento della lista info corrente.

Prototipo:

const char *weechat_infolist_fields (struct t_infolist *infolist);

Argomenti:

Valore restituito:

Esempio in C:

const char *fields = weechat_infolist_fields (infolist);
/* i campi contengono qualcosa come:
   "i:my_integer,s:my_string,p:my_pointer,b:my_buffer,t:my_time" */

Script (Python):

# prototipo
fields = weechat.infolist_fields(infolist)

# esempio
fields = weechat.infolist_fields(infolist)
# i campi contengono qualcosa come:
# "i:my_integer,s:my_string,p:my_pointer,b:my_buffer,t:my_time"

3.18.13. weechat_infolist_integer

Restituisce il valore della variabile intera nell’elemento corrente della lista info.

Prototipo:

int weechat_infolist_integer (struct t_infolist *infolist, const char *var);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "integer = %d",
                weechat_infolist_integer (infolist, "my_integer"));

Script (Python):

# prototipo
value = weechat.infolist_integer(infolist, var)

# esempio
weechat.prnt("", "integer = %d" % weechat.infolist_integer(infolist, "my_integer"))

3.18.14. weechat_infolist_string

Restituisce il valore della variabile stringa nell’elemento della lista info corrente.

Prototipo:

const char *weechat_infolist_string (struct t_infolist *infolist, const char *var);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "string = %s",
                weechat_infolist_string (infolist, "my_string"));

Script (Python):

# prototipo
value = weechat.infolist_string(infolist, var)

# esempio
weechat.prnt("", "string = %s" % weechat.infolist_string(infolist, "my_string"))

3.18.15. weechat_infolist_pointer

Restituisce il valore della variabile puntatore nell’elemento della lista info corrente.

Prototipo:

void *weechat_infolist_pointer (struct t_infolist *infolist, const char *var);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "pointer = 0x%lx",
                weechat_infolist_pointer (infolist, "my_pointer"));

Script (Python):

# prototipo
value = weechat.infolist_pointer(infolist, var)

# esempio
weechat.prnt("", "pointer = 0x%lx" % weechat.infolist_pointer(infolist, "my_pointer"))

3.18.16. weechat_infolist_buffer

Restituisce il valore della variabile buffer nell’elemento corrente della lista info.

Prototipo:

void *weechat_infolist_buffer (struct t_infolist *infolist, const char *var,
                               int *size);

Argomenti:

Valore restituito:

Esempio in C:

int size;
void *pointer = weechat_infolist_buffer (infolist, "my_buffer", &size);
weechat_printf (NULL, "buffer = 0x%lx, size = %d",
                pointer, size);

3.18.17. weechat_infolist_time

Restituisce il valore della variabile data/ora nell’elemento attivo della lista info.

Prototipo:

time_t weechat_infolist_time (struct t_infolist *infolist, const char *var);

Argomenti:

Valore restituito:

Esempio in C:

weechat_printf (NULL, "time = %ld",
                weechat_infolist_time (infolist, "my_time"));

Script (Python):

# prototipo
value = weechat.infolist_time(infolist, var)

# esempio
weechat.prnt("", "time = %ld" % weechat.infolist_time(infolist, "my_time"))

3.18.18. weechat_infolist_free

Libera una lista info.

Prototipo:

void weechat_infolist_free (struct t_infolist *infolist);

Argomenti:

Esempio in C:

weechat_infolist_free (infolist);

Script (Python):

# prototipo
weechat.infolist_free(infolist)

# esempio
weechat.infolist_free(infolist)

3.19. Aggiornamento

Funzioni per l’aggiornamento di WeeChat (comando "/upgrade").

3.19.1. weechat_upgrade_new

Crea o legge un file per l’aggiornamento.

Prototipo:

struct t_upgrade_file *weechat_upgrade_new (const char *filename, int write);

Argomenti:

Valore restituito:

Esempio in C:

struct t_upgrade_file *upgrade_file = weechat_upgrade_new ("my_file", 1);

Script (Python):

# prototipo
upgrade_file = weechat.upgrade_new(filename, write)

# esempio
upgrade_file = weechat.upgrade_new("my_file", 1)

3.19.2. weechat_upgrade_write_object

Scrive un oggetto nel file di aggiornamento.

Prototipo:

int weechat_upgrade_write_object (struct t_upgrade_file *upgrade_file,
                                  int object_id,
                                  struct t_infolist *infolist);

Argomenti:

Valore restituito:

Esempio in C:

if (weechat_upgrade_write_object (upgrade_file, 1, &infolist))
{
    /* ok */
}
else
{
    /* errore */
}

Script (Python):

# prototipo
rc = weechat.upgrade_write_object(upgrade_file, object_id, infolist)

# esempio
weechat.upgrade_write_object(upgrade_file, 1, infolist)

3.19.3. weechat_upgrade_read

Legge un file di aggiornamento.

Prototipo:

int weechat_upgrade_read (struct t_upgrade_file *upgrade_file,
                          int (*callback_read)(void *data,
                                               struct t_upgrade_file *upgrade_file,
                                               int object_id,
                                               struct t_infolist *infolist),
                          void *callback_read_data);

Argomenti:

Valore restituito:

Esempio in C:

int
my_upgrade_read_cb (struct t_upgrade_file *upgrade_file,
                    int object_id,
                    struct t_infolist *infolist)
{
    /* lettura variabili... */
    return WEECHAT_RC_OK;
}

weechat_upgrade_read (upgrade_file, &my_upgrade_read_cb, NULL);

Script (Python):

# prototipo
rc = weechat.upgrade_read(upgrade_file, callback_read, callback_read_data)

# esempio
def my_upgrade_read_cb(upgrade_file, object_id, infolist):
    # lettura variabili...
    return weechat.WEECHAT_RC_OK

weechat.upgrade_read(upgrade_file, "my_upgrade_read_cb", ""))

3.19.4. weechat_upgrade_close

Chiude un file di aggiornamento.

Prototipo:

void weechat_upgrade_close (struct t_upgrade_file *upgrade_file);

Argomenti:

Esempio in C:

weechat_upgrade_close (upgrade_file);

Script (Python):

# prototipo
weechat.upgrade_close(upgrade_file)

# esempio
weechat.upgrade_close(upgrade_file)