Skip to content

Commit f8d0e38

Browse files
committed
v13.9.0.1
1 parent a726715 commit f8d0e38

File tree

9 files changed

+110
-77
lines changed

9 files changed

+110
-77
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Easy to use for ghost development
1717
## Command line arguments
1818

1919
```text
20-
ghost terminal v13.9
20+
ghost terminal v13.9.0.1
2121
2222
ghost_terminal [options]
2323
options:
@@ -110,8 +110,9 @@ The rest of the events should only be defined if you want to change the default
110110
Event after the command has been typed
111111
- `Reference0`
112112
Commands collected by the terminal
113-
- Return value
114-
Ignored, **but sakura scripts are executed normally**
113+
- Return Value
114+
If you have not defined "ShioriEcho.GetResult", you can return any of the return values supported by "ShioriEcho.GetResult" here, which will also be correctly processed by the terminal (except for return value 3, which will enter the next command acquisition when "ShioriEcho" does not return anything without defining "ShioriEcho.GetResult").
115+
If you have defined "ShioriEcho.GetResult", the return value here will be ignored (**but Sakura Script will execute normally**).
115116
- `ShioriEcho.GetResult`
116117
Query for value result event
117118
- Possible return value 1

docs/README_CN.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ up/down切换命令,鼠标右键快速粘贴,支持tab补全(如果人格
1313
## 命令行参数
1414

1515
```text
16-
ghost terminal v13.9
16+
ghost terminal v13.9.0.1
1717
1818
ghost_terminal [options]
1919
选项:
@@ -107,7 +107,8 @@ ghost_terminal通过`X-SSTP-PassThru-*`进行与人格间的信息沟通(见[
107107
- `Reference0`
108108
终端所收集到的命令
109109
- 返值
110-
忽略,**但言灵正常执行**
110+
如果你没有定义`ShioriEcho.GetResult`,你可以在这里返回`ShioriEcho.GetResult`所支持的任意返回值,它们同样会被terminal正确处理(除了可能返回值3,在没有定义`ShioriEcho.GetResult`的情况下`ShioriEcho`中什么都不返回只会进入下一个命令的获取)
111+
若你定义了`ShioriEcho.GetResult`,则这里的返回值将被忽略(**但言灵正常执行**
111112
- `ShioriEcho.GetResult`
112113
查询求值结果事件
113114
- 可能返值1

docs/README_EN.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Easy to use for ghost development
1313
## Command line arguments
1414

1515
```text
16-
ghost terminal v13.9
16+
ghost terminal v13.9.0.1
1717
1818
ghost_terminal [options]
1919
options:
@@ -106,8 +106,9 @@ The rest of the events should only be defined if you want to change the default
106106
Event after the command has been typed
107107
- `Reference0`
108108
Commands collected by the terminal
109-
- Return value
110-
Ignored, **but sakura scripts are executed normally**
109+
- Return Value
110+
If you have not defined "ShioriEcho.GetResult", you can return any of the return values supported by "ShioriEcho.GetResult" here, which will also be correctly processed by the terminal (except for return value 3, which will enter the next command acquisition when "ShioriEcho" does not return anything without defining "ShioriEcho.GetResult").
111+
If you have defined "ShioriEcho.GetResult", the return value here will be ignored (**but Sakura Script will execute normally**).
111112
- `ShioriEcho.GetResult`
112113
Query for value result event
113114
- Possible return value 1

docs/README_JP.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ghost_terminalをシステム端末のように使用する
1515
テキスト
1616

1717
```text
18-
ghost terminal v13.9
18+
ghost terminal v13.9.0.1
1919
2020
ghost_terminal [オプション]を指定します。
2121
オプションで指定します。
@@ -109,7 +109,8 @@ ghost_terminalの出力は、プレーンテキストではなく、仮想端末
109109
- `Reference0`
110110
端末で収集したコマンド
111111
- 戻り値
112-
無視される、**ただし、sakura scriptは正常に実行される**
112+
もし`ShioriEcho.GetResult`を定義していない場合、ここで`ShioriEcho.GetResult`でサポートされている任意の返値を返すことができます。これらの返値は、ターミナルによって正しく処理されます(ただし、戻り値3は、`ShioriEcho.GetResult`を定義せずに何も返さない場合、次のコマンド取得に入ります)。
113+
`ShioriEcho.GetResult`を定義している場合、ここでの返値は無視されます(**ただし、sakura scriptは正常に実行される**)。
113114
- `ShioriEcho.GetResult`
114115
バリューリザルトイベントのクエリ
115116
- 可能な戻り値 1
@@ -197,15 +198,15 @@ ghost_terminalの出力は、プレーンテキストではなく、仮想端末
197198
コマンドヒストリーを取得したときのイベント
198199
- `Reference0`
199200
履歴コマンドのインデックス(逆順、開始値0)
200-
- 戻り値
201+
- 戻り値
201202
- `X-SSTP-PassThru-Command` (オプション)
202203
コマンドをこの内容で置き換える
203204
- `ShioriEcho.CommandHistory.ForwardIndex`
204205
ユーザが `` を押したときにインデックスが更新されるときのイベント
205-
- `Reference0`
206+
- `Reference0`
206207
履歴コマンドのインデックス(逆順、開始値0)
207-
- `Reference1`
208+
- `Reference1`
208209
`index`の値上がりが予想される量。
209-
- 戻り値
210+
- 戻り値
210211
- `X-SSTP-PassThru-Index` (オプション)
211212
インデックスをこの値に更新する

ghost_terminal.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
8989
<OutDir>.\builds\$(Configuration)\</OutDir>
9090
<IntDir>.\builds\$(Configuration)\temp\</IntDir>
91+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
9192
</PropertyGroup>
9293
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
9394
<OutDir>.\builds\$(Configuration)\</OutDir>
@@ -96,6 +97,7 @@
9697
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
9798
<OutDir>.\builds\$(Configuration)\</OutDir>
9899
<IntDir>.\builds\$(Configuration)\temp\</IntDir>
100+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
99101
</PropertyGroup>
100102
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
101103
<ClCompile>

src/Version.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#define VERSION_NUM1 13
22
#define VERSION_NUM2 9
3+
#define VERSION_NUM3 0
4+
#define VERSION_NUM4 1
35

46
#define STRINGIZER_HELPER(a) #a
57
#define STRINGIZER(a) STRINGIZER_HELPER(a)
68

7-
#define VERSION_NUMS VERSION_NUM1,VERSION_NUM2
8-
#define VERSION_STRING STRINGIZER(VERSION_NUM1) "." STRINGIZER(VERSION_NUM2)
9+
#define VERSION_NUMS VERSION_NUM1,VERSION_NUM2,VERSION_NUM3,VERSION_NUM4
10+
#define VERSION_STRING STRINGIZER(VERSION_NUM1) "." STRINGIZER(VERSION_NUM2) "." STRINGIZER(VERSION_NUM3) "." STRINGIZER(VERSION_NUM4)
911

1012
#define VERSION_STRING_WITH_V "v" VERSION_STRING
1113

12-
#define RC_VERSION_STRING(num1,num2) STRINGIZER(num1) "." STRINGIZER(num2)
14+
#define RC_VERSION_STRING(num1,num2,num3,num4) STRINGIZER(num1) "." STRINGIZER(num2) "." STRINGIZER(num3) "." STRINGIZER(num4)

src/ghost_terminal.cpp

Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ghost_terminal final: public simple_terminal {
133133

134134
auto& data_until_login = data_until_login_saver.get();
135135
auto& args_info = data_until_login.args_info;
136-
auto& fira_code_font_found = data_until_login.fira_code_font_found;
136+
//auto& fira_code_font_found = data_until_login.fira_code_font_found;
137137
auto& LOCALAPPDATA = data_until_login.LOCALAPPDATA;
138138

139139
auto& ghost_path = args_info.ghost_path;
@@ -227,17 +227,17 @@ class ghost_terminal final: public simple_terminal {
227227
else
228228
//for each disable text split by ','
229229
for(const auto& word: views::split(disable_text, L',')) {
230-
const wstring_view disable_text{word.begin(), word.end()};
231-
if(disable_text == L"root")
230+
const wstring_view disable_text_type{word.begin(), word.end()};
231+
if(disable_text_type == L"root")
232232
disable_root_text = true;
233-
else if(disable_text == L"event")
233+
else if(disable_text_type == L"event")
234234
disable_event_text = true;
235-
else if(disable_text == L"WindowsTerminal")
235+
else if(disable_text_type == L"WindowsTerminal")
236236
disable_WindowsTerminal_text = true;
237-
else if(disable_text == L"FiraCode")
237+
else if(disable_text_type == L"FiraCode")
238238
disable_FiraCode_text = true;
239-
else if(disable_text.size())
240-
err << SET_GRAY "Ignore unknown disable text: " << SET_PURPLE << disable_text << RESET_COLOR << endline;
239+
else if(disable_text_type.size())
240+
err << SET_GRAY "Ignore unknown disable text: " SET_PURPLE << disable_text_type << RESET_COLOR << endline;
241241
}
242242
}
243243
else if(argv[i] == L"-h" || argv[i] == L"--help") { //help
@@ -652,13 +652,16 @@ class ghost_terminal final: public simple_terminal {
652652
if(!disable_FiraCode_text) {
653653
//通过EnumFontFamiliesEx遍历字体,找到一个以Fira Code开头的字体就不提示了
654654
//如果找不到,就提示一下
655-
LOGFONTW lf;
656-
lf.lfCharSet = DEFAULT_CHARSET;
657-
lf.lfFaceName[0] = L'\0';
658-
HDC hdc = GetDC(NULL);
659-
if(hdc) {
660-
EnumFontFamiliesExW(hdc, &lf, (FONTENUMPROCW)FiraCode_Finder, (LPARAM)this, 0);
661-
ReleaseDC(NULL, hdc);
655+
{
656+
LOGFONTW lf;//可以掠过0初始化:以下3个必须项目已被正确赋值
657+
lf.lfCharSet = DEFAULT_CHARSET;
658+
lf.lfFaceName[0] = L'\0';
659+
lf.lfPitchAndFamily = 0;
660+
HDC hdc = GetDC(NULL);
661+
if(hdc) {
662+
EnumFontFamiliesExW(hdc, &lf, (FONTENUMPROCW)FiraCode_Finder, (LPARAM)this, 0);
663+
ReleaseDC(NULL, hdc);
664+
}
662665
}
663666
if(!fira_code_font_found)
664667
out << SET_GRAY "You can use " SET_GREEN "Fira Code" SET_GRAY " font for a better experience in terminal and editor.\n"
@@ -749,7 +752,7 @@ class ghost_terminal final: public simple_terminal {
749752
if(!linker.Has_Event(L"ShioriEcho.GetResult")) {
750753
able_get_result = 0;
751754
err << "Event " SET_GREEN "ShioriEcho.GetResult" SET_GRAY " Not defined.\n"
752-
"Terminal will not send get result event to your ghost and will not echo result.\n\n";
755+
"Terminal will not send get result event to your ghost and will not echo the result if your ghost does not returns " SET_PURPLE "Result&Type" SET_GRAY " in the " SET_GREEN "ShioriEcho" SET_GRAY " event.\n\n";
753756
}
754757
if(!linker.Has_Event(L"ShioriEcho.CommandComplete")) {
755758
able_command_complete = 0;
@@ -798,53 +801,69 @@ class ghost_terminal final: public simple_terminal {
798801
}
799802
}
800803
//terminal runnning
804+
enum terminal_result_status {
805+
Continue, Wait, End
806+
};
807+
terminal_result_status result_handle(const SSTP_ret_t& Result) {
808+
{
809+
const auto code = Result.get_code();
810+
if(code == 404 || code == -1) {
811+
err << RED_TEXT("Lost connection with target ghost.") << endline;
812+
exit(1);
813+
}
814+
}
815+
if(Result.has(L"Special")) {
816+
out << do_transfer(Result[L"Special"]) << endline;
817+
return Continue;
818+
}
819+
else if(Result.has(L"Result")) {
820+
out << Result[L"Result"] << endline;
821+
if(Result.has(L"Type"))
822+
out << "Type: " << Result[L"Type"] << endline;
823+
return Continue;
824+
}
825+
else if(Result.has(L"Type")) {
826+
out << "Has " GREEN_TEXT("Type") " but no " GREEN_TEXT("Result") " here:\n "
827+
<< to_ansi_colored_wstring(Result) << endline;
828+
return Continue;
829+
}
830+
else if(Result.has(L"Status")) {
831+
const auto& status = Result[L"Status"];
832+
if(status == L"End")
833+
return End;
834+
else if(status == L"Continue")
835+
return Continue;
836+
}
837+
else if(able_get_result)
838+
return Wait;
839+
else
840+
return Continue;
841+
}
801842
virtual bool terminal_run(const wstring& command) override {
802-
linker.NOTYFY({{L"Event", L"ShioriEcho"},
843+
auto Result = linker.NOTYFY({{L"Event", L"ShioriEcho"},
803844
{L"ID", ghost_uid},
804845
{L"Reference0", command}});
805846
if(able_get_result)
806-
try {
807-
floop {
808-
auto Result = linker.NOTYFY({{L"Event", L"ShioriEcho.GetResult"}});
809-
{
810-
const auto code = Result.get_code();
811-
if(code == 404 || code == -1) {
812-
err << RED_TEXT("Lost connection with target ghost.") << endline;
813-
exit(1);
814-
}
815-
}
816-
if(Result.has(L"Special")) {
817-
out << do_transfer(Result[L"Special"]) << endline;
818-
break;
819-
}
820-
else if(Result.has(L"Result")) {
821-
out << Result[L"Result"] << endline;
822-
if(Result.has(L"Type"))
823-
out << "Type: " << Result[L"Type"] << endline;
824-
break;
825-
}
826-
else if(Result.has(L"Type")) {
827-
out << "Has " GREEN_TEXT("Type") " but no " GREEN_TEXT("Result") " here:\n "
828-
<< to_ansi_colored_wstring(Result) << endline;
829-
break;
830-
}
831-
else {
832-
Sleep(1000);
833-
}
834-
if(Result.has(L"Status")) {
835-
const auto& status = Result[L"Status"];
836-
if(status == L"End")
837-
return false;
838-
else if(status == L"Continue")
839-
break;
840-
}
847+
floop {
848+
auto GetResult = linker.NOTYFY({{L"Event", L"ShioriEcho.GetResult"}});
849+
switch(result_handle(GetResult)) {
850+
case Continue:
851+
return true;
852+
case Wait:
853+
Sleep(1000);
854+
break;
855+
case End:
856+
return false;
841857
}
842858
}
843-
catch(const std::exception& a) {
844-
err << RED_OUTPUT(a.what()) << endline;
845-
exit(1);
859+
else {
860+
switch(result_handle(Result)) {
861+
case Continue:
862+
return true;
863+
default:
864+
return false;
846865
}
847-
return true;
866+
}
848867
}
849868
//terminal exit
850869
virtual void terminal_exit() override {
@@ -978,5 +997,11 @@ class ghost_terminal final: public simple_terminal {
978997
};
979998

980999
int wmain(int argc, wchar_t* argv[]) {
981-
return ghost_terminal{}(argc, argv),0;
1000+
try {
1001+
return ghost_terminal{}(argc, argv), 0;
1002+
}
1003+
catch(const std::exception& a) {
1004+
err << RED_OUTPUT(a.what()) << endline;
1005+
exit(1);
1006+
}
9821007
}

src/resource/ghost_terminal.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ BEGIN
3838
BLOCK "000004b0"
3939
BEGIN
4040
VALUE "FileDescription", "terminal for every ghost!"
41-
VALUE "FileVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2)
41+
VALUE "FileVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2,VERSION_NUM3,VERSION_NUM4)
4242
VALUE "OriginalFilename", "ghost_terminal.exe"
43-
VALUE "ProductVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2)
43+
VALUE "ProductVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2,VERSION_NUM3,VERSION_NUM4)
4444
VALUE "ProductName", "ghost terminal"
4545
END
4646
END

0 commit comments

Comments
 (0)