replay

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT Imports: 30 Imported by: 0

README

replay

Package replay is an interface for playing, searching, and copying text from recorded terminal sessions.

Documentation

Index

Constants

View Source
const (
	PLAYBACK_FPS   = 30
	IDLE_THRESHOLD = time.Second
)

Variables

View Source
var Incremental stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createIncrementalSession(),
		ActionCursorUp,
		ActionBeginning,
		ActionSearchForward,
	)

	return replay, nil
}
View Source
var IncrementalBackward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createIncrementalSession(),
		ActionCursorUp,
		ActionBeginning,
		ActionSearchBackward,
		"century",
	)

	return replay, nil
}
View Source
var IncrementalForward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createIncrementalSession(),
		ActionCursorUp,
		ActionBeginning,
		ActionSearchForward,
		"century",
	)

	return replay, nil
}
View Source
var JumpBackward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createStorySession(),
		ActionSearchBackward,
		"3m",
	)

	return replay, nil
}
View Source
var JumpForward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createStorySession(),
		ActionSearchForward,
		"3m",
	)

	return replay, nil
}
View Source
var SearchEmpty stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createStorySession(),
		ActionBeginning,
		ActionSearchForward,
		"asdf",
		"enter",
	)

	return replay, nil
}
View Source
var SearchProgress stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createStorySession(),
		ActionSearchForward,
		"query",
		"enter",
		ProgressEvent{Percent: 60},
	)

	return replay, nil
}
View Source
var SearchTimeBackward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createStorySession(),
		ActionSearchBackward,
		"query",
	)

	return replay, nil
}
View Source
var SearchTimeForward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createStorySession(),
		ActionSearchForward,
		"query",
	)

	return replay, nil
}
View Source
var Searching stories.InitFunc = func(ctx context.Context) (mux.Screen, error) {
	replay := createStory(
		ctx,
		createStorySession(),
		ActionSearchForward,
		"query",
		"enter",
	)

	return replay, nil
}
View Source
var (
	TIME_DELTA_REGEX = regexp.MustCompile("^((?P<days>\\d+)d)?((?P<hours>\\d+)h)?((?P<min>\\d+)m)?((?P<sec>\\d+)s)?$")
)

Functions

func New

func New(
	ctx context.Context,
	player *player.Player,
	timeBinds, copyBinds *bind.BindScope,
	options ...Option,
) *taro.Program

func WithCopyMode

func WithCopyMode(r *Replay)

WithCopyMode puts Replay immediately into copy mode.

func WithFlow

func WithFlow(r *Replay)

WithFlow swaps to flow mode, if possible.

func WithNoQuit

func WithNoQuit(r *Replay)

WithNoQuit makes it so Replay will never exit.

Types

type ActionEvent

type ActionEvent struct {
	Type ActionType
	Arg  string
}

type ActionType

