gio

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 8 Imported by: ? 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 gio fills gaps in Gio's widgets: Ctrl-modified word motion and deletion for editors, and mouse wheel scrolling by whole notches.

Index

Constants

View Source
const (
	// WheelNotch is the scroll distance Gio reports for one wheel notch on X11.
	WheelNotch = 10
	// MaxWheelNotches caps the notches a single scroll event can produce.
	// Wayland reports many times WheelNotch for one notch, so without a cap
	// each notch would jump much further than it does on X11.
	MaxWheelNotches = 3
)

Variables

This section is empty.

Functions

func HandleWordEditing

func HandleWordEditing(gtx layout.Context, ed *widget.Editor) (changed bool)

HandleWordEditing handles word editing keys for ed: Ctrl+Left and Ctrl+Right move the caret by a word, extending the selection with Shift, and Ctrl+Backspace and Ctrl+Delete delete a word, or the selection if there is one. Deletions are ignored while ed is read-only, but motion still works. Edits go through the editor's caret and delete calls, so they can be undone.

HandleWordEditing must be called each frame before anything else reads ed's events, including ed's own Update and Layout, since Gio gives each key event to the first filter that matches it. It reports whether it changed ed's text, as the editor won't send a ChangeEvent for these edits.

func WordBoundary

func WordBoundary(text []rune, pos, dir int) int

WordBoundary returns the rune offset reached by moving a word from pos in direction dir (-1 back, 1 forward) through text: past any whitespace, then past the run of non-whitespace beyond it.

Types

type WheelAccumulator

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

WheelAccumulator turns Gio's mouse wheel scroll distances into whole notches, so a notch can scroll by something meaningful, such as list items, rather than the few pixels Gio's X11 backend reports for one. Smooth scrolling, as from a trackpad, reports fractions of a notch that add up across events. The zero value is ready to use.

func (*WheelAccumulator) Add

func (a *WheelAccumulator) Add(delta float32) int

Add adds a scroll distance and returns the whole notches it completes, from -MaxWheelNotches to MaxWheelNotches. What's left of a notch is kept for later calls, unless the direction reverses or the cap is reached, when it's dropped.

type WheelList

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

WheelList scrolls a widget.List by a number of items per wheel notch, in place of the list's own pixel-based wheel scrolling. The zero value is ready to use.

func (*WheelList) Layout

func (l *WheelList) Layout(
	gtx layout.Context,
	list *widget.List,
	itemsPerNotch float32,
	w layout.Widget,
) layout.Dimensions

Layout lays out w, which should lay out list, and scrolls list by itemsPerNotch items for each wheel notch over it. It takes every wheel event over w along list's axis, but clicks, drags and hovers pass through to w, so list's scrollbar and items work as usual.

Jump to

Keyboard shortcuts

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