reader

package
v0.0.0-...-d27f951 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

reader normalizes OS newlines and returns EOF for end of line and panics for errors, which simplifies its usage it also keeps track of the position of the cursor in terms of bytes, lines and columns.

Index

Constants

View Source
const EOF rune = 3 // Pretend there's an EOF byte at the end of the file to simplify control flow, it's treated like a newline TODO: might be better to use -1

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Line           int    // The line number (start with 0)
	LineRuneOffset int    // The number of runes read on this line
	LineOffset     int    // The number of bytes read on this line
	ByteOffset     int    // The number of bytes read so far
	File           string // The file path if present
	// contains filtered or unexported fields
}

type Reader

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

func New

func New(readSeeker io.ReadSeeker) *Reader

func (*Reader) ReadRune

func (r *Reader) ReadRune() rune

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

func (*Reader) UnreadRune

func (r *Reader) UnreadRune()

Jump to

Keyboard shortcuts

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