Skip to content

Commit 1f59b15

Browse files
committed
add: 未知的终端命令也过滤一下,到时候不执行就好了,不要显示出来
1 parent d226fbe commit 1f59b15

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

llcomNext/LLCOM/Models/TerminalCommand.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace LLCOM.Models;
66
public enum TerminalCommand
77
{
88
None, //没匹配上任何命令
9+
Unknown, //未知命令
910

1011
Bs, //退格 0x08
1112
Ht, //水平制表符 0x09
@@ -159,6 +160,8 @@ public static ((TerminalCommand, (int, int)), int) Do(ReadOnlySpan<char> slice)
159160
return ((mr, (code,0)), i);
160161
}
161162
break;
163+
default:
164+
return ((TerminalCommand.Unknown, (0,0)), i); //未知命令
162165
}
163166
//检查是不是匹配\x1b[{n};{m}H
164167
if(cmd != ';')

llcomNext/llcomTest/TerminalCommandTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public void TestMultiple()
4141
("\x1b[7m", TerminalCommand.Reverse, (7, 0), 4),
4242
("\x1b[31m", TerminalCommand.ForegroundColor, (31, 0), 5),
4343
("\x1b[43m", TerminalCommand.BackgroundColor, (43, 0), 5),
44+
("\x1b[2004l", TerminalCommand.Unknown, (0, 0), 7),
45+
("\x1b[2004h", TerminalCommand.Unknown, (0, 0), 7),
4446
};
4547

4648
foreach (var (input, expectedCmd, expectedPos, expectedLength) in testCases)

0 commit comments

Comments
 (0)