From 8f58be6075dada644098d630a3b4d61781d39866 Mon Sep 17 00:00:00 2001 From: LEOYoon-Tsaw Date: Mon, 17 Aug 2020 01:18:44 -0400 Subject: [PATCH] Avoid jumping window in vertical mode --- SquirrelPanel.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/SquirrelPanel.m b/SquirrelPanel.m index 77045896d..8ab5e27f5 100644 --- a/SquirrelPanel.m +++ b/SquirrelPanel.m @@ -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) { @@ -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); @@ -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];