Skip to content

Commit

Permalink
v13.9.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed May 19, 2023
1 parent a726715 commit f8d0e38
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 77 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Easy to use for ghost development
## Command line arguments

```text
ghost terminal v13.9
ghost terminal v13.9.0.1
ghost_terminal [options]
options:
Expand Down Expand Up @@ -110,8 +110,9 @@ The rest of the events should only be defined if you want to change the default
Event after the command has been typed
- `Reference0`
Commands collected by the terminal
- Return value
Ignored, **but sakura scripts are executed normally**
- Return Value
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").
If you have defined "ShioriEcho.GetResult", the return value here will be ignored (**but Sakura Script will execute normally**).
- `ShioriEcho.GetResult`
Query for value result event
- Possible return value 1
Expand Down
5 changes: 3 additions & 2 deletions docs/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ up/down切换命令,鼠标右键快速粘贴,支持tab补全(如果人格
## 命令行参数

```text
ghost terminal v13.9
ghost terminal v13.9.0.1
ghost_terminal [options]
选项:
Expand Down Expand Up @@ -107,7 +107,8 @@ ghost_terminal通过`X-SSTP-PassThru-*`进行与人格间的信息沟通(见[
- `Reference0`
终端所收集到的命令
- 返值
忽略,**但言灵正常执行**
如果你没有定义`ShioriEcho.GetResult`,你可以在这里返回`ShioriEcho.GetResult`所支持的任意返回值,它们同样会被terminal正确处理(除了可能返回值3,在没有定义`ShioriEcho.GetResult`的情况下`ShioriEcho`中什么都不返回只会进入下一个命令的获取)
若你定义了`ShioriEcho.GetResult`,则这里的返回值将被忽略(**但言灵正常执行**
- `ShioriEcho.GetResult`
查询求值结果事件
- 可能返值1
Expand Down
7 changes: 4 additions & 3 deletions docs/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Easy to use for ghost development
## Command line arguments

```text
ghost terminal v13.9
ghost terminal v13.9.0.1
ghost_terminal [options]
options:
Expand Down Expand Up @@ -106,8 +106,9 @@ The rest of the events should only be defined if you want to change the default
Event after the command has been typed
- `Reference0`
Commands collected by the terminal
- Return value
Ignored, **but sakura scripts are executed normally**
- Return Value
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").
If you have defined "ShioriEcho.GetResult", the return value here will be ignored (**but Sakura Script will execute normally**).
- `ShioriEcho.GetResult`
Query for value result event
- Possible return value 1
Expand Down
13 changes: 7 additions & 6 deletions docs/README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ghost_terminalをシステム端末のように使用する
テキスト

```text
ghost terminal v13.9
ghost terminal v13.9.0.1
ghost_terminal [オプション]を指定します。
オプションで指定します。
Expand Down Expand Up @@ -109,7 +109,8 @@ ghost_terminalの出力は、プレーンテキストではなく、仮想端末
- `Reference0`
端末で収集したコマンド
- 戻り値
無視される、**ただし、sakura scriptは正常に実行される**
もし`ShioriEcho.GetResult`を定義していない場合、ここで`ShioriEcho.GetResult`でサポートされている任意の返値を返すことができます。これらの返値は、ターミナルによって正しく処理されます(ただし、戻り値3は、`ShioriEcho.GetResult`を定義せずに何も返さない場合、次のコマンド取得に入ります)。
`ShioriEcho.GetResult`を定義している場合、ここでの返値は無視されます(**ただし、sakura scriptは正常に実行される**)。
- `ShioriEcho.GetResult`
バリューリザルトイベントのクエリ
- 可能な戻り値 1
Expand Down Expand Up @@ -197,15 +198,15 @@ ghost_terminalの出力は、プレーンテキストではなく、仮想端末
コマンドヒストリーを取得したときのイベント
- `Reference0`
履歴コマンドのインデックス(逆順、開始値0)
- 戻り値
- 戻り値
- `X-SSTP-PassThru-Command` (オプション)
コマンドをこの内容で置き換える
- `ShioriEcho.CommandHistory.ForwardIndex`
ユーザが `` を押したときにインデックスが更新されるときのイベント
- `Reference0`
- `Reference0`
履歴コマンドのインデックス(逆順、開始値0)
- `Reference1`
- `Reference1`
`index`の値上がりが予想される量。
- 戻り値
- 戻り値
- `X-SSTP-PassThru-Index` (オプション)
インデックスをこの値に更新する
2 changes: 2 additions & 0 deletions ghost_terminal.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\builds\$(Configuration)\</OutDir>
<IntDir>.\builds\$(Configuration)\temp\</IntDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>.\builds\$(Configuration)\</OutDir>
Expand All @@ -96,6 +97,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>.\builds\$(Configuration)\</OutDir>
<IntDir>.\builds\$(Configuration)\temp\</IntDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
8 changes: 5 additions & 3 deletions src/Version.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#define VERSION_NUM1 13
#define VERSION_NUM2 9
#define VERSION_NUM3 0
#define VERSION_NUM4 1

#define STRINGIZER_HELPER(a) #a
#define STRINGIZER(a) STRINGIZER_HELPER(a)

#define VERSION_NUMS VERSION_NUM1,VERSION_NUM2
#define VERSION_STRING STRINGIZER(VERSION_NUM1) "." STRINGIZER(VERSION_NUM2)
#define VERSION_NUMS VERSION_NUM1,VERSION_NUM2,VERSION_NUM3,VERSION_NUM4
#define VERSION_STRING STRINGIZER(VERSION_NUM1) "." STRINGIZER(VERSION_NUM2) "." STRINGIZER(VERSION_NUM3) "." STRINGIZER(VERSION_NUM4)

#define VERSION_STRING_WITH_V "v" VERSION_STRING

#define RC_VERSION_STRING(num1,num2) STRINGIZER(num1) "." STRINGIZER(num2)
#define RC_VERSION_STRING(num1,num2,num3,num4) STRINGIZER(num1) "." STRINGIZER(num2) "." STRINGIZER(num3) "." STRINGIZER(num4)
139 changes: 82 additions & 57 deletions src/ghost_terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ghost_terminal final: public simple_terminal {

auto& data_until_login = data_until_login_saver.get();
auto& args_info = data_until_login.args_info;
auto& fira_code_font_found = data_until_login.fira_code_font_found;
//auto& fira_code_font_found = data_until_login.fira_code_font_found;
auto& LOCALAPPDATA = data_until_login.LOCALAPPDATA;

auto& ghost_path = args_info.ghost_path;
Expand Down Expand Up @@ -227,17 +227,17 @@ class ghost_terminal final: public simple_terminal {
else
//for each disable text split by ','
for(const auto& word: views::split(disable_text, L',')) {
const wstring_view disable_text{word.begin(), word.end()};
if(disable_text == L"root")
const wstring_view disable_text_type{word.begin(), word.end()};
if(disable_text_type == L"root")
disable_root_text = true;
else if(disable_text == L"event")
else if(disable_text_type == L"event")
disable_event_text = true;
else if(disable_text == L"WindowsTerminal")
else if(disable_text_type == L"WindowsTerminal")
disable_WindowsTerminal_text = true;
else if(disable_text == L"FiraCode")
else if(disable_text_type == L"FiraCode")
disable_FiraCode_text = true;
else if(disable_text.size())
err << SET_GRAY "Ignore unknown disable text: " << SET_PURPLE << disable_text << RESET_COLOR << endline;
else if(disable_text_type.size())
err << SET_GRAY "Ignore unknown disable text: " SET_PURPLE << disable_text_type << RESET_COLOR << endline;
}
}
else if(argv[i] == L"-h" || argv[i] == L"--help") { //help
Expand Down Expand Up @@ -652,13 +652,16 @@ class ghost_terminal final: public simple_terminal {
if(!disable_FiraCode_text) {
//通过EnumFontFamiliesEx遍历字体,找到一个以Fira Code开头的字体就不提示了
//如果找不到,就提示一下
LOGFONTW lf;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfFaceName[0] = L'\0';
HDC hdc = GetDC(NULL);
if(hdc) {
EnumFontFamiliesExW(hdc, &lf, (FONTENUMPROCW)FiraCode_Finder, (LPARAM)this, 0);
ReleaseDC(NULL, hdc);
{
LOGFONTW lf;//可以掠过0初始化:以下3个必须项目已被正确赋值
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfFaceName[0] = L'\0';
lf.lfPitchAndFamily = 0;
HDC hdc = GetDC(NULL);
if(hdc) {
EnumFontFamiliesExW(hdc, &lf, (FONTENUMPROCW)FiraCode_Finder, (LPARAM)this, 0);
ReleaseDC(NULL, hdc);
}
}
if(!fira_code_font_found)
out << SET_GRAY "You can use " SET_GREEN "Fira Code" SET_GRAY " font for a better experience in terminal and editor.\n"
Expand Down Expand Up @@ -749,7 +752,7 @@ class ghost_terminal final: public simple_terminal {
if(!linker.Has_Event(L"ShioriEcho.GetResult")) {
able_get_result = 0;
err << "Event " SET_GREEN "ShioriEcho.GetResult" SET_GRAY " Not defined.\n"
"Terminal will not send get result event to your ghost and will not echo result.\n\n";
"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";
}
if(!linker.Has_Event(L"ShioriEcho.CommandComplete")) {
able_command_complete = 0;
Expand Down Expand Up @@ -798,53 +801,69 @@ class ghost_terminal final: public simple_terminal {
}
}
//terminal runnning
enum terminal_result_status {
Continue, Wait, End
};
terminal_result_status result_handle(const SSTP_ret_t& Result) {
{
const auto code = Result.get_code();
if(code == 404 || code == -1) {
err << RED_TEXT("Lost connection with target ghost.") << endline;
exit(1);
}
}
if(Result.has(L"Special")) {
out << do_transfer(Result[L"Special"]) << endline;
return Continue;
}
else if(Result.has(L"Result")) {
out << Result[L"Result"] << endline;
if(Result.has(L"Type"))
out << "Type: " << Result[L"Type"] << endline;
return Continue;
}
else if(Result.has(L"Type")) {
out << "Has " GREEN_TEXT("Type") " but no " GREEN_TEXT("Result") " here:\n "
<< to_ansi_colored_wstring(Result) << endline;
return Continue;
}
else if(Result.has(L"Status")) {
const auto& status = Result[L"Status"];
if(status == L"End")
return End;
else if(status == L"Continue")
return Continue;
}
else if(able_get_result)
return Wait;
else
return Continue;
}
virtual bool terminal_run(const wstring& command) override {
linker.NOTYFY({{L"Event", L"ShioriEcho"},
auto Result = linker.NOTYFY({{L"Event", L"ShioriEcho"},
{L"ID", ghost_uid},
{L"Reference0", command}});
if(able_get_result)
try {
floop {
auto Result = linker.NOTYFY({{L"Event", L"ShioriEcho.GetResult"}});
{
const auto code = Result.get_code();
if(code == 404 || code == -1) {
err << RED_TEXT("Lost connection with target ghost.") << endline;
exit(1);
}
}
if(Result.has(L"Special")) {
out << do_transfer(Result[L"Special"]) << endline;
break;
}
else if(Result.has(L"Result")) {
out << Result[L"Result"] << endline;
if(Result.has(L"Type"))
out << "Type: " << Result[L"Type"] << endline;
break;
}
else if(Result.has(L"Type")) {
out << "Has " GREEN_TEXT("Type") " but no " GREEN_TEXT("Result") " here:\n "
<< to_ansi_colored_wstring(Result) << endline;
break;
}
else {
Sleep(1000);
}
if(Result.has(L"Status")) {
const auto& status = Result[L"Status"];
if(status == L"End")
return false;
else if(status == L"Continue")
break;
}
floop {
auto GetResult = linker.NOTYFY({{L"Event", L"ShioriEcho.GetResult"}});
switch(result_handle(GetResult)) {
case Continue:
return true;
case Wait:
Sleep(1000);
break;
case End:
return false;
}
}
catch(const std::exception& a) {
err << RED_OUTPUT(a.what()) << endline;
exit(1);
else {
switch(result_handle(Result)) {
case Continue:
return true;
default:
return false;
}
return true;
}
}
//terminal exit
virtual void terminal_exit() override {
Expand Down Expand Up @@ -978,5 +997,11 @@ class ghost_terminal final: public simple_terminal {
};

int wmain(int argc, wchar_t* argv[]) {
return ghost_terminal{}(argc, argv),0;
try {
return ghost_terminal{}(argc, argv), 0;
}
catch(const std::exception& a) {
err << RED_OUTPUT(a.what()) << endline;
exit(1);
}
}
2 changes: 1 addition & 1 deletion src/my-gists
4 changes: 2 additions & 2 deletions src/resource/ghost_terminal.rc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ BEGIN
BLOCK "000004b0"
BEGIN
VALUE "FileDescription", "terminal for every ghost!"
VALUE "FileVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2)
VALUE "FileVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2,VERSION_NUM3,VERSION_NUM4)
VALUE "OriginalFilename", "ghost_terminal.exe"
VALUE "ProductVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2)
VALUE "ProductVersion", RC_VERSION_STRING(VERSION_NUM1,VERSION_NUM2,VERSION_NUM3,VERSION_NUM4)
VALUE "ProductName", "ghost terminal"
END
END
Expand Down

0 comments on commit f8d0e38

Please sign in to comment.