terminal

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package terminal serves the terminal socket: a page attaches to a tab's tmux session through a pty and talks a small binary protocol. One byte of type, then the payload:

page → runtime: 0x00 keystrokes, 0x02 resize (uint16 cols, uint16 rows, big endian), 0x03 heartbeat,
                0x04 kill the session, 0x05 text from the composer, 0x06 the id of the composer message that the
                next 0x05 carries ({"id": "…"})
runtime → page: 0x01 output (UTF-8, whole characters), 0x03 heartbeat answer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge interface {
	// ClaimPrompt is false when the composer message went into a pane already: it must not be typed again.
	ClaimPrompt(id, session, text string) bool
	// PromptEnter notes that Enter was passed on in the session, for the prompt-submit timing.
	PromptEnter(session string)
	// ReconcileCwd: a tab's session is gone, its saved folder may need fixing.
	ReconcileCwd(session string)
}

Bridge is what the terminal tells the rest of the runtime.

type Config

type Config struct {
	Tmux   *tmux.Tmux
	Bridge Bridge
	Home   string
	// Env is the environment of the tmux client the pty runs.
	Env            []string
	MaxConnections int
}

type Server

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

Server holds the open terminals.

func New

func New(cfg Config) *Server

func (*Server) Attached added in v0.15.40

func (s *Server) Attached(session string) bool

Attached: a page has the session's terminal open now.

func (*Server) Handle

func (s *Server) Handle(w http.ResponseWriter, r *http.Request)

Handle upgrades an already authenticated request for `?session=` and serves it until either side closes.

func (*Server) Pause

func (s *Server) Pause(session string) (cols, rows int, ok bool)

Pause stops the session's output to the page while the pane is captured at another width; false when there is no terminal or it is paused already.

func (*Server) Resize

func (s *Server) Resize(session string, cols, rows int)

Resize sets the session's pty size, whatever the page asked.

func (*Server) Resume

func (s *Server) Resume(session string)

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown closes every terminal; the sessions stay.

func (*Server) Size

func (s *Server) Size(session string) (cols, rows int, ok bool)

Size is the size the page gave the session's terminal.

Jump to

Keyboard shortcuts

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