From 321311bea5da0731ccab97d382bcf1e26aec0676 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Mon, 29 Jul 2024 21:56:24 +0800 Subject: [PATCH 01/25] Clarify mechanism of `endmatchhere` option --- ...\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" | 2 +- ...\256\276\345\256\232\347\232\204\351\200\211\351\241\271.md" | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 caa5a3c..8aabe6c 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" @@ -65,7 +65,7 @@ 你可以为匹配规则设定一些选项。如需设定,请在`[/substitute_string]`或`[/substitute_regex]`之后添加选项设定,或使用`set_options`为之后定义的匹配规则应用这些选项设定。 -- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则时,不再继续按顺序应用其他的匹配规则 +- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续按顺序应用其他的匹配规则 - 使用`noendmatchhere`以取消设定 - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 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 ed4ad85..c1615b2 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" @@ -96,5 +96,5 @@ - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 - `substall`:**默认设定;用于重置之前设定**;匹配所有内容 -- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则时,不再继续应用其他的匹配规则 +- `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续应用其他的匹配规则 - 使用`noendmatchhere`以取消设定 -- Gitee From 36ebacf01ca4e21a54e12d02174484e0e09db55d Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Sat, 3 Aug 2024 15:04:11 +0800 Subject: [PATCH 02/25] Rename "Generating data" to "Processing files" --- ...3\244\350\241\214\345\267\245\345\205\267.md" | 16 ++++++++-------- "\347\256\200\344\273\213.md" | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) 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 60191e7..cca0c88 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" @@ -32,8 +32,8 @@ $ 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 ``` @@ -60,8 +60,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 @@ -84,8 +84,8 @@ Successfully removed the current theme data ```plaintext $ clitheme update-theme -==> Generating data... -Successfully generated data +==> Processing files... +Successfully processed files ==> Applying theme... Theme applied successfully ``` @@ -141,8 +141,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/\347\256\200\344\273\213.md" "b/\347\256\200\344\273\213.md" index e5ce4a4..f52f485 100644 --- "a/\347\256\200\344\273\213.md" +++ "b/\347\256\200\344\273\213.md" @@ -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 ``` -- Gitee From 295b93c888041d93c90fdcc4e22457c2aad9d890 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Wed, 7 Aug 2024 20:57:17 +0800 Subject: [PATCH 03/25] Rename `substall` option to `substallstreams` --- ...\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" | 2 +- ...\256\276\345\256\232\347\232\204\351\200\211\351\241\271.md" | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 8aabe6c..745d295 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" @@ -69,7 +69,7 @@ - 使用`noendmatchhere`以取消设定 - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 -- `substall`:默认设定;用于重置之前设定;匹配所有内容 +- `substallstreams`:默认设定;用于重置之前设定;匹配所有内容 更多信息以及可以设定的选项请见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md)。 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 c1615b2..e3487fe 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" @@ -95,6 +95,6 @@ 以下几个选项仅适用于`[substitute_string]`和`[substitute_regex]`语法: - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 -- `substall`:**默认设定;用于重置之前设定**;匹配所有内容 +- `substallstreams`:**默认设定;用于重置之前设定**;匹配所有内容 - `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续应用其他的匹配规则 - 使用`noendmatchhere`以取消设定 -- Gitee From 60a420235775011cd90e269e8cb545cbcaf620c0 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Wed, 7 Aug 2024 20:57:24 +0800 Subject: [PATCH 04/25] Add more items to gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 600d2d3..eb9d03b 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 -- Gitee From df487752fc143b2c655d939bbe145018248e34b1 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Thu, 8 Aug 2024 15:11:53 +0800 Subject: [PATCH 05/25] Rename options in `clitheme-exec` - Rename `--debug-showchars` to `--showchars` - Rename `--debug-foreground` to `--foreground-stat` - Rename `--debug-nosubst` to `--nosubst` - Require `--debug` when using `--debug-newlines` --- ...56\232\344\271\211\346\226\207\344\273\266.md" | 6 +++--- .../2. \344\275\277\347\224\250clitheme-exec.md" | 15 ++++++++------- ...40\267\344\276\213\346\225\231\347\250\213.md" | 8 ++++---- "\347\256\200\344\273\213.md" | 2 +- ...56\232\347\232\204\351\200\211\351\241\271.md" | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) 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 745d295..e0383d5 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" @@ -58,7 +58,7 @@ - 替换内容可以是多行的;详见[多行内容段落](../附录:主题定义文件通用语法/多行内容段落.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]`)。** +- 如果匹配的内容之间有任何终端控制字符,匹配内容中必须包括它。你可以使用`clitheme-exec --showchars`在终端输出中以绿色颜色显示这些字符(详见[使用clitheme-exec](2.%20使用clitheme-exec.md))。如需引用ANSI Escape字符(`{{ESC}}`),请在前面添加`set_options substesc`(详见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md))并且在内容中使用`{{ESC}}`。**如需引用其他字符(如`\x08`、`\x07`等),你必须使用正则表达式替换(`[substitute_regex]`)。** - 以`#`开头的行是注释;它们必须定义在新的一行上 ### 可以设定的选项 @@ -178,12 +178,12 @@ - `normalcmdmatch`:默认匹配机制;**用于重置/取消设定之前的设置** - `foregroundonly`:仅在进程为前台运行时应用这些替换规则。该选项适用于使用`clitheme-exec`执行shell等应用程序:通过大多数shell执行其他命令时,该shell会切换为后台运行(并且将执行的命令切换为前台)。这个选项可以防止输出误替换的问题,并且可以确保仅在shell的提示信息上应用有关的的替换规则。 - 使用`noforegroundonly`以取消设定该选项 - - 你可以使用`clitheme-exec --debug-foreground`以在前台状态切换时获得提示信息 + - 你可以使用`clitheme-exec --foreground-stat`以在前台状态切换时获得提示信息 - **注意:** 经测试,只有shell等应用程序会在执行其他命令时修改自己的前台状态;`sudo`等程序不会(除非通过`sudo`执行shell,如`sudo bash`)。 - **注意:** 大多数shell程序(`bash`、`zsh`、`csh`、`fish`)的命令执行错误提示(如`command not found`、`permission denied`等)会通过创建的另一个进程输出,并且shell会在后台运行。这会导致带有该选项的命令限制规则和对应的替换规则在这些提示输出上不会被应用: ```plaintext -$ clitheme-exec --debug-foreground bash +$ clitheme-exec --foreground-stat bash bash-3.2$ wef ! Foreground: False bash: wef: command not found 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 97becc9..74120d4 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] [command] 错误:未指定命令 使用"clitheme-exec --help"以获取使用方式 $ python3 -m clitheme.exec @@ -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 fe458b8..fed9bba 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 diff --git "a/\347\256\200\344\273\213.md" "b/\347\256\200\344\273\213.md" index f52f485..f41c63e 100644 --- "a/\347\256\200\344\273\213.md" +++ "b/\347\256\200\344\273\213.md" @@ -48,7 +48,7 @@ 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"以显示它们 + # clang的输出包含用于设定字体颜色的终端控制字符:请使用"clitheme-exec --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.+)' locale:default \g杂鱼~: \g'\g'从不兼容的指针类型赋值为'\g',纯爱战神很生气! [/substitute_regex] 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 e3487fe..ebbc6f9 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" @@ -90,7 +90,7 @@ - `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]`语法: - `subststdoutonly`:仅匹配standard output的输出内容 -- Gitee From 8b38741ed93048f664d531ff9717b1de34de61b9 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Thu, 8 Aug 2024 15:12:49 +0800 Subject: [PATCH 06/25] Add missing options in `clitheme-exec` command example --- .../2. \344\275\277\347\224\250clitheme-exec.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 74120d4..07cccaf 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] [--showchars] [command] + clitheme-exec [--debug] [--debug-color] [--debug-newlines] [--showchars] [--foreground-stat] [--nosubst] [command] 错误:未指定命令 使用"clitheme-exec --help"以获取使用方式 $ python3 -m clitheme.exec -- Gitee From 1c7a0c8cf85f6537e179770017a523ebf56422a3 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Sat, 10 Aug 2024 23:37:47 +0800 Subject: [PATCH 07/25] Update list of banphrase characters --- ...\222\214\346\225\260\346\215\256\347\273\223\346\236\204.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 75afd8a..a8af96d 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 @@ ## 注意事项 -- 路径名称的任何子路径不能包括`/`和`\`符号,并且不能以`.`开头。 +- 路径名称的任何子路径不能包括`<`、`>`、`:`、`"`、`/`、`\`、`|`、`?`、和`*`符号,并且不能以`.`开头。 -- Gitee From a54c3cc4dab128c25327ff7ef1562837d17c5dc1 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Sun, 11 Aug 2024 13:35:39 +0800 Subject: [PATCH 08/25] Add prompt to invoke `set_local_themedef` only once in module code; - Add UTF-8 encoding specification to relevant example code --- ...42\230\345\256\232\344\271\211\346\226\207\344\273\266.md" | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 99a6c4f..de5cc8f 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,13 +16,15 @@ ```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`参数同时设定多个本地定义文件。如需使用,请在每次的函数调用指定这个参数。 -- Gitee From c41470e4bae9d1b755b807dd17f61bca73a682bd Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Sun, 11 Aug 2024 13:39:16 +0800 Subject: [PATCH 09/25] Change Gitee wiki URL - The `/pages` URL and the preview page never works properly --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0883312..3c26204 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [**项目简介和样例展示**](./简介.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 @@ -12,7 +12,7 @@ GitHub镜像仓库:https://github.com/swiftycode256/clitheme-wiki-repo # clitheme Wiki pages (`v2.0-dev`) -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 -- Gitee From 196697e89f529b461677c77012432b4ebe9fc43f Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Tue, 17 Sep 2024 16:51:29 +0800 Subject: [PATCH 10/25] Change instructions on `foregroundonly` option Change the description according to mechanism changes in main code --- ...45\256\232\344\271\211\346\226\207\344\273\266.md" | 11 ++++++----- ...45\256\232\347\232\204\351\200\211\351\241\271.md" | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) 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 e0383d5..25479f7 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" @@ -70,6 +70,11 @@ - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 - `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会在后台运行。这会导致带有该选项的命令限制规则和对应的替换规则在这些提示输出上不会被应用: 更多信息以及可以设定的选项请见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md)。 @@ -176,11 +181,7 @@ - `exactcmdmatch`:用户输入的命令必须与限制条件命令完全相同 - `smartcmdmatch`:和默认匹配机制相似,但是所有命令中单个横杠(`-`)开头的语句会被拆分成单个选项,如`ls -lih`将会被视为`ls -l -i -h`。带有多个横杠(`--`)的语句不受影响。 - `normalcmdmatch`:默认匹配机制;**用于重置/取消设定之前的设置** -- `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会在后台运行。这会导致带有该选项的命令限制规则和对应的替换规则在这些提示输出上不会被应用: +- `foregroundonly`:你也可以在限制条件中指定该选项,以应用于适用的替换规则。当取消设定或者重新设定新的限制条件时,该选项将会还原到之前的设定,**即使中途更改了该选项的设定**。 ```plaintext $ clitheme-exec --foreground-stat bash 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 ebbc6f9..38fb582 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" @@ -91,6 +91,7 @@ - `foregroundonly`:仅在进程为前台运行时应用这些替换规则。该选项适用于使用`clitheme-exec`执行shell等应用程序:通过大多数shell执行其他命令时,该shell会切换为后台运行(并且将执行的命令切换为前台)。这个选项可以防止输出误替换的问题,并且可以确保仅在shell的提示信息上应用有关的的替换规则。 - 使用`noforegroundonly`以取消设定该选项 - 你可以使用`clitheme-exec --foreground-stat`以在前台状态切换时获得提示信息 + - 你也可以在限制条件中指定该选项,以应用于适用的替换规则。当取消设定或者重新设定新的限制条件时,该选项将会还原到之前的设定,**即使中途更改了该选项的设定**。 --- 以下几个选项仅适用于`[substitute_string]`和`[substitute_regex]`语法: - `subststdoutonly`:仅匹配standard output的输出内容 -- Gitee From 0612a797cb64fa159ff82e659eae22286911ba6e Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Mon, 30 Sep 2024 22:42:04 +0800 Subject: [PATCH 11/25] Update descriptions on setting frontend default values --- ...24\250frontend\346\250\241\345\235\227.md" | 51 +++++++++++-------- ...14\346\225\264\346\226\207\346\241\243.md" | 40 ++++++++++++--- 2 files changed, 62 insertions(+), 29 deletions(-) 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 1f822d6..855558c 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 6b2d841..e658f8a 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" @@ -67,26 +67,50 @@ 取消设定本地定义文件。取消设定后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 -- Gitee From ab81264bef23aec75146182f264ff2598ad0f6f1 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Mon, 30 Sep 2024 23:27:25 +0800 Subject: [PATCH 12/25] Add information on `set_local_themedefs` function --- ...\256\214\346\225\264\346\226\207\346\241\243.md" | 13 +++++++++++++ ...\256\232\344\271\211\346\226\207\344\273\266.md" | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 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 e658f8a..5740a81 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,6 +61,19 @@ **注意:** 请将**文件内容**传递到这个函数中,不要传递文件的路径名称。 +### `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`() 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 de5cc8f..02ca394 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" @@ -27,11 +27,15 @@ frontend.set_local_themedef(c) ## 同时设定多个本地定义文件 -你可以通过`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) -- Gitee From d6f45f0baa869640433b6aced75e268875ffaca5 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Mon, 30 Sep 2024 23:48:15 +0800 Subject: [PATCH 13/25] Fix link in introduction file Add a space after the URL so that the webpage doesn't mess up recognizing the URL --- "\347\256\200\344\273\213.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/\347\256\200\344\273\213.md" "b/\347\256\200\344\273\213.md" index f41c63e..bd632e2 100644 --- "a/\347\256\200\344\273\213.md" +++ "b/\347\256\200\344\273\213.md" @@ -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 ) ## 更多信息 -- Gitee From ab65af17bf13b5c3806aa5e360fc8eb00d16c076 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Fri, 4 Oct 2024 23:11:54 +0800 Subject: [PATCH 14/25] Add beta version information to version document --- ...232\204\351\207\215\350\246\201\344\277\241\346\201\257.md" | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ab81f8f..cd0ee7e 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`中,并且会在新的发行版中包括此版本号。 -- Gitee From 8919083cb7c586341f5540f299572525309a1d41 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Sat, 5 Oct 2024 18:01:52 +0800 Subject: [PATCH 15/25] Add information on `!require_version` definition --- ...01\347\232\204\347\211\210\346\234\254.md" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "\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" 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 0000000..7fb2e53 --- /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,19 @@ +# 指定最低支持的版本 + +从`v2.0`版本开始,你可以指定定义文件最低支持的版本,以确保新版本中的功能可以正常使用。要指定最低支持的版本,请在**文件开头**使用`!require_version`定义: + +```plaintext +!require_version 2.0 +``` + +**注意:** 该定义必须添加在除注释意外的任何内容之前 + +## 可以指定的版本格式 + +你可以在`!require_version`中指定`2.0`及以上的版本,并且可以指定如`a.b.X`格式的发行版次。你还可以指定带有`-betaN`后缀的beta版本。完整支持的版本格式如下:(括号代表可选信息) + +```plaintext +a.b[.X][-betaN] +``` + +**注意:** 不支持指定带有`-devYYYYMMDD`后缀的版本号。这些版本包含了beta版本发行号码信息;你可以使用最新的beta版本号码代替。 \ No newline at end of file -- Gitee From ce76d2935098e21d8661609b82cb21afa0252386 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Fri, 25 Oct 2024 09:27:33 +0800 Subject: [PATCH 16/25] Require `name` field in header section --- .../\345\237\272\346\234\254\347\224\250\346\263\225.md" | 2 +- .../header\346\256\265\350\220\275.md" | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 1c6395d..0c61ac3 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/\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 f39af4e..00be772 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`: 定义该主题的更多详细信息。 -- Gitee From 92eb6c40a858bee333ebd6621e64381ff528e288 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Wed, 13 Nov 2024 22:02:04 +0800 Subject: [PATCH 17/25] Support using content variables in `locale:` syntax --- ...\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 25479f7..c7c9de6 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" @@ -57,7 +57,7 @@ - 更多信息请见[多语言支持](../附录:主题定义文件通用语法/多语言支持.md) - 替换内容可以是多行的;详见[多行内容段落](../附录:主题定义文件通用语法/多行内容段落.md) - 如果替换的内容只有一行,你可以使用`locale:<系统语言>`并且在后面加上替换的内容。这样子写起来会更便捷 - - 注意:不能同时指定多个系统语言,并且不支持在此语法中使用变量替换(`substvar`;详见[可以设定的选项](../附录:主题定义文件通用语法/可以设定的选项.md)),如`locale:{{some_var}}`将不会把`{{some_var}}`替换成对应变量的内容 + - 注意:不能同时指定多个系统语言,但是支持在此语法中使用变量替换(`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`等),你必须使用正则表达式替换(`[substitute_regex]`)。** - 以`#`开头的行是注释;它们必须定义在新的一行上 -- Gitee From 27bd52dd5fa486e38c06286cac99d1d007e71ea3 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 17:49:48 +0800 Subject: [PATCH 18/25] Change: `endmatchhere` option only applies to rules in the current file --- ...5\206\231\345\256\232\344\271\211\346\226\207\344\273\266.md" | 1 + ...0\256\276\345\256\232\347\232\204\351\200\211\351\241\271.md" | 1 + 2 files changed, 2 insertions(+) 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 c7c9de6..6766aa5 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" @@ -66,6 +66,7 @@ 你可以为匹配规则设定一些选项。如需设定,请在`[/substitute_string]`或`[/substitute_regex]`之后添加选项设定,或使用`set_options`为之后定义的匹配规则应用这些选项设定。 - `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续按顺序应用其他的匹配规则 + - **注意:** 该选项仅适用于匹配规则所在文件中的其他规则,其他文件中的规则将不受影响 - 使用`noendmatchhere`以取消设定 - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 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 38fb582..ef6f67d 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" @@ -98,4 +98,5 @@ - `subststderronly`:仅匹配standard error的输出内容 - `substallstreams`:**默认设定;用于重置之前设定**;匹配所有内容 - `endmatchhere`,`noendmatchhere`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续应用其他的匹配规则 + - **注意:** 该选项仅适用于匹配规则所在文件中的其他规则,其他文件中的规则将不受影响 - 使用`noendmatchhere`以取消设定 -- Gitee From 1b3be1b6e843e7eb7889dac65df33295bf16a1dc Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Mon, 16 Dec 2024 23:28:20 +0800 Subject: [PATCH 19/25] Update documentation to use new `subst` shortened syntax --- ...32\344\271\211\346\226\207\344\273\266.md" | 67 ++++++++++--------- ...67\344\276\213\346\225\231\347\250\213.md" | 8 +-- "\347\256\200\344\273\213.md" | 8 +-- ...32\347\232\204\351\200\211\351\241\271.md" | 20 +++--- ...55\350\250\200\346\224\257\346\214\201.md" | 4 +- 5 files changed, 54 insertions(+), 53 deletions(-) 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 6766aa5..0faa79e 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`) @@ -58,12 +59,12 @@ - 替换内容可以是多行的;详见[多行内容段落](../附录:主题定义文件通用语法/多行内容段落.md) - 如果替换的内容只有一行,你可以使用`locale:<系统语言>`并且在后面加上替换的内容。这样子写起来会更便捷 - 注意:不能同时指定多个系统语言,但是支持在此语法中使用变量替换(`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`等),你必须使用正则表达式替换(`[substitute_regex]`)。** +- 如果匹配的内容之间有任何终端控制字符,匹配内容中必须包括它。你可以使用`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`:当遇到带有该选项的匹配规则并且与当前输出内容成功匹配时,不再继续按顺序应用其他的匹配规则 - **注意:** 该选项仅适用于匹配规则所在文件中的其他规则,其他文件中的规则将不受影响 @@ -81,35 +82,35 @@ ### 同时指定多个匹配表达式 -在替换内容基本相同的情况下,你可以为一个规则定义同时指定多个匹配表达式。该功能可以免去对替换内容和定义段落的重复复制粘贴,并且修改替换内容会简单很多。如需使用,请同时指定多个`[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} ``` @@ -119,24 +120,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} ``` @@ -152,15 +153,15 @@ # 你也可以使用以下语法: filter_command <命令> # 该限制会对以下的规则生效 - [substitute_regex] + [subst_regex] <...> - [/substitute_regex] + [/subst_regex] # 使用以下语句对之后的规则取消设定限制 unset_filter_command # 以下的规则不会受到限制 - [substitute_regex] + [subst_regex] <...> - [/substitute_regex] + [/subst_regex] {/substrules_section} ``` 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 fed9bba..db6b127 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" @@ -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/\347\256\200\344\273\213.md" "b/\347\256\200\344\273\213.md" index bd632e2..2d1376d 100644 --- "a/\347\256\200\344\273\213.md" +++ "b/\347\256\200\344\273\213.md" @@ -49,12 +49,12 @@ test.c:4:3: warning: incompatible pointer types assigning to 'char *' from 'int g++ [/filter_commands] # clang的输出包含用于设定字体颜色的终端控制字符:请使用"clitheme-exec --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.+)' + [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} ``` 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 ef6f67d..cac2be4 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]`语句后指定,会应用在路径名称上 ### 命令行输出替换 @@ -93,7 +93,7 @@ - 你可以使用`clitheme-exec --foreground-stat`以在前台状态切换时获得提示信息 - 你也可以在限制条件中指定该选项,以应用于适用的替换规则。当取消设定或者重新设定新的限制条件时,该选项将会还原到之前的设定,**即使中途更改了该选项的设定**。 --- -以下几个选项仅适用于`[substitute_string]`和`[substitute_regex]`语法: +以下几个选项仅适用于`[subst_string]`和`[subst_regex]`语法: - `subststdoutonly`:仅匹配standard output的输出内容 - `subststderronly`:仅匹配standard error的输出内容 - `substallstreams`:**默认设定;用于重置之前设定**;匹配所有内容 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 67218f0..16e1231 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} ``` -- Gitee From f593eeabd6663409c79d9501d6886c0a4d7f10c4 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Tue, 17 Dec 2024 15:55:51 +0800 Subject: [PATCH 20/25] Add updated options about `get-current-theme-info` --- ...44\350\241\214\345\267\245\345\205\267.md" | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) 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 cca0c88..d221888 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" @@ -10,7 +10,7 @@ $ clitheme Usage: clitheme apply-theme [themedef-file] [--overlay] [--preserve-temp] - clitheme get-current-theme-info + clitheme get-current-theme-info [--name] [--file-path] clitheme unset-current-theme clitheme update-theme clitheme generate-data [themedef-file] [--overlay] @@ -96,7 +96,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 +106,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` - 生成数据结构 -- Gitee From 7f1806b3f282eb86fcae6c957f0ac347feaf5261 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Thu, 19 Dec 2024 13:16:24 +0800 Subject: [PATCH 21/25] Support specifying `--yes` option to skip confirmation --- ...75\344\273\244\350\241\214\345\267\245\345\205\267.md" | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 d221888..8649f5d 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 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 @@ -38,6 +38,8 @@ Successfully processed files Theme applied successfully ``` +你可以指定`--yes`选项以跳过确认提示。 + **提示:** 你可以同时指定多个文件名称,以同时应用这些文件的定义。指定的文件会以从左到右的顺序应用,比如`clitheme apply-theme file1 file2`会先应用`file1`然后再应用`file2`,相当于先应用`file1`然后把`file2`中的定义叠加到当前数据上。 ### 主题数据叠加 @@ -82,6 +84,8 @@ Successfully removed the current theme data 使用这个指令时,请确保之前使用的主题定义文件没有被删除或移动,否则操作会失败。 +你可以指定`--yes`选项以跳过确认提示。 + ```plaintext $ clitheme update-theme ==> Processing files... -- Gitee From 2efc6755fbcbee17801c25dc6a35e4ed3f3c8eb7 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Wed, 1 Jan 2025 17:24:16 +0800 Subject: [PATCH 22/25] Update version specification info --- ...4\257\346\214\201\347\232\204\347\211\210\346\234\254.md" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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" index 7fb2e53..4b89456 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/\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" @@ -10,10 +10,11 @@ ## 可以指定的版本格式 -你可以在`!require_version`中指定`2.0`及以上的版本,并且可以指定如`a.b.X`格式的发行版次。你还可以指定带有`-betaN`后缀的beta版本。完整支持的版本格式如下:(括号代表可选信息) +你可以在`!require_version`中指定`2.0`及以上的版本,并且可以指定如`a.b`格式的发行版次。你还可以指定带有`-betaN`后缀的beta版本。完整支持的版本格式如下:(括号代表可选信息) ```plaintext -a.b[.X][-betaN] +a.b[-betaN] ``` +**注意:** 不支持带有bugfix版本信息的版本格式(`a.b.X`)。这是为了更好的兼容未来可能发布的其他`clitheme`变种(bugfix信息不一致)。 **注意:** 不支持指定带有`-devYYYYMMDD`后缀的版本号。这些版本包含了beta版本发行号码信息;你可以使用最新的beta版本号码代替。 \ No newline at end of file -- Gitee From 829df601694edb3693fd2fc429c30c430ddca867 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Thu, 2 Jan 2025 13:21:38 +0800 Subject: [PATCH 23/25] Update version information to `v2.0-beta3` --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3c26204..e5c793a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# clitheme Wiki文档(`v2.0-dev`) +# clitheme Wiki文档(`v2.0-beta3`) [**项目简介和样例展示**](./简介.md) @@ -10,7 +10,7 @@ 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 -- Gitee From 22a940f9c3b3336019732eb174e0c12968239453 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Thu, 2 Jan 2025 13:48:49 +0800 Subject: [PATCH 24/25] Fix incorrect position of example output for `foregroundonly` option --- ...232\344\271\211\346\226\207\344\273\266.md" | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 0faa79e..de0f300 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" @@ -78,6 +78,15 @@ - **注意:** 经测试,只有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)。 ### 同时指定多个匹配表达式 @@ -185,15 +194,6 @@ - `normalcmdmatch`:默认匹配机制;**用于重置/取消设定之前的设置** - `foregroundonly`:你也可以在限制条件中指定该选项,以应用于适用的替换规则。当取消设定或者重新设定新的限制条件时,该选项将会还原到之前的设定,**即使中途更改了该选项的设定**。 -```plaintext -$ clitheme-exec --foreground-stat bash -bash-3.2$ wef -! Foreground: False -bash: wef: command not found -! Foreground: True -bash-3.2$ -``` - **注意:** 无论选择了哪个匹配选项,如果用户输入的命令中第一个词语包含路径(指定可执行文件),`clitheme`会永远检查并尝试匹配程序名称。比如说,如果用户输入了`/usr/bin/python3 test.py`,`python3 test.py`也会被尝试匹配。 #### 样例: -- Gitee From 344ee29009537ba1f2c4d10d0d3377666e7f0330 Mon Sep 17 00:00:00 2001 From: swiftycode <10752639+swiftycode@user.noreply.gitee.com> Date: Thu, 2 Jan 2025 13:56:34 +0800 Subject: [PATCH 25/25] Small typo fix in documentation - Fix an incorrect word in a file --- .../2. \344\275\277\347\224\250clitheme-exec.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 07cccaf..03cac1d 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" @@ -42,7 +42,7 @@ $ sudo clitheme-exec some-command <...> ``` -如果你已经应用了主题,但是依然受到“没有设定主题”的提示,那是因为使用`sudo`时没有保留你的用户文件夹信息。你可以在`/etc/sudoers`文件中添加`Defaults env_keep += "HOME"`,或找到这一行并删除注释符号,以修复这个问题。 +如果你已经应用了主题,但是依然收到“没有设定主题”的提示,那是因为使用`sudo`时没有保留你的用户文件夹信息。你可以在`/etc/sudoers`文件中添加`Defaults env_keep += "HOME"`,或找到这一行并删除注释符号,以修复这个问题。 ## 可以设定的选项 -- Gitee