Documentation
¶
Index ¶
- Constants
- Variables
- func New(ctx context.Context, player *player.Player, ...) *taro.Program
- func WithCopyMode(r *Replay)
- func WithFlow(r *Replay)
- func WithNoQuit(r *Replay)
- type ActionEvent
- type ActionType
- type ApplyOptionsEvent
- type CopyEvent
- type Mode
- type Option
- func WithBorgFlush(flush func(context.Context) error) Option
- func WithBorgPath(path string) Option
- func WithHighlights(highlights []movement.Highlight) Option
- func WithLocation(location geom.Vec2) Option
- func WithParams(params *params.Parameters) Option
- func WithResults(results []search.SearchResult) Option
- func WithSnapshot(state *tty.State) Option
- type PlaybackRateEvent
- type ProgressEvent
- type Replay
- type SearchResultEvent
Constants ¶
const ( PLAYBACK_FPS = 30 PLAYBACK_TIME_STEP = time.Second / PLAYBACK_FPS IDLE_THRESHOLD = time.Second )
const ( // SEEK_THRESHOLD is the amount of time that must pass before we show // the progress of a seek. SEEK_THRESHOLD = 120 * time.Millisecond )
Variables ¶
var Incremental stories.InitFunc = func(ctx context.Context) (mux.Screen, error) { _, run := createStory( ctx, createIncrementalSession(), ActionCursorUp, ActionBeginning, ActionSearchForward, ) return run(), nil }
var IncrementalBackward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) { _, run := createStory( ctx, createIncrementalSession(), ActionCursorUp, ActionBeginning, ActionSearchBackward, "century", ) return run(), nil }
var IncrementalForward stories.InitFunc = func(ctx context.Context) (mux.Screen, error) { _, run := createStory( ctx, createIncrementalSession(), ActionCursorUp, ActionBeginning, ActionSearchForward, "century", ) return run(), nil }
var JumpBackward stories.InitFunc = createTrivialStory( ActionSearchBackward, "3m", )
var JumpForward stories.InitFunc = createTrivialStory( ActionSearchForward, "3m", )
var LongHistory stories.InitFunc = func(ctx context.Context) (mux.Screen, error) { sim := sessions.NewSimulator(). Defaults() for range 100 { sim.Add( "Finally, code is a cultural resource, not trivial and only instrumental, but bound up in social change, aesthetic projects, and the relationship of people to computers. Instead of being dismissed as cryptic and irrelevant to human concerns such as art and user experience, code should be valued as text with machine and human meanings, something produced and operating within culture.\n", ) } _, run := createStory(ctx, sim.Events()) return run(), nil }
var MOTIONS = map[ActionType]motion.Motion{ ActionStartOfLine: motion.StartOfLine, ActionFirstNonBlank: motion.FirstNonBlank, ActionEndOfLine: motion.EndOfLine, ActionLastNonBlank: motion.LastNonBlank, ActionStartOfScreenLine: motion.StartOfScreenLine, ActionFirstNonBlankScreen: motion.StartOfScreenLine, ActionMiddleOfScreenLine: motion.MiddleOfScreenLine, ActionMiddleOfLine: motion.MiddleOfLine, ActionEndOfScreenLine: motion.EndOfScreenLine, ActionLastNonBlankScreen: motion.StartOfScreenLine, }
var SearchEmpty = createTrivialStory( ActionBeginning, ActionSearchForward, "asdf", "enter", )
var SearchProgress stories.InitFunc = func(ctx context.Context) (mux.Screen, error) { r, run := createStory( ctx, createStorySession(), ActionSearchForward, "query", "enter", ) r.isWaiting = true r.progressPercent = 50 return run(), nil }
var SearchTimeBackward stories.InitFunc = createTrivialStory( ActionSearchBackward, "query", )
var SearchTimeForward stories.InitFunc = createTrivialStory( ActionSearchForward, "query", )
var Searching stories.InitFunc = createTrivialStory( ActionSearchForward, "query", "enter", )
var (
TIME_DELTA_REGEX = regexp.MustCompile(
`^((?P<days>\d+)d)?((?P<hours>\d+)h)?((?P<min>\d+)m)?((?P<sec>\d+)s)?$`,
)
)
Functions ¶
func WithCopyMode ¶
func WithCopyMode(r *Replay)
WithCopyMode puts Replay immediately into copy mode.
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 ApplyOptionsEvent ¶ added in v0.10.0
type ApplyOptionsEvent struct {
Options []Option
}
type Option ¶
type Option func(r *Replay)
func WithBorgFlush ¶ added in v1.10.0
WithBorgFlush sets a callback that is invoked before loading history from the .borg file. This is used to ensure any buffered writes are flushed to disk so the loader sees the latest output.
func WithBorgPath ¶ added in v1.10.0
WithBorgPath enables on-demand loading of replay history from a .borg file.
func WithHighlights ¶ added in v0.11.0
WithHighlights provides highlights to apply to the screen on creation.
func WithLocation ¶
WithLocation attempts to move the cursor to `location`, which is a point in the reference frame of the Movement.
func WithParams ¶ added in v0.12.0
func WithParams(params *params.Parameters) Option
WithParams provides parameters this Replay will use for rendering.
func WithResults ¶ added in v0.10.0
func WithResults(results []search.SearchResult) Option
WithResults provides existing search results to the Replay.
func WithSnapshot ¶ added in v1.10.0
WithSnapshot provides the state to show before history is loaded.
type PlaybackRateEvent ¶
type PlaybackRateEvent struct {
Rate int
}
type ProgressEvent ¶
type ProgressEvent struct {
Percent int
}
type SearchResultEvent ¶
type SearchResultEvent struct {
Forward bool
Origin search.Address
Results []search.SearchResult
// contains filtered or unexported fields
}