type ActionType int
const (
	ActionQuit ActionType = iota

	// Bimodal actions
	ActionBeginning
	ActionEnd
	ActionSearchForward
	ActionSearchBackward
	ActionSearchAgain
	ActionSearchReverse

	// Time controls have no tmux parallel
	//////////////////////////////////////
	ActionTimePlay
	ActionTimeStepBack
	ActionTimeStepForward

	// cy-specific actions
	//////////////////////
	ActionSwapScreen
	ActionCommandForward
	ActionCommandBackward
	ActionCommandSelectForward
	ActionCommandSelectBackward

	//////////////////////////////////////////////////////////////////
	// ╺┳╸┏┳┓╻ ╻╻ ╻   ┏━╸┏━┓┏━┓╻ ╻   ┏┳┓┏━┓╺┳┓┏━╸
	//  ┃ ┃┃┃┃ ┃┏╋┛   ┃  ┃ ┃┣━┛┗┳┛   ┃┃┃┃ ┃ ┃┃┣╸
	//  ╹ ╹ ╹┗━┛╹ ╹   ┗━╸┗━┛╹   ╹    ╹ ╹┗━┛╺┻┛┗━╸
	//////////////////////////////////////////////////////////////////
	// All tmux copy-mode commands, only some of which are implemented
	//////////////////////////////////////////////////////////////////
	// append-selection
	// append-selection-and-cancel                  A
	// back-to-indentation                          ^               M-m
	// begin-selection                              Space           C-Space
	// bottom-line                                  L
	// cancel                                       q               Escape
	// clear-selection                              Escape          C-g
	// copy-end-of-line [<prefix>]
	// copy-end-of-line-and-cancel [<prefix>]
	// copy-pipe-end-of-line [<command>] [<prefix>]
	// copy-pipe-end-of-line-and-cancel [<command>] [<prefix>] D               C-k
	// copy-line [<prefix>]
	// copy-line-and-cancel [<prefix>]
	// copy-pipe-line [<command>] [<prefix>]
	// copy-pipe-line-and-cancel [<command>] [<prefix>]
	// copy-pipe [<command>] [<prefix>]
	// copy-pipe-no-clear [<command>] [<prefix>]
	// copy-pipe-and-cancel [<command>] [<prefix>]
	// copy-selection [<prefix>]
	// copy-selection-no-clear [<prefix>]
	// copy-selection-and-cancel [<prefix>]         Enter           M-w
	ActionCopy
	// cursor-down                                  j               Down
	ActionCursorDown
	// cursor-down-and-cancel
	// cursor-left                                  h               Left
	ActionCursorLeft
	// cursor-right                                 l               Right
	ActionCursorRight
	// cursor-up                                    k               Up
	ActionCursorUp
	// end-of-line                                  $               C-e
	// goto-line <line>                             :               g
	// halfpage-down                                C-d             M-Down
	ActionScrollDownHalf
	// halfpage-down-and-cancel
	// halfpage-up                                  C-u             M-Up
	ActionScrollUpHalf
	// history-bottom                               G               M->
	// history-top                                  g               M-<
	// jump-again                                   ;               ;
	ActionJumpAgain
	// jump-backward <to>                           F               F
	ActionJumpBackward
	// jump-forward <to>                            f               f
	ActionJumpForward
	// jump-reverse                                 ,               ,
	ActionJumpReverse
	// jump-to-backward <to>                        T
	ActionJumpToBackward
	// jump-to-forward <to>                         t
	ActionJumpToForward
	// jump-to-mark                                 M-x             M-x
	// middle-line                                  M               M-r
	// next-matching-bracket                        %               M-C-f
	// next-paragraph                               }               M-}
	// next-space                                   W
	// next-space-end                               E
	// next-word                                    w
	// next-word-end                                e               M-f
	// other-end                                    o
	// page-down                                    C-f             PageDown
	// page-down-and-cancel
	// page-up                                      C-b             PageUp
	// pipe [<command>] [<prefix>]
	// pipe-no-clear [<command>] [<prefix>]
	// pipe-and-cancel [<command>] [<prefix>]
	// previous-matching-bracket                                    M-C-b
	// previous-paragraph                           {               M-{
	// previous-space                               B
	// previous-word                                b               M-b
	// rectangle-on
	// rectangle-off
	// rectangle-toggle                             v               R
	ActionSelect
	// refresh-from-pane                            r               r
	// scroll-down                                  C-e             C-Down
	ActionScrollDown
	// scroll-down-and-cancel
	// scroll-up                                    C-y             C-Up
	ActionScrollUp

	// Left-right motions
	/////////////////////
	// h, left, ctrl+h, backspace -> ActionCursorLeft
	// l, right, space -> ActionCursorRight
	// 0
	ActionStartOfLine
	// home -> TODO
	// ^
	ActionFirstNonBlank
	// $, end
	ActionEndOfLine
	// g_
	ActionLastNonBlank
	// g0, g<home>
	ActionStartOfScreenLine
	// g^
	ActionFirstNonBlankScreen
	// gm
	ActionMiddleOfScreenLine
	// gM
	ActionMiddleOfLine
	// g$
	ActionEndOfScreenLine
	// g<end>
	ActionLastNonBlankScreen

	// Word motions
	///////////////
	// w
	ActionWordForward
	// b
	ActionWordBackward
	// e
	ActionWordEndForward
	// ge
	ActionWordEndBackward
	// W
	ActionBigWordForward
	// B
	ActionBigWordBackward
	// E
	ActionBigWordEndForward
	// gE
	ActionBigWordEndBackward
)

type CopyEvent

type CopyEvent struct {
	Text string
}

type Mode

type Mode uint8
const (
	// The default mode, Time, allows the user to navigate in time
	ModeTime Mode = iota
	// Copy mode occurs when the user moves the cursor or scrolls the
	// window
	ModeCopy
	// Input mode is used for searching
	ModeInput
)

type Option

type Option func(r *Replay)

func WithLocation

func WithLocation(location geom.Vec2) Option

WithLocation attempts to move the cursor to `location`, which is a point in the reference frame of the Movement.

type PlaybackEvent

type PlaybackEvent struct {
	Since time.Time
}

type PlaybackRateEvent

type PlaybackRateEvent struct {
	Rate int
}

type ProgressEvent

type ProgressEvent struct {
	Percent int
}

type Replay

type Replay struct {
	*player.Player
	// contains filtered or unexported fields
}

func (*Replay) Init

func (r *Replay) Init() tea.Cmd

func (*Replay) Update

func (r *Replay) Update(msg tea.Msg) (taro.Model, tea.Cmd)

func (*Replay) View

func (r *Replay) View(state *tty.State)

type Replayable

type Replayable struct {
	util.Lifetime
	deadlock.RWMutex
	*mux.UpdatePublisher
	// contains filtered or unexported fields
}

func NewReplayable

func NewReplayable(
	ctx context.Context,
	cmd, stream mux.Stream,
	timeBinds, copyBinds *bind.BindScope,
) *Replayable

func (*Replayable) Cmd

func (r *Replayable) Cmd() mux.Stream

TODO(cfoust): 04/07/24 This is a dirty hack specifically for (cmd/path).

func (*Replayable) Commands

func (r *Replayable) Commands() []detect.Command

func (*Replayable) EnterReplay

func (r *Replayable) EnterReplay(options ...Option)

func (*Replayable) Kill added in v0.2.0

func (r *Replayable) Kill()

func (*Replayable) Preview

func (r *Replayable) Preview(
	location geom.Vec2,
	highlights []movement.Highlight,
) *tty.State

func (*Replayable) Resize

func (r *Replayable) Resize(size geom.Size) error

func (*Replayable) Screen

func (r *Replayable) Screen() mux.Screen

func (*Replayable) Send

func (r *Replayable) Send(msg mux.Msg)

func (*Replayable) State

func (r *Replayable) State() *tty.State

func (*Replayable) Stream

func (r *Replayable) Stream() mux.Stream

type SearchResultEvent

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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