本文整理匯總了Golang中github.com/limetext/backend.View.RowCol方法的典型用法代碼示例。如果您正苦於以下問題:Golang View.RowCol方法的具體用法?Golang View.RowCol怎麽用?Golang View.RowCol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/limetext/backend.View
的用法示例。
在下文中一共展示了View.RowCol方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Show
func (t *tbfe) Show(v *backend.View, r Region) {
t.lock.Lock()
l := t.layout[v]
t.lock.Unlock()
p := util.Prof.Enter("show")
defer p.Exit()
lv := l.visible
s1, _ := v.RowCol(lv.Begin())
e1, _ := v.RowCol(lv.End())
s2, _ := v.RowCol(r.Begin())
e2, _ := v.RowCol(r.End())
r1 := Region{s1, e1}
r2 := Region{s2, e2}
r3 := r1.Cover(r2)
diff := 0
if d1, d2 := Abs(r1.Begin()-r3.Begin()), Abs(r1.End()-r3.End()); d1 > d2 {
diff = r3.Begin() - r1.Begin()
} else {
diff = r3.End() - r1.End()
}
r3.A = r1.Begin() + diff
r3.B = r1.End() + diff
r3 = t.clip(v, r3.A, r3.B)
l.visible = r3
t.lock.Lock()
t.layout[v] = l
t.lock.Unlock()
t.render()
}
示例2: clip
func (t *tbfe) clip(v *backend.View, s, e int) Region {
p := util.Prof.Enter("clip")
defer p.Exit()
t.lock.Lock()
h := t.layout[v].height
t.lock.Unlock()
if e-s > h {
e = s + h
} else if e-s < h {
s = e - h
}
if e2, _ := v.RowCol(v.TextPoint(e, 0)); e2 < e {
e = e2
}
if s < 0 {
s = 0
}
e = s + h
r := Region{v.TextPoint(s, 0), v.TextPoint(e, 0)}
return v.LineR(r)
}
示例3: renderLStatus
func (t *tbfe) renderLStatus(v *backend.View, y int, fg, bg termbox.Attribute) {
st := v.Status()
sel := v.Sel()
j := 0
for k, v := range st {
s := fmt.Sprintf("%s: %s, ", k, v)
addString(j, y, s, fg, bg)
}
if sel.Len() == 0 {
return
} else if l := sel.Len(); l > 1 {
s := fmt.Sprintf("%d selection regions", l)
j = addString(j, y, s, fg, bg)
} else if r := sel.Get(0); r.Size() == 0 {
row, col := v.RowCol(r.A)
s := fmt.Sprintf("Line %d, Column %d", row, col)
j = addString(j, y, s, fg, bg)
} else {
ls := v.Lines(r)
s := v.Substr(r)
if len(ls) < 2 {
s := fmt.Sprintf("%d characters selected", len(s))
j = addString(j, y, s, fg, bg)
} else {
s := fmt.Sprintf("%d lines %d characters selected", len(ls), len(s))
j = addString(j, y, s, fg, bg)
}
}
if t.status_message != "" {
s := fmt.Sprintf("; %s", t.status_message)
addString(j, y, s, fg, bg)
}
}
示例4: renderView
func (t *tbfe) renderView(v *backend.View, lay layout) {
p := util.Prof.Enter("render")
defer p.Exit()
sx, sy, w, h := lay.x, lay.y, lay.width, lay.height
vr := lay.visible
runes := v.Substr(vr)
x, y := sx, sy
ex, ey := sx+w, sy+h
style, _ := v.Settings().Get("caret_style", "underline").(string)
inverse, _ := v.Settings().Get("inverse_caret_state", false).(bool)
caretStyle := getCaretStyle(style, inverse)
oldCaretStyle := caretStyle
caretBlink, _ := v.Settings().Get("caret_blink", true).(bool)
if caretBlink && blink {
caretStyle = 0
}
tabSize := 4
if i, ok := v.Settings().Get("tab_size", tabSize).(int); ok {
tabSize = i
}
lineNumbers, _ := v.Settings().Get("line_numbers", true).(bool)
recipe := v.Transform(vr).Transcribe()
fg, bg := defaultFg, defaultBg
sel := v.Sel()
line, _ := v.RowCol(vr.Begin())
eofline, _ := v.RowCol(v.Size())
lineNumberRenderSize := len(intToRunes(eofline))
for i, r := range runes {
fg, bg = defaultFg, defaultBg
if lineNumbers {
renderLineNumber(&line, &x, y, lineNumberRenderSize, fg, bg)
}
curr := 0
o := vr.Begin() + i
for curr < len(recipe) && (o >= recipe[curr].Region.Begin()) {
if o < recipe[curr].Region.End() {
fg = palLut(render.Colour(recipe[curr].Flavour.Foreground))
bg = palLut(render.Colour(recipe[curr].Flavour.Background))
}
curr++
}
iscursor := sel.Contains(Region{o, o})
if iscursor {
fg = fg | caretStyle
termbox.SetCell(x, y, ' ', fg, bg)
}
if r == '\t' {
add := (x + 1 + (tabSize - 1)) &^ (tabSize - 1)
for ; x < add; x++ {
if x < ex {
termbox.SetCell(x, y, ' ', fg, bg)
}
// A long cursor looks weird
fg = fg & ^(termbox.AttrUnderline | termbox.AttrReverse)
}
continue
} else if r == '\n' {
x = sx
if y++; y > ey {
break
} else if lineNumbers {
// This results in additional calls to renderLineNumber.
// Maybe just accumulate positions needing line numbers, rendering them
// after the loop?
renderLineNumber(&line, &x, y, lineNumberRenderSize, defaultFg, defaultBg)
}
continue
}
if x < ex {
termbox.SetCell(x, y, r, fg, bg)
}
x++
}
fg, bg = defaultFg, defaultBg
// Need this if the cursor is at the end of the buffer
o := vr.Begin() + len(runes)
iscursor := sel.Contains(Region{o, o})
if iscursor {
fg = fg | caretStyle
termbox.SetCell(x, y, ' ', fg, bg)
}
// restore original caretStyle before blink modification
caretStyle = oldCaretStyle
//.........這裏部分代碼省略.........