윈도우에서 cmd의 색상이 제대로 안나오는 문제 수정

This commit is contained in:
leedongmyung[desktop] 2023-11-05 11:17:26 +09:00
parent d04f43591f
commit 5d78499f3f

View file

@ -103,12 +103,12 @@ class CLI {
static String style(String message,
{Color? color, Color? background, Style? style}) {
if (Platform.isWindows) {
return message;
} else {
return printer.getStyle(message,
color: color, background: background, style: style);
}
// if (Platform.isWindows) {
// return message;
// } else {
return printer.getStyle(message,
color: color, background: background, style: style);
// }
}
static final commandNameSpace = 18;
@ -221,6 +221,12 @@ class _PrinterWindows extends Printer {
}
}
message.writeln(':setESC');
message.writeln(
'''for /F "tokens=1,2 delims=#" %%a in ('"prompt #\$H#\$E# & echo on & for %%b in (1) do rem"') do (''');
message.writeln(' set ESC=%%b');
message.writeln(' exit /B 0');
message.writeln(')');
message.writeln('exit /B 0');
var temp = await getTempFile(message.toString(), 'bat');
await Process.run('cmd', ['/C', temp.path]).then((ProcessResult result) {