Browse Source

fix typo

pull/253/head
Rasmus Lindroth 3 years ago
parent
commit
c08de33372
  1. 2
      config.example.toml
  2. 83
      config/config.go
  3. 2
      config/default_config.go
  4. 4
      docs/man/tut.5
  5. 4
      docs/man/tut.5.md

2
config.example.toml

@ -648,7 +648,7 @@ special-keys=["Left"]
keys=["l","L"]
# default=["Right"]
specialkeys=["Right"]
special-keys=["Right"]
[input.main-prev-pane]
# Focus on the previous feed pane

83
config/config.go

@ -2,7 +2,6 @@ package config
import (
"embed"
"errors"
"fmt"
"io"
"log"
@ -416,64 +415,6 @@ func NewKeyT(hint string, hintAlt string, keys []string, special []string) (Key,
return k, nil
}
func NewKey(s []string, double bool) (Key, error) {
var k Key
if len(s) < 2 {
return k, errors.New("key must have a minimum length of 2")
}
var start int
if double {
start = 1
k = Key{
Hint: [][]string{newHint(s[0]), newHint(s[1])},
}
} else {
start = 0
k = Key{
Hint: [][]string{newHint(s[0])},
}
}
var runes []rune
var keys []tcell.Key
for _, v := range s[start+1:] {
value := []rune(strings.TrimSpace(v))
if len(value) < 3 {
return k, errors.New("key value must have a minimum length of 3")
}
if value[0] == '\'' {
if len(value) != 3 {
return k, fmt.Errorf("rune %s must only contain one char", string(value))
}
runes = append(runes, value[1])
} else if value[0] == '"' {
if value[len(value)-1] != '"' {
return k, fmt.Errorf("key %s must end with \"", string(value))
}
keyName := string(value[1 : len(value)-1])
found := false
var fk tcell.Key
for tk, tv := range tcell.KeyNames {
if tv == keyName {
found = true
fk = tk
break
}
}
if found {
keys = append(keys, fk)
} else {
return k, fmt.Errorf("no key named %s", keyName)
}
} else {
return k, fmt.Errorf("input %s is in the wrong format", string(value))
}
}
k.Runes = runes
k.Keys = keys
return k, nil
}
type Key struct {
Hint [][]string
Runes []rune
@ -1106,18 +1047,29 @@ func parseGeneral(cfg GeneralTOML) General {
tls = append(tls, tl)
}
}
if len(tls) == 0 {
shown := 0
for _, tl := range tls {
if !tl.Closed {
shown += 1
}
}
if len(tls) == 0 || shown == 0 {
tls = append(tls,
NewTimeline(Timeline{
FeedType: TimelineHome,
Name: "Home",
}),
)
kn, err := NewKeyT("", "", []string{"n", "N"}, []string{})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
tls = append(tls,
NewTimeline(Timeline{
FeedType: Notifications,
Name: "[N]otifications",
Key: inputStrOrErr([]string{"", "'n'", "'N'"}, false),
Key: kn,
}),
)
}
@ -1300,15 +1252,6 @@ func parseTemplates(cfg *ini.File, cnfPath string, cnfDir string) Templates {
}
}
func inputStrOrErr(vals []string, double bool) Key {
k, err := NewKey(vals, double)
if err != nil {
fmt.Printf("error parsing config. Error: %v\n", err)
os.Exit(1)
}
return k
}
func inputOrDef(keyName string, user *KeyHintTOML, def *KeyHintTOML, double bool) Key {
values := *def
if user != nil {

2
config/default_config.go

@ -650,7 +650,7 @@ special-keys=["Left"]
keys=["l","L"]
# default=["Right"]
specialkeys=["Right"]
special-keys=["Right"]
[input.main-prev-pane]
# Focus on the previous feed pane

4
docs/man/tut.5

@ -1093,9 +1093,9 @@ Go to next feed
.SS keys
.PP
\f[B]keys\f[R]=\f[I][\[lq]l\[rq],\[lq]L\[rq]]\f[R]
.SS specialkeys
.SS special-keys
.PP
\f[B]specialkeys\f[R]=\f[I][\[lq]Right\[rq]]\f[R]
\f[B]special-keys\f[R]=\f[I][\[lq]Right\[rq]]\f[R]
.SH INPUT.MAIN-PREV-PANE
.PP
This section is [input.main-prev-pane] in your configuration file

4
docs/man/tut.5.md

@ -734,8 +734,8 @@ Go to next feed
## keys
**keys**=*["l","L"]*
## specialkeys
**specialkeys**=*["Right"]*
## special-keys
**special-keys**=*["Right"]*
# INPUT.MAIN-PREV-PANE
This section is \[input.main-prev-pane\] in your configuration file

Loading…
Cancel
Save