| %= VT.bat 批处理控制台虚拟终端序列库 =% |
| %= 请使用 GB2312 编码保存 =% |
| %= 参考:learn.microsoft.com/zh-cn/windows/console/console-virtual-terminal-sequences =% |
| |
| %================================================================% |
| %= 初始化 ESC 字符和基本引导序列 =% |
| %================================================================% |
| @For /F "Delims=#" %%_ in ('Prompt #$E# ^& Echo on ^& For %%$ in ^(1^) Do DosKey') Do @Set "VT.ESC=%%_" |
| |
| @Set VT.CSI=%VT.ESC%[ |
| |
| %================================================================% |
| %= 标准颜色 =% |
| %================================================================% |
| |
| @Set VT.Colors.Black=0 |
| @Set VT.Colors.Red=1 |
| @Set VT.Colors.Green=2 |
| @Set VT.Colors.Yellow=3 |
| @Set VT.Colors.Blue=4 |
| @Set VT.Colors.Magenta=5 |
| @Set VT.Colors.Cyan=6 |
| @Set VT.Colors.White=7 |
| @Set VT.Colors.Default=9 |
| |
| %================================================================% |
| %= 简单光标定位 =% |
| %================================================================% |
| |
| @Set VTInline.Cursor.ReverseIndex=%VT.ESC%M |
| @Set VTInline.RI=%VTInline.Cursor.ReverseIndex% |
| |
| @Set VTInline.Cursor.SaveCursorPosition=%VT.ESC%7 |
| @Set VTInline.DECSC=%VTInline.Cursor.SaveCursorPosition% |
| |
| @Set VTInline.Cursor.RestoreCursorPosition=%VT.ESC%8 |
| @Set VTInline.DECSR=%VTInline.Cursor.RestoreCursorPosition% |
| |
| %================================================================% |
| %= 光标定位 =% |
| %================================================================% |
| |
| @Set VTInline.Cursor.Up=%VT.CSI%#n |
| @Set VTInline.CUU=%VTInline.Cursor.Up% |
| |
| @Set VTInline.Cursor.Down=%VT.CSI%#n |
| @Set VTInline.CUD=%VTInline.Cursor.Down% |
| |
| @Set VTInline.Cursor.Forward=%VT.CSI%#n |
| @Set VTInline.CUF=%VTInline.Cursor.Forward% |
| |
| @Set VTInline.Cursor.Backward=%VT.CSI%#n |
| @Set VTInline.CUB=%VTInline.Cursor.Backward% |
| |
| @Set VTInline.Cursor.NextLine=%VT.CSI%#n |
| @Set VTInline.CNL=%VTInline.Cursor.NextLine% |
| |
| @Set VTInline.Cursor.PreviousLine=%VT.CSI%#n |
| @Set VTInline.CPL=%VTInline.Cursor.PreviousLine% |
| |
| @Set VTInline.Cursor.HorizontalAbsolute=%VT.CSI%#n |
| @Set VTInline.CHA=%VTInline.Cursor.HorizontalAbsolute% |
| |
| @Set VTInline.VerticalLinePositionAbsolute=%VT.CSI%#n |
| @Set VTInline.VPA=%VTInline.VerticalLinePositionAbsolute% |
| |
| @Set VTInline.Cursor.Position=%VT.CSI%#y |
| @Set VTInline.CUP=%VTInline.Cursor.Position% |
| |
| @Set VTInline.Cursor.HorizontalVerticalPosition=%VT.CSI%#y |
| @Set VTInline.HVP=%VTInline.Cursor.HorizontalVerticalPosition% |
| |
| @Set VTInline.Cursor.SaveCursorAnsiSysEmulation=%VT.CSI%s |
| @Set VTInline.ANSISYSSC=%VTInline.Cursor.SaveCursorAnsiSysEmulation% |
| |
| @Set VTInline.Cursor.RestoreCursorAnsiSysEmulation=%VT.CSI%u |
| @Set VTInline.ANSISYSRC=%VTInline.Cursor.RestoreCursorAnsiSysEmulation% |
| |
| %================================================================% |
| %= 光标可见性 =% |
| %================================================================% |
| |
| @Set VTInline.TextCursor.EnableBlinking=%VT.CSI%?12h |
| @Set VTInline.TextCursor.DisableBlinking=%VT.CSI%?12l |
| @Set VTInline.TextCursor.EnableModeShow=%VT.CSI%?25h |
| @Set VTInline.TextCursor.EnableModeHide=%VT.CSI%?25l |
| |
| %================================================================% |
| %= 光标形状 =% |
| %================================================================% |
| |
| @Set VTInline.TextCursor.UserShape=%VT.CSI%0 q |
| @Set VTInline.TextCursor.BlinkingBlock=%VT.CSI%1 q |
| @Set VTInline.TextCursor.SteadyBlock=%VT.CSI%2 q |
| @Set VTInline.TextCursor.BlinkingUnderline=%VT.CSI%3 q |
| @Set VTInline.TextCursor.SteadyUnderline=%VT.CSI%4 q |
| @Set VTInline.TextCursor.BlinkingBar=%VT.CSI%5 q |
| @Set VTInline.TextCursor.SteadyBar=%VT.CSI%6 q |
| |
| %================================================================% |
| %= 视区定位 =% |
| %================================================================% |
| |
| @Set VTInline.Viewport.ScrollUp=%VT.CSI%#n |
| @Set VTInline.SU=%VTInline.Viewport.ScrollUp% |
| |
| @Set VTInline.Viewport.ScrollDown=%VT.CSI%#n |
| @Set VTInline.SD=%VTInline.Viewport.ScrollDown% |
| |
| %================================================================% |
| %= 文本修改 =% |
| %================================================================% |
| |
| @Set VTInline.Text.InsertCharacter=%VT.CSI%#n |
| @Set VTInline.ICH=%VTInline.Text.InsertCharacter% |
| |
| @Set VTInline.Text.DeleteCharacter=%VT.CSI%#n |
| @Set VTInline.DCH=%VTInline.Text.DeleteCharacter% |
| |
| @Set VTInline.Text.EraseCharacter=%VT.CSI%#n |
| @Set VTInline.ECH=%VTInline.Text.EraseCharacter% |
| |
| @Set VTInline.Text.InsertLine=%VT.CSI%#n |
| @Set VTInline.IL=%VTInline.Text.InsertLine% |
| |
| @Set VTInline.Text.DeleteLine=%VT.CSI%#n |
| @Set VTInline.DL=%VTInline.Text.DeleteLine% |
| |
| @Set VTInline.Text.EraseInDisplay=%VT.CSI%#n |
| @Set VTInline.ED=%VTInline.Text.EraseInDisplay% |
| |
| @Set VTInline.Text.EraseInLine=%VT.CSI%#n |
| @Set VTInline.EL=%VTInline.Text.EraseInLine% |
| |
| %================================================================% |
| %= 文本格式 =% |
| %================================================================% |
| |
| @Set VTInline.Formatting.SetGraphicsRendition=%VT.CSI%#n |
| @Set VTInline.SGR=%VTInline.Formatting.SetGraphicsRendition% |
| |
| @Set VTInline.Formatting.Default=%VTInline.SGR: |
| @Set VTInline.Formatting.BoldOrBright=%VTInline.SGR: |
| @Set VTInline.Formatting.NoBoldOrBright=%VTInline.SGR: |
| @Set VTInline.Formatting.Underline=%VTInline.SGR: |
| @Set VTInline.Formatting.NoUnderline=%VTInline.SGR: |
| @Set VTInline.Formatting.Negative=%VTInline.SGR: |
| @Set VTInline.Formatting.NoNegative=%VTInline.SGR: |
| @Set VTInline.Formatting.Positive=%VTInline.SGR: |
| |
| @Set VTInline.Formatting.Foreground=%VTInline.SGR: |
| @Set VTInline.Formatting.Background=%VTInline.SGR: |
| |
| @Set VTInline.Formatting.BrightForeground=%VTInline.SGR: |
| @Set VTInline.Formatting.BrightBackground=%VTInline.SGR: |
| |
| @Set VTInline.Formatting.ForegroundRGB=%VTInline.SGR: |
| @Set VTInline.Formatting.BackgroundRGB=%VTInline.SGR: |
| |
| @Set VTInline.Formatting.Foreground256=%VTInline.SGR: |
| @Set VTInline.Formatting.Background256=%VTInline.SGR: |
| |
| @Set VTInline.Formatting.Foreground88=%VTInline.SGR: |
| @Set VTInline.Formatting.Background88=%VTInline.SGR: |
| |
| %================================================================% |
| %= 屏幕颜色(索引):由于行为似乎不能被 CMD 实现,所以不支持 =% |
| %================================================================% |
| |
| %================================================================% |
| %= 模式更改:由于行为似乎不能被 CMD 实现,所以不支持 =% |
| %================================================================% |
| |
| %================================================================% |
| %= 查询状态:由于行为似乎不能被 CMD 完全实现,所以不支持 =% |
| %================================================================% |
| |
| %================================================================% |
| %= 制表符 =% |
| %================================================================% |
| |
| @Set VTInline.Tabs.HorizontalTabSet=%VT.ESC%H |
| @Set VTInline.Tabs.HTS=%VTInline.Tabs.HorizontalTabSet% |
| |
| @Set VTInline.Tabs.CursorHorizontalForwardTab=%VT.CSI%#n |
| @Set VTInline.CHT=%VTInline.Tabs.CursorHorizontalForwardTab% |
| |
| @Set VTInline.Tabs.CursorBackwardsTab=%VT.CSI%#n |
| @Set VTInline.CBT=%VTInline.Tabs.CursorBackwardsTab% |
| |
| @Set VTInline.Tabs.TabClearCurrentColumn=%VT.CSI%0g |
| @Set VTInline.Tabs.TabClearAllColumns=%VT.CSI%3g |
| |
| %================================================================% |
| %= 指定字符集 =% |
| %================================================================% |
| |
| @Set VTInline.CharacterSet.DEC=%VT.ESC%(0 |
| @Set VTInline.CharacterSet.ASCII=%VT.ESC%(B |
| |
| %================================================================% |
| %= 滚动边距 =% |
| %================================================================% |
| |
| @Set VTInline.SetScrollingRegion=%VT.CSI%#t |
| @Set VTInline.DECSTBM=%VTInline.SetScrollingRegion% |
| |
| %================================================================% |
| %= 窗口标题:由于有 Title 命令,没有必要实现 =% |
| %================================================================% |
| |
| %================================================================% |
| %= 备用屏幕缓冲区 =% |
| %================================================================% |
| |
| @Set VTInline.Buffers.UseAlternateScreenBuffer=%VT.CSI%?1049h |
| @Set VTInline.Buffers.UseMainScreenBuffer=%VT.CSI%?1049l |
| |
| %================================================================% |
| %= 窗口宽度:由于行为似乎不能被 CMD 实现,所以不支持 =% |
| %================================================================% |
| |
| %================================================================% |
| %= 软重置 =% |
| %================================================================% |
| |
| @Set VTInline.SoftReset=%VT.CSI%!p |
| @Set VTInline.DECSTR=%VTInline.SoftReset% |
| |
| %================================================================% |
| %= 输入序列:由于行为似乎不能被 CMD 实现,所以不支持 =% |
| %================================================================% |
| |
| %================================================================% |
| %= 生成命令版函数 =% |
| %================================================================% |
| |
| @For /F "delims=. tokens=1,*" %%I in ('@Set VTInline') Do @( |
| @For /F "delims== tokens=1,*" %%i in ('Echo;%%J') Do @( |
| @Set "VT.%%i=@Set /P="%%j"< Nul" |
| ) |
| ) |
| |
| %================================================================% |
| %= 软重置 =% |
| %================================================================% |
| |
| %VT.SoftReset%COPY |