ui

package
v0.0.0-...-a46f82b Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Editor

type Editor struct {
	Window *Window
	Buffer [][]rune
	Path   string
	Mode   Mode
	// contains filtered or unexported fields
}

Editor defines an editor window for editing a single file

func NewEditor

func NewEditor(path string, x1, y1, x2, y2 int) *Editor

NewEditor creates and returns an editor instance

func (*Editor) BuftoWin

func (e *Editor) BuftoWin(x, y int) (int, int)

BuftoWin converts a buffer coordinate to window space

func (*Editor) Cursor

func (e *Editor) Cursor() (int, int)

Cursor returns the window position of the cursor in the buffer

func (*Editor) Draw

func (e *Editor) Draw(s tcell.Screen)

Draw renders the editor to the screen

func (*Editor) Input

func (e *Editor) Input(ev *tcell.EventKey)

Input performs an editor action based on user input

func (*Editor) Load

func (e *Editor) Load(path string)

Load reads the given file into the buffer.

func (*Editor) MoveCursor

func (e *Editor) MoveCursor(dx, dy int)

MoveCursor moves the cursor within boundaries, shifting the offset if necessary

func (*Editor) MoveWindow

func (e *Editor) MoveWindow(dx, dy int)

MoveWindow shifts the editor window

func (*Editor) Save

func (e *Editor) Save(path string)

Save is used to write the buffer to a path

func (*Editor) SetCursor

func (e *Editor) SetCursor(x, y int)

SetCursor moves the editor cursor to the point given

func (*Editor) Status

func (e *Editor) Status() (status string)

Status returns the status string for display in the status bar

func (*Editor) WintoBuf

func (e *Editor) WintoBuf(x, y int) (int, int)

WintoBuf converts a window coordinate to buffer space

type Manager

type Manager struct {
	Status  *StatusBar
	Editor  *Editor // TODO: Add support for multiple editors
	Focused View
}

Manager is the main UI handler for each instance of a program

func NewManager

func NewManager(path string, w, h int) *Manager

NewManager creates an returns the standard initial layout for a jai instance

func (*Manager) Draw

func (m *Manager) Draw(s tcell.Screen)

Draw renders all current windows the the screen

func (*Manager) Input

func (m *Manager) Input(ev *tcell.EventKey)

Input delegates input events to the respective Views

type Mode

type Mode int

Mode represents a possible editor mode

const (
	Edit Mode = iota
	Write
)

The possible modes the editor can be in

func (Mode) String

func (m Mode) String() string

type StatusBar

type StatusBar struct {
	Window *Window
	Active View
}

StatusBar is the status bar shown for each editor

func NewStatusBar

func NewStatusBar(width, y int) *StatusBar

NewStatusBar creates and returns the default status bar

func (*StatusBar) Draw

func (sb *StatusBar) Draw(s tcell.Screen)

Draw renders the status bar to the screen

type View

type View interface {
	Input(*tcell.EventKey)
	Draw(s tcell.Screen)
	Cursor() (int, int)
	Status() string
}

View is a drawable view on the screen

type Window

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

Window represents a view in the UI

func NewWindow

func NewWindow(x1, y1, x2, y2 int) *Window

NewWindow creates and returns a UI window

func (*Window) Box

func (w *Window) Box() (int, int, int, int)

Box returns the x1, y1, x2, and y2 of the window

func (*Window) ScrtoWin

func (w *Window) ScrtoWin(x, y int) (int, int)

ScrtoWin converts a screen coordinate to window space

func (*Window) SetBox

func (w *Window) SetBox(x1, y1, x2, y2 int)

SetBox updates the bounding box of the window

func (*Window) Size

func (w *Window) Size() (int, int)

Size returns the width and height of the window

func (*Window) WintoScr

func (w *Window) WintoScr(x, y int) (int, int)

WintoScr converts a window coordinate to screen space

Jump to

Keyboard shortcuts

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