diff --git a/.gitignore b/.gitignore index 600d2d33badf45cc068e01d2e3c837e11c417bc4..eb9d03b1667b39ee01d6ce90c3ab4798f9f1d398 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -.vscode \ No newline at end of file +.vscode +mkdocs/ +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 088331252588f88eeea5e3646b8a672d69ed71fb..e5c793a24a79ace28c97a2a538c4dee0a55b70ac 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# clitheme Wiki文档(`v2.0-dev`) +# clitheme Wiki文档(`v2.0-beta3`) [**项目简介和样例展示**](./简介.md) -clitheme项目的Wiki文档可以在这里查看:https://gitee.com/swiftycode/clitheme/wikis/pages +clitheme项目的Wiki文档可以在这里查看:https://gitee.com/swiftycode/clitheme/wikis 这些Wiki文档也可以在这个仓库内查看:https://gitee.com/swiftycode/clitheme-wiki-repo @@ -10,9 +10,9 @@ GitHub镜像仓库:https://github.com/swiftycode256/clitheme-wiki-repo 这些仓库包含最新的更改以及开发中的内容。如需提交Issues和Pull Requests,请通过上方的任意一个仓库提交。 -# clitheme Wiki pages (`v2.0-dev`) +# clitheme Wiki pages (`v2.0-beta3`) -The Wiki pages for the clitheme project can be viewed here: https://gitee.com/swiftycode/clitheme/wikis/pages +The Wiki pages for the clitheme project can be viewed here: https://gitee.com/swiftycode/clitheme/wikis It is also available in this repository: https://gitee.com/swiftycode/clitheme-wiki-repo diff --git "a/\344\275\277\347\224\250clitheme\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" "b/\344\275\277\347\224\250clitheme\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" index 60191e731c89855335e6dc9913b0bd0c1cabfbb9..8649f5d257ff3be7b6ba088ea2a7ec5ba9122aae 100644 --- "a/\344\275\277\347\224\250clitheme\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" +++ "b/\344\275\277\347\224\250clitheme\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" @@ -9,10 +9,10 @@ ```plaintext $ clitheme Usage: - clitheme apply-theme [themedef-file] [--overlay] [--preserve-temp] - clitheme get-current-theme-info + clitheme apply-theme [themedef-file] [--overlay] [--preserve-temp] [--yes] + clitheme get-current-theme-info [--name] [--file-path] clitheme unset-current-theme - clitheme update-theme + clitheme update-theme [--yes] clitheme generate-data [themedef-file] [--overlay] clitheme --version clitheme --help @@ -32,12 +32,14 @@ $ python3 -m src.clitheme ```plaintext $ clitheme apply-theme example-theme.clithemedef.txt -==> Generating data... -Successfully generated data +==> Processing files... +Successfully processed files ==> Applying theme... Theme applied successfully ``` +你可以指定`--yes`选项以跳过确认提示。 + **提示:** 你可以同时指定多个文件名称,以同时应用这些文件的定义。指定的文件会以从左到右的顺序应用,比如`clitheme apply-theme file1 file2`会先应用`file1`然后再应用`file2`,相当于先应用`file1`然后把`file2`中的定义叠加到当前数据上。 ### 主题数据叠加 @@ -60,8 +62,8 @@ $ clitheme apply-theme --overlay example-theme.clithemedef.txt ```plaintext $ clitheme apply-theme --preserve-temp example-theme.clithemedef.txt -==> Generating data... -Successfully generated data +==> Processing files... +Successfully processed files View at /tmp/clitheme-temp-XXXXXXXX ==> Applying theme... Theme applied successfully @@ -82,10 +84,12 @@ Successfully removed the current theme data 使用这个指令时,请确保之前使用的主题定义文件没有被删除或移动,否则操作会失败。 +你可以指定`--yes`选项以跳过确认提示。 + ```plaintext $ clitheme update-theme -==> Generating data... -Successfully generated data +==> Processing files... +Successfully processed files ==> Applying theme... Theme applied successfully ``` @@ -96,7 +100,7 @@ Theme applied successfully ```plaintext $ clitheme get-current-theme-info -Currently installed theme: +Currently installed theme(s): [1]: Example theme Version: 1.0 Supported locales: @@ -106,29 +110,38 @@ Supported apps: • example-app • example-app-two • another-example -``` - -如果通过数据叠加选项同时应用了多个主题,该指令会显示叠加历史记录,从最新应用的主题往下排序。 -```plaintext -$ clitheme get-current-theme-info -Overlay history (sorted by latest installed): [2]: 颜文字样例主题 Version: 1.0 Supported locales: • zh_CN Supported apps: • clitheme_example +``` +你可以指定`--name`选项以仅显示每个主题的名称或`--file-path`以仅显示每个主题的源文件路径。同时指定这两个选项时,名称和路径都会显示。 + +```plaintext +$ clitheme get-current-theme-info --name +Currently installed theme(s): [1]: Example theme -Version: 1.0 -Supported locales: -• en_US -• zh_CN -Supported apps: -• example-app -• example-app-two -• another-example +[2]: 颜文字样例主题 +``` + +```plaintext +$ clitheme get-current-theme-info --file-path +Currently installed theme(s): +/home/user/Documents/example-theme.clithemedef.txt +/home/user/Documents/textemojis.clithemedef.txt +``` + +```plaintext +$ clitheme get-current-theme-info --name --file-path +Currently installed theme(s): +[1]: Example theme +/home/user/Documents/example-theme.clithemedef.txt +[2]: 颜文字样例主题 +/home/user/Documents/textemojis.clithemedef.txt ``` ## `generate-data` - 生成数据结构 @@ -141,8 +154,8 @@ Supported apps: ```plaintext $ clitheme generate-data example-theme.clithemedef.txt -==> Generating data... -Successfully generated data +==> Processing files... +Successfully processed files View at /tmp/clitheme-temp-XXXXXXXX ``` diff --git "a/\345\205\263\344\272\216\347\211\210\346\234\254\347\232\204\351\207\215\350\246\201\344\277\241\346\201\257.md" "b/\345\205\263\344\272\216\347\211\210\346\234\254\347\232\204\351\207\215\350\246\201\344\277\241\346\201\257.md" index ab81f8f4d8b8758bb800ac3cf1868d9c70cdfa25..cd0ee7edb65f50ee47b74f1ca7c243703da867d9 100644 --- "a/\345\205\263\344\272\216\347\211\210\346\234\254\347\232\204\351\207\215\350\246\201\344\277\241\346\201\257.md" +++ "b/\345\205\263\344\272\216\347\211\210\346\234\254\347\232\204\351\207\215\350\246\201\344\277\241\346\201\257.md" @@ -3,11 +3,12 @@ ## 命名方式 `clitheme`采用了以下的版本命名方式: -`a.b.X`或`a.b[.X]-devYYYYMMDD` +`a.b.X`或`a.b[.X]-devYYYYMMDD`或`a.b-betaN` - `a.b`代表了主要版本号。当有新的功能加入`clitheme`时,该版本号的`b`值会变更。比如说:`1.0`、`1.1`、`2.0` - `.X`代表了该版本的发行版次。当小改进和问题修复被加入时,该版本号的`X`值会变更。比如说:`1.0.1`,`2.0.1` - `dev`代表了正在开发的下一个版本。当新的改动被同步到仓库时,我会把当天的日期添加在版本号的后面。比如说:`dev20231202` +- `beta`代表了测试版本;一般会在有复杂功能的功能更新前发布测试版本以更好的改进这些功能。 这个版本信息会被储存在仓库中的`src/clitheme/_version.py`中,并且会在新的发行版中包括此版本号。 diff --git "a/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/1. \347\274\226\345\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" "b/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/1. \347\274\226\345\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" index caa5a3c31b9ca70957527326d301724e2e14e957..de0f300608c5c9f105ba7e038c80a1c2657c5e48 100644 --- "a/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/1. \347\274\226\345\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" +++ "b/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/1. \347\274\226\345\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" @@ -22,7 +22,7 @@ **请注意:**目前仅支持匹配单行的输出,不支持匹配多行输出(这意味着**不要在匹配正则表达式中使用`\n`等换行符号**)。不需要匹配一行中的所有内容;你可以仅匹配和替换一行中的部分内容。 -### 字符串和正则表达式替换:`substitute_string`和`substitute_regex` +### 字符串和正则表达式替换:`subst_string`和`subst_regex` 定义字符串规则的语法如下: @@ -30,26 +30,27 @@ {substrules_section} # 把"{{ESC}}"替换为ANSI Escape字符: set_options substesc - [substitute_string] <匹配文本内容> + [subst_string] <匹配文本内容> [locale] <替换文本内容> [/locale] # 或者: locale: <替换文本内容> - [/substitute_string] + [/subst_string] - [substitute_regex] <匹配正则表达式> + [subst_regex] <匹配正则表达式> [locale] <替换内容(正则表达式替换语法)> [/locale] # 或者: locale: <替换文本内容> - [/substitute_regex] + [/subst_regex] {/substrules_section} ``` -- 在`[substitute_string]`之后输入要匹配/查找的文本内容;在`[substitute_regex]`之后输入要匹配的正则表达式。 +- 在`[subst_string]`之后输入要匹配/查找的文本内容;在`[subst_regex]`之后输入要匹配的正则表达式。 - `clitheme`用的是Python内置的的正则表达式引擎,所以你必须使用Python的正则表达式语法。有关更多信息,请见[本文章](https://docs.python.org/zh-cn/3/howto/regex.html)。 + - 你也可以使用`[substitute_string]`和`[substitute_regex]`语法 - 使用以`[locale]`开头的内容段落输入要替换的内容 - 在`[locale]`之后可以定义系统语言(locale):当前的系统语言设定符合这个定义时才会执行替换;如不需要限制系统语言,请使用`default`。 - 你可以同时指定多个系统语言;只需要用空格分开就可以了(如`[locale] en_US zh_CN`) @@ -57,53 +58,68 @@ - 更多信息请见[多语言支持](../附录:主题定义文件通用语法/多语言支持.md) - 替换内容可以是多行的;详见[多行内容段落](../附录:主题定义文件通用语法/多行内容段落.md) - 如果替换的内容只有一行,你可以使用`locale:<系统语言>`并且在后面加上替换的内容。这样子写起来会更便捷 - - 注意:不能同时指定多个系统语言,并且不支持在此语法中使用变量替换(`substvar`;详见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md)),如`locale:{{some_var}}`将不会把`{{some_var}}`替换成对应变量的内容 -- 如果匹配的内容之间有任何终端控制字符,匹配内容中必须包括它。你可以使用`clitheme-exec --debug-showchars`在终端输出中以绿色颜色显示这些字符(详见[使用clitheme-exec](2.%20使用clitheme-exec.md))。如需引用ANSI Escape字符(`{{ESC}}`),请在前面添加`set_options substesc`(详见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md))并且在内容中使用`{{ESC}}`。**如需引用其他字符(如`\x08`、`\x07`等),你必须使用正则表达式替换(`[substitute_regex]`)。** + - 注意:不能同时指定多个系统语言,但是支持在此语法中使用变量替换(`substvar`;详见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md)),如`locale:{{some_var}}`会把`{{some_var}}`替换成对应变量的内容,并且在变量的内容中可以通过空格指定多个系统语言。 +- 如果匹配的内容之间有任何终端控制字符,匹配内容中必须包括它。你可以使用`clitheme-exec --showchars`在终端输出中以绿色颜色显示这些字符(详见[使用clitheme-exec](2.%20使用clitheme-exec.md))。如需引用ANSI Escape字符(`{{ESC}}`),请在前面添加`set_options substesc`(详见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md))并且在内容中使用`{{ESC}}`。**如需引用其他字符(如`\x08`、`\x07`等),你必须使用正则表达式替换(`[subst_regex]`)。** - 以`#`开头的行是注释;它们必须定义在新的一行上 ### 可以设定的选项 -你可以为匹配规则设定一些选项。如需设定,请在`[/substitute_string]`或`[/substitute_regex]`之后添加选项设定,或使用`set_options`为之后定义的匹配规则应用这些选项设定。 +你可以为匹配规则设定一些选项。如需设定,请在`[/subst_string]`或`[/subst_regex]`之后添加选项设定,或使用`set_options`为之后定义的匹配规则应用这些选项设定。 -- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则时,不再继续按顺序应用其他的匹配规则 +- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续按顺序应用其他的匹配规则 + - **注意:** 该选项仅适用于匹配规则所在文件中的其他规则,其他文件中的规则将不受影响 - 使用`noendmatchhere`以取消设定 - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 -- `substall`:默认设定;用于重置之前设定;匹配所有内容 +- `substallstreams`:默认设定;用于重置之前设定;匹配所有内容 +- `foregroundonly`:仅在进程为前台运行时应用这些替换规则。该选项适用于使用`clitheme-exec`执行shell等应用程序:通过大多数shell执行其他命令时,该shell会切换为后台运行(并且将执行的命令切换为前台)。这个选项可以防止输出误替换的问题,并且可以确保仅在shell的提示信息上应用有关的的替换规则。 + - 使用`noforegroundonly`以取消设定该选项 + - 你可以使用`clitheme-exec --foreground-stat`以在前台状态切换时获得提示信息 + - **注意:** 经测试,只有shell等应用程序会在执行其他命令时修改自己的前台状态;`sudo`等程序不会(除非通过`sudo`执行shell,如`sudo bash`)。 + - **注意:** 大多数shell程序(`bash`、`zsh`、`csh`、`fish`)的命令执行错误提示(如`command not found`、`permission denied`等)会通过创建的另一个进程输出,并且shell会在后台运行。这会导致带有该选项的命令限制规则和对应的替换规则在这些提示输出上不会被应用: + +```plaintext +$ clitheme-exec --foreground-stat bash +bash-3.2$ wef +! Foreground: False +bash: wef: command not found +! Foreground: True +bash-3.2$ +``` 更多信息以及可以设定的选项请见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md)。 ### 同时指定多个匹配表达式 -在替换内容基本相同的情况下,你可以为一个规则定义同时指定多个匹配表达式。该功能可以免去对替换内容和定义段落的重复复制粘贴,并且修改替换内容会简单很多。如需使用,请同时指定多个`[substitute_string]`或`[substitute_regex]`语句。 +在替换内容基本相同的情况下,你可以为一个规则定义同时指定多个匹配表达式。该功能可以免去对替换内容和定义段落的重复复制粘贴,并且修改替换内容会简单很多。如需使用,请同时指定多个`[subst_string]`或`[subst_regex]`语句。 -**注意:** 不能同时指定`[substitute_string]`或`[substitute_regex]`语句(两者不能在同一个规则定义中混用) +**注意:** 不能同时指定`[subst_string]`或`[subst_regex]`语句(两者不能在同一个规则定义中混用) 样例: ```plaintext {substrules_section} - [substitute_string] Some text 1 - [substitute_string] Some another text - [substitute_string] Some text 2 + [subst_string] Some text 1 + [subst_string] Some another text + [subst_string] Some text 2 locale:default Some substitution text - [/substitute_string] + [/subst_string] # 上方定义等于以下定义: - [substitute_string] Some text 1 + [subst_string] Some text 1 locale:default Some substitution text - [/substitute_string] - [substitute_string] Some text 2 + [/subst_string] + [subst_string] Some text 2 locale:default Some substitution text - [/substitute_string] - [substitute_string] Some another text + [/subst_string] + [subst_string] Some another text locale:default Some substitution text - [/substitute_string] + [/subst_string] # 错误语法(两者不能混用): - [substitute_string] Some text 1 - [substitute_regex] Some regex 1 + [subst_string] Some text 1 + [subst_regex] Some regex 1 locale:default Some substitution text - [/substitute_string] + [/subst_string] {/substrules_section} ``` @@ -113,24 +129,24 @@ {substrules_section} # substesc和endmatchhere选项会对以下所有的匹配规则生效 set_options endmatchhere substesc - [substitute_string] Some text + [subst_string] Some text [locale] default Some other text here Good stuff {{ESC}} [/locale] - [/substitute_string] subststderronly - [substitute_string] Some other text + [/subst_string] subststderronly + [subst_string] Some other text [locale] default Another good stuff [/locale] - [/substitute_string] noendmatchhere subststdoutonly + [/subst_string] noendmatchhere subststdoutonly # 上方定义的noendmatchhere会覆盖之前在set_options中定义的endmatchhere - [substitute_regex] Error at file number (?P\d+): item (?P.+) not found + [subst_regex] Error at file number (?P\d+): item (?P.+) not found # 如果系统语言为zh_CN,会使用以下定义: locale:zh_CN (ToT)/~~~ 在文件\g发生错误:找不到项目"\g"!(>﹏<) # 否则,会使用以下定义: locale:default (ToT)/~~~ Error at file number \g! Could not find item "\g"! - [/substitute_regex] + [/subst_regex] {/substrules_section} ``` @@ -146,15 +162,15 @@ # 你也可以使用以下语法: filter_command <命令> # 该限制会对以下的规则生效 - [substitute_regex] + [subst_regex] <...> - [/substitute_regex] + [/subst_regex] # 使用以下语句对之后的规则取消设定限制 unset_filter_command # 以下的规则不会受到限制 - [substitute_regex] + [subst_regex] <...> - [/substitute_regex] + [/subst_regex] {/substrules_section} ``` @@ -176,20 +192,7 @@ - `exactcmdmatch`:用户输入的命令必须与限制条件命令完全相同 - `smartcmdmatch`:和默认匹配机制相似,但是所有命令中单个横杠(`-`)开头的语句会被拆分成单个选项,如`ls -lih`将会被视为`ls -l -i -h`。带有多个横杠(`--`)的语句不受影响。 - `normalcmdmatch`:默认匹配机制;**用于重置/取消设定之前的设置** -- `foregroundonly`:仅在进程为前台运行时应用这些替换规则。该选项适用于使用`clitheme-exec`执行shell等应用程序:通过大多数shell执行其他命令时,该shell会切换为后台运行(并且将执行的命令切换为前台)。这个选项可以防止输出误替换的问题,并且可以确保仅在shell的提示信息上应用有关的的替换规则。 - - 使用`noforegroundonly`以取消设定该选项 - - 你可以使用`clitheme-exec --debug-foreground`以在前台状态切换时获得提示信息 - - **注意:** 经测试,只有shell等应用程序会在执行其他命令时修改自己的前台状态;`sudo`等程序不会(除非通过`sudo`执行shell,如`sudo bash`)。 - - **注意:** 大多数shell程序(`bash`、`zsh`、`csh`、`fish`)的命令执行错误提示(如`command not found`、`permission denied`等)会通过创建的另一个进程输出,并且shell会在后台运行。这会导致带有该选项的命令限制规则和对应的替换规则在这些提示输出上不会被应用: - -```plaintext -$ clitheme-exec --debug-foreground bash -bash-3.2$ wef -! Foreground: False -bash: wef: command not found -! Foreground: True -bash-3.2$ -``` +- `foregroundonly`:你也可以在限制条件中指定该选项,以应用于适用的替换规则。当取消设定或者重新设定新的限制条件时,该选项将会还原到之前的设定,**即使中途更改了该选项的设定**。 **注意:** 无论选择了哪个匹配选项,如果用户输入的命令中第一个词语包含路径(指定可执行文件),`clitheme`会永远检查并尝试匹配程序名称。比如说,如果用户输入了`/usr/bin/python3 test.py`,`python3 test.py`也会被尝试匹配。 diff --git "a/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/2. \344\275\277\347\224\250clitheme-exec.md" "b/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/2. \344\275\277\347\224\250clitheme-exec.md" index 97becc9bf65f3bf7ccbb518c90b02d2d95bc08b9..03cac1d75ecc9ad8b041bf1ed5bff804e49f58f7 100644 --- "a/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/2. \344\275\277\347\224\250clitheme-exec.md" +++ "b/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/2. \344\275\277\347\224\250clitheme-exec.md" @@ -7,7 +7,7 @@ ```plaintext $ clitheme-exec 使用方式: - clitheme-exec [--debug] [--debug-color] [--debug-newlines] [--debug-showchars] [command] + clitheme-exec [--debug] [--debug-color] [--debug-newlines] [--showchars] [--foreground-stat] [--nosubst] [command] 错误:未指定命令 使用"clitheme-exec --help"以获取使用方式 $ python3 -m clitheme.exec @@ -42,7 +42,7 @@ $ sudo clitheme-exec some-command <...> ``` -如果你已经应用了主题,但是依然受到“没有设定主题”的提示,那是因为使用`sudo`时没有保留你的用户文件夹信息。你可以在`/etc/sudoers`文件中添加`Defaults env_keep += "HOME"`,或找到这一行并删除注释符号,以修复这个问题。 +如果你已经应用了主题,但是依然收到“没有设定主题”的提示,那是因为使用`sudo`时没有保留你的用户文件夹信息。你可以在`/etc/sudoers`文件中添加`Defaults env_keep += "HOME"`,或找到这一行并删除注释符号,以修复这个问题。 ## 可以设定的选项 @@ -53,24 +53,25 @@ $ sudo clitheme-exec some-command - 标记符号为`e`时,表示该输出为standard error(`stderr`) - 标记背景颜色为白色时,则表示该行输出执行替换规则后被改变 - 标记背景颜色为红色时,则表示执行替换规则时超时,并且输出没有被替换 +- `--debug-newlines`:永远用新的一行显示所有输出(用于末尾没有换行的输出内容) + - **该选项必须与`--debug`一起使用** - `--debug-color`:对每一行添加颜色标记:如果该行输出为stdout,则标记黄色;如果该行输出为stderr,则标记红色。 -- `--debug-showchars`:用明文显示以下终端控制字符: +- `--showchars`:用明文显示以下终端控制字符: - ASCII Escape(`{{ESC}}`) - Carriage换行(`\r`) - 换行符号(`\n`) - ASCII Backspace符号(`\x08`) - ASCII Bell符号(`\x07`) -- `--debug-newlines`:永远用新的一行显示所有输出(用于末尾没有换行的输出内容) -- `--debug-foreground`:当进程的前台状态(通过`tcgetpgrp`获取)变动时,显示提示输出。 +- `--foreground-stat`:当进程的前台状态(通过`tcgetpgrp`获取)变动时,显示提示输出。 - `! Foreground: False ()`:进程退出前台状态 - `! Foreground: True ()`:进程进入/重新进入前台状态 - ``为当前前台进程的PID -- `--debug-nosubst`:不进行任何输出替换,即使已设定主题 +- `--nosubst`:不进行任何输出替换,即使已设定主题 如需设定这些选项,请在**指定命令之前**指定这些选项,比如说: ```plaintext -$ clitheme-exec --debug --debug-showchars gcc something.c +$ clitheme-exec --debug --showchars gcc something.c # 不要这样子写: -$ clitheme-exec gcc something.c --debug --debug-showchars +$ clitheme-exec gcc something.c --debug --showchars ``` \ No newline at end of file diff --git "a/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/3. \346\240\267\344\276\213\346\225\231\347\250\213.md" "b/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/3. \346\240\267\344\276\213\346\225\231\347\250\213.md" index fe458b8aaf8ba82dcffc22f71723576dd7c72927..db6b12746da739d220797f0eee5601b1ed3388f5 100644 --- "a/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/3. \346\240\267\344\276\213\346\225\231\347\250\213.md" +++ "b/\345\221\275\344\273\244\350\241\214\350\276\223\345\207\272\346\233\277\346\215\242/3. \346\240\267\344\276\213\346\225\231\347\250\213.md" @@ -1,6 +1,6 @@ # 一个简单的样例展示 -本文章将展示命令行输出替换的一个样例,包含使用`clitheme-exec --debug-showchars`获取所需的输出和为输出编写替换规则。 +本文章将展示命令行输出替换的一个样例,包含使用`clitheme-exec --showchars`获取所需的输出和为输出编写替换规则。 浏览本文章前,请先阅读[编写定义文件](1.%20编写定义文件.md)和[使用clitheme-exec](2.%20使用clitheme-exec.md)。 @@ -8,14 +8,14 @@ ## 1. 获取应用程序的输出 -假如说我们想要自定义`clang`编译器中的一个错误提示。如果我们的测试文件时`test.c`,我们可以使用`clitheme-exec --debug-showchars clang test.c`来获取包含终端控制符号的输出。编写匹配规则时需要考虑到这些终端控制符号;这是为什么我们要获取**包含终端控制符号**的输出。你也可以使用`--debug-nosubst`来获取未替换过的输出,如果你已经设定了主题。 +假如说我们想要自定义`clang`编译器中的一个错误提示。如果我们的测试文件时`test.c`,我们可以使用`clitheme-exec --showchars clang test.c`来获取包含终端控制符号的输出。编写匹配规则时需要考虑到这些终端控制符号;这是为什么我们要获取**包含终端控制符号**的输出。你也可以使用`--nosubst`来获取未替换过的输出,如果你已经设定了主题。 你可以使用`--debug`选项来在每一行输出前加上标记。这个标记会包含输出为stdout或stderr的信息(通过`o`和`e`表达)。 -注意:`--debug-showchars`和任何debug选项必须放在`clang test.c`的前面,否则要执行的命令将会被认为`clang test.c --debug-showchars`。 +注意:`--showchars`和任何debug选项必须放在`clang test.c`的前面,否则要执行的命令将会被认为`clang test.c --showchars`。 ```plaintext -$ clitheme-exec --debug --debug-showchars --debug-nosubst clang test.c +$ clitheme-exec --debug --showchars --nosubst clang test.c e> {{ESC}}[1mtest.c:1:1: {{ESC}}[0m{{ESC}}[0;1;31merror: {{ESC}}[0m{{ESC}}[1munknown type name 'bool'{{ESC}}[0m\r\n e> bool *haku(int *a) {\r\n e> {{ESC}}[0;1;32m^\r\n @@ -100,14 +100,14 @@ test.c:4:3: warning: incompatible pointer types assigning to 'char *' from 'int gcc g++ [/filter_commands] - [substitute_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)warning: (?P({{ESC}}.*?m)*)incompatible pointer types assigning to '(?P.+)' from '(?P.+)' + [subst_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)warning: (?P({{ESC}}.*?m)*)incompatible pointer types assigning to '(?P.+)' from '(?P.+)' # 如果你想仅在系统语言设定为中文(zh_CN)时应用这个替换规则,你可以使用"locale:zh_CN" # 使用"locale:default"时不会添加系统语言限制 locale:default \g杂鱼~: \g'\g'从不兼容的指针类型赋值为'\g',纯爱战神很生气! - [/substitute_regex] - [substitute_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)error: (?P({{ESC}}.*?m)*)unknown type name '(?P.+)' + [/subst_regex] + [subst_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)error: (?P({{ESC}}.*?m)*)unknown type name '(?P.+)' locale:default \g笨蛋!: \g未知的类型名'\g',是忘了定义了吗喵? - [/substitute_regex] + [/subst_regex] {/substrules_section} ``` diff --git "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/1. \350\267\257\345\276\204\345\220\215\347\247\260\345\222\214\346\225\260\346\215\256\347\273\223\346\236\204.md" "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/1. \350\267\257\345\276\204\345\220\215\347\247\260\345\222\214\346\225\260\346\215\256\347\273\223\346\236\204.md" index 75afd8a56016ac961addbf4e9dc285ae707f8fb8..a8af96d814b27f0f4641892519d0dd84926b1d29 100644 --- "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/1. \350\267\257\345\276\204\345\220\215\347\247\260\345\222\214\346\225\260\346\215\256\347\273\223\346\236\204.md" +++ "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/1. \350\267\257\345\276\204\345\220\215\347\247\260\345\222\214\346\225\260\346\215\256\347\273\223\346\236\204.md" @@ -22,4 +22,4 @@ ## 注意事项 -- 路径名称的任何子路径不能包括`/`和`\`符号,并且不能以`.`开头。 +- 路径名称的任何子路径不能包括`<`、`>`、`:`、`"`、`/`、`\`、`|`、`?`、和`*`符号,并且不能以`.`开头。 diff --git "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/3. \344\275\277\347\224\250frontend\346\250\241\345\235\227.md" "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/3. \344\275\277\347\224\250frontend\346\250\241\345\235\227.md" index 1f822d63181d149626e471b4a8910b2e02b12af0..855558c0622b84fdc7db4b2936eff8899bc613ed 100644 --- "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/3. \344\275\277\347\224\250frontend\346\250\241\345\235\227.md" +++ "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/3. \344\275\277\347\224\250frontend\346\250\241\345\235\227.md" @@ -81,43 +81,52 @@ f.retrieve_entry_or_fallback("example-fmt-entry", "{0}: Current value is {value} ## 全局定义参数 -除了在`FetchDescriptor`中定义这些选项和参数,你可以对程序中所有的`FetchDescriptor`设置这些参数。以下变量定义会对所有的`FetchDescriptor`生效,除非创建`FetchDescriptor`时明确指定了这些参数。 +除了在`FetchDescriptor`中定义这些选项和参数,你可以对程序中所有的`FetchDescriptor`设置默认参数值。以下操作会对**在当前文件中**所有的`FetchDescriptor`生效,除非创建`FetchDescriptor`时明确指定了这些参数。你可以指定`None`为数值来取消设定默认值。 -- `global_domain`,`global_appname`,和`global_subsections`:指定了默认的`domain_name`,`app_name`,和`subsections`数值 -- `global_debugmode`:指定了默认的`debug_mode`数值 +- `set_domain`,`set_appname`,和`set_subsections`:指定默认的`domain_name`,`app_name`,和`subsections`数值 +- `set_debugmode`:指定默认的`debug_mode`数值 - 该数值也会控制`frontend.set_local_themedef`函数的输出(详见[**调用本地主题定义文件**](调用本地主题定义文件.md)) -- `global_lang`:指定了默认的`lang`数值 -- `global_disablelang`:指定了默认的`disable_lang`数值 +- `set_lang`:指定默认的`lang`数值 +- `set_disablelang`:指定默认的`disable_lang`数值 **请注意:** 这些全局定义只会影响之后新建的`FetchDescriptor`;更改或设定这些全局定义不会影响已经创建的`FetchDescriptor`。 +你也可以修改以下全局变量来设定默认值。该定义会对一个模块中的**所有文件**生效,并且没有通过以上函数进行设定(或取消设定)时会被使用。 + +- `global_domain` +- `global_appname` +- `global_subsections` +- `global_debugmode` +- `global_lang` +- `global_disablelang` + ```py from clitheme import frontend f0=frontend.FetchDescriptor() # 不会使用定义的全局变量 -# 默认值: +# 参数默认值设定 +frontend.set_domain("com.example") # 对应domain_name +frontend.set_appname("example-app") # 对应app_name +frontend.set_subsections("example-subsection subsection-2") # 对应subsections +frontend.set_debugmode(False) # 对应debug_mode +frontend.set_lang("") # 对应lang(留空以使用系统语言) +frontend.set_disablelang(False) # 对应disable_lang + +# 会使用定义的默认值 +f1=frontend.FetchDescriptor() +f2=frontend.FetchDescriptor() + +# 会忽略设定的set_debugmode默认值,设定debug_mode为True +f3=frontend.FetchDescriptor(debug_mode=True) + +# 设定以下全局变量并且没有通过函数设定时,会被视为默认值 # frontend.global_domain="" # frontend.global_appname="" # frontend.global_subsections="" # frontend.global_debugmode=False # frontend.global_lang="" # frontend.global_disablelang=False - -# 全局设定变量 -frontend.global_domain="com.example" # 对应domain_name -frontend.global_appname="example-app" # 对应app_name -frontend.global_subsections="example-subsection subsection-2" # 对应subsections -frontend.global_debugmode=False # 对应debug_mode -frontend.global_lang="" # 对应lang(留空以使用系统语言) -frontend.global_disablelang=False # 对应disable_lang - -# 会使用定义的全局变量 -f1=frontend.FetchDescriptor() -f2=frontend.FetchDescriptor() - -# 会忽略全局的global_debugmode=False定义,设定debug_mode为True -f3=frontend.FetchDescriptor(debug_mode=True) ``` ## 使用fallback模块 diff --git "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/frontend\346\250\241\345\235\227\345\256\214\346\225\264\346\226\207\346\241\243.md" "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/frontend\346\250\241\345\235\227\345\256\214\346\225\264\346\226\207\346\241\243.md" index 6b2d841840fd3dedf9dbff10fa1a9c9d8ae8d175..5740a81157444ab80713509d7a3de0685a610ee1 100644 --- "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/frontend\346\250\241\345\235\227\345\256\214\346\225\264\346\226\207\346\241\243.md" +++ "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/frontend\346\250\241\345\235\227\345\256\214\346\225\264\346\226\207\346\241\243.md" @@ -61,32 +61,69 @@ **注意:** 请将**文件内容**传递到这个函数中,不要传递文件的路径名称。 +### `set_local_themedefs` + +`frontend.set_local_themedefs`(`file_contents`: `list[str]`, `overlay`: `bool`=`False`) -> `bool` + +同时设定多个本地定义文件。该函数与以下操作类似: + +```py +frontend.set_local_themedef(file_content1, overlay=overlay) +frontend.set_local_themedef(file_content2, overlay=True) +frontend.set_local_themedef(file_content3, overlay=True) +# ... +``` + ### `unset_local_themedef` `frontend.unset_local_themedef`() 取消设定本地定义文件。取消设定后frontend将不再尝试调用本地定义文件。 -## 全局变量和选项 +## 设定默认参数值 -以下的变量定义会对所有之后创建的`FetchDescriptor`生效,除非定义`FetchDescriptor`时指定了其他的数值。 +以下的函数操作会对**在本文件内**所有之后创建的`FetchDescriptor`生效,除非定义`FetchDescriptor`时指定了其他的数值。你可以指定`None`为数值来取消设定默认值。 -### `global_domain` +### `set_domain` + +`frontend.set_domain`(`value`: `str | None`) 设定默认的`domain_name`数值。 -### `global_appname` +### `set_appname` + +`frontend.set_appname`(`value`: `str | None`) 设定默认的`app_name`数值。 -### `global_subsections` +### `set_subsections` + +`frontend.set_subsections`(`value`: `str | None`) 设定默认的`global_subsections`数值。 -### `global_lang` +### `set_debugmode` + +`frontend.set_debugmode`(`value`: `bool | None`) + +设定默认的`debug_mode`数值。 + +### `set_lang` + +`frontend.set_lang`(`value`: `str | None`) 设定默认的`lang`数值。 -### `global_disablelang` +### `set_disablelang` + +`frontend.set_disablelang`(`value`: `bool | None`) + +设定默认的`disable_lang`数值。 + +--- + +你也可以修改以下全局变量来设定默认值。该定义会对一个模块中的**所有文件**生效,并且没有通过以上函数进行设定(或取消设定)时会被使用。 + +### `global_domain`, `global_appname`, `global_subsections`, `global_debugmode`, `global_lang`, `global_disablelang` -设定默认的`disable_lang`数值。 \ No newline at end of file +全局设定默认数值。 \ No newline at end of file diff --git "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/\350\260\203\347\224\250\346\234\254\345\234\260\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266.md" "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/\350\260\203\347\224\250\346\234\254\345\234\260\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266.md" index 99a6c4fbc875e52ae716aa32d9f94c76307eb448..02ca394aa4ddc1c545a8c558d706a8ae48dcd7fc 100644 --- "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/\350\260\203\347\224\250\346\234\254\345\234\260\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266.md" +++ "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\345\272\224\347\224\250\347\250\213\345\272\217\351\200\202\351\205\215/\350\260\203\347\224\250\346\234\254\345\234\260\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266.md" @@ -16,20 +16,26 @@ ```py from clitheme import frontend -f=open("", "r") # 为文件路径 +f=open("", "r", encoding="utf-8") # 为文件路径 c=f.read() frontend.set_local_themedef(c) ``` 设定完成后会对之后的字符串调用操作生效。获取字符串时,只有当前系统/全局主题设定中没有该字符串定义的情况下才会调用本地文件中的定义。 +**注意:** 该设定会对同一Python模块/应用程序中的所有代码文件生效,不需要在多个文件中重复调用该函数。 + ## 同时设定多个本地定义文件 -你可以通过`set_local_themedef`函数中的`overlay`参数同时设定多个本地定义文件。如需使用,请在每次的函数调用指定这个参数。 +你可以通过`set_local_themedefs`函数同时设定多个本地定义文件。使用时,请通过列表指定多个文件内容。 + +除此之外,你可以使用`set_local_themedef`函数并设定`overlay`参数。请在每次的函数调用指定这个参数。 ```py from clitheme import frontend -# ... +# 方法1: +frontend.set_local_themedefs([file_content1, file_content2, file_content3]) +# 方法2: # 第一个调用不需要指定overlay frontend.set_local_themedef(file_content1) frontend.set_local_themedef(file_content2, overlay=True) diff --git "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\347\274\226\345\206\231\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266/\345\237\272\346\234\254\347\224\250\346\263\225.md" "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\347\274\226\345\206\231\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266/\345\237\272\346\234\254\347\224\250\346\263\225.md" index 1c6395d25f87e6a31686438467c4e63030da0ead..0c61ac3e4943899f2a23e5b535d88ebefca02e7c 100644 --- "a/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\347\274\226\345\206\231\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266/\345\237\272\346\234\254\347\224\250\346\263\225.md" +++ "b/\345\272\224\347\224\250\347\250\213\345\272\217\345\222\214\345\255\227\347\254\246\344\270\262\345\256\232\344\271\211API/\347\274\226\345\206\231\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266/\345\237\272\346\234\254\347\224\250\346\263\225.md" @@ -35,7 +35,7 @@ {/header_section} ``` -在`header`段落内可以定义以下信息。你不需要定义所有的信息,但是建议定义以下所有的信息。 +在`header`段落内可以定义以下信息。你仅需要定义`name`条目,但是建议定义以下所有的信息。 - `name`:定义该主题的名称,如**example-app颜文字主题**。 - `description`: 定义该主题的更多详细信息。 diff --git "a/\347\256\200\344\273\213.md" "b/\347\256\200\344\273\213.md" index e5ce4a4e5d73483de767165c8dd0d34b734506f1..2d1376d39c4b5403c6566cf1eacfdd406b155453 100644 --- "a/\347\256\200\344\273\213.md" +++ "b/\347\256\200\344\273\213.md" @@ -48,13 +48,13 @@ test.c:4:3: warning: incompatible pointer types assigning to 'char *' from 'int gcc g++ [/filter_commands] - # clang的输出包含用于设定字体颜色的终端控制字符:请使用"clitheme-exec --debug-showchars clang test.c"以显示它们 - [substitute_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)warning: (?P({{ESC}}.*?m)*)incompatible pointer types assigning to '(?P.+)' from '(?P.+)' + # clang的输出包含用于设定字体颜色的终端控制字符:请使用"clitheme-exec --showchars clang test.c"以显示它们 + [subst_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)warning: (?P({{ESC}}.*?m)*)incompatible pointer types assigning to '(?P.+)' from '(?P.+)' locale:default \g杂鱼~: \g'\g'从不兼容的指针类型赋值为'\g',纯爱战神很生气! - [/substitute_regex] - [substitute_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)error: (?P({{ESC}}.*?m)*)unknown type name '(?P.+)' + [/subst_regex] + [subst_regex] (?P^({{ESC}}.*?m)*(.+:\d+:\d+:) ({{ESC}}.*?m)*)error: (?P({{ESC}}.*?m)*)unknown type name '(?P.+)' locale:default \g笨蛋!: \g未知的类型名'\g',是忘了定义了吗喵? - [/substitute_regex] + [/subst_regex] {/substrules_section} ``` @@ -62,8 +62,8 @@ test.c:4:3: warning: incompatible pointer types assigning to 'char *' from 'int ```plaintext $ clitheme apply-theme clang-theme_clithemedef.txt -==> Generating data... -Successfully generated data +==> Processing files... +Successfully processed files ==> Applying theme...Success Theme applied successfully ``` @@ -85,7 +85,7 @@ test.c:4:3: 笨蛋!: 'char *'从不兼容的指针类型赋值为'int *',纯 关于编写主题定义文件的更多信息,请参考[命令行输出替换/编写定义文件](命令行输出替换/1.%20编写定义文件.md)。 -(本样例中的部分内容来自于`kawaii-gcc`项目。项目地址:https://github.com/Bill-Haku/kawaii-gcc) +(本样例中的部分内容来自于`kawaii-gcc`项目。项目地址:https://github.com/Bill-Haku/kawaii-gcc ) ## 更多信息 diff --git "a/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/header\346\256\265\350\220\275.md" "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/header\346\256\265\350\220\275.md" index f39af4e396dc6647ea0722fd86a2af2ccea55b4a..00be77258f2b7eb0fccffed38f6f428677b9f087 100644 --- "a/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/header\346\256\265\350\220\275.md" +++ "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/header\346\256\265\350\220\275.md" @@ -12,7 +12,7 @@ {/header_section} ``` -在`header`段落内可以定义以下信息。你不需要定义所有的信息,但是建议定义以下所有的信息。 +在`header`段落内可以定义以下信息。你仅需要定义`name`条目,但是建议定义以下所有的信息。 - `name`:定义该主题的名称,如**example-app颜文字主题**。 - `description`: 定义该主题的更多详细信息。 diff --git "a/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\217\257\344\273\245\350\256\276\345\256\232\347\232\204\351\200\211\351\241\271.md" "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\217\257\344\273\245\350\256\276\345\256\232\347\232\204\351\200\211\351\241\271.md" index ed4ad85af3056d4f102978cb3facffd245da3c51..cac2be419bba0537ecd82f4469af11570aa02ca0 100644 --- "a/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\217\257\344\273\245\350\256\276\345\256\232\347\232\204\351\200\211\351\241\271.md" +++ "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\217\257\344\273\245\350\256\276\345\256\232\347\232\204\351\200\211\351\241\271.md" @@ -6,29 +6,29 @@ 你可以使用`set_options <选项>`语法来设定选项。你可以同时指定多个选项设定;只需要使用空格分开即可。设定后,这些选项将会被应用在该语句之后的相关定义。比如:`set_options substesc substvar leadtabs:1` -你也可以对单个定义设定这些选项;只需要在它们的结束语句之后添加这些选项设定就可以了。这些设定会覆盖之前通过`set_options`设定的选项设置。比如说:`[/substitute_regex] subststdoutonly endmatchhere`或`[/locale] substesc substvar leadtabs:1` +你也可以对单个定义设定这些选项;只需要在它们的结束语句之后添加这些选项设定就可以了。这些设定会覆盖之前通过`set_options`设定的选项设置。比如说:`[/subst_regex] subststdoutonly endmatchhere`或`[/locale] substesc substvar leadtabs:1` ```plaintext {substrules_section} # substesc和endmatchhere选项会对以下所有的匹配规则生效 set_options endmatchhere substesc - [substitute_string] Some text + [subst_string] Some text [locale] default Some other text here Good stuff {{ESC}} [/locale] - [/substitute_string] subststderronly - [substitute_string] Some other text + [/subst_string] subststderronly + [subst_string] Some other text [locale] default Another good stuff [/locale] - [/substitute_string] noendmatchhere subststdoutonly + [/subst_string] noendmatchhere subststdoutonly # 上方定义的noendmatchhere会覆盖之前在set_options中定义的endmatchhere - [substitute_regex] Error at file number (?P\d+): item (?P.+) not found + [subst_regex] Error at file number (?P\d+): item (?P.+) not found # 如果想对以下内容设定选项,需要使用多行内容段落 locale:zh_CN (ToT)/~~~ 在文件\g发生错误:找不到项目"\g"!(>﹏<) locale:default (ToT)/~~~ Error at file number \g! Could not find item "\g"! - [/substitute_regex] + [/subst_regex] {/substrules_section} ``` @@ -73,9 +73,9 @@ - `substesc`:将内容中的`{{ESC}}`替换为终端ESC(ASCII Escape)字符(`\x1b`) - **该选项仅适用于这些地方:**`header`段落中的`description`定义;`substrules`段落中的匹配和替换内容;`entries`中的字符串定义内容 - - 当该选项在`[/substitute_string]`或`[/substitute_regex]`语句后指定,会应用在匹配内容上 + - 当该选项在`[/subst_string]`或`[/subst_regex]`语句后指定,会应用在匹配内容上 - `substvar`:将内容中的变量名称引用替换成变量内容(详见[内容变量](./内容变量.md)) - - 当该选项在`[/substitute_string]`或`[/substitute_regex]`语句后指定,会应用在匹配内容上 + - 当该选项在`[/subst_string]`或`[/subst_regex]`语句后指定,会应用在匹配内容上 - 当该选项在`[/entry]`语句后指定,会应用在路径名称上 ### 命令行输出替换 @@ -90,11 +90,13 @@ - `normalcmdmatch`:**默认设定;用于重置之前设定**;用户输入的命令中的语句需要包含匹配条件中的语句(e.g. `example-app --this --that`会匹配`example-app --that`匹配条件) - `foregroundonly`:仅在进程为前台运行时应用这些替换规则。该选项适用于使用`clitheme-exec`执行shell等应用程序:通过大多数shell执行其他命令时,该shell会切换为后台运行(并且将执行的命令切换为前台)。这个选项可以防止输出误替换的问题,并且可以确保仅在shell的提示信息上应用有关的的替换规则。 - 使用`noforegroundonly`以取消设定该选项 - - 你可以使用`clitheme-exec --debug-foreground`以在前台状态切换时获得提示信息 + - 你可以使用`clitheme-exec --foreground-stat`以在前台状态切换时获得提示信息 + - 你也可以在限制条件中指定该选项,以应用于适用的替换规则。当取消设定或者重新设定新的限制条件时,该选项将会还原到之前的设定,**即使中途更改了该选项的设定**。 --- -以下几个选项仅适用于`[substitute_string]`和`[substitute_regex]`语法: +以下几个选项仅适用于`[subst_string]`和`[subst_regex]`语法: - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 -- `substall`:**默认设定;用于重置之前设定**;匹配所有内容 -- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则时,不再继续应用其他的匹配规则 +- `substallstreams`:**默认设定;用于重置之前设定**;匹配所有内容 +- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续应用其他的匹配规则 + - **注意:** 该选项仅适用于匹配规则所在文件中的其他规则,其他文件中的规则将不受影响 - 使用`noendmatchhere`以取消设定 diff --git "a/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\244\232\350\257\255\350\250\200\346\224\257\346\214\201.md" "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\244\232\350\257\255\350\250\200\346\224\257\346\214\201.md" index 67218f06246e8d66e0e6c739d42db27b5d73b827..16e1231899d77b97600608121d6c686f4873f101 100644 --- "a/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\244\232\350\257\255\350\250\200\346\224\257\346\214\201.md" +++ "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\345\244\232\350\257\255\350\250\200\346\224\257\346\214\201.md" @@ -50,14 +50,14 @@ LC_ALL= {/entries_section} {substrules_section} # ... - [substitute_string] Some example output message + [subst_string] Some example output message locale:default Output message! :) locale:zh_CN 输出提示!o(≧v≦)o # 同时定义default、C、和en_US语言 [locale] default C en_US Output message! :) [/locale] - [/substitute_string] + [/subst_string] {/substrules_section} ``` diff --git "a/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\346\214\207\345\256\232\346\234\200\344\275\216\346\224\257\346\214\201\347\232\204\347\211\210\346\234\254.md" "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\346\214\207\345\256\232\346\234\200\344\275\216\346\224\257\346\214\201\347\232\204\347\211\210\346\234\254.md" new file mode 100644 index 0000000000000000000000000000000000000000..4b894560968ff32a8f10aaa877f29178f23ea98a --- /dev/null +++ "b/\351\231\204\345\275\225\357\274\232\344\270\273\351\242\230\345\256\232\344\271\211\346\226\207\344\273\266\351\200\232\347\224\250\350\257\255\346\263\225/\346\214\207\345\256\232\346\234\200\344\275\216\346\224\257\346\214\201\347\232\204\347\211\210\346\234\254.md" @@ -0,0 +1,20 @@ +# 指定最低支持的版本 + +从`v2.0`版本开始,你可以指定定义文件最低支持的版本,以确保新版本中的功能可以正常使用。要指定最低支持的版本,请在**文件开头**使用`!require_version`定义: + +```plaintext +!require_version 2.0 +``` + +**注意:** 该定义必须添加在除注释意外的任何内容之前 + +## 可以指定的版本格式 + +你可以在`!require_version`中指定`2.0`及以上的版本,并且可以指定如`a.b`格式的发行版次。你还可以指定带有`-betaN`后缀的beta版本。完整支持的版本格式如下:(括号代表可选信息) + +```plaintext +a.b[-betaN] +``` + +**注意:** 不支持带有bugfix版本信息的版本格式(`a.b.X`)。这是为了更好的兼容未来可能发布的其他`clitheme`变种(bugfix信息不一致)。 +**注意:** 不支持指定带有`-devYYYYMMDD`后缀的版本号。这些版本包含了beta版本发行号码信息;你可以使用最新的beta版本号码代替。 \ No newline at end of file