Skip to content

Commit

Permalink
update view if content changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Palao committed Aug 29, 2021
1 parent 47847f1 commit 0497828
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions ios/test/harness/OutputViewController.h
Expand Up @@ -7,6 +7,7 @@
// output view

@property CGFloat fontSize;
@property NSUInteger outputTextLength;
@property (weak, nonatomic) IBOutlet UITextView * outputTextView;
@property (retain) UIPinchGestureRecognizer * pinchGestRecognizer;
@property (retain) NSTimer * timer;
Expand Down
24 changes: 15 additions & 9 deletions ios/test/harness/OutputViewController.m
Expand Up @@ -17,9 +17,10 @@ @implementation OutputViewController
- (void) viewDidLoad
{
[super viewDidLoad];

self.startTime = [NSDate date];
_outputText = [[[self outputTextView] attributedText] mutableCopy];

self.outputTextLength = 0;
_fontSize = 13;
[[self outputTextView] setFont:[UIFont fontWithName:@"CourierNewPSMT" size:_fontSize]];
[[self outputTextView] setTextColor:[self colorFromHexString: @"#28FE14"]];
Expand Down Expand Up @@ -190,13 +191,17 @@ - (void) updateOutputText: (NSString *) output withColor: (UIColor * _Nonnull) c

- (void) updateOutputTextView
{
[[NSOperationQueue mainQueue] addOperationWithBlock: ^{
@synchronized (self)
{
[[self outputTextView] setAttributedText: [self outputText]];
}
[[self outputTextView] scrollRangeToVisible: NSMakeRange( [[self outputTextView].text length], 0 )];
}];
if ([self outputText].length > self.outputTextLength)
{
[[NSOperationQueue mainQueue] addOperationWithBlock: ^{
@synchronized (self)
{
[[self outputTextView] setAttributedText: [self outputText]];
self.outputTextLength = [self outputText].length;
}
[[self outputTextView] scrollRangeToVisible: NSMakeRange( [[self outputTextView].text length], 0 )];
}];
}
}

- (void) showDialog: (NSString *) title withMessage: (NSString *) message
Expand Down Expand Up @@ -263,7 +268,8 @@ - (void) startPerlScript
NSURL * filePathUrl = [NSURL URLWithString: self.scriptPath];
NSURL * dirPath = [filePathUrl URLByDeletingLastPathComponent];

[[CBPerl alloc] initWithFileName:self.scriptPath withAbsolutePwd:dirPath.absoluteURL.path withDebugger:0 withOptions:options withArguments:nil error: &error completion:nil];
[[CBPerl alloc] initWithFileName:self.scriptPath withAbsolutePwd:dirPath.absoluteURL.path withDebugger:0 withOptions:options withArguments:nil error: &error completion: (PerlCompletionBlock) ^ (int perlResult) {
}];
[self handlePerlError:error];
[self cleanupStdioRedirection];
NSTimeInterval timeInterval = -[self.startTime timeIntervalSinceNow];
Expand Down

0 comments on commit 0497828

Please sign in to comment.