mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Cleanup and revise TTY interface
This commit is contained in:
parent
286b8d9c71
commit
78c87ab165
44
src/gopheros/device/tty/device.go
Normal file
44
src/gopheros/device/tty/device.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package tty
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gopheros/device/video/console"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// State defines the supported terminal state values.
|
||||||
|
type State uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// StateInactive marks the terminal as inactive. Any writes will be
|
||||||
|
// buffered and not synced to the attached console.
|
||||||
|
StateInactive State = iota
|
||||||
|
|
||||||
|
// StateActive marks the terminal as active. Any writes will be
|
||||||
|
// buffered and also synced to the attached console.
|
||||||
|
StateActive
|
||||||
|
)
|
||||||
|
|
||||||
|
// Device is implemented by objects that can be used as a terminal device.
|
||||||
|
type Device interface {
|
||||||
|
io.Writer
|
||||||
|
io.ByteWriter
|
||||||
|
|
||||||
|
// AttachTo connects a TTY to a console instance.
|
||||||
|
AttachTo(console.Device)
|
||||||
|
|
||||||
|
// State returns the TTY's state.
|
||||||
|
State() State
|
||||||
|
|
||||||
|
// SetState updates the TTY's state.
|
||||||
|
SetState(State)
|
||||||
|
|
||||||
|
// CursorPosition returns the current cursor x,y coordinates. Both
|
||||||
|
// coordinates are 1-based (top-left corner has coordinates 1,1).
|
||||||
|
CursorPosition() (uint16, uint16)
|
||||||
|
|
||||||
|
// SetCursorPosition sets the current cursor position to (x,y). Both
|
||||||
|
// coordinates are 1-based (top-left corner has coordinates 1,1).
|
||||||
|
// Implementations are expected to clip the cursor position to their
|
||||||
|
// viewport.
|
||||||
|
SetCursorPosition(x, y uint16)
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
package tty
|
|
||||||
|
|
||||||
import "io"
|
|
||||||
|
|
||||||
// Tty is implemented by objects that can register themselves as ttys.
|
|
||||||
type Tty interface {
|
|
||||||
io.Writer
|
|
||||||
io.ByteWriter
|
|
||||||
|
|
||||||
// Position returns the current cursor position (x, y).
|
|
||||||
Position() (uint16, uint16)
|
|
||||||
|
|
||||||
// SetPosition sets the current cursor position to (x,y). Console implementations
|
|
||||||
// must clip the provided cursor position if it exceeds the console dimensions.
|
|
||||||
SetPosition(x, y uint16)
|
|
||||||
|
|
||||||
// Clear clears the terminal.
|
|
||||||
Clear()
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user