Skip to content

Commit d0b4d2d

Browse files
authored
Merge pull request #239 from PeteTheHeat/print_window
Added FBPrintWindow command
2 parents 1ca4c58 + 5d6a9f1 commit d0b4d2d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

commands/FBPrintCommands.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,27 @@ def options(self):
5252
return [
5353
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.'),
5454
fb.FBCommandArgument(short='-d', long='--depth', arg='depth', type='int', default="0", help='Print only to a given depth. 0 indicates infinite depth.'),
55+
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]".'),
5556
]
5657

5758
def args(self):
5859
return [ fb.FBCommandArgument(arg='aView', type='UIView*/NSView*', help='The view to print the description of.', default='__keyWindow_dynamic__') ]
5960

6061
def run(self, arguments, options):
6162
maxDepth = int(options.depth)
63+
window = int(options.window)
6264
isMac = runtimeHelpers.isMacintoshArch()
6365

64-
if arguments[0] == '__keyWindow_dynamic__':
65-
arguments[0] = '(id)[[UIApplication sharedApplication] keyWindow]'
66-
66+
if window > 0:
67+
if isMac:
68+
arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:' + str(window) + '] contentView]'
69+
else:
70+
arguments[0] = '(id)[[[UIApplication sharedApplication] windows] objectAtIndex:' + str(window) + ']'
71+
elif arguments[0] == '__keyWindow_dynamic__':
6772
if isMac:
6873
arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:0] contentView]'
74+
else:
75+
arguments[0] = '(id)[[UIApplication sharedApplication] keyWindow]'
6976

7077
if options.upwards:
7178
view = arguments[0]
@@ -87,7 +94,6 @@ def run(self, arguments, options):
8794
description = re.sub(r'%s.*\n' % (prefixToRemove), r'', description)
8895
print description
8996

90-
9197
class FBPrintCoreAnimationTree(fb.FBCommand):
9298
def name(self):
9399
return 'pca'

0 commit comments

Comments
 (0)