length

package
v0.14.2-0...-12ef1ef Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package length provides various length that can be used for configuring the behavior of line/column calculations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Units

func Units() iter.Seq[Unit]

Units returns an iterator over all of the [Unit]s

Types

type Unit

type Unit int

Unit represents units of measurement for the length of a string.

The most commonly used Unit in protocompile is TermWidth, which approximates columns in a terminal emulator. This takes into account the Unicode width of runes, and tabstops. The rune A is one column wide, the rune 貓 is two columns wide, and the multi-rune emoji presentation sequence 🐈‍⬛ is also two columns wide.

Other units of length can be used to cope with the needs of other rendering contexts, such as the Language Server Protocol.

const (
	Bytes     Unit = iota // The length in UTF-8 code units (bytes).
	UTF16                 // The length in UTF-16 code units (uint16s).
	Runes                 // The length in UTF-32 code units (runes).
	TermWidth             // The length in approximate terminal columns.
)

func (Unit) GoString

func (v Unit) GoString() string

GoString implements fmt.GoStringer.

func (Unit) String

func (v Unit) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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