确定行号之间是否存在偏移?
我需要确定给定的选择是否位于起始线和结束线之间。 我有一个 ILineRange 和 Eclipse 视口内的给定偏移量。 (我需要知道,选择(来自远程方)是否是在本地用户的当前视口内进行的。不幸的是,我无法从选择中获取 ILineRange
。我必须依赖 getOffset( ) 和 getLength()...
有人有主意吗?
我认为对此没有一个干净的解决方案,因为偏移量(或每行的字符不同(新行行或一大块注释)。
I need to determine if a given selection is in between a start line and an end line.
I have an ILineRange
and a given offset within the viewport of eclipse. (I need to know, if the selection (from a remote party) was made within the current viewport of the local user. Unfortunately, I cannot get an ILineRange
from the selection. I must rely on getOffset() and getLength()...
Anyone has an idea?
I think there is not a clean solution for this, as the offset (or the characters per line vary (new line lines or a big block of comment).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
位置和偏移量之间的转换可以使用 IDocument 的 API(围绕 getLine*() 的方法)完成。 (我不确定我完全理解你的问题,但我确实希望这是有用的信息。)
The conversion between positions and offsets can be done with IDocument's API (methods around getLine*()). (I'm not sure I fully understood your question, but I do hope that this is helpful information.)
也许你可以检查是否
org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STOverviewRuler
类 处理与您遇到的同类问题.大致如下:
Maybe you can check if that
org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STOverviewRuler
class deals with the same kind of problem you have.Something along the lines of: