如何在 AvalonEdit 中启用虚拟空间?
我想实现“虚拟空间” AvalonEdit 中的功能类似于 Visual Studio 中的功能。
即插入符号可以放置在文本行末尾之外,如果您按任意键,则会自动添加空格来匹配。
我非常习惯这个功能,但是无论是谷歌搜索还是研究 AvalonEdit 的代码都没有给我任何关于如何启用它的线索(如果它受支持的话)。
如果不是,建议如何扩展插入符处理机制会很好。
谢谢!
I want to achieve "Virtual Space" functionality, similar to one in Visual Studio, in AvalonEdit.
I.e. the caret could be positioned beyond the end of the text line, and if you press any key, there would be spaces automatically added to match.
I am very used to this feature, but neither Googling nor studying AvalonEdit's code gave me any clues on how to enable it, if it is supported at all.
If it is not, suggestions how to extend caret handling mechanisms would be nice.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
虚拟空间支持已在 4.2.0.8283 版本中添加到 AvalonEdit。
设置textEditor.Options.EnableVirtualSpace = true;。
以下是我原来的回答。
目前不支持。
如果您想尝试添加它,请确保您阅读了“坐标系”文档(在 CodeProject 的帮助文件中)。您需要扩展“视觉列”,以便行尾之后的位置有效。并且您必须调整位置<->列计算(VisualLine.GetVisualColumn 和朋友)。使用 TextView.WideSpaceWidth 找出超出行尾的列。
上面应该允许您使用鼠标将插入符号放置在虚拟空间中。之后,您需要更改插入符号移动(箭头键、CaretNavigationCommandHandler)和文本输入逻辑(TextArea.PerformTextInput)以支持虚拟空间。
如果您成功完成上述步骤,请不要忘记将您的更改贡献回 AvalonEdit。 :-)
虽然我本人不喜欢虚拟空间,但我们需要类似的东西才能使 RectangleSelection 正常工作。
Edit:
Virtual space support has been added to AvalonEdit in version 4.2.0.8283.
Set
textEditor.Options.EnableVirtualSpace = true;
.Below is my original answer.
It's not currently supported.
If you want to try adding it, make sure you read the "coordinate systems" documentation (in the help file on CodeProject). You'll want to extend the "visual column" so that positions after the line end are valid. And you'll have to adjust the position<->column calculations (VisualLine.GetVisualColumn and friends). Use TextView.WideSpaceWidth to figure out the columns past the end of the line.
The above should allow you to use the mouse to place the caret in virtual space. After that, you'll need to change the caret movement (arrow keys, CaretNavigationCommandHandler) and text input logic (TextArea.PerformTextInput) to also support the virtual space.
And if you're successful with the above steps, don't forget to contribute your changes back to AvalonEdit. :-)
While I'm not a fan of virtual space myself, we need something like it to make the RectangleSelection work properly.