diff --git a/ChangeLog b/ChangeLog index e74fe9109..e42ec57cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2008-06-17 +ChangeLog - 2008-06-18 Version 0.2.7 (under dev!): + * add new options for completion, optional stop instead of cycling with + words found * add speed limit for DCC files sending (task #6178) * add new input action "set_unread_current_buffer" to set unread marker for current buffer only (task #7286) diff --git a/po/cs.po b/po/cs.po index 7ba31b34d..8f867373c 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-06-17 16:16+0200\n" +"POT-Creation-Date: 2008-06-18 16:02+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -1026,16 +1026,6 @@ msgstr "" msgid "time format for \"time\" bar item" msgstr "časová značka pro čas v infobaru" -msgid "complete only with first nick found" -msgstr "dokončit pouze s prvním nalezenou přezdívkou" - -msgid "chars ignored for nick completion" -msgstr "znaky ignorovány pro doplňování přezdívky" - -#, fuzzy -msgid "string inserted after nick completion" -msgstr "řetězec vložený za doplňování přezdívky" - #, fuzzy msgid "display nicklist (on buffers with nicklist enabled)" msgstr "zobrazit okno se seznamem přezdívek (pouze pro okno kanálu)" @@ -1403,6 +1393,36 @@ msgstr "barva pro '+' při procházení přezdívek" msgid "text color for nicklist separator" msgstr "barva děliče přezdívek" +#, fuzzy +msgid "string inserted after nick completion" +msgstr "řetězec vložený za doplňování přezdívky" + +msgid "complete only with first nick found" +msgstr "dokončit pouze s prvním nalezenou přezdívkou" + +msgid "chars ignored for nick completion" +msgstr "znaky ignorovány pro doplňování přezdívky" + +msgid "alert user when a partial completion occurs" +msgstr "" + +msgid "" +"partially complete nicks (stop when many nicks found begin with same letters)" +msgstr "" + +msgid "" +"partially complete command names (stop when many commands found begin with " +"same letters)" +msgstr "" + +msgid "" +"partially complete command arguments (stop when many arguments found begin " +"with same prefix)" +msgstr "" + +msgid "display count for each partial completion in bar item" +msgstr "" + #, fuzzy msgid "maximum number of lines in history per buffer (0 = unlimited)" msgstr "maximální počet uživatelských příkazů v historii (0 = nekonečně)" @@ -3017,15 +3037,6 @@ msgstr "" msgid "automatically rejoin channels when kicked" msgstr "automaticky znovu přijít na kanál po vykopnutí" -msgid "" -"comma separated list of notify levels for channels of this server (format: " -"#channel:1,..), a channel name '*' is reserved for server default notify " -"level" -msgstr "" -"čárkou oddělený seznam levelů upozornění pro kanály na tomto serveru " -"(formát: #kanál:1,..), jméno serveru '*' je rezervováno pro defaultní " -"hodnotu levelu upozornění" - #, fuzzy, c-format msgid "%s%s: error creating server option \"%s\"" msgstr "%s nedostatek paměti pro infobar zprávu\n" @@ -4589,6 +4600,15 @@ msgstr "%s DCC: nemohu nastavit 'neblokovaci' volbu na soket\n" msgid "%s%s: timeout for \"%s\" with %s" msgstr "%s chybí argument pro volbu \"%s\"\n" +#~ msgid "" +#~ "comma separated list of notify levels for channels of this server " +#~ "(format: #channel:1,..), a channel name '*' is reserved for server " +#~ "default notify level" +#~ msgstr "" +#~ "čárkou oddělený seznam levelů upozornění pro kanály na tomto serveru " +#~ "(formát: #kanál:1,..), jméno serveru '*' je rezervováno pro defaultní " +#~ "hodnotu levelu upozornění" + #, fuzzy #~ msgid "%sError: incorrect notify level (must be between %d and %d)" #~ msgstr "%s nekorektní level upozornění (musí být mezi %d a %d)\n" diff --git a/po/de.po b/po/de.po index ee884abae..44b0ddfd1 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-06-17 16:16+0200\n" +"POT-Creation-Date: 2008-06-18 16:02+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -1019,16 +1019,6 @@ msgstr "" msgid "time format for \"time\" bar item" msgstr "Timestamp in der Infobar" -msgid "complete only with first nick found" -msgstr "nur mit dem ersten, passenden Nicknamen vervollständigen" - -msgid "chars ignored for nick completion" -msgstr "Zeichen, die bei der Nickvervollständigung ignoriert werden" - -#, fuzzy -msgid "string inserted after nick completion" -msgstr "Nach Nickvervollständigung anzufügende Zeichenfolge" - #, fuzzy msgid "display nicklist (on buffers with nicklist enabled)" msgstr "Nicklisten-Fenster in Channelfenstern anzeigen" @@ -1398,6 +1388,36 @@ msgstr "Farbe des '+' beim Scrolling von Nicknames" msgid "text color for nicklist separator" msgstr "Farbe der Nicknamefenster-Trennlinie" +#, fuzzy +msgid "string inserted after nick completion" +msgstr "Nach Nickvervollständigung anzufügende Zeichenfolge" + +msgid "complete only with first nick found" +msgstr "nur mit dem ersten, passenden Nicknamen vervollständigen" + +msgid "chars ignored for nick completion" +msgstr "Zeichen, die bei der Nickvervollständigung ignoriert werden" + +msgid "alert user when a partial completion occurs" +msgstr "" + +msgid "" +"partially complete nicks (stop when many nicks found begin with same letters)" +msgstr "" + +msgid "" +"partially complete command names (stop when many commands found begin with " +"same letters)" +msgstr "" + +msgid "" +"partially complete command arguments (stop when many arguments found begin " +"with same prefix)" +msgstr "" + +msgid "display count for each partial completion in bar item" +msgstr "" + #, fuzzy msgid "maximum number of lines in history per buffer (0 = unlimited)" msgstr "maximale Anzahl an Befehlen im Verlauf (0: kein Limit)" @@ -2995,15 +3015,6 @@ msgstr "" msgid "automatically rejoin channels when kicked" msgstr "Channels nach Kick automatisch wieder betreten, falls möglich" -msgid "" -"comma separated list of notify levels for channels of this server (format: " -"#channel:1,..), a channel name '*' is reserved for server default notify " -"level" -msgstr "" -"durch Kommata getrennte Liste der Notify-Levels für die Channels auf diesem " -"Server (Format: #channel:1,...), der Channelname '*' ist für den Default-" -"Server-Notify-Level" - #, fuzzy, c-format msgid "%s%s: error creating server option \"%s\"" msgstr "%s nicht genügend Speicher für Infobar-Nachricht\n" @@ -4579,6 +4590,15 @@ msgstr "%s DCC: kann die 'nonblock'-Option für den Socket nicht festlegen\n" msgid "%s%s: timeout for \"%s\" with %s" msgstr "%s fehlende Argumente für die \"--dir\"-Option\n" +#~ msgid "" +#~ "comma separated list of notify levels for channels of this server " +#~ "(format: #channel:1,..), a channel name '*' is reserved for server " +#~ "default notify level" +#~ msgstr "" +#~ "durch Kommata getrennte Liste der Notify-Levels für die Channels auf " +#~ "diesem Server (Format: #channel:1,...), der Channelname '*' ist für den " +#~ "Default-Server-Notify-Level" + #, fuzzy #~ msgid "%sError: incorrect notify level (must be between %d and %d)" #~ msgstr "%s ungültige Notify-Ebene (muss zwischen %d und %d liegen)\n" diff --git a/po/es.po b/po/es.po index 73babcf78..2afe97cc4 100644 --- a/po/es.po +++ b/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-06-17 16:16+0200\n" +"POT-Creation-Date: 2008-06-18 16:02+0200\n" "PO-Revision-Date: 2007-09-19 12:09+0200\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -998,16 +998,6 @@ msgstr "" msgid "time format for \"time\" bar item" msgstr "fecha y hora para las conversaciones guardadas" -msgid "complete only with first nick found" -msgstr "completar únicamente con el primer nick encontrado" - -msgid "chars ignored for nick completion" -msgstr "caracteres ignorados para el completado del nombre de usuario" - -#, fuzzy -msgid "string inserted after nick completion" -msgstr "la cadena mostrada tras la finalización de los nombres de usuario" - #, fuzzy msgid "display nicklist (on buffers with nicklist enabled)" msgstr "mostrar ventana de usuarios (para las ventanas de canal)" @@ -1383,6 +1373,36 @@ msgstr "color para '+' al desplazar nicks" msgid "text color for nicklist separator" msgstr "color para el separador de alias" +#, fuzzy +msgid "string inserted after nick completion" +msgstr "la cadena mostrada tras la finalización de los nombres de usuario" + +msgid "complete only with first nick found" +msgstr "completar únicamente con el primer nick encontrado" + +msgid "chars ignored for nick completion" +msgstr "caracteres ignorados para el completado del nombre de usuario" + +msgid "alert user when a partial completion occurs" +msgstr "" + +msgid "" +"partially complete nicks (stop when many nicks found begin with same letters)" +msgstr "" + +msgid "" +"partially complete command names (stop when many commands found begin with " +"same letters)" +msgstr "" + +msgid "" +"partially complete command arguments (stop when many arguments found begin " +"with same prefix)" +msgstr "" + +msgid "display count for each partial completion in bar item" +msgstr "" + #, fuzzy msgid "maximum number of lines in history per buffer (0 = unlimited)" msgstr "" @@ -2989,15 +3009,6 @@ msgstr "" msgid "automatically rejoin channels when kicked" msgstr "unirse de nuevo automáticamente a los canales cuando sea expulsado" -#, fuzzy -msgid "" -"comma separated list of notify levels for channels of this server (format: " -"#channel:1,..), a channel name '*' is reserved for server default notify " -"level" -msgstr "" -"lista separada por comas de niveles de notificación para canales de este " -"servidor (formato: #canal:1,...)" - #, fuzzy, c-format msgid "%s%s: error creating server option \"%s\"" msgstr "" @@ -4588,6 +4599,15 @@ msgstr "%s no es posible crear el servidor\n" msgid "%s%s: timeout for \"%s\" with %s" msgstr "%s falta un argumento para la opción --dir\n" +#, fuzzy +#~ msgid "" +#~ "comma separated list of notify levels for channels of this server " +#~ "(format: #channel:1,..), a channel name '*' is reserved for server " +#~ "default notify level" +#~ msgstr "" +#~ "lista separada por comas de niveles de notificación para canales de este " +#~ "servidor (formato: #canal:1,...)" + #, fuzzy #~ msgid "%sError: incorrect notify level (must be between %d and %d)" #~ msgstr "%s nivel de notificación incorrecto (debe estar entre %d y %d)\n" diff --git a/po/fr.po b/po/fr.po index cc33f76fa..6a71a0928 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-06-17 16:16+0200\n" -"PO-Revision-Date: 2008-06-17 16:16+0200\n" +"POT-Creation-Date: 2008-06-18 16:02+0200\n" +"PO-Revision-Date: 2008-06-18 16:02+0200\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -1033,15 +1033,6 @@ msgstr "" msgid "time format for \"time\" bar item" msgstr "format de date/heure pour l'objet de barre \"time\"" -msgid "complete only with first nick found" -msgstr "compléter seulement avec le premier pseudo trouvé" - -msgid "chars ignored for nick completion" -msgstr "caractères à ignorer pour la complétion des pseudos" - -msgid "string inserted after nick completion" -msgstr "chaîne affichée après la complétion des pseudos" - msgid "display nicklist (on buffers with nicklist enabled)" msgstr "" "afficher la liste de pseudos (sur les tampons avec la liste de pseudos " @@ -1346,6 +1337,42 @@ msgstr "" msgid "text color for nicklist separator" msgstr "couleur du texte pour le séparateur de la liste des pseudos" +msgid "string inserted after nick completion" +msgstr "chaîne affichée après la complétion des pseudos" + +msgid "complete only with first nick found" +msgstr "compléter seulement avec le premier pseudo trouvé" + +msgid "chars ignored for nick completion" +msgstr "caractères à ignorer pour la complétion des pseudos" + +msgid "alert user when a partial completion occurs" +msgstr "alterte de l'utilisateur lorsqu'une complétion partielle survient" + +msgid "" +"partially complete nicks (stop when many nicks found begin with same letters)" +msgstr "" +"complète partiellement les pseudos (stoppe quand plusieurs pseudos trouvés " +"commencent par les mêmes lettres)" + +msgid "" +"partially complete command names (stop when many commands found begin with " +"same letters)" +msgstr "" +"complète partiellement les noms de commandes (stoppe quand plusieurs " +"commandes trouvées commencent par les mêmes lettres)" + +msgid "" +"partially complete command arguments (stop when many arguments found begin " +"with same prefix)" +msgstr "" +"complète partiellement les paramètres de commande (stoppe quand plusieurs " +"paramètres trouvés commencent par les mêmes lettres)" + +msgid "display count for each partial completion in bar item" +msgstr "" +"afficher le compteur pour chaque complétion partielle dans l'objet de barre" + msgid "maximum number of lines in history per buffer (0 = unlimited)" msgstr "nombre maximum de lignes dans l'historique (0 = sans limite)" @@ -2947,15 +2974,6 @@ msgstr "" msgid "automatically rejoin channels when kicked" msgstr "rejoindre automatiquement les canaux quand mis dehors" -msgid "" -"comma separated list of notify levels for channels of this server (format: " -"#channel:1,..), a channel name '*' is reserved for server default notify " -"level" -msgstr "" -"liste des niveaux de notifications (séparés par des virgules) pour les " -"canaux de ce serveur (format: #canal:1,..), un nom de canal '*' est réservé " -"pour la notification par défaut du serveur" - #, c-format msgid "%s%s: error creating server option \"%s\"" msgstr "%s%s: erreur de création de l'option serveur \"%s\"" @@ -4537,3 +4555,12 @@ msgstr "%s%s: impossible de positionner l'option \"nonblock\" pour la socket" #, c-format msgid "%s%s: timeout for \"%s\" with %s" msgstr "%s%s: délai d'attente dépassé pour \"%s\" avec %s" + +#~ msgid "" +#~ "comma separated list of notify levels for channels of this server " +#~ "(format: #channel:1,..), a channel name '*' is reserved for server " +#~ "default notify level" +#~ msgstr "" +#~ "liste des niveaux de notifications (séparés par des virgules) pour les " +#~ "canaux de ce serveur (format: #canal:1,..), un nom de canal '*' est " +#~ "réservé pour la notification par défaut du serveur" diff --git a/po/hu.po b/po/hu.po index ebbe04beb..50f77e175 100644 --- a/po/hu.po +++ b/po/hu.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-06-17 16:16+0200\n" +"POT-Creation-Date: 2008-06-18 16:02+0200\n" "PO-Revision-Date: 2007-10-10 18:07+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -1027,16 +1027,6 @@ msgstr "" msgid "time format for \"time\" bar item" msgstr "időbélyeg a információs pult idejéhez" -msgid "complete only with first nick found" -msgstr "kiegészítés az első adandó névvel" - -msgid "chars ignored for nick completion" -msgstr "névkiegészítéskor mellőzött karakterek" - -#, fuzzy -msgid "string inserted after nick completion" -msgstr "névkiegészítés után beszúrt szöveg" - #, fuzzy msgid "display nicklist (on buffers with nicklist enabled)" msgstr "névlista ablak mutatása (szobaablakban)" @@ -1406,6 +1396,36 @@ msgstr "a '+' jel színe névlista görgetésekor" msgid "text color for nicklist separator" msgstr "névelválasztó színe" +#, fuzzy +msgid "string inserted after nick completion" +msgstr "névkiegészítés után beszúrt szöveg" + +msgid "complete only with first nick found" +msgstr "kiegészítés az első adandó névvel" + +msgid "chars ignored for nick completion" +msgstr "névkiegészítéskor mellőzött karakterek" + +msgid "alert user when a partial completion occurs" +msgstr "" + +msgid "" +"partially complete nicks (stop when many nicks found begin with same letters)" +msgstr "" + +msgid "" +"partially complete command names (stop when many commands found begin with " +"same letters)" +msgstr "" + +msgid "" +"partially complete command arguments (stop when many arguments found begin " +"with same prefix)" +msgstr "" + +msgid "display count for each partial completion in bar item" +msgstr "" + #, fuzzy msgid "maximum number of lines in history per buffer (0 = unlimited)" msgstr "" @@ -3026,15 +3046,6 @@ msgstr "" msgid "automatically rejoin channels when kicked" msgstr "automatikus visszalépés a szobába kirúgáskor" -msgid "" -"comma separated list of notify levels for channels of this server (format: " -"#channel:1,..), a channel name '*' is reserved for server default notify " -"level" -msgstr "" -"vesszővel elválasztott emlékeztetési szintek ezen szerver szobáira (forma: " -"#szoba:1,...), a '*' szobanév a szerver alapértelmezett értesítési " -"szintjének van fenntartva" - #, fuzzy, c-format msgid "%s%s: error creating server option \"%s\"" msgstr "%s nincs elég memória az információs pult üzenethez\n" @@ -4595,6 +4606,15 @@ msgstr "%s DCC: nem sikerült 'nonblock' opciót beállítani a csatornán\n" msgid "%s%s: timeout for \"%s\" with %s" msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n" +#~ msgid "" +#~ "comma separated list of notify levels for channels of this server " +#~ "(format: #channel:1,..), a channel name '*' is reserved for server " +#~ "default notify level" +#~ msgstr "" +#~ "vesszővel elválasztott emlékeztetési szintek ezen szerver szobáira " +#~ "(forma: #szoba:1,...), a '*' szobanév a szerver alapértelmezett " +#~ "értesítési szintjének van fenntartva" + #, fuzzy #~ msgid "%sError: incorrect notify level (must be between %d and %d)" #~ msgstr "" diff --git a/po/ru.po b/po/ru.po index 6bd2e55b0..952856bfd 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-06-17 16:16+0200\n" +"POT-Creation-Date: 2008-06-18 16:02+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -1028,16 +1028,6 @@ msgstr "" msgid "time format for \"time\" bar item" msgstr "время в информационной строке" -msgid "complete only with first nick found" -msgstr "дополнять только первым найденным ником" - -msgid "chars ignored for nick completion" -msgstr "символы, игнорируемые при автодополнении ника" - -#, fuzzy -msgid "string inserted after nick completion" -msgstr "строка, вставляемая после автодополнения ника" - #, fuzzy msgid "display nicklist (on buffers with nicklist enabled)" msgstr "показывать список ников (в окнах каналов)" @@ -1409,6 +1399,36 @@ msgstr "цвет '+' при прокрутке ников" msgid "text color for nicklist separator" msgstr "цвет разделителя ников" +#, fuzzy +msgid "string inserted after nick completion" +msgstr "строка, вставляемая после автодополнения ника" + +msgid "complete only with first nick found" +msgstr "дополнять только первым найденным ником" + +msgid "chars ignored for nick completion" +msgstr "символы, игнорируемые при автодополнении ника" + +msgid "alert user when a partial completion occurs" +msgstr "" + +msgid "" +"partially complete nicks (stop when many nicks found begin with same letters)" +msgstr "" + +msgid "" +"partially complete command names (stop when many commands found begin with " +"same letters)" +msgstr "" + +msgid "" +"partially complete command arguments (stop when many arguments found begin " +"with same prefix)" +msgstr "" + +msgid "display count for each partial completion in bar item" +msgstr "" + #, fuzzy msgid "maximum number of lines in history per buffer (0 = unlimited)" msgstr "максимальное количество команд в истории (0 = не ограничено)" @@ -3020,15 +3040,6 @@ msgstr "" msgid "automatically rejoin channels when kicked" msgstr "автоматически перезаходить на каналы после кика" -msgid "" -"comma separated list of notify levels for channels of this server (format: " -"#channel:1,..), a channel name '*' is reserved for server default notify " -"level" -msgstr "" -"разделённый запятыми список уровней уведомления этого сервера (формат: " -"#канал:1,..), название канала '*' зарезервировано для уровня уведомления " -"сервера" - #, fuzzy, c-format msgid "%s%s: error creating server option \"%s\"" msgstr "%s недостаточно памяти для сообщения в строке информации\n" @@ -4578,6 +4589,15 @@ msgstr "%s DCC: не могу установить неблокирующий р msgid "%s%s: timeout for \"%s\" with %s" msgstr "%s нет аргумента для параметра \"%s\"\n" +#~ msgid "" +#~ "comma separated list of notify levels for channels of this server " +#~ "(format: #channel:1,..), a channel name '*' is reserved for server " +#~ "default notify level" +#~ msgstr "" +#~ "разделённый запятыми список уровней уведомления этого сервера (формат: " +#~ "#канал:1,..), название канала '*' зарезервировано для уровня уведомления " +#~ "сервера" + #, fuzzy #~ msgid "%sError: incorrect notify level (must be between %d and %d)" #~ msgstr "%s некорректный уровень уведомления (должен быть от %d до %d)\n" diff --git a/po/weechat.pot b/po/weechat.pot index 1c28fcce8..4734a1ce5 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-06-17 16:16+0200\n" +"POT-Creation-Date: 2008-06-18 16:02+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -849,15 +849,6 @@ msgstr "" msgid "time format for \"time\" bar item" msgstr "" -msgid "complete only with first nick found" -msgstr "" - -msgid "chars ignored for nick completion" -msgstr "" - -msgid "string inserted after nick completion" -msgstr "" - msgid "display nicklist (on buffers with nicklist enabled)" msgstr "" @@ -1136,6 +1127,35 @@ msgstr "" msgid "text color for nicklist separator" msgstr "" +msgid "string inserted after nick completion" +msgstr "" + +msgid "complete only with first nick found" +msgstr "" + +msgid "chars ignored for nick completion" +msgstr "" + +msgid "alert user when a partial completion occurs" +msgstr "" + +msgid "" +"partially complete nicks (stop when many nicks found begin with same letters)" +msgstr "" + +msgid "" +"partially complete command names (stop when many commands found begin with " +"same letters)" +msgstr "" + +msgid "" +"partially complete command arguments (stop when many arguments found begin " +"with same prefix)" +msgstr "" + +msgid "display count for each partial completion in bar item" +msgstr "" + msgid "maximum number of lines in history per buffer (0 = unlimited)" msgstr "" @@ -2506,12 +2526,6 @@ msgstr "" msgid "automatically rejoin channels when kicked" msgstr "" -msgid "" -"comma separated list of notify levels for channels of this server (format: " -"#channel:1,..), a channel name '*' is reserved for server default notify " -"level" -msgstr "" - #, c-format msgid "%s%s: error creating server option \"%s\"" msgstr "" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index def88fda2..b355994db 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1499,7 +1499,7 @@ command_plugin_list (const char *name, int full) hook_found = 1; gui_chat_printf (NULL, " %s", - HOOK_COMPLETION(ptr_hook, completion)); + HOOK_COMPLETION(ptr_hook, completion_item)); } } diff --git a/src/core/wee-config.c b/src/core/wee-config.c index afbd74278..263800c9c 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -85,9 +85,6 @@ struct t_config_option *config_look_infobar_seconds; struct t_config_option *config_look_infobar_time_format; struct t_config_option *config_look_input_format; struct t_config_option *config_look_item_time_format; -struct t_config_option *config_look_nick_complete_first; -struct t_config_option *config_look_nick_completion_ignore; -struct t_config_option *config_look_nick_completor; struct t_config_option *config_look_nicklist; struct t_config_option *config_look_nicklist_max_size; struct t_config_option *config_look_nicklist_min_size; @@ -167,6 +164,17 @@ struct t_config_option *config_color_nicklist_prefix5; struct t_config_option *config_color_nicklist_more; struct t_config_option *config_color_nicklist_separator; +/* config, completion section */ + +struct t_config_option *config_completion_nick_completor; +struct t_config_option *config_completion_nick_first_only; +struct t_config_option *config_completion_nick_ignore_chars; +struct t_config_option *config_completion_partial_completion_alert; +struct t_config_option *config_completion_partial_completion_nick; +struct t_config_option *config_completion_partial_completion_command; +struct t_config_option *config_completion_partial_completion_command_arg; +struct t_config_option *config_completion_partial_completion_count; + /* config, history section */ struct t_config_option *config_history_max_lines; @@ -885,21 +893,6 @@ config_weechat_init () "item_time_format", "string", N_("time format for \"time\" bar item"), NULL, 0, 0, "%H:%M", NULL, NULL, &config_change_item_time_format, NULL, NULL, NULL); - config_look_nick_complete_first = config_file_new_option ( - weechat_config_file, ptr_section, - "nick_complete_first", "boolean", - N_("complete only with first nick found"), - NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL); - config_look_nick_completion_ignore = config_file_new_option ( - weechat_config_file, ptr_section, - "nick_completion_ignore", "string", - N_("chars ignored for nick completion"), - NULL, 0, 0, "[]-^", NULL, NULL, NULL, NULL, NULL, NULL); - config_look_nick_completor = config_file_new_option ( - weechat_config_file, ptr_section, - "nick_completor", "string", - N_("string inserted after nick completion"), - NULL, 0, 0, ":", NULL, NULL, NULL, NULL, NULL, NULL); config_look_nicklist = config_file_new_option ( weechat_config_file, ptr_section, "nicklist", "boolean", @@ -1455,6 +1448,61 @@ config_weechat_init () NULL, GUI_COLOR_NICKLIST_SEPARATOR, 0, "blue", NULL, NULL, &config_change_color, NULL, NULL, NULL); + /* completion */ + ptr_section = config_file_new_section (weechat_config_file, "completion", + 0, 0, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL); + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + + config_completion_nick_completor = config_file_new_option ( + weechat_config_file, ptr_section, + "nick_completor", "string", + N_("string inserted after nick completion"), + NULL, 0, 0, ":", NULL, NULL, NULL, NULL, NULL, NULL); + config_completion_nick_first_only = config_file_new_option ( + weechat_config_file, ptr_section, + "nick_first_only", "boolean", + N_("complete only with first nick found"), + NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL); + config_completion_nick_ignore_chars = config_file_new_option ( + weechat_config_file, ptr_section, + "nick_ignore_chars", "string", + N_("chars ignored for nick completion"), + NULL, 0, 0, "[]-^", NULL, NULL, NULL, NULL, NULL, NULL); + config_completion_partial_completion_alert = config_file_new_option ( + weechat_config_file, ptr_section, + "partial_completion_alert", "boolean", + N_("alert user when a partial completion occurs"), + NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL); + config_completion_partial_completion_nick = config_file_new_option ( + weechat_config_file, ptr_section, + "partial_completion_nick", "boolean", + N_("partially complete nicks (stop when many nicks found begin with " + "same letters)"), + NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL); + config_completion_partial_completion_command = config_file_new_option ( + weechat_config_file, ptr_section, + "partial_completion_command", "boolean", + N_("partially complete command names (stop when many commands found " + "begin with same letters)"), + NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL); + config_completion_partial_completion_command_arg = config_file_new_option ( + weechat_config_file, ptr_section, + "partial_completion_command_arg", "boolean", + N_("partially complete command arguments (stop when many arguments " + "found begin with same prefix)"), + NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL); + config_completion_partial_completion_count = config_file_new_option ( + weechat_config_file, ptr_section, + "partial_completion_count", "boolean", + N_("display count for each partial completion in bar item"), + NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL); + /* history */ ptr_section = config_file_new_section (weechat_config_file, "history", 0, 0, diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 09d712b51..3be8ffbed 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -71,9 +71,6 @@ extern struct t_config_option *config_look_infobar_seconds; extern struct t_config_option *config_look_infobar_time_format; extern struct t_config_option *config_look_input_format; extern struct t_config_option *config_look_item_time_format; -extern struct t_config_option *config_look_nick_complete_first; -extern struct t_config_option *config_look_nick_completion_ignore; -extern struct t_config_option *config_look_nick_completor; extern struct t_config_option *config_look_nicklist; extern struct t_config_option *config_look_nicklist_max_size; extern struct t_config_option *config_look_nicklist_min_size; @@ -151,6 +148,15 @@ extern struct t_config_option *config_color_nicklist_prefix5; extern struct t_config_option *config_color_nicklist_more; extern struct t_config_option *config_color_nicklist_separator; +extern struct t_config_option *config_completion_nick_completor; +extern struct t_config_option *config_completion_nick_first_only; +extern struct t_config_option *config_completion_nick_ignore_chars; +extern struct t_config_option *config_completion_partial_completion_alert; +extern struct t_config_option *config_completion_partial_completion_nick; +extern struct t_config_option *config_completion_partial_completion_command; +extern struct t_config_option *config_completion_partial_completion_command_arg; +extern struct t_config_option *config_completion_partial_completion_count; + extern struct t_config_option *config_history_max_lines; extern struct t_config_option *config_history_max_commands; extern struct t_config_option *config_history_display_default; diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 98b853e9f..e8f659342 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -40,6 +40,7 @@ #include "wee-util.h" #include "../gui/gui-buffer.h" #include "../gui/gui-color.h" +#include "../gui/gui-completion.h" #include "../plugins/plugin.h" @@ -1121,13 +1122,13 @@ hook_config_exec (const char *option, const char *value) */ struct t_hook * -hook_completion (struct t_weechat_plugin *plugin, const char *completion, +hook_completion (struct t_weechat_plugin *plugin, const char *completion_item, t_hook_callback_completion *callback, void *callback_data) { struct t_hook *new_hook; struct t_hook_completion *new_hook_completion; - if (!completion || !completion[0] || strchr (completion, ' ')) + if (!completion_item || !completion_item[0] || strchr (completion_item, ' ')) return NULL; new_hook = malloc (sizeof (*new_hook)); @@ -1144,20 +1145,34 @@ hook_completion (struct t_weechat_plugin *plugin, const char *completion, new_hook->hook_data = new_hook_completion; new_hook_completion->callback = callback; - new_hook_completion->completion = strdup (completion); + new_hook_completion->completion_item = strdup (completion_item); hook_add_to_list (new_hook); return new_hook; } +/* + * hook_completion_list_add: add a word for a completion (called by plugins) + */ + +void +hook_completion_list_add (struct t_gui_completion *completion, + const char *word, int nick_completion, + const char *where) +{ + gui_completion_list_add (completion, word, nick_completion, where); +} + /* * hook_completion_exec: execute completion hook */ void -hook_completion_exec (struct t_weechat_plugin *plugin, const char *completion, - struct t_gui_buffer *buffer, struct t_weelist *list) +hook_completion_exec (struct t_weechat_plugin *plugin, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { struct t_hook *ptr_hook, *next_hook; @@ -1173,12 +1188,12 @@ hook_completion_exec (struct t_weechat_plugin *plugin, const char *completion, if (!ptr_hook->deleted && !ptr_hook->running - && (string_strcasecmp (HOOK_COMPLETION(ptr_hook, completion), - completion) == 0)) + && (string_strcasecmp (HOOK_COMPLETION(ptr_hook, completion_item), + completion_item) == 0)) { ptr_hook->running = 1; (void) (HOOK_COMPLETION(ptr_hook, callback)) - (ptr_hook->callback_data, completion, buffer, list); + (ptr_hook->callback_data, completion_item, buffer, completion); ptr_hook->running = 0; } @@ -1371,8 +1386,8 @@ unhook (struct t_hook *hook) free ((struct t_hook_config *)hook->hook_data); break; case HOOK_TYPE_COMPLETION: - if (HOOK_COMPLETION(hook, completion)) - free (HOOK_COMPLETION(hook, completion)); + if (HOOK_COMPLETION(hook, completion_item)) + free (HOOK_COMPLETION(hook, completion_item)); free ((struct t_hook_completion *)hook->hook_data); break; case HOOK_TYPE_MODIFIER: @@ -1558,7 +1573,7 @@ hook_print_log () { log_printf (" completion data:"); log_printf (" callback . . . . . . : 0x%x", HOOK_COMPLETION(ptr_hook, callback)); - log_printf (" completion . . . . . : '%s'", HOOK_COMPLETION(ptr_hook, completion)); + log_printf (" completion_item. . . : '%s'", HOOK_COMPLETION(ptr_hook, completion_item)); } break; case HOOK_TYPE_MODIFIER: diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index ab7e7fa4c..074ad97d5 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -25,6 +25,7 @@ #endif struct t_gui_buffer; +struct t_gui_completion; struct t_weelist; /* hook types */ @@ -168,14 +169,15 @@ struct t_hook_config /* (NULL = hook for all options) */ }; -typedef int (t_hook_callback_completion)(void *data, const char *completion, +typedef int (t_hook_callback_completion)(void *data, + const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list); + struct t_gui_completion *completion); struct t_hook_completion { t_hook_callback_completion *callback; /* completion callback */ - char *completion; /* name of completion */ + char *completion_item; /* name of completion */ }; typedef char *(t_hook_callback_modifier)(void *data, const char *modifier, @@ -250,13 +252,16 @@ extern struct t_hook *hook_config (struct t_weechat_plugin *, const char *option void *callback_data); extern void hook_config_exec (const char *option, const char *value); extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin, - const char *completion, + const char *completion_item, t_hook_callback_completion *callback, void *callback_data); +extern void hook_completion_list_add (struct t_gui_completion *completion, + const char *word, int nick_completion, + const char *where); extern void hook_completion_exec (struct t_weechat_plugin *plugin, - const char *completion, + const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list); + struct t_gui_completion *completion); extern struct t_hook *hook_modifier (struct t_weechat_plugin *plugin, const char *modifier, t_hook_callback_modifier *callback, diff --git a/src/core/wee-list.c b/src/core/wee-list.c index 7d1c80c36..a261cdbbc 100644 --- a/src/core/wee-list.c +++ b/src/core/wee-list.c @@ -156,6 +156,28 @@ weelist_add (struct t_weelist *weelist, const char *data, const char *where) return new_item; } +/* + * weelist_dup: duplicate a weelist + */ + +struct t_weelist * +weelist_dup (struct t_weelist *weelist) +{ + struct t_weelist *new_weelist; + struct t_weelist_item *ptr_item; + + new_weelist = weelist_new (); + if (new_weelist) + { + for (ptr_item = weelist->items; ptr_item; + ptr_item = ptr_item->next_item) + { + weelist_add (new_weelist, ptr_item->data, WEECHAT_LIST_POS_END); + } + } + return new_weelist; +} + /* * weelist_search: search data in a list (case sensitive) */ diff --git a/src/core/wee-list.h b/src/core/wee-list.h index 01deee6e3..054988982 100644 --- a/src/core/wee-list.h +++ b/src/core/wee-list.h @@ -37,6 +37,7 @@ struct t_weelist extern struct t_weelist *weelist_new (); extern struct t_weelist_item *weelist_add (struct t_weelist *weelist, const char *data, const char *where); +extern struct t_weelist *weelist_dup (struct t_weelist *weelist); extern struct t_weelist_item *weelist_search (struct t_weelist *weelist, const char *data); extern struct t_weelist_item *weelist_casesearch (struct t_weelist *weelist, diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c index 42ad87686..7ed66b57c 100644 --- a/src/gui/curses/gui-curses-keyboard.c +++ b/src/gui/curses/gui-curses-keyboard.c @@ -297,7 +297,7 @@ gui_keyboard_flush () gui_input_insert_string (gui_current_window->buffer, key_str, -1); if (gui_current_window->buffer->completion) - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 0); input_draw = 1; } diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index c4b21b8d4..6ee48ee1e 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -37,6 +37,7 @@ #include "gui-bar.h" #include "gui-buffer.h" #include "gui-color.h" +#include "gui-completion.h" #include "gui-filter.h" #include "gui-hotlist.h" #include "gui-window.h" @@ -46,7 +47,7 @@ struct t_gui_bar_item *gui_bar_items = NULL; /* first bar item */ struct t_gui_bar_item *last_gui_bar_item = NULL; /* last bar item */ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] = { "time", "buffer_count", "buffer_plugin", "buffer_name", "buffer_filter", - "nicklist_count", "scroll", "hotlist" + "nicklist_count", "scroll", "hotlist", "completion" }; struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL; struct t_hook *gui_bar_item_timer = NULL; @@ -550,6 +551,58 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item, return strdup (buf); } +/* + * gui_bar_item_default_completion: default item for (partial) completion + */ + +char * +gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + int max_width, int max_height) +{ + int length; + char *buf, number_str[16]; + struct t_gui_completion_partial *ptr_item; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) window; + (void) max_width; + (void) max_height; + + length = 1; + for (ptr_item = gui_completion_partial_list; ptr_item; + ptr_item = ptr_item->next_item) + { + length += strlen (ptr_item->word) + 32; + } + buf = malloc (length); + if (buf) + { + buf[0] = '\0'; + for (ptr_item = gui_completion_partial_list; ptr_item; + ptr_item = ptr_item->next_item) + { + strcat (buf, GUI_COLOR(GUI_COLOR_STATUS)); + strcat (buf, ptr_item->word); + if (ptr_item->count > 0) + { + strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS)); + strcat (buf, "("); + snprintf (number_str, sizeof (number_str), + "%d", ptr_item->count); + strcat (buf, number_str); + strcat (buf, ")"); + } + if (ptr_item->next_item) + strcat (buf, " "); + } + return buf; + } + return NULL; +} + /* * gui_bar_item_timer_cb: timer callback */ @@ -690,6 +743,13 @@ gui_bar_item_init () &gui_bar_item_default_hotlist, NULL); gui_bar_item_hook ("hotlist_changed", gui_bar_item_names[GUI_BAR_ITEM_HOTLIST]); + + /* completion (possible words when a partial completion occurs) */ + gui_bar_item_new (NULL, + gui_bar_item_names[GUI_BAR_ITEM_COMPLETION], + &gui_bar_item_default_completion, NULL); + gui_bar_item_hook ("partial_completion", + gui_bar_item_names[GUI_BAR_ITEM_COMPLETION]); } /* diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index 2777ebfa1..05686e7ea 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -30,6 +30,7 @@ enum t_gui_bar_item_weechat GUI_BAR_ITEM_NICKLIST_COUNT, GUI_BAR_ITEM_SCROLL, GUI_BAR_ITEM_HOTLIST, + GUI_BAR_ITEM_COMPLETION, /* number of bar items */ GUI_BAR_NUM_ITEMS, }; diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 939b3982e..87250f10d 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -47,6 +47,10 @@ #include "gui-nicklist.h" +struct t_gui_completion_partial *gui_completion_partial_list = NULL; +struct t_gui_completion_partial *last_gui_completion_partial = NULL; + + /* * gui_completion_init: init completion */ @@ -66,6 +70,7 @@ gui_completion_init (struct t_gui_completion *completion, completion->args = NULL; completion->direction = 0; completion->add_space = 1; + completion->force_partial_completion = 0; completion->completion_list = weelist_new (); @@ -116,16 +121,85 @@ gui_completion_free (struct t_gui_completion *completion) free (completion); } +/* + * gui_completion_partial_list_add: add an item to partial completions list + */ + +struct t_gui_completion_partial * +gui_completion_partial_list_add (const char *word, int count) +{ + struct t_gui_completion_partial *new_item; + + new_item = malloc (sizeof (*new_item)); + if (new_item) + { + new_item->word = strdup (word); + new_item->count = count; + + new_item->prev_item = last_gui_completion_partial; + if (gui_completion_partial_list) + last_gui_completion_partial->next_item = new_item; + else + gui_completion_partial_list = new_item; + last_gui_completion_partial = new_item; + new_item->next_item = NULL; + } + return new_item; +} + +/* + * gui_completion_partial_free: remove an item from partial completions list + */ + +void +gui_completion_partial_list_free (struct t_gui_completion_partial *item) +{ + /* remove partial completion item from list */ + if (item->prev_item) + item->prev_item->next_item = item->next_item; + if (item->next_item) + item->next_item->prev_item = item->prev_item; + if (gui_completion_partial_list == item) + gui_completion_partial_list = item->next_item; + if (last_gui_completion_partial == item) + last_gui_completion_partial = item->prev_item; + + /* free data */ + if (item->word) + free (item->word); + free (item); +} + +/* + * gui_completion_partial_free: remove partial completions list + */ + +void +gui_completion_partial_list_free_all () +{ + while (gui_completion_partial_list) + { + gui_completion_partial_list_free (gui_completion_partial_list); + } +} + /* * gui_completion_stop: stop completion (for example after 1 arg of command * with 1 arg) */ void -gui_completion_stop (struct t_gui_completion *completion) +gui_completion_stop (struct t_gui_completion *completion, + int remove_partial_completion_list) { completion->context = GUI_COMPLETION_NULL; completion->position = -1; + if (remove_partial_completion_list) + { + gui_completion_partial_list_free_all (); + hook_signal_send ("partial_completion", + WEECHAT_HOOK_SIGNAL_STRING, NULL); + } } /* @@ -163,7 +237,7 @@ gui_completion_is_only_alphanum (const char *string) { while (string[0]) { - if (strchr (CONFIG_STRING(config_look_nick_completion_ignore), + if (strchr (CONFIG_STRING(config_completion_nick_ignore_chars), string[0])) return 0; string++; @@ -184,7 +258,7 @@ gui_completion_strdup_alphanum (const char *string) pos = result; while (string[0]) { - if (!strchr (CONFIG_STRING(config_look_nick_completion_ignore), + if (!strchr (CONFIG_STRING(config_completion_nick_ignore_chars), string[0])) { pos[0] = string[0]; @@ -207,8 +281,8 @@ gui_completion_nickncmp (const char *base_word, const char *nick, int max) char *base_word2, *nick2; int return_cmp; - if (!CONFIG_STRING(config_look_nick_completion_ignore) - || !CONFIG_STRING(config_look_nick_completion_ignore)[0] + if (!CONFIG_STRING(config_completion_nick_ignore_chars) + || !CONFIG_STRING(config_completion_nick_ignore_chars)[0] || !base_word || !nick || !base_word[0] || !nick[0] || (!gui_completion_is_only_alphanum (base_word))) return string_strncasecmp (base_word, nick, max); @@ -477,7 +551,7 @@ gui_completion_list_add_nicks (struct t_gui_completion *completion) hook_completion_exec (completion->buffer->plugin, "nick", completion->buffer, - completion->completion_list); + completion); if (weelist_size (completion->completion_list) == count_before) { /* no plugin overrides nick completion, then we use default nick */ @@ -515,6 +589,8 @@ gui_completion_list_add_option (struct t_gui_completion *completion) int length; char *option_full_name; + completion->force_partial_completion = 1; + for (ptr_config = config_files; ptr_config; ptr_config = ptr_config->next_config) { @@ -811,7 +887,7 @@ gui_completion_custom (struct t_gui_completion *completion, hook_completion_exec (plugin, custom_completion, completion->buffer, - completion->completion_list); + completion); } /* @@ -840,8 +916,8 @@ gui_completion_build_list_template (struct t_gui_completion *completion, if (word_offset > 0) { word[word_offset] = '\0'; - weelist_add (completion->completion_list, - word, WEECHAT_LIST_POS_SORT); + gui_completion_list_add (completion, word, + 0, WEECHAT_LIST_POS_SORT); } word_offset = 0; break; @@ -852,7 +928,7 @@ gui_completion_build_list_template (struct t_gui_completion *completion, switch (pos[0]) { case '-': /* stop completion */ - gui_completion_stop (completion); + gui_completion_stop (completion, 1); free (word); return; break; @@ -951,7 +1027,7 @@ gui_completion_build_list (struct t_gui_completion *completion) if (!ptr_hook || !HOOK_COMMAND(ptr_hook, completion) || (strcmp (HOOK_COMMAND(ptr_hook, completion), "-") == 0)) { - gui_completion_stop (completion); + gui_completion_stop (completion, 1); return; } @@ -1000,8 +1076,8 @@ gui_completion_build_list (struct t_gui_completion *completion) */ void -gui_completion_find_context (struct t_gui_completion *completion, const char *data, - int size, int pos) +gui_completion_find_context (struct t_gui_completion *completion, + const char *data, int size, int pos) { int i, command, command_arg, pos_start, pos_end; @@ -1121,112 +1197,183 @@ gui_completion_find_context (struct t_gui_completion *completion, const char *da } /* - * gui_completion_command: complete a command + * gui_completion_common_prefix_size: find common prefix size in matching items + * (case is ignored) + * if utf_char is not null, only words + * beginning with this char are compared + * (all other words are ignored) + * for example with items: + * FlashCode, flashy, flashouille + * common prefix size is 5 ("flash") */ -void -gui_completion_command (struct t_gui_completion *completion) +int +gui_completion_common_prefix_size (struct t_weelist *list, + const char *utf_char) { - int length, word_found_seen, other_completion; - struct t_hook *ptr_hook; - struct t_weelist_item *ptr_item, *ptr_item2; + struct t_weelist_item *ptr_item; + char *ptr_first_item, *ptr_char, *next_char; - length = strlen (completion->base_word); - word_found_seen = 0; - other_completion = 0; - if (!completion->completion_list->items) - { - for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook; - ptr_hook = ptr_hook->next_hook) - { - if (!ptr_hook->deleted - && HOOK_COMMAND(ptr_hook, command) - && HOOK_COMMAND(ptr_hook, command)[0] - && (HOOK_COMMAND(ptr_hook, level) == 0)) - { - gui_completion_list_add (completion, - HOOK_COMMAND(ptr_hook, command), - 0, WEECHAT_LIST_POS_SORT); - } - } - } - if (completion->direction < 0) - ptr_item = completion->completion_list->last_item; - else - ptr_item = completion->completion_list->items; + ptr_first_item = list->items->data; + ptr_char = ptr_first_item; - while (ptr_item) + while (ptr_char && ptr_char[0]) { - if (string_strncasecmp (ptr_item->data, completion->base_word, length) == 0) - { - if ((!completion->word_found) || word_found_seen) - { - if (completion->word_found) - free (completion->word_found); - completion->word_found = strdup (ptr_item->data); - - if (completion->direction < 0) - ptr_item2 = ptr_item->prev_item; - else - ptr_item2 = ptr_item->next_item; - - while (ptr_item2) - { - if (string_strncasecmp (ptr_item2->data, - completion->base_word, length) == 0) - other_completion++; - - if (completion->direction < 0) - ptr_item2 = ptr_item2->prev_item; - else - ptr_item2 = ptr_item2->next_item; - } - - if (other_completion == 0) - completion->position = -1; - else - if (completion->position < 0) - completion->position = 0; - return; - } - other_completion++; - } - if (completion->word_found && - (string_strcasecmp (ptr_item->data, completion->word_found) == 0)) - word_found_seen = 1; + next_char = utf8_next_char (ptr_char); - if (completion->direction < 0) - ptr_item = ptr_item->prev_item; - else - ptr_item = ptr_item->next_item; - } - if (completion->word_found) - { - free (completion->word_found); - completion->word_found = NULL; - gui_completion_command (completion); + for (ptr_item = list->items->next_item; ptr_item; + ptr_item = ptr_item->next_item) + { + if (!utf_char + || (utf8_charcasecmp (utf_char, ptr_item->data) == 0)) + { + if ((ptr_item->data[ptr_char - ptr_first_item] == '\0') + || (utf8_charcasecmp (ptr_char, + ptr_item->data + (ptr_char - ptr_first_item)) != 0)) + { + return ptr_char - ptr_first_item; + } + } + } + + ptr_char = next_char; } + return ptr_char - ptr_first_item; } /* - * gui_completion_command_arg: complete a command argument + * gui_completion_partial_build_list: build list with possible completions + * when a partial completion occurs */ void -gui_completion_command_arg (struct t_gui_completion *completion, - int nick_completion) +gui_completion_partial_build_list (struct t_gui_completion *completion, + int common_prefix_size) { - int length, word_found_seen, other_completion; + int char_size, items_count; + char utf_char[16], *word; + struct t_weelist *weelist_temp, *weelist_words; + struct t_weelist_item *ptr_item, *next_item; + + gui_completion_partial_list_free_all (); + + if (!completion->completion_list || !completion->completion_list->items) + return; + + weelist_temp = weelist_new (); + if (!weelist_temp) + return; + + weelist_words = weelist_new (); + if (!weelist_words) + { + weelist_free (weelist_temp); + return; + } + + for (ptr_item = completion->completion_list->items; ptr_item; + ptr_item = ptr_item->next_item) + { + weelist_add (weelist_temp, ptr_item->data + common_prefix_size, + WEECHAT_LIST_POS_END); + } + + while (weelist_temp->items) + { + char_size = utf8_char_size (weelist_temp->items->data); + memcpy (utf_char, weelist_temp->items->data, char_size); + utf_char[char_size] = '\0'; + word = NULL; + common_prefix_size = gui_completion_common_prefix_size (weelist_temp, + utf_char); + if (common_prefix_size > 0) + { + word = string_strndup (weelist_temp->items->data, + common_prefix_size); + } + items_count = 0; + ptr_item = weelist_temp->items; + while (ptr_item) + { + next_item = ptr_item->next_item; + + if (utf8_charcasecmp (utf_char, ptr_item->data) == 0) + { + weelist_remove (weelist_temp, ptr_item); + items_count++; + } + + ptr_item = next_item; + } + if (word) + { + gui_completion_partial_list_add (word, + CONFIG_BOOLEAN(config_completion_partial_completion_count) ? + items_count : -1); + free (word); + } + } + + weelist_free (weelist_temp); +} + +/* + * gui_completion_complete: complete word using matching items + */ + +void +gui_completion_complete (struct t_gui_completion *completion, + int nick_completion) +{ + int length, word_found_seen, other_completion, partial_completion; + int common_prefix_size; struct t_weelist_item *ptr_item, *ptr_item2; length = strlen (completion->base_word); word_found_seen = 0; other_completion = 0; + + partial_completion = completion->force_partial_completion; + + if (!partial_completion) + { + if (nick_completion) + { + partial_completion = CONFIG_BOOLEAN(config_completion_partial_completion_nick); + } + else + { + if (completion->context == GUI_COMPLETION_COMMAND) + { + partial_completion = CONFIG_BOOLEAN(config_completion_partial_completion_command); + } + else + { + partial_completion = CONFIG_BOOLEAN(config_completion_partial_completion_command_arg); + } + } + } + + common_prefix_size = 0; + if (partial_completion + && completion->completion_list && completion->completion_list->items) + { + common_prefix_size = gui_completion_common_prefix_size (completion->completion_list, + NULL); + } + if (completion->direction < 0) ptr_item = completion->completion_list->last_item; else ptr_item = completion->completion_list->items; + if (partial_completion + && completion->word_found + && ((int)strlen (completion->word_found) >= common_prefix_size)) + { + return; + } + while (ptr_item) { if ((nick_completion @@ -1242,6 +1389,14 @@ gui_completion_command_arg (struct t_gui_completion *completion, free (completion->word_found); completion->word_found = strdup (ptr_item->data); + /* stop after first nick if user asked that */ + if (nick_completion + && CONFIG_BOOLEAN(config_completion_nick_first_only)) + { + gui_completion_stop (completion, 1); + return; + } + if (completion->direction < 0) ptr_item2 = ptr_item->prev_item; else @@ -1257,7 +1412,9 @@ gui_completion_command_arg (struct t_gui_completion *completion, && (string_strncasecmp (completion->base_word, ptr_item2->data, length) == 0))) + { other_completion++; + } if (completion->direction < 0) ptr_item2 = ptr_item2->prev_item; @@ -1270,92 +1427,32 @@ gui_completion_command_arg (struct t_gui_completion *completion, else if (completion->position < 0) completion->position = 0; - return; - } - other_completion++; - } - if (completion->word_found && - (string_strcasecmp (ptr_item->data, completion->word_found) == 0)) - word_found_seen = 1; - - if (completion->direction < 0) - ptr_item = ptr_item->prev_item; - else - ptr_item = ptr_item->next_item; - } - if (completion->word_found) - { - free (completion->word_found); - completion->word_found = NULL; - gui_completion_command_arg (completion, nick_completion); - } -} - -/* - * gui_completion_nick: complete a nick - */ - -void -gui_completion_nick (struct t_gui_completion *completion) -{ - int length, word_found_seen, other_completion; - struct t_weelist_item *ptr_item, *ptr_item2; - - if (!completion->completion_list->items) - gui_completion_list_add_nicks (completion); - - completion->context = GUI_COMPLETION_NICK; - - length = strlen (completion->base_word); - word_found_seen = 0; - other_completion = 0; - - if (completion->direction < 0) - ptr_item = completion->completion_list->last_item; - else - ptr_item = completion->completion_list->items; - - while (ptr_item) - { - if (gui_completion_nickncmp (completion->base_word, ptr_item->data, - length) == 0) - { - if ((!completion->word_found) || word_found_seen) - { - if (completion->word_found) - free (completion->word_found); - completion->word_found = strdup (ptr_item->data); - if (CONFIG_BOOLEAN(config_look_nick_complete_first)) + + /* stop after common prefix, if asked by user */ + if (partial_completion + && (((int)strlen (completion->word_found) >= common_prefix_size)) + && (other_completion > 0)) { + completion->word_found[common_prefix_size] = '\0'; + completion->add_space = 0; completion->position = -1; + string_tolower (completion->word_found); + + /* alert user of partial completion */ + if (CONFIG_BOOLEAN(config_completion_partial_completion_alert)) + printf ("\a"); + + /* send "partial_completion" signal, to display possible + completions in bar item */ + gui_completion_partial_build_list (completion, + common_prefix_size); + hook_signal_send ("partial_completion", + WEECHAT_HOOK_SIGNAL_STRING, NULL); return; } - if (completion->direction < 0) - ptr_item2 = ptr_item->prev_item; - else - ptr_item2 = ptr_item->next_item; + gui_completion_partial_list_free_all (); - while (ptr_item2) - { - if (gui_completion_nickncmp (completion->base_word, - ptr_item2->data, - length) == 0) - other_completion++; - - if (completion->direction < 0) - ptr_item2 = ptr_item2->prev_item; - else - ptr_item2 = ptr_item2->next_item; - } - - if (other_completion == 0) - completion->position = -1; - else - { - if (completion->position < 0) - completion->position = 0; - } return; } other_completion++; @@ -1369,14 +1466,61 @@ gui_completion_nick (struct t_gui_completion *completion) else ptr_item = ptr_item->next_item; } - if (completion->word_found) + + /* if we was on last completion in list, then recomplete, starting from + first matching item */ + if (completion->word_found && (completion->position >= 0)) { free (completion->word_found); completion->word_found = NULL; - gui_completion_nick (completion); + gui_completion_complete (completion, nick_completion); } } +/* + * gui_completion_command: complete a command + */ + +void +gui_completion_command (struct t_gui_completion *completion) +{ + struct t_hook *ptr_hook; + + if (!completion->completion_list->items) + { + for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook; + ptr_hook = ptr_hook->next_hook) + { + if (!ptr_hook->deleted + && HOOK_COMMAND(ptr_hook, command) + && HOOK_COMMAND(ptr_hook, command)[0] + && (HOOK_COMMAND(ptr_hook, level) == 0)) + { + gui_completion_list_add (completion, + HOOK_COMMAND(ptr_hook, command), + 0, WEECHAT_LIST_POS_SORT); + } + } + } + + gui_completion_complete (completion, 0); +} + +/* + * gui_completion_nick: complete a nick + */ + +void +gui_completion_nick (struct t_gui_completion *completion) +{ + if (!completion->completion_list->items) + gui_completion_list_add_nicks (completion); + + completion->context = GUI_COMPLETION_NICK; + + gui_completion_complete (completion, 1); +} + /* * gui_completion_auto: auto complete: nick, filename or channel */ @@ -1390,7 +1534,7 @@ gui_completion_auto (struct t_gui_completion *completion) { if (!completion->completion_list->items) gui_completion_list_add_filename (completion); - gui_completion_command_arg (completion, 0); + gui_completion_complete (completion, 0); return; } @@ -1438,7 +1582,7 @@ gui_completion_search (struct t_gui_completion *completion, int direction, break; case GUI_COMPLETION_COMMAND_ARG: if (completion->completion_list->items) - gui_completion_command_arg (completion, completion->arg_is_nick); + gui_completion_complete (completion, completion->arg_is_nick); else { completion->context = GUI_COMPLETION_AUTO; @@ -1478,22 +1622,23 @@ void gui_completion_print_log (struct t_gui_completion *completion) { log_printf ("[completion (addr:0x%x)]", completion); - log_printf (" buffer . . . . . . . . : 0x%x", completion->buffer); - log_printf (" context. . . . . . . . : %d", completion->context); - log_printf (" base_command . . . . . : '%s'", completion->base_command); - log_printf (" base_command_arg . . . : %d", completion->base_command_arg); - log_printf (" arg_is_nick. . . . . . : %d", completion->arg_is_nick); - log_printf (" base_word. . . . . . . : '%s'", completion->base_word); - log_printf (" base_word_pos. . . . . : %d", completion->base_word_pos); - log_printf (" position . . . . . . . : %d", completion->position); - log_printf (" args . . . . . . . . . : '%s'", completion->args); - log_printf (" direction. . . . . . . : %d", completion->direction); - log_printf (" add_space. . . . . . . : %d", completion->add_space); - log_printf (" completion_list. . . . : 0x%x", completion->completion_list); - log_printf (" word_found . . . . . . : '%s'", completion->word_found); - log_printf (" position_replace . . . : %d", completion->position_replace); - log_printf (" diff_size. . . . . . . : %d", completion->diff_size); - log_printf (" diff_length. . . . . . : %d", completion->diff_length); + log_printf (" buffer. . . . . . . . . : 0x%x", completion->buffer); + log_printf (" context . . . . . . . . : %d", completion->context); + log_printf (" base_command. . . . . . : '%s'", completion->base_command); + log_printf (" base_command_arg. . . . : %d", completion->base_command_arg); + log_printf (" arg_is_nick . . . . . . : %d", completion->arg_is_nick); + log_printf (" base_word . . . . . . . : '%s'", completion->base_word); + log_printf (" base_word_pos . . . . . : %d", completion->base_word_pos); + log_printf (" position. . . . . . . . : %d", completion->position); + log_printf (" args. . . . . . . . . . : '%s'", completion->args); + log_printf (" direction . . . . . . . : %d", completion->direction); + log_printf (" add_space . . . . . . . : %d", completion->add_space); + log_printf (" force_partial_completion: %d", completion->force_partial_completion); + log_printf (" completion_list . . . . : 0x%x", completion->completion_list); + log_printf (" word_found. . . . . . . : '%s'", completion->word_found); + log_printf (" position_replace. . . . : %d", completion->position_replace); + log_printf (" diff_size . . . . . . . : %d", completion->diff_size); + log_printf (" diff_length . . . . . . : %d", completion->diff_length); if (completion->completion_list) { log_printf (""); diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h index 4f86220ee..e5ef472ca 100644 --- a/src/gui/gui-completion.h +++ b/src/gui/gui-completion.h @@ -29,33 +29,49 @@ struct t_gui_completion { /* completion context */ - struct t_gui_buffer *buffer;/* buffer where completion was asked */ - int context; /* context: null, nick, command, cmd arg */ - char *base_command; /* command with arg to complete (can be NULL)*/ - int base_command_arg; /* # arg to complete (if context is cmd arg) */ - int arg_is_nick; /* argument is nick */ - char *base_word; /* word to complete (when Tab was pressed) */ - int base_word_pos; /* beggining of base word */ - int position; /* position where Tab was pressed */ - char *args; /* command line args (including base word) */ - int direction; /* +1 = search next word, -1 = previous word */ - int add_space; /* add space after completion? */ + struct t_gui_buffer *buffer; /* buffer where completion was asked */ + int context; /* context: null, nick, command, cmd arg */ + char *base_command; /* cmd with arg to complete (can be NULL) */ + int base_command_arg; /* # arg to complete (if context=cmd arg) */ + int arg_is_nick; /* argument is nick */ + char *base_word; /* word to complete (when Tab was pressed) */ + int base_word_pos; /* beggining of base word */ + int position; /* position where Tab was pressed */ + char *args; /* command line args (including base word) */ + int direction; /* +1=search next word, -1=previous word */ + int add_space; /* add space after completion? */ + int force_partial_completion; /* force partial completion? */ /* for command argument completion */ struct t_weelist *completion_list; /* data list for completion */ /* completion found */ - char *word_found; /* word found (to replace base word) */ - int position_replace; /* position where word has to be replaced */ - int diff_size; /* size difference (< 0 = char(s) deleted) */ - int diff_length; /* length difference (<= diff_size) */ + char *word_found; /* word found (to replace base word) */ + int position_replace; /* position where word has to be replaced */ + int diff_size; /* size difference (< 0 = char(s) deleted) */ + int diff_length; /* length difference (<= diff_size) */ }; +struct t_gui_completion_partial +{ + char *word; /* (partial) word matching completion */ + int count; /* number of matching items with this word */ + struct t_gui_completion_partial *prev_item; + struct t_gui_completion_partial *next_item; +}; + +extern struct t_gui_completion_partial *gui_completion_partial_list; + /* completion functions */ extern void gui_completion_init (struct t_gui_completion *completion, struct t_gui_buffer *buffer); extern void gui_completion_free (struct t_gui_completion *completion); +extern void gui_completion_stop (struct t_gui_completion *completion, + int remove_partial_completion_list); +extern void gui_completion_list_add (struct t_gui_completion *completion, + const char *word, + int nick_completion, const char *where); extern void gui_completion_search (struct t_gui_completion *completion, int direction, const char *data, int size, int pos); diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 32afa3c3f..0a00f3b21 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -285,7 +285,7 @@ gui_input_clipboard_paste () { gui_input_insert_string (gui_current_window->buffer, gui_input_clipboard, -1); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); gui_input_draw (gui_current_window->buffer, 0); } } @@ -319,7 +319,7 @@ gui_input_return () gui_current_window->buffer->input_buffer_length = 0; gui_current_window->buffer->input_buffer_pos = 0; gui_current_window->buffer->input_buffer_1st_display = 0; - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); gui_current_window->buffer->ptr_history = NULL; gui_input_optimize_size (gui_current_window->buffer); gui_input_draw (gui_current_window->buffer, 0); @@ -403,25 +403,28 @@ gui_input_complete (struct t_gui_buffer *buffer) if ((buffer->completion->base_word_pos == 0) && (buffer->completion->context == GUI_COMPLETION_NICK)) { - if (strncmp (utf8_add_offset (buffer->input_buffer, - buffer->input_buffer_pos), - CONFIG_STRING(config_look_nick_completor), - strlen (CONFIG_STRING(config_look_nick_completor))) != 0) - gui_input_insert_string (buffer, - CONFIG_STRING(config_look_nick_completor), - buffer->input_buffer_pos); - else - buffer->input_buffer_pos += utf8_strlen (CONFIG_STRING(config_look_nick_completor)); - if (buffer->completion->position >= 0) - buffer->completion->position += strlen (CONFIG_STRING(config_look_nick_completor)); - if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer, - buffer->input_buffer_pos)] != ' ') - gui_input_insert_string (buffer, " ", - buffer->input_buffer_pos); - else - buffer->input_buffer_pos++; - if (buffer->completion->position >= 0) - buffer->completion->position++; + if (buffer->completion->add_space) + { + if (strncmp (utf8_add_offset (buffer->input_buffer, + buffer->input_buffer_pos), + CONFIG_STRING(config_completion_nick_completor), + strlen (CONFIG_STRING(config_completion_nick_completor))) != 0) + gui_input_insert_string (buffer, + CONFIG_STRING(config_completion_nick_completor), + buffer->input_buffer_pos); + else + buffer->input_buffer_pos += utf8_strlen (CONFIG_STRING(config_completion_nick_completor)); + if (buffer->completion->position >= 0) + buffer->completion->position += strlen (CONFIG_STRING(config_completion_nick_completor)); + if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer, + buffer->input_buffer_pos)] != ' ') + gui_input_insert_string (buffer, " ", + buffer->input_buffer_pos); + else + buffer->input_buffer_pos++; + if (buffer->completion->position >= 0) + buffer->completion->position++; + } } else { @@ -531,7 +534,7 @@ gui_input_delete_previous_char () gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0'; gui_input_optimize_size (gui_current_window->buffer); gui_input_draw (gui_current_window->buffer, 0); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); } } } @@ -563,7 +566,7 @@ gui_input_delete_next_char () gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0'; gui_input_optimize_size (gui_current_window->buffer); gui_input_draw (gui_current_window->buffer, 0); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); } } } @@ -623,7 +626,7 @@ gui_input_delete_previous_word () gui_current_window->buffer->input_buffer_pos -= length_deleted; gui_input_optimize_size (gui_current_window->buffer); gui_input_draw (gui_current_window->buffer, 0); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); } } } @@ -663,7 +666,7 @@ gui_input_delete_next_word () gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0'; gui_input_optimize_size (gui_current_window->buffer); gui_input_draw (gui_current_window->buffer, 0); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); } } @@ -700,7 +703,7 @@ gui_input_delete_beginning_of_line () gui_current_window->buffer->input_buffer_pos = 0; gui_input_optimize_size (gui_current_window->buffer); gui_input_draw (gui_current_window->buffer, 0); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); } } } @@ -733,7 +736,7 @@ gui_input_delete_end_of_line (const char *args) gui_current_window->buffer->input_buffer_length = utf8_strlen (gui_current_window->buffer->input_buffer); gui_input_optimize_size (gui_current_window->buffer); gui_input_draw (gui_current_window->buffer, 0); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); } } @@ -752,7 +755,7 @@ gui_input_delete_line () gui_current_window->buffer->input_buffer_length = 0; gui_current_window->buffer->input_buffer_pos = 0; gui_input_optimize_size (gui_current_window->buffer); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); gui_input_draw (gui_current_window->buffer, 0); } } @@ -799,7 +802,7 @@ gui_input_transpose_chars () gui_current_window->buffer->input_buffer_pos++; gui_input_draw (gui_current_window->buffer, 0); - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); } } } diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index d48e69101..35541f3d6 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -114,7 +114,7 @@ gui_keyboard_grab_end () { gui_input_insert_string (gui_current_window->buffer, expanded_key, -1); if (gui_current_window->buffer->completion) - gui_current_window->buffer->completion->position = -1; + gui_completion_stop (gui_current_window->buffer->completion, 1); gui_input_draw (gui_current_window->buffer, 0); } free (expanded_key); diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c index 3bfd3094d..2625eea96 100644 --- a/src/plugins/alias/alias.c +++ b/src/plugins/alias/alias.c @@ -805,20 +805,22 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc, */ int -alias_completion_cb (void *data, const char *completion, - struct t_gui_buffer *buffer, struct t_weelist *list) +alias_completion_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { struct t_alias *ptr_alias; /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias) { - weechat_list_add (list, ptr_alias->name, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_alias->name, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index 776d183d2..2e1554093 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -38,17 +38,21 @@ */ int -irc_completion_server_cb (void *data, const char *completion, - struct t_gui_buffer *buffer, struct t_weelist *list) +irc_completion_server_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { IRC_GET_SERVER(buffer); /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; if (ptr_server) - weechat_list_add (list, ptr_server->name, WEECHAT_LIST_POS_SORT); + { + weechat_hook_completion_list_add (completion, ptr_server->name, + 0, WEECHAT_LIST_POS_SORT); + } return WEECHAT_RC_OK; } @@ -59,9 +63,9 @@ irc_completion_server_cb (void *data, const char *completion, */ int -irc_completion_server_nicks_cb (void *data, const char *completion, +irc_completion_server_nicks_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { struct t_irc_channel *ptr_channel2; struct t_irc_nick *ptr_nick; @@ -70,7 +74,7 @@ irc_completion_server_nicks_cb (void *data, const char *completion, /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; if (ptr_server) @@ -83,14 +87,15 @@ irc_completion_server_nicks_cb (void *data, const char *completion, for (ptr_nick = ptr_channel2->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - weechat_list_add (list, ptr_nick->name, - WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_nick->name, + 1, WEECHAT_LIST_POS_SORT); } } } /* add self nick at the end */ - weechat_list_add (list, ptr_server->nick, WEECHAT_LIST_POS_END); + weechat_hook_completion_list_add (completion, ptr_server->nick, + 1, WEECHAT_LIST_POS_END); } return WEECHAT_RC_OK; @@ -101,20 +106,22 @@ irc_completion_server_nicks_cb (void *data, const char *completion, */ int -irc_completion_servers_cb (void *data, const char *completion, - struct t_gui_buffer *buffer, struct t_weelist *list) +irc_completion_servers_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { struct t_irc_server *ptr_server; /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { - weechat_list_add (list, ptr_server->name, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_server->name, + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; @@ -125,17 +132,21 @@ irc_completion_servers_cb (void *data, const char *completion, */ int -irc_completion_channel_cb (void *data, const char *completion, - struct t_gui_buffer *buffer, struct t_weelist *list) +irc_completion_channel_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { IRC_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; if (ptr_channel) - weechat_list_add (list, ptr_channel->name, WEECHAT_LIST_POS_SORT); + { + weechat_hook_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_SORT); + } return WEECHAT_RC_OK; } @@ -146,9 +157,9 @@ irc_completion_channel_cb (void *data, const char *completion, */ int -irc_completion_channel_nicks_cb (void *data, const char *completion, +irc_completion_channel_nicks_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { struct t_irc_nick *ptr_nick; char *nick; @@ -158,7 +169,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion, /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; if (ptr_channel) { @@ -167,8 +178,8 @@ irc_completion_channel_nicks_cb (void *data, const char *completion, for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - weechat_list_add (list, ptr_nick->name, - WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_nick->name, + 1, WEECHAT_LIST_POS_SORT); } /* add nicks speaking recently on this channel */ @@ -180,18 +191,20 @@ irc_completion_channel_nicks_cb (void *data, const char *completion, nick = weechat_list_string (weechat_list_get (ptr_channel->nicks_speaking, i)); if (nick && irc_nick_search (ptr_channel, nick)) { - weechat_list_add (list, nick, - WEECHAT_LIST_POS_BEGINNING); + weechat_hook_completion_list_add (completion, nick, + 1, WEECHAT_LIST_POS_BEGINNING); } } } /* add self nick at the end */ - weechat_list_add (list, ptr_server->nick, WEECHAT_LIST_POS_END); + weechat_hook_completion_list_add (completion, ptr_server->nick, + 1, WEECHAT_LIST_POS_END); } if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) { - weechat_list_add (list, ptr_channel->name, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_SORT); } ptr_channel->nick_completion_reset = 0; @@ -206,9 +219,9 @@ irc_completion_channel_nicks_cb (void *data, const char *completion, */ int -irc_completion_channel_nicks_hosts_cb (void *data, const char *completion, +irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { struct t_irc_nick *ptr_nick; char *buf; @@ -218,7 +231,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion, /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; if (ptr_channel) { @@ -227,7 +240,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion, for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - weechat_list_add (list, ptr_nick->name, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_nick->name, + 1, WEECHAT_LIST_POS_SORT); if (ptr_nick->host) { length = strlen (ptr_nick->name) + 1 + @@ -237,7 +251,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion, { snprintf (buf, length, "%s!%s", ptr_nick->name, ptr_nick->host); - weechat_list_add (list, buf, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, buf, + 0, WEECHAT_LIST_POS_SORT); free (buf); } } @@ -245,8 +260,8 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion, } if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) { - weechat_list_add (list, ptr_channel->name, - WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_SORT); } } @@ -259,9 +274,9 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion, */ int -irc_completion_channel_topic_cb (void *data, const char *completion, +irc_completion_channel_topic_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { char *topic_color; @@ -269,14 +284,14 @@ irc_completion_channel_topic_cb (void *data, const char *completion, /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0]) { topic_color = irc_color_decode_for_user_entry (ptr_channel->topic); - weechat_list_add (list, - (topic_color) ? topic_color : ptr_channel->topic, - WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, + (topic_color) ? topic_color : ptr_channel->topic, + 0, WEECHAT_LIST_POS_SORT); if (topic_color) free (topic_color); } @@ -289,15 +304,16 @@ irc_completion_channel_topic_cb (void *data, const char *completion, */ int -irc_completion_channels_cb (void *data, const char *completion, - struct t_gui_buffer *buffer, struct t_weelist *list) +irc_completion_channels_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; for (ptr_server = irc_servers; ptr_server; @@ -306,7 +322,8 @@ irc_completion_channels_cb (void *data, const char *completion, for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - weechat_list_add (list, ptr_channel->name, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_channel->name, + 0, WEECHAT_LIST_POS_SORT); } } @@ -318,20 +335,21 @@ irc_completion_channels_cb (void *data, const char *completion, */ int -irc_completion_msg_part_cb (void *data, const char *completion, - struct t_gui_buffer *buffer, struct t_weelist *list) +irc_completion_msg_part_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; if (weechat_config_string (irc_config_network_default_msg_part) && weechat_config_string (irc_config_network_default_msg_part)[0]) { - weechat_list_add (list, - weechat_config_string (irc_config_network_default_msg_part), - WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, + weechat_config_string (irc_config_network_default_msg_part), + 0, WEECHAT_LIST_POS_SORT); } return WEECHAT_RC_OK; diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 676907ff6..70a52f70a 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -380,6 +380,7 @@ plugin_load (const char *filename) new_plugin->hook_signal_send = &hook_signal_send; new_plugin->hook_config = &hook_config; new_plugin->hook_completion = &hook_completion; + new_plugin->hook_completion_list_add = &hook_completion_list_add; new_plugin->hook_modifier = &hook_modifier; new_plugin->hook_modifier_exec = &hook_modifier_exec; new_plugin->unhook = &unhook; diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 92c8b2e31..ad1ddae0b 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -2882,9 +2882,9 @@ weechat_lua_api_hook_config (lua_State *L) */ int -weechat_lua_api_hook_completion_cb (void *data, const char *completion, +weechat_lua_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { struct t_script_callback *script_callback; char *lua_argv[4]; @@ -2892,9 +2892,9 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion, script_callback = (struct t_script_callback *)data; - lua_argv[0] = (char *)completion; + lua_argv[0] = (char *)completion_item; lua_argv[1] = script_ptr2str (buffer); - lua_argv[2] = script_ptr2str (list); + lua_argv[2] = script_ptr2str (completion); lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -2960,6 +2960,51 @@ weechat_lua_api_hook_completion (lua_State *L) LUA_RETURN_STRING_FREE(result); } +/* + * weechat_lua_api_hook_completion_list_add: add a word to list for a completion + */ + +static int +weechat_lua_api_hook_completion_list_add (lua_State *L) +{ + const char *completion, *word, *where; + int n, nick_completion; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + LUA_RETURN_ERROR; + } + + completion = NULL; + word = NULL; + nick_completion = 0; + where = NULL; + + n = lua_gettop (lua_current_interpreter); + + if (n < 4) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + LUA_RETURN_ERROR; + } + + completion = lua_tostring (lua_current_interpreter, -4); + word = lua_tostring (lua_current_interpreter, -3); + nick_completion = lua_tonumber (lua_current_interpreter, -2); + where = lua_tostring (lua_current_interpreter, -1); + + weechat_hook_completion_list_add (script_str2ptr (completion), + word, + nick_completion, + where); + + LUA_RETURN_OK; +} + /* * weechat_lua_api_hook_modifier_cb: callback for modifier hooked */ @@ -4999,6 +5044,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = { { "hook_signal_send", &weechat_lua_api_hook_signal_send }, { "hook_config", &weechat_lua_api_hook_config }, { "hook_completion", &weechat_lua_api_hook_completion }, + { "hook_completion_list_add", &weechat_lua_api_hook_completion_list_add }, { "hook_modifier", &weechat_lua_api_hook_modifier }, { "hook_modifier_exec", &weechat_lua_api_hook_modifier_exec }, { "unhook", &weechat_lua_api_unhook }, diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 6759dbe87..ef48749c3 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -413,16 +413,16 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer, */ int -weechat_lua_completion_cb (void *data, const char *completion, +weechat_lua_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; - script_completion (weechat_lua_plugin, list, lua_scripts); + script_completion (weechat_lua_plugin, completion, lua_scripts); return WEECHAT_RC_OK; } diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 586f0fbbd..0ae18e0c7 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -2398,9 +2398,9 @@ static XS (XS_weechat_hook_config) */ int -weechat_perl_api_hook_completion_cb (void *data, const char *completion, +weechat_perl_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { struct t_script_callback *script_callback; char *perl_argv[4]; @@ -2408,9 +2408,9 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion, script_callback = (struct t_script_callback *)data; - perl_argv[0] = (char *)completion; + perl_argv[0] = (char *)completion_item; perl_argv[1] = script_ptr2str (buffer); - perl_argv[2] = script_ptr2str (list); + perl_argv[2] = script_ptr2str (completion); perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -2468,6 +2468,42 @@ static XS (XS_weechat_hook_completion) PERL_RETURN_STRING_FREE(result); } +/* + * weechat::hook_completion_list_add: add a word to list for a completion + */ + +static XS (XS_weechat_hook_completion_list_add) +{ + char *completion, *word, *where; + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + PERL_RETURN_ERROR; + } + + if (items < 4) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + PERL_RETURN_ERROR; + } + + completion = SvPV (ST (0), PL_na); + word = SvPV (ST (1), PL_na); + where = SvPV (ST (3), PL_na); + + weechat_hook_completion_list_add (script_str2ptr (completion), + word, + SvIV (ST (2)), /* nick_completion */ + where); + + PERL_RETURN_OK; +} + /* * weechat_perl_api_hook_modifier_cb: callback for modifier hooked */ @@ -3922,6 +3958,7 @@ weechat_perl_api_init (pTHX) newXS ("weechat::hook_signal_send", XS_weechat_hook_signal_send, "weechat"); newXS ("weechat::hook_config", XS_weechat_hook_config, "weechat"); newXS ("weechat::hook_completion", XS_weechat_hook_completion, "weechat"); + newXS ("weechat::hook_completion_list_add", XS_weechat_hook_completion_list_add, "weechat"); newXS ("weechat::hook_modifier", XS_weechat_hook_modifier, "weechat"); newXS ("weechat::hook_modifier_exec", XS_weechat_hook_modifier_exec, "weechat"); newXS ("weechat::unhook", XS_weechat_unhook, "weechat"); diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index f76cf337e..6f426cd70 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -554,16 +554,16 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer, */ int -weechat_perl_completion_cb (void *data, const char *completion, +weechat_perl_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; - script_completion (weechat_perl_plugin, list, perl_scripts); + script_completion (weechat_perl_plugin, completion, perl_scripts); return WEECHAT_RC_OK; } diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 605c8d219..7420e1e74 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -2552,9 +2552,9 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args) */ int -weechat_python_api_hook_completion_cb (void *data, const char *completion, +weechat_python_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { struct t_script_callback *script_callback; char *python_argv[4]; @@ -2562,9 +2562,9 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion, script_callback = (struct t_script_callback *)data; - python_argv[0] = (char *)completion; + python_argv[0] = (char *)completion_item; python_argv[1] = script_ptr2str (buffer); - python_argv[2] = script_ptr2str (list); + python_argv[2] = script_ptr2str (completion); python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -2624,6 +2624,45 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args) PYTHON_RETURN_STRING_FREE(result); } +/* + * weechat_python_api_hook_completion_list_add: add a word to list for a completion + */ + +static PyObject * +weechat_python_api_hook_completion_list_add (PyObject *self, PyObject *args) +{ + char *completion, *word, *where; + int nick_completion; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + PYTHON_RETURN_ERROR; + } + + completion = NULL; + word = NULL; + nick_completion = 0; + where = NULL; + + if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion, + &where)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + PYTHON_RETURN_ERROR; + } + + weechat_hook_completion_list_add (script_str2ptr (completion), + word, + nick_completion, + where); + + PYTHON_RETURN_OK; +} + /* * weechat_python_api_hook_modifier_cb: callback for modifier hooked */ @@ -4169,6 +4208,7 @@ PyMethodDef weechat_python_funcs[] = { "hook_signal_send", &weechat_python_api_hook_signal_send, METH_VARARGS, "" }, { "hook_config", &weechat_python_api_hook_config, METH_VARARGS, "" }, { "hook_completion", &weechat_python_api_hook_completion, METH_VARARGS, "" }, + { "hook_completion_list_add", &weechat_python_api_hook_completion_list_add, METH_VARARGS, "" }, { "hook_modifier", &weechat_python_api_hook_modifier, METH_VARARGS, "" }, { "hook_modifier_exec", &weechat_python_api_hook_modifier_exec, METH_VARARGS, "" }, { "unhook", &weechat_python_api_unhook, METH_VARARGS, "" }, diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 784df538e..9755e9532 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -605,16 +605,16 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer, */ int -weechat_python_completion_cb (void *data, const char *completion, +weechat_python_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; - script_completion (weechat_python_plugin, list, python_scripts); + script_completion (weechat_python_plugin, completion, python_scripts); return WEECHAT_RC_OK; } diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index b0f91fcd6..b63a0f59a 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -2939,9 +2939,9 @@ weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function) */ int -weechat_ruby_api_hook_completion_cb (void *data, const char *completion, +weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { struct t_script_callback *script_callback; char *ruby_argv[4]; @@ -2949,9 +2949,9 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion, script_callback = (struct t_script_callback *)data; - ruby_argv[0] = (char *)completion; + ruby_argv[0] = (char *)completion_item; ruby_argv[1] = script_ptr2str (buffer); - ruby_argv[2] = script_ptr2str (list); + ruby_argv[2] = script_ptr2str (completion); ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -3018,6 +3018,57 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion, RUBY_RETURN_STRING_FREE(result); } +/* + * weechat_ruby_api_hook_completion_list_add: add a word to list for a completion + */ + +static VALUE +weechat_ruby_api_hook_completion_list_add (VALUE class, VALUE completion, + VALUE word, VALUE nick_completion, + VALUE where) +{ + char *c_completion, *c_word, *c_where; + int c_nick_completion; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + RUBY_RETURN_ERROR; + } + + c_completion = NULL; + c_word = NULL; + c_nick_completion = 0; + c_where = NULL; + + if (NIL_P (completion) || NIL_P (word) || NIL_P (nick_completion) + || NIL_P (where)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + RUBY_RETURN_ERROR; + } + + Check_Type (completion, T_STRING); + Check_Type (word, T_STRING); + Check_Type (nick_completion, T_FIXNUM); + Check_Type (where, T_STRING); + + c_completion = STR2CSTR (completion); + c_word = STR2CSTR (word); + c_nick_completion = FIX2INT (nick_completion); + c_where = STR2CSTR (where); + + weechat_hook_completion_list_add (script_str2ptr (c_completion), + c_word, + c_nick_completion, + c_where); + + RUBY_RETURN_OK; +} + /* * weechat_ruby_api_hook_modifier_cb: callback for modifier hooked */ @@ -4800,6 +4851,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "hook_signal_send", &weechat_ruby_api_hook_signal_send, 3); rb_define_module_function (ruby_mWeechat, "hook_config", &weechat_ruby_api_hook_config, 2); rb_define_module_function (ruby_mWeechat, "hook_completion", &weechat_ruby_api_hook_completion, 2); + rb_define_module_function (ruby_mWeechat, "hook_completion_list_add", &weechat_ruby_api_hook_completion_list_add, 4); rb_define_module_function (ruby_mWeechat, "hook_modifier", &weechat_ruby_api_hook_modifier, 2); rb_define_module_function (ruby_mWeechat, "hook_modifier_exec", &weechat_ruby_api_hook_modifier_exec, 3); rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1); diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 1b2e4ed3f..612fbe736 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -589,16 +589,16 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer, */ int -weechat_ruby_completion_cb (void *data, const char *completion, +weechat_ruby_completion_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list) + struct t_gui_completion *completion) { /* make C compiler happy */ (void) data; - (void) completion; + (void) completion_item; (void) buffer; - script_completion (weechat_ruby_plugin, list, ruby_scripts); + script_completion (weechat_ruby_plugin, completion, ruby_scripts); return WEECHAT_RC_OK; } diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index 55f877f78..a00f48d66 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -832,9 +832,10 @@ struct t_hook * script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *completion, - int (*callback)(void *data, const char *completion, + int (*callback)(void *data, + const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list), + struct t_gui_completion *completion), const char *function) { struct t_script_callback *new_script_callback; diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index f9bc3dc2c..9a8270775 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -142,9 +142,9 @@ extern struct t_hook *script_api_hook_completion (struct t_weechat_plugin *weech struct t_plugin_script *script, const char *completion, int (*callback)(void *data, - const char *completion, + const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list), + struct t_gui_completion *completion), const char *function); extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index 869d95e55..cd4522061 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -84,9 +84,9 @@ script_init (struct t_weechat_plugin *weechat_plugin, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol), - int (*callback_completion)(void *data, const char *completion, + int (*callback_completion)(void *data, const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list), + struct t_gui_completion *completion), int (*callback_signal_debug_dump)(void *data, const char *signal, const char *type_data, void *signal_data), @@ -525,7 +525,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin, void script_completion (struct t_weechat_plugin *weechat_plugin, - struct t_weelist *list, + struct t_gui_completion *completion, struct t_plugin_script *scripts) { struct t_plugin_script *ptr_script; @@ -533,7 +533,8 @@ script_completion (struct t_weechat_plugin *weechat_plugin, for (ptr_script = scripts; ptr_script; ptr_script = ptr_script->next_script) { - weechat_list_add (list, ptr_script->name, WEECHAT_LIST_POS_SORT); + weechat_hook_completion_list_add (completion, ptr_script->name, + 0, WEECHAT_LIST_POS_SORT); } } diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h index 0ff89b541..c35bedda2 100644 --- a/src/plugins/scripts/script.h +++ b/src/plugins/scripts/script.h @@ -61,9 +61,10 @@ extern void script_init (struct t_weechat_plugin *weechat_plugin, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol), - int (*callback_completion)(void *data, const char *completion, + int (*callback_completion)(void *data, + const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list), + struct t_gui_completion *completion), int (*callback_signal_debug_dump)(void *data, const char *signal, const char *type_data, @@ -94,7 +95,7 @@ extern void script_remove (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script **scripts, struct t_plugin_script *script); extern void script_completion (struct t_weechat_plugin *weechat_plugin, - struct t_weelist *list, + struct t_gui_completion *completion, struct t_plugin_script *scripts); extern void script_display_list (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *scripts, diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 7188e1ff0..8ed79cf65 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -27,6 +27,7 @@ struct t_gui_window; struct t_gui_buffer; struct t_gui_bar; struct t_gui_bar_item; +struct t_gui_completion; struct t_weelist; /* macros for defining plugin infos */ @@ -349,12 +350,15 @@ struct t_weechat_plugin const char *value), void *callback_data); struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin, - const char *completion, + const char *completion_item, int (*callback)(void *data, - const char *completion, + const char *completion_item, struct t_gui_buffer *buffer, - struct t_weelist *list), + struct t_gui_completion *completion), void *callback_data); + void (*hook_completion_list_add) (struct t_gui_completion *completion, + const char *word, int nick_completion, + const char *where); struct t_hook *(*hook_modifier) (struct t_weechat_plugin *plugin, const char *modifier, char *(*callback)(void *data, @@ -781,6 +785,11 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); #define weechat_hook_completion(__completion, __callback, __data) \ weechat_plugin->hook_completion(weechat_plugin, __completion, \ __callback, __data) +#define weechat_hook_completion_list_add(__completion, __word, \ + __nick_completion, __where) \ + weechat_plugin->hook_completion_list_add(__completion, __word, \ + __nick_completion, \ + __where) #define weechat_hook_modifier(__modifier, __callback, __data) \ weechat_plugin->hook_modifier(weechat_plugin, __modifier, \ __callback, __data)