vre

package
v0.0.0-...-47a2700 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEY_CTRLB     = 2
	KEY_CTRLC     = 3
	KEY_CTRLD     = 4
	KEY_CTRLF     = 6
	KEY_CTRLH     = 8
	KEY_CTRLJ     = 10
	KEY_CTRLK     = 11
	KEY_CTRLL     = 12
	KEY_ENTER     = 13
	KEY_CTRLT     = 20
	KEY_ESC       = 27
	KEY_BACKSPACE = 127
	KEY_LEFT      = 279168
	KEY_RIGHT     = 279167
	KEY_DEL       = 2791126
)
View Source
const ChunkSize int = 250

number of lines in a chunk

Variables

View Source
var TABSTOP int = 8

number of spaces in a tab

Functions

func Run

func Run()

Types

type Bounds

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

type Chunk

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

type Doc

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

type EventBox

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

func NewEventBox

func NewEventBox() *EventBox

func (*EventBox) Clear

func (eb *EventBox) Clear()

Clear removes all events. Typically used in callback for Wait

func (*EventBox) Put

func (eb *EventBox) Put(e EventType, val interface{})

func (*EventBox) Wait

func (eb *EventBox) Wait(callback func(*Events))

Wait runs when Put has been called and applies callback to the events

type EventType

type EventType int
const (
	EvtReadNew EventType = iota
	EvtReadDone
	EvtReadError
	EvtQuit
	EvtSearchNew
	EvtSearchFinal
	EvtSearchProgress
	EvtSearchCancel
	// EvtHeartbeat
	EvtFinish
)

type Events

type Events map[EventType]interface{}

type Input

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

func Parse

func Parse(s string) *Input

type Machine

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

func NewMachine

func NewMachine(eb *EventBox, ch chan<- *Output) *Machine

func (*Machine) Finish

func (m *Machine) Finish()

func (*Machine) Loop

func (m *Machine) Loop()

Loop keep applying regexp to m.doc starting at m.curr

func (*Machine) Snapshot

func (m *Machine) Snapshot() *Result

Snapshot returns a copy of the current outputs of the regexp program It is called inside a critical section

func (*Machine) UpdateDoc

func (m *Machine) UpdateDoc(d []*Doc, final bool)

func (*Machine) UpdateMachine

func (m *Machine) UpdateMachine(q Query)

UpdateMachine updates the regexp if possible

type Output

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

Output.output is what gets printed at the end

type Prog

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

func NewProg

func NewProg(s string) *Prog

func (*Prog) Find

func (p *Prog) Find(s []byte) [][]int

func (*Prog) Replace

func (p *Prog) Replace(s []byte) ([][]int, [][]int, []byte)

Replace returns (in order) the indices of the matches in the original string, the indices of the replacements in the new string, and the new string

type Query

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

type Reader

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

Reader acts as the model

func NewReader

func NewReader(eb *EventBox) *Reader

func (*Reader) ReadFile

func (r *Reader) ReadFile(io *os.File, name string, final bool)

ReadStream reads the file in ChunkSize chunks and appends to Reader

func (*Reader) ReadFiles

func (r *Reader) ReadFiles(fs []string)

ReadFiles reads the files given

func (*Reader) Snapshot

func (r *Reader) Snapshot() []*Doc

Snapshot returns a copy of the current items in the document

type Result

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

Result goes to tui for display

type Terminal

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

Terminal acts as the view

func NewTerminal

func NewTerminal(eb *EventBox) *Terminal

func (*Terminal) ClearBounds

func (t *Terminal) ClearBounds()

func (*Terminal) Close

func (t *Terminal) Close()

Close closes alternate screen buffer and restores original terminal state

func (*Terminal) GetSize

func (t *Terminal) GetSize()

GetSize updates the size of the terminal

func (*Terminal) Init

func (t *Terminal) Init(files int)

Init saves current state of terminal, sets up raw mode and alternate screen buffer

func (*Terminal) Loop

func (t *Terminal) Loop()

func (*Terminal) Refresh

func (t *Terminal) Refresh()

Refresh prints contents

func (*Terminal) RefreshPrompt

func (t *Terminal) RefreshPrompt()

RefreshPrompt refreshes just the prompt line

func (*Terminal) UpdateBounds

func (t *Terminal) UpdateBounds(x *Result)

func (*Terminal) UpdateChunks

func (t *Terminal) UpdateChunks(docs []*Doc, final bool)

UpdateChunks saves input snapshot

func (*Terminal) UpdatePrompt

func (t *Terminal) UpdatePrompt(s string)

Jump to

Keyboard shortcuts

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