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
149e0623
Unverified
Commit
149e0623
authored
Feb 06, 2020
by
Levi Lesches
Committed by
GitHub
Feb 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to clear the terminal by pressing "c" (#50034)
parent
a9b8d360
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
49 additions
and
5 deletions
+49
-5
command_help.dart
packages/flutter_tools/lib/src/base/command_help.dart
+3
-0
logger.dart
packages/flutter_tools/lib/src/base/logger.dart
+14
-1
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+8
-0
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+6
-3
run_cold.dart
packages/flutter_tools/lib/src/run_cold.dart
+1
-0
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+1
-0
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+3
-0
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+10
-1
testbed.dart
packages/flutter_tools/test/src/testbed.dart
+3
-0
No files found.
packages/flutter_tools/lib/src/base/command_help.dart
View file @
149e0623
...
...
@@ -53,6 +53,9 @@ class CommandHelp {
CommandHelpOption
_a
;
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
_d
;
CommandHelpOption
get
d
=>
_d
??=
_makeOption
(
'd'
,
'Detach (terminate "flutter run" but leave application running).'
);
...
...
packages/flutter_tools/lib/src/base/logger.dart
View file @
149e0623
...
...
@@ -168,6 +168,9 @@ abstract class Logger {
/// Only surfaces a value in machine modes, Loggers may ignore this message in
/// non-machine modes.
void
sendEvent
(
String
name
,
[
Map
<
String
,
dynamic
>
args
])
{
}
/// Clears all output.
void
clear
();
}
class
StdoutLogger
extends
Logger
{
...
...
@@ -326,6 +329,13 @@ class StdoutLogger extends Logger {
@override
void
sendEvent
(
String
name
,
[
Map
<
String
,
dynamic
>
args
])
{
}
@override
void
clear
()
{
_status
?.
pause
();
writeToStdOut
(
_terminal
.
clearScreen
()
+
'
\n
'
);
_status
?.
resume
();
}
}
/// A [StdoutLogger] which replaces Unicode characters that cannot be printed to
...
...
@@ -470,7 +480,7 @@ class BufferLogger extends Logger {
)..
start
();
}
/// Clears all buffers.
@override
void
clear
()
{
_error
.
clear
();
_status
.
clear
();
...
...
@@ -627,6 +637,9 @@ class VerboseLogger extends Logger {
@override
bool
get
hasTerminal
=>
parent
.
hasTerminal
;
@override
void
clear
()
=>
parent
.
clear
();
}
enum
_LogType
{
error
,
status
,
trace
}
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
149e0623
...
...
@@ -1000,6 +1000,10 @@ class NotifyingLogger extends Logger {
@override
bool
get
hasTerminal
=>
false
;
// This method is only relevant for terminals.
@override
void
clear
()
{
}
}
/// A running application, started by this daemon.
...
...
@@ -1230,6 +1234,10 @@ class _AppRunLogger extends Logger {
@override
bool
get
hasTerminal
=>
false
;
// This method is only relevant for terminals.
@override
void
clear
()
{
}
}
class
LogMessage
{
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
149e0623
...
...
@@ -1052,9 +1052,6 @@ abstract class ResidentRunner {
commandHelp
.
P
.
print
();
commandHelp
.
a
.
print
();
}
if
(
flutterDevices
.
any
((
FlutterDevice
d
)
=>
d
.
device
.
supportsScreenshot
))
{
commandHelp
.
s
.
print
();
}
}
/// Called when a signal has requested we exit.
...
...
@@ -1062,6 +1059,9 @@ abstract class ResidentRunner {
/// Called right before we exit.
Future
<
void
>
cleanupAtFinish
();
// Clears the screen.
void
clearScreen
()
=>
globals
.
logger
.
clear
();
}
class
OperationResult
{
...
...
@@ -1167,6 +1167,9 @@ class TerminalHandler {
return
true
;
}
return
false
;
case
'c'
:
residentRunner
.
clearScreen
();
return
true
;
case
'd'
:
case
'D'
:
await
residentRunner
.
detach
();
...
...
packages/flutter_tools/lib/src/run_cold.dart
View file @
149e0623
...
...
@@ -189,6 +189,7 @@ class ColdRunner extends ResidentRunner {
if
(
_didAttach
)
{
commandHelp
.
d
.
print
();
}
commandHelp
.
c
.
print
();
commandHelp
.
q
.
print
();
for
(
final
FlutterDevice
device
in
flutterDevices
)
{
final
String
dname
=
device
.
device
.
name
;
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
149e0623
...
...
@@ -1053,6 +1053,7 @@ class HotRunner extends ResidentRunner {
if
(
_didAttach
)
{
commandHelp
.
d
.
print
();
}
commandHelp
.
c
.
print
();
commandHelp
.
q
.
print
();
if
(
details
)
{
printHelpDetails
();
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
149e0623
...
...
@@ -737,6 +737,9 @@ class StreamLogger extends Logger {
@override
bool
get
hasTerminal
=>
false
;
@override
void
clear
()
=>
_log
(
'[stdout]
${globals.terminal.clearScreen()}
\n
'
);
}
class
LoggerInterrupted
implements
Exception
{
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
149e0623
...
...
@@ -377,6 +377,7 @@ void main() {
commandHelp
.
r
,
commandHelp
.
R
,
commandHelp
.
h
,
commandHelp
.
c
,
commandHelp
.
q
,
commandHelp
.
s
,
commandHelp
.
w
,
...
...
@@ -390,7 +391,6 @@ void main() {
commandHelp
.
z
,
commandHelp
.
P
,
commandHelp
.
a
,
commandHelp
.
s
,
'An Observatory debugger and profiler on null is available at: null'
,
''
].
join
(
'
\n
'
)
...
...
@@ -423,6 +423,15 @@ void main() {
expect
(
testLogger
.
errorText
,
contains
(
'Error'
));
}));
test
(
'ResidentTunner clears the screen when it should'
,
()
=>
testbed
.
run
(()
async
{
const
String
message
=
'This should be cleared'
;
expect
(
testLogger
.
statusText
,
equals
(
''
));
testLogger
.
printStatus
(
message
);
expect
(
testLogger
.
statusText
,
equals
(
message
+
'
\n
'
));
// printStatus makes a newline
residentRunner
.
clearScreen
();
expect
(
testLogger
.
statusText
,
equals
(
''
));
}));
test
(
'ResidentRunner bails taking screenshot on debug device if debugAllowBanner throws post'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockDevice
.
supportsScreenshot
).
thenReturn
(
true
);
when
(
mockIsolate
.
flutterDebugAllowBanner
(
true
)).
thenThrow
(
Exception
());
...
...
packages/flutter_tools/test/src/testbed.dart
View file @
149e0623
...
...
@@ -822,6 +822,9 @@ class DelegateLogger implements Logger {
@override
bool
get
supportsColor
=>
delegate
.
supportsColor
;
@override
void
clear
()
=>
delegate
.
clear
();
}
/// An implementation of the Cache which does not download or require locking.
...
...
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