ScintillaNET:如何获取单击单词的周围符号
我在 VisualStudio/C# 中使用 ScintillaNET。 当用户单击(LMB 或 RMB)文本中的特定单词时,我需要获取周围的符号。例如:
This is <a test> to show my <problem>
在这种情况下,如果用户单击单词“test”,我想检索“<”之间的整个块。和“>”,所以我需要获取。 如果用户点击“问题”,我需要获取
。
我知道我可以获取插入符号位置,然后在该位置(向左)之前“导航”(for 循环)以查找第一次出现的“<”,然后在插入符号位置(向右)之后“导航”以找到第一次出现“>”。
但还有其他更好的方法来实现这一目标吗? Scintilla 是否提供一些找到它们的方法?
感谢您的帮助!
I'm using ScintillaNET in VisualStudio/C#.
When the user clicks (LMB or RMB) a specific word inside the text, I need to get the surrounding symbols. For example:
This is <a test> to show my <problem>
In this case, if the user clicks over the word "test", I want to retrieve the entire block between "<" and ">", so I need to get <a test>
.
If the user clicks over "problem" I need to get <problem>
.
I know that I can get the caret position then "navigate" (for loop) before the position (going left) to find the first occurence of "<", then "navigate" after the caret position (going right) to find the first occurrence of ">".
But is there any other better way to achieve this? Does Scintilla supply some methods to find them?
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用这段代码来找到解决方法,但坦率地说,我希望找到更好的解决方案:
I used this code to find a workaround, but frankly speaking I wish to find a better solution: