length

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 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 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