Browse Source

Adds UP hot key

up-dir
sloum 1 year ago
parent
commit
d747249069
  1. 4
      bombadillo.1
  2. 28
      client.go
  3. 19
      url.go

4
bombadillo.1

@ -111,6 +111,10 @@ Reload the current page (does not destroy forward history).
Quick navigation to the first 10 links on a page. The 0 key will navigate to the link numbered '10', all other numbers navigate to their matching link number.
.TP
.B
U
Move up a level in the current url path. \fI/mydir/mysubdir/myfile.txt\fP would become \fI/mydir/mysubdir/\fP, and so on.
.TP
.B
u
Scroll up an amount corresponding to 75% of your terminal window height in the current document.
.TP

28
client.go

@ -146,42 +146,47 @@ func (c *client) TakeControlInput() {
switch input {
case '1', '2', '3', '4', '5', '6', '7', '8', '9', '0':
// Quick link
if input == '0' {
c.goToLink("10")
} else {
c.goToLink(string(input))
}
case 'j':
// scroll down one line
// Scroll down one line
c.ClearMessage()
c.Scroll(1)
case 'k':
// scroll up one line
// Scroll up one line
c.ClearMessage()
c.Scroll(-1)
case 'q':
// quit bombadillo
// Quit
cui.Exit(0, "")
case 'g':
// scroll to top
// Scroll to top
c.ClearMessage()
c.Scroll(-len(c.PageState.History[c.PageState.Position].WrappedContent))
case 'G':
// scroll to bottom
// Scroll to bottom
c.ClearMessage()
c.Scroll(len(c.PageState.History[c.PageState.Position].WrappedContent))
case 'd':
// scroll down 75%
// Scroll down 75%
c.ClearMessage()
distance := c.Height - c.Height/4
c.Scroll(distance)
case 'u':
// scroll up 75%
// Scroll up 75%
c.ClearMessage()
distance := c.Height - c.Height/4
c.Scroll(-distance)
case 'U':
// Move up a directory for the current host
url := c.PageState.History[c.PageState.Position].Location.Full
c.Visit(UpOneDir(url))
case 'b', 'h':
// go back
// Go back
c.ClearMessage()
err := c.PageState.NavigateHistory(-1)
if err != nil {
@ -193,6 +198,7 @@ func (c *client) TakeControlInput() {
c.Draw()
}
case 'R':
// Refresh the current page
c.ClearMessage()
err := c.ReloadPage()
if err != nil {
@ -202,11 +208,11 @@ func (c *client) TakeControlInput() {
c.Draw()
}
case 'B':
// open the bookmarks browser
// Toggle the bookmark browser
c.BookMarks.ToggleOpen()
c.Draw()
case 'f', 'l':
// go forward
// Go forward
c.ClearMessage()
err := c.PageState.NavigateHistory(1)
if err != nil {
@ -218,7 +224,7 @@ func (c *client) TakeControlInput() {
c.Draw()
}
case '\t':
// Toggle bookmark browser focus on/off
// Toggle bookmark browser focus
c.BookMarks.ToggleFocused()
c.Draw()
case 'n':

19
url.go

@ -3,6 +3,7 @@ package main
import (
"fmt"
"os/user"
"path"
"path/filepath"
"regexp"
"strings"
@ -145,6 +146,24 @@ func MakeUrl(u string) (Url, error) {
return out, nil
}
func UpOneDir(u string) string {
url, err := MakeUrl(u)
if len(url.Resource) < 1 || err != nil {
return u
}
if strings.HasSuffix(url.Resource, "/") {
url.Resource = url.Resource[:len(url.Resource)-1]
}
url.Resource, _ = path.Split(url.Resource)
if url.Scheme == "gopher" {
url.Mime = "1"
}
url.Full = url.Scheme + "://" + url.Host + ":" + url.Port + "/" + url.Mime + url.Resource
return url.Full
}
func parseFinger(u string) (Url, error) {
var out Url
out.Scheme = "finger"

Loading…
Cancel
Save