示例#1
0
文件: main.go 项目: BinaryPaean/lime
func (t *tbfe) clip(v *backend.View, r primitives.Region) primitives.Region {
	s, _ := v.Buffer().RowCol(r.Begin())
	e, _ := v.Buffer().RowCol(r.End())

	_, h := termbox.Size()
	h -= console_height
	if e-s > h {
		e = s + h
	}
	if e2, _ := v.Buffer().RowCol(v.Buffer().TextPoint(e, 1)); e2 < e {
		e = e2
	}
	if e-s < h {
		s = e - h
	}
	if s < 1 {
		s = 1
	}
	r.A = v.Buffer().Line(v.Buffer().TextPoint(s, 1)).A
	r.B = v.Buffer().Line(v.Buffer().TextPoint(e, 1)).B
	return r
}