~mna/mauve

bdf2357b33a1be31b609f9244450fc87dd71645d — Martin Angers 3 years ago
initial design work
7 files changed, 113 insertions(+), 0 deletions(-)

A .gitignore
A .golangci.toml
A README.md
A cmd/mauve-keys/mauve_keys.go
A doc/design.md
A doc/mauve_concepts.drawio
A mauve.go
A  => .gitignore +6 -0
@@ 1,6 @@
# environment files (e.g. managed by direnv) and other secrets
/.env*

# output files for different tools, e.g. code coverage
/*.out


A  => .golangci.toml +30 -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 = [
  ]

A  => README.md +4 -0
@@ 1,4 @@
# mauve

[![GoDoc](https://godoc.org/git.sr.ht/~mna/mauve?status.svg)](https://godoc.org/git.sr.ht/~mna/mauve)


A  => cmd/mauve-keys/mauve_keys.go +34 -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())
	}
}

A  => doc/design.md +20 -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?

A  => doc/mauve_concepts.drawio +1 -0
@@ 1,1 @@
<mxfile host="Electron" modified="2019-11-26T16:16:51.859Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.2.2 Chrome/78.0.3904.94 Electron/7.1.0 Safari/537.36" etag="GEh_OKscpK4vonHhQ4D3" version="12.2.2" type="device" pages="1"><diagram id="pgsMLVG_pbv6QXweCJr3" name="Page-1">7Ztbb6M4FMc/TR634p70sU3bmYfubNWutNOnkQNO8BZwZJxbP/0eg801lCSTBLRiVGnwwTd8/vbPt4zMabj9xtDS/5N6OBgZmrcdmQ8jw9A13YD/hGWXWhzLTg0LRjwZKTe8kU+sUkrring4LkXklAacLMtGl0YRdnnJhhijm3K0OQ3KpS7RAtcMby4K6tZ/iMf91Dqxtdz+HZOFr0rWNfkmRCqyNMQ+8uimYDIfR+aUUcrTp3A7xYFoPNUuabqnhrdZxRiO+J4EdPavaA9DC9AMfJJEwB7hlKUJVT4/f3gf+vp7zH/92H1om1/vrjv+Q7ezCmYFx3ynGiXekDBAEYTuXZ8E3jPa0ZWoRMyR+6FC9z5l5JNGHInidTDAa8alj02tFONNpASzsM5JEExpADUVpZmaNnHnc2GHmAX7U/IP7IyuIg97shARS5ahWyos664llWD0I3OmIdLjGOK/qJbUMtM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O9bDJdROrvCVp2Vdc9QZziyuyg2b/uNTWffov8LbA5Hdu1dqZ20Hd9GqYxCY+1Ma0OnmtGF14ZO/cgOZlGxus09kK271aHT/X6mU985GMh2PrI5PT+wc/ZtDpy+n7kbnX5mdt6DvjMSS22gtBKrydnXIpZT+e2Hc+r9ySqyxlfeznTq2xQxDrArZlMDtbpej/WAWuPhR0QXpdak39QaH7AeO5Ran5jRv6laUnlPJMiiKSAdsVDK4JfdHrn6dX/n0Ov+44az1o4WWJNzHb6dj1YQzH9lm0bPf6tsPv4H</diagram></mxfile>
\ No newline at end of file

A  => mauve.go +18 -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
}