memedit

package
v1.3.6-alpha1009 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPosition

func NewPosition(line, column int) *position

func NewRange

func NewRange(p1, p2 PositionIf) *codeRange

Types

type MemEditor

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

func NewMemEditor

func NewMemEditor(sourceCode string) *MemEditor

func (*MemEditor) CodeLength

func (ve *MemEditor) CodeLength() int

func (*MemEditor) CompareRangeWithString

func (ve *MemEditor) CompareRangeWithString(start, end int, compareTo string) (bool, error)

比较指定范围的文本是否与给定字符串相同

func (*MemEditor) ExpandWordTextOffset

func (ve *MemEditor) ExpandWordTextOffset(startOffset, endOffset int) (int, int)

func (*MemEditor) ExpandWordTextRange

func (ve *MemEditor) ExpandWordTextRange(i RangeIf) RangeIf

func (*MemEditor) FindRegexpRange

func (ve *MemEditor) FindRegexpRange(patternStr string, callback func(RangeIf) error) error

func (*MemEditor) FindStringRange

func (ve *MemEditor) FindStringRange(feature string, callback func(RangeIf) error) error

func (*MemEditor) FindStringRangeIndexFirst

func (ve *MemEditor) FindStringRangeIndexFirst(startIndex int, feature string, callback func(RangeIf)) (end int, ok bool)

func (*MemEditor) GetContextAroundRange

func (ve *MemEditor) GetContextAroundRange(startPos, endPos PositionIf, n int, prefix ...func(i int) string) (string, error)

func (*MemEditor) GetContextAroundRangeEx

func (ve *MemEditor) GetContextAroundRangeEx(startPos, endPos PositionIf, n int, prefix func(i int) string, suffix func(i int) string) (string, error)

func (*MemEditor) GetCurrentLine

func (ve *MemEditor) GetCurrentLine() (string, error)

GetCurrentLine 返回当前光标所在行的内容

func (*MemEditor) GetEndOffsetByLine

func (ve *MemEditor) GetEndOffsetByLine(x int) (int, error)

func (*MemEditor) GetFilename

func (ve *MemEditor) GetFilename() string

func (*MemEditor) GetFormatedUrl

func (ve *MemEditor) GetFormatedUrl() string

func (*MemEditor) GetFullRange

func (ve *MemEditor) GetFullRange() RangeIf

func (*MemEditor) GetLine

func (ve *MemEditor) GetLine(x int) (string, error)

获取指定行的内容

func (*MemEditor) GetMinAndMaxOffset

func (ve *MemEditor) GetMinAndMaxOffset(pos ...PositionIf) (int, int)

func (*MemEditor) GetOffsetByPosition

func (ve *MemEditor) GetOffsetByPosition(p PositionIf) int

func (*MemEditor) GetOffsetByPositionRaw

func (ve *MemEditor) GetOffsetByPositionRaw(line, col int) int

func (*MemEditor) GetOffsetByPositionWithError

func (ve *MemEditor) GetOffsetByPositionWithError(line, col int) (int, error)

func (*MemEditor) GetPositionByLine

func (ve *MemEditor) GetPositionByLine(line, column int) PositionIf

func (*MemEditor) GetPositionByOffset

func (ve *MemEditor) GetPositionByOffset(offset int) PositionIf

func (*MemEditor) GetPositionByOffsetWithError

func (ve *MemEditor) GetPositionByOffsetWithError(offset int) (PositionIf, error)

func (*MemEditor) GetPureSourceHash

func (ve *MemEditor) GetPureSourceHash() string

func (*MemEditor) GetRangeByPosition

func (ve *MemEditor) GetRangeByPosition(start, end PositionIf) RangeIf

func (*MemEditor) GetRangeOffset

func (ve *MemEditor) GetRangeOffset(start, end int) RangeIf

func (*MemEditor) GetSourceCode

func (ve *MemEditor) GetSourceCode() string

func (*MemEditor) GetStartOffsetByLine

