Initial import

This commit is contained in:
2025-10-10 10:05:13 +02:00
parent 3effc1597b
commit b96b6e7f8f
164 changed files with 5473 additions and 0 deletions

68
recorder/recorder.go Normal file
View File

@@ -0,0 +1,68 @@
package recorder
import (
"errors"
"io"
"os"
)
type Format int
const (
Text Format = iota
TTYRec
ASCIICastv3
)
var (
ErrFormat = errors.New("recorder: unknown format")
)
type Recorder interface {
Reads() io.WriteCloser
Writes() io.WriteCloser
}
type Resizer interface {
Resize(columns, rows int)
}
type Info struct {
Columns int
Rows int
TerminalType string
Title string
Env map[string]string
}
func New(name string, format Format, info Info) (Recorder, error) {
f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY, 0o640)
if err != nil {
return nil, err
}
return NewWriter(f, format, info)
}
func NewWriter(wc io.WriteCloser, format Format, info Info) (Recorder, error) {
switch format {
case Text:
return textRecorder{wc}, nil
case ASCIICastv3:
return newAsciiCastRecorder(wc, info)
case TTYRec:
return newTTYRecRecorder(wc), nil
default:
return nil, ErrFormat
}
}
type nopCloser struct {
io.Writer
}
func (nopCloser) Close() error {
return nil
}