mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Use updateRuler
method for line number view update
This commit is contained in:
parent
820b60e61d
commit
1c4dcd206f
@ -247,7 +247,7 @@ a
|
||||
|
||||
|
||||
### Additions/Changes
|
||||
a
|
||||
|
||||
- Drop support for __OS X Lion.__
|
||||
- Migrate document drawer to sidebar style.
|
||||
- Add “show document inspector” option to preferences.
|
||||
|
@ -200,7 +200,6 @@
|
||||
CEDefaultFirstColoringDelayKey: @0.3f,
|
||||
CEDefaultSecondColoringDelayKey: @0.7f,
|
||||
CEDefaultAutoCompletionDelayKey: @0.25,
|
||||
CEDefaultLineNumUpdateIntervalKey: @0.12f,
|
||||
CEDefaultInfoUpdateIntervalKey: @0.2f,
|
||||
CEDefaultIncompatibleCharIntervalKey: @0.42f,
|
||||
CEDefaultOutlineMenuIntervalKey: @0.37f,
|
||||
|
@ -43,8 +43,6 @@
|
||||
@property (nonatomic, nonnull) CEEditorScrollView *scrollView;
|
||||
@property (nonatomic, nonnull) NSTextStorage *textStorage;
|
||||
|
||||
@property (nonatomic, nullable) NSTimer *lineNumUpdateTimer;
|
||||
|
||||
@property (nonatomic) BOOL highlightsCurrentLine;
|
||||
@property (nonatomic) NSInteger lastCursorLocation;
|
||||
|
||||
@ -158,7 +156,6 @@
|
||||
- (void)dealloc
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
[self stopUpdateLineNumberTimer];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[_textStorage removeLayoutManager:[_textView layoutManager]];
|
||||
@ -224,8 +221,6 @@
|
||||
if (isVertical) {
|
||||
[textView setLayoutOrientation:NSTextLayoutOrientationVertical];
|
||||
}
|
||||
|
||||
[[self scrollView] invalidateLineNumber];
|
||||
}
|
||||
|
||||
|
||||
@ -569,21 +564,6 @@
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// textStorage をセット
|
||||
- (void)setTextStorage:(NSTextStorage *)textStorage
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
// 行番号ビューのためにテキストの変更を監視する
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(updateLineNumber)
|
||||
name:NSTextStorageDidProcessEditingNotification
|
||||
object:textStorage];
|
||||
|
||||
_textStorage = textStorage;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// アウトラインメニューの選択項目を更新
|
||||
- (void)updateOutlineMenuSelection
|
||||
@ -607,49 +587,6 @@
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// 行番号表示を更新
|
||||
- (void)updateLineNumber
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
// 行番号更新
|
||||
NSTimeInterval lineNumUpdateInterval = [defaults doubleForKey:CEDefaultLineNumUpdateIntervalKey];
|
||||
if ([self lineNumUpdateTimer]) {
|
||||
[[self lineNumUpdateTimer] setFireDate:[NSDate dateWithTimeIntervalSinceNow:lineNumUpdateInterval]];
|
||||
} else {
|
||||
[self setLineNumUpdateTimer:[NSTimer scheduledTimerWithTimeInterval:lineNumUpdateInterval
|
||||
target:self
|
||||
selector:@selector(updateLineNumberWithTimer:)
|
||||
userInfo:nil
|
||||
repeats:NO]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// 行番号更新
|
||||
- (void)updateLineNumberWithTimer:(nonnull NSTimer *)timer
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
[self stopUpdateLineNumberTimer];
|
||||
[[self scrollView] invalidateLineNumber];
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// 行番号更新タイマーを停止
|
||||
- (void)stopUpdateLineNumberTimer
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
if ([self lineNumUpdateTimer]) {
|
||||
[[self lineNumUpdateTimer] invalidate];
|
||||
[self setLineNumUpdateTimer:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// カレント行をハイライト表示
|
||||
- (void)highlightCurrentLine
|
||||
|
@ -76,12 +76,6 @@ static const NSString *LineNumberFontName;
|
||||
self = [super initWithScrollView:scrollView orientation:orientation];
|
||||
if (self) {
|
||||
[self setClientView:[scrollView documentView]];
|
||||
|
||||
// update line number on scroll view resize for text wrapping change
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(invalidateLineNumber)
|
||||
name:NSViewFrameDidChangeNotification
|
||||
object:scrollView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -98,15 +92,6 @@ static const NSString *LineNumberFontName;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// clean up
|
||||
- (void)dealloc
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// draw background
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
@ -323,15 +308,6 @@ static const NSString *LineNumberFontName;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// update line number
|
||||
- (void)invalidateLineNumber
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// select lines while dragging event
|
||||
- (void)selectLines:(nullable NSTimer *)timer
|
||||
|
@ -568,7 +568,6 @@ static NSPoint kTextContainerOrigin;
|
||||
|
||||
[self setFont:newFont];
|
||||
[self setNeedsDisplayInRect:[self visibleRect] avoidAdditionalLayout:YES]; // 最下行以下のページガイドの描画が残るための措置 (2009-02-14)
|
||||
[self updateLineNumberAndAdjustScroll];
|
||||
}
|
||||
|
||||
|
||||
@ -949,6 +948,15 @@ static NSPoint kTextContainerOrigin;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// let line number view update
|
||||
- (void)updateRuler
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
[[self scrollView] invalidateLineNumber];
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark Protocol
|
||||
|
||||
@ -1118,7 +1126,12 @@ static NSPoint kTextContainerOrigin;
|
||||
// redraw
|
||||
NSRange range = NSMakeRange(0, [[self string] length]);
|
||||
[[self layoutManager] invalidateLayoutForCharacterRange:range actualCharacterRange:nil];
|
||||
[self updateLineNumberAndAdjustScroll];
|
||||
|
||||
// 行番号を強制的に更新(スクロール位置が調整されない時は再描画が行われないため)
|
||||
[self updateRuler];
|
||||
|
||||
// キャレット/選択範囲が見えるようにスクロール位置を調整
|
||||
[self scrollRangeToVisible:[self selectedRange]];
|
||||
}
|
||||
|
||||
|
||||
@ -1172,7 +1185,9 @@ static NSPoint kTextContainerOrigin;
|
||||
CGFloat size = (CGFloat)[[NSUserDefaults standardUserDefaults] doubleForKey:CEDefaultFontSizeKey];
|
||||
|
||||
[self setFont:[NSFont fontWithName:name size:size] ? : [NSFont systemFontOfSize:size]];
|
||||
[self updateLineNumberAndAdjustScroll];
|
||||
|
||||
// キャレット/選択範囲が見えるようにスクロール位置を調整
|
||||
[self scrollRangeToVisible:[self selectedRange]];
|
||||
}
|
||||
|
||||
|
||||
@ -1529,19 +1544,6 @@ static NSPoint kTextContainerOrigin;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// 行番号更新、キャレット/選択範囲が見えるようスクロール位置を調整
|
||||
- (void)updateLineNumberAndAdjustScroll
|
||||
// ------------------------------------------------------
|
||||
{
|
||||
// 行番号を強制的に更新(スクロール位置が調整されない時は再描画が行われないため)
|
||||
[[self scrollView] invalidateLineNumber];
|
||||
|
||||
// キャレット/選択範囲が見えるようにスクロール位置を調整
|
||||
[self scrollRangeToVisible:[self selectedRange]];
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------
|
||||
/// Pasetboard内文字列の改行コードを書類に設定されたものに置換する
|
||||
- (void)replaceLineEndingToDocCharInPboard:(NSPasteboard *)pboard
|
||||
@ -2043,9 +2045,6 @@ static NSPoint kTextContainerOrigin;
|
||||
if (isSelectionVisible) {
|
||||
[self scrollRangeToVisible:selectedRange];
|
||||
}
|
||||
|
||||
// force redraw line number view
|
||||
[[self scrollView] invalidateLineNumber];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -219,7 +219,6 @@ extern NSString *__nonnull const CEDefaultBasicColoringDelayKey;
|
||||
extern NSString *__nonnull const CEDefaultFirstColoringDelayKey;
|
||||
extern NSString *__nonnull const CEDefaultSecondColoringDelayKey;
|
||||
extern NSString *__nonnull const CEDefaultAutoCompletionDelayKey;
|
||||
extern NSString *__nonnull const CEDefaultLineNumUpdateIntervalKey;
|
||||
extern NSString *__nonnull const CEDefaultInfoUpdateIntervalKey;
|
||||
extern NSString *__nonnull const CEDefaultIncompatibleCharIntervalKey;
|
||||
extern NSString *__nonnull const CEDefaultOutlineMenuIntervalKey;
|
||||
|
@ -218,7 +218,6 @@ NSString *__nonnull const CEDefaultBasicColoringDelayKey = @"basicColoringDelay"
|
||||
NSString *__nonnull const CEDefaultFirstColoringDelayKey = @"firstColoringDelay";
|
||||
NSString *__nonnull const CEDefaultSecondColoringDelayKey = @"secondColoringDelay";
|
||||
NSString *__nonnull const CEDefaultAutoCompletionDelayKey = @"autoCompletionDelay";
|
||||
NSString *__nonnull const CEDefaultLineNumUpdateIntervalKey = @"lineNumUpdateInterval";
|
||||
NSString *__nonnull const CEDefaultInfoUpdateIntervalKey = @"infoUpdateInterval";
|
||||
NSString *__nonnull const CEDefaultIncompatibleCharIntervalKey = @"incompatibleCharInterval";
|
||||
NSString *__nonnull const CEDefaultOutlineMenuIntervalKey = @"outlineMenuInterval";
|
||||
|
Loading…
Reference in New Issue
Block a user