|
|
@ -120,10 +120,15 @@ func scrollDOWN(v *gocui.View) error { |
|
|
|
} |
|
|
|
} |
|
|
|
func scrollView(v *gocui.View, delta int) error { |
|
|
|
func scrollView(v *gocui.View, delta int) error { |
|
|
|
if v != nil { |
|
|
|
if v != nil { |
|
|
|
v.Autoscroll = false |
|
|
|
_, y := v.Size() |
|
|
|
ox, oy := v.Origin() |
|
|
|
ox, oy := v.Origin() |
|
|
|
if err := v.SetOrigin(ox, oy+delta); err != nil { |
|
|
|
if oy+delta > strings.Count(v.ViewBuffer(), "\n")-y { |
|
|
|
return err |
|
|
|
v.Autoscroll = true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
v.Autoscroll = false |
|
|
|
|
|
|
|
if err := v.SetOrigin(ox, oy+delta); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -160,6 +165,13 @@ func initKeybindings() error { |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if err := g.SetKeybinding("", gocui.KeyEsc, gocui.ModNone, |
|
|
|
|
|
|
|
func(g *gocui.Gui, v *gocui.View) error { |
|
|
|
|
|
|
|
autoScrollView("Chat") |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
}); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, |
|
|
|
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, |
|
|
|
func(g *gocui.Gui, v *gocui.View) error { |
|
|
|
func(g *gocui.Gui, v *gocui.View) error { |
|
|
|
input, err := getInputString("Input") |
|
|
|
input, err := getInputString("Input") |
|
|
|