这个不起作用(在 Cmd-Box 中的 Windows 上):
import 'dart:io';
void main() {
print("Hello, World!");
Process.start('cls', [], runInShell: true).then((process) {
stdout.addStream(process.stdout);
stderr.addStream(process.stderr);
});
}
Run Code Online (Sandbox Code Playgroud)
Gün*_*uer 13
编辑
这似乎有答案为什么它在 Windows 上不起作用如何使 win32 控制台识别 ANSI/VT100 转义序列?
原来的
if(Platform.isWindows) {
// not tested, I don't have Windows
// may not to work because 'cls' is an internal command of the Windows shell
// not an executeable
print(Process.runSync("cls", [], runInShell: true).stdout);
} else {
print(Process.runSync("clear", [], runInShell: true).stdout);
}
Run Code Online (Sandbox Code Playgroud)
或者
print("\x1B[2J\x1B[0;0H"); // clear entire screen, move cursor to 0;0
print("xxx") // just to show where the cursor is
// http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes
Run Code Online (Sandbox Code Playgroud)
或者
for(int i = 0; i < stdout.terminalLines; i++) {
stdout.writeln();
}
Run Code Online (Sandbox Code Playgroud)
然后光标位置在底部。您必须在某些输出后添加换行符才能将其移至顶部。
| 归档时间: |
|
| 查看次数: |
3150 次 |
| 最近记录: |