scroll

package
v0.0.0-...-6737c8c Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Pacakge scroll contains some utilities for processing and displaying manageable chunks of an io.Reader. This was originally developed as a way to scan large text files without thrashing memory or requiring a user to hold down a key while scanning output.

The speed of the output is variable to allow for varying skill or use cases and either a hex+text representation similar to hexdump, or a simple text output are currently available depending on need.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HexScroller

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

HexScroller implements Runner and outputs the hex representation of input from r in w columns of 8 bytes each, along with the string representation similar to the output of hexdump.

func NewHexScroller

func NewHexScroller(r io.Reader, w int) HexScroller

NewHexScroller returns an implementation of Runner that outputs the hex representation of input from r in w columns of 8 bytes each, along with the string representation similar to the output of hexdump.

func (HexScroller) Run

func (s HexScroller) Run()

Run implements Runner and reads the bytes of the input in 8*width sized chunks, displaying them cleanly alongside their string representation.

type Runner

type Runner interface {
	Run()
}

Runner describes an interface consisting of a single Run method. Implementations of Runner are expected to process a single "line" of input for each call to Run. At the moment, it is acceptable to exit from within Run, though this is likely to change.

type Scroller

type Scroller struct {
	Runner
}

Scroller manages the event loop for processing input using a Runner. It listens for key events to pause or exit the program, and calls Runner on the user-specified schedule.

func NewScroller

func NewScroller(sr Runner) Scroller

NewScroller returns a Scroller that uses the provided Runner to process input.

func (Scroller) Start

func (s Scroller) Start(speed time.Duration)

Start runs two goroutines in parallel. The first waits for keyboard input to either pause or exist the program. The second runs the primary processing loop which calls the underlying Runner's Run method with the provided frequency.

type TextScroller

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

TextScroller implements Runner and simply outputs the lines of the input reader as text.

func NewTextScroller

func NewTextScroller(r io.Reader) TextScroller

NewTextScroller returns an implementation of Runner that simply outputs the lines of the input reader as text.

func (TextScroller) Run

func (s TextScroller) Run()

Run implements Runner and simply scans successive lines of text and outputs them unmodified to stdout.

Jump to

Keyboard shortcuts

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