Merge branch 'scroll-options' of sloum/bombadillo into master
Closes #13 & #14
This commit is contained in:
commit
6a524d9f70
|
@ -111,3 +111,69 @@ func (w *Window) ScrollUp() {
|
||||||
fmt.Print("\a")
|
fmt.Print("\a")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *Window) PageDown() {
|
||||||
|
var borderThickness int
|
||||||
|
if w.drawBox {
|
||||||
|
borderThickness = -1
|
||||||
|
} else {
|
||||||
|
borderThickness = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
height := w.Box.row2 - w.Box.row1 + borderThickness
|
||||||
|
contentLength := len(w.Content)
|
||||||
|
if w.Scrollposition < contentLength-height {
|
||||||
|
w.Scrollposition += height
|
||||||
|
if w.Scrollposition > contentLength-height {
|
||||||
|
w.Scrollposition = contentLength-height
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Print("\a")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Window) PageUp() {
|
||||||
|
var borderThickness int
|
||||||
|
if w.drawBox {
|
||||||
|
borderThickness = -1
|
||||||
|
} else {
|
||||||
|
borderThickness = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
height := w.Box.row2 - w.Box.row1 + borderThickness
|
||||||
|
contentLength := len(w.Content)
|
||||||
|
if w.Scrollposition > 0 && height < contentLength {
|
||||||
|
w.Scrollposition -= height
|
||||||
|
if w.Scrollposition < 0 {
|
||||||
|
w.Scrollposition = 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Print("\a")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Window) ScrollHome() {
|
||||||
|
if w.Scrollposition > 0 {
|
||||||
|
w.Scrollposition = 0
|
||||||
|
} else {
|
||||||
|
fmt.Print("\a")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Window) ScrollEnd() {
|
||||||
|
var borderThickness int
|
||||||
|
if w.drawBox {
|
||||||
|
borderThickness = -1
|
||||||
|
} else {
|
||||||
|
borderThickness = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
height := w.Box.row2 - w.Box.row1 + borderThickness
|
||||||
|
|
||||||
|
contentLength := len(w.Content)
|
||||||
|
if w.Scrollposition < contentLength-height {
|
||||||
|
w.Scrollposition = contentLength-height
|
||||||
|
} else {
|
||||||
|
fmt.Print("\a")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
main.go
12
main.go
|
@ -487,6 +487,18 @@ func main() {
|
||||||
screen.ReflashScreen(false)
|
screen.ReflashScreen(false)
|
||||||
case 'q', 'Q':
|
case 'q', 'Q':
|
||||||
cui.Exit()
|
cui.Exit()
|
||||||
|
case 'g':
|
||||||
|
screen.Windows[screen.Activewindow].ScrollHome()
|
||||||
|
screen.ReflashScreen(false)
|
||||||
|
case 'G':
|
||||||
|
screen.Windows[screen.Activewindow].ScrollEnd()
|
||||||
|
screen.ReflashScreen(false)
|
||||||
|
case 'd':
|
||||||
|
screen.Windows[screen.Activewindow].PageDown()
|
||||||
|
screen.ReflashScreen(false)
|
||||||
|
case 'u':
|
||||||
|
screen.Windows[screen.Activewindow].PageUp()
|
||||||
|
screen.ReflashScreen(false)
|
||||||
case 'b':
|
case 'b':
|
||||||
success := history.GoBack()
|
success := history.GoBack()
|
||||||
if success {
|
if success {
|
||||||
|
|
Loading…
Reference in New Issue