Skip to content

Commit

Permalink
Catch error in term_init and show message with error. refs blinksh#558
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Oct 3, 2018
1 parent 2a53eeb commit 66b38ff
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Blink/TermDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,5 +351,16 @@ - (BOOL)handleControl:(NSString *)control
return NO;
}

- (void)viewShowAlert:(NSString *)title andMessage:(NSString *)message {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[_delegate.viewController dismissViewControllerAnimated:YES completion:nil];
}]];

[_delegate.viewController presentViewController:alertController animated:YES completion:nil];
}


@end
1 change: 1 addition & 0 deletions Blink/TermView.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- (void)viewWinSizeChanged:(struct winsize)win;
- (void)viewSendString:(NSString *)data;
- (void)viewCopyString:(NSString *)text;
- (void)viewShowAlert:(NSString *)title andMessage:(NSString *)message;

@end

Expand Down
2 changes: 2 additions & 0 deletions Blink/TermView.m
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ - (void)userContentController:(WKUserContentController *)userContentController
[_device viewFontSizeChanged:[data[@"size"] integerValue]];
} else if ([operation isEqualToString:@"copy"]) {
[_device viewCopyString: data[@"content"]];
} else if ([operation isEqualToString:@"alert"]) {
[_device viewShowAlert:data[@"title"] andMessage:data[@"message"]];
} else if ([operation isEqualToString:@"sendString"]) {
[_device viewSendString:data[@"string"]];
}
Expand Down
9 changes: 7 additions & 2 deletions Resources/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ function term_setup() {

function term_init() {
term_setupDefaults();
applyUserSettings();
waitForFontFamily(term_setup);
try {
applyUserSettings();
waitForFontFamily(term_setup);
} catch (e) {
_postMessage('alert', {title: 'Error', message: "Failed to setup theme. Please check syntax of your theme.\n" + e.toString()})
term_setup();
}
}

function term_write(data) {
Expand Down

0 comments on commit 66b38ff

Please sign in to comment.