撤消 Scintilla 中的边距文本更改

发布于 2024-10-01 21:32:34 字数 368 浏览 9 评论 0原文

我正在使用 Scintilla 编写一个文本编辑器(实际上是 ScintillaNET,但有关普通 Scintilla 的信息也可能很有用)。在此编辑器中,我们希望在边距中显示更改信息(例如,如果我修改一行文本,该行将在边距中显示我的名字)。我已经设法在修改一行时更改边距,但如果有人撤消其更改,我似乎无法找到撤消边距更改的好方法。

我尝试在 BeforeTextInsert 事件中调用 BeginUndoAction,并在 TextInserted 事件结束时调用 EndUndoAction,但这似乎并未将边距更改视为可撤消。有没有一种好的方法可以撤消保证金变化?我想我可能需要实现我自己的小边距撤消堆栈(或修改 Scintilla 的撤消堆栈)并以这种方式处理它,但如果有内置的东西,我宁愿这样做。

I'm writing a text editor with Scintilla (actually ScintillaNET, but information on vanilla Scintilla could be useful as well). In this editor, we're wanting to display change information in a margin (for instance, if I modify a line of text, that line would display my name in the margin). I've managed to have the margin change on modifying a line, but I can't seem to figure out a good way to undo the margin change if someone undoes their change.

I've tried calling BeginUndoAction in the BeforeTextInsert event and EndUndoAction at the end of the TextInserted event, but that doesn't seem to treat the margin changes as undoable. Is there a decent way to undo margin changes? I'm thinking I may need to implement my own little margin undo stack (or modify Scintilla's undo stack) and just handle it that way, but if there's something built in, I'd rather go with that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕花眠 2024-10-08 21:32:34

我刚刚继续创建了自己的撤消堆栈来保存边距更改。如果正在修改文本并且不是撤消,我会添加修改后的文本、起始位置、行数和字符串列表(修改的每行的边距文本)。如果有修改并且是撤消,我会查看堆栈上的第一项,如果位置和修改后的文本相同,我会继续将边距更改回旧值。

似乎工作正常,尽管它比我想要的要难看一点。我确实担心堆栈会以某种方式与 Scintilla 撤消堆栈不同步,但我并不是真的想修改 Scintilla 源代码。

I've just went ahead and created my own undo stack to save margin changes. If the text is being modified and it's not an undo, I add modified text, start position, line count and a list of strings (the margin text for each line modified). If there's a modification and it is an undo, I peek at the first item on the stack and if the position and modified text is the same, I go ahead and change the margins back to the old values.

Seems to work ok, although it's a bit uglier than I'd like. I do worry about the stack somehow getting out of sync with the Scintilla undo stack, but I'm not really wanting to modify the Scintilla source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文