window

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: BSD-3-Clause Imports: 14 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 window is a desktop window as a terminal.Host, drawn by glyph.Raster. On X11, under Linux and FreeBSD, Xlib opens it and EGL shows each frame as one texture, through GLES 2 or desktop OpenGL, all loaded at run time with purego; on Windows it is a Win32 window and GDI shows the frame. Neither needs cgo. Ctrl with =, - or the wheel zooms within Config.Zoom; Ctrl with 0 undoes the zoom.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Title      string
	Font       *glyph.Font
	Cols, Rows int
	Scale      int
	// Cell is the zoom the window opens at, a cell's height in dp of Scale pixels,
	// 0 for the font's own, its largest strike's; Zoom is the range its player's
	// zoom keeps to, the zero Zoom none
	Cell float64
	Zoom glyph.Zoom
	// Maximized or Fullscreen is the state the window opens in, on X11 asked of the
	// window manager; the grid follows the size that gives, as it follows any resize.
	// Windows has no manager to toggle full screen: F11 and Alt+Enter do there.
	Maximized, Fullscreen bool
}

Config is the window as it opens: its title, the font cells are drawn with, the grid it is sized for and the window pixels a pixel of the font's largest strike covers each way, at least 1, which Windows multiplies by its display's scale

type Window

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

Window is a terminal.Host over a window of the platform's. Frames, Sync and the pointer mode may be set from any goroutine; one locked OS thread owns the window and what draws in it. Its close button posts terminal.EventClosed and leaves it open: Close, which the Fini of NewWithHost's Terminal calls, closes it. On Windows Ctrl-Shift-V and Shift-Insert post the clipboard's text as a paste.

func Open

func Open(cfg Config) (*Window, error)

Open opens the window and starts its thread; it returns once the window is placed on screen, so Size is the grid it then holds

func (*Window) Blocked

func (w *Window) Blocked() time.Duration

Blocked is how long the window has held a frame it has not drawn

func (*Window) Cell

func (w *Window) Cell() float64

Cell is the zoom the player left the window at, a cell's height in dp, 0 for the font's own, which a program keeps for the next run

func (*Window) Close

func (w *Window) Close()

Close stops the thread and releases the window and what draws in it

func (*Window) ColorMode

func (w *Window) ColorMode() terminal.ColorMode

ColorMode is truecolor: the raster resolves every cell to RGB

func (*Window) Events

func (w *Window) Events() <-chan terminal.Event

func (*Window) Flush

func (w *Window) Flush(cells []terminal.Cell, width, height int)

Flush posts a frame; the window draws the newest one it holds when it is free

func (*Window) SetKeyReport

func (w *Window) SetKeyReport(report terminal.KeyReport, allow terminal.KeySource) error

SetKeyReport asks for each key's release, which the window answers with an EventKeyReport: presses alone on an X server that repeats a held key as releases and presses, since those can't be told from the player's own

func (*Window) SetPointerMode

func (w *Window) SetPointerMode(enabled, motion bool)

SetPointerMode selects the pointer events posted: none, buttons and drags, or every motion as well

func (*Window) Size

func (w *Window) Size() (cols, rows int)

Size is the grid of whole cells the window holds

func (*Window) Sync

func (w *Window) Sync()

Sync draws the next frame whole

Jump to

Keyboard shortcuts

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