Documentation
¶
Overview ¶
Package wrap computes where word wrap breaks a line into rows (SPEC §9.2): the algorithm of VS Code's monospace line breaks computer, which counts columns, for lines whose characters have the width of one or two columns, and the helpers the editor uses for the other lines, which it breaks by laying the text out. It has no dependency on the UI.
Ported from VS Code: src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts
Index ¶
Constants ¶
const ( DefaultBreakBefore = "([{‘“〈《「『【〔([{「£¥$£¥++" DefaultBreakAfter = "" /* 275-byte string literal not displayed */ )
Default break characters of VS Code (editor.wordWrapBreakBeforeCharacters and editor.wordWrapBreakAfterCharacters): a row may break before one of the first and after one of the second, which also name where the ideographic and the kinsoku shori rules apply.
Variables ¶
This section is empty.
Functions ¶
func IndentColumns ¶
IndentColumns is the number of columns continuation rows of a line are indented by, as Compute gives them: for a line that is broken another way (by laying the text out).
Types ¶
type Breaks ¶
type Breaks struct {
// Offsets are the byte offsets where the rows end: row i is the text from Offsets[i-1] (0
// for the first row) to Offsets[i]; the last is the length of the line.
Offsets []int
// VisibleColumns are the visible columns of the line at those offsets.
VisibleColumns []int
// IndentLength is the number of columns continuation rows are indented by.
IndentLength int
}
Breaks says how a line is split into rows.
func Compute ¶
Compute breaks a line into rows of o.Column columns, breaking at the best place before the column (after a space, before a bracket, between ideographs), or at the column when there is none. It returns nil when the line fits in one row. Tabs go to the next tab stop and a character of more than one code unit is never split.
Ported from VS Code: src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts (createLineBreaks)
func (*Breaks) RowEnd ¶
RowEnd is the byte offset where a row ends, or -1 for the end of the line when b is nil.
type Indent ¶
type Indent int
Indent is how continuation rows are indented (editor.wrappingIndent).
func ParseIndent ¶
ParseIndent reads a value of editor.wrappingIndent: "none", "same", "indent" or "deepIndent"; anything else is "same", VS Code's default.
type Options ¶
type Options struct {
// TabSize is the distance between tab stops, in columns.
TabSize int
// Column is the number of columns of a row, 1 or more.
Column int
// Indent is how continuation rows are indented.
Indent Indent
// BreakBefore and BreakAfter are the characters a row may break before and after; empty
// strings break nowhere but at the column.
BreakBefore, BreakAfter string
// KeepAll keeps words of ideographs together (editor.wordBreak "keepAll").
KeepAll bool
// FullWidthColumns is how many columns a full-width character takes; 0 means 2.
FullWidthColumns int
}
Options are what the breaking of a line depends on.