Skip to content

Commit

Permalink
update librime
Browse files Browse the repository at this point in the history
  • Loading branch information
groverlynn committed Apr 28, 2024
1 parent 2b2ea77 commit de56538
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
35 changes: 17 additions & 18 deletions SquirrelInputController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ @implementation SquirrelInputController {
NSString* _currentApp;
NSRange _selRange;
NSRange _candidateIndices;
NSUInteger _caretPos;
NSUInteger _converted;
NSRange _inlineSelRange;
NSUInteger _inlineCaretPos;
NSUInteger _currentIndex;
NSEventModifierFlags _lastModifiers;
NSEventType _lastEventType;
Expand Down Expand Up @@ -194,7 +194,7 @@ - (BOOL)mouseDownOnCharacterIndex:(NSUInteger)index
*keepTracking = NO;
@autoreleasepool {
if ((!_inlinePreedit && !_inlineCandidate) || _composedString.length == 0 ||
_caretPos == index ||
_inlineCaretPos == index ||
(flags & NSEventModifierFlagDeviceIndependentFlagsMask)) {
return NO;
}
Expand All @@ -213,7 +213,7 @@ - (BOOL)mouseDownOnCharacterIndex:(NSUInteger)index
} else if (point.x < head.x || index <= 0) {
[self performAction:kPROCESS onIndex:kHomeKey];
} else {
[self moveCursor:_caretPos
[self moveCursor:_inlineCaretPos
toPosition:index
inlinePreedit:_inlinePreedit
inlineCandidate:_inlineCandidate];
Expand Down Expand Up @@ -670,7 +670,7 @@ - (void)dealloc {
}

- (NSRange)selectionRange {
return NSMakeRange(_caretPos, 0);
return NSMakeRange(_inlineCaretPos, 0);
}

- (NSRange)replacementRange {
Expand All @@ -696,7 +696,7 @@ - (void)cancelComposition {

- (void)updateComposition {
[self.client setMarkedText:_preeditString
selectionRange:NSMakeRange(_caretPos, 0)
selectionRange:NSMakeRange(_inlineCaretPos, 0)
replacementRange:NSMakeRange(NSNotFound, NSNotFound)];
}

Expand All @@ -705,11 +705,11 @@ - (void)showPreeditString:(NSString*)preedit
caretPos:(NSUInteger)pos __attribute__((objc_direct)) {
// NSLog(@"showPreeditString: '%@'", preedit);
if ([preedit isEqualToString:_preeditString.string] &&
NSEqualRanges(range, _selRange) && pos == _caretPos) {
NSEqualRanges(range, _inlineSelRange) && pos == _inlineCaretPos) {
return;
}
_selRange = range;
_caretPos = pos;
_inlineSelRange = range;
_inlineCaretPos = pos;
// NSLog(@"selRange.location = %ld, selRange.length = %ld; caretPos = %ld",
// range.location, range.length, pos);
NSDictionary* attrs = [self markForStyle:kTSMHiliteRawText
Expand Down Expand Up @@ -961,8 +961,9 @@ - (void)rimeUpdate {
: (NSUInteger)ctx.menu.highlighted_candidate_index;
BOOL finalPage = (BOOL)ctx.menu.is_last_page;

didCompose |= start != _converted;
_converted = start;
NSRange selRange = NSMakeRange(start, end - start);
didCompose |= !NSEqualRanges(_selRange, selRange);
_selRange = selRange;
// update expander and section status in tabular layout;
// already processed the action if _currentIndex == NSNotFound
if (panel.tabular && !showingStatus) {
Expand Down Expand Up @@ -1004,8 +1005,7 @@ - (void)rimeUpdate {
[self clearBuffer];
} else if (!_showingSwitcherMenu && _inlineCandidate) {
const char* candidatePreview = ctx.commit_text_preview;
NSString* candidatePreviewText =
candidatePreview ? @(candidatePreview) : @"";
NSString* candidatePreviewText = @(candidatePreview ?: "");
if (_inlinePreedit) {
if (end <= caretPos && caretPos < length) {
candidatePreviewText = [candidatePreviewText
Expand All @@ -1029,10 +1029,9 @@ - (void)rimeUpdate {
substringToIndex:candidatePreviewText.length - (length - end)];
}
[self showPreeditString:candidatePreviewText
selRange:NSMakeRange(start - (caretPos < end),
candidatePreviewText.length -
start + (caretPos < end))
caretPos:caretPos < end ? caretPos - 1
selRange:NSMakeRange(start,
candidatePreviewText.length - start)
caretPos:caretPos < end ? caretPos
: candidatePreviewText.length];
}
} else if (!_showingSwitcherMenu) {
Expand Down Expand Up @@ -1096,7 +1095,7 @@ - (void)rimeUpdate {
[self showPanelWithPreedit:_inlinePreedit && !_showingSwitcherMenu
? nil
: preeditText
selRange:NSMakeRange(start, end - start)
selRange:selRange
caretPos:_showingSwitcherMenu ? NSNotFound : caretPos
candidateIndices:candidateIndices
highlightedIndex:highlightedIndex
Expand Down
25 changes: 13 additions & 12 deletions SquirrelPanel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3912,7 +3912,6 @@ @implementation SquirrelPanel {
NSUInteger _functionButton;
NSUInteger _caretPos;
NSUInteger _pageNum;
BOOL _caretAtHome;
BOOL _finalPage;
}

Expand Down Expand Up @@ -4474,9 +4473,14 @@ - (void)highlightFunctionButton:(SquirrelIndex)functionButton
addAttribute:NSForegroundColorAttributeName
value:theme.hilitedPreeditForeColor
range:NSMakeRange(NSMaxRange(_view.preeditRange) - 1, 1)];
functionButton = _caretAtHome ? kEscapeKey : kBackSpaceKey;
functionButton = _caretPos == NSNotFound || _caretPos == 0
? kEscapeKey
: kBackSpaceKey;
[_toolTip showWithToolTip:NSLocalizedString(
_caretAtHome ? @"escape" : @"delete", nil)
_caretPos == NSNotFound || _caretPos == 0
? @"escape"
: @"delete",
nil)
withDelay:delay];
break;
}
Expand Down Expand Up @@ -4821,8 +4825,6 @@ - (void)showPreedit:(NSString*)preeditString
finalPage:(BOOL)finalPage
didCompose:(BOOL)didCompose {
BOOL updateCandidates = didCompose || !NSEqualRanges(_indexRange, indexRange);
_caretAtHome = caretPos == NSNotFound ||
(caretPos == selRange.location && selRange.location == 1);
_caretPos = caretPos;
_pageNum = pageNum;
_finalPage = finalPage;
Expand Down Expand Up @@ -4897,16 +4899,15 @@ - (void)showPreedit:(NSString*)preeditString
range:NSMakeRange(NSMaxRange(selRange) - 1, 1)];
}
}
[preedit appendAttributedString:_caretAtHome ? theme.symbolDeleteStroke
: theme.symbolDeleteFill];
[preedit appendAttributedString:_caretPos == NSNotFound || _caretPos == 0
? theme.symbolDeleteStroke
: theme.symbolDeleteFill];
// force caret to be rendered sideways, instead of uprights, in vertical
// orientation
if (theme.vertical && caretPos != NSNotFound) {
[preedit
addAttribute:NSVerticalGlyphFormAttributeName
value:@(NO)
range:NSMakeRange(caretPos - (caretPos < NSMaxRange(selRange)),
1)];
[preedit addAttribute:NSVerticalGlyphFormAttributeName
value:@(NO)
range:NSMakeRange(caretPos, 1)];
}
preeditRange = NSMakeRange(0, preedit.length);
if (rulerAttrsPreedit) {
Expand Down
4 changes: 2 additions & 2 deletions action-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -e

rime_version=1.11.0
rime_git_hash=76a0a16
rime_version=1.11.2
rime_git_hash=5b09f35

rime_archive="rime-${rime_git_hash}-macOS-universal.tar.bz2"
rime_download_url="https://github.com/rime/librime/releases/download/${rime_version}/${rime_archive}"
Expand Down

0 comments on commit de56538

Please sign in to comment.