summaryrefslogtreecommitdiff
path: root/frontends/cocoa/BrowserView.m
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/cocoa/BrowserView.m')
-rw-r--r--frontends/cocoa/BrowserView.m33
1 files changed, 11 insertions, 22 deletions
diff --git a/frontends/cocoa/BrowserView.m b/frontends/cocoa/BrowserView.m
index c1cf9beb9..31d433515 100644
--- a/frontends/cocoa/BrowserView.m
+++ b/frontends/cocoa/BrowserView.m
@@ -38,6 +38,8 @@
@property (readwrite, copy, nonatomic) NSString *markedText;
+@property (readwrite, nonatomic) NSRect caretRect;
+
- (void)scrollHorizontal:(CGFloat)amount;
- (void)scrollVertical:(CGFloat)amount;
- (CGFloat)pageScroll;
@@ -92,34 +94,22 @@ static const NSTimeInterval CaretBlinkTime = 0.8;
[history redraw];
}
-static inline NSRect cocoa_get_caret_rect(BrowserView *view)
-{
- float bscale = browser_window_get_scale(view->browser);
-
- NSRect caretRect = {
- .origin = NSMakePoint(view->caretPoint.x * bscale, view->caretPoint.y * bscale),
- .size = NSMakeSize(CaretWidth, view->caretHeight * bscale)
- };
-
- return caretRect;
-}
-
- (void)removeCaret
{
hasCaret = NO;
- [self setNeedsDisplayInRect:cocoa_get_caret_rect(self)];
+ [self setNeedsDisplayInRect: self.caretRect];
[self setCaretTimer:nil];
}
-- (void)addCaretAt:(NSPoint)point height:(CGFloat)height
+- (void)addCaretAtX: (int)caretX Y: (int)caretY height: (int)caretHeight;
{
if (hasCaret) {
- [self setNeedsDisplayInRect:cocoa_get_caret_rect(self)];
+ [self setNeedsDisplayInRect:self.caretRect];
}
- caretPoint = point;
- caretHeight = height;
+ self.caretRect = cocoa_rect_wh(caretX, caretY, CaretWidth, caretHeight);
+
hasCaret = YES;
caretVisible = YES;
@@ -129,14 +119,14 @@ static inline NSRect cocoa_get_caret_rect(BrowserView *view)
[caretTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:CaretBlinkTime]];
}
- [self setNeedsDisplayInRect:cocoa_get_caret_rect(self)];
+ [self setNeedsDisplayInRect:self.caretRect];
}
- (void)caretBlink:(NSTimer *)timer
{
if (hasCaret) {
caretVisible = !caretVisible;
- [self setNeedsDisplayInRect:cocoa_get_caret_rect(self)];
+ [self setNeedsDisplayInRect: self.caretRect];
}
}
@@ -165,10 +155,9 @@ static inline NSRect cocoa_get_caret_rect(BrowserView *view)
browser_window_redraw(browser, 0, 0, &clip, &ctx);
}
- NSRect caretRect = cocoa_get_caret_rect(self);
- if (hasCaret && caretVisible && [self needsToDrawRect:caretRect]) {
+ if (hasCaret && caretVisible && [self needsToDrawRect:self.caretRect]) {
[[NSColor blackColor] set];
- [NSBezierPath fillRect:caretRect];
+ [NSBezierPath fillRect: self.caretRect];
}
}
}