Allow debugPaintSizeEnabled to be toggled from the runner (#7028)
This commit is contained in:
@@ -535,8 +535,7 @@ class HotRunner extends ResidentRunner {
|
||||
);
|
||||
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".');
|
||||
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
|
||||
printHelpDetails();
|
||||
printStatus('To repeat this help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.');
|
||||
} else {
|
||||
printStatus('For a more detailed help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.');
|
||||
|
||||
@@ -61,17 +61,21 @@ abstract class ResidentRunner {
|
||||
Future<Null> _debugDumpApp() async {
|
||||
if (vmService != null)
|
||||
await vmService.vm.refreshViews();
|
||||
|
||||
await currentView.uiIsolate.flutterDebugDumpApp();
|
||||
}
|
||||
|
||||
Future<Null> _debugDumpRenderTree() async {
|
||||
if (vmService != null)
|
||||
await vmService.vm.refreshViews();
|
||||
|
||||
await currentView.uiIsolate.flutterDebugDumpRenderTree();
|
||||
}
|
||||
|
||||
Future<Null> _debugToggleDebugPaintSizeEnabled() async {
|
||||
if (vmService != null)
|
||||
await vmService.vm.refreshViews();
|
||||
await currentView.uiIsolate.flutterToggleDebugPaintSizeEnabled();
|
||||
}
|
||||
|
||||
void registerSignalHandlers() {
|
||||
ProcessSignal.SIGINT.watch().listen((ProcessSignal signal) async {
|
||||
_resetTerminal();
|
||||
@@ -154,6 +158,11 @@ abstract class ResidentRunner {
|
||||
return true;
|
||||
await _debugDumpRenderTree();
|
||||
return true;
|
||||
} else if (lower == 'p') {
|
||||
if (!supportsServiceProtocol)
|
||||
return true;
|
||||
await _debugToggleDebugPaintSizeEnabled();
|
||||
return true;
|
||||
} else if (lower == 'q' || character == AnsiTerminal.KEY_F10) {
|
||||
// F10, exit
|
||||
await stop();
|
||||
@@ -225,12 +234,19 @@ abstract class ResidentRunner {
|
||||
appFinished();
|
||||
}
|
||||
|
||||
/// Called to print help to the terminal.
|
||||
void printHelp({ @required bool details });
|
||||
|
||||
void printHelpDetails() {
|
||||
printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".');
|
||||
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
|
||||
printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".');
|
||||
}
|
||||
|
||||
/// Called when a signal has requested we exit.
|
||||
Future<Null> cleanupAfterSignal();
|
||||
/// Called right before we exit.
|
||||
Future<Null> cleanupAtFinish();
|
||||
/// Called to print help to the terminal.
|
||||
void printHelp({ @required bool details });
|
||||
/// Called when the runner should handle a terminal command.
|
||||
Future<Null> handleTerminalCommand(String code);
|
||||
}
|
||||
|
||||
@@ -179,10 +179,8 @@ class RunAndStayResident extends ResidentRunner {
|
||||
printStatus('The Observatory debugger and profiler is available at: http://127.0.0.1:${_result.observatoryPort}/');
|
||||
if (supportsServiceProtocol) {
|
||||
haveDetails = true;
|
||||
if (details) {
|
||||
printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".');
|
||||
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
|
||||
}
|
||||
if (details)
|
||||
printHelpDetails();
|
||||
}
|
||||
if (haveDetails && !details) {
|
||||
printStatus('For a more detailed help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.');
|
||||
|
||||
@@ -810,6 +810,13 @@ class Isolate extends ServiceObjectOwner {
|
||||
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpRenderTree');
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> flutterToggleDebugPaintSizeEnabled() async {
|
||||
Map<String, dynamic> state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint');
|
||||
if (state != null && state.containsKey('enabled') && state['enabled'] is bool)
|
||||
state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint', <String, dynamic>{ 'enabled': !state['enabled'] });
|
||||
return state;
|
||||
}
|
||||
|
||||
static bool _isMethodNotFoundException(dynamic e) {
|
||||
return (e is rpc.RpcException) &&
|
||||
(e.code == rpc_error_code.METHOD_NOT_FOUND);
|
||||
|
||||
Reference in New Issue
Block a user