Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c23d9cd4
Unverified
Commit
c23d9cd4
authored
Feb 10, 2020
by
Zachary Anderson
Committed by
GitHub
Feb 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Print emojis in Windows Terminal (#50446)
parent
5f465897
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
447 additions
and
338 deletions
+447
-338
command_help.dart
packages/flutter_tools/lib/src/base/command_help.dart
+104
-35
logger.dart
packages/flutter_tools/lib/src/base/logger.dart
+16
-21
terminal.dart
packages/flutter_tools/lib/src/base/terminal.dart
+14
-2
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+0
-2
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+1
-2
xcodeproj.dart
packages/flutter_tools/lib/src/ios/xcodeproj.dart
+1
-2
logger_test.dart
...es/flutter_tools/test/general.shard/base/logger_test.dart
+295
-266
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+16
-8
No files found.
packages/flutter_tools/lib/src/base/command_help.dart
View file @
c23d9cd4
...
...
@@ -36,58 +36,122 @@ class CommandHelp {
final
OutputPreferences
_outputPreferences
;
CommandHelpOption
_L
;
CommandHelpOption
get
L
=>
_L
??=
_makeOption
(
'L'
,
'Dump layer tree to the console.'
,
'debugDumpLayerTree'
);
CommandHelpOption
get
L
=>
_L
??=
_makeOption
(
'L'
,
'Dump layer tree to the console.'
,
'debugDumpLayerTree'
,
);
CommandHelpOption
_P
;
CommandHelpOption
get
P
=>
_P
??=
_makeOption
(
'P'
,
'Toggle performance overlay.'
,
'WidgetsApp.showPerformanceOverlay'
);
CommandHelpOption
get
P
=>
_P
??=
_makeOption
(
'P'
,
'Toggle performance overlay.'
,
'WidgetsApp.showPerformanceOverlay'
,
);
CommandHelpOption
_R
;
CommandHelpOption
get
R
=>
_R
??=
_makeOption
(
'R'
,
'Hot restart.'
);
CommandHelpOption
get
R
=>
_R
??=
_makeOption
(
'R'
,
'Hot restart.'
,
);
CommandHelpOption
_S
;
CommandHelpOption
get
S
=>
_S
??=
_makeOption
(
'S'
,
'Dump accessibility tree in traversal order.'
,
'debugDumpSemantics'
);
CommandHelpOption
get
S
=>
_S
??=
_makeOption
(
'S'
,
'Dump accessibility tree in traversal order.'
,
'debugDumpSemantics'
,
);
CommandHelpOption
_U
;
CommandHelpOption
get
U
=>
_U
??=
_makeOption
(
'U'
,
'Dump accessibility tree in inverse hit test order.'
,
'debugDumpSemantics'
);
CommandHelpOption
get
U
=>
_U
??=
_makeOption
(
'U'
,
'Dump accessibility tree in inverse hit test order.'
,
'debugDumpSemantics'
,
);
CommandHelpOption
_a
;
CommandHelpOption
get
a
=>
_a
??=
_makeOption
(
'a'
,
'Toggle timeline events for all widget build methods.'
,
'debugProfileWidgetBuilds'
);
CommandHelpOption
get
a
=>
_a
??=
_makeOption
(
'a'
,
'Toggle timeline events for all widget build methods.'
,
'debugProfileWidgetBuilds'
,
);
CommandHelpOption
_c
;
CommandHelpOption
get
c
=>
_c
??=
_makeOption
(
'c'
,
'Clear the screen'
);
CommandHelpOption
get
c
=>
_c
??=
_makeOption
(
'c'
,
'Clear the screen'
,
);
CommandHelpOption
_d
;
CommandHelpOption
get
d
=>
_d
??=
_makeOption
(
'd'
,
'Detach (terminate "flutter run" but leave application running).'
);
CommandHelpOption
get
d
=>
_d
??=
_makeOption
(
'd'
,
'Detach (terminate "flutter run" but leave application running).'
,
);
CommandHelpOption
_h
;
CommandHelpOption
get
h
=>
_h
??=
_makeOption
(
'h'
,
'Repeat this help message.'
);
CommandHelpOption
get
h
=>
_h
??=
_makeOption
(
'h'
,
'Repeat this help message.'
,
);
CommandHelpOption
_i
;
CommandHelpOption
get
i
=>
_i
??=
_makeOption
(
'i'
,
'Toggle widget inspector.'
,
'WidgetsApp.showWidgetInspectorOverride'
);
CommandHelpOption
get
i
=>
_i
??=
_makeOption
(
'i'
,
'Toggle widget inspector.'
,
'WidgetsApp.showWidgetInspectorOverride'
,
);
CommandHelpOption
_o
;
CommandHelpOption
get
o
=>
_o
??=
_makeOption
(
'o'
,
'Simulate different operating systems.'
,
'defaultTargetPlatform'
);
CommandHelpOption
get
o
=>
_o
??=
_makeOption
(
'o'
,
'Simulate different operating systems.'
,
'defaultTargetPlatform'
,
);
CommandHelpOption
_p
;
CommandHelpOption
get
p
=>
_p
??=
_makeOption
(
'p'
,
'Toggle the display of construction lines.'
,
'debugPaintSizeEnabled'
);
CommandHelpOption
get
p
=>
_p
??=
_makeOption
(
'p'
,
'Toggle the display of construction lines.'
,
'debugPaintSizeEnabled'
,
);
CommandHelpOption
_q
;
CommandHelpOption
get
q
=>
_q
??=
_makeOption
(
'q'
,
'Quit (terminate the application on the device).'
);
CommandHelpOption
get
q
=>
_q
??=
_makeOption
(
'q'
,
'Quit (terminate the application on the device).'
,
);
CommandHelpOption
_r
;
CommandHelpOption
get
r
=>
_r
??=
_makeOption
(
'r'
,
'Hot reload.
$fire$fire$fire
'
);
CommandHelpOption
get
r
=>
_r
??=
_makeOption
(
'r'
,
'Hot reload.
$fire$fire$fire
'
,
);
CommandHelpOption
_s
;
CommandHelpOption
get
s
=>
_s
??=
_makeOption
(
's'
,
'Save a screenshot to flutter.png.'
);
CommandHelpOption
get
s
=>
_s
??=
_makeOption
(
's'
,
'Save a screenshot to flutter.png.'
,
);
CommandHelpOption
_t
;
CommandHelpOption
get
t
=>
_t
??=
_makeOption
(
't'
,
'Dump rendering tree to the console.'
,
'debugDumpRenderTree'
);
CommandHelpOption
get
t
=>
_t
??=
_makeOption
(
't'
,
'Dump rendering tree to the console.'
,
'debugDumpRenderTree'
,
);
CommandHelpOption
_w
;
CommandHelpOption
get
w
=>
_w
??=
_makeOption
(
'w'
,
'Dump widget hierarchy to the console.'
,
'debugDumpApp'
);
CommandHelpOption
get
w
=>
_w
??=
_makeOption
(
'w'
,
'Dump widget hierarchy to the console.'
,
'debugDumpApp'
,
);
CommandHelpOption
_z
;
CommandHelpOption
get
z
=>
_z
??=
_makeOption
(
'z'
,
'Toggle elevation checker.'
);
CommandHelpOption
get
z
=>
_z
??=
_makeOption
(
'z'
,
'Toggle elevation checker.'
,
);
CommandHelpOption
_makeOption
(
String
key
,
String
description
,
[
String
inParenthesis
=
''
,
...
...
@@ -142,25 +206,30 @@ class CommandHelpOption {
String
toString
()
{
final
StringBuffer
message
=
StringBuffer
();
message
.
writeAll
(<
String
>[
_terminal
.
bolden
(
key
),
description
],
' '
);
if
(!
_hasTextInParenthesis
)
{
return
message
.
toString
();
}
if
(
_hasTextInParenthesis
)
{
bool
wrap
=
false
;
final
int
maxWidth
=
math
.
max
(
_outputPreferences
.
wrapColumn
??
0
,
maxLineWidth
);
int
width
=
maxWidth
-
(
_platform
.
stdoutSupportsAnsi
?
_rawMessageLength
+
1
:
message
.
length
);
final
String
parentheticalText
=
'(
$inParenthesis
)'
;
if
(
width
<
parentheticalText
.
length
)
{
width
=
maxWidth
;
wrap
=
true
;
}
if
(
wrap
)
{
message
.
write
(
'
\n
'
);
}
// pad according to the raw text
message
.
write
(
''
.
padLeft
(
width
-
parentheticalText
.
length
));
message
.
write
(
_terminal
.
color
(
parentheticalText
,
TerminalColor
.
grey
));
bool
wrap
=
false
;
final
int
maxWidth
=
math
.
max
(
_outputPreferences
.
wrapColumn
??
0
,
maxLineWidth
,
);
final
int
adjustedMessageLength
=
_platform
.
stdoutSupportsAnsi
?
_rawMessageLength
+
1
:
message
.
length
;
int
width
=
maxWidth
-
adjustedMessageLength
;
final
String
parentheticalText
=
'(
$inParenthesis
)'
;
if
(
width
<
parentheticalText
.
length
)
{
width
=
maxWidth
;
wrap
=
true
;
}
if
(
wrap
)
{
message
.
write
(
'
\n
'
);
}
// pad according to the raw text
message
.
write
(
''
.
padLeft
(
width
-
parentheticalText
.
length
));
message
.
write
(
_terminal
.
color
(
parentheticalText
,
TerminalColor
.
grey
));
return
message
.
toString
();
}
...
...
packages/flutter_tools/lib/src/base/logger.dart
View file @
c23d9cd4
...
...
@@ -5,7 +5,6 @@
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'package:platform/platform.dart'
;
import
'../base/context.dart'
;
import
'../globals.dart'
as
globals
;
...
...
@@ -179,15 +178,13 @@ class StdoutLogger extends Logger {
@required
Stdio
stdio
,
@required
OutputPreferences
outputPreferences
,
@required
TimeoutConfiguration
timeoutConfiguration
,
@required
Platform
platform
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
_stdio
=
stdio
,
_terminal
=
terminal
,
_timeoutConfiguration
=
timeoutConfiguration
,
_outputPreferences
=
outputPreferences
,
_stopwatchFactory
=
stopwatchFactory
,
_platform
=
platform
;
_stopwatchFactory
=
stopwatchFactory
;
@override
final
AnsiTerminal
_terminal
;
...
...
@@ -197,7 +194,6 @@ class StdoutLogger extends Logger {
final
TimeoutConfiguration
_timeoutConfiguration
;
final
Stdio
_stdio
;
final
StopwatchFactory
_stopwatchFactory
;
final
Platform
_platform
;
Status
_status
;
...
...
@@ -306,8 +302,8 @@ class StdoutLogger extends Logger {
onFinish:
_clearStatus
,
stdio:
_stdio
,
timeoutConfiguration:
_timeoutConfiguration
,
platform:
_platform
,
stopwatch:
_stopwatchFactory
.
createStopwatch
(),
terminal:
_terminal
,
)..
start
();
}
else
{
_status
=
SummaryStatus
(
...
...
@@ -352,7 +348,6 @@ class WindowsStdoutLogger extends StdoutLogger {
@required
Stdio
stdio
,
@required
OutputPreferences
outputPreferences
,
@required
TimeoutConfiguration
timeoutConfiguration
,
@required
Platform
platform
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
super
(
terminal:
terminal
,
...
...
@@ -360,15 +355,16 @@ class WindowsStdoutLogger extends StdoutLogger {
outputPreferences:
outputPreferences
,
timeoutConfiguration:
timeoutConfiguration
,
stopwatchFactory:
stopwatchFactory
,
platform:
platform
,
);
@override
void
writeToStdOut
(
String
message
)
{
// TODO(jcollins-g): wrong abstraction layer for this, move to [Stdio].
final
String
windowsMessage
=
message
.
replaceAll
(
'✗'
,
'X'
)
.
replaceAll
(
'✓'
,
'√'
);
final
String
windowsMessage
=
_terminal
.
supportsEmoji
?
message
:
message
.
replaceAll
(
'🔥'
,
''
)
.
replaceAll
(
'✗'
,
'X'
)
.
replaceAll
(
'✓'
,
'√'
);
_stdio
.
stdoutWrite
(
windowsMessage
);
}
}
...
...
@@ -681,19 +677,18 @@ abstract class Status {
@required
Duration
timeout
,
@required
TimeoutConfiguration
timeoutConfiguration
,
@required
Stopwatch
stopwatch
,
@required
bool
supportsColor
,
@required
Platform
platform
,
@required
AnsiTerminal
terminal
,
VoidCallback
onFinish
,
SlowWarningCallback
slowWarningCallback
,
})
{
if
(
supportsColor
)
{
if
(
terminal
.
supportsColor
)
{
return
AnsiSpinner
(
timeout:
timeout
,
onFinish:
onFinish
,
slowWarningCallback:
slowWarningCallback
,
timeoutConfiguration:
timeoutConfiguration
,
stopwatch:
stopwatch
,
platform:
platform
,
terminal:
terminal
,
)..
start
();
}
return
SilentStatus
(
...
...
@@ -862,12 +857,12 @@ class AnsiSpinner extends Status {
@required
Duration
timeout
,
@required
TimeoutConfiguration
timeoutConfiguration
,
@required
Stopwatch
stopwatch
,
@required
Platform
platform
,
@required
AnsiTerminal
terminal
,
VoidCallback
onFinish
,
this
.
slowWarningCallback
,
Stdio
stdio
,
})
:
_stdio
=
stdio
??
globals
.
stdio
,
_
isWindows
=
platform
.
isWindows
,
_
terminal
=
terminal
,
super
(
timeout:
timeout
,
onFinish:
onFinish
,
...
...
@@ -878,7 +873,7 @@ class AnsiSpinner extends Status {
final
String
_backspaceChar
=
'
\
b'
;
final
String
_clearChar
=
' '
;
final
Stdio
_stdio
;
final
bool
_isWindows
;
final
AnsiTerminal
_terminal
;
bool
timedOut
=
false
;
...
...
@@ -886,7 +881,7 @@ class AnsiSpinner extends Status {
Timer
timer
;
// Windows console font has a limited set of Unicode characters.
List
<
String
>
get
_animation
=>
_isWindows
List
<
String
>
get
_animation
=>
!
_terminal
.
supportsEmoji
?
const
<
String
>[
r'-'
,
r'\'
,
r'|'
,
r'/'
]
:
const
<
String
>[
'⣾'
,
'⣽'
,
'⣻'
,
'⢿'
,
'⡿'
,
'⣟'
,
'⣯'
,
'⣷'
];
...
...
@@ -984,7 +979,7 @@ class AnsiStatus extends AnsiSpinner {
this
.
padding
=
kDefaultStatusPadding
,
@required
Duration
timeout
,
@required
Stopwatch
stopwatch
,
@required
Platform
platform
,
@required
AnsiTerminal
terminal
,
VoidCallback
onFinish
,
Stdio
stdio
,
TimeoutConfiguration
timeoutConfiguration
,
...
...
@@ -997,7 +992,7 @@ class AnsiStatus extends AnsiSpinner {
stdio:
stdio
,
timeoutConfiguration:
timeoutConfiguration
,
stopwatch:
stopwatch
,
platform:
platform
,
terminal:
terminal
,
);
final
String
message
;
...
...
packages/flutter_tools/lib/src/base/terminal.dart
View file @
c23d9cd4
...
...
@@ -86,7 +86,10 @@ class OutputPreferences {
}
class
AnsiTerminal
{
AnsiTerminal
({
@required
io
.
Stdio
stdio
,
@required
Platform
platform
})
AnsiTerminal
({
@required
io
.
Stdio
stdio
,
@required
Platform
platform
,
})
:
_stdio
=
stdio
,
_platform
=
platform
;
...
...
@@ -121,7 +124,16 @@ class AnsiTerminal {
bool
get
supportsColor
=>
_platform
.
stdoutSupportsAnsi
??
false
;
final
RegExp
_boldControls
=
RegExp
(
'(
${RegExp.escape(resetBold)}
|
${RegExp.escape(bold)}
)'
);
// Assume unicode emojis are supported when not on Windows.
// If we are on Windows, unicode emojis are supported in Windows Terminal,
// which sets the WT_SESSION environment variable. See:
// https://github.com/microsoft/terminal/blob/master/doc/user-docs/index.md#tips-and-tricks
bool
get
supportsEmoji
=>
!
_platform
.
isWindows
||
_platform
.
environment
.
containsKey
(
'WT_SESSION'
);
final
RegExp
_boldControls
=
RegExp
(
'(
${RegExp.escape(resetBold)}
|
${RegExp.escape(bold)}
)'
,
);
/// Whether we are interacting with the flutter tool via the terminal.
///
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
c23d9cd4
...
...
@@ -127,14 +127,12 @@ Future<T> runInContext<T>(
stdio:
globals
.
stdio
,
outputPreferences:
outputPreferences
,
timeoutConfiguration:
timeoutConfiguration
,
platform:
globals
.
platform
,
)
:
StdoutLogger
(
terminal:
globals
.
terminal
,
stdio:
globals
.
stdio
,
outputPreferences:
outputPreferences
,
timeoutConfiguration:
timeoutConfiguration
,
platform:
globals
.
platform
,
),
MacOSWorkflow:
()
=>
const
MacOSWorkflow
(),
MDnsObservatoryDiscovery:
()
=>
MDnsObservatoryDiscovery
(),
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
c23d9cd4
...
...
@@ -258,8 +258,7 @@ class Doctor {
slowWarningCallback:
()
=>
validator
.
slowWarning
,
timeoutConfiguration:
timeoutConfiguration
,
stopwatch:
Stopwatch
(),
supportsColor:
globals
.
terminal
.
supportsColor
,
platform:
globals
.
platform
,
terminal:
globals
.
terminal
,
);
ValidationResult
result
;
try
{
...
...
packages/flutter_tools/lib/src/ios/xcodeproj.dart
View file @
c23d9cd4
...
...
@@ -314,9 +314,8 @@ class XcodeProjectInterpreter {
final
Status
status
=
Status
.
withSpinner
(
timeout:
const
TimeoutConfiguration
().
fastOperation
,
timeoutConfiguration:
const
TimeoutConfiguration
(),
platform:
_platform
,
stopwatch:
Stopwatch
(),
supportsColor:
_terminal
.
supportsColor
,
terminal:
_terminal
,
);
final
List
<
String
>
showBuildSettingsCommand
=
<
String
>[
_executable
,
...
...
packages/flutter_tools/test/general.shard/base/logger_test.dart
View file @
c23d9cd4
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
c23d9cd4
...
...
@@ -204,9 +204,11 @@ void main() {
Logger:
()
=>
StdoutLogger
(
outputPreferences:
OutputPreferences
.
test
(),
stdio:
mockStdio
,
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
()),
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
(),
),
timeoutConfiguration:
const
TimeoutConfiguration
(),
platform:
FakePlatform
(),
),
WebSocketConnector:
()
=>
(
String
url
,
{
CompressionOptions
compression
})
async
=>
throw
const
SocketException
(
'test'
),
});
...
...
@@ -283,10 +285,12 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
StdoutLogger
(
outputPreferences:
outputPreferences
,
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
()),
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
(),
),
stdio:
mockStdio
,
timeoutConfiguration:
const
TimeoutConfiguration
(),
platform:
FakePlatform
(),
),
});
...
...
@@ -301,10 +305,12 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
StdoutLogger
(
outputPreferences:
outputPreferences
,
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
()),
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
(),
),
stdio:
mockStdio
,
timeoutConfiguration:
const
TimeoutConfiguration
(),
platform:
FakePlatform
(),
),
});
...
...
@@ -320,10 +326,12 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
StdoutLogger
(
outputPreferences:
outputPreferences
,
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
()),
terminal:
AnsiTerminal
(
stdio:
mockStdio
,
platform:
const
LocalPlatform
(),
),
stdio:
mockStdio
,
timeoutConfiguration:
const
TimeoutConfiguration
(),
platform:
FakePlatform
(),
),
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment