Translators:

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

La versione più recente di questo documento si trova qui: https://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

WEECHAT_PLUGIN_PRIORITY(1000)

the plugin priority (optional, see below)

2.2. Funzioni principali

Il plugin deve usare due funzioni:

  • weechat_plugin_init

  • weechat_plugin_end

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:

  • plugin: puntatore alla struttura del plugin di WeeChat

  • argc: numero di argomenti per il plugin (fornito dalla riga di comando dall’utente)

  • argv: argomenti per il plugin

Valori restituiti:

  • WEECHAT_RC_OK se l’operazione ha successo (il plugin verrà caricato)

  • WEECHAT_RC_ERROR se c’è un errore (il plugin NON verrà caricato)

Plugin priority

When plugins are auto-loaded (for example on startup), WeeChat first loads all plugins, and then calls the init functions, using the priority defined in each plugin. A high priority means that the init function is called first.

Default priority is 1000 (with such priority, the plugin is loaded after all default plugins).

The default WeeChat plugins are initialized in this order:

  1. charset (13000)

  2. logger (12000)

  3. exec (11000)

  4. trigger (10000)

  5. aspell (9000)

  6. alias (8000)

  7. fifo (7000)

  8. xfer (6000)

  9. irc (5000)

  10. relay (4000)

  11. guile, javascript, lua, perl, python, ruby, tcl (3000)

  12. script (2000)

2.2.2. weechat_plugin_end

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

Prototipo:

int weechat_plugin_end (struct t_weechat_plugin *plugin);

Argomenti:

  • plugin: puntatore alla struttura plugin di WeeChat

Valori restituiti:

  • WEECHAT_RC_OK se l’operazione ha successo

  • WEECHAT_RC_ERROR se c’è un errore

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("Sébastien 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 (const void *pointer, 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, 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:

  • descrizione della funzione,

  • prototipo C,

  • dettaglio degli argomenti,

  • valore restituito,

  • esempio C,

  • esempio nello script Python (la sintassi è simile per gli altri linguaggi di scripting).

3.1. Plugin

Funzioni per ottenere informazioni sui plugin.

3.1.1. plugin_get_name

Ottiene il nome del plugin.

Prototipo:

const char *weechat_plugin_get_name (struct t_weechat_plugin *plugin);

Argomenti:

  • plugin: puntatore alla struttura plugin di WeeChat (può essere NULL)

Valore restituito:

  • nome del plugin, "core" per il core di WeeChat (se il puntatore al plugin è NULL)

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. 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:

  • charset: nuovo set caratteri da usare

Esempio in C:

weechat_charset_set ("iso-8859-1");

Script (Python):

# prototipo
weechat.charset_set(charset)

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

3.2.2. 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:

  • charset: set caratteri da convertire

  • string: stringa da convertire

Valore restituito:

  • la stringa convertita (deve essere liberata richiamando "free" dopo l’utilizzo)

Esempio in C:

char *str = weechat_iconv_to_internal ("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. 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:

  • charset: set caratteri in uscita

  • string: stringa da convertire

Valore restituito:

  • la stringa convertita (deve essere liberata richiamando "free" dopo l’utilizzo

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. gettext

Restituisce la stringa tradotta (dipende dalla lingua).

Prototipo:

const char *weechat_gettext (const char *string);

Argomenti:

  • string: stringa da tradurre

Valore restituito:

  • stringa tradotta

Esempio in C:

char *str = weechat_gettext ("hello");

Script (Python):

# prototipo
str = weechat.gettext(string)

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

3.2.5. 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:

  • string: stringa da tradurre, singolare

  • plural: stringa da tradurre, plurale

  • count: utilizzato per scegliere tra singolare e plurale (la scelta viene fatta in base alla lingua locale)

Valore restituito:

  • stringa tradotta

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. strndup

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

Prototipo:

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

Argomenti:

  • string: stringa da duplicare

  • length: caratteri massimi da duplicare

Valore restituito:

  • stringa duplicata (deve essere liberata chiamando "free" dopo l’utilizzo)

Esempio in C:

char *str = weechat_strndup ("abcdef", 3);  /* result: "abc" */
/* ... */
free (str);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.7. string_tolower

Converte una stringa UTF-8 in minuscolo.

Prototipo:

void weechat_string_tolower (char *string);

Argomenti:

  • string: stringa da convertire

Esempio in C:

char str[] = "AbCdé";
weechat_string_tolower (str);  /* str ora è: "abcdé" */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.8. string_toupper

Converte una stringa UTF-8 in maiuscolo.

Prototipo:

void weechat_string_toupper (char *string);

Argomenti:

  • string: stringa da convertire

Esempio in C:

char str[] = "AbCdé";
weechat_string_toupper (str);  /* str ora è: "ABCDé" */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.9. strcasecmp

Updated in 1.0.

Confronta stringa non sensibile alle maiuscole e alla localizzazione.

Prototipo:

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

Argomenti:

  • string1: prima stringa da comparare

  • string2: seconda stringa da comparare

Valore restituito:

  • -1 se stringa1 < stringa2

  • 0 se stringa1 == stringa1

  • 1 se stringa1 > stringa2

Esempio in C:

int diff = weechat_strcasecmp ("aaa", "CCC");  /* == -2 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.10. strcasecmp_range

WeeChat ≥ 0.3.7, updated in 1.0.

Confronta stringa non sensibile alle maiuscole e alla localizzazione, usando una serie per il confronto.

Prototipo:

int weechat_strcasecmp_range (const char *string1, const char *string2, int range);

Argomenti:

  • string1: prima stringa da comparare

  • string2: seconda stringa da comparare

  • range: numero di caratteri nel confronto maiuscole/minuscole, ad esempio:

    • 26: A-Z vengono ridotti ad a-z

    • 29: A-Z [ \ ] vengono ridotti ad a-z { | }

    • 30: A-Z [ \ ] ^ vengono ridotti ad a-z { | } ~

Note
I valori 29 e 30 vengono usati da alcuni protocolli come IRC.

Valore restituito:

  • -1 se stringa1 < stringa2

  • 0 se stringa1 == stringa1

  • 1 se stringa1 > stringa2

Esempio in C:

int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29);  /* == 0 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.11. strncasecmp

Updated in 1.0.

Confronta stringa indipendente non sensibile alle maiuscole e alla localizzazione, per un numero max di caratteri.

Prototipo:

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

Argomenti:

  • string1: prima stringa da comparare

  • string2: seconda stringa da comparare

  • max: numero massimo di caratteri da comparare

Valore restituito:

  • -1 se stringa1 < stringa2

  • 0 se stringa1 == stringa1

  • 1 se stringa1 > stringa2

Esempio in C:

int diff = weechat_strncasecmp ("aabb", "aacc", 2);  /* == 0 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.12. strncasecmp_range

WeeChat ≥ 0.3.7, updated in 1.0.

Confronta una stringa non sensibile alle maiuscole e alla localizzazione, per un numero max di caratteri, usando una serie per il confronto.

Prototipo:

int weechat_strncasecmp_range (const char *string1, const char *string2, int max, int range);

Argomenti:

  • string1: prima stringa da comparare

  • string2: seconda stringa da comparare

  • max: numero massimo di caratteri da comparare

  • range: numero di caratteri nel confronto maiuscole/minuscole, ad esempio:

    • 26: A-Z vengono ridotti ad a-z

    • 29: A-Z [ \ ] vengono ridotti ad a-z { | }

    • 30: A-Z [ \ ] ^ vengono ridotti ad a-z { | } ~

Note
I valori 29 e 30 vengono usati da alcuni protocolli come IRC.

Valore restituito:

  • -1 se stringa1 < stringa2

  • 0 se stringa1 == stringa1

  • 1 se stringa1 > stringa2

Esempio in C:

int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29);  /* == 0 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.13. strcmp_ignore_chars

Updated in 1.0.

Confronta una stringa localizzata (e opzionalmente non sensibile alle maiuscole), ignorando alcuni caratteri.

Prototipo:

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

Argomenti:

  • string1: prima stringa per il confronto

  • string2: seconda stringa per il confronto

  • chars_ignored: stringa con caratteri da ignorare

  • case_sensitive: 1 per il confronto sensibile alle maiuscole, altrimenti 0

Valore restituito:

  • -1 se stringa1 < stringa2

  • 0 se stringa1 == stringa1

  • 1 se stringa1 > stringa2

Esempio in C:

int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1);  /* == -3 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.14. strcasestr

Updated in 1.3.

Cerca una stringa non sensibile alle maiuscole e indipendente dalla localizzazione.

Prototipo:

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

Argomenti:

  • string: stringa

  • search: stringa da cercare in string

Valore restituito:

  • puntatore alla stringa trovata, o NULL se non trovata (WeeChat ≥ 1.3: pointer returned is a const char * instead of char *)

Esempio in C:

const char *pos = weechat_strcasestr ("aBcDeF", "de");  /* risultato: puntatore a "DeF" */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.15. strlen_screen

WeeChat ≥ 0.4.2.

Restituisce il numero di caratteri necessari per visualizzare la stringa UTF-8 su schermo. Non-printable chars have a width of 1 (this is the difference with the function utf8_strlen_screen).

Prototipo:

int weechat_strlen_screen (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • numero di caratteri necessari per visualizzare la stringa UTF-8 su schermo

Esempio in C:

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

Script (Python):

# prototipo
length = weechat.strlen_screen(string)

# esempio
length = weechat.strlen_screen("é")  # 1

3.2.16. string_match

Updated in 1.0.

Verifica se una stringa coincide ad una mask.

Prototipo:

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

Argomenti:

  • string: stringa

  • mask: mask with wildcards (*), each wildcard matches 0 or more chars in the string

  • case_sensitive: 1 per il confronto sensibile alle maiuscole, altrimenti 0

Note
Since version 1.0, wildcards are allowed inside the mask (not only beginning/end of mask).

Valore restituito:

  • 1 se la stringa coincide alla mask, altrimenti 0

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 */
int match5 = weechat_string_match ("abcdef", "*b*d*", 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
match5 = weechat.string_match("abcdef", "*b*d*", 0)  # 1

3.2.17. string_expand_home

WeeChat ≥ 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:

  • path: percorso

Valore restituito:

  • percorso con la ~ iniziale sostituita dalla cartella home (deve essere liberata chiamando "free" dopo l’uso)

Esempio in C:

char *str = weechat_string_expand_home ("~/file.txt");
/* result: "/home/xxx/file.txt" */
/* ... */
free (str);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.18. string_eval_path_home

WeeChat ≥ 1.3.

Evaluate a path in 3 steps:

  1. replace leading %h by WeeChat home directory,

  2. replace leading ~ by user home directory (call to string_expand_home),

  3. evaluate variables (see string_eval_expression).

Prototipo:

char *weechat_string_eval_path_home (const char *path,
                                     struct t_hashtable *pointers,
                                     struct t_hashtable *extra_vars,
                                     struct t_hashtable *options);

Argomenti:

Valore restituito:

  • evaluated path (must be freed by calling "free" after use)

Esempio in C:

char *str = weechat_string_eval_path_home ("%h/test", NULL, NULL, NULL);
/* result: "/home/xxx/.weechat/test" */
/* ... */
free (str);

Script (Python):

# prototipo
path = weechat.string_eval_path_home(path, pointers, extra_vars, options)

# esempio
path = weechat.string_eval_path_home("%h/test", {}, {}, {})
# path == "/home/xxx/.weechat/test"

3.2.19. 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:

  • string: stringa

  • quotes: stringa con elenco di virgolette

Valore restituito:

  • stringa senza virgolette all’inizio/fine (deve essere liberata chiamando "free" dopo l’uso)

Esempio in C:

char *str = weechat_string_remove_quotes (string, " 'Non posso' ", "'");
/* risultato: "Non posso" */
/* ... */
free (str);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.20. 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:

  • string: stringa

  • left: rimuove i caratteri a sinistra se diversi da 0

  • right: rimuove i caratteri a destra se diversi da 0

  • chars: stringa con i caratteri da rimuovere

Valore restituito:

  • stringa corretta (deve essere liberata chiamando "free" dopo l’uso)

Esempio in C:

char *str = weechat_string_strip (".abc -", 0, 1, "- .");  /* risultato: ".abc" */
/* ... */
free (str);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.21. string_convert_escaped_chars

WeeChat ≥ 1.0.

Convert escaped chars to their value:

  • \": double quote

  • \\: backslash

  • \a: alert (BEL)

  • \b: backspace

  • \e: escape

  • \f: form feed

  • \n: new line

  • \r: carriage return

  • \t: horizontal tab

  • \v: vertical tab

  • \0ooo: char as octal value (ooo is 0 to 3 digits)

  • \xhh: char as hexadecimal value (hh is 1 to 2 digits)

  • \uhhhh: unicode char as hexadecimal value (hhhh is 1 to 4 digits)

  • \Uhhhhhhhh: unicode char as hexadecimal value (hhhhhhhh is 1 to 8 digits)

Prototipo:

char *weechat_string_convert_escaped_chars (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • string with escaped chars replaced by their value (deve essere liberata chiamando "free" dopo l’uso)

Esempio in C:

char *str = weechat_string_convert_escaped_chars ("snowman: \\u2603");
/* str == "snowman: ☃" */
/* ... */
free (str);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.22. 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:

  • mask: mask

Valore restituito:

  • espressione regolare, come stringa (deve essere liberata chiamando "free" dopo l’uso)

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.23. string_regex_flags

WeeChat ≥ 0.3.7.

Restituisce sia il puntatore sulla stringa dopo le flag che la mask con le flag per compilare l’espressione regolare.

Prototipo:

const char *weechat_string_regex_flags (const char *regex, int default_flags, int *flags)

Argomenti:

  • regex: POSIX extended regular expression

  • default_flags: combinazione dei seguenti valori (consultare man regcomp):

    • REG_EXTENDED

    • REG_ICASE

    • REG_NEWLINE

    • REG_NOSUB

  • flags: pointer value is set with flags used in regular expression (default flags + flags set in regular expression)

Flags must be at beginning of regular expression. Format is: "(?eins-eins)string".

Allowed flags are:

  • e: POSIX extended regular expression (REG_EXTENDED)

  • i: case insensitive (REG_ICASE)

  • n: match-any-character operators don_t match a newline (REG_NEWLINE)

  • s: support for substring addressing of matches is not required (REG_NOSUB)

Valore restituito:

  • pointer in regex, after flags

Esempio in C:

const char *regex = "(?i)test";
int flags;
const char *ptr_regex = weechat_string_regex_flags (regex, REG_EXTENDED, &flags);
/* ptr_regex == "test", flags == REG_EXTENDED | REG_ICASE */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.24. string_regcomp

WeeChat ≥ 0.3.7.

Compile a POSIX extended regular expression using optional flags at beginning of string (for format of flags, see string_regex_flags).

Prototipo:

int weechat_string_regcomp (void *preg, const char *regex, int default_flags)

Argomenti:

  • preg: pointer to regex_t structure

  • regex: POSIX extended regular expression

  • default_flags: combination of following values (see man regcomp):

    • REG_EXTENDED

    • REG_ICASE

    • REG_NEWLINE

    • REG_NOSUB

Valore restituito:

  • same return code as function regcomp (0 if ok, other value for error, see man regcomp)

Esempio in C:

regex_t my_regex;
if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) != 0)
{
    /* error */
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.25. 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:

  • string: stringa

  • highlight_words: lista di parole per gli eventi, separate da virgole

Valore restituito:

  • 1 se la stringa ha uno o più eventi, altrimenti 0

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.26. string_has_highlight_regex

WeeChat ≥ 0.3.4.

Check if a string has one or more highlights, using a POSIX extended regular expression.
For at least one match of regular expression on string, it must be surrounded by delimiters (chars different from: alphanumeric, -, _ and |).

Prototipo:

int weechat_string_has_highlight_regex (const char *string, const char *regex);

Argomenti:

  • string: stringa

  • regex: POSIX extended regular expression

Valore restituito:

  • 1 se la stringa ha uno o più eventi, altrimenti 0

Esempio in C:

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

Script (Python):

# prototipo
highlight = weechat.string_has_highlight_regex(string, regex)

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

3.2.27. 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:

  • string: stringa

  • search: stringa da sostituire

  • replace: sostituzione per la stringa search

Valore restituito:

  • la stringa dopo search sostituita da replace (deve essere liberata chiamando "free" dopo l’uso)

Esempio in C:

char *str = weechat_string_replace ("test", "s", "x");  /* result: "text" */
/* ... */
free (str);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.28. string_replace_regex

WeeChat ≥ 1.0.

Replace text in a string using a regular expression, replacement text and optional callback.

Prototipo:

char *weechat_string_replace_regex (const char *string, void *regex,
                                    const char *replace, const char reference_char,
                                    char *(*callback)(void *data, const char *text),
                                    void *callback_data);

Argomenti:

  • string: string

  • regex: pointer to a regular expression (regex_t structure) compiled with WeeChat function string_regcomp or regcomp (see man regcomp)

  • replace: replacement text, where following references are allowed:

    • $0 to $99: match 0 to 99 in regular expression (0 is the whole match, 1 to 99 are groups captured between parentheses)

    • $+: the last match (with highest number)

    • $.*N: match N (can be + or 0 to 99), with all chars replaced by * (the * char can be any char between space (32) and ~ (126))

  • reference_char: the char used for reference to match (commonly $)

  • callback: an optional callback called for each reference in replace (except for matches replaced by a char); the callback must return:

    • newly allocated string: it is used as replacement text (it is freed after use)

    • NULL: the text received in callback is used as replacement text (without changes)

  • callback_data: pointer given to callback when it is called

Valore restituito:

  • string with text replaced, NULL if problem (must be freed by calling "free" after use)

Esempio in C:

regex_t my_regex;
char *string;
if (weechat_string_regcomp (&my_regex, "([0-9]{4})-([0-9]{2})-([0-9]{2})",
                            REG_EXTENDED) == 0)
{
    string = weechat_string_replace_regex ("date: 2014-02-14", &my_regex,
                                           "$3/$2/$1", '$', NULL, NULL);
    /* string == "date: 14/02/2014" */
    if (string)
        free (string);
    regfree (&my_regex);
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.29. 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:

  • string: stringa da dividere

  • separators: delimitatori usati per dividere

  • keep_eol:

    • 0: ogni stringa conterrà una parola

    • 1: ogni stringa conterrà tutte le stringhe fino a fine riga (consultare il seguente esempio)

    • 2: come il punto 1, ma non rimuove i delimitatori alla fine della stringa prima della divisione (WeeChat ≥ 0.3.6)

  • num_items_max: numero massimo di elementi creati (0 = nessun limite)

  • num_items: puntatore ad int che conterrà il numero di elementi creati

Valore restituito:

  • array di stringhe, NULL se si verifica un problema (deve essere liberata chiamando string_free_split dopo l’uso)

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);

argv = weechat_string_split ("abc de  fghi ", " ", 2, 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);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.30. string_split_shell

WeeChat ≥ 1.0.

Split a string like the shell does for a command with arguments.

This function is a C conversion of Python class "shlex" (file: Lib/shlex.py in Python repository), see: http://docs.python.org/3/library/shlex.html.

Prototipo:

char **weechat_string_split_shell (const char *string, int *num_items);

Argomenti:

  • string: stringa da dividere

  • num_items: puntatore ad int che conterrà il numero di elementi creati

Valore restituito:

  • array di stringhe, NULL se si verifica un problema (deve essere liberata chiamando string_free_split dopo l’uso)

Esempio in C:

char **argv;
int argc;
argv = weechat_string_split_shell ("test 'first arg'  \"second arg\"", &argc);
/* result: argv[0] == "test"
           argv[1] == "first arg"
           argv[2] == "second arg"
           argv[3] == NULL
           argc == 3
*/
weechat_string_free_split (argv);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.31. 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);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.32. 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:

  • split_string: stringa divisa dalla funzione string_split

  • separator: stringa usata per separare le stringhe

Valore restituito:

  • stringa compilata con la stringa divisa (deve essere liberata chiamando "free" dopo l’uso)

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);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.33. 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:

  • command: comando da dividere

  • separator: separatore

Valore restituito:

  • array di stringhe, NULL in caso di problemi (deve essere liberata chiamando free_split_command dopo l’uso)

Esempio in C:

char **argv = weechat_string_split_command ("/command1 arg;/command2", ';');
/* result: argv[0] == "/command1 arg"
           argv[1] == "/command2"
           argv[2] == NULL
*/
weechat_free_split_command (argv);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.34. 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);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.35. 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 long size);

Argomenti:

  • size: dimensione (in byte)

Valore restituito:

  • stringa formattata (deve essere liberata chiamando "free" dopo l’uso)

Esempi in C:

/* esempi in lingua inglese */

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

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

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

char *str = weechat_string_format_size (15200);  /* str == "15.2 KB" */
/* ... */
free (str);

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

3.2.36. string_remove_color

Rimuove i colori di WeeChat da una stringa.

Prototipo:

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

Argomenti:

  • string: stringa

  • replacement: se non NULL e non vuota, i codici colore di WeeChat sono sostituiti dal primo carattere di questa stringa, altrimenti i codici colori di WeeChat ed i caratteri seguenti (se correlate al colore) sono rimossi dalla stringa

Valore restituito:

  • stringa senza un colore (deve essere liberata chiamando "free" dopo l’uso)

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.37. string_encode_base64

WeeChat ≥ 0.3.2.

Codifica una stringa in base64.

Prototipo:

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

Argomenti:

  • from: stringa da codificare

  • length: lunghezza della stringa da codificare (ad esempio strlen(from))

  • to: puntatore alla stringa per memorizzare il risultato (deve essere sufficientemente lunga, il risultato è più lungo della stringa iniziale)

Esempio in C:

char *string = "abcdefgh", result[128];
weechat_string_encode_base64 (string, strlen (string), result);
/* result == "YWJjZGVmZ2g=" */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.38. string_decode_base64

WeeChat ≥ 0.3.2.

Decodifica una stringa in base64.

Prototipo:

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

Argomenti:

  • from: stringa da decodificare

  • to: puntatore alla stringa per memorizzare il risultato (deve essere sufficientemente lunga, il risultato è più lungo della stringa iniziale)

Valore restituito:

  • lunghezza della stringa memorizzata in *to (lo \0 finale non conta)

Esempio in C:

char *string = "YWJjZGVmZ2g=", result[128];
int length;
length = weechat_string_decode_base64 (string, result);
/* length == 8, result == "abcdefgh" */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.39. string_hex_dump

WeeChat ≥ 1.4.

Display a dump of data as hexadecimal and ascii bytes.

Prototipo:

char *string_hex_dump (const char *data, int data_size, int bytes_per_line,
                       const char *prefix, const char *suffix);

Argomenti:

  • data: the data to dump

  • data_size: number of bytes to dump in data

  • bytes_per_line: number of bytes to display in each line

  • prefix: the prefix to display at the beginning of each line (optional, can be NULL)

  • suffix: the suffix to display at the end of each line (optional, can be NULL)

Valore restituito:

  • string with dump of data (must be freed by calling "free" after use)

Esempio in C:

char *string = "abc def-ghi";
char *dump = weechat_string_hex_dump (string, strlen (string), 8, " >> ", NULL);
/* dump == " >> 61 62 63 20 64 65 66 2D   a b c   d e f - \n"
           " >> 67 68 69                  g h i           "  */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.2.40. string_is_command_char

WeeChat ≥ 0.3.2.

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

Prototipo:

int weechat_string_is_command_char (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • 1 se il primo carattere della stringa è un comando carattere, altrimenti 0

Esempi in C:

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

Script (Python):

# prototipo
is_cmdchar = weechat.string_is_command_char(string)

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

3.2.41. string_input_for_buffer

WeeChat ≥ 0.3.2.

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

Prototipo:

const char *weechat_string_input_for_buffer (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • puntatore all’interno di "string", oppure NULL

Esempi in C:

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):

# prototipo
str = weechat.string_input_for_buffer(string)

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

3.2.42. string_eval_expression

WeeChat ≥ 0.4.0, updated in 0.4.2, 1.0, 1.1, 1.2 and 1.3.

Evaluate an expression and return result as a string. Special variables with format ${variable} are expanded (see table below).

Note
Since version 1.0, nested variables are supported, for example: ${color:${variable}}.

Prototipo:

char *weechat_string_eval_expression (const char *expr,
                                      struct t_hashtable *pointers,
                                      struct t_hashtable *extra_vars,
                                      struct t_hashtable *options);

Argomenti:

  • expr: the expression to evaluate (see table below)

  • pointers: hashtable with pointers (keys must be string, values must be pointer); pointers "window" and "buffer" are automatically added if they are not in hashtable (with pointer to current window/buffer) (can be NULL):

    • regex: pointer to a regular expression (regex_t structure) compiled with WeeChat function string_regcomp or regcomp (see man regcomp); this option is similar to regex in hashtable options (below), but is used for better performance

  • extra_vars: extra variables that will be expanded (can be NULL)

  • options: a hashtable with some options (keys and values must be string) (can be NULL):

    • type: default behavior is just to replace values in expression, other types can be selected:

      • condition: the expression is evaluated as a condition: operators and parentheses are used, result is a boolean ("0" or "1")

    • prefix: prefix before variables to replace (default: ${)

    • suffix: suffix after variables to replace (default: })

    • extra: default behavior is to just replace extra variables (extra_vars), other behavior can be selected:

      • eval: extra variables (extra_vars) are evaluated themselves before replacing

    • regex: a regex used to replace text in expr (which is then not evaluated)

    • regex_replace: the replacement text to use with regex, to replace text in expr (the regex_replace is evaluated on each match of regex against expr, until no match is found)

Valore restituito:

  • evaluated expression (must be freed by calling "free" after use), or NULL if problem (invalid expression or not enough memory)

List of variables expanded in expression (by order of priority, from first expanded to last):

Format Description Examples Results

${name}

Variable name from hashtable extra_vars

${name}

value

${eval:xxx}
(WeeChat ≥ 1.3)

String to evaluate

${eval:${date:${weechat.look.buffer_time_format}}}

19:02:45 (with colors if there are color codes in the option weechat.look.buffer_time_format)

${esc:xxx}
${\xxx}

String with escaped chars

${esc:prefix\tmessage}
${\ua9}

prefix<TAB>message
©

${hide:x,value}

String with hidden chars (all chars in value replaced x)

${hide:*,password}

********

${re:N}

Regex captured group: 0 = whole string matching, 1 to 99 = group captured, + = last group captured

${re:1}

test

${color:name}

WeeChat color code (the name of color has optional attributes), see function color for supported formats

${color:red}red text
${color:*214}bold orange text

red text (in red)
bold orange text (in bold orange)

${info:name}
${info:name,arguments}

Info from WeeChat or a plugin, see function info_get

${info:version}
${info:irc_nick_color_name,foo}

1.0
lightblue

${date}
${date:xxx}
(WeeChat ≥ 1.3)

Current date/time, with custom format (see man strftime), default format is %F %T

${date}
${date:%H:%M:%S}

2015-06-30 19:02:45
19:02:45

${env:NAME}
(WeeChat ≥ 1.2)

Value of the environment variable NAME

${env:HOME}

/home/user

${sec.data.name}

Value of the secured data name

${sec.data.freenode_pass}

my_password

${file.section.option}

Value of the option

${weechat.look.buffer_time_format}

%H:%M:%S

${name}

Value of local variable name in buffer

${nick}

FlashCode

${hdata.var1.var2...}
${hdata[list].var1.var2...}

Hdata value (pointers window and buffer are set by default with current window/buffer)

${buffer[gui_buffers].full_name}
${window.buffer.number}

core.weechat
1

Esempi in C:

/* conditions */
struct t_hashtable *options1 = weechat_hashtable_new (8,
                                                      WEECHAT_HASHTABLE_STRING,
                                                      WEECHAT_HASHTABLE_STRING,
                                                      NULL,
                                                      NULL);
weechat_hashtable_set (options1, "type", "condition");
char *str1 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options1);  /* "1" */
char *str2 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options1);                 /* "0" */

