termfs

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2022 License: BSD-3-Clause Imports: 7 Imported by: 4

Documentation

Overview

Package termfs provides a lightweight implementation of terminal device filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CharMap added in v0.0.2

type CharMap uint8
const (
	InCRLF    CharMap = 1 << 0 // map input "\r" to "\n"
	OutLFCRLF CharMap = 1 << 3 // map output "\n" to "\r\n"

)

type FS

type FS struct {
	// contains filtered or unexported fields
}

An FS provides a file system that represents a terminal device. As the embeded systems rarely require more than one terminal device (console) the FS is very simple and provides only one device file "." which can be opened, written and read concurenly by multiple goroutines.

func New

func New(name string, r io.Reader, w io.Writer) *FS

New returns a new terminal file system named name. The r and w correspond to the terminal input and output device.

func (*FS) CharMap added in v0.0.2

func (fsys *FS) CharMap() CharMap

func (*FS) Echo added in v0.0.2

func (fsys *FS) Echo() bool

Echo returns the echo configuration.

func (*FS) LineMode added in v0.0.2

func (fsys *FS) LineMode() (enabled bool, maxLen int)

LineMode returns the configuration of line mode.

func (*FS) Name

func (fsys *FS) Name() string

Name implements the rtos.FS Name method

func (*FS) OpenWithFinalizer

func (fsys *FS) OpenWithFinalizer(name string, flag int, perm fs.FileMode, closed func()) (fs.File, error)

OpenWithFinalizer implements the rtos.FS OpenWithFinalizer method. The name must be ".", the flag can be O_RDWR, O_RDONLY, O_WRONLY, the perm is ignored.

func (*FS) SetCharMap added in v0.0.2

func (fsys *FS) SetCharMap(cmap CharMap)

func (*FS) SetEcho added in v0.0.2

func (fsys *FS) SetEcho(on bool)

SetEcho enables/disables echoing of input data. Data are echoed by fs.File Read method. The echo is a confirmation that the reading goroutine is ready to consume data.

func (*FS) SetLineMode added in v0.0.2

func (fsys *FS) SetLineMode(enable bool, maxLen int)

SetLineMode allows to enable/disable the line mode and change the size of the internal line buffer. The default line buffer has zero size. Use maxLen > 0 to allocate a new one, maxLen == 0 to free it and maxLen < 0 to leave the line buffer unchanged.

In the line mode the terminal input is buffered until new-line character received. Small subset of ANSI terminal codes is supported to enable editing the line before passing it to the reading goroutine. There is also simple one line history implemented (use up, down arrows).

func (*FS) Type

func (fsys *FS) Type() string

Type implements the rtos.FS Type method

func (*FS) Usage added in v0.0.2

func (fsys *FS) Usage() (int, int, int64, int64)

Usage implements the rtos.FS Usage method

type LightFS added in v0.0.3

type LightFS struct {
	// contains filtered or unexported fields
}

An LightFS provides a file system that represents a terminal device. It is a thin wrapper over provided io.Reader and io.Writer that allows use them concurently by multiple goroutines. Unlike FS it does not support CR/LF conversions, echo, line editing. If you need such futures use FS or configure your terminal emulator to handle them locally.

func NewLight added in v0.0.3

func NewLight(name string, r io.Reader, w io.Writer) *LightFS

NewLight returns a new terminal file system named name. The r and w correspond to the terminal input and output device.

func (*LightFS) Name added in v0.0.3

func (fsys *LightFS) Name() string

Name implements the rtos.FS Name method

func (*LightFS) OpenWithFinalizer added in v0.0.3

func (fsys *LightFS) OpenWithFinalizer(name string, flag int, perm fs.FileMode, closed func()) (fs.File, error)

OpenWithFinalizer implements the rtos.FS OpenWithFinalizer method. The name must be ".". The flag and perm are ignored.

func (*LightFS) Type added in v0.0.3

func (fsys *LightFS) Type() string

Type implements the rtos.FS Type method

func (*LightFS) Usage added in v0.0.3

func (fsys *LightFS) Usage() (int, int, int64, int64)

Usage implements the rtos.FS Usage method

Jump to

Keyboard shortcuts

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