Commit 04e7446b authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Make the fire red on black-and-white terminals (#6748)

parent 974da474
......@@ -26,7 +26,7 @@ abstract class Logger {
/// Display normal output of the command. This should be used for things like
/// progress messages, success messages, or just normal command output.
void printStatus(String message, { bool emphasis: false, bool newline: true });
void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative });
/// Use this for verbose tracing output. Users can turn this output on in order
/// to help diagnose issues with the toolchain or with their setup.
......@@ -60,14 +60,16 @@ class StdoutLogger extends Logger {
}
@override
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) {
_status?.cancel();
_status = null;
if (terminal.supportsColor && ansiAlternative != null)
message = ansiAlternative;
if (emphasis)
message = terminal.bolden(message);
if (newline)
stdout.writeln(emphasis ? terminal.writeBold(message) : message);
else
stdout.write(emphasis ? terminal.writeBold(message) : message);
message = '$message\n';
stdout.write(message);
}
@override
......@@ -106,7 +108,7 @@ class BufferLogger extends Logger {
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
@override
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) {
if (newline)
_status.writeln(message);
else
......@@ -139,7 +141,7 @@ class VerboseLogger extends Logger {
}
@override
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) {
_emit(_LogType.status, message);
}
......@@ -168,7 +170,7 @@ class VerboseLogger extends Logger {
} else {
prefix = '+$millis ms'.padLeft(prefixWidth);
if (millis >= 100)
prefix = terminal.writeBold(prefix);
prefix = terminal.bolden(prefix);
}
prefix = '[$prefix] ';
......@@ -176,11 +178,11 @@ class VerboseLogger extends Logger {
String indentMessage = message.replaceAll('\n', '\n$indent');
if (type == _LogType.error) {
stderr.writeln(prefix + terminal.writeBold(indentMessage));
stderr.writeln(prefix + terminal.bolden(indentMessage));
if (stackTrace != null)
stderr.writeln(indent + stackTrace.toString().replaceAll('\n', '\n$indent'));
} else if (type == _LogType.status) {
print(prefix + terminal.writeBold(indentMessage));
print(prefix + terminal.bolden(indentMessage));
} else {
print(prefix + indentMessage);
}
......@@ -210,7 +212,7 @@ class AnsiTerminal {
bool supportsColor;
String writeBold(String str) => supportsColor ? '$_bold$str$_reset' : str;
String bolden(String str) => supportsColor ? '$_bold$str$_reset' : str;
String clearScreen() => supportsColor ? _clear : '\n\n';
......
......@@ -624,7 +624,7 @@ class NotifyingLogger extends Logger {
}
@override
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) {
_messageController.add(new LogMessage('status', message));
}
......@@ -698,7 +698,7 @@ class _AppRunLogger extends Logger {
}
@override
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) {
_sendLogEvent(<String, dynamic>{ 'log': message });
}
......
......@@ -27,8 +27,15 @@ void printError(String message, [StackTrace stackTrace]) => logger.printError(me
/// Display normal output of the command. This should be used for things like
/// progress messages, success messages, or just normal command output.
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
logger.printStatus(message, emphasis: emphasis, newline: newline);
///
/// Set `emphasis` to true to make the output bold if it's supported.
///
/// Set `newline` to false to skip the trailing linefeed.
///
/// If `ansiAlternative` is provided, and the terminal supports color, that
/// string will be printed instead of the message.
void printStatus(String message, { bool emphasis: false, bool newline: true, String ansiAlternative }) {
logger.printStatus(message, emphasis: emphasis, newline: newline, ansiAlternative: ansiAlternative);
}
/// Use this for verbose tracing output. Users can turn this output on in order
......
......@@ -594,7 +594,15 @@ class HotRunner extends ResidentRunner {
@override
void printHelp({ @required bool details }) {
printStatus('🔥 To hot reload your app on the fly, press "r" or F5. To restart the app entirely, press "R".', emphasis: true);
const String fire = '🔥';
const String redOnBlack = '\u001B[31;40m';
const String bold = '\u001B[0;1m';
const String reset = '\u001B[0m';
printStatus(
'$fire To hot reload your app on the fly, press "r" or F5. To restart the app entirely, press "R".',
ansiAlternative: '$redOnBlack$fire$bold To ${redOnBlack}hot reload$bold your app on the fly, '
'press "r" or F5. To restart the app entirely, press "R".$reset'
);
printStatus('The Observatory debugger and profiler is available at: http://127.0.0.1:$_observatoryPort/');
if (details) {
printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment