mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Detect hw and wire active console and TTY
This commit is contained in:
@@ -5,6 +5,14 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultScrollback defines the terminal scrollback in lines.
|
||||
DefaultScrollback = 80
|
||||
|
||||
// DefaultTabWidth defines the number of spaces that tabs expand to.
|
||||
DefaultTabWidth = 4
|
||||
)
|
||||
|
||||
// State defines the supported terminal state values.
|
||||
type State uint8
|
||||
|
||||
|
||||
11
src/gopheros/device/tty/probe.go
Normal file
11
src/gopheros/device/tty/probe.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package tty
|
||||
|
||||
import "gopheros/device"
|
||||
|
||||
// HWProbes returns a slice of device.ProbeFn that can be used by the hal
|
||||
// package to probe for TTY device hardware.
|
||||
func HWProbes() []device.ProbeFn {
|
||||
return []device.ProbeFn{
|
||||
probeForVT,
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package tty
|
||||
|
||||
import (
|
||||
"gopheros/device"
|
||||
"gopheros/device/video/console"
|
||||
"gopheros/kernel"
|
||||
"io"
|
||||
@@ -258,3 +259,7 @@ func (t *VT) DriverVersion() (uint16, uint16, uint16) {
|
||||
|
||||
// DriverInit initializes this driver.
|
||||
func (t *VT) DriverInit() *kernel.Error { return nil }
|
||||
|
||||
func probeForVT() device.Driver {
|
||||
return NewVT(DefaultTabWidth, DefaultScrollback)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"gopheros/device/video/console"
|
||||
"image/color"
|
||||
"io"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -337,6 +338,28 @@ func TestVTDriverInterface(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVTProbe(t *testing.T) {
|
||||
var (
|
||||
expProbePtr = reflect.ValueOf(probeForVT).Pointer()
|
||||
foundProbe bool
|
||||
)
|
||||
|
||||
for _, probeFn := range HWProbes() {
|
||||
if reflect.ValueOf(probeFn).Pointer() == expProbePtr {
|
||||
foundProbe = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !foundProbe {
|
||||
t.Fatal("expected probeForVT to be part of the probes returned by HWProbes")
|
||||
}
|
||||
|
||||
if drv := probeForVT(); drv == nil {
|
||||
t.Fatal("expected probeForVT to return a driver")
|
||||
}
|
||||
}
|
||||
|
||||
type mockConsole struct {
|
||||
width, height uint16
|
||||
fg, bg uint8
|
||||
|
||||
Reference in New Issue
Block a user