From 80fad75a594eb6c2ce5ebd498adf60de53684844 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Sun, 11 Jun 2023 18:58:01 -0400 Subject: [PATCH] basic main --- main.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..25b51f6 --- /dev/null +++ b/main.go @@ -0,0 +1,53 @@ +package main + +import ( + "fmt" + "os" + + "github.com/gdamore/tcell/v2" + "github.com/rivo/tview" + "github.com/spf13/cobra" +) + +const ( + NormalMode = "normal" + FocusedMode = "focused" + SearchMode = "search" + ExMode = "ex" +) + +type UI struct { + Mode string + App *tview.Application +} + +func (ui *UI) handleInput(event *tcell.EventKey) *tcell.EventKey { + return nil +} + +func newUI() *UI { + app := tview.NewApplication() + ui := UI{ + Mode: NormalMode, + App: app, + } + app.SetInputCapture(ui.handleInput) + return &ui +} + +func _main() error { + cmd := &cobra.Command{ + Use: "porphyry", + RunE: func(cmd *cobra.Command, args []string) error { + return newUI().App.Run() + }, + } + + return cmd.Execute() +} + +func main() { + if err := _main(); err != nil { + fmt.Fprintf(os.Stderr, err.Error()+"\n") + } +}