本文整理匯總了Golang中github.com/kisielk/vigo/buffer.Cursor.VoffsetCoffset方法的典型用法代碼示例。如果您正苦於以下問題:Golang Cursor.VoffsetCoffset方法的具體用法?Golang Cursor.VoffsetCoffset怎麽用?Golang Cursor.VoffsetCoffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kisielk/vigo/buffer.Cursor
的用法示例。
在下文中一共展示了Cursor.VoffsetCoffset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MoveCursorTo
// Move cursor to the 'boffset' position in the 'line'. Obviously 'line' must be
// from the attached buffer. If 'boffset' < 0, use 'last_cursor_voffset'. Keep
// in mind that there is no need to maintain connections between lines (e.g. for
// moving from a deleted line to another line).
func (v *View) MoveCursorTo(c buffer.Cursor) {
v.dirty |= dirtyStatus
if c.Boffset < 0 {
bo, co, vo := c.Line.FindClosestOffsets(v.lastCursorVoffset)
v.cursor.Boffset = bo
v.cursorCoffset = co
v.cursorVoffset = vo
} else {
vo, co := c.VoffsetCoffset()
v.cursor.Boffset = c.Boffset
v.cursorCoffset = co
v.cursorVoffset = vo
}
if c.Boffset >= 0 {
v.lastCursorVoffset = v.cursorVoffset
}
if c.Line != v.cursor.Line {
if v.lineVoffset != 0 {
v.dirty = dirtyEverything
}
v.lineVoffset = 0
}
v.cursor.Line = c.Line
v.cursor.LineNum = c.LineNum
v.adjustLineVoffset()
v.adjustTopLine()
if v.selection.Type != SelectionNone {
v.dirty |= dirtyContents
v.selection.End = v.Cursor()
}
}
示例2: cursorPositionFor
func (v *view) cursorPositionFor(cursor buffer.Cursor) (int, int) {
y := cursor.LineNum - v.topLineNum
vo, _ := cursor.VoffsetCoffset()
x := vo - v.lineVoffset
return x, y
}