From bdf2357b33a1be31b609f9244450fc87dd71645d Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Tue, 26 Nov 2019 11:18:49 -0500 Subject: [PATCH] initial design work --- .gitignore | 6 ++++++ .golangci.toml | 30 ++++++++++++++++++++++++++++++ README.md | 4 ++++ cmd/mauve-keys/mauve_keys.go | 34 ++++++++++++++++++++++++++++++++++ doc/design.md | 20 ++++++++++++++++++++ doc/mauve_concepts.drawio | 1 + mauve.go | 18 ++++++++++++++++++ 7 files changed, 113 insertions(+) create mode 100644 .gitignore create mode 100644 .golangci.toml create mode 100644 README.md create mode 100644 cmd/mauve-keys/mauve_keys.go create mode 100644 doc/design.md create mode 100644 doc/mauve_concepts.drawio create mode 100644 mauve.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a100c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# environment files (e.g. managed by direnv) and other secrets +/.env* + +# output files for different tools, e.g. code coverage +/*.out + diff --git a/.golangci.toml b/.golangci.toml new file mode 100644 index 0000000..1f0513d --- /dev/null +++ b/.golangci.toml @@ -0,0 +1,30 @@ +[linters] + disable-all = true + enable = [ + "deadcode", + "errcheck", + "gochecknoinits", + "gochecknoglobals", + "gofmt", + "golint", + "gosec", + "gosimple", + "govet", + "ineffassign", + "interfacer", + "misspell", + "nakedret", + "prealloc", + "staticcheck", + "structcheck", + "typecheck", + "unconvert", + "unparam", + "unused", + "varcheck", + ] + +[issues] + # regexps of issue texts to exclude + exclude = [ + ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..433db2a --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# mauve + +[![GoDoc](https://godoc.org/git.sr.ht/~mna/mauve?status.svg)](https://godoc.org/git.sr.ht/~mna/mauve) + diff --git a/cmd/mauve-keys/mauve_keys.go b/cmd/mauve-keys/mauve_keys.go new file mode 100644 index 0000000..9f670f5 --- /dev/null +++ b/cmd/mauve-keys/mauve_keys.go @@ -0,0 +1,34 @@ +package main + +import ( + "fmt" + "log" + + "github.com/pkg/term" + "github.com/tj/go-terminput" +) + +func main() { + t, err := term.Open("/dev/tty") + if err != nil { + log.Fatalf("error: %s\n", err) + } + + t.SetRaw() + defer t.Restore() + + fmt.Printf("Type something, use 'q' to exit.\r\n") + + for { + e, err := terminput.Read(t) + if err != nil { + log.Fatalf("error: %s\n", err) + } + + if e.Key() == terminput.KeyEscape || e.Rune() == 'q' { + break + } + + fmt.Printf("%s (%d) — shift=%v ctrl=%v alt=%v meta=%v\r\n", e.String(), e.Key(), e.Shift(), e.Ctrl(), e.Alt(), e.Meta()) + } +} diff --git a/doc/design.md b/doc/design.md new file mode 100644 index 0000000..294a2f7 --- /dev/null +++ b/doc/design.md @@ -0,0 +1,20 @@ +# mauve - a text editor + +## concepts + +* editor: the mauve instance +* terminal: the tty instance used for I/O +* document: the document being edited, might not be a "file" yet (e.g. not saved to disk, no path/name) +* buffer: a loaded instance of a document in memory - typically a 1:1 relationship? +* view: a view in a buffer, each view is independent and may have different positions, cursors, modes, etc. +* cursor: an input position into a view, each view may have multiple cursors +* selection: a range of selected text, each cursor may have a selection, and the cursor may be at the start or end of it +* mode: the current edit mode, each view has a distinct edit mode +* settings: a layered set of options, loaded from system-global, user file, environment variables, command-line flags, and view-specific. +* global settings: a layered set of options that apply to the mauve instance as a whole (e.g. status bar visibility, color scheme, ...) + +* global marks : via extension mechanisms? +* local marks : via extension mechanisms? +* recorded macros : via extension mechanisms? +* highlights (*not* text selections) : maybe not first-class concept, implement via extension mechanisms? +* search : via extension mechanisms? diff --git a/doc/mauve_concepts.drawio b/doc/mauve_concepts.drawio new file mode 100644 index 0000000..b75fcf1 --- /dev/null +++ b/doc/mauve_concepts.drawio @@ -0,0 +1 @@ +7Ztbb6M4FMc/TR634p70sU3bmYfubNWutNOnkQNO8BZwZJxbP/0eg801lCSTBLRiVGnwwTd8/vbPt4zMabj9xtDS/5N6OBgZmrcdmQ8jw9A13YD/hGWXWhzLTg0LRjwZKTe8kU+sUkrring4L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lNFvNF1Rp2HpBYEXzAh8muhxqa0AVvCQTxcUJuVFqLorts5GiRyLOQnfSyC8+OpN+bQVcU3a6AhxVlVkpyLOrGZ0YcSpQbSg4dlqPsdsANy1AWcbvQOcPexLXhJwtrZfEH0BnG2dFXD/02WZmgW2MivtTQOzfptZdk2Wa4I3A7E6P0hzuidW/cQ1JVZIPZwSS9zuUAYD+q7YeFfNMeDrGHz1/PTdnrTjq32JdPIKTgFIrt9EUx25fiutzs5ILDWtaydWxxuJllkeYBzzRGTZlYzsakYNyAL3ol0hmux3jRV2KptU6pCvqV5j48v48JDW4Lz8rO9bDJdROrvCVp2Vdc9QZziyuyg2b/uNTWffov8LbA5Hdu1dqZ20Hd9GqYxCY+1Ma0OnmtGF14ZO/cgOZlGxus09kK271aHT/X6mU985GMh2PrI5PT+wc/ZtDpy+n7kbnX5mdt6DvjMSS22gtBKrydnXIpZT+e2Hc+r9ySqyxlfeznTq2xQxDrArZlMDtbpej/WAWuPhR0QXpdak39QaH7AeO5Ran5jRv6laUnlPJMiiKSAdsVDK4JfdHrn6dX/n0Ov+44az1o4WWJNzHb6dj1YQzH9lm0bPf6tsPv4H \ No newline at end of file diff --git a/mauve.go b/mauve.go new file mode 100644 index 0000000..36cca53 --- /dev/null +++ b/mauve.go @@ -0,0 +1,18 @@ +package mauve + +import "io" + +// Concepts: +// +// - terminal: the tty instance used for I/O +// - document: the document being edited, might not be a "file" yet (e.g. not saved to disk, no path/name) +// - buffer: a loaded instance of a document in memory - typically a 1:1 relationship? +// - view: a view in a buffer, each view is independent and may have different positions, cursors, modes, etc. +// - cursor: an input position into a view, each view may have multiple cursors +// - selection: a range of selected text, each cursor may have a selection, and the cursor may be at the start or end of it +// - mode: the current edit mode, each view has a distinct edit mode +// - settings: a layered set of options, loaded from system-global, user file, environment variables, command-line flags, and view-specific. + +type Input struct { + r io.Reader // the terminal, typically +} -- 2.45.2