Esempio n. 1
0
func prevOne(g *gocui.Gui, v *gocui.View) error {
	if lv := g.View("side"); lv != nil {
		_, height := g.Size()
		height = height - 2*Padding
		length := len(files)
		file_offset = (file_offset - 1 + length) % length
		drawSide(g, lv, files, file_offset)
	}
	return nil
}
Esempio n. 2
0
func drawCenter(g *gocui.Gui) {
	if v := g.View("center"); v != nil {
		_, height := g.Size()
		height = height - 2
		if text, err := TailFile(files[file_offset], height); err == nil {
			if i := strings.Index(text, "\n"); i > 0 {
				re := regexp.MustCompile("\\033[[0-9]+m")
				line := re.ReplaceAllString(text[0:i], "")
				text = line + text[i:]
			} else {
				re := regexp.MustCompile("\\033[[0-9]+m")
				text = re.ReplaceAllString(text, "")
			}
			v.Clear()
			fmt.Fprintf(v, "%s", text)
			g.Flush()
		} else {
			v.Clear()
			fmt.Fprintf(v, "------ failed to read from %s ------\n", filepath.Base(files[file_offset]))
			g.Flush()
		}
	}
}