Compare commits

..

2 Commits

Author SHA1 Message Date
nbsp 5868ae2f13
0.1.1 2025-01-09 05:05:55 +02:00
nbsp 251c250a8d
default to nano and warn if $EDITOR not set 2025-01-09 05:04:00 +02:00
7 changed files with 43 additions and 5 deletions

View File

@ -1 +0,0 @@
patch type="added" "use 755 for config dir"

View File

@ -1 +0,0 @@
patch type="added" "save position of previous list when going back"

View File

@ -1,2 +1,2 @@
name neofeels
version 0.1.0
version 0.1.1

View File

@ -1,5 +1,11 @@
# Changelog
## [0.1.1] - 2025-01-09
- use 755 for config dir
- save position of previous list when going back
- default to nano and warn if no $EDITOR set
## [0.1.0] - 2025-01-08
initial release: fully supports everything in ttbp, in a backwards-compatible

View File

@ -1,6 +1,8 @@
package app
import (
"bufio"
"fmt"
"os"
"os/exec"
@ -61,6 +63,17 @@ func (graffiti *Graffiti) Event(state *ui.State, event vaxis.Event) (processed b
}
func editGraffiti(state *ui.State) {
// if $EDITOR isn't set, warn about it, and use nano
editor := os.ExpandEnv(os.Getenv("EDITOR"))
if editor == "" {
editor = "nano"
state.Suspend()
fmt.Print("$EDITOR not found, using nano. press ↵ to continue")
input := bufio.NewScanner(os.Stdin)
input.Scan()
state.Resume()
}
state.HideCursor()
vt := term.New()
vt.TERM = os.Getenv("TERM")

View File

@ -1,6 +1,8 @@
package app
import (
"bufio"
"fmt"
"os"
"os/exec"
"path"
@ -23,7 +25,7 @@ const title = ` ___ __
/ _/__ ___ / /__
/ _/ -_) -_) (_-<
/_/ \__/\__/_/___/
neofeels 0.1.0`
neofeels 0.1.1`
func NewMainMenu(index int) *MainMenu {
return &MainMenu{
@ -129,13 +131,24 @@ func showManpage(state *ui.State) {
}
func newFeels(state *ui.State) {
// if $EDITOR isn't set, warn about it, and use nano
editor := os.ExpandEnv(os.Getenv("EDITOR"))
if editor == "" {
editor = "nano"
state.Suspend()
fmt.Print("$EDITOR not found, using nano. press ↵ to continue")
input := bufio.NewScanner(os.Stdin)
input.Scan()
state.Resume()
}
state.HideCursor()
vt := term.New()
vt.TERM = os.Getenv("TERM")
vt.Attach(state.PostEvent())
vt.Focus()
now := time.Now()
err := vt.Start(exec.Command(os.ExpandEnv(os.Getenv("EDITOR")), path.Join(ttbp.PathUserEntries, now.Format("20060102")+".txt")))
err := vt.Start(exec.Command(editor, path.Join(ttbp.PathUserEntries, now.Format("20060102")+".txt")))
if err != nil {
panic(err)
}

View File

@ -83,3 +83,11 @@ func (state *State) HideCursor() {
func (state *State) Window() vaxis.Window {
return state.vx.Window()
}
func (state *State) Suspend() {
state.vx.Suspend()
}
func (state *State) Resume() {
state.vx.Resume()
}