edit

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package edit implements buffered position-based editing of byte slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

A Buffer is a queue of edits to apply to a given byte slice.

func NewBuffer

func NewBuffer(old []byte) *Buffer

NewBuffer returns a new buffer to accumulate changes to an initial data slice. The returned buffer maintains a reference to the data, so the caller must ensure the data is not modified until after the Buffer is done being used.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns a new byte slice containing the original data with the queued edits applied.

func (*Buffer) Delete

func (b *Buffer) Delete(start, end int)

Delete deletes the text old[start:end].

func (*Buffer) Insert

func (b *Buffer) Insert(pos int, new string)

Insert inserts the new string at old[pos:pos].

func (*Buffer) Replace

func (b *Buffer) Replace(start, end int, new string)

Replace replaces old[start:end] with new.

func (*Buffer) String

func (b *Buffer) String() string

String returns a string containing the original data with the queued edits applied.

Jump to

Keyboard shortcuts

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