mirror of
https://github.com/walles/moar.git
synced 2024-11-14 20:08:02 +03:00
Print a footer at the bottom
This commit is contained in:
parent
6f13bde11e
commit
29183c1eeb
26
m/pager.go
26
m/pager.go
@ -19,6 +19,23 @@ func NewPager(r _Reader) *_Pager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _AddFooter(s tcell.Screen) {
|
||||||
|
_, height := s.Size()
|
||||||
|
|
||||||
|
for pos, char := range "Press ESC / Return to exit" {
|
||||||
|
s.SetContent(pos, height-1, char, nil, tcell.StyleDefault)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Redraw(s tcell.Screen) {
|
||||||
|
s.Clear()
|
||||||
|
|
||||||
|
// FIXME: Ask our reader for lines and draw them
|
||||||
|
|
||||||
|
_AddFooter(s)
|
||||||
|
s.Sync()
|
||||||
|
}
|
||||||
|
|
||||||
// StartPaging brings up the pager on screen
|
// StartPaging brings up the pager on screen
|
||||||
func (p *_Pager) StartPaging() {
|
func (p *_Pager) StartPaging() {
|
||||||
// This function initially inspired by
|
// This function initially inspired by
|
||||||
@ -36,15 +53,12 @@ func (p *_Pager) StartPaging() {
|
|||||||
|
|
||||||
quit := make(chan struct{})
|
quit := make(chan struct{})
|
||||||
|
|
||||||
s.Clear()
|
|
||||||
for pos, char := range "Press ESC / Return to exit" {
|
|
||||||
s.SetContent(5+pos, 5, char, nil, tcell.StyleDefault)
|
|
||||||
}
|
|
||||||
s.Show()
|
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
go func() {
|
go func() {
|
||||||
|
s.Show()
|
||||||
for {
|
for {
|
||||||
|
_Redraw(s)
|
||||||
|
|
||||||
ev := s.PollEvent()
|
ev := s.PollEvent()
|
||||||
switch ev := ev.(type) {
|
switch ev := ev.(type) {
|
||||||
case *tcell.EventKey:
|
case *tcell.EventKey:
|
||||||
|
Loading…
Reference in New Issue
Block a user