formula

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package formula reads the formula being typed in the UI: the reference F4 cycles through absolute markers, and the word and function call around the caret that formula assistance follows. It works on the entry's runes alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgPart

func ArgPart(parts []string, arg int, variadic bool) int

ArgPart maps an argument index to the part of the signature that describes it: a repeating part like "[value2, ...]" covers every argument from its position on. It returns -1 past the last argument.

func CycleRef

func CycleRef(buf []rune, pos int) ([]rune, int, bool)

CycleRef finds the reference (or range) at or just before pos in a formula and returns the text with its absolute markers cycled, and the caret moved to the reference's end.

func SplitArgs

func SplitArgs(args string) []string

SplitArgs splits a signature's arguments at the top-level commas, so "[value2, ...]" stays one part.

Types

type Caret

type Caret struct {
	Word      string
	WordStart int
	Fn        string // e.g. "SUM", or "" outside any function's parentheses
	Arg       int    // index of the argument the caret is in
}

Caret describes the formula text before the caret: the word being typed, if it may be a function, name or sheet, and the innermost function call the caret is in. A sheet name being typed in quotes is a word starting with the quote, e.g. "'Q3 p".

func ScanCaret

func ScanCaret(buf []rune, pos int) Caret

ScanCaret reads a formula up to pos the way the lexer does: strings are skipped, parentheses nest, and commas or semicolons at the innermost level separate arguments.

Jump to

Keyboard shortcuts

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