/* simple expression */
char *str3 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL);  /* "core.weechat" */

/* replace with regex */
struct t_hashtable *options2 = weechat_hashtable_new (8,
                                                      WEECHAT_HASHTABLE_STRING,
                                                      WEECHAT_HASHTABLE_STRING,
                                                      NULL,
                                                      NULL);
/* add brackets around URLs */
weechat_hashtable_set (options2, "regex", "\\w+://\\S+");
weechat_hashtable_set (options2, "regex_replace", "[ ${re:0} ]");
char *str4 = weechat_string_eval_expression ("test: https://weechat.org", NULL, NULL, NULL);  /* "test: [ https://weechat.org ]" */

/* hide passwords */
weechat_hashtable_set (options2, "regex", "(password=)(\\S+)");
weechat_hashtable_set (options2, "regex_replace", "${re:1}${hide:*,${re:2}}");
char *str5 = weechat_string_eval_expression ("password=abc password=def", NULL, NULL, NULL);  /* "password=*** password=***" */

Script (Python):

# prototipo
str = weechat.string_eval_expression(expr, pointers, extra_vars, options)

# esempi

# conditions
str1 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"})  # "1"
str2 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"})                 # "0"

# simple expression
str3 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"

# replace with regex: add brackets around URLs
options = {
    "regex": "\\w+://\\S+",
    "regex_replace": "[ ${re:0} ]",
}
str4 = weechat.string_eval_expression("test: https://weechat.org", {}, {}, options)  # "test: [ https://weechat.org ]"

# replace with regex: hide passwords
options = {
    "regex": "(password=)(\\S+)",
    "regex_replace": "${re:1}${hide:*,${re:2}}",
}
str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, options)  # "password=*** password=***"

3.3. UTF-8

Alcune funzioni stringa UTF-8.

3.3.1. utf8_has_8bits

Verifica che una stringa abbia caratteri a 8-bit.

Prototipo:

