當前位置: 首頁>>代碼示例>>Golang>>正文


Golang buffer.Cursor類代碼示例

本文整理匯總了Golang中github.com/kisielk/vigo/buffer.Cursor的典型用法代碼示例。如果您正苦於以下問題:Golang Cursor類的具體用法?Golang Cursor怎麽用?Golang Cursor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Cursor類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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()
	}
}
開發者ID:kisielk,項目名稱:vigo,代碼行數:38,代碼來源:view.go

示例2: deindentLine

func (v *View) deindentLine(line buffer.Cursor) {
	line.Boffset = 0
	if r, _ := line.RuneUnder(); r == '\t' {
		v.buf.Delete(line, 1)
	}
	if v.cursor.Line == line.Line && v.cursor.Boffset > 0 {
		cursor := v.cursor
		cursor.Boffset -= 1
		v.MoveCursorTo(cursor)
	}
}
開發者ID:kisielk,項目名稱:vigo,代碼行數:11,代碼來源:view.go

示例3: prependToKillBuffer

func (v *view) prependToKillBuffer(cursor buffer.Cursor, nbytes int) {
	kb := *v.ctx.killBuffer

	switch v.lastCommand.Cmd {
	case vCommandKillWord, vCommandKillWordBackward, vCommandKillRegion, vCommandKillLine:
	default:
		kb = kb[:0]
	}

	kb = append(cursor.ExtractBytes(nbytes), kb...)
	*v.ctx.killBuffer = kb
}
開發者ID:pombredanne,項目名稱:vigo,代碼行數:12,代碼來源:view.go

示例4: indentLine

func (v *View) indentLine(line buffer.Cursor) {
	line.Boffset = 0
	v.buf.Insert(line, []byte{'\t'})
	if v.cursor.Line == line.Line {
		cursor := v.cursor
		cursor.Boffset += 1
		v.MoveCursorTo(cursor)
	}
}
開發者ID:kisielk,項目名稱:vigo,代碼行數:9,代碼來源:view.go

示例5: includes

func (s Selection) includes(c buffer.Cursor) bool {
	if s.Type == SelectionNone {
		return false
	}

	start, end := buffer.SortCursors(s.Start, s.End)
	inc := false

	switch s.Type {
	case SelectionChar:
		inc = (start.Before(c) || start.Equals(c)) && (c.Before(end) || c.Equals(end))
	case SelectionLine:
		inc = start.LineNum <= c.LineNum && c.LineNum <= end.LineNum
	case SelectionBlock:
		// TODO
		panic("not implemented")
	}

	return inc
}
開發者ID:kisielk,項目名稱:vigo,代碼行數:20,代碼來源:view.go

示例6: 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
}
開發者ID:pombredanne,項目名稱:vigo,代碼行數:6,代碼來源:view.go


注:本文中的github.com/kisielk/vigo/buffer.Cursor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。