aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-07-22 22:17:32 -0230
committerSam Anthony <sam@samanthony.xyz>2023-07-22 22:17:32 -0230
commita1e02a94f69f06af62af137212da1534c460c756 (patch)
tree5d39f503c235ad40d1b86e5cf76fb4970d9e889a
parent4e17a27eb8d36868bcf7e1edf32affd84412a1f4 (diff)
downloadpfc-a1e02a94f69f06af62af137212da1534c460c756.zip
ui skeleton
-rw-r--r--.gitignore1
-rw-r--r--Makefile7
-rw-r--r--cmd/pfc.go9
-rw-r--r--go.mod20
-rw-r--r--go.sum35
-rw-r--r--main.go24
-rw-r--r--ui.go48
7 files changed, 133 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..eeb2310
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/pfc
diff --git a/Makefile b/Makefile
index dd45c4c..db17c6e 100644
--- a/Makefile
+++ b/Makefile
@@ -2,12 +2,15 @@ include config.mk
build:
go mod tidy
- gofmt -l -s -w ./**/*.go
+ go build
+ go test
+ gofmt -l -s -w .
clean:
rm -f pfc
-install: build
+install:
+ go build
cp pfc ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/pfc
mkdir -p ${DESTDIR}${MANPREFIX}/man1
diff --git a/cmd/pfc.go b/cmd/pfc.go
deleted file mode 100644
index 67821f5..0000000
--- a/cmd/pfc.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package main
-
-import (
- "fmt"
-)
-
-func main() {
- fmt.Println("Hello, world")
-}
diff --git a/go.mod b/go.mod
index 84505d8..0c52465 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,23 @@
module git.samanthony.xyz/pfc
go 1.20
+
+require github.com/charmbracelet/bubbletea v0.24.2
+
+require (
+ github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
+ github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
+ github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
+ github.com/mattn/go-isatty v0.0.18 // indirect
+ github.com/mattn/go-localereader v0.0.1 // indirect
+ github.com/mattn/go-runewidth v0.0.14 // indirect
+ github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
+ github.com/muesli/cancelreader v0.2.2 // indirect
+ github.com/muesli/reflow v0.3.0 // indirect
+ github.com/muesli/termenv v0.15.1 // indirect
+ github.com/rivo/uniseg v0.2.0 // indirect
+ golang.org/x/sync v0.1.0 // indirect
+ golang.org/x/sys v0.6.0 // indirect
+ golang.org/x/term v0.6.0 // indirect
+ golang.org/x/text v0.3.8 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..2113bfb
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,35 @@
+github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
+github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
+github.com/charmbracelet/bubbletea v0.24.2 h1:uaQIKx9Ai6Gdh5zpTbGiWpytMU+CfsPp06RaW2cx/SY=
+github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FDaJmO3l2nejekbsgg=
+github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
+github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
+github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
+github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
+github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
+github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
+github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
+github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
+github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
+github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
+github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
+github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
+github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
+github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
+github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
+github.com/muesli/termenv v0.15.1 h1:UzuTb/+hhlBugQz28rpzey4ZuKcZ03MeKsoG7IJZIxs=
+github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ=
+github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
+github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
+golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
+golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
+golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
+golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..0a84c8f
--- /dev/null
+++ b/main.go
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/charmbracelet/bubbletea"
+)
+
+// Types
+
+type Calculator struct {
+ stack []float64
+ buffer string
+}
+
+// Function Definitions
+
+func main() {
+ if _, err := tea.NewProgram(new(UI)).Run(); err != nil {
+ fmt.Fprintf(os.Stderr, "%v", err)
+ os.Exit(1)
+ }
+}
diff --git a/ui.go b/ui.go
new file mode 100644
index 0000000..03286ec
--- /dev/null
+++ b/ui.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "fmt"
+
+ "github.com/charmbracelet/bubbletea"
+)
+
+// Types
+
+type UI struct {
+ calc Calculator
+ windowWidth int // Width of the window measured in characters.
+}
+
+// Interface Implementations
+
+func (ui UI) Init() tea.Cmd {
+ return nil
+}
+
+func (ui UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+ switch msg := msg.(type) {
+ case tea.WindowSizeMsg:
+ ui.windowWidth = msg.Width
+ case tea.KeyMsg:
+ switch msg.String() {
+ case "ctrl+c", "q":
+ return ui, tea.Quit
+ }
+ }
+ return ui, nil
+}
+
+func (ui UI) View() string {
+ var s string
+ for _, f := range ui.calc.stack {
+ s += fmt.Sprintf("%f\n", f)
+ }
+ horizBar := make([]byte, ui.windowWidth)
+ for i := range horizBar {
+ horizBar[i] = '-'
+ }
+ s += string(horizBar) + "\n"
+ s += fmt.Sprintf("| %*s |\n", ui.windowWidth-4, ui.calc.buffer)
+ s += string(horizBar)
+ return s
+}