mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
✨ Support paging - fixes #19
This commit is contained in:
parent
c594155c1a
commit
3e807ab5b8
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Alt-Left and Alt-Right for history navigation (#23)
|
- Alt-Left and Alt-Right for history navigation (#23)
|
||||||
- You can type `..` in the bottom bar to go up a directory in the URL (#21)
|
- You can type `..` in the bottom bar to go up a directory in the URL (#21)
|
||||||
- Error popup for when input string would result in a too long out-of-spec URL (#25)
|
- Error popup for when input string would result in a too long out-of-spec URL (#25)
|
||||||
|
- Paging, using <kbd>d</kbd> and <kbd>u</kbd>, as well as <kbd>Page Up</kbd> and <kbd>Page Down</kbd> (#19)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Bottom bar now says `URL/Num./Search: ` when space is pressed
|
- Bottom bar now says `URL/Num./Search: ` when space is pressed
|
||||||
|
@ -20,7 +20,9 @@ var tabMap = make(map[int]*structs.Page) // Map of tab number to page
|
|||||||
// Holds the actual tab primitives
|
// Holds the actual tab primitives
|
||||||
var tabViews = make(map[int]*cview.TextView)
|
var tabViews = make(map[int]*cview.TextView)
|
||||||
|
|
||||||
|
// Terminal dimensions
|
||||||
var termW int
|
var termW int
|
||||||
|
var termH int
|
||||||
|
|
||||||
// The user input and URL display bar at the bottom
|
// The user input and URL display bar at the bottom
|
||||||
var bottomBar = cview.NewInputField().
|
var bottomBar = cview.NewInputField().
|
||||||
@ -69,6 +71,7 @@ var App = cview.NewApplication().
|
|||||||
SetAfterResizeFunc(func(width int, height int) {
|
SetAfterResizeFunc(func(width int, height int) {
|
||||||
// Store for calculations
|
// Store for calculations
|
||||||
termW = width
|
termW = width
|
||||||
|
termH = height
|
||||||
|
|
||||||
// Shift new tabs created before app startup, when termW == 0
|
// Shift new tabs created before app startup, when termW == 0
|
||||||
// XXX: This is hacky but works. The biggest issue is that there will sometimes be a tiny flash
|
// XXX: This is hacky but works. The biggest issue is that there will sometimes be a tiny flash
|
||||||
@ -247,6 +250,12 @@ func Init() {
|
|||||||
case tcell.KeyCtrlD:
|
case tcell.KeyCtrlD:
|
||||||
go addBookmark()
|
go addBookmark()
|
||||||
return nil
|
return nil
|
||||||
|
case tcell.KeyPgUp:
|
||||||
|
pageUp()
|
||||||
|
return nil
|
||||||
|
case tcell.KeyPgDn:
|
||||||
|
pageDown()
|
||||||
|
return nil
|
||||||
case tcell.KeyRune:
|
case tcell.KeyRune:
|
||||||
// Regular key was sent
|
// Regular key was sent
|
||||||
switch string(event.Rune()) {
|
switch string(event.Rune()) {
|
||||||
@ -271,6 +280,13 @@ func Init() {
|
|||||||
case "?":
|
case "?":
|
||||||
Help()
|
Help()
|
||||||
return nil
|
return nil
|
||||||
|
case "u":
|
||||||
|
pageUp()
|
||||||
|
return nil
|
||||||
|
case "d":
|
||||||
|
pageDown()
|
||||||
|
return nil
|
||||||
|
|
||||||
// Shift+NUMBER keys, for switching to a specific tab
|
// Shift+NUMBER keys, for switching to a specific tab
|
||||||
case "!":
|
case "!":
|
||||||
SwitchTab(0)
|
SwitchTab(0)
|
||||||
|
@ -17,6 +17,18 @@ import (
|
|||||||
|
|
||||||
// This file contains the functions that aren't part of the public API.
|
// This file contains the functions that aren't part of the public API.
|
||||||
|
|
||||||
|
// pageUp scrolls up 75% of the height of the terminal, like Bombadillo.
|
||||||
|
func pageUp() {
|
||||||
|
row, col := tabViews[curTab].GetScrollOffset()
|
||||||
|
tabViews[curTab].ScrollTo(row-(termH/4)*3, col)
|
||||||
|
}
|
||||||
|
|
||||||
|
// pageDown scrolls down 75% of the height of the terminal, like Bombadillo.
|
||||||
|
func pageDown() {
|
||||||
|
row, col := tabViews[curTab].GetScrollOffset()
|
||||||
|
tabViews[curTab].ScrollTo(row+(termH/4)*3, col)
|
||||||
|
}
|
||||||
|
|
||||||
func leftMargin() int {
|
func leftMargin() int {
|
||||||
return int(float64(termW) * viper.GetFloat64("a-general.left_margin"))
|
return int(float64(termW) * viper.GetFloat64("a-general.left_margin"))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user