Eri*_*ner 6 macos cocoa objective-c
我已经通过正确设置NSTextStoragemy 的委托NSTextView和更改文本属性来实现基本的语法突出显示-textStorageDidProcessEditing.
基本过程如下
- (void)textStorageDidProcessEditing:(NSNotification *)notification {
NSTextStorage *storage = [notification object];
[storage beginEditing];
NSString *text = [storage string];
NSRange textRange = NSMakeRange(0, [text length]);
[storage removeAttribute:NSForegroundColorAttributeName range:textRange];
// Some regex matching here ...
[storage addAttribute:NSForegroundColorAttributeName
value:[COSyntax colorForPatternGroup:pattern.groupName]
range:capturedRanges[group]];
[storage endEditing];
}
Run Code Online (Sandbox Code Playgroud)
无论何时-removeAttribute:range:或-addAttribute:value:range在SPACE输入字符时调用,NSTextView周围的NSScrollView位置都会开始跳转(滚动旋钮到达附近的某个随机位置)
是什么导致了这个?
trs*_*rss 11
我终于从我的观察中发现跳跃不仅在按空格键时发生,而且在其他键如退格键时发生,这恰好发生在两者都发生时.
- 打开非连续布局
- 对可见区域之前的文本进行任何修改,甚至是属性,-textStorageDidProcessEditing:
看起来像是非连续布局功能中的错误!如果专家能够确认,那将会很好.
它似乎与呼叫-beginEditing和无关-endEditing.
| 归档时间: |
|
| 查看次数: |
1633 次 |
| 最近记录: |