android

package
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: 6 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 android is the Go half of an Android view showing a Terminal's cells: the grid its pixels hold, its keys, touches and text as Events, the frames its drawer takes and the texture it paints them from. An app's binding calls a View from the view's own threads; nothing here imports one.

Index

Constants

View Source
const DefaultCell = 12

DefaultCell is a cell's height in dp until a pinch zooms it, in whole pixels at the face's aspect: 16x32 on a 420 dpi phone

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Font    *glyph.Font
	Raster  bool       // the drawer shows the raster's pixels, not cells of the texture
	Density float32    // the screen's pixels to a dp
	Cell    float64    // a kept zoom, a cell's height in dp, 0 for DefaultCell
	Zoom    glyph.Zoom // the range a pinch keeps the cell to
	BarRows int        // the rows at the grid's foot a finger presses with the pointer off, 0 for none
}

Config is what a view opens with

type View

type View struct {
	*terminal.Frames
	// contains filtered or unexported fields
}

View is an Android view as a terminal.Host. Frames wait in the embedded terminal.Frames for the drawer to take them; the grid is the cells the view's pixels hold, and the drawer stretches it over them, so a touch maps in proportion. The UI thread calls what sizes the view and reads its input, the drawer's thread AtlasChanged and Take, the program the rest.

func NewView

func NewView(c Config) *View

NewView opens a view with no pixels yet: its first Resize gives it its grid, before its program reads Size or a finger lands

func (*View) Aspect

func (v *View) Aspect() float64

Aspect is the width over the height of the cells the view shows: the face's, whichever strike draws them

func (*View) Atlas

func (v *View) Atlas() []byte

Atlas is the texture of the strike frames are encoded for, as glyph.NewTexture lays it out; a drawer of the raster's pixels reads the cell's size from it

func (*View) AtlasChanged

func (v *View) AtlasChanged() []byte

AtlasChanged is Atlas once after a zoom crossed to another strike and the program drew the zoomed grid, nil otherwise. The drawer's thread calls it before each Take and paints from what it returns: the frames switch to that strike in the same call, the next one every cell, so none is encoded for a texture the drawer does not hold, and the drawer never repaints the grid the zoom left in the new strike.

func (*View) Cell

func (v *View) Cell() float64

Cell is the zoom the player left the view at, a cell's height in dp, 0 for DefaultCell

func (*View) Covered

func (v *View) Covered() int

Covered is the grid's rows the keyboard hides with the strip above it, the drawer stretching the grid over the view's pixels

func (*View) Drag

func (v *View) Drag(x, y int)

Drag is a pressed finger moving to the view's pixel x, y: the left button dragged to the cell under it, once per cell

func (*View) Events

func (v *View) Events() <-chan terminal.Event

func (*View) Flush added in v0.7.2

func (v *View) Flush(cells []terminal.Cell, width, height int)

Flush keeps a frame for the drawer and notes its grid, which AtlasChanged waits on

func (*View) FocusLost

func (v *View) FocusLost()

FocusLost ends every key held: the window's keys go elsewhere, their ups too

func (*View) Key

func (v *View) Key(code, typed, meta int32) bool

Key is a key pressed and let go at once, with no up of its own to come: Back, or the system keyboard's delete

func (*View) KeyDown

func (v *View) KeyDown(code, typed, meta int32, repeat bool) bool

KeyDown is a key the view received going down, or repeating while held: Android's key code, the character it types without Ctrl or Alt (0 for none) and its meta state. It reports whether a terminal has the key; one it has not, a volume key, is left to the system.

func (*View) KeyUp

func (v *View) KeyUp(code, typed, meta int32) bool

KeyUp is a key the view received coming up, taken as its KeyDown was

func (*View) OnBar

func (v *View) OnBar(y int) bool

OnBar reports whether the view's pixel row y is drawn on the bar, where a finger presses with the pointer off

func (*View) Post

func (v *View) Post(ev terminal.Event)

Post queues an event for the program; with the queue full the event is lost, which a UI thread that must not wait on the program prefers

func (*View) Resize

func (v *View) Resize(width, height int) bool

Resize follows the view's pixels: the grid is the whole cells they hold, at least one each way. It reports whether the grid changed, and posts the change as a resize unless the grid is the view's first, the one its program opens on.

func (*View) SetCovered

func (v *View) SetCovered(px int)

SetCovered is the pixels at the view's foot the system keyboard covers, 0 while it is down

func (*View) SetKeyReport

func (v *View) SetKeyReport(report terminal.KeyReport, allow terminal.KeySource) error

SetKeyReport asks for each key's release, which a hardware key's up gives; the system keyboard's text and the keys the view makes let go as they press

func (*View) SetPointerMode

func (v *View) SetPointerMode(enabled, _ bool)

SetPointerMode drops touches while the program takes no pointer; a finger has no motion of its own to report

func (*View) Size

func (v *View) Size() (cols, rows int)

func (*View) Text

func (v *View) Text(s string)

Text is what the system keyboard committed or a paste brought: one event carries it, so a long paste fits the queue whole

func (*View) Touch

func (v *View) Touch(x, y int, down bool)

Touch is a finger going down or up at the view's pixel x, y: the left button pressed or released on the cell under it

func (*View) Zoom

func (v *View) Zoom(scale float64)

Zoom scales the cell by a pinch's scale, a step of the range and never under the font's smallest strike, and refits the grid to the view's pixels

Jump to

Keyboard shortcuts

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