func (ve *MemEditor) GetStartOffsetByLine(x int) (int, error)

func (*MemEditor) GetTextContextWithPrompt

func (e *MemEditor) GetTextContextWithPrompt(p RangeIf, n int, msg ...string) string

func (*MemEditor) GetTextFromOffset

func (ve *MemEditor) GetTextFromOffset(offset1, offset2 int) string

func (*MemEditor) GetTextFromPosition

func (ve *MemEditor) GetTextFromPosition(p1, p2 PositionIf) string

func (*MemEditor) GetTextFromPositionInt

func (ve *MemEditor) GetTextFromPositionInt(startLine, startCol, endLine, endCol int) string

func (*MemEditor) GetTextFromRange

func (ve *MemEditor) GetTextFromRange(i RangeIf) string

func (*MemEditor) GetTextFromRangeContext

func (ve *MemEditor) GetTextFromRangeContext(i RangeIf, lineNum int) string

func (*MemEditor) GetTextFromRangeWithError

func (ve *MemEditor) GetTextFromRangeWithError(r RangeIf) (string, error)

GetTextFromRangeWithError 根据Range获取文本,优先使用Offset,其次使用Line和Column

func (*MemEditor) GetWordTextFromOffset

func (ve *MemEditor) GetWordTextFromOffset(start, end int) string

func (*MemEditor) GetWordTextFromRange

func (ve *MemEditor) GetWordTextFromRange(i RangeIf) string

func (*MemEditor) IsOffsetValid

func (ve *MemEditor) IsOffsetValid(offset int) bool

func (*MemEditor) IsValidPosition

func (ve *MemEditor) IsValidPosition(line, col int) bool

func (*MemEditor) MoveCursor

func (ve *MemEditor) MoveCursor(position int) error

MoveCursor 移动模拟光标位置

func (*MemEditor) PushSourceCodeContext

func (ve *MemEditor) PushSourceCodeContext(i any)

func (*MemEditor) ResetSourceCodeHash

func (ve *MemEditor) ResetSourceCodeHash()

func (*MemEditor) Select

func (ve *MemEditor) Select(start, end int) (string, error)

Select 返回指定范围的文本

func (*MemEditor) SetUrl

func (ve *MemEditor) SetUrl(url string)

func (*MemEditor) SourceCodeMd5

func (ve *MemEditor) SourceCodeMd5() string

func (*MemEditor) SourceCodeSha1

func (ve *MemEditor) SourceCodeSha1() string

func (*MemEditor) SourceCodeSha256

func (ve *MemEditor) SourceCodeSha256() string

func (*MemEditor) UpdateTextByRange

func (ve *MemEditor) UpdateTextByRange(r RangeIf, newText string) error

UpdateTextByRange 根据Range更新文本,优先使用Offset,其次使用Line和Column

type PositionIf

type PositionIf interface {
	GetLine() int
	GetColumn() int
	// to string
	String() string
}

type RangeIf

type RangeIf interface {
	// position
	GetStart() PositionIf
	GetStartOffset() int
	GetEnd() PositionIf
	GetEndOffset() int
	// editor
	GetEditor() *MemEditor
	// text
	GetText() string
	GetWordText() string
	GetTextContext(int) string
	GetTextContextWithPrompt(n int, msg ...string) string
	Len() int
	// extern
	Add(end RangeIf)

	// to string
	String() string
}

type SafeString

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

func NewSafeString

func NewSafeString(i any) *SafeString

func (*SafeString) Len

func (s *SafeString) Len() int

func (*SafeString) Slice1

func (s *SafeString) Slice1(idx int) rune

func (*SafeString) Slice2

func (s *SafeString) Slice2(start, end int) string

func (*SafeString) SliceBeforeStart

func (s *SafeString) SliceBeforeStart(end int) string

func (*SafeString) SliceToEnd

func (s *SafeString) SliceToEnd(start int) string

func (*SafeString) String

func (s *SafeString) String() string

Jump to

Keyboard shortcuts

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