Browse Source
Merge pull request 'Release 2.3.3 to master' (#204) from develop into master
Merge pull request 'Release 2.3.3 to master' (#204) from develop into master
Reviewed-on: #204master 2.3.3
22 changed files with 336 additions and 137 deletions
-
1.gitignore
-
4DEVELOPING.md
-
10Makefile
-
2VERSION
-
24bombadillo.1
-
119client.go
-
2cmdparse/lexer.go
-
4cmdparse/parser.go
-
2cui/cui.go
-
5defaults.go
-
47gemini/gemini.go
-
8gopher/gopher.go
-
31help.go
-
2http/http_render.go
-
2http/open_browser_darwin.go
-
30http/open_browser_linux.go
-
29http/open_browser_other.go
-
4http/open_browser_windows.go
-
20main.go
-
19page.go
-
94page_test.go
-
14pages.go
@ -1,2 +1,3 @@ |
|||
bombadillo |
|||
*.asciinema |
|||
*.swp |
@ -1 +1 @@ |
|||
2.3.1 |
|||
2.3.3 |
@ -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]]`", |
|||
} |
@ -1,30 +0,0 @@ |
|||
// +build linux
|
|||
|
|||
package http |
|||
|
|||
import ( |
|||
"fmt" |
|||
"os" |
|||
"os/exec" |
|||
) |
|||
|
|||
// OpenInBrowser checks for the presence of a display server
|
|||
// and environment variables indicating a gui is present. If found
|
|||
// then xdg-open is called on a url to open said url in the default
|
|||
// gui web browser for the system
|
|||
func OpenInBrowser(url string) (string, error) { |
|||
disp := os.Getenv("DISPLAY") |
|||
wayland := os.Getenv("WAYLAND_DISPLAY") |
|||
_, err := exec.LookPath("Xorg") |
|||
if disp == "" && wayland == "" && err != nil { |
|||
return "", fmt.Errorf("No gui is available, check 'webmode' setting") |
|||
} |
|||
|
|||
// Use start rather than run or output in order
|
|||
// to release the process and not block
|
|||
err = exec.Command("xdg-open", url).Start() |
|||
if err != nil { |
|||
return "", err |
|||
} |
|||
return "Opened in system default web browser", nil |
|||
} |
@ -1,11 +1,30 @@ |
|||
// +build !linux
|
|||
// +build !darwin
|
|||
// +build !windows
|
|||
// +build !darwin,!windows
|
|||
|
|||
package http |
|||
|
|||
import "fmt" |
|||
import ( |
|||
"fmt" |
|||
"os" |
|||
"os/exec" |
|||
) |
|||
|
|||
// OpenInBrowser checks for the presence of a display server
|
|||
// and environment variables indicating a gui is present. If found
|
|||
// then xdg-open is called on a url to open said url in the default
|
|||
// gui web browser for the system
|
|||
func OpenInBrowser(url string) (string, error) { |
|||
return "", fmt.Errorf("Unsupported os for 'webmode' 'gui' setting") |
|||
disp := os.Getenv("DISPLAY") |
|||
wayland := os.Getenv("WAYLAND_DISPLAY") |
|||
_, err := exec.LookPath("Xorg") |
|||
if disp == "" && wayland == "" && err != nil { |
|||
return "", fmt.Errorf("No gui is available, check 'webmode' setting") |
|||
} |
|||
|
|||
// Use start rather than run or output in order
|
|||
// to release the process and not block
|
|||
err = exec.Command("xdg-open", url).Start() |
|||
if err != nil { |
|||
return "", err |
|||
} |
|||
return "Opened in system default web browser", nil |
|||
} |
@ -0,0 +1,94 @@ |
|||
package main |
|||
|
|||
import ( |
|||
"reflect" |
|||
"testing" |
|||
) |
|||
|
|||
func Test_WrapContent_Wrapped_Line_Length(t *testing.T) { |
|||
type fields struct { |
|||
WrappedContent []string |
|||
RawContent string |
|||
Links []string |
|||
Location Url |
|||
ScrollPosition int |
|||
FoundLinkLines []int |
|||
SearchTerm string |
|||
SearchIndex int |
|||
FileType string |
|||
WrapWidth int |
|||
Color bool |
|||
} |
|||
type args struct { |
|||
width int |
|||
color bool |
|||
} |
|||
|
|||
// create a Url for use by the MakePage function
|
|||
url, _ := MakeUrl("gemini://rawtext.club") |
|||
|
|||
tests := []struct { |
|||
name string |
|||
input string |
|||
expects []string |
|||
args args |
|||
}{ |
|||
{ |
|||
"Short line that doesn't wrap", |
|||
"0123456789\n", |
|||
[]string{ |
|||
"0123456789", |
|||
"", |
|||
}, |
|||
args{ |
|||
10, |
|||
false, |
|||
}, |
|||
}, |
|||
{ |
|||
"Long line wrapped to 10 columns", |
|||
"0123456789 123456789 123456789 123456789 123456789\n", |
|||
[]string{ |
|||
"0123456789", |
|||
" 123456789", |
|||
" 123456789", |
|||
" 123456789", |
|||
" 123456789", |
|||
"", |
|||
}, |
|||
args{ |
|||
10, |
|||
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) { |
|||
p := MakePage(url, tt.input, []string{""}) |
|||
p.WrapContent(tt.args.width-1, tt.args.color) |
|||
if !reflect.DeepEqual(p.WrappedContent, tt.expects) { |
|||
t.Errorf("Test failed - %s\nexpects %s\nactual %s", tt.name, tt.expects, p.WrappedContent) |
|||
} |
|||
}) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue