ziti

package module
v0.0.0-...-d664b97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2022 License: BSD-2-Clause Imports: 9 Imported by: 0

README

Ziti

Ziti is a small terminal/screen text editor in less than 2K lines of Go code. It uses Go's rune (unicode) machinery. Has multiple buffers. But still single window. hope this makes it into the vault

Usage: ziti <filename>

To build: clone repo into gopath;

 $ cd cmd
 $ go get -d ./...
 $ go build -o ziti

Copy to someplace in your PATH

be sure you have https://godoc.org/github.com/nsf/termbox-go so, you may need to go get github.com/nsf/termbox-go

Key Commands:
Movement
  • CTRL-Y: HELP
  • Use ArrowKeys to move Cursor around.
  • Home, End, and PageUp & PageDown should work
  • CTRL-A: Move to beginning of current line
  • CTRL-E: Move to end of current line
  • on mac keyboards:
    • FN+ArrowUp: PageUp (screen full)
    • FN+ArrowDown: PageDown (screen full)
File/Buffer
  • CTRL-S: Save the file
  • CTRL-Q: Quit the editor
  • CTRL-F: Find string in file (ESC to exit search mode, arrows to navigate to next/prev find)
  • CTRL-N: Next Buffer
  • CTRL-B: List all the buffers
  • CTRL-O: (control oh) Open File into new buffer
  • CTRL-W: kill buffer
Cut/Copy/Paste & Deletion
  • CTRL-Space: Set Mark
  • CTRL-X: Cut region from Mark to Cursor into paste buffer
  • CTRL-C: Copy region from Mark to Cursor into paste buffer
  • CTRL-V: Paste copied/cut region into file at Cursor Once you've set the Mark, as you move the cursor, you should be getting underlined text showing the current selection/region.
  • Delete: to delete a rune backward
  • CTRL-K: killtoEndOfLine (once) removeLine (twice)

Setting the cursor with a mouse click should work. (and so, it should work to set the selection. but hey, you MUST SetMark for a selection to start... sorry, it's not a real mouse based editor.)

Implementation Notes

Ziti was based on Kilo, a project by Salvatore Sanfilippo at https://github.com/antirez/kilo.

It's a very simple editor, with kinda-"Mac-Emacs"-like key bindings. It uses `go get github.com/nsf/termbox-go" for simple termio junk.

The central data structure is an array of lines (type erow struct). Each line in the file has a struct, which contains an array of rune. (If you're not familiar with Go's runes, they are Go's unicode code points (or characters))

Multiple buffers, but no window splits. Two mini modes, one for the search modal operations, and one for opening files.

Notice the goroutine attached to events coming from termbox-go, that is pretty cool. Yet another real reason that Go routines are handy.

Ziti was written in Go by K Younger and is released under the BSD 2 clause license.

Documentation

Index

Constants

View Source
const (
	KeyNull   = 0   /* NULL ctrl-space set mark */
	CtrlA     = 1   /* Ctrl-a BOL */
	CtrlB     = 2   /* Ctrl-B list buffers */
	CtrlC     = 3   /* Ctrl-c  copy */
	CtrlE     = 5   /* Ctrl-e  EOL */
	CtrlD     = 4   /* Ctrl-d del forward? */
	CtrlF     = 6   /* Ctrl-f find */
	CtrlH     = 8   /* Ctrl-h del backward*/
	Tab       = 9   /* Tab */
	CtrlK     = 11  /* Ctrl+k killToEOL */
	CtrlL     = 12  /* Ctrl+l redraw */
	Enter     = 13  /* Enter */
	CtrlN     = 14  /* Ctrl+n nextBuffer */
	CtrlO     = 15  /* Ctrl+Oh load(open) file */
	CtrlQ     = 17  /* Ctrl-q quit*/
	CtrlS     = 19  /* Ctrl-s save*/
	CtrlU     = 21  /* Ctrl-u number of times??*/
	CtrlV     = 22  /* Ctrl-V paste */
	CtrlW     = 23  /* Ctrl-W kill buffer */
	CtrlX     = 24  /* Ctrl-X cut */
	CtrlY     = 25  /* Help */
	CtrlZ     = 26  /* ?? */
	Esc       = 27  /* Escape */
	Space     = 32  /* Space */
	Backspace = 127 /* Backspace */
)

KEY constants

View Source
const (
	ArrowLeft  = termbox.KeyArrowLeft
	ArrowRight = termbox.KeyArrowRight
	ArrowUp    = termbox.KeyArrowUp
	ArrowDown  = termbox.KeyArrowDown
	DelKey     = termbox.KeyDelete
	HomeKey    = termbox.KeyHome
	EndKey     = termbox.KeyEnd
	PageUp     = termbox.KeyPgup
	PageDown   = termbox.KeyPgdn
)

Cursor movement keys

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	// contains filtered or unexported fields
}

State contains the state of a terminal.

type Ziti

type Ziti struct {
	// contains filtered or unexported fields
}

Ziti is the top-level exported type

func (*Ziti) Start

func (z *Ziti) Start(filename string)

Start runs an editor

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL