forked from sloum/bombadillo
Responds to GoMetaLinter for more of the codebase.
This commit is contained in:
parent
3a33320ec5
commit
6d9ae540e3
|
@ -51,7 +51,7 @@ func (c *client) GetSizeOnce() {
|
||||||
os.Exit(5)
|
os.Exit(5)
|
||||||
}
|
}
|
||||||
var h, w int
|
var h, w int
|
||||||
fmt.Sscan(string(out), &h, &w)
|
_, _ = fmt.Sscan(string(out), &h, &w)
|
||||||
c.Height = h
|
c.Height = h
|
||||||
c.Width = w
|
c.Width = w
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func (c *client) GetSize() {
|
||||||
os.Exit(5)
|
os.Exit(5)
|
||||||
}
|
}
|
||||||
var h, w int
|
var h, w int
|
||||||
fmt.Sscan(string(out), &h, &w)
|
_, _ = fmt.Sscan(string(out), &h, &w)
|
||||||
if h != c.Height || w != c.Width {
|
if h != c.Height || w != c.Width {
|
||||||
c.Height = h
|
c.Height = h
|
||||||
c.Width = w
|
c.Width = w
|
||||||
|
@ -268,7 +268,7 @@ func (c *client) routeCommandInput(com *cmdparse.Command) error {
|
||||||
case cmdparse.DOLINKAS:
|
case cmdparse.DOLINKAS:
|
||||||
c.doLinkCommandAs(com.Action, com.Target, com.Value)
|
c.doLinkCommandAs(com.Action, com.Target, com.Value)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unknown command entry!")
|
return fmt.Errorf("Unknown command entry")
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
@ -1049,7 +1049,8 @@ func (c *client) handleWeb(u Url) {
|
||||||
// + + + F U N C T I O N S + + + \\
|
// + + + F U N C T I O N S + + + \\
|
||||||
//--------------------------------------------------\\
|
//--------------------------------------------------\\
|
||||||
|
|
||||||
// Creates a client instance and names the client after the string that is passed in
|
// MakeClient returns a client struct and names the client after
|
||||||
|
// the string that is passed in
|
||||||
func MakeClient(name string) *client {
|
func MakeClient(name string) *client {
|
||||||
c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()}
|
c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()}
|
||||||
return &c
|
return &c
|
||||||
|
|
8
main.go
8
main.go
|
@ -106,7 +106,7 @@ func loadConfig() error {
|
||||||
|
|
||||||
confparser := config.NewParser(file)
|
confparser := config.NewParser(file)
|
||||||
settings, _ = confparser.Parse()
|
settings, _ = confparser.Parse()
|
||||||
file.Close()
|
_ = file.Close()
|
||||||
for _, v := range settings.Settings {
|
for _, v := range settings.Settings {
|
||||||
lowerkey := strings.ToLower(v.Key)
|
lowerkey := strings.ToLower(v.Key)
|
||||||
if lowerkey == "configlocation" {
|
if lowerkey == "configlocation" {
|
||||||
|
@ -128,7 +128,7 @@ func loadConfig() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, v := range settings.Bookmarks.Titles {
|
for i, v := range settings.Bookmarks.Titles {
|
||||||
bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]})
|
_, _ = bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range settings.Certs {
|
for _, v := range settings.Certs {
|
||||||
|
@ -156,7 +156,7 @@ func handleSignals(c <-chan os.Signal) {
|
||||||
switch <-c {
|
switch <-c {
|
||||||
case syscall.SIGTSTP:
|
case syscall.SIGTSTP:
|
||||||
cui.CleanupTerm()
|
cui.CleanupTerm()
|
||||||
syscall.Kill(syscall.Getpid(), syscall.SIGSTOP)
|
_ = syscall.Kill(syscall.Getpid(), syscall.SIGSTOP)
|
||||||
case syscall.SIGCONT:
|
case syscall.SIGCONT:
|
||||||
cui.InitTerm()
|
cui.InitTerm()
|
||||||
bombadillo.Draw()
|
bombadillo.Draw()
|
||||||
|
@ -178,7 +178,7 @@ Examples: bombadillo gopher://bombadillo.colorfield.space
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
`
|
`
|
||||||
fmt.Fprint(os.Stdout, art)
|
_, _ = fmt.Fprint(os.Stdout, art)
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
page.go
3
page.go
|
@ -23,6 +23,8 @@ type Page struct {
|
||||||
// + + + R E C E I V E R S + + + \\
|
// + + + R E C E I V E R S + + + \\
|
||||||
//--------------------------------------------------\\
|
//--------------------------------------------------\\
|
||||||
|
|
||||||
|
// ScrollPositionRange may not be in actual usage....
|
||||||
|
// TODO: find where this is being used
|
||||||
func (p *Page) ScrollPositionRange(termHeight int) (int, int) {
|
func (p *Page) ScrollPositionRange(termHeight int) (int, int) {
|
||||||
termHeight -= 3
|
termHeight -= 3
|
||||||
if len(p.WrappedContent)-p.ScrollPosition < termHeight {
|
if len(p.WrappedContent)-p.ScrollPosition < termHeight {
|
||||||
|
@ -88,6 +90,7 @@ func (p *Page) WrapContent(width int) {
|
||||||
// + + + F U N C T I O N S + + + \\
|
// + + + F U N C T I O N S + + + \\
|
||||||
//--------------------------------------------------\\
|
//--------------------------------------------------\\
|
||||||
|
|
||||||
|
// MakePage returns a Page struct with default values
|
||||||
func MakePage(url Url, content string, links []string) Page {
|
func MakePage(url Url, content string, links []string) Page {
|
||||||
p := Page{make([]string, 0), content, links, url, 0}
|
p := Page{make([]string, 0), content, links, url, 0}
|
||||||
return p
|
return p
|
||||||
|
|
14
pages.go
14
pages.go
|
@ -8,6 +8,9 @@ import (
|
||||||
// + + + T Y P E S + + + \\
|
// + + + T Y P E S + + + \\
|
||||||
//--------------------------------------------------\\
|
//--------------------------------------------------\\
|
||||||
|
|
||||||
|
// Pages is a struct that represents the history of the client.
|
||||||
|
// It functions as a container for the pages (history array) and
|
||||||
|
// tracks the current history length and location.
|
||||||
type Pages struct {
|
type Pages struct {
|
||||||
Position int
|
Position int
|
||||||
Length int
|
Length int
|
||||||
|
@ -18,6 +21,10 @@ type Pages struct {
|
||||||
// + + + R E C E I V E R S + + + \\
|
// + + + R E C E I V E R S + + + \\
|
||||||
//--------------------------------------------------\\
|
//--------------------------------------------------\\
|
||||||
|
|
||||||
|
// NavigateHistory takes a positive or negative integer
|
||||||
|
// and updates the current history position. Checks are done
|
||||||
|
// to make sure that the position moved to is a valid history
|
||||||
|
// location. Returns an error or nil.
|
||||||
func (p *Pages) NavigateHistory(qty int) error {
|
func (p *Pages) NavigateHistory(qty int) error {
|
||||||
newPosition := p.Position + qty
|
newPosition := p.Position + qty
|
||||||
if newPosition < 0 {
|
if newPosition < 0 {
|
||||||
|
@ -30,6 +37,10 @@ func (p *Pages) NavigateHistory(qty int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add gets passed a Page, which gets added to the history
|
||||||
|
// arrayr. Add also updates the current length and position
|
||||||
|
// of the Pages struct to which it belongs. Add also shifts
|
||||||
|
// off array items if necessary.
|
||||||
func (p *Pages) Add(pg Page) {
|
func (p *Pages) Add(pg Page) {
|
||||||
if p.Position == p.Length-1 && p.Length < len(p.History) {
|
if p.Position == p.Length-1 && p.Length < len(p.History) {
|
||||||
p.History[p.Length] = pg
|
p.History[p.Length] = pg
|
||||||
|
@ -47,6 +58,8 @@ func (p *Pages) Add(pg Page) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render wraps the content for the current page and returns
|
||||||
|
// the page content as a string slice
|
||||||
func (p *Pages) Render(termHeight, termWidth int) []string {
|
func (p *Pages) Render(termHeight, termWidth int) []string {
|
||||||
if p.Length < 1 {
|
if p.Length < 1 {
|
||||||
return make([]string, 0)
|
return make([]string, 0)
|
||||||
|
@ -79,6 +92,7 @@ func (p *Pages) Render(termHeight, termWidth int) []string {
|
||||||
// + + + F U N C T I O N S + + + \\
|
// + + + F U N C T I O N S + + + \\
|
||||||
//--------------------------------------------------\\
|
//--------------------------------------------------\\
|
||||||
|
|
||||||
|
// MakePages returns a Pages struct with default values
|
||||||
func MakePages() Pages {
|
func MakePages() Pages {
|
||||||
return Pages{-1, 0, [20]Page{}}
|
return Pages{-1, 0, [20]Page{}}
|
||||||
}
|
}
|
||||||
|
|
5
url.go
5
url.go
|
@ -12,6 +12,11 @@ import (
|
||||||
// + + + T Y P E S + + + \\
|
// + + + T Y P E S + + + \\
|
||||||
//--------------------------------------------------\\
|
//--------------------------------------------------\\
|
||||||
|
|
||||||
|
// Url is a struct representing the different pieces
|
||||||
|
// of a url. This custom struct is used rather than the
|
||||||
|
// built-in url library so-as to support gopher URLs, as
|
||||||
|
// well as track mime-type and renderability (can the
|
||||||
|
// response to the url be rendered as text in the client).
|
||||||
type Url struct {
|
type Url struct {
|
||||||
Scheme string
|
Scheme string
|
||||||
Host string
|
Host string
|
||||||
|
|
Loading…
Reference in New Issue