forked from sloum/bombadillo
Compare commits
18 Commits
Author | SHA1 | Date |
---|---|---|
Sloom Sloum Sluom IV | b171dc2230 | |
Sloom Sloum Sluom IV | 3cbf52fe6d | |
sloum | 38e7ccea52 | |
Sloom Sloum Sluom IV | 30e550c183 | |
Sloom Sloum Sluom IV | df99584222 | |
sloum | 93cf4321d4 | |
Sloom Sloum Sluom IV | 5a91f4ac94 | |
Sloom Sloum Sluom IV | 2a254a42ff | |
R. Aidan Campbell | 1bef2e51a1 | |
Sloom Sloum Sluom IV | ceb83eb5e3 | |
R. Aidan Campbell | 070f7eb6ba | |
R. Aidan Campbell | dac13e1669 | |
R. Aidan Campbell | 984fb4eb2f | |
Sloom Sloum Sluom IV | 59321b8977 | |
Jay Williams | 06a47e9c3d | |
Jay Williams | 80aabcd531 | |
sloum | d747249069 | |
sloum | ec61d49497 |
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ install: install-bin install-man install-desktop clean
|
||||||
|
|
||||||
.PHONY: install-man
|
.PHONY: install-man
|
||||||
install-man: bombadillo.1
|
install-man: bombadillo.1
|
||||||
gzip -k ./bombadillo.1
|
gzip -c ./bombadillo.1 > ./bombadillo.1.gz
|
||||||
install -d ${DESTDIR}${MAN1DIR}
|
install -d ${DESTDIR}${MAN1DIR}
|
||||||
install -m 0644 ./bombadillo.1.gz ${DESTDIR}${MAN1DIR}
|
install -m 0644 ./bombadillo.1.gz ${DESTDIR}${MAN1DIR}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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
|
.TP
|
||||||
.B
|
.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
|
u
|
||||||
Scroll up an amount corresponding to 75% of your terminal window height in the current document.
|
Scroll up an amount corresponding to 75% of your terminal window height in the current document.
|
||||||
.TP
|
.TP
|
||||||
|
@ -253,6 +257,10 @@ homeurl
|
||||||
The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed.
|
The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed.
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
|
maxwidth
|
||||||
|
The number of characters at which lines should be wrapped. If this is bigger than the available terminal width, the full width of the terminal will be used. If a non-integer or an integer less than 10 is given, a default value will be used.
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
savelocation
|
savelocation
|
||||||
The path to the directory that \fBbombadillo\fP should write files to. This must be a valid filepath for the system, must be a directory, and must already exist.
|
The path to the directory that \fBbombadillo\fP should write files to. This must be a valid filepath for the system, must be a directory, and must already exist.
|
||||||
.TP
|
.TP
|
||||||
|
|
15
bookmarks.go
15
bookmarks.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
70
client.go
70
client.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -73,7 +88,7 @@ func (c *client) Draw() {
|
||||||
screen.WriteString("\033[0m")
|
screen.WriteString("\033[0m")
|
||||||
screen.WriteString(c.TopBar.Render(c.Width, c.Options["theme"]))
|
screen.WriteString(c.TopBar.Render(c.Width, c.Options["theme"]))
|
||||||
screen.WriteString("\n")
|
screen.WriteString("\n")
|
||||||
pageContent := c.PageState.Render(c.Height, c.Width-1, (c.Options["theme"] == "color"))
|
pageContent := c.PageState.Render(c.Height, c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color"))
|
||||||
var re *regexp.Regexp
|
var re *regexp.Regexp
|
||||||
if c.Options["theme"] == "inverse" {
|
if c.Options["theme"] == "inverse" {
|
||||||
screen.WriteString("\033[7m")
|
screen.WriteString("\033[7m")
|
||||||
|
@ -146,42 +161,47 @@ func (c *client) TakeControlInput() {
|
||||||
|
|
||||||
switch input {
|
switch input {
|
||||||
case '1', '2', '3', '4', '5', '6', '7', '8', '9', '0':
|
case '1', '2', '3', '4', '5', '6', '7', '8', '9', '0':
|
||||||
|
// Quick link
|
||||||
if input == '0' {
|
if input == '0' {
|
||||||
c.goToLink("10")
|
c.goToLink("10")
|
||||||
} else {
|
} else {
|
||||||
c.goToLink(string(input))
|
c.goToLink(string(input))
|
||||||
}
|
}
|
||||||
case 'j':
|
case 'j':
|
||||||
// scroll down one line
|
// Scroll down one line
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
c.Scroll(1)
|
c.Scroll(1)
|
||||||
case 'k':
|
case 'k':
|
||||||
// scroll up one line
|
// Scroll up one line
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
c.Scroll(-1)
|
c.Scroll(-1)
|
||||||
case 'q':
|
case 'q':
|
||||||
// quit bombadillo
|
// Quit
|
||||||
cui.Exit(0, "")
|
cui.Exit(0, "")
|
||||||
case 'g':
|
case 'g':
|
||||||
// scroll to top
|
// Scroll to top
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
c.Scroll(-len(c.PageState.History[c.PageState.Position].WrappedContent))
|
c.Scroll(-len(c.PageState.History[c.PageState.Position].WrappedContent))
|
||||||
case 'G':
|
case 'G':
|
||||||
// scroll to bottom
|
// Scroll to bottom
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
c.Scroll(len(c.PageState.History[c.PageState.Position].WrappedContent))
|
c.Scroll(len(c.PageState.History[c.PageState.Position].WrappedContent))
|
||||||
case 'd':
|
case 'd':
|
||||||
// scroll down 75%
|
// Scroll down 75%
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
distance := c.Height - c.Height/4
|
distance := c.Height - c.Height/4
|
||||||
c.Scroll(distance)
|
c.Scroll(distance)
|
||||||
case 'u':
|
case 'u':
|
||||||
// scroll up 75%
|
// Scroll up 75%
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
distance := c.Height - c.Height/4
|
distance := c.Height - c.Height/4
|
||||||
c.Scroll(-distance)
|
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':
|
case 'b', 'h':
|
||||||
// go back
|
// Go back
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
err := c.PageState.NavigateHistory(-1)
|
err := c.PageState.NavigateHistory(-1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -193,6 +213,7 @@ func (c *client) TakeControlInput() {
|
||||||
c.Draw()
|
c.Draw()
|
||||||
}
|
}
|
||||||
case 'R':
|
case 'R':
|
||||||
|
// Refresh the current page
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
err := c.ReloadPage()
|
err := c.ReloadPage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -202,11 +223,11 @@ func (c *client) TakeControlInput() {
|
||||||
c.Draw()
|
c.Draw()
|
||||||
}
|
}
|
||||||
case 'B':
|
case 'B':
|
||||||
// open the bookmarks browser
|
// Toggle the bookmark browser
|
||||||
c.BookMarks.ToggleOpen()
|
c.BookMarks.ToggleOpen()
|
||||||
c.Draw()
|
c.Draw()
|
||||||
case 'f', 'l':
|
case 'f', 'l':
|
||||||
// go forward
|
// Go forward
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
err := c.PageState.NavigateHistory(1)
|
err := c.PageState.NavigateHistory(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -218,7 +239,7 @@ func (c *client) TakeControlInput() {
|
||||||
c.Draw()
|
c.Draw()
|
||||||
}
|
}
|
||||||
case '\t':
|
case '\t':
|
||||||
// Toggle bookmark browser focus on/off
|
// Toggle bookmark browser focus
|
||||||
c.BookMarks.ToggleFocused()
|
c.BookMarks.ToggleFocused()
|
||||||
c.Draw()
|
c.Draw()
|
||||||
case 'n':
|
case 'n':
|
||||||
|
@ -258,7 +279,7 @@ func (c *client) TakeControlInput() {
|
||||||
}
|
}
|
||||||
err = c.NextSearchItem(0)
|
err = c.NextSearchItem(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.PageState.History[c.PageState.Position].WrapContent(c.Width-1,(c.Options["theme"] == "color"))
|
c.PageState.History[c.PageState.Position].WrapContent(c.Width-1,getMaxWidth(c.Options),(c.Options["theme"] == "color"))
|
||||||
c.Draw()
|
c.Draw()
|
||||||
}
|
}
|
||||||
case ':', ' ':
|
case ':', ' ':
|
||||||
|
@ -988,7 +1009,7 @@ func (c *client) handleGopher(u Url) {
|
||||||
} else {
|
} else {
|
||||||
pg.FileType = "text"
|
pg.FileType = "text"
|
||||||
}
|
}
|
||||||
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color"))
|
||||||
c.PageState.Add(pg)
|
c.PageState.Add(pg)
|
||||||
c.SetPercentRead()
|
c.SetPercentRead()
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
|
@ -1015,7 +1036,7 @@ func (c *client) handleGemini(u Url) {
|
||||||
u.Mime = capsule.MimeMin
|
u.Mime = capsule.MimeMin
|
||||||
pg := MakePage(u, capsule.Content, capsule.Links)
|
pg := MakePage(u, capsule.Content, capsule.Links)
|
||||||
pg.FileType = capsule.MimeMaj
|
pg.FileType = capsule.MimeMaj
|
||||||
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color"))
|
||||||
c.PageState.Add(pg)
|
c.PageState.Add(pg)
|
||||||
c.SetPercentRead()
|
c.SetPercentRead()
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
|
@ -1081,7 +1102,7 @@ func (c *client) handleLocal(u Url) {
|
||||||
if ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".png" {
|
if ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".png" {
|
||||||
pg.FileType = "image"
|
pg.FileType = "image"
|
||||||
}
|
}
|
||||||
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color"))
|
||||||
c.PageState.Add(pg)
|
c.PageState.Add(pg)
|
||||||
c.SetPercentRead()
|
c.SetPercentRead()
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
|
@ -1097,7 +1118,7 @@ func (c *client) handleFinger(u Url) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pg := MakePage(u, content, []string{})
|
pg := MakePage(u, content, []string{})
|
||||||
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color"))
|
||||||
c.PageState.Add(pg)
|
c.PageState.Add(pg)
|
||||||
c.SetPercentRead()
|
c.SetPercentRead()
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
|
@ -1117,7 +1138,7 @@ func (c *client) handleWeb(u Url) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pg := MakePage(u, page.Content, page.Links)
|
pg := MakePage(u, page.Content, page.Links)
|
||||||
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color"))
|
||||||
c.PageState.Add(pg)
|
c.PageState.Add(pg)
|
||||||
c.SetPercentRead()
|
c.SetPercentRead()
|
||||||
c.ClearMessage()
|
c.ClearMessage()
|
||||||
|
@ -1258,3 +1279,16 @@ func updateTimeouts(timeoutString string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getMaxWidth looks through the given options map and will safely return a max width to render
|
||||||
|
// if the option is missing or malformed, it will default to 100. A sane minimum of 10 is enforced.
|
||||||
|
func getMaxWidth(options map[string]string) int {
|
||||||
|
out, err := strconv.Atoi(options["maxwidth"])
|
||||||
|
if err != nil {
|
||||||
|
out = 100
|
||||||
|
}
|
||||||
|
if out < 10 {
|
||||||
|
out = 10
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package cmdparse
|
package cmdparse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package cmdparse
|
package cmdparse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
15
cui/cui.go
15
cui/cui.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package cui
|
package cui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
16
defaults.go
16
defaults.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -56,6 +71,7 @@ var defaultOptions = map[string]string{
|
||||||
"theme": "normal", // "normal", "inverted", "color"
|
"theme": "normal", // "normal", "inverted", "color"
|
||||||
"timeout": "15", // connection timeout for gopher/gemini in seconds
|
"timeout": "15", // connection timeout for gopher/gemini in seconds
|
||||||
"webmode": "none", // "none", "gui", "lynx", "w3m", "elinks"
|
"webmode": "none", // "none", "gui", "lynx", "w3m", "elinks"
|
||||||
|
"maxwidth": "100",
|
||||||
}
|
}
|
||||||
|
|
||||||
// homePath will return the path to your home directory as a string
|
// homePath will return the path to your home directory as a string
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package finger
|
package finger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
15
footbar.go
15
footbar.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package gemini
|
package gemini
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
// Contains the building blocks of a gopher client: history, url, and view.
|
// Contains the building blocks of a gopher client: history, url, and view.
|
||||||
// History handles the browsing session and view represents individual
|
// History handles the browsing session and view represents individual
|
||||||
// text based resources, the url represents a parsed url.
|
// text based resources, the url represents a parsed url.
|
||||||
|
|
15
headbar.go
15
headbar.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
15
help.go
15
help.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// ERRS maps commands to their syntax error message
|
// ERRS maps commands to their syntax error message
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
// This will build for osx without a build tag based on the filename
|
// This will build for osx without a build tag based on the filename
|
||||||
|
|
||||||
package http
|
package http
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
// +build !darwin,!windows
|
// +build !darwin,!windows
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
// This will only build for windows based on the filename
|
// This will only build for windows based on the filename
|
||||||
// no build tag required
|
// no build tag required
|
||||||
package http
|
package http
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package local
|
package local
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
30
main.go
30
main.go
|
@ -3,21 +3,21 @@ package main
|
||||||
// Bombadillo is an internet client for the terminal of unix or
|
// Bombadillo is an internet client for the terminal of unix or
|
||||||
// unix-like systems.
|
// unix-like systems.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2019 Brian Evans
|
/*
|
||||||
//
|
* Copyright (C) 2022 Brian Evans
|
||||||
// This program is free software: you can redistribute it and/or modify
|
*
|
||||||
// it under the terms of the GNU General Public License as published by
|
* This program is free software: you can redistribute it and/or modify
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
* it under the terms of the GNU General Public License as published by
|
||||||
// (at your option) any later version.
|
* the Free Software Foundation, version 3 of the License.
|
||||||
//
|
*
|
||||||
// This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
//
|
*
|
||||||
// You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
45
page.go
45
page.go
|
@ -1,10 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"tildegit.org/sloum/bombadillo/tdiv"
|
"tildegit.org/sloum/bombadillo/tdiv"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
//------------------------------------------------\\
|
//------------------------------------------------\\
|
||||||
|
@ -65,12 +80,12 @@ func (p *Page) RenderImage(width int) {
|
||||||
// width and updates the WrappedContent
|
// width and updates the WrappedContent
|
||||||
// of the Page struct width a string slice
|
// of the Page struct width a string slice
|
||||||
// of the wrapped data
|
// of the wrapped data
|
||||||
func (p *Page) WrapContent(width int, color bool) {
|
func (p *Page) WrapContent(width, maxWidth int, color bool) {
|
||||||
if p.FileType == "image" {
|
if p.FileType == "image" {
|
||||||
p.RenderImage(width)
|
p.RenderImage(width)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
width = min(width, 100)
|
width = min(width, maxWidth)
|
||||||
counter := 0
|
counter := 0
|
||||||
spacer := ""
|
spacer := ""
|
||||||
var content strings.Builder
|
var content strings.Builder
|
||||||
|
@ -83,7 +98,10 @@ func (p *Page) WrapContent(width int, color bool) {
|
||||||
} else if strings.HasSuffix(p.Location.Mime, "gemini") { //gemini document
|
} else if strings.HasSuffix(p.Location.Mime, "gemini") { //gemini document
|
||||||
spacer = " "
|
spacer = " "
|
||||||
}
|
}
|
||||||
for _, ch := range []rune(p.RawContent) {
|
|
||||||
|
runeArr := []rune(p.RawContent)
|
||||||
|
for i := 0; i < len(runeArr); i++ {
|
||||||
|
ch := runeArr[i]
|
||||||
if escape {
|
if escape {
|
||||||
if color {
|
if color {
|
||||||
esc.WriteRune(ch)
|
esc.WriteRune(ch)
|
||||||
|
@ -109,7 +127,7 @@ func (p *Page) WrapContent(width int, color bool) {
|
||||||
counter = 0
|
counter = 0
|
||||||
}
|
}
|
||||||
} else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' || ch == '\a' {
|
} else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' || ch == '\a' {
|
||||||
// Get rid of control characters we dont want
|
// Get rid of control characters we don't want
|
||||||
continue
|
continue
|
||||||
} else if ch == 27 {
|
} else if ch == 27 {
|
||||||
if p.Location.Scheme == "local" {
|
if p.Location.Scheme == "local" {
|
||||||
|
@ -125,9 +143,24 @@ func (p *Page) WrapContent(width int, color bool) {
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
if counter <= width {
|
// peek forward to see if we can render the word without going over
|
||||||
|
j := i
|
||||||
|
for ; j < len(runeArr) && !unicode.IsSpace(runeArr[j]); j++ {
|
||||||
|
if counter+(j-i) > width+1 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we can render the rest of the word, write the next letter. else, skip to the next line.
|
||||||
|
// TODO(raidancampbell): optimize this to write out the whole word, this will involve referencing the
|
||||||
|
// above special cases
|
||||||
|
if counter+(j-i) <= width+1 && !(j == i && counter == width+1) {
|
||||||
content.WriteRune(ch)
|
content.WriteRune(ch)
|
||||||
counter++
|
counter++
|
||||||
|
} else if ch == ' ' || ch == '\t' {
|
||||||
|
// we want to wrap and write this char, but it's a space. eat it to prevent the next line from
|
||||||
|
// having a leading whitespace because of our wrapping
|
||||||
|
counter++
|
||||||
} else {
|
} else {
|
||||||
content.WriteRune('\n')
|
content.WriteRune('\n')
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
71
page_test.go
71
page_test.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -20,8 +35,9 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
|
||||||
Color bool
|
Color bool
|
||||||
}
|
}
|
||||||
type args struct {
|
type args struct {
|
||||||
width int
|
width int
|
||||||
color bool
|
maxWidth int
|
||||||
|
color bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a Url for use by the MakePage function
|
// create a Url for use by the MakePage function
|
||||||
|
@ -41,22 +57,56 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
args{
|
args{
|
||||||
|
10,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Long line wrapped to 10 columns",
|
"multiple words should wrap at the right point",
|
||||||
"0123456789 123456789 123456789 123456789 123456789\n",
|
"01 345 789 123456789 123456789 123456789 123456789\n",
|
||||||
[]string{
|
[]string{
|
||||||
"0123456789",
|
"01 345 789",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789 ",
|
||||||
" 123456789",
|
"123456789",
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
args{
|
args{
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Long line wrapped to 10 columns, leading spaces omitted when wrapping",
|
||||||
|
"0123456789 123456789 123456789 123456789 123456789\n",
|
||||||
|
[]string{
|
||||||
|
"0123456789",
|
||||||
|
"123456789 ",
|
||||||
|
"123456789 ",
|
||||||
|
"123456789 ",
|
||||||
|
"123456789",
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
args{
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Intentional leading spaces aren't trimmed",
|
||||||
|
"01 345\n 789 123456789\n",
|
||||||
|
[]string{
|
||||||
|
"01 345",
|
||||||
|
" 789 ",
|
||||||
|
"123456789",
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
args{
|
||||||
|
10,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
@ -77,6 +127,7 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
args{
|
args{
|
||||||
|
10,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
@ -85,7 +136,7 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
p := MakePage(url, tt.input, []string{""})
|
p := MakePage(url, tt.input, []string{""})
|
||||||
p.WrapContent(tt.args.width-1, tt.args.color)
|
p.WrapContent(tt.args.width-1, tt.args.maxWidth, tt.args.color)
|
||||||
if !reflect.DeepEqual(p.WrappedContent, tt.expects) {
|
if !reflect.DeepEqual(p.WrappedContent, tt.expects) {
|
||||||
t.Errorf("Test failed - %s\nexpects %s\nactual %s", tt.name, tt.expects, p.WrappedContent)
|
t.Errorf("Test failed - %s\nexpects %s\nactual %s", tt.name, tt.expects, p.WrappedContent)
|
||||||
}
|
}
|
||||||
|
|
19
pages.go
19
pages.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -60,7 +75,7 @@ func (p *Pages) Add(pg Page) {
|
||||||
|
|
||||||
// Render wraps the content for the current page and returns
|
// Render wraps the content for the current page and returns
|
||||||
// the page content as a string slice
|
// the page content as a string slice
|
||||||
func (p *Pages) Render(termHeight, termWidth int, color bool) []string {
|
func (p *Pages) Render(termHeight, termWidth, maxWidth int, color bool) []string {
|
||||||
if p.Length < 1 {
|
if p.Length < 1 {
|
||||||
return make([]string, 0)
|
return make([]string, 0)
|
||||||
}
|
}
|
||||||
|
@ -68,7 +83,7 @@ func (p *Pages) Render(termHeight, termWidth int, color bool) []string {
|
||||||
prev := len(p.History[p.Position].WrappedContent)
|
prev := len(p.History[p.Position].WrappedContent)
|
||||||
|
|
||||||
if termWidth != p.History[p.Position].WrapWidth || p.History[p.Position].Color != color {
|
if termWidth != p.History[p.Position].WrapWidth || p.History[p.Position].Color != color {
|
||||||
p.History[p.Position].WrapContent(termWidth, color)
|
p.History[p.Position].WrapContent(termWidth, maxWidth, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
now := len(p.History[p.Position].WrappedContent)
|
now := len(p.History[p.Position].WrappedContent)
|
||||||
|
|
15
tdiv/tdiv.go
15
tdiv/tdiv.go
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package tdiv
|
package tdiv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
// Package telnet provides a function that starts a telnet session in a subprocess.
|
// Package telnet provides a function that starts a telnet session in a subprocess.
|
||||||
package telnet
|
package telnet
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package termios
|
package termios
|
||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
// +build !linux
|
// +build !linux
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package termios
|
package termios
|
||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package termios
|
package termios
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
34
url.go
34
url.go
|
@ -1,8 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Brian Evans
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -145,6 +161,24 @@ func MakeUrl(u string) (Url, error) {
|
||||||
return out, nil
|
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) {
|
func parseFinger(u string) (Url, error) {
|
||||||
var out Url
|
var out Url
|
||||||
out.Scheme = "finger"
|
out.Scheme = "finger"
|
||||||
|
|
Loading…
Reference in New Issue