Compare commits

...

63 Commits

Author SHA1 Message Date
Sloom Sloum Sluom IV 757305db66 Merge pull request 'Release 2.3.3 to master' (#204) from develop into master
Reviewed-on: sloum/bombadillo#204
2020-11-20 04:38:12 +00:00
Sloom Sloum Sluom IV a8456f7e98 Merge pull request 'release2.3.3 -> develop' (#203) from release2.3.3 into develop
Reviewed-on: sloum/bombadillo#203
2020-11-20 04:26:34 +00:00
sloum 8796dffd6e Minor adjustment to help output for jump command 2020-11-19 20:09:53 -08:00
Sloom Sloum Sluom IV a6a324acb3 Merge pull request 'Adds a jump command' (#202) from over-command into release2.3.3
Reviewed-on: sloum/bombadillo#202
2020-11-20 04:07:15 +00:00
sloum 4de473441a Solves merge conflicts with base and updates man page language 2020-11-19 20:06:22 -08:00
Sloom Sloum Sluom IV b8ae9d659c Merge pull request 'Adds version command' (#198) from version-command into release2.3.3
Reviewed-on: sloum/bombadillo#198
2020-11-20 04:02:19 +00:00
sloum 7d722d7dfa Adds a jump command to allow for navigating by history location as an alternate to a tabbed workflow 2020-11-14 15:40:18 -08:00
sloum f18dc293fd Removes previous version build system in favor of simple variable 2020-11-12 20:51:21 -08:00
sloum ee56961b20 Fixes a regression where searches did not clear out previous search highlights 2020-11-12 20:24:19 -08:00
sloum d78e2f4205 Adds further fixes to the man page. I had noticed some issues. 2020-11-08 10:30:22 -08:00
sloum 7219f6cae1 Merge branch 'version-command' of https://tildegit.org/sloum/Bombadillo into version-command 2020-11-05 19:34:16 -08:00
sloum 1ae3312ad6 Handles the case where no version information is available 2020-11-05 19:33:54 -08:00
Sloom Sloum Sluom IV 20b92fdc02 Merge branch 'release2.3.3' into version-command 2020-11-06 03:28:49 +00:00
Sloom Sloum Sluom IV ebcd1ff1d7 Merge pull request 'Minor fix to how we verify hostnames' (#197) from tls-commonname-check into release2.3.3
Reviewed-on: sloum/bombadillo#197
2020-11-06 03:28:31 +00:00
Sloom Sloum Sluom IV 14340034f6 Merge branch 'release2.3.3' into tls-commonname-check 2020-11-06 03:27:53 +00:00
asdf 8c838ce491 Merge pull request 'WIP Initial support for some unicode line endings' (#200) from unicode-line-endings into release2.3.3
Reviewed-on: sloum/bombadillo#200
2020-11-06 02:34:08 +00:00
sloum ed084298c7 Fixes merge conflicts with base branch 2020-11-05 07:48:42 -08:00
sloum 82d0742d52 Adds update to man page 2020-11-05 07:47:08 -08:00
Sloom Sloum Sluom IV 33e78753ea Merge branch 'release2.3.3' into unicode-line-endings 2020-11-05 15:44:50 +00:00
asdf 388218a5b6 Initial support for some unicode line endings 2020-11-05 21:28:54 +11:00
Sloom Sloum Sluom IV ddb73018d9 Merge pull request 'Solves the lynx lack of 404 issue' (#196) from lynx404 into release2.3.3
Reviewed-on: sloum/bombadillo#196
2020-11-02 02:55:29 +00:00
Sloom Sloum Sluom IV b48126d971 Merge branch 'release2.3.3' into lynx404 2020-11-02 02:53:45 +00:00
Sloom Sloum Sluom IV a6375ecc21 Merge pull request 'improve-command-error-messages' (#195) from improve-command-error-messages into release2.3.3
Reviewed-on: sloum/bombadillo#195
2020-11-02 02:53:23 +00:00
Sloom Sloum Sluom IV 49ba8313c7 Merge branch 'release2.3.3' into improve-command-error-messages 2020-11-02 02:53:15 +00:00
sloum 228ec598ab Adds version command 2020-11-01 06:55:46 -08:00
sloum 3624fd9510 Minor fix to how we verify hostnames 2020-11-01 06:45:11 -08:00
Sloom Sloum Sluom IV 7136a49fbe Merge branch 'release2.3.3' into lynx404 2020-11-01 14:41:43 +00:00
Sloom Sloum Sluom IV d190e0ad00 Merge pull request 'Adds spacing to gemini docs to normalize the formatting with gopher docs' (#188) from gemini-gutter into release2.3.3
Reviewed-on: sloum/bombadillo#188

Merging in gemini and gopher link number gutter updates. This will create a more unified look between the protocols.
2020-11-01 14:09:25 +00:00
sloum 4f166ca61a Adds a prefix string to help output 2020-11-01 06:01:17 -08:00
asdf 53de1b5662 Minor correction to help text 2020-11-01 21:09:41 +11:00
Sloom Sloum Sluom IV 5581419489 Merge branch 'release2.3.3' into improve-command-error-messages 2020-11-01 05:18:47 +00:00
sloum c9a7e0ff25 Merge branch 'improve-command-error-messages' of https://tildegit.org/sloum/Bombadillo into improve-command-error-messages 2020-10-31 22:05:54 -07:00
sloum 89095351a8 Fixes help to take an optional action as a value to get syntax for a given command 2020-10-31 22:05:27 -07:00
sloum a3cb016449 Brings gopher link numbering style inline with the other protocols 2020-10-31 21:44:45 -07:00
Sloom Sloum Sluom IV 8789b4d6af Merge branch 'release2.3.3' into gemini-gutter 2020-11-01 04:39:05 +00:00
sloum 2270dee513 Uses asdf's suggestion to reduce HasPrefix overhead by setting the spacer at the beginning of the document wrap code 2020-10-24 10:10:06 -07:00
Sloom Sloum Sluom IV d2e238baac Merge pull request 'Improved command error messages' (#189) from improve-command-error-messages into release2.3.3
Reviewed-on: sloum/bombadillo#189
2020-10-24 16:42:19 +00:00
Sloom Sloum Sluom IV 7ef32afd4a Merge branch 'release2.3.3' into improve-command-error-messages 2020-10-24 16:42:07 +00:00
sloum bafa5a0739 Solves the lynx lack of 404 issue 2020-09-17 21:24:16 -07:00
asdf 7dc68a18bf Corrected several issues identified during review 2020-09-14 06:17:54 +10:00
asdf 86ba01b1d9 Updated branch, reduced to implementing improved error messages 2020-09-11 14:30:17 +10:00
asdf 568de7d3b3 Merge branch 'develop' into improve-command-error-messages 2020-09-10 14:49:00 +10:00
Sloom Sloum Sluom IV 7d326eaba6 Updates gitinore to ignore swap files 2020-09-08 21:37:01 -07:00
Sloom Sloum Sluom IV 92c04fed7f Merge branch 'gemini-gutter' of https://tildegit.org/sloum/bombadillo into gemini-gutter 2020-09-08 21:36:23 -07:00
Sloom Sloum Sluom IV 36b256da07 Removes swap files 2020-09-08 21:35:59 -07:00
Sloom Sloum Sluom IV 824d8bbf81 Merge branch 'release2.3.3' into gemini-gutter 2020-09-09 04:34:07 +00:00
Sloom Sloum Sluom IV 01d071e510 Adds spacing to gemini docs to normalize the formatting with gopher docs 2020-09-08 21:20:34 -07:00
Sloom Sloum Sluom IV 51eade565f Merge pull request 'Update development documentation to reflect the current release process' (#187) from update-release-process-documentation into release2.3.3
Reviewed-on: sloum/bombadillo#187
2020-09-09 02:25:48 +00:00
asdf ad9b5f567e Merge branch 'release2.3.3' into update-release-process-documentation 2020-09-08 05:21:08 +00:00
asdf 3031536a0c Updated to reflect the current release process 2020-09-08 15:10:52 +10:00
Sloom Sloum Sluom IV 26a5e3869d Merge pull request 'Handle input errors while returning to correct terminal mode' (#186) from handle_input_errors into release2.3.3
Reviewed-on: sloum/bombadillo#186
2020-09-08 04:18:07 +00:00
asdf 2f8eedded7 Handle input errors while returning to correct terminal mode 2020-09-08 13:41:52 +10:00
Sloom Sloum Sluom IV 7f3705fba6 Adds more help documentation 2020-07-16 22:05:37 -07:00
Sloom Sloum Sluom IV 51cdb686f6 Adds more help pages 2020-07-02 11:37:00 -07:00
sloum 55a31fa8df Adds more help documentation 2020-06-29 21:18:20 -07:00
Sloom Sloum Sluom IV 8baf53d32b Adds more help sections 2020-06-23 20:31:32 -07:00
Sloom Sloum Sluom IV 8b7e52bd5a Adds help files to Makefile and adds more help content 2020-06-21 21:04:40 -07:00
Sloom Sloum Sluom IV 975a3e34fd Adds more help files 2020-06-21 15:53:31 -07:00
Sloom Sloum Sluom IV 3ffd878ad6 Working help requests! 2020-06-21 10:16:05 -07:00
Sloom Sloum Sluom IV 4a297490c1 Adds better error messaging for commands and starts the help documentation 2020-06-20 22:33:59 -07:00
Sloom Sloum Sluom IV abc6a170dc Merge pull request 'Develop -> Master' (#172) from develop into master 2020-05-30 12:52:48 -04:00
Sloom Sloum Sluom IV e06de9bac1 Merge pull request 'Release of v.2.3.0 to master' (#160) from develop into master 2020-05-24 12:47:34 -04:00
Sloom Sloum Sluom IV 61ae2859bf Merge pull request 'Release 2.2.0' (#140) from develop into master 2020-03-23 01:29:16 -04:00
17 changed files with 181 additions and 58 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
bombadillo
*.asciinema
*.swp

View File

@ -25,10 +25,10 @@ Changes are implemented to the default branch when:
### Process for introducing a new change
Please refer to our [notes on contributing](README.md#contributing) to get an understanding of how new changes are initiated, the type of changes accepted and the review process.
Before you begin, please refer to our [notes on contributing](README.md#contributing) to get an understanding of how new changes are initiated, the type of changes accepted and the review process.
1. Create a new feature branch based on the **develop** branch.
1. Raise a pull request (PR) targeting the **develop** branch.
1. Raise a pull request (PR) targeting the current release branch (confirm this in the issue comments before proceeding).
1. The PR is reviewed.
1. If the PR is approved, it is merged.
1. The version number is incremented, along with any other release activity.

View File

@ -13,17 +13,9 @@ test : GOCMD := go1.11.13
# %:z - so settle for %z.
BUILD_TIME := ${shell date "+%Y-%m-%dT%H:%M%z"}
# If VERSION is empty or not defined use the contents of the VERSION file
VERSION := ${shell git describe --exact-match 2> /dev/null}
ifndef VERSION
VERSION := ${shell cat ./VERSION}
endif
LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}"
.PHONY: build
build:
${GOCMD} build ${LDFLAGS} -o ${BINARY}
${GOCMD} build -o ${BINARY}
.PHONY: install
install: install-bin install-man install-desktop clean

View File

@ -1 +1 @@
2.3.2
2.3.3

View File

@ -181,6 +181,14 @@ home
Navigates to the document set by the \fIhomeurl\fP setting. \fIh\fP can be entered, rather than the full \fIhome\fP.
.TP
.B
jump
Navigates to the previous page in history from the current page. Useful for keeping the current page in your history while still browsing. \fIj\fP can be used instead of the full \fIjump\fP.
.TP
.B
jump [history location]
Navigates to the given history location. The history location should be an integer between 0 and 20. \fIj\fP can be used instead of the full \fIjump\fP.
.TP
.B
purge *
Deletes all pinned gemini server certificates. \fIp\fP can be used instead of the full \fIpurge\fP.
.TP
@ -209,6 +217,10 @@ set [setting name] [value]
Sets the value for a given configuration setting. \fIs\fP can be used instead of the full \fIset\fP.
.TP
.B
version
Shows the current Bombadillo version number.
.TP
.B
write .
Writes the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the directory set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP.
.TP
@ -246,7 +258,7 @@ The path to the directory that \fBbombadillo\fP should write files to. This must
.TP
.B
searchengine
The url to use for the LINE COMMANDs \fI?\fP and \fIsearch\fP. Should be a valid search path that terms may be appended to.
The url to use for the LINE COMMAND \fIsearch\fP. Should be a valid search path that terms may be appended to.
.TP
.B
telnetcommand
@ -259,6 +271,8 @@ Can toggle between visual modes. Valid values are \fInormal\fP, \fIcolor\fP, and
.B
timeout
The number of seconds after which connections to gopher or gemini servers should time out if the server has not responded.
.TP
.B
webmode
Controls behavior when following web links. The following values are valid: \fInone\fP will disable following web links, \fIgui\fP will have the browser attempt to open web links in a user's default graphical web browser; \fIlynx\fP, \fIw3m\fP, and \fIelinks\fP will have the browser attempt to use the selected terminal web browser to handle the rendering of web pages and will display the pages directly in Bombadillo.

View File

@ -258,6 +258,7 @@ func (c *client) TakeControlInput() {
}
err = c.NextSearchItem(0)
if err != nil {
c.PageState.History[c.PageState.Position].WrapContent(c.Width-1,(c.Options["theme"] == "color"))
c.Draw()
}
case ':', ' ':
@ -344,23 +345,41 @@ func (c *client) simpleCommand(action string) {
case "SEARCH":
c.search("", "", "?")
case "HELP", "?":
go c.Visit(helplocation)
c.Visit(helplocation)
case "JUMP", "J":
err := c.PageState.CopyHistory(-1)
if err != nil {
c.SetMessage(err.Error(), false)
c.DrawMessage()
} else {
c.Draw()
}
case "VERSION":
ver := version
if ver == "" {
ver = "Improperly compiled, no version information"
}
c.SetMessage("Bombadillo version: " + ver, false)
c.DrawMessage()
default:
c.SetMessage(fmt.Sprintf("Unknown action %q", action), true)
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
}
}
func (c *client) doCommand(action string, values []string) {
if length := len(values); length != 1 {
c.SetMessage(fmt.Sprintf("Expected 1 argument, received %d", len(values)), true)
c.DrawMessage()
return
}
switch action {
case "CHECK", "C":
case "C", "CHECK":
c.displayConfigValue(values[0])
c.DrawMessage()
case "HELP", "?":
if val, ok := ERRS[values[0]]; ok {
c.SetMessage("Usage: " + val, false)
} else {
msg := fmt.Sprintf("%q is not a valid command; help syntax: %s", values[0], ERRS[action])
c.SetMessage(msg, false)
}
c.DrawMessage()
case "PURGE", "P":
err := c.Certs.Purge(values[0])
if err != nil {
@ -403,26 +422,23 @@ func (c *client) doCommand(action string, values []string) {
fn = "index"
}
c.saveFile(u, fn)
default:
c.SetMessage(fmt.Sprintf("Unknown action %q", action), true)
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
}
}
func (c *client) doCommandAs(action string, values []string) {
if len(values) < 2 {
c.SetMessage(fmt.Sprintf("Expected 2+ arguments, received %d", len(values)), true)
c.DrawMessage()
return
}
if values[0] == "." {
values[0] = c.PageState.History[c.PageState.Position].Location.Full
}
switch action {
case "ADD", "A":
if len(values) < 2 {
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
return
}
if values[0] == "." {
values[0] = c.PageState.History[c.PageState.Position].Location.Full
}
msg, err := c.BookMarks.Add(values)
if err != nil {
c.SetMessage(err.Error(), true)
@ -441,8 +457,18 @@ func (c *client) doCommandAs(action string, values []string) {
c.Draw()
}
case "SEARCH":
if len(values) < 2 {
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
return
}
c.search(strings.Join(values, " "), "", "")
case "SET", "S":
if len(values) < 2 {
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
return
}
if _, ok := c.Options[values[0]]; ok {
val := strings.Join(values[1:], " ")
if !validateOpt(values[0], val) {
@ -473,7 +499,7 @@ func (c *client) doCommandAs(action string, values []string) {
c.SetMessage(fmt.Sprintf("Unable to set %s, it does not exist", values[0]), true)
c.DrawMessage()
default:
c.SetMessage(fmt.Sprintf("Unknown command structure"), true)
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
}
}
@ -523,7 +549,7 @@ func (c *client) doLinkCommandAs(action, target string, values []string) {
out = append(out, values...)
c.doCommandAs(action, out)
default:
c.SetMessage(fmt.Sprintf("Unknown command structure"), true)
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
}
}
@ -630,6 +656,15 @@ func (c *client) doLinkCommand(action, target string) {
link := links[num]
c.SetMessage(fmt.Sprintf("[%d] %s", num+1, link), false)
c.DrawMessage()
case "JUMP", "J":
num--
err = c.PageState.CopyHistory(num)
if err != nil {
c.SetMessage(err.Error(), false)
c.DrawMessage()
} else {
c.Draw()
}
case "WRITE", "W":
links := c.PageState.History[c.PageState.Position].Links
if len(links) < num || num < 1 {
@ -655,7 +690,7 @@ func (c *client) doLinkCommand(action, target string) {
}
c.saveFile(u, fn)
default:
c.SetMessage("Unknown command structure", true)
c.SetMessage(syntaxErrorMessage(action), true)
c.DrawMessage()
}
@ -977,6 +1012,7 @@ func (c *client) handleGemini(u Url) {
case 2:
// Success
if capsule.MimeMaj == "text" || (c.Options["showimages"] == "true" && capsule.MimeMaj == "image") {
u.Mime = capsule.MimeMin
pg := MakePage(u, capsule.Content, capsule.Links)
pg.FileType = capsule.MimeMaj
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
@ -1203,6 +1239,13 @@ func findAvailableFileName(fpath, fname string) (string, error) {
return savePath, nil
}
func syntaxErrorMessage(action string) string {
if val, ok := ERRS[action]; ok {
return fmt.Sprintf("Incorrect syntax. Try: %s", val)
}
return fmt.Sprintf("Unknown command %q", action)
}
func updateTimeouts(timeoutString string) error {
sec, err := strconv.Atoi(timeoutString)
if err != nil {

View File

@ -72,7 +72,7 @@ func (s *scanner) scanText() Token {
"S", "SET", "R", "RELOAD", "SEARCH",
"Q", "QUIT", "B", "BOOKMARKS", "H",
"HOME", "?", "HELP", "C", "CHECK",
"P", "PURGE":
"P", "PURGE", "JUMP", "J", "VERSION":
return Token{Action, capInput}
}

View File

@ -94,10 +94,10 @@ func (p *Parser) parseAction() (*Command, error) {
case Value:
cm.Target = t.val
cm.Type = DOLINK
case Word:
case Word, Action:
cm.Value = append(cm.Value, t.val)
cm.Type = DO
case Action, Whitespace:
case Whitespace:
return nil, fmt.Errorf("Found %q (%d), expected value", t.val, t.kind)
}
t = p.scan()

View File

@ -102,6 +102,7 @@ func Getch() rune {
func GetLine(prefix string) (string, error) {
termios.SetLineMode()
defer termios.SetCharMode()
reader := bufio.NewReader(os.Stdin)
fmt.Print(prefix)
@ -110,7 +111,6 @@ func GetLine(prefix string) (string, error) {
return "", err
}
termios.SetCharMode()
return text[:len(text)-1], nil
}

View File

@ -78,7 +78,7 @@ func (t *TofuDigest) Match(host, localCert string, cState *tls.ConnectionState)
return fmt.Errorf("EXP")
}
if err := cert.VerifyHostname(host); err != nil {
if err := cert.VerifyHostname(host); err != nil && cert.Subject.CommonName != host {
return fmt.Errorf("Certificate error: %s", err)
}
@ -107,7 +107,7 @@ func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error {
continue
}
if err := cert.VerifyHostname(host); err != nil {
if err := cert.VerifyHostname(host); err != nil && cert.Subject.CommonName != host {
reasons.WriteString(fmt.Sprintf("Cert [%d] hostname does not match", index+1))
continue
}
@ -361,6 +361,7 @@ func parseGemini(b, currentUrl string) (string, []string) {
links := make([]string, 0, 10)
inPreBlock := false
spacer := " "
outputIndex := 0
for i, ln := range splitContent {
@ -371,7 +372,7 @@ func parseGemini(b, currentUrl string) (string, []string) {
alt := strings.TrimSpace(ln)
if len(alt) > 3 {
alt = strings.TrimSpace(alt[3:])
splitContent[outputIndex] = fmt.Sprintf("[ %s ]", alt)
splitContent[outputIndex] = fmt.Sprintf("%s[ALT][ %s ]", spacer, alt)
outputIndex++
}
} else if isPreBlockDeclaration {
@ -401,7 +402,12 @@ func parseGemini(b, currentUrl string) (string, []string) {
if inPreBlock && (BlockBehavior == "alt" || BlockBehavior == "neither") {
continue
}
splitContent[outputIndex] = ln
var leader, tail string = "", ""
if len(ln) > 0 && ln[0] == '#' {
leader = "\033[1m"
tail = "\033[0m"
}
splitContent[outputIndex] = fmt.Sprintf("%s%s%s%s", spacer, leader, ln, tail)
outputIndex++
}
}

View File

@ -144,7 +144,8 @@ func parseMap(text string) (string, []string) {
} else {
link := buildLink(line[2], line[3], string(line[0][0]), line[1])
links = append(links, link)
linktext := fmt.Sprintf("(%s) %2d %s", getType(string(line[0][0])), len(links), title)
linkNum := fmt.Sprintf("[%d]",len(links))
linktext := fmt.Sprintf("%s %5s %s", getType(string(line[0][0])), linkNum, title)
splitContent[i] = linktext
}
}

31
help.go Normal file
View File

@ -0,0 +1,31 @@
package main
// ERRS maps commands to their syntax error message
var ERRS = map[string]string{
"A": "`a [target] [name...]`",
"ADD": "`add [target] [name...]`",
"D": "`d [bookmark-id]`",
"DELETE": "`delete [bookmark-id]`",
"B": "`b [[bookmark-id]]`",
"BOOKMARKS": "`bookmarks [[bookmark-id]]`",
"C": "`c [link_id]` or `c [setting]`",
"CHECK": "`check [link_id]` or `check [setting]`",
"H": "`h`",
"HOME": "`home`",
"J": "`j [[history_position]]`",
"JUMP": "`jump [[history_position]]`",
"P": "`p [host]`",
"PURGE": "`purge [host]`",
"Q": "`q`",
"QUIT": "`quit`",
"R": "`r`",
"RELOAD": "`reload`",
"SEARCH": "`search [[keyword(s)...]]`",
"S": "`s [setting] [value]`",
"SET": "`set [setting] [value]`",
"W": "`w [target]`",
"WRITE": "`write [target]`",
"VERSION": "`version`",
"?": "`? [[command]]`",
"HELP": "`help [[command]]`",
}

View File

@ -33,7 +33,7 @@ func Visit(webmode, url string, width int) (Page, error) {
return Page{}, fmt.Errorf("Invalid webmode setting")
}
c, err := exec.Command(webmode, "-dump", w, fmt.Sprintf("%d", width), url).Output()
if err != nil {
if err != nil && c == nil {
return Page{}, err
}
return parseLinks(string(c)), nil

View File

@ -35,8 +35,7 @@ import (
"tildegit.org/sloum/bombadillo/gemini"
)
var version string
var build string
var version string = "2.3.3"
var bombadillo *client
var helplocation string = "gopher://bombadillo.colorfield.space:70/1/user-guide.map"
@ -211,7 +210,7 @@ func main() {
flag.Usage = printHelp
flag.Parse()
if *getVersion {
fmt.Printf("Bombadillo %s - build %s\n", version, build)
fmt.Printf("Bombadillo %s\n", version)
os.Exit(0)
}
args := flag.Args()

18
page.go
View File

@ -72,11 +72,17 @@ func (p *Page) WrapContent(width int, color bool) {
}
width = min(width, 100)
counter := 0
spacer := " "
spacer := ""
var content strings.Builder
var esc strings.Builder
escape := false
content.Grow(len(p.RawContent))
if p.Location.Mime == "1" { // gopher document
spacer = " "
} else if strings.HasSuffix(p.Location.Mime, "gemini") { //gemini document
spacer = " "
}
for _, ch := range []rune(p.RawContent) {
if escape {
if color {
@ -91,8 +97,8 @@ func (p *Page) WrapContent(width int, color bool) {
}
continue
}
if ch == '\n' {
content.WriteRune(ch)
if ch == '\n' || ch == '\u0085' || ch == '\u2028' || ch == '\u2029' {
content.WriteRune('\n')
counter = 0
} else if ch == '\t' {
if counter+4 < width {
@ -125,10 +131,8 @@ func (p *Page) WrapContent(width int, color bool) {
} else {
content.WriteRune('\n')
counter = 0
if p.Location.Mime == "1" {
content.WriteString(spacer)
counter += len(spacer)
}
content.WriteString(spacer)
counter += len(spacer)
content.WriteRune(ch)
counter++
}

View File

@ -61,6 +61,26 @@ func Test_WrapContent_Wrapped_Line_Length(t *testing.T) {
false,
},
},
{
"Unicode line endings that should not wrap",
"LF\u000A" +
"CR+LF\u000D\u000A" +
"NEL\u0085" +
"LS\u2028" +
"PS\u2029",
[]string{
"LF",
"CR+LF",
"NEL",
"LS",
"PS",
"",
},
args{
10,
false,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

View File

@ -38,7 +38,7 @@ func (p *Pages) NavigateHistory(qty int) error {
}
// Add gets passed a Page, which gets added to the history
// arrayr. Add also updates the current length and position
// array. 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) {
@ -92,6 +92,18 @@ func (p *Pages) Render(termHeight, termWidth int, color bool) []string {
return p.History[p.Position].WrappedContent[pos:]
}
func (p *Pages) CopyHistory(pos int) error {
if p.Length < 2 || pos > p.Position {
return fmt.Errorf("There are not enough history locations available")
}
if pos < 0 {
pos = p.Position-1
}
p.Add(p.History[pos])
return nil
}
//------------------------------------------------\\
// + + + F U N C T I O N S + + + \\
//--------------------------------------------------\\