pine

package
v0.0.0-...-f560b72 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION  = "0.2.6 alpha"
	TABWIDTH = 4
)
View Source
const (
	DEFAULT_BUFFERNAME     = "untitled"
	DEFAULT_CURR_BUF_INDEX = 0
	HELP_DOC_PATH          = "/usr/local/share/doc/pe/help.txt"
)
View Source
const (
	HEADLINE_OFFSET                 = 0
	STATUSLINE_OFFSET               = -1
	BUFFER_CONTENT_START_OFFSET     = 1
	BUFFER_DIR_CONTENT_START_OFFSET = 2
	BUFFER_END_OFFSET               = -2
)

UI

View Source
const (
	FileOpenInfo = "Open file (^G to cancel): "
	FileSaveInfo = "Save file (^G to cancel): "
	SearchInfo   = "Search (^G to cancel): "
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BufRender

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

BufRender renders content of a buffer ViewStartPos and ViewEndPos are the absolute coordinate of the view on terminal screen ViewCursor is the absolute coordinate of the cusor ViewAnchor is the coordinate of buffer content, used to calculate content outside of the screen HlStartPos and hlEndPos are the view coordinate of the highlight area

func (*BufRender) Draw

func (r *BufRender) Draw(buf *Buffer, hasCursor, hasHighlight bool)

func (*BufRender) MoveCursorByMouse

func (r *BufRender) MoveCursorByMouse(buf *Buffer, p Pos, mode Mode)

* Mouse position is limited by terminal height and weight * It should be one to one mapped to view cursor position * But there are multi-length rune that we cannot position cursor * in between. So we convert back to cursor first. *

func (*BufRender) Reset

func (r *BufRender) Reset()

func (*BufRender) SyncCursorToView

func (r *BufRender) SyncCursorToView(buf *Buffer)

Calculate cursor colume position Cursor buffer position is different than terminal view since runes can have multiple width

type Buffer

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

func (*Buffer) Delete

func (b *Buffer) Delete()

func (*Buffer) DeleteLine

func (b *Buffer) DeleteLine()

func (*Buffer) Insert

func (b *Buffer) Insert(data rune)

func (*Buffer) InsertString

func (b *Buffer) InsertString(s string)

func (*Buffer) InsertTab

func (b *Buffer) InsertTab()

func (*Buffer) New

func (b *Buffer) New(path string, log *log.Logger) FileOpenState

func (*Buffer) NewLine

func (b *Buffer) NewLine()

func (*Buffer) ResetHightlight

func (b *Buffer) ResetHightlight()

func (*Buffer) Save

func (b *Buffer) Save(path string) (int, error)

type Editor

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

func (*Editor) Close

func (e *Editor) Close()

Close current buffer

func (*Editor) Exit

func (e *Editor) Exit()

Exit the editor

func (*Editor) Init

func (e *Editor) Init(sett *Setting)

func (*Editor) Open

func (e *Editor) Open(path string, bufIdx int)

Try to open a given filepath in the target buffer If no index is given, open it in the end of buffers If filepath is invalid, create a new buffer

func (*Editor) Save

func (e *Editor) Save(path string)

Save current buffer to the given filepath

func (*Editor) Start

func (e *Editor) Start(path string)

type FileOpMode

type FileOpMode int64
const (
	OpenOp FileOpMode = iota
	SaveOp
)

type FileOpenState

type FileOpenState int64
const (
	Success FileOpenState = iota
	IsDir
	HasError
	NotFound
)

type KeyMapper

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

func (*KeyMapper) Map

func (k *KeyMapper) Map(event tm.Event)

type KeyOps

type KeyOps int64
const (
	NoOp KeyOps = iota
	// Editor Ops
	ExitOp
	OpenFileOp
	SaveFileOp
	CloseFileOp
	HelpOp
	NextBufferOp
	PrevBufferOp
	// Navigation Ops
	MoveCursorUpOp
	MoveCursorDownOp
	MoveCursorLeftOp
	MoveCursorRightOp
	NextHalfPageOp
	PrevHalfPageOp
	// of the line
	GoToBOLOp
	GoToEOLOp
	// of the document
	GoToBODOp
	GoToEODOp
	// Text Edit Ops
	InsertChOp
	InsertSpaceOp
	InsertTabOp
	InsertEnterOp
	DeleteChOp
	DeleteLineOp
	// Search
	SearchOp
	SearchNextOp
	SearchPrevOp
	// Misc
	CmdOp
	CancelOp
)

type Mode

type Mode int64
const (
	EditMode Mode = iota
	FileOpenMode
	FileSaveMode
	DirMode
	SearchMode
	ConfirmExitOp
	ConfirmCloseOp
)

type Pos

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

type Render

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

func (*Render) Clear

func (r *Render) Clear()

func (*Render) Draw

func (r *Render) Draw(content RenderContent)

func (*Render) Init

func (r *Render) Init(sett *Setting, logger *log.Logger)

func (*Render) IsMousePointerOnBuffer

func (r *Render) IsMousePointerOnBuffer(mousePos Pos) bool

func (*Render) IsMousePointerOnBufferName

func (r *Render) IsMousePointerOnBufferName(mousePos Pos, filePath string, bufIdx int) bool

func (*Render) MoveCursor

func (r *Render) MoveCursor(mode Mode, buf *Buffer, op KeyOps)

func (*Render) MoveCursorByMouse

func (r *Render) MoveCursorByMouse(buf *Buffer, p Pos, mode Mode)

type RenderContent

type RenderContent struct {
	// contains filtered or unexported fields
}
type Search struct {
	// contains filtered or unexported fields
}

func (*Search) Search

func (s *Search) Search(target string, buffer *Buffer)

func (*Search) SetBufferHightlight

func (s *Search) SetBufferHightlight(buffer *Buffer, target string)

type Setting

type Setting struct {
	IsDebug bool
}

Jump to

Keyboard shortcuts

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