int weechat_utf8_has_8bits (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • 1 se la stringa ha caratteri a 8-bit, 0 se solo a 7-bit

Esempio in C:

if (weechat_utf8_has_8bits (string))
{
    /* ... */
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.2. utf8_is_valid

Updated in 1.4.

Verifica che una stringa sia valida in UTF-8.

Prototipo:

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

Argomenti:

  • string: stringa

  • length: max number of UTF-8 chars to check; if ≤ 0, the whole string is checked (WeeChat ≥ 1.4)

  • error: se non NULL, *error è impostato con il puntatore al primo carattere UTF-8 non valido nella stringa, se esiste

Valore restituito:

  • 1 se la stringa UTF-8 è valida, altrimenti 0

Esempio in C:

char *error;
if (weechat_utf8_is_valid (string, -1, &error))
{
    /* ... */
}
else
{
    /* "error" punta al primo carattere non valido */
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.3. utf8_normalize

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

Prototipo:

void weechat_utf8_normalize (char *string, char replacement);

Argomenti:

  • string: stringa

  • replacement: carattere sotitutivo per i caratteri non validi

Esempio in C:

weechat_utf8_normalize (string, '?');
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.4. utf8_prev_char

Updated in 1.3.

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

Prototipo:

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

Argomenti:

  • string_start: inizio della stringa (la funzione non restituirà un carattere prima di questo puntatore)

  • string: puntatore alla stringa (deve essere ≥ string_start)

Valore restituito:

  • puntatore al precedente carattere UTF-8, NULL se non trovata (raggiunta l’inizio della stringa) (WeeChat ≥ 1.3: pointer returned is a const char * instead of char *)

Esempio in C:

const char *prev_char = weechat_utf8_prev_char (string, ptr_in_string);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.5. utf8_next_char

Updated in 1.3.

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

Prototipo:

const char *weechat_utf8_next_char (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • puntatore al carattere UTF-8 successivo, NULL se non trovato (raggiunta la fine della stringa) (WeeChat ≥ 1.3: pointer returned is a const char * instead of char *)

Esempio in C:

const char *next_char = weechat_utf8_next_char (string);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.6. utf8_char_int

Restituisce un carattere UTF-8 come intero.

Prototipo:

int weechat_utf8_char_int (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • carattere UTF-8 come intero

Esempio in C:

int char_int = weechat_utf8_char_int ("être");  /* "ê" come intero */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.7. utf8_char_size

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

Prototipo:

int weechat_utf8_char_size (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • dimensione carattere UTF-8 (in byte)

Esempio in C:

int char_size = weechat_utf8_char_size ("être");  /* == 2 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.8. utf8_strlen

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

Prototipo:

int weechat_utf8_strlen (const char *string);

Argomenti:

  • string: stringa

Valore restituito:

  • lunghezza della stringa UTF-8 (numero di caratteri UTF-8)

Esempio in C:

int length = weechat_utf8_strlen ("chêne");  /* == 5 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.9. 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:

  • string: stringa

  • bytes: massimo di byte

Valore restituito:

  • lunghezza della stringa UTF-8 (numero di caratteri UTF-8)

Esempio in C:

int length = weechat_utf8_strnlen ("chêne", 4);  /* == 3 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.10. 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:

  • string: stringa

Valore restituito:

  • numero di caratteri necessari per visualizzare la stringa UTF-8 su schermo

Esempio in C:

int length_on_screen = weechat_utf8_strlen_screen ("é");  /* == 1 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.11. utf8_charcmp

Updated in 1.0.

Confronta due caratteri UTF-8.

Prototipo:

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

Argomenti:

  • string1: prima stringa da comparare

  • string2: seconda stringa da comparare

Valore restituito:

  • -1 se string1 < string2

  • 0 se string1 == string2

  • 1 se string1 > string2

Esempio in C:

int diff = weechat_utf8_charcmp ("aaa", "ccc");  /* == -2 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.12. utf8_charcasecmp

Updated in 1.0.

Confronta due caratteri UTF-8, ignorando la sensibilità alle maiuscole.

Prototipo:

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

Argomenti:

  • string1: prima stringa da comparare

  • string2: seconda stringa da comparare

Valore restituito:

  • -1 se string1 < string2

  • 0 se string1 == string2

  • 1 se string1 > string2

Esempio in C:

int diff = weechat_utf8_charcasecmp ("aaa", "CCC");  /* == -2 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.13. 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:

  • string: stringa

Valore restituito:

  • numero di caratteri necessario per visualizzare il carattere UTF-8 su schermo

Esempio in C:

int length_on_screen = weechat_utf8_char_size_screen ("é");  /* == 1 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.14. utf8_add_offset

Updated in 1.3.

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

Prototipo:

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

Argomenti:

  • string: stringa

  • offset: numero di caratteri

Valore restituito:

  • puntatore alla stringa, N caratteri dopo (NULL se non raggiungibile) (WeeChat ≥ 1.3: pointer returned is a const char * instead of char *)

Esempio in C:

const char *str = "chêne";
const char *str2 = weechat_utf8_add_offset (str, 3);  /* points to "ne" */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.15. utf8_real_pos

Restituisce la posizione reale nella stringa UTF-8.

Prototipo:

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

Argomenti:

  • string: stringa

  • pos: posizione (numero di caratteri)

Valore restituito:

  • pozisione reale (in byte)

Esempio in C:

int pos = weechat_utf8_real_pos ("chêne", 3);  /* == 4 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.16. utf8_pos

Restituisce la posizione nella stringa UTF-8.

Prototipo:

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

Argomenti:

  • string: stringa

  • real_pos: posizione (byte)

Valore restituito:

  • posizione (numero di caratteri)

Esempio in C:

int pos = weechat_utf8_pos ("chêne", 4);  /* == 3 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.3.17. utf8_strndup

Restituisce la stringa duplicata, di lunghezza massima length.

Prototipo:

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

Argomenti:

  • string: stringa

  • length: caratteri massimi da duplicare

Valore restituito:

  • stringa duplicata (deve essere liberata chiamando "free" dopo l’uso)

Esempio in C:

char *string = weechat_utf8_strndup ("chêne", 3);  /* restituisce "chê" */
/* ... */
free (string);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.4. Cartelle

Alcune funzioni legate alle cartelle.

3.4.1. mkdir_home

Crea una cartella nella home di WeeChat.

Prototipo:

int weechat_mkdir_home (char *directory, int mode);

Argomenti:

  • directory: nome della cartella da creare

  • mode: modalità per la cartella

Valore restituito:

  • 1 se la cartella è stata creata con successo, 0 in caso di errore

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. mkdir

Crea una cartella.

Prototipo:

int weechat_mkdir (char *directory, int mode);

Argomenti:

  • directory: nome della cartella da creare

  • mode: modalità per la cartella

Valore restituito:

  • 1 se la cartella è stata creata con successo, 0 in caso di errore

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. mkdir_parents

Crea una cartella e le cartelle genitore se necessario.

Prototipo:

int weechat_mkdir_parents (char *directory, int mode);

Argomenti:

  • directory: nome della cartella da creare

  • mode: modalità per la cartella

Valore restituito:

  • 1 se la cartella è stata creata con successo, 0 in caso di errore

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. exec_on_files

Updated in 1.5.

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 (*callback)(void *data,
                                             const char *filename),
                            void *callback_data);

Argomenti:

  • directory: cartella in cui cercare i file

  • hidden_files: 1 per includere i file nascosti, altrimenti 0

  • callback: funzione chiamata per ogni file trovato, argomenti:

    • void *data: puntatore

    • const char *filename: nome file trovato

  • callback_data: puntatore fornito alla callback quando chiamata da WeeChat

Esempio in C:

void callback (void *data, const char *filename)
{
    /* ... */
}
...
weechat_exec_on_files ("/tmp", 0, &callback, NULL);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.4.5. file_get_content

WeeChat ≥ 0.3.1.

Ottiene il contenuto del file di testo in una stringa.

Prototipo:

char *weechat_file_get_content (const char *filename);

Argomenti:

  • filename: percorso e nome file

Valore restituito:

  • contenuto del file come stringa (deve essere liberata chiamando "free dopo l’uso)

Esempio in C:

char *content;

content = weechat_file_get_content ("/tmp/test.txt");
/* ... */
free (content);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.5. Utilità

Alcune funzioni utili.

3.5.1. util_timeval_cmp

Confronta due strutture "timeval".

Prototipo:

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

Argomenti:

  • tv1: prima struttura "timeval"

  • tv2: seconda struttura "timeval"

Valore restituito:

  • -1 se tv1 < tv2

  • zero se tv1 == tv2

  • +1 se tv1 > tv2

Esempio in C:

if (weechat_util_timeval_cmp (&tv1, &tv2) > 0)
{
    /* tv1 > tv2 */
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.5.2. util_timeval_diff

Updated in 1.1.

Return difference (in microseconds) between two "timeval" structures.

Prototipo:

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

Argomenti:

  • tv1: prima struttura "timeval"

  • tv2: seconda struttura "timeval"

Valore restituito:

  • difference in microseconds

Note
With WeeChat ≤ 1.0, the returned value was in milliseconds.

Esempio in C:

long long diff = weechat_util_timeval_diff (&tv1, &tv2);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.5.3. util_timeval_add

Updated in 1.1.

Add interval (in microseconds) to a timeval structure.

Prototipo:

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

Argomenti:

  • tv: struttura timeval

  • interval: interval (in microseconds)

Note
With WeeChat ≤ 1.0, the interval was expressed in milliseconds.

Esempio in C:

weechat_util_timeval_add (&tv, 2000000);  /* aggiunge 2 secondi */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.5.4. util_get_time_string

WeeChat ≥ 0.3.2, updated in 1.3.

Get date/time as a string built with "strftime" and the format defined in option weechat.look.time_format.

Prototipo:

const char *weechat_util_get_time_string (const time_t *date);

Argomenti:

  • date: puntatore alla data

Valore restituito:

  • pointer to a string with date/time

Esempio in C:

time_t date = time (NULL);
weechat_printf (NULL, "date: %s",
                weechat_util_get_time_string (&date));
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.5.5. util_version_number

WeeChat ≥ 0.3.9.

Convert a string with WeeChat version to a number.

Prototipo:

int weechat_util_version_number (const char *version);

Argomenti:

  • version: WeeChat version as string (example: "0.3.9" or "0.3.9-dev")

Esempio in C:

version_number = weechat_util_version_number ("0.3.8");      /* == 0x00030800 */
version_number = weechat_util_version_number ("0.3.9-dev");  /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9-rc1");  /* == 0x00030900 */
version_number = weechat_util_version_number ("0.3.9");      /* == 0x00030900 */
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.6. Elenchi ordinati

Funzioni lista ordinata.

3.6.1. list_new

Crea una nuova lista.

Prototipo:

struct t_weelist *weechat_list_new ();

Valore restituito:

  • puntatore alla nuova lista

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. 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:

  • weelist: puntatore alla lista

  • data: dati da inserire nella lista

  • where: posizione nella lista:

    • WEECHAT_LIST_POS_SORT: aggiunge alla lista, mantenendola ordinata

    • WEECHAT_LIST_POS_BEGINNING: aggiunge all’inizio della lista

    • WEECHAT_LIST_POS_END: aggiunge alla fine della lista

  • user_data: qualsiasi puntatore

Valore restituito:

  • puntatore al nuovo elemento

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:

  • weelist: puntatore alla lista

  • data: dati da cercare nella lista

Valore restituito:

  • puntatore all’elemento trovato, NULL se non trovato

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. list_search_pos

WeeChat ≥ 0.3.4.

Cerca la posizione di un elemento nella lista.

Prototipo:

int weechat_list_search_pos (struct t_weelist *weelist,
                             const char *data);

Argomenti:

  • weelist: puntatore alla lista

  • data: dati da cercare nella lista

Valore restituito:

  • posizione dell’elemento trovato, -1 se non trovato

Esempio in C:

int pos_item = weechat_list_search_pos (list, "my data");

Script (Python):

# prototipo
pos_item = weechat.list_search_pos(list, data)

# esempio
pos_item = weechat.list_search_pos(list, "my data")

3.6.5. 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:

  • weelist: puntatore alla lista

  • data: dati da cercare nella lista

Valore restituito:

  • puntatore all’elemento trovato, NULL se non trovato

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.6. list_casesearch_pos

WeeChat ≥ 0.3.4.

Cerca la posizione di un elemento in una lista, ricerca normale.

Prototipo:

int weechat_list_casesearch_pos (struct t_weelist *weelist,
                                 const char *data);

Argomenti:

  • weelist: puntatore alla lista

  • data: dati da cercare nella lista

Valore restituito:

  • posizione dell’elemento trovato, -1 se non trovato

Esempio in C:

int pos_item = weechat_list_casesearch_pos (list, "my data");

Script (Python):

# prototipo
pos_item = weechat.list_casesearch_pos(list, data)

# esempio
pos_item = weechat.list_casesearch_pos(list, "my data")

3.6.7. 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:

  • weelist: puntatore alla lista

  • position: posizione nella lista (il primo elemento è 0)

Valore restituito:

  • puntatore all’elemento trovato, NULL se non trovato

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.8. list_set

Imposta un nuovo valore per un elemento.

Prototipo:

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

Argomenti:

  • item: puntatore all’elemento

  • value: nuovo valore per l’elemento

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.9. list_next

Restituisce l’elemento successivo nella lista.

Prototipo:

struct t_weelist_item *weechat_list_next (struct t_weelist_item *item);

Argomenti:

  • item: puntatore all’elemento

Valore restituito:

  • puntatore all’elemento successivo, NULL se il puntatore è l’ultimo oggetto nella lista

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.10. list_prev

Restituisce l’elemento precedente nella lista.

Prototipo:

struct t_weelist_item *weechat_list_prev (struct t_weelist_item *item);

Argomenti:

  • item: puntatore all’elemento

Valore restituito:

  • pointer to previous item, NULL if pointer was first item in list

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.11. list_string

Restituisce il valore stringa di un elemento.

Prototipo:

const char *weechat_list_string (struct t_weelist_item *item);

Argomenti:

  • item: puntatore all’elemento

Valore restituito:

  • valore stringa di un elemento

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.12. list_size

Restituisce la dimensione della lista (numero di elementi).

Prototipo:

char *weechat_list_size (struct t_weelist *weelist);

Argomenti:

  • weelist: puntatore alla lista

Valore restituito:

  • dimensione della lista (numero di elementi), 0 se la lista è vuota

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.13. list_remove

Rimuove un elemento in una lista.

Prototipo:

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

Argomenti:

  • weelist: puntatore alla lista

  • item: puntatore all’elemento

Esempio in C:

weechat_list_remove (list, item);

Script (Python):

# prototipo
weechat.list_remove(list, item)

# esempio
weechat.list_remove(list, item)

3.6.14. list_remove_all

Rimuove tutti gli elementi in una lista.

Prototipo:

void weechat_list_remove_all (struct t_weelist *weelist);

Argomenti:

  • weelist: puntatore alla lista

Esempio in C:

weechat_list_remove_all (list);

Script (Python):

# prototipo
weechat.list_remove_all(list)

# esempio
weechat.list_remove_all(list)

3.6.15. list_free

Libera una lista.

Prototipo:

void weechat_list_free (struct t_weelist *weelist);

Argomenti:

  • weelist: puntatore alla lista

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. hashtable_new

WeeChat ≥ 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 long long (*callback_hash_key)(struct t_hashtable *hashtable,
                                                                                   const void *key),
                                           int (*callback_keycmp)(struct t_hashtable *hashtable,
                                                                  const void *key1,
                                                                  const void *key2));

Argomenti:

  • size: dimensione dell’array interno per memorizzare le chiavi con hash, un valore più alto usa più memoria, ma ha migliori performance. (questo non è un limite per il numero di elementi nella tabella hash)

  • type_keys: tipo per le chiavi nella tabella hash:

    • WEECHAT_HASHTABLE_INTEGER

    • WEECHAT_HASHTABLE_STRING

    • WEECHAT_HASHTABLE_POINTER

    • WEECHAT_HASHTABLE_BUFFER

    • WEECHAT_HASHTABLE_TIME

  • type_values: tipo per i valori nella tabella hash:

    • WEECHAT_HASHTABLE_INTEGER

    • WEECHAT_HASHTABLE_STRING

    • WEECHAT_HASHTABLE_POINTER

    • WEECHAT_HASHTABLE_BUFFER

    • WEECHAT_HASHTABLE_TIME

  • callback_hash_key: callback used to "hash" a key (key as integer value), can be NULL if key type is not "buffer" (a default hash function is used), arguments and return value:

    • struct t_hashtable *hashtable: puntatore alla tabella hash

    • const void *key: chiave

    • return value: hash della chiave

  • callback_keycmp: callback used to compare two keys, can be NULL if key type is not "buffer" (a default comparison function is used), arguments and return value:

    • struct t_hashtable *hashtable: puntatore alla tabella hash

    • const void *key1: prima chiave

    • const void *key2: seconda chiave

    • valore restituito:

      • numero negativo se key1 è minore di key2

      • 0 se key1 è uguale a key2

      • numero positivo se key1 è maggiore di key2

Valore restituito:

  • puntatore alla nuova tabella hash, NULL in caso di errore

Esempio in C:

struct t_hashtable *hashtable = weechat_hashtable_new (8,
                                                       WEECHAT_HASHTABLE_STRING,
                                                       WEECHAT_HASHTABLE_STRING,
                                                       NULL,
                                                       NULL);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.2. hashtable_set_with_size

WeeChat ≥ 0.3.3, updated in 0.4.2.

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

Prototipo:

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

Argomenti:

  • hashtable: puntatore alla tabella hash

  • key: puntatore alla chiave

  • key_size: dimensione della chiave (in byte), usata solo se il tipo delle chiavi nella tabella hash è "buffer"

  • value: puntatore al valore

  • value_size: dimensione del valore (in byte), utilizzata solo se il tipo dei valori nella tabella è "buffer"

Valore restituito:

  • pointer to item created/updated, NULL if error

Esempio in C:

weechat_hashtable_set_with_size (hashtable, "my_key", 0,
                                 my_buffer, sizeof (my_buffer_struct));
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.3. hashtable_set

WeeChat ≥ 0.3.3, updated in 0.4.2.

Aggiunge o aggiorna un elemento nella tabella hash.

Prototipo:

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

Argomenti:

  • hashtable: puntatore alla tabella hash

  • key: puntatore alla chiave

  • value: puntatore al valore

Valore restituito:

  • pointer to item created/updated, NULL if error

Esempio in C:

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

3.7.4. hashtable_get

WeeChat ≥ 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:

  • hashtable: puntatore alla tabella hash

  • key: puntatore alla chiave

Valore restituito:

  • valore per la chiave, NULL se non trovata

Esempio in C:

void *value = weechat_hashtable_get (hashtable, "my_key");
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.5. hashtable_has_key

WeeChat ≥ 0.3.4.

Check if a key is in the hashtable.

Prototipo:

int weechat_hashtable_has_key (struct t_hashtable *hashtable, void *key);

Argomenti:

  • hashtable: puntatore alla tabella hash

  • key: puntatore alla chiave

Valore restituito:

  • 1 se la chiave si trova nella tabella hash, 0 in caso contrario

Esempio in C:

if (weechat_hashtable_has_key (hashtable, "my_key"))
{
    /* la chiave è nella tabella hash */
    /* ... */
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.6. hashtable_map

WeeChat ≥ 0.3.3.

Chiama una funzione su tutte le voci della tabella hash.

Prototipo:

void weechat_hashtable_map (struct t_hashtable *hashtable,
                            void (*callback_map)(void *data,
                                                 struct t_hashtable *hashtable,
                                                 const void *key,
                                                 const void *value),
                            void *callback_map_data);

Argomenti:

  • hashtable: puntatore alla tabella hash

  • callback_map: funzione chiamata per ogni voce nella tabella hash

  • callback_map_data: puntatore fornito alla mappa di callback quando chiamata

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);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.7. hashtable_map_string

WeeChat ≥ 0.3.7.

Chiama una funzione su tutte le voci della tabella hash, inviando chiavi e valori come stringhe.

Prototipo:

void weechat_hashtable_map_string (struct t_hashtable *hashtable,
                                   void (*callback_map)(void *data,
                                                        struct t_hashtable *hashtable,
                                                        const char *key,
                                                        const char *value),
                                   void *callback_map_data);

Argomenti:

  • hashtable: puntatore alla tabella hash

  • callback_map: funzione chiamata per ogni voce nella tabella hash

  • callback_map_data: puntatore fornito alla mappa di callback quando chiamata

Note
Le stringhe key e value inviate alla callback sono temporanee, vengono eliminate dopo la chiamata alla callback.

Esempio in C:

void
map_cb (void *data, struct t_hashtable *hashtable,
        const char *key, const char *value)
{
    /* display key and value */
    weechat_printf (NULL, "key: '%s', value: '%s'",
                    key, value);
}
/* ... */
weechat_hashtable_map_string (hashtable, &map_cb, NULL);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.8. hashtable_dup

WeeChat ≥ 1.0.

Duplicate a hashtable.

Prototipo:

struct t_hashtable *weechat_hashtable_dup (struct t_hashtable *hashtable);

Argomenti:

  • hashtable: puntatore alla tabella hash

Valore restituito:

  • duplicated hashtable

Esempio in C:

struct t_hashtable *new_hashtable = weechat_hashtable_dup (hashtable);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.9. hashtable_get_integer

WeeChat ≥ 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:

  • hashtable: puntatore alla tabella hash

  • property: nome della proprietà:

    • size: dimensione dell’array interno "htable" nella tabella hash

    • items_count: numero di elementi nella tabella hash

Valore restituito:

  • valore intero della proprietà

Esempio in C:

int items_count = weechat_hashtable_get_integer (hashtable, "items_count");
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.10. hashtable_get_string

WeeChat ≥ 0.3.4.

Restituisce il valore stringa della proprietà di una tabella hash.

Prototipo:

const char *weechat_hashtable_get_string (struct t_hashtable *hashtable,
                                          const char *property);

Argomenti:

  • hashtable: puntatore alla tabella hash

  • property: nome della proprietà:

    • type_keys: tipo per le chiavi:

      • integer: intero

      • string: stringa

      • pointer: puntatore

      • buffer: buffer

      • time: tempo

    • type_values: tipo per i valori:

      • integer: intero

      • string: stringa

      • pointer: puntatore

      • buffer: buffer

      • time: tempo

    • keys: stringa con la lista di chiavi (formato: "chiave1,chiave2,chiave3")

    • keys_sorted: stringa con l’elenco di chiavi ordinate (formato: "chiave1,chiave2,chiave3")

    • values: stringa con la lista di valori (formato: "valore1,valore2,valore3")

    • keys_values: stringa con la lista di valori e chiavi (formato: "chiave1:valore1,chiave2:valore2,chiave3:valore3")

    • keys_values_sorted: stringa con la lista di chiavi e valori (ordinata per chiavi) (formato: "chiave1:valore1,chiave2:valore2,chiave3:valore3")

Valore restituito:

  • valore stringa della proprietà

Esempio in C:

weechat_printf (NULL, "keys are type: %s",
                weechat_hashtable_get_string (hashtable, "type_keys"));
weechat_printf (NULL, "list of keys: %s",
                weechat_hashtable_get_string (hashtable, "keys"));
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.11. hashtable_set_pointer

WeeChat ≥ 0.3.4.

Imposta il valore puntatore della proprietà di una tabella hash.

Prototipo:

void weechat_hashtable_set_pointer (struct t_hashtable *hashtable,
                                    const char *property, void *pointer);

Argomenti:

  • hashtable: puntatore alla tabella hash

  • property: nome della proprietà:

    • callback_free_key: set callback function used to free keys in hashtable (WeeChat ≥ 0.4.2)

    • callback_free_value: imposta la funzione callback usata per liberare i valori nella tabella hash

  • pointer: new pointer value for property

Esempio in C:

void
my_free_value_cb (struct t_hashtable *hashtable, const void *key, void *value)
{
    /* ... */
}

void
my_free_key_cb (struct t_hashtable *hashtable, void *key)
{
    /* ... */
}

weechat_hashtable_set_pointer (hashtable, "callback_free_value", &my_free_value_cb);
weechat_hashtable_set_pointer (hashtable, "callback_free_key", &my_free_key_cb);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.12. hashtable_add_to_infolist

WeeChat ≥ 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:

  • hashtable: puntatore alla tabella hash

  • infolist_item: puntatore all’elemento della lista info

  • prefix: stringa usata come prefisso per i nomi nella lista info

Valore restituito:

  • 1 se ok, 0 in caso di errore

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_00000"  = "key1"
     "testhash_value_00000" = "value 1"
     "testhash_name_00001"  = "key2"
     "testhash_value_00001" = "value 2"
*/
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.13. hashtable_remove

WeeChat ≥ 0.3.3.

Rimuove un elemento in una tabella hash.

Prototipo:

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

Argomenti:

  • hashtable: puntatore alla tabella hash

  • key: puntatore alla chiave

Esempio in C:

weechat_hashtable_remove (hashtable, "my_key");
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.14. hashtable_remove_all

WeeChat ≥ 0.3.3.

Rimuove tutti gli elementi in una tabella hash.

Prototipo:

void weechat_hashtable_remove_all (struct t_hashtable *hashtable);

Argomenti:

  • hashtable: puntatore alla tabella hash

Esempio in C:

weechat_hashtable_remove_all (hashtable);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.7.15. hashtable_free

WeeChat ≥ 0.3.3.

Libera una tabella hash.

Prototipo:

void weechat_hashtable_free (struct t_hashtable *hashtable);

Argomenti:

  • hashtable: puntatore alla tabella hash

Esempio in C:

weechat_hashtable_free (hashtable);
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.8. File di configurazione

Funzioni per i file di configurazione.

3.8.1. config_new

Updated in 1.5.

Crea un nuovo file di configurazione.

Prototipo:

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

Argomenti:

  • name: nome del file di configurazione (senza percorso o estensione)

  • callback_reload: funzione chiamata quando il file di configurazione viene ricaricato con /reload (opzionale, può essere NULL), argomenti e valore restituito:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_file *config_file: puntatore al file di configurazione

    • valore restituito:

      • WEECHAT_CONFIG_READ_OK

      • WEECHAT_CONFIG_READ_MEMORY_ERROR

      • WEECHAT_CONFIG_READ_FILE_NOT_FOUND

  • callback_reload_pointer: puntatore fornito per ricaricare il callback quando richiesto da WeeChat

  • callback_reload_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the configuration file is freed

Valore restituito:

  • puntatore al nuovo file di configurazione, NULL in caso di errore

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

Esempio in C:

int
my_config_reload_cb (const void *pointer, 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, NULL);

Script (Python):

# prototipo
config_file = weechat.config_new(name, callback_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. config_new_section

Updated in 1.5.

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)(const void *pointer,
                         void *data,
                         struct t_config_file *config_file,
                         struct t_config_section *section,
                         const char *option_name,
                         const char *value),
    const void *callback_read_pointer,
    void *callback_read_data,
    int (*callback_write)(const void *pointer,
                          void *data,
                          struct t_config_file *config_file,
                          const char *section_name),
    const void *callback_write_pointer,
    void *callback_write_data,
    int (*callback_write_default)(const void *pointer,
                                  void *data,
                                  struct t_config_file *config_file,
                                  const char *section_name),
    const void *callback_write_default_pointer,
    void *callback_write_default_data,
    int (*callback_create_option)(const void *pointer,
                                  void *data,
                                  struct t_config_file *config_file,
                                  struct t_config_section *section,
                                  const char *option_name,
                                  const char *value),
    const void *callback_create_option_pointer,
    void *callback_create_option_data,
    int (*callback_delete_option)(const void *pointer,
                                  void *data,
                                  struct t_config_file *config_file,
                                  struct t_config_section *section,
                                  struct t_config_option *option),
    const void *callback_delete_option_pointer,
    void *callback_delete_option_data);

Argomenti:

  • config_file: puntatore al file di configurazione

  • name: nome della sezione

  • user_can_add_options: 1 se l’utente può creare nuove opzioni nella sezione, oppure 0 se non gli è consentito

  • user_can_delete_options: 1 se l’utente può eliminare le opzioni nella sezione, oppure 0 se non gli è consentito

  • callback_read: funzione chiamata quando un’opzione nella sezione viene letta da disco (dovrebbe essere NULL in molti casi, tranne se l’opzione nella sezione necessita di una funzione personalizza), argomenti e valore restituito:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_file *config_file: puntatore al file di configurazione

    • struct t_config_section *section: puntatore alla sezione

    • const char *option_name: nome dell’opzione

    • const char *value: valore

    • valore restituito:

      • WEECHAT_CONFIG_READ_OK

      • WEECHAT_CONFIG_READ_MEMORY_ERROR

      • WEECHAT_CONFIG_READ_FILE_NOT_FOUND

  • callback_read_pointer: puntatore fornito alla callback quando chiamata da WeeChat

  • callback_read_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the section is freed

  • callback_write: funzione chiamata quando la sezione è scritta nel file (dovrebbe essere NULL in molti casi, tranne se la sezione necessita di una funzione personalizzata), argomenti e valore restituito:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_file *config_file: puntatore al file di configurazione

    • const char *section_name: nome della sezione

    • valore restituito:

      • WEECHAT_CONFIG_WRITE_OK

      • WEECHAT_CONFIG_WRITE_ERROR

      • WEECHAT_CONFIG_WRITE_MEMORY_ERROR

  • callback_write_pointer: puntatore fornito alla callback quando chiamata da WeeChat

  • callback_write_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the section is freed

  • callback_write_default: funzione chiamata quando i valori predefiniti per la sezione devono essere scritti in un file, argomenti e valore restituito:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_file *config_file: puntatore al file di configurazione

    • const char *section_name: nome della sezione

    • valore restituito:

      • WEECHAT_CONFIG_WRITE_OK

      • WEECHAT_CONFIG_WRITE_ERROR

      • WEECHAT_CONFIG_WRITE_MEMORY_ERROR

  • callback_write_default_pointer: puntatore fornito alla callback quando chiamata da WeeChat

  • callback_write_default_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the section is freed

  • callback_create_option: funzione chiamata quando viene creata una nuova opzione nella sezione (NULL se la sezione non consente di creare nuove opzioni), argomenti e valore restituito:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_file *config_file: puntatore al file di configurazione

    • struct t_config_section *section: puntatore alla sezione

    • const char *option_name: nome dell’opzione

    • const char *value: valore

    • valore restituito:

      • WEECHAT_CONFIG_OPTION_SET_OK_CHANGED

      • WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE

      • WEECHAT_CONFIG_OPTION_SET_ERROR

      • WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND

  • callback_create_option_pointer: puntatore fornito alla callback quando chiamata da WeeChat

  • callback_create_option_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the section is freed

  • callback_delete_option: funzione chiamata quando un’opzione viene eliminata nella sezione (NULL se la sezione non consente di eliminare delle opzioni), argomenti e valore restituito:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_file *config_file: puntatore al file di configurazione

    • struct t_config_section *section: puntatore alla sezione

    • struct t_config_option *option: puntatore all’opzione

    • valore restituito:

      • WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET

      • WEECHAT_CONFIG_OPTION_UNSET_OK_RESET

      • WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED

      • WEECHAT_CONFIG_OPTION_UNSET_ERROR

  • callback_delete_option_pointer: puntatore fornito alla callback quando chiamata da WeeChat

  • callback_delete_option_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the section is freed

Valore restituito:

  • puntatore alla nuova sezione nel file di configurazione, NULL in caso di errore

Esempio in C:

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

    return WEECHAT_CONFIG_READ_OK;
    /* return WEECHAT_CONFIG_READ_MEMORY_ERROR; */
    /* return WEECHAT_CONFIG_READ_FILE_NOT_FOUND; */
}

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

    return WEECHAT_CONFIG_WRITE_OK;
    /* return WEECHAT_CONFIG_WRITE_ERROR; */
    /* return WEECHAT_CONFIG_WRITE_MEMORY_ERROR; */
}

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

    return WEECHAT_CONFIG_WRITE_OK;
    /* return WEECHAT_CONFIG_WRITE_ERROR; */
    /* return WEECHAT_CONFIG_WRITE_MEMORY_ERROR; */
}

int
my_section_create_option_cb (const void *pointer, 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_CHANGED;
    /* return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE; */
    /* return WEECHAT_CONFIG_OPTION_SET_ERROR; */
    /* return WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND; */
}

int
my_section_delete_option_cb (const void *pointer, 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_OK_NO_RESET; */
    /* return WEECHAT_CONFIG_OPTION_UNSET_OK_RESET; */
    /* 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, NULL,
                                NULL, NULL, NULL,
                                NULL, NULL, NULL,
                                NULL, NULL, NULL,
                                NULL, NULL, NULL);

/* 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, NULL,
                                &my_section_write_cb, NULL, NULL,
                                &my_section_write_default_cb, NULL, NULL,
                                &my_section_create_option_cb, NULL, NULL,
                                &my_section_delete_option_cb, NULL, 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_CONFIG_OPTION_SET_OK_CHANGED
    # return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
    # return weechat.WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND
    # return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR

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. 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:

  • config_file: puntatore al file di configurazione

  • section_name: nome della sezione da cercare

Valore restituito:

  • puntatore alla sezione trovata, NULL se non trovata

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. config_new_option

Updated in 1.5.

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)(const void *pointer,
                                void *data,
                                struct t_config_option *option,
                                const char *value),
    const void *callback_check_value_pointer,
    void *callback_check_value_data,
    void (*callback_change)(const void *pointer,
                            void *data,
                            struct t_config_option *option),
    const void *callback_change_pointer,
    void *callback_change_data,
    void (*callback_delete)(const void *pointer,
                            void *data,
                            struct t_config_option *option),
    const void *callback_delete_pointer,
    void *callback_delete_data);

Argomenti:

  • config_file: puntatore al file di configurazione

  • section: puntatore alla sezione

  • name: nome dell’opzione; with WeeChat ≥ 1.4, the name can include a parent option name (the value of parent option will be displayed in /set command output if this option is "null"), the syntax is then: "name << file.section.option"

  • type: tipo dell’opzione:

    • boolean: valore booleano (on/off)

    • integer: valore intero (con stringhe opzionali per i valori)

    • string: valore stringa

    • color: colore

  • description: descrizione dell’opzione

  • string_values: valori come stringa (separati da |), usato dal tipo integer (opzionale)

  • min: valore minimo (per il tipo integer)

  • max: valore massimo (per il tipo integer)

  • default_value: valore predefinito per l’opzione (usato per il reset dell’opzione)

  • value: valore per l’opzione

  • null_value_allowed: 1 se null (valore non definito) è consentito per l’opzione, altrimenti 0

  • callback_check_value: funzione chiamata per verificare il nuovo valore per l’opzione (ozionale), argomenti e valore restituito:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_option *option: puntatore all’opzione

    • const char *value: nuovo valore per l’opzione

    • valore restituito:

      • 1 se il valore è corretto

      • 0 se il valore non è valido

  • callback_check_value_pointer: puntatore fornito alla callback check_value quando chiamata da WeeChat

  • callback_check_value_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the option is freed

  • callback_change: funzione chiamata quando il valore dell’opzione è stata cambiata (opzionale), argomenti:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_option *option: puntatore all’opzione

  • callback_change_pointer: puntatore fornito per cambiare alla callback quando chiamato da WeeChat

  • callback_change_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the option is freed

  • callback_delete: funzione chiamata quando l’opzione verrà eliminata (opzionale), argomenti:

    • const void *pointer: puntatore

    • void *data: puntatore

    • struct t_config_option *option: puntatore all’opzione

  • callback_delete_pointer: puntatore fornito per eiliminare alla callback quando chiamato da WeeChat

  • callback_delete_data: puntatore fornito dalla callback quando chiamata da WeeChat; if not NULL, it must have been allocated with malloc (or similar function) and it is automatically freed when the option is freed

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,
                               0, 0,
                               "on",
                               "on",
                               0,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL);

/* intero */
struct t_config_option *option2 =
    weechat_config_new_option (config_file, section, "option2", "integer",
                               "My option, type integer",
                               NULL,
                               0, 100,
                               "15",
                               "15",
                               0,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL);

/* 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",
                               0, 0,
                               "bottom",
                               "bottom",
                               0,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL);

/* stringa */
struct t_config_option *option4 =
    weechat_config_new_option (config_file, section, "option4", "string",
                               "My option, type string",
                               NULL,
                               0, 0,
                               "test",
                               "test",
                               1,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL);

/* colore */
struct t_config_option *option5 =
    weechat_config_new_option (config_file, section, "option5", "color",
                               "My option, type color",
                               NULL,
                               0, 0,
                               "lightblue",
                               "lightblue",
                               0,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL,
                               NULL, NULL, NULL);

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 1
    # return 0

def option4_change_cb(data, option):
    # ...

def option4_delete_cb(data, option):
    # ...

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, 0, "lightblue", "lightblue", 0,
    "", "",
    "", "",
    "", "")
Note
In Ruby, the 3 callbacks + data (6 strings) must be given in an array of 6 strings (due to a Ruby limitation of 15 arguments by function), see the WeeChat Scripting Guide for more info (fixed in version 0.4.1).

3.8.5. 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:

  • config_file: puntatore al file di configurazione

  • section: puntatore alla sezione

  • name: nome dell’opzione da cercare

Valore restituito:

  • puntatore all’opzione trovata, NULL se non trovata

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. 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);

Argomenti:

  • config_file: puntatore al file di configurazione

  • section: puntatore alla sezione

  • option_name: nome dell’opzione

  • section_found: puntatore al puntatore della sezione, sarà impostato alla sezione dell’opzione, se viene trovata

  • option_found: puntatore al puntatore dell’opzione, sarà impostato al puntatore di un’opzione, se viene trovata

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 */
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.8.7. config_search_with_string

Get file/section/option info about an option with full name.

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,
                                        char **pos_option_name);

Argomenti:

  • option_name: nome completo dell’opzione (formato: "file.section.option")

  • config_file: puntatore al puntatore del file di configurazione, sarà impostato al puntatore al file di configurazione se l’opzione viene trovata

  • section: puntatore al puntatore della sezione, sarà impostato alla sezione dell’opzione, se viene trovata

  • option: puntatore al puntatore dell’opzione, sarà impostato al puntatore di un’opzione, se viene trovata

  • pos_option_name: pointer to a string pointer, will be set to pointer to name of option, if found

Esempio in C:

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

weechat_config_search_with_string ("file.section.option",
                                   &ptr_config_file,
                                   &ptr_section,
                                   &ptr_option,
                                   &option_name);
if (ptr_option)
{
    /* opzione trovata */
}
else
{
    /* opzione non trovata */
}
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.8.8. 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:

  • text: testo da analizzare

Valore restituito:

  • 1 se il testo è "true" ("on", "yes", "y", "true", "t", "1")

  • 0 se il testo è "false" ("off", "no", "n", "false", "f", "0")

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. 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:

  • option: puntatore all’opzione

  • run_callback: 1 per la chiamata alla callbackse il valore dell’opzione è cambiato, altrimenti 0

Valore restituito:

  • WEECHAT_CONFIG_OPTION_SET_OK_CHANGED se il valore dell’opzione è stato resettato

  • WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE se il valore non è stato modificato

  • WEECHAT_CONFIG_OPTION_SET_ERROR in caso di errore

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. 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:

  • option: puntatore all’opzione

  • value: nuovo valore per l’opzione

  • run_callback: 1 per la chiamata alla callback chang se il valore dell’opzione è cambiato, altrimenti 0

Valore restituito:

  • WEECHAT_CONFIG_OPTION_SET_OK_CHANGED se il valore dell’opzione è cambiato

  • WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE se il valore non è cambiato

  • WEECHAT_CONFIG_OPTION_SET_ERROR in caso di errore

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. 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:

  • option: puntatore all’opzione

  • run_callback: 1 per la chiamata alla callback chang se il valore dell’opzione è cambiato (se non è null), altrimenti 0

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

Valore restituito:

  • WEECHAT_CONFIG_OPTION_SET_OK_CHANGED se il valore dell’opzione è cambiato

  • WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE se il valore non è cambiato

  • WEECHAT_CONFIG_OPTION_SET_ERROR in caso di errore

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. config_option_unset

Rimuove/ripristina un’opzione.

Prototipo:

int weechat_config_option_unset (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Valore restituito:

  • WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET se il valore dell’opzione non è stato ripristinato

  • WEECHAT_CONFIG_OPTION_UNSET_OK_RESET se il valore dell’opzione è stato ripristinato

  • WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED se l’opzione è stata rimossa

  • WEECHAT_CONFIG_OPTION_UNSET_ERROR in caso di errore

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. config_option_rename

Rinomina un’opzione.

Prototipo:

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

Argomenti:

  • option: puntatore all’opzione

  • new_name: nuovo nome per l’opzione

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. 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:

  • option: puntatore all’opzione

  • property: nome della proprietà:

    • config_file: puntatore al file di configurazione (struct t_config_file *)

    • section: puntatore alla sezione (struct t_config_section *)

    • name: nome dell’opzione (char *)

    • parent_name: name of parent option (char *) (WeeChat ≥ 1.4)

    • type: tipo dell’opzione (int *)

    • description: descrizione dell’opzione (char *)

    • string_values: valori stringa (char *)

    • min: valore minimo (int *)

    • max: valore massimo (int *)

    • default_value: valore predefinito (dipende dal tipo)

    • value: valore corrente (dipende dal tipo)

    • prev_option: puntatore all’opzione precedente (struct t_config_option *)

    • next_option: puntatore all’opzione successiva (struct t_config_option *)

Valore restituito:

  • puntatore alla proprietà richiesta

Esempio in C:

char *description = weechat_config_option_get_pointer (option, "description");
Note
Questa funzione non è disponibile nelle API per lo scripting.

3.8.15. 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:

  • option: puntatore all’opzione

Valore restituito:

  • 1 se il valore dell’opzione è "null"

  • 0 se il valore dell’opzione non è "null"

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. 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:

  • option: puntatore all’opzione

Valore restituito:

  • 1 se il valore predefinito di un’opzione è "null"

  • 0 se il valore predefinito di un’opzione non è "null"

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. config_boolean

Restituisce il valore bool di un’opzione.

Prototipo:

int weechat_config_boolean (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: boolean value of option (0 or 1)

  • integer: 0

  • string: 0

  • color: 0

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
if (weechat_config_boolean (option))
{
    /* il valore è "true" */
}
else
{
    /* il valore è "false" */
}

Script (Python):

# prototipo
value = weechat.config_boolean(option)

# esempio
option = weechat.config_get("plugin.section.option")
if weechat.config_boolean(option):
    # ...

3.8.18. config_boolean_default

Restituisce il valore bool predefinito di un’opzione.

Prototipo:

int weechat_config_boolean_default (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: default boolean value of option (0 or 1)

  • integer: 0

  • string: 0

  • color: 0

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
if (weechat_config_boolean_default (option))
{
    /* il valore è "true" */
}
else
{
    /* il valore è "false" */
}

Script (Python):

# prototipo
value = weechat.config_boolean_default(option)

# esempio
option = weechat.config_get("plugin.section.option")
if weechat.config_boolean_default(option):
    # ...

3.8.19. config_integer

Restituisce il valore intero di un’opzione.

Prototipo:

int weechat_config_integer (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: boolean value of option (0 or 1)

  • integer: integer value of option

  • string: 0

  • color: color index

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
int value = weechat_config_integer (option);

Script (Python):

# prototipo
value = weechat.config_integer(option)

# esempio
option = weechat.config_get("plugin.section.option")
value = weechat.config_integer(option)

3.8.20. config_integer_default

Restituisce il valore intero predefinito di un’opzione.

Prototipo:

int weechat_config_integer_default (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: default boolean value of option (0 or 1)

  • integer: default integer value of option

  • string: 0

  • color: default color index

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
int value = weechat_config_integer_default (option);

Script (Python):

# prototipo
value = weechat.config_integer_default(option)

# esempio
option = weechat.config_get("plugin.section.option")
value = weechat.config_integer_default(option)

3.8.21. config_string

Restituisce il valore stringa di un’opzione.

Prototipo:

const char *weechat_config_string (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: "on" if value is true, otherwise "off"

  • integer: string value if the option is an integer with string values, otherwise NULL

  • string: string value of option

  • color: name of color

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
const char *value = weechat_config_string (option);

Script (Python):

# prototipo
value = weechat.config_string(option)

# esempio
option = weechat.config_get("plugin.section.option")
value = weechat.config_string(option)

3.8.22. config_string_default

Restituisce il valore stringa predefinito di un’opzione.

Prototipo:

const char *weechat_config_string_default (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: "on" if default value is true, otherwise "off"

  • integer: default string value if the option is an integer with string values, otherwise NULL

  • string: default string value of option

  • color: name of default color

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
const char *value = weechat_config_string_default (option);

Script (Python):

# prototipo
value = weechat.config_string_default(option)

# esempio
option = weechat.config_get("plugin.section.option")
value = weechat.config_string_default(option)

3.8.23. config_color

Restituisce il valore colore di un’opzione.

Prototipo:

const char *weechat_config_color (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: NULL

  • integer: NULL

  • string: NULL

  • color: name of color

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
const char *color = weechat_config_color (option);

Script (Python):

# prototipo
value = weechat.config_color(option)

# esempio
option = weechat.config_get("plugin.section.option")
value = weechat.config_color(option)

3.8.24. config_color_default

Restituisce il valore colore predefinito di un’opzione.

Prototipo:

const char *weechat_config_color_default (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • boolean: NULL

  • integer: NULL

  • string: NULL

  • color: name of default color

Esempio in C:

struct t_config_option *option = weechat_config_get ("plugin.section.option");
const char *color = weechat_config_color_default (option);

Script (Python):

# prototipo
value = weechat.config_color_default(option)

# esempio
option = weechat.config_get("plugin.section.option")
value = weechat.config_color_default(option)

3.8.25. config_write_option

Scrive una riga nel file di configurazione con l’opzione ed il suo valore (questa funzione /span>);

Argomenti:

  • option: puntatore all’opzione

Valore restituito:

) value = weechat.config_color(option)

3.8.24. config_color_default

Restituisce il valore colore predefinito di un’opzione.

Prototipo:

const char *
:
    # ..class="tok-o">.3.8.25. config_write_option

Scrive una riga nel file di configurazione con l’opzione ed il suo valore (questa funzione /span>); = weechat.co

const char *weechat_config_color_default (struct t_config_option *option);

Argomenti:

  • option: puntatore all’opzione

Return value, depending on the option type:

  • é

  • | : garder les attributs : ne pas réinitialiser gras/inverse/italique/souligné lors du changement de couleur (WeeChat ≥ 0.3.6)

ragraph">

Argomenti:

  • option: puntatore all’opzione

Valore restituito:

) value rc = "plugin.section.option") .config_color) .config_color) .config_color

option: puntatore all’opzione

Prototipo:

t_config_option *option0, WEECHAT_LI puntato

Script (Python):

# prototipo
value = 3.8.24. config_color_default

Restituisce il valore colore predefinito di un’opzione.

Prototipo:

,
                               "My option, type color",
                               NULL,
                               0, 0,
                               "lightblue",
                               option)

3.8.24. config_color_default

Restituisce il valore colore predefinito di un’opzione.

weechat
  • é

  • | : garder les attributs : ne pas réinitialiser gras/inverse/italique/souligné lors du changement de couleur (WeeChat ≥ 0.3.6)

ragraph">

Argomenti:

  • option: puntatore all’opzione

Valore restituito:

) value rc rc = "plugin.sevalor

punrd >.) .config_color

# prototipo value = 3.8.24. config_color_default

Restituint

Prototipo:

,
                               "My 

Valoter vefinito di un’opzione.

weechat
    la sezione

  • user_can_add_options: 1 se l’utente può creare nuove opzioni nella sezione, oppure 0 se non gli è consentito

  • user_can_delete_options: 1 se l’utente può eliminare le opzioni nella sezione, oppuri="listingblock">

    # prototipo
    value = 3.8.24. config_color_default
    

    3.8.24. config_color_default

    Restituisce il valore colore predefinito di un’opzione.

    tok-o">*option0, WEECHAT_LI puntato

    Script (Pythoass="tok-p">, WEECHAT_LI puntato

    Script (Python):

    # prototipotok-n">weechat_hak-s2">&qsce il valore colore predefinito di un’opzione.

    Prototipo:

    ,
                    s="tok-n">rc = "plugin.sevalor
    

    punrd >.) .config_cce il valore colore predefinito di un’opzione.

    *hashtable);<, option)
    • option: puntatore all’opzione

    Valore restituito:

    ) value rc = # prototipo value = 3.8.24. config_color_default

    Restituisce il valore colore predefinito di un’opzione.

    # prototipotok">)(WeeChat ≥ 0.3.6)

ragraph">

Argomenti:

  • option: puntatore all’opzione

Valore restituito:

Valore restituito:

)

Prototipo:

,weechat.config_color(option)

3.8.24.tent">
# prototipo
value = 3.8.24. config_color_default

    la sezione

  • user_can_add_options: 1 se l’utclass="tok-n">hashtable);<, option)

    • option: puntatore all’opzione

Valore restituito:

3.8.24. config_color_default

Restituisce il valore colore predefinito di un’opzione.

tok-o">*option0, WEECHAT_LI puntato

Script (Pythoass="tok-p">, WEECHAT_LI puntato

Script (Python):

# prototipotok-n">weechat_hak-s2">&qsce il valore colore predefinito di un’opzione.

Prototipo:

,
     ptok-p">(info_name, description, args_description,
              etestituito:

Valore restituito:

)

Prototipo:

, etestituito:

Valore restituito:

)

Prototipo:

, ring: stringa

Valore restituito:

  • ngement de couleur h">

    Prototipo:

,wee>iv>
,weechat
,wee>iv>
Resti3.8.14. config_option_get_pointer

Restituisce un puntatore alla proprietà di un’opzione.

Prototipo:

(WeeChat ≥ 0.3.6)

ragraph">

Argomenti:

  • option: puntatore all’opzione

  • WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET se il valore dell’opss="pygments highlightween IRCan>,weechat.config_color(option)

option>

Prototipo:

t_conem>string_values: valori come stringa (separati da |), usato dal tipo integer (opzionale)

  • min: vala "tok-kt" fig_colom(option)

  • 3.8.24.tent">
    (WeeChat ≥ 0.3.6)

    /div>

    3.8.24. config_color_default

    Restituisce il valore colore predefinito di un’opzione.

    tok-o">*

    Script (Pythoass="tok-p">, WEECHAT_LI puntato

    Script (Python):

    # prototipotok-n">weechat_hak-s2">&qsce il valore colore predefinito di un’opzione.

    Prototipo:

    ,
         ptok-p">(info_name, description
    
    # prototipotok">)(WeeChat ≥ 0.3.6)

    ragraph">

    Argomenti:

    • optn> ring

      • optn> ring

        • optn> ring

          • optn> ring

            • optn> ring

              • optn> ring

                • optn> ring

                _null(option)

    option>

    Prototipo:

    t_conem>string_values: valori come stringa (separati da

    bar_condition_yyy

    ,weechat,weechat.config_color(option)

    option

    Pour certains "hooks", vous pouvez définir une priorité. Un "hook" avec une priorité plus élevée sera au début de la liste des "hooks", et donc il sera trouvé et exécuté avant les autres "hooks". Cela est pratique poass="p ote

    bar_condition_yyy

    ,weechat,weechat..config_color(option)

    option

    Pour certains "hooks", vous pouvez définir une priorité. Un "hook" avec une priorité plus élevée sera au début de la liste des "hooks", et donc il sera trouvé et exécuté avant les autres "hooks". Cela eains "hooks", vous pouvez définir une priorité. Un "hook" avec une priorité plus élevée sera au début de la liste des "hooks", e>

    callback_free_value: fault">em>: integer value of option

  • string: 0

  • color: color index

  • li> ph">

    Prototipo:

    t_conem>string_values: valo>)

    option

    Pour certainsrototipo value = 3.8.24. config_color_defaultt_conem>string_values: valori come stringa (separati da , WEECHAT_LI puntato

    Script (Python):

    # prototipotok-n">an cl, vous pouvez ass="tok-n">WE: puntatore alla chiave

  • key_size: dimensione della chiave (in byte), usata solo se il tipo delle chiavi nella tabella hash è "buffer"

  • value: puntatore al valore

  • value_size: dimensione del valité. Un "hook" avec une priorité plus élevée sera au début de la liste des "hooks", et donc il sera trouvé et exécuté avant les autres "hooks". Cela est pratique poass="p ote

  • bar_condition_yyy ste des2( a liste des certainsrototipo ,

  • bar_conid="_co

  • mtn> ring

    • optn> ring"plugin.sevalor

      punrd >.) .config_color

      # prop">

      ,weechat,

    • t_conem>string_values: valo>)

      option

      Pour certainsrototipo value = 3.8.24. config_coln"d="_coprior"tok-nf">weechat_config_string_default (

      Return value, depending on the option type:

      • boolean: "on" if default value is true, otherwise "off"

      • integer: default string value if the option is an integer >: 0

      • color: color index

      tok-n">Wlass/em>: dimensione della chiave (in byte), usata solo se il tipo delle chiavi nella tabella hash è "buffer"

    • value: puntatore al valore

    • value_size: dimensione del valité. Un "hook" avec une prioriEECHAT_LI puntato

      Script (Python):

      Script (Python):

      callback_free_value: fault">em>: integer value of option

    • string: 0

    • color: color index

  • Script (Pytss="tok-n">config_color

    # prop">

    ,weechat,

  • , WEECHAT_LI puntato

    Script (Python):

    # prototipotok-tainsrototipo , WEECHAT_LI puntato

    Script (Python):

    # prototipotok-tainsrototipo )

    bar_condition_yyy ste des2( a liste des certainsrototipo ,

  • Script (Python):

    Script (Python):

    Prototipo:

    t_conem>string_values: valo>)

    option

    Pour certainsrototipo value insrototipo

    Script (Python):

  • value_size: dimensione del valité. Un "hook" avec une prioriEECHAT_LI puntato

    Script (Python):

    Script (Python):

    { case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: /* .... */ break; )
  • option

    Pour certainsrototipo value insrototipo

    Script (Python):

    { case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: "tok-p">)

    bar_condition_yyy color = weech/span> weech/span> weech/span> weech/span> weech/span> : # ..class="tok-o">.3.8.25. cté. U">{ case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: "tok-p">)

    bar_condition_yyy cté. U">{ case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: "tok-p">)

    t_conem>string_valuediv cl-n">t_conem>string_values: valo>)

    option

    Pour certainsrototipo value insrototipo

    Script (Pyth sera au début de la liste des "hooks", lass=iv cl-n">t_conem>string_values: valo>)

    option

    Pour certainsrototipo value insrototipo

    Script (Pyth sera au début de la liste des "hooks", lass=iv cl-n">t_conem>string_values: valo>

    Script (Python):

    { case WEECHAT_CONFIG_OPTION_SET_OK_CHANGOu"ptol valitÃlt">em>:ur certainsrototipo value insrototipo t_config_option *option = weechat_config_get ("plugin.section.option"sti avec une prioriEECHAT_LI puntato

    Script (Python):

    { case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: "tok-p">) { case WEECHAT_CONFIG_OPTIspan class="tok-o">*
     ("plugin.section.option"sti avec une
    prioriEECHAT_LI puntato

    Script (Python):

    { case

    t_conem>string_valuediv cl-n">t_conem>string_values: valo>)

    option

    Pour certainsrototipot_conem>string_valuediv cl-n">t_conem>string_values: valo>)

    option

    Pour certainsrototipot_conem>string_valuediv tipot_conem>string_valuediv tipot_conem>string_aragraph">

    Pour certainsrototipo value insrototipo

    Script (Pyth sera au début de la liste des "hooks", lass=iv cl-n">t_conem>string_values: valo>)

    opm>: dimeenti:

    ="tok-p">)

    option

    Pour certainsrototipot_conem>string_valuediv tipot_conem>string_valuediv tipot_conem>string_aragraph">

    Poug_color_default

  • Restituint

    Prototipo:

    ,
                                   "My 

    Valoter vefinito di un’opzione.

    weechat
      la sezione

    • user_can_add_options:>)

      option

      Pour certainsrototipo value insrototipo

      Script (Python):

    ); const char *color = weechat_config_color (: valo>)

    t_conem>string_valuediv cl-n">t_conem>string_values: valo>)

    option

    Pour certainsrototipot_conem>string_valuediv cl-n">t_conem>stri > ,weechat

    Script (Pytss="tok-n">config_color

    # prop">

    ,weechat,

  • , WEECHAT_LI puntato

    Script (Python):

    # prototipotok-tainsrototipo , WEECHAT_LI puntato

    Script (Python):

    case

    t_conem>string_valuediv cl-n">t_conem>string_values: valo>)

    option

    Pour certainsrototipot_conem>string_valuediv cl-n">t_conem>string_values: valo>)

    option (tet_conem>string_valuediv cl-n">t_conem>string_values: valo>)

    option

    Pour certainsrototipot_conem>string_valuediv cl-n">t_conem>string_values: valo défaut est 1000.

    Exemple en C :

    /* accroche un modificateur avec priorité = 2000 */

    ="tok-p">)

    option

    Pour certainsrototipot_conem>string_valuediv tipot_conem>string_valuediv tipot_conem>string_aragraph">

    Poug_color_default

  • Restituint

    Prototipo:

    ,
                                   "My 

    Valoter vefinito di hook_command">3.11.1. hook_command

    Mis à jour dans la 1.5.

    Accrocher une commande.

    Prototype :

    struct t_hook *weechat_hook_command (
    

    Script (Pytss="tok-n">config_color

    # prop">

    ,weechat,t_conem>string_valuediv cl-n">t_conem>stri > ,weechat

    Script (Pytss="tok-n">config_color

    # prop">

    ,weechat,

  • , WEECHAT_LI puntato
    ,weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > ,weechat

    Script (Pytss="tok-n">config_color

    # prop">

    /em>: v,soragraph">

    Pour certainsrototipot_conem>string_valuediv tipotur certainsrototipot_conem>string_valuediv tipot_conem>string_valuediv tipot_conem>string_aragraph">

    Poug_color_default

    Restituint

    Prototipo:

    t_conemh">
    

    Restituint

    Prototipo:

    ,
                                   t_conem>string_valuediv cl-n">t_conem>string_values: valo défaut est 1000.

    Exemple en C :

    /* accroche un modificateur avec priorité = 2000 */

    WeeChat ≥ 0.3.4.

    Retourner la valeur d’une propriété de la complétion sous conem>string_valuediv tipot_conem>string_aragraph">

    Poug_color_default

  • Restituint

    Prototipo:

    ,weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>stri > ,weechat: color index

    li> ph">

    Prototipo:

    t_conem>string_values: vner la valeur d’une propriété de la complétion sous conem>string_valuediv tipot_conem>string_valuediv cl-n">t_conem>stri > t_conem>stri >

    Accrocher une commande.

    Prototype :

    struct t_hook *weechat_hook_command (
    

    Script (Pytss="tok-n">config_color

    # prop">

    struct t_hook *weechat_hook_command (
    

    Script (Pytss="tok-n">config_color

    # prop">

    /em>: v,soragraph">

    Pour certainsrototipot_conem>string_valuediv tipotur certainsrototipo_hook_command (

    Script (Pytss="tok-n">config_color

    # prop">

    /em>: v,soragraph">

    Pour certainsrototipo

    Prototipo:

    t_conemh">
    

    Restituint

    ,
                                   t_conem>string_valuediv cl-n">t_conem>string_values: valo défaut est 1000.

    Exemple en C :

    /* accroche un modificateur avec priorité = 2000 */

    ,weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>stri > ,weechat: color index

    li> ph">

    Prototipo:

    t_conem>string_values: vner la valeur d’une propriété de la complétion sous conem>string_valuediv tipot_conem>string_valuediv cl-n">t_conem>striook_comr" hr
  • option

    Pour certains "hooks", vous pouvez définir une priorité. Un "hook" avec une priorité plus élevée sera au début de la liste des "hooks", et donc il sera trouvé et exécuté avant les autres "hooks". Cela est pratique poass="p ote

  • bar_condition_yyy

    3.1.1. plugin_getcase

    const char *weechat_plugin_get_name t_conem>striook_comr" hr
  • option

    Pour certains "hooks", vous pouvez définir une priorité. Un "hook" avec une priorité plus élevée sera au début de la liste des "hooks", et donc il sera trouvé et exécuté avant les autres "hooks". Cela est,

    bar_condition_yyy

    3.1.1. plugin_getcase

    bar_condition_yyy

    struct t_config_option *option = weechat_config_get (

    t_conem>stri >
    (
    

    Script (Pytss="t class="tok-n">t_config_option *option ="tok-np>

    ,option = weechat_config_get (

    t_conem>stri >
    
    
    *option = 
    
    t_conem>stri >
    
    
    *t_conem>string_valuediv cl-n">t_conem>stri >
    t_conem>stri >
    ,="tok-

    ,option = weechat_config_get (

    t_conem>stri >
    ediv cl-n">t_conem>stri >
    t_conem>stri >
    string_valuediv cl-n">t_conem>stri >
    t_conem>stri >
    ,="tok-

    ,option = = = = = = = = = =<1s oqm.1. plugin_getcase = = =

    *option = bar_condition_yyy

    3.1.1. plugin_getcase bar_condition_yyy

    ,option = weechat_config_get =
    *option = bar_condition_yyy

    t_con_yyy # prop">

    /em>: v,soragraph">

    Pour certainsrototipot_conem>"tok-n">="tok-o">=

  • color: color indtween IRss="tok-o">=

  • color: color indtween IRss="tok-o">=

    *option = stri >
    =
    *<>string: 0

  • color: color indtween IRss="tok-o">=

    : color indexstri > : colorg_valuedolor: color indexstri > , =
    = bar_condition_yyy

    3.1.1. plugin_getcase aluedolor: st,

    ,option
    *option weechat,t_conem>string_valuediv cl-n">t_conem>s aluedolor: st,

    ,option
    *option weechat *
    ,w-n">weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>strdiv7;opss="pygments highlightween IRCan>,weechat,w

    ,option
    *option weechat *=
    *<>string: 0

  • tri > t_conem>strdiv7;opss="pygments highlightween IRCan>,weechat: color pan class="tok-n">option = bar_condition_yyy

    3.1.1. plugin_getcase aluedolor: st, ata-lang="C""tok-n">weechat: color pan class="tok-n">option = bar_condition_yyy

    , =
    <"> , =
    = bar_condition_yyy

    3.1.1. plugin_getcase v clingrass="tok p">,w-n">weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>strdiv7;opss="pygments highlightween IRCan>,weechat,w

    ,option
    *# prop">

    ,weechat,

  • , WEECHAT_LI puntato

    Script (Python):

    weechat,t_conem>string_valuediv cl-n">t_conem>s aluedolor: st, cl-n">t_conem>s aluedolor: st,

    ,option
    *option weechat *
    ,w-n">weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>strdiv7;opss="pygmeito highlightween IRCan>,weechat,w

    ,option
    *option weechat *= *<>string: 0

  • tri > t_conem>strdiv7;opss="pygments highlightween IRCan>,weechat: color pan claere"> 3.1.1. plugin_getcase="tok-p">:
    "tok-p">)

    bar_condition_yyy color = weech/span> weech/spa3.1.1. plugin_getcase v clingrass="tok p">,w-n">weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>strdiv7;opss="pygments highlightween IRCan>,=

    *option weechat,: color pan class="tok-n">option

    Script (pan> =

    *option weechat,w-n">weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>strdiv7;opss="pygments highlightween IRCan>,weechatbar_condition_yyy

    3.1.1. plugin_getcase aluedolor: st, ata-lang="C""tok-n">weechat: color pan class="tok-n">option = , : color pan class="tok-n">option = , :l-n">t_conem>s t_conem>string_valuediv cl-n">t_conem>s aluedolor: st, cl-n">t_conem>s aluedolor: st, class="tableblock halign-center valign-top">

    weechat

    filters_disabled

    -

    Filtres désactivés

    v clingrass="tok p">,w-n">weechat<,: rite_optnm-nito highlightween IRCan>,weechat,w

    ,"tok-n">wocl-n">t_conem>stri > ,weechat: color indexstri >
    =
    ,"tok-n">wocl-n">t_conem>stri > ,weechat: color indexstri >
    =
    ,"tok-n">wocl-n">t_conem>stri > ,w-n">weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>strdiv7;opss="pygments highlightween IRCan>,=
    *option wonem>strdiv7;opss="pygments highlightween IRCan>,ipo: color pan class="tok-n">option

    Script (pan> = ,weechat: color indexstri >

    =
    ,"tok-n">wocl-n">t_conem>stri > ,

    Script (pan> = ,=

    ,"tok-n">wocl-n">t_conem>stri > ,

    Script (pan> = ,=

    ,"tok-n">wocl-n">van cla"tok-n class prioritxécuté a ot/xaluedolor: st,

    ,option
    *option weechat,t_conem>string_valuediv cl-n">t_conem>s alupaann> *option weechat,w-n">weechat<,: rite_optnm-n">t_conem>string_valuediv cl-n">t_conem>stri > t_conem>strdiv7;opss="pygments highlightween IRCan>,weechatbar_condition_yyy

    3.1.1. plugin_getcase , : color pan class="tok-n">option = weechat*completion_item, ighlightween IRCan>,ipo: color pan class="tok-n">option

    Script (pan> = ,weechat: color indexstri >

    =
    ,"tok-n">wocl-n">t_conem>stri > ,

    Script (pan> = ,=