srcpos

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: 0BSD Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package srcpos converts byte offsets in source text into lines and columns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Position

func Position(src wtf8.String, offset int) (line, column int)

Position converts a byte offset in src into a 1-based line and a 1-based column counted in code points.

Types

type Table

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

Table converts byte offsets in a source text into positions. A Table may be used by multiple goroutines at the same time.

func NewTable

func NewTable(src wtf8.String) *Table

NewTable returns a Table for the text src.

func (*Table) Position

func (t *Table) Position(offset int32) (line, column int)

Position converts a byte offset into a 1-based line and a 1-based column counted in code points.

func (*Table) SourceLine

func (t *Table) SourceLine(offset int32) (text wtf8.String, line, column int)

SourceLine returns the line containing offset and its 1-based line and UTF-16 column numbers.

Jump to

Keyboard shortcuts

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