示例#1
0
文件: main.go 项目: hanshenu/lime
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.Buffer().RowCol(r.A)
		s := fmt.Sprintf("Line %d, Column %d", row, col)
		j = addString(j, y, s, fg, bg)
	} else {
		ls := v.Buffer().Lines(r)
		s := v.Buffer().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)
	}
}