Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FBPrintWindow command #239

Merged
merged 6 commits into from
May 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions commands/FBPrintCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,27 @@ 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):
return [ fb.FBCommandArgument(arg='aView', type='UIView*/NSView*', help='The view to print the description of.', default='__keyWindow_dynamic__') ]

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this check can be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now why you have this. Never mind :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I was hoping the if/else flow was clear, if a window is passed in, do some new stuff, else fall back to what the code was doing before.

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]
Expand All @@ -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'
Expand Down