file

package
v0.0.0-...-01db604 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	READONLY flags = 1 << iota

	LF linefeed = 1 << iota
	CRLF
	CR
)

Variables

This section is empty.

Functions

func Split

func Split(s []rune, sep rune) (r [][]rune)

Split s []rune by sep rune sep is not deleted

func SplitByLF

func SplitByLF(s []byte) (results [][]byte)

SplitByLF split s []byte by lf lf is not deleted

Types

type Action

type Action struct {
	Class  ActionClass
	Before Cursor
	After  Cursor
	Data   []byte
}

type ActionClass

type ActionClass int
const (
	INSERT ActionClass = iota
	DELETE
	DELETE_BACKWARD
	ACTION_SEPARATOR
)

type ActionGroup

type ActionGroup []Action

func NewActionGroup

func NewActionGroup() *ActionGroup

func (*ActionGroup) IsEmpty

func (ag *ActionGroup) IsEmpty() bool

func (*ActionGroup) MoveTo

func (undo *ActionGroup) MoveTo(redo *ActionGroup)

This bad function Move Undo ActionGroup to RedoActionGroup

func (*ActionGroup) Pop

func (ag *ActionGroup) Pop() (lastAction Action, _ bool)

try before isUndoEmpty() method

func (*ActionGroup) Push

func (ag *ActionGroup) Push(a Action)

type Cursor

type Cursor struct {
	RowIndex int
	ColIndex int
}

func (*Cursor) AdjustForDeletion

func (c *Cursor) AdjustForDeletion(deleteStart, deleteEnd Cursor)

adjustCursorForDeletion updates the cursor position to reflect the deleted text within the buffer.

func (*Cursor) AdjustForInsertion

func (c *Cursor) AdjustForInsertion(insertStart, insertEnd Cursor)

adjustCursorForInsertion updates the cursor position to reflect the inserted text within the buffer.

func (Cursor) Equals

func (c Cursor) Equals(other Cursor) bool

type Encoder

type Encoder interface {
	Encoder(string, *[]byte) error // Save file
	GuessCharset(path string, bytes int) (string, error)
	Decoder(*[]byte) (string, error) // Load file
	IsDecodedMessage(error) bool
}

type File

type File struct {
	LangMode *lang.Mode

	TabWidth int
	SoftTab  bool

	UndoAction *ActionGroup
	RedoAction *ActionGroup
	// contains filtered or unexported fields
}

func NewFile

func NewFile(rawPath string) *File

Call New() or Load() after invoking this function

func (*File) AddRow

func (r *File) AddRow(data []byte)

AddRow adds a new []byte to the lines **slices**

func (*File) AddToRow

func (r *File) AddToRow(index int, b []byte) bool

AddToRow adds a byte to a specific []byte by index

func (*File) Backup

func (ff *File) Backup() error

would like to consider other formats such as dates.

func (*File) ChangePath

func (ff *File) ChangePath(path string)

func (*File) Clear

func (r *File) Clear()

Clear removes all lines

func (*File) DecodeEndRune

func (r *File) DecodeEndRune(rowIndex int) (ch rune, size, colIndex int, ok bool)

func (*File) DecodePrevRune

func (r *File) DecodePrevRune(rowIndex int, colIndex int) (ch rune, size, i int, ok bool)

DecodePrevRune decodes the previous rune from the specified line and position i: colIndex

func (*File) DecodeRune

func (r *File) DecodeRune(rowIndex int, colIndex int) (ch rune, size int, ok bool)

DecodeRune decodes a rune from the specified line and position

func (*File) GetBase

func (ff *File) GetBase() string

func (*File) GetClass

func (ff *File) GetClass() string

func (*File) GetColLength

func (r *File) GetColLength(rowIndex int) (int, bool)

GetColLength returns the length of a specific []byte by index

func (*File) GetDispPath

func (ff *File) GetDispPath() string

func (*File) GetEncoding

func (ff *File) GetEncoding() string

func (*File) GetLinefeed

func (ff *File) GetLinefeed() string

func (*File) GetPath

func (ff *File) GetPath() string

func (*File) GetRegion

func (ff *File) GetRegion(cursor1, cursor2 Cursor) *[]byte

No undo/redo functionality

func (*File) GetRow

func (r *File) GetRow(index int) (*row, bool)

GetRow retrieves a []byte from the lines by index

func (*File) GetTabWidth

func (ff *File) GetTabWidth() int

func (*File) InsertRow

func (r *File) InsertRow(rowIndex int, newRow []byte) bool

InsertRow inserts a new line at the specified index

func (*File) InsertToCol

func (r *File) InsertToCol(rowIndex int, insertIndex int, data []byte) bool

InsertToCol inserts a byte slice into a specific line at the specified position

func (*File) IsDirtyFlag

func (ff *File) IsDirtyFlag() bool

func (*File) IsReadonly

func (ff *File) IsReadonly() bool

func (*File) IsRowIndexLastRow

func (r *File) IsRowIndexLastRow(rowIndex int) bool

func (*File) Load

func (ff *File) Load() error

Load file

func (*File) New

func (ff *File) New() error

New file

func (*File) RemoveRegion

func (ff *File) RemoveRegion(cursor1, cursor2 Cursor) *[]byte

No undo/redo functionality

func (*File) RemoveRow

func (r *File) RemoveRow(rowIndex int) bool

RemoveLine removes a []byte from the lines by index

func (*File) RowLength

func (r *File) RowLength() int

RowLength returns the number of lines

func (*File) Rows

func (ff *File) Rows() *rows

func (*File) Save

func (ff *File) Save() error

Return error is joined errors

func (*File) SetPath

func (ff *File) SetPath(path string)

func (*File) SetReadonly

func (ff *File) SetReadonly(b bool)

func (*File) SetRow

func (r *File) SetRow(rowIndex int, row []byte) bool

SetRow sets the content of a specific line by index

func (*File) String

func (r *File) String(rowIndex int) (string, bool)

Jump to

Keyboard shortcuts

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