diff --git a/commands/FBPrintCommands.py b/commands/FBPrintCommands.py index 74b9b84..a90fb51 100755 --- a/commands/FBPrintCommands.py +++ b/commands/FBPrintCommands.py @@ -51,6 +51,7 @@ def options(self): return [ fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Print only the hierarchy directly above the view, up to its window.'), fb.FBCommandArgument(short='-d', long='--depth', arg='depth', type='int', default="0", help='Print only to a given depth. 0 indicates infinite depth.'), + fb.FBCommandArgument(short='-w', long='--window', arg='window', type='int', default="0", help='Specify the window to print a description of. Check which windows exist with "po (id)[[UIApplication sharedApplication] windows]".'), ] def args(self): @@ -58,13 +59,19 @@ def args(self): def run(self, arguments, options): maxDepth = int(options.depth) + window = int(options.window) isMac = runtimeHelpers.isMacintoshArch() - if arguments[0] == '__keyWindow_dynamic__': - arguments[0] = '(id)[[UIApplication sharedApplication] keyWindow]' - + if window > 0: + if isMac: + arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:' + str(window) + '] contentView]' + else: + arguments[0] = '(id)[[[UIApplication sharedApplication] windows] objectAtIndex:' + str(window) + ']' + elif arguments[0] == '__keyWindow_dynamic__': if isMac: arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:0] contentView]' + else: + arguments[0] = '(id)[[UIApplication sharedApplication] keyWindow]' if options.upwards: view = arguments[0] @@ -86,7 +93,6 @@ def run(self, arguments, options): description = re.sub(r'%s.*\n' % (prefixToRemove), r'', description) print description - class FBPrintCoreAnimationTree(fb.FBCommand): def name(self): return 'pca'