core: add reverse of string for screen in evaluation of expressions with "revscr:"
This commit is contained in:
parent
9535f4a70b
commit
8fc8f728d4
@ -21,6 +21,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
New features::
|
||||
|
||||
* core: add file weechat.desktop
|
||||
* core: add reverse of string for screen in evaluation of expressions with "revscr:"
|
||||
* core: add length of string (number of chars and on screen) in evaluation of expressions with "length:xxx" and "lengthscr:xxx"
|
||||
* core: add calculation of expression in evaluation of expressions with "calc:xxx" (issue #997)
|
||||
* core: add optional default path (evaluated) in completion "filename"
|
||||
|
@ -266,68 +266,68 @@ infolists: zeigt Information über die Infolists an
|
||||
/eval [-n|-s] <expression>
|
||||
[-n] -c <expression1> <operator> <expression2>
|
||||
|
||||
-n: gibt das Ergebnis aus, ohne dass dieses in den Buffer gesendet wird (debug Modus)
|
||||
-s: teilt Ausdrücke, bevor sie evaluiert werden (mehrere Befehle können durch Semikolon getrennt werden)
|
||||
-c: Auswertung als Bedingung: nutzt Operatoren und runde Klammern, Rückgabewert als Boolean-Wert ("0" oder "1")
|
||||
expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten); mehrere Befehle werden durch ein Semikolon voneinander getrennt
|
||||
operator: ein logischer oder vergleichender Operand:
|
||||
- logische Operanden:
|
||||
&& boolean "und"
|
||||
|| boolean "oder"
|
||||
- vergleichende Operanden:
|
||||
== gleich
|
||||
!= ungleich
|
||||
<= kleiner oder gleich
|
||||
< kleiner
|
||||
>= größer oder gleich
|
||||
> größer
|
||||
=~ stimmt mit regulärem POSIX Ausdruck überein
|
||||
!~ stimmt NICHT mit regulärem POSIX Ausdruck überein
|
||||
=* stimmt mit Maske überein (Platzhalter "*" ist erlaubt)
|
||||
!* stimmt mit Maske NICHT überein (Platzhalter "*" ist erlaubt)
|
||||
-n: display result without sending it to buffer (debug mode)
|
||||
-s: split expression before evaluating it (many commands can be separated by semicolons)
|
||||
-c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1")
|
||||
expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons
|
||||
operator: a logical or comparison operator:
|
||||
- logical operators:
|
||||
&& boolean "and"
|
||||
|| boolean "or"
|
||||
- comparison operators:
|
||||
== equal
|
||||
!= not equal
|
||||
<= less or equal
|
||||
< less
|
||||
>= greater or equal
|
||||
> greater
|
||||
=~ is matching POSIX extended regex
|
||||
!~ is NOT matching POSIX extended regex
|
||||
=* is matching mask (wildcard "*" is allowed)
|
||||
!* is NOT matching mask (wildcard "*" is allowed)
|
||||
|
||||
Ein Ausdruck gilt als "wahr" sofern das Ergebnis weder NULL, nicht leer und von "0" abweichend ist.
|
||||
Für einen Vergleich werden Fließkommazahlen genutzt, insofern es sich bei beiden Ausdrücken um gültige Zahlen handelt, folgende Formate werden unterstützt:
|
||||
- Integer (Beispiele: 5, -7)
|
||||
- Fließkommazahl (Beispiele: 5.2, -7.5, 2.83e-2)
|
||||
- hexadezimale Zahl (Beispiele: 0xA3, -0xA3)
|
||||
Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel:
|
||||
An expression is considered as "true" if it is not NULL, not empty, and different from "0".
|
||||
The comparison is made using floating point numbers if the two expressions are valid numbers, with one of the following formats:
|
||||
- integer (examples: 5, -7)
|
||||
- floating point number (examples: 5.2, -7.5, 2.83e-2)
|
||||
- hexadecimal number (examples: 0xA3, -0xA3)
|
||||
To force a string comparison, you can add double quotes around each expression, for example:
|
||||
50 > 100 ==> 0
|
||||
"50" > "100" ==> 1
|
||||
|
||||
Einige Variablen werden im Ausdruck mittels der Formatierung ${variable} ersetzt. Mögliche Variablen sind, nach Reihenfolge ihrer Priorität:
|
||||
1. eine evaluierte Teilzeichenkette (Format: "eval:xxx")
|
||||
2. eine Zeichenkette mit Escapesequenzen (Format: "esc:xxx" oder "\xxx")
|
||||
3. Zeichen, die in einer Zeichenkette nicht dargestellt werden sollen (Format: "hide:Zeichen,Zeichenkette")
|
||||
4. eine Zeichenkette mit einer maximalen Anzahl an Zeichen (Format: "cut:+Max,Suffix,Zeichenkette")
|
||||
oder maximale Anzahl an Zeichen die auf dem Bildschirm angezeigt werden sollen (Format: "cutscr:Max,Suffix,Zeichenkette oder "cutscr:+Max,Suffix,Zeichenkette")
|
||||
5. eine Zeichenkette umkehren (Format: "rev:xxx")
|
||||
6. eine Zeichenkette wiederholen (Format: "repeat:Anzahl,Zeichenkette")
|
||||
7. Länge einer Zeichenkette (Format: "length:xxx" oder "lengthscr:xxx")
|
||||
8. eine Farbe (Format: "color:xxx", siehe "Anleitung für API Erweiterung", Funktion "color")
|
||||
9. ein Modifizierer (Format: "info:Name,Argumente", Argumente sind optional)
|
||||
10. eine Info (Format: "Info:Name,Argumente", Argumente sind optional)
|
||||
11. aktuelles Datum/Uhrzeit (Format: "date" oder "date:format")
|
||||
12. eine Umgebungsvariable (Format: "env:XXX")
|
||||
13. ein Dreifachoperand (Format: "if:Bedingung?Wert_falls_wahr:Wert_falls_unwahr")
|
||||
14. Ergebnis eines Ausdrucks mit Klammern und Operatoren + - * / // % ** (Format: "calc:xxx")
|
||||
15. eine Option (Format: "file.section.option")
|
||||
16. eine lokale Variable eines Buffers
|
||||
17. ein(e) hdata - Name/Variable (der Wert wird automatisch in eine Zeichenkette konvertiert), standardmäßig wird für "window" und "buffer" das aktuelle Fenster/Buffer verwendet.
|
||||
Das Format für hdata kann wie folgt aufgebaut sein:
|
||||
hdata.var1.var2...: startet mit hdata (der Pointer muss bekannt sein) und fragt eine Variable nach der anderen ab (weitere hdata können folgen)
|
||||
hdata[list].var1.var2...: startet hdata mittels einer Liste, zum Beispiel:
|
||||
${buffer[gui_buffers].full_name}: der vollständige Name des ersten Buffers, in der verknüpften Liste aller Buffer
|
||||
${plugin[weechat_plugins].name}: Name der ersten Erweiterung, in der verknüpften Liste aller Erweiterungen
|
||||
hdata[pointer].var1.var2...: startet hdata mittels einem Pointer, zum Beispiel:
|
||||
${buffer[0x1234abcd].full_name}: vollständiger Name eines Buffers und des dazugehörigen Pointers (kann in triggern benutzt werden)
|
||||
Die vorhandenen Namen für hdata und Variablen sind in der "Anleitung für API Erweiterung", Bereich "weechat_hdata_get". beschrieben
|
||||
Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority:
|
||||
1. an evaluated sub-string (format: "eval:xxx")
|
||||
2. a string with escaped chars (format: "esc:xxx" or "\xxx")
|
||||
3. a string with chars to hide (format: "hide:char,string")
|
||||
4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string")
|
||||
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string")
|
||||
5. a reversed string (format: "rev:xxx" or "revscr:xxx")
|
||||
6. a repeated string (format: "repeat:count,string")
|
||||
7. length of a string (format: "length:xxx" or "lengthscr:xxx")
|
||||
8. a color (format: "color:xxx", see "Plugin API reference", function "color")
|
||||
9. a modifier (format: "modifier:name,data,string")
|
||||
10. an info (format: "info:name,arguments", arguments are optional)
|
||||
11. current date/time (format: "date" or "date:format")
|
||||
12. an environment variable (format: "env:XXX")
|
||||
13. a ternary operator (format: "if:condition?value_if_true:value_if_false")
|
||||
14. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx")
|
||||
15. an option (format: "file.section.option")
|
||||
16. a local variable in buffer
|
||||
17. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer.
|
||||
Format for hdata can be one of following:
|
||||
hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed)
|
||||
hdata[list].var1.var2...: start with a hdata using a list, for example:
|
||||
${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
|
||||
${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins
|
||||
hdata[pointer].var1.var2...: start with a hdata using a pointer, for example:
|
||||
${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers)
|
||||
For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
|
||||
|
||||
Beispiele (einfache Zeichenketten):
|
||||
Examples (simple strings):
|
||||
/eval -n ${info:version} ==> 0.4.3
|
||||
/eval -n ${env:HOME} ==> /home/user
|
||||
/eval -n ${weechat.look.scroll_amount} ==> 3
|
||||
/eval -n ${sec.data.freenode_password} ==> geheim
|
||||
/eval -n ${sec.data.freenode_password} ==> secret
|
||||
/eval -n ${window} ==> 0x2549aa0
|
||||
/eval -n ${window.buffer} ==> 0x2549320
|
||||
/eval -n ${window.buffer.full_name} ==> core.weechat
|
||||
@ -343,16 +343,16 @@ Beispiele (einfache Zeichenketten):
|
||||
/eval -n ${length:test} ==> 4
|
||||
/eval -n ${calc:(5+2)*3} ==> 21
|
||||
|
||||
Beispiele (Bedingungen):
|
||||
/eval -n -c ${window.buffer.number} > 2 ==> 0
|
||||
/eval -n -c ${window.win_width} > 100 ==> 1
|
||||
/eval -n -c (8 > 12) || (5 > 2) ==> 1
|
||||
/eval -n -c (8 > 12) && (5 > 2) ==> 0
|
||||
/eval -n -c abcd =~ ^ABC ==> 1
|
||||
/eval -n -c abcd =~ (?-i)^ABC ==> 0
|
||||
/eval -n -c abcd =~ (?-i)^abc ==> 1
|
||||
/eval -n -c abcd !~ abc ==> 0
|
||||
/eval -n -c abcd =* a*d ==> 1
|
||||
Examples (conditions):
|
||||
/eval -n -c ${window.buffer.number} > 2 ==> 0
|
||||
/eval -n -c ${window.win_width} > 100 ==> 1
|
||||
/eval -n -c (8 > 12) || (5 > 2) ==> 1
|
||||
/eval -n -c (8 > 12) && (5 > 2) ==> 0
|
||||
/eval -n -c abcd =~ ^ABC ==> 1
|
||||
/eval -n -c abcd =~ (?-i)^ABC ==> 0
|
||||
/eval -n -c abcd =~ (?-i)^abc ==> 1
|
||||
/eval -n -c abcd !~ abc ==> 0
|
||||
/eval -n -c abcd =* a*d ==> 1
|
||||
----
|
||||
|
||||
[[command_weechat_filter]]
|
||||
|
@ -301,7 +301,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl
|
||||
3. a string with chars to hide (format: "hide:char,string")
|
||||
4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string")
|
||||
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string")
|
||||
5. a reversed string (format: "rev:xxx")
|
||||
5. a reversed string (format: "rev:xxx" or "revscr:xxx")
|
||||
6. a repeated string (format: "repeat:count,string")
|
||||
7. length of a string (format: "length:xxx" or "lengthscr:xxx")
|
||||
8. a color (format: "color:xxx", see "Plugin API reference", function "color")
|
||||
|
@ -2464,9 +2464,20 @@ expanded to last):
|
||||
|
||||
| `+${rev:xxx}+` +
|
||||
_(WeeChat ≥ 2.2)_ |
|
||||
Reversed string. |
|
||||
`+${rev:Hello, world!}+` |
|
||||
`+!dlrow ,olleH+`
|
||||
Reversed string (color codes are reversed, so the string should not contain
|
||||
color codes). |
|
||||
`+${rev:Hello, world!}+` +
|
||||
`+${rev:Hello, ${color:red}world!}+` |
|
||||
`+!dlrow ,olleH+` +
|
||||
`+!dlrow30F ,olleH+` (no color, the color code is reversed)
|
||||
|
||||
| `+${revscr:xxx}+` +
|
||||
_(WeeChat ≥ 2.7)_ |
|
||||
Reversed string for screen, color codes are not reversed. |
|
||||
`+${revscr:Hello, world!}+` +
|
||||
`+${revscr:Hello, ${color:red}world!}+` |
|
||||
`+!dlrow ,olleH+` +
|
||||
`+!dlrow ,olleH+` (`pass:[ ,olleH]` in red)
|
||||
|
||||
| `+${repeat:count,string}+` +
|
||||
_(WeeChat ≥ 2.3)_ |
|
||||
|
@ -301,7 +301,7 @@ Des variables sont remplacées dans l'expression, en utilisant le format ${varia
|
||||
3. une chaîne avec des caractères à cacher (format : "hide:caractère,chaîne")
|
||||
4. une chaîne avec un maximum de caractères (format : "cut:max,suffixe,chaîne" ou "cut:+max,suffixe,chaîne")
|
||||
ou un maximum de caractères affichés à l'écran (format : "cutscr:max,suffixe,chaîne" ou "cutscr:+max,suffixe,chaîne")
|
||||
5. une chaîne inversée (format : "rev:xxx")
|
||||
5. une chaîne inversée (format : "rev:xxx" ou "revscr:xxx")
|
||||
6. une chaîne répétée (format : "repeat:nombre,chaîne")
|
||||
7. longueur d'une chaîne (format : "length:xxx" ou "lengthscr:xxx")
|
||||
8. une couleur (format : "color:xxx", voir la "Référence API extension", fonction "color")
|
||||
|
@ -2511,9 +2511,20 @@ première étendue à la dernière) :
|
||||
|
||||
| `+${rev:xxx}+` +
|
||||
_(WeeChat ≥ 2.2)_ |
|
||||
Chaîne inversée. |
|
||||
`+${rev:Bonjour !}+` |
|
||||
`+! ruojnoB+`
|
||||
Chaîne inversée (les codes couleurs sont inversés, donc la chaîne ne devrait
|
||||
pas contenir de codes couleurs). |
|
||||
`+${rev:Bonjour, le monde !}+` +
|
||||
`+${rev:Bonjour, ${color:red}le monde !}+` |
|
||||
`+! ednom el ,ruojnoB+` +
|
||||
`+! ednom el30F ,ruojnoB+` (pas de couleur, le code couleur est inversé)
|
||||
|
||||
| `+${revscr:xxx}+` +
|
||||
_(WeeChat ≥ 2.7)_ |
|
||||
Chaîne inversée pour l'écran : les codes couleurs ne sont pas inversés. |
|
||||
`+${revscr:Bonjour, le monde !}+` +
|
||||
`+${revscr:Bonjour, ${color:red}le monde !}+` |
|
||||
`+! ednom el ,ruojnoB+` +
|
||||
`+! ednom el ,ruojnoB+` (`pass:[ ,ruojnoB]` en rouge)
|
||||
|
||||
| `+${repeat:nombre,chaîne}+` +
|
||||
_(WeeChat ≥ 2.3)_ |
|
||||
|
@ -301,7 +301,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl
|
||||
3. a string with chars to hide (format: "hide:char,string")
|
||||
4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string")
|
||||
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string")
|
||||
5. a reversed string (format: "rev:xxx")
|
||||
5. a reversed string (format: "rev:xxx" or "revscr:xxx")
|
||||
6. a repeated string (format: "repeat:count,string")
|
||||
7. length of a string (format: "length:xxx" or "lengthscr:xxx")
|
||||
8. a color (format: "color:xxx", see "Plugin API reference", function "color")
|
||||
|
@ -2572,9 +2572,20 @@ expanded to last):
|
||||
|
||||
| `+${rev:xxx}+` +
|
||||
_(WeeChat ≥ 2.2)_ |
|
||||
Reversed string. |
|
||||
`+${rev:Hello, world!}+` |
|
||||
`+!dlrow ,olleH+`
|
||||
Reversed string (color codes are reversed, so the string should not contain
|
||||
color codes). |
|
||||
`+${rev:Hello, world!}+` +
|
||||
`+${rev:Hello, ${color:red}world!}+` |
|
||||
`+!dlrow ,olleH+` +
|
||||
`+!dlrow30F ,olleH+` (no color, the color code is reversed)
|
||||
|
||||
| `+${revscr:xxx}+` +
|
||||
_(WeeChat ≥ 2.7)_ |
|
||||
Reversed string for screen, color codes are not reversed. |
|
||||
`+${revscr:Hello, world!}+` +
|
||||
`+${revscr:Hello, ${color:red}world!}+` |
|
||||
`+!dlrow ,olleH+` +
|
||||
`+!dlrow ,olleH+` (`pass:[ ,olleH]` in red)
|
||||
|
||||
| `+${repeat:count,string}+` +
|
||||
_(WeeChat ≥ 2.3)_ |
|
||||
|
@ -301,7 +301,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl
|
||||
3. a string with chars to hide (format: "hide:char,string")
|
||||
4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string")
|
||||
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string")
|
||||
5. a reversed string (format: "rev:xxx")
|
||||
5. a reversed string (format: "rev:xxx" or "revscr:xxx")
|
||||
6. a repeated string (format: "repeat:count,string")
|
||||
7. length of a string (format: "length:xxx" or "lengthscr:xxx")
|
||||
8. a color (format: "color:xxx", see "Plugin API reference", function "color")
|
||||
|
@ -2473,11 +2473,24 @@ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, optio
|
||||
`+thi…+` +
|
||||
`+こ>>+`
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| `+${rev:xxx}+` +
|
||||
_(WeeChat バージョン 2.2 以上で利用可)_ |
|
||||
文字順を反転させた文字列。|
|
||||
`+${rev:Hello, world!}+` |
|
||||
`+!dlrow ,olleH+`
|
||||
Reversed string (color codes are reversed, so the string should not contain
|
||||
color codes). |
|
||||
`+${rev:Hello, world!}+` +
|
||||
`+${rev:Hello, ${color:red}world!}+` |
|
||||
`+!dlrow ,olleH+` +
|
||||
`+!dlrow30F ,olleH+` (no color, the color code is reversed)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| `+${revscr:xxx}+` +
|
||||
_(WeeChat バージョン 2.7 以上で利用可)_ |
|
||||
Reversed string for screen, color codes are not reversed. |
|
||||
`+${revscr:Hello, world!}+` +
|
||||
`+${revscr:Hello, ${color:red}world!}+` |
|
||||
`+!dlrow ,olleH+` +
|
||||
`+!dlrow ,olleH+` (`pass:[ ,olleH]` in red)
|
||||
|
||||
| `+${repeat:count,string}+` +
|
||||
_(WeeChat バージョン 2.3 以上で利用可)_ |
|
||||
@ -2487,7 +2500,7 @@ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, optio
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| `+${length:xxx}+` +
|
||||
_(WeeChat ≥ 2.7)_ |
|
||||
_(WeeChat バージョン 2.7 以上で利用可)_ |
|
||||
Length of string (number of UTF-8 chars), color codes are ignored. |
|
||||
`+${length:test}+` +
|
||||
`+${length:こんにちは世界}+` |
|
||||
@ -2496,7 +2509,7 @@ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, optio
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| `+${lengthscr:xxx}+` +
|
||||
_(WeeChat ≥ 2.7)_ |
|
||||
_(WeeChat バージョン 2.7 以上で利用可)_ |
|
||||
Length of string displayed on screen, color codes are ignored. |
|
||||
`+${lengthscr:test}+` +
|
||||
`+${lengthscr:こんにちは世界}+` |
|
||||
|
@ -301,7 +301,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl
|
||||
3. a string with chars to hide (format: "hide:char,string")
|
||||
4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string")
|
||||
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string")
|
||||
5. a reversed string (format: "rev:xxx")
|
||||
5. a reversed string (format: "rev:xxx" or "revscr:xxx")
|
||||
6. a repeated string (format: "repeat:count,string")
|
||||
7. length of a string (format: "length:xxx" or "lengthscr:xxx")
|
||||
8. a color (format: "color:xxx", see "Plugin API reference", function "color")
|
||||
|
4
po/cs.po
4
po/cs.po
@ -21,7 +21,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
|
||||
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1570,7 +1570,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
5
po/de.po
5
po/de.po
@ -24,7 +24,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-10-11 22:39+0200\n"
|
||||
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
|
||||
"Language-Team: German <kde-i18n-de@kde.org>\n"
|
||||
@ -1661,6 +1661,7 @@ msgstr "evaluierter Ausdruck"
|
||||
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
|
||||
msgstr "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
|
||||
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
" -n: display result without sending it to buffer (debug mode)\n"
|
||||
" -s: split expression before evaluating it (many commands can be "
|
||||
@ -1706,7 +1707,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
4
po/es.po
4
po/es.po
@ -22,7 +22,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
|
||||
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1601,7 +1601,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
8
po/fr.po
8
po/fr.po
@ -21,8 +21,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"PO-Revision-Date: 2019-10-11 20:23+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-10-12 17:09+0200\n"
|
||||
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
"Language: fr\n"
|
||||
@ -1675,7 +1675,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
@ -1789,7 +1789,7 @@ msgstr ""
|
||||
"chaîne\" ou \"cut:+max,suffixe,chaîne\")\n"
|
||||
" ou un maximum de caractères affichés à l'écran (format : \"cutscr:max,"
|
||||
"suffixe,chaîne\" ou \"cutscr:+max,suffixe,chaîne\")\n"
|
||||
" 5. une chaîne inversée (format : \"rev:xxx\")\n"
|
||||
" 5. une chaîne inversée (format : \"rev:xxx\" ou \"revscr:xxx\")\n"
|
||||
" 6. une chaîne répétée (format : \"repeat:nombre,chaîne\")\n"
|
||||
" 7. longueur d'une chaîne (format : \"length:xxx\" ou \"lengthscr:xxx\")\n"
|
||||
" 8. une couleur (format : \"color:xxx\", voir la \"Référence API extension"
|
||||
|
4
po/hu.po
4
po/hu.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
|
||||
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1489,7 +1489,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
4
po/it.po
4
po/it.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-05-13 21:31+0200\n"
|
||||
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1584,7 +1584,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
4
po/ja.po
4
po/ja.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-09-22 18:54+0200\n"
|
||||
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
|
||||
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
|
||||
@ -1638,7 +1638,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
4
po/pl.po
4
po/pl.po
@ -22,7 +22,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-09-22 18:54+0200\n"
|
||||
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
|
||||
"Language-Team: Polish <kde-i18n-doc@kde.org>\n"
|
||||
@ -1673,7 +1673,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
4
po/pt.po
4
po/pt.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-09-22 18:54+0200\n"
|
||||
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
|
||||
"Language-Team: Portuguese <>\n"
|
||||
@ -1642,7 +1642,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
@ -21,7 +21,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-05-13 21:32+0200\n"
|
||||
"Last-Translator: Eduardo Elias <camponez@gmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1646,7 +1646,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
4
po/ru.po
4
po/ru.po
@ -21,7 +21,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-05-13 21:32+0200\n"
|
||||
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1511,7 +1511,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
4
po/tr.po
4
po/tr.po
@ -20,7 +20,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2019-05-13 21:32+0200\n"
|
||||
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1342,7 +1342,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
@ -21,7 +21,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2019-10-11 13:59+0200\n"
|
||||
"POT-Creation-Date: 2019-10-12 17:09+0200\n"
|
||||
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
|
||||
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@ -1344,7 +1344,7 @@ msgid ""
|
||||
"+max,suffix,string\")\n"
|
||||
" or max chars displayed on screen (format: \"cutscr:max,suffix,string\" "
|
||||
"or \"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or \"lengthscr:xxx\")\n"
|
||||
" 8. a color (format: \"color:xxx\", see \"Plugin API reference\", function "
|
||||
|
@ -7353,7 +7353,7 @@ command_init ()
|
||||
" or max chars displayed on screen "
|
||||
"(format: \"cutscr:max,suffix,string\" or "
|
||||
"\"cutscr:+max,suffix,string\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\")\n"
|
||||
" 5. a reversed string (format: \"rev:xxx\" or \"revscr:xxx\")\n"
|
||||
" 6. a repeated string (format: \"repeat:count,string\")\n"
|
||||
" 7. length of a string (format: \"length:xxx\" or "
|
||||
"\"lengthscr:xxx\")\n"
|
||||
|
@ -295,7 +295,8 @@ end:
|
||||
* 5. a string with max chars (format: cut:max,suffix,string or
|
||||
* cut:+max,suffix,string) or max chars on screen
|
||||
* (format: cutscr:max,suffix,string or cutscr:+max,suffix,string)
|
||||
* 6. a reversed string (format: rev:xxx)
|
||||
* 6. a reversed string (format: rev:xxx) or reversed string for screen,
|
||||
* color codes are not reversed (format: revscr:xxx)
|
||||
* 7. a repeated string (format: repeat:count,string)
|
||||
* 8. length of a string (format: length:xxx) or length of a string on screen
|
||||
* (format: lengthscr:xxx); color codes are ignored
|
||||
@ -459,9 +460,9 @@ eval_replace_vars_cb (void *data, const char *text)
|
||||
|
||||
/* 6. reverse string */
|
||||
if (strncmp (text, "rev:", 4) == 0)
|
||||
{
|
||||
return string_reverse (text + 4);
|
||||
}
|
||||
if (strncmp (text, "revscr:", 7) == 0)
|
||||
return string_reverse_screen (text + 7);
|
||||
|
||||
/* 7. repeated string */
|
||||
if (strncmp (text, "repeat:", 7) == 0)
|
||||
|
@ -203,6 +203,66 @@ string_reverse (const char *string)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reverses a string for screen: color codes are not reversed.
|
||||
* For example: reverse of "<red>test" is "test<red>" where the color code
|
||||
* "<red>" is kept as-is, so it is still valid (this is not the case with
|
||||
* function string_reverse).
|
||||
*
|
||||
* Note: result must be freed after use.
|
||||
*/
|
||||
|
||||
char *
|
||||
string_reverse_screen (const char *string)
|
||||
{
|
||||
int length, color_size, char_size;
|
||||
const char *ptr_string, *ptr_next;
|
||||
char *result, *ptr_result;
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
if (!string[0])
|
||||
return strdup (string);
|
||||
|
||||
length = strlen (string);
|
||||
result = malloc (length + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
ptr_string = string;
|
||||
ptr_result = result + length;
|
||||
ptr_result[0] = '\0';
|
||||
|
||||
while (ptr_string && ptr_string[0])
|
||||
{
|
||||
ptr_next = gui_chat_string_next_char (NULL, NULL,
|
||||
(const unsigned char *)ptr_string,
|
||||
0, 0, 0);
|
||||
if (!ptr_next)
|
||||
ptr_next = ptr_string + strlen (ptr_string);
|
||||
color_size = ptr_next - ptr_string;
|
||||
if (color_size > 0)
|
||||
{
|
||||
/* add the color code as-is */
|
||||
ptr_result -= color_size;
|
||||
memcpy (ptr_result, ptr_string, color_size);
|
||||
ptr_string += color_size;
|
||||
}
|
||||
|
||||
if (ptr_string[0])
|
||||
{
|
||||
char_size = utf8_char_size (ptr_string);
|
||||
|
||||
ptr_result -= char_size;
|
||||
memcpy (ptr_result, ptr_string, char_size);
|
||||
ptr_string += char_size;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Repeats a string a given number of times.
|
||||
*
|
||||
|
@ -40,6 +40,7 @@ extern char *string_strndup (const char *string, int length);
|
||||
extern char *string_cut (const char *string, int length, int count_suffix,
|
||||
int screen, const char *cut_suffix);
|
||||
extern char *string_reverse (const char *string);
|
||||
extern char *string_reverse_screen (const char *string);
|
||||
extern char *string_repeat (const char *string, int count);
|
||||
extern void string_tolower (char *string);
|
||||
extern void string_toupper (char *string);
|
||||
|
@ -354,6 +354,18 @@ TEST(CoreEval, EvalExpression)
|
||||
/* test reverse of string */
|
||||
WEE_CHECK_EVAL("!dlrow ,olleH", "${rev:Hello, world!}");
|
||||
WEE_CHECK_EVAL("界世はちにんこ", "${rev:こんにちは世界}");
|
||||
WEE_CHECK_EVAL("!dlrow30F\x19 ,olleH",
|
||||
"${rev:Hello, ${color:red}world!}");
|
||||
WEE_CHECK_EVAL("Hello, \x19" "F03world!",
|
||||
"${rev:${rev:Hello, ${color:red}world!}}");
|
||||
|
||||
/* test reverse of string (for screen) */
|
||||
WEE_CHECK_EVAL("!dlrow ,olleH", "${revscr:Hello, world!}");
|
||||
WEE_CHECK_EVAL("界世はちにんこ", "${revscr:こんにちは世界}");
|
||||
WEE_CHECK_EVAL("!dlrow\x19" "F03 ,olleH",
|
||||
"${revscr:Hello, ${color:red}world!}");
|
||||
WEE_CHECK_EVAL("Hello, \x19" "F03world!",
|
||||
"${revscr:${revscr:Hello, ${color:red}world!}}");
|
||||
|
||||
/* test repeat of string */
|
||||
WEE_CHECK_EVAL("", "${repeat:-1,x}");
|
||||
|
@ -35,6 +35,7 @@ extern "C"
|
||||
#include "src/core/weechat.h"
|
||||
#include "src/core/wee-string.h"
|
||||
#include "src/core/wee-hashtable.h"
|
||||
#include "src/gui/gui-color.h"
|
||||
#include "src/plugins/plugin.h"
|
||||
}
|
||||
|
||||
@ -276,6 +277,8 @@ TEST(CoreString, Cut)
|
||||
|
||||
TEST(CoreString, Reverse)
|
||||
{
|
||||
char string[128];
|
||||
|
||||
POINTERS_EQUAL(NULL, string_reverse (NULL));
|
||||
STRCMP_EQUAL("", string_reverse (""));
|
||||
|
||||
@ -291,6 +294,73 @@ TEST(CoreString, Reverse)
|
||||
* the function string_reverse accepts only an UTF-8 string as input
|
||||
*/
|
||||
STRCMP_EQUAL("\xeblon", string_reverse ("no\xebl"));
|
||||
|
||||
/* reverse of string with color codes */
|
||||
snprintf (string, sizeof (string),
|
||||
"%s",
|
||||
gui_color_get_custom ("red"));
|
||||
STRCMP_EQUAL("30F\x19", string_reverse (string));
|
||||
|
||||
snprintf (string, sizeof (string),
|
||||
"%s red",
|
||||
gui_color_get_custom ("red"));
|
||||
STRCMP_EQUAL("der 30F\x19", string_reverse (string));
|
||||
|
||||
snprintf (string, sizeof (string),
|
||||
"red %s",
|
||||
gui_color_get_custom ("red"));
|
||||
STRCMP_EQUAL("30F\x19 der", string_reverse (string));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* string_reverse_screen
|
||||
*/
|
||||
|
||||
TEST(CoreString, ReverseScreen)
|
||||
{
|
||||
char string[128], result[128];
|
||||
|
||||
POINTERS_EQUAL(NULL, string_reverse_screen (NULL));
|
||||
STRCMP_EQUAL("", string_reverse_screen (""));
|
||||
|
||||
/* reverse of UTF-8 string */
|
||||
STRCMP_EQUAL("n", string_reverse_screen ("n"));
|
||||
STRCMP_EQUAL("on", string_reverse_screen ("no"));
|
||||
STRCMP_EQUAL("ëon", string_reverse_screen ("noë"));
|
||||
STRCMP_EQUAL("lëon", string_reverse_screen ("noël"));
|
||||
STRCMP_EQUAL("界世はちにんこ", string_reverse_screen ("こんにちは世界"));
|
||||
|
||||
/*
|
||||
* reverse of ISO-8859-15 string: the result may not be what you expect:
|
||||
* the function string_reverse_screen accepts only an UTF-8 string as input
|
||||
*/
|
||||
STRCMP_EQUAL("\xeblon", string_reverse_screen ("no\xebl"));
|
||||
|
||||
/* reverse of string with color codes */
|
||||
snprintf (string, sizeof (string),
|
||||
"%s",
|
||||
gui_color_get_custom ("red"));
|
||||
snprintf (result, sizeof (result),
|
||||
"%s",
|
||||
gui_color_get_custom ("red"));
|
||||
STRCMP_EQUAL(result, string_reverse_screen (string));
|
||||
|
||||
snprintf (string, sizeof (string),
|
||||
"%s red",
|
||||
gui_color_get_custom ("red"));
|
||||
snprintf (result, sizeof (result),
|
||||
"der %s",
|
||||
gui_color_get_custom ("red"));
|
||||
STRCMP_EQUAL(result, string_reverse_screen (string));
|
||||
|
||||
snprintf (string, sizeof (string),
|
||||
"red %s",
|
||||
gui_color_get_custom ("red"));
|
||||
snprintf (result, sizeof (result),
|
||||
"%s der",
|
||||
gui_color_get_custom ("red"));
|
||||
STRCMP_EQUAL(result, string_reverse_screen (string));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -353,6 +353,14 @@ TEST(CoreUtf8, Size)
|
||||
LONGS_EQUAL(3, utf8_char_size ("€"));
|
||||
LONGS_EQUAL(3, utf8_char_size (cjk_yellow));
|
||||
LONGS_EQUAL(4, utf8_char_size (han_char));
|
||||
/* ë as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(1, utf8_char_size ("\xeb"));
|
||||
/* ël as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(2, utf8_char_size ("\xebl"));
|
||||
/* ëlm as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(3, utf8_char_size ("\xeblm"));
|
||||
/* ëlmn as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(3, utf8_char_size ("\xeblmn"));
|
||||
|
||||
/* char size on screen */
|
||||
LONGS_EQUAL(0, utf8_char_size_screen (NULL));
|
||||
@ -361,6 +369,14 @@ TEST(CoreUtf8, Size)
|
||||
LONGS_EQUAL(1, utf8_char_size_screen ("ë"));
|
||||
LONGS_EQUAL(1, utf8_char_size_screen ("€"));
|
||||
LONGS_EQUAL(2, utf8_char_size_screen (cjk_yellow));
|
||||
/* ë as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(1, utf8_char_size_screen ("\xeb"));
|
||||
/* ël as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(1, utf8_char_size_screen ("\xebl"));
|
||||
/* ëlm as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(1, utf8_char_size_screen ("\xeblm"));
|
||||
/* ëlmn as iso-8859-15: invalid UTF-8 */
|
||||
LONGS_EQUAL(1, utf8_char_size_screen ("\xeblmn"));
|
||||
|
||||
/* length of string (in chars) */
|
||||
LONGS_EQUAL(0, utf8_strlen (NULL));
|
||||
|
Loading…
x
Reference in New Issue
Block a user