Skip to content

Commit

Permalink
Avoid jumping window in vertical mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LEOYoon-Tsaw committed Aug 17, 2020
1 parent 19bc95a commit 8f58be6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions SquirrelPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ - (void)show {
NSSize innerSize = NSMakeSize(windowRect.size.height - _view.edgeInset.height * 2, windowRect.size.width - _view.edgeInset.width * 2);
NSRect newTextBoundingRect = [_view.text boundingRectWithSize:innerSize options:NSStringDrawingUsesLineFragmentOrigin];
windowRect.size = NSMakeSize(newTextBoundingRect.size.height + _view.edgeInset.height * 2, newTextBoundingRect.size.width + _view.edgeInset.width * 2);
}
if (NSMidY(_position) / NSHeight(screenRect) >= 0.5) {
windowRect.origin.y = NSMinY(_position) - kOffsetHeight - NSHeight(windowRect);
} else {
windowRect.origin.y = NSMaxY(_position) + kOffsetHeight;
}
windowRect.origin.x -= windowRect.size.width;
if (!_inlinePreedit) {
Expand All @@ -266,7 +270,11 @@ - (void)show {
windowRect.origin.x = NSMinX(screenRect);
}
if (NSMinY(windowRect) < NSMinY(screenRect)) {
windowRect.origin.y = NSMaxY(_position) + kOffsetHeight;
if (_vertical) {
windowRect.origin.y = NSMinY(screenRect);
} else {
windowRect.origin.y = NSMaxY(_position) + kOffsetHeight;
}
}
if (NSMaxY(windowRect) > NSMaxY(screenRect)) {
windowRect.origin.y = NSMaxY(screenRect) - NSHeight(windowRect);
Expand Down Expand Up @@ -610,8 +618,9 @@ - (void)updateStatus:(NSString *)message {
}

- (void)showStatus:(NSString *)message {
NSAttributedString *text = [[NSAttributedString alloc] initWithString:message
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:message
attributes:_commentAttrs];
[self convertToVerticalGlyph:text inRange:NSMakeRange(0, text.length)];
[_view setText:text hilightedRect:NSZeroRect];
[self show];

Expand Down

0 comments on commit 8f58be6

Please sign in to comment.