diff --git a/config.example.toml b/config.example.toml index 55c7e8b..2d0bd7b 100644 --- a/config.example.toml +++ b/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 diff --git a/config/config.go b/config/config.go index ff40a74..98666b7 100644 --- a/config/config.go +++ b/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 { diff --git a/config/default_config.go b/config/default_config.go index 84d4260..b047432 100644 --- a/config/default_config.go +++ b/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 diff --git a/docs/man/tut.5 b/docs/man/tut.5 index 1cd881c..061b59f 100644 --- a/docs/man/tut.5 +++ b/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 diff --git a/docs/man/tut.5.md b/docs/man/tut.5.md index f28be75..72bda0c 100644 --- a/docs/man/tut.5.md +++ b/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