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
- type Config
- type View
- func (v *View) Aspect() float64
- func (v *View) Atlas() []byte
- func (v *View) AtlasChanged() []byte
- func (v *View) Cell() float64
- func (v *View) Covered() int
- func (v *View) Drag(x, y int)
- func (v *View) Events() <-chan terminal.Event
- func (v *View) Flush(cells []terminal.Cell, width, height int)
- func (v *View) FocusLost()
- func (v *View) Key(code, typed, meta int32) bool
- func (v *View) KeyDown(code, typed, meta int32, repeat bool) bool
- func (v *View) KeyUp(code, typed, meta int32) bool
- func (v *View) OnBar(y int) bool
- func (v *View) Post(ev terminal.Event)
- func (v *View) Resize(width, height int) bool
- func (v *View) SetCovered(px int)
- func (v *View) SetKeyReport(report terminal.KeyReport, allow terminal.KeySource) error
- func (v *View) SetPointerMode(enabled, _ bool)
- func (v *View) Size() (cols, rows int)
- func (v *View) Text(s string)
- func (v *View) Touch(x, y int, down bool)
- func (v *View) Zoom(scale float64)
Constants ¶
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 ¶
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 ¶
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 ¶
Aspect is the width over the height of the cells the view shows: the face's, whichever strike draws them
func (*View) Atlas ¶
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 ¶
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 ¶
Cell is the zoom the player left the view at, a cell's height in dp, 0 for DefaultCell
func (*View) Covered ¶
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 ¶
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) Flush ¶ added in v0.7.2
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 ¶
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 ¶
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) OnBar ¶
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 ¶
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 ¶
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 ¶
SetCovered is the pixels at the view's foot the system keyboard covers, 0 while it is down
func (*View) SetKeyReport ¶
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 ¶
SetPointerMode drops touches while the program takes no pointer; a finger has no motion of its own to report
func (*View) Text ¶
Text is what the system keyboard committed or a paste brought: one event carries it, so a long paste fits the queue whole