settingsui

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 16 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 settingsui holds the settings editor (SPEC §11.1): the widget that lists the registered settings by group, edits them in the user's or the workspace's settings.json through core/settings, and marks the ones the file sets.

Ported from VS Code: src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts and settingsTree.ts (the layout, the rows, the commit rules and the colors); the model is core/settings (UIModel).

Index

Constants

View Source
const (

	// UserTabLabel and WorkspaceTabLabel are the texts of the tabs of the targets.
	UserTabLabel      = "User"
	WorkspaceTabLabel = "Workspace"
	// NoWorkspaceTooltip is the tooltip of the Workspace tab while no folder is open.
	NoWorkspaceTooltip = "Open a folder to edit the settings of the workspace."
	// OpenJSONTooltip is the tooltip of the button that opens the file of the tab.
	OpenJSONTooltip = "Open Settings (JSON)"
	// NoResultsText is what the list says while nothing matches the search.
	NoResultsText = "No Settings Found."
	// LanguageHeaderPrefix is the text before the name of the language in the title of the list of @lang:.
	LanguageHeaderPrefix = "Language: "
	// ClearSearchTooltip is the tooltip of the button that clears the search box.
	ClearSearchTooltip = "Clear Search Results"
)

Metrics of the settings editor, from VS Code's settingsEditor2.css.

Variables

This section is empty.

Functions

func RowKey

func RowKey(categoryID, key string) foundation.Key

RowKey is the key of the widget of a setting in a group of the list; tests find rows by it.

Types

type Controller

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

Controller drives a settings editor from outside: the commands that open the editor with a search, and tests. It belongs to one editor.

func NewController

func NewController() *Controller

NewController makes a controller that is not attached to an editor yet; its methods do nothing until it is.

func (*Controller) FocusSearch

func (c *Controller) FocusSearch()

FocusSearch gives the search box the focus.

func (*Controller) SearchInput added in v1.0.0

SearchInput is the text and the focus node of the search box, nil while the editor is not built; with SearchTyped it is what kit.StartTypeAheadLater needs to type the keys that came before the box was there.

func (*Controller) SearchTyped added in v1.0.0

func (c *Controller) SearchTyped(text string)

SearchTyped is told that the text of the search box was changed other than by typing in it (a type-ahead put keys there): the list is filtered by it, as it is by the keys the box takes itself.

func (*Controller) SelectCategory

func (c *Controller) SelectCategory(id string)

SelectCategory selects a group of the tree and scrolls the list to it.

func (*Controller) SetQuery

func (c *Controller) SetQuery(q string)

SetQuery puts a text in the search box and filters the list by it.

func (*Controller) SetTarget

func (c *Controller) SetTarget(t editorgroup.SettingsTarget)

SetTarget switches the tab.

func (*Controller) ViewState

func (c *Controller) ViewState() editorgroup.SettingsViewState

ViewState is the view of the editor now.

type Editor

type Editor struct {
	widgets.StatefulWidget
	// contains filtered or unexported fields
}

Editor is the settings editor (SPEC §11.1): a search box, the tabs of the user's and the workspace's settings and the button that opens the JSON file over a tree of the groups of settings and the list of the settings of each group, whose rows are as high as their text and control are. A change of the settings by anything else, such as typing in settings.json, shows in the rows at once.

Ported from VS Code: src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts and settingsTree.ts

func NewEditor

func NewEditor(opts Options) *Editor

NewEditor makes a settings editor.

func (*Editor) CreateState

func (e *Editor) CreateState() widgets.State

CreateState implements widgets.StatefulWidget.

type Options

type Options struct {
	// Model is the model of the settings over the store the editor reads and writes (core/settings).
	Model *settings.UIModel
	// Context is the context of the writes.
	Context context.Context
	// State is the view the editor starts with: the tab, the group of the tree that is selected, how far the
	// list is scrolled and the text of the search.
	State editorgroup.SettingsViewState
	// OnState is called when the user changes the view (the tab, the group, the scroll position, the search); the
	// owner keeps it with the input of the editor (SPEC §10.10).
	OnState func(editorgroup.SettingsViewState)
	// HasFolder says that a folder is open: the Workspace tab is enabled only then.
	HasFolder bool
	// OnOpenJSON opens the settings.json of a target in a text editor, at the key of a setting when it is not
	// empty. The button of the header and the "Edit in settings.json" link call it.
	OnOpenJSON func(target settings.Target, key string)
	// Languages finds the language of the filter @lang: by its id or name; without it the text after @lang: is the
	// id of a language that exists.
	Languages settings.LanguageResolver
	// OnError is told of a write that failed (the file has errors, cannot be written); the owner shows it.
	OnError func(err error)
	// CopyText puts a text on the clipboard ("Copy Setting ID").
	CopyText func(text string)
	// CodeFont is the family of the code spans of the descriptions; the desktop's monospace font by default.
	CodeFont string
	// Controller lets code drive the editor from outside.
	Controller *Controller
	// Autofocus gives the search box the focus when the editor is shown.
	Autofocus bool
}

Options are the options of NewEditor.

Jump to

Keyboard shortcuts

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