mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Add loadHTMLString: API to HTML output view
This replaces the current HTML shown without adding to the history and will preserve scroll position.
This commit is contained in:
@@ -14,6 +14,7 @@ extern NSString* const kCommandRunnerURLScheme; // from HTMLOutput.h
|
||||
@property (nonatomic) BOOL runningCommand;
|
||||
@property (nonatomic) HOAutoScroll* autoScrollHelper;
|
||||
@property (nonatomic) std::map<std::string, std::string> environment;
|
||||
@property (nonatomic) NSRect pendingVisibleRect;
|
||||
@end
|
||||
|
||||
@implementation OakHTMLOutputView
|
||||
@@ -35,6 +36,12 @@ extern NSString* const kCommandRunnerURLScheme; // from HTMLOutput.h
|
||||
[self.webView.mainFrame stopLoading];
|
||||
}
|
||||
|
||||
- (void)loadHTMLString:(NSString*)someHTML
|
||||
{
|
||||
self.pendingVisibleRect = [[[[self.webView mainFrame] frameView] documentView] visibleRect];
|
||||
[[self.webView mainFrame] loadHTMLString:someHTML baseURL:[NSURL fileURLWithPath:NSHomeDirectory()]];
|
||||
}
|
||||
|
||||
// =======================
|
||||
// = Frame Load Delegate =
|
||||
// =======================
|
||||
@@ -67,6 +74,10 @@ extern NSString* const kCommandRunnerURLScheme; // from HTMLOutput.h
|
||||
if(frame == [sender mainFrame])
|
||||
[self webView:sender didClearWindowObject:[frame windowObject] forFrame:frame];
|
||||
|
||||
if(!NSEqualRects(self.pendingVisibleRect, NSZeroRect))
|
||||
[[[[self.webView mainFrame] frameView] documentView] scrollRectToVisible:self.pendingVisibleRect];
|
||||
self.pendingVisibleRect = NSZeroRect;
|
||||
|
||||
[super webView:sender didFinishLoadForFrame:frame];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user