gosh

package module
v0.0.0-...-49fe472 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const GoshLicense = `` /* 1082-byte string literal not displayed */

GoshLicense contains basic information about this shell's license. It defaults to the MIT license.

View Source
const GoshName = "gosh"

GoshName is the shells name, defaulting to "gosh"

View Source
const GoshVersion = "v0.0.1"

GoshVersion is the gosh's rolling version number The GoshVersion number should be equal to the tag version in the Git repository

Variables

This section is empty.

Functions

This section is empty.

Types

type Gosh

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

Gosh type collects all modules of a gosh shell.

func NewGosh

func NewGosh() *Gosh

NewGosh creates a new, empty gosh but does not start it yet.

func (*Gosh) Close

func (g *Gosh) Close()

Close closes all sub-parts of the gosh instance (I/O, the terminal).

func (*Gosh) DebugMessage

func (g *Gosh) DebugMessage(k int, msg string)

DebugMessage sends a message with the specified module identifier and contents to the debug server.

func (*Gosh) Eval

func (g *Gosh) Eval(line string)

Eval evaluates the specified statement in the current namespace

func (*Gosh) GetWD

func (g *Gosh) GetWD() string

GetWD returns a string representation of the current working directory or ~ if any error occured (e. g. the directory was deleted).

func (*Gosh) Init

func (g *Gosh) Init() error

Init prepares all sub-functionality of this gosh instance. If the returned error is not nil, this gosh must not be used until the issue is fixed.

func (*Gosh) Interactive

func (g *Gosh) Interactive() (int, error)

Interactive sets this gosh's mode to interactive. User input is read from the underlying terminal and commands are executed in the current namespace. A suitable exit code and any error is returned in the end.

func (*Gosh) LoadPlugin

func (g *Gosh) LoadPlugin(s string) error

LoadPlugin loads the plugin specified by the path. It returns an error if the file could not be read.

func (*Gosh) SendKey

func (g *Gosh) SendKey(k *termios.Key) bool

SendKey sends the specified key to all loaded plugins.

func (*Gosh) SetDebugClient

func (g *Gosh) SetDebugClient(c *debug.Client)

SetDebugClient attaches the specified debugging client to the gosh instance.

func (*Gosh) Write

func (g *Gosh) Write(p []byte) (int, error)

func (*Gosh) WriteString

func (g *Gosh) WriteString(s string) (int, error)

WriteString writes the specified string to the gosh's terminal

type Handler

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

Handler handles all event-based plugins. It is capable of loading new plugins from a specified path using the Load() method, as well as sending an event to all registered plugins

func NewHandler

func NewHandler(g *Gosh) *Handler

NewHandler creates a new plugin handler with 0 plugins pre-loaded and the specified gosh as parent. g shall not be nil.

func (*Handler) Load

func (h *Handler) Load(path string) error

Load loads a plugin (shared library) from the specified path. It returns an error if the file could not be found.

func (*Handler) OnKey

func (h *Handler) OnKey(k *termios.Key) bool

OnKey sends the event to all plugins and returns false as soon as the first plugin returns false or true if all loaded plugins returned true.

type Prompt

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

Prompt is responsible for drawing the UI of an interactive Gosh

func NewPrompt

func NewPrompt(parent *Gosh) *Prompt

NewPrompt creates a new prompt with the SimplePromptStyle style.

func (*Prompt) OnKey

func (p *Prompt) OnKey(key termios.Key)

OnKey is the event callback when a key has been pressed in the interactive terminal

type PromptStyle

type PromptStyle interface {

	// LeftPrompt returns the contents of the area to the left of the prompt.
	// The int parameter indicates which prompt line is requested (starting with 0).
	// All paddings and margins must be added inside the prompt style, as the style will
	// be printed as-is and with no added spaces.
	LeftPrompt(*Gosh, int) string

	// RightPrompt returns the contents of the area on the right side of the screen.
	// The contents should be returned from left to right
	RightPrompt(*Gosh, int) string
}

PromptStyle are individual styles for the prompt. They create prompt text to the left and right.

type SimplePromptStyle

type SimplePromptStyle struct{}

SimplePromptStyle is a prompt style that displays the most basic contents

func (*SimplePromptStyle) LeftPrompt

func (s *SimplePromptStyle) LeftPrompt(g *Gosh, line int) string

LeftPrompt displays the current working directory and an >

func (*SimplePromptStyle) RightPrompt

func (s *SimplePromptStyle) RightPrompt(g *Gosh, line int) string

RightPrompt simply displays a bar

Jump to

Keyboard shortcuts

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