nuts

package module
v0.0.0-...-52724f9 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2018 License: BSD-3-Clause Imports: 2 Imported by: 0

README

Oh Nuts

these aren't the seeds you're looking for

peanut

An experimental with fruits and seeds.

Documentation

Overview

text.go implements a text structure and function for building a text editor functionality independent of UI.

Index

Constants

View Source
const (
	// Plain describes a text/plain document
	Plain = iota
	// FDX a Final Draft XML document
	FDX
	// Markdown document
	Markdown
	// Fountain document
	Fountain
)
View Source
const Version = `v0.0.1-dev`

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	// Source holds the text in a byte slice
	Source []byte
	// Cursor holds the location of where to start reading or writing
	Cursor int
}

Block is a structure for holding text content you want to process. The goal is to have a foundation for making stream processors, analyzers and editors easily.

A Block structure should play nicely with any Reader, Writer and Seeker interfaces

func (*Block) Read

func (b *Block) Read(p []byte) (int, error)

Read copies b.Source into byte slice p up to the size of p

func (*Block) ReadAt

func (b *Block) ReadAt(p []byte, offset int) (int, error)

ReadAt implements the io.ReadAt interface for Block

func (*Block) Seek

func (b *Block) Seek(offset int, whence int) (int, error)

Seek implements the io.Seeker interface for Block

func (*Block) Write

func (b *Block) Write(p []byte) (int, error)

Write copies the content of p and appends it to b.Source

func (*Block) WriteAt

func (b *Block) WriteAt(p []byte, offset int) (int, error)

WriteAt implements the io.WriteAt interface for Block

type Document

type Document struct {
	// Name holds a human friendly name as a label
	Name string
	// Type is an integer value representing one of the text types supported (e.g. TextPlain).
	Type int
	// Meta is a map to any additional data associated with the text, e.g. File Info, DOI content, etc.
	Meta map[string]interface{}
	// Cursor holds the document level cursor (byte count into document)
	Cursor int
	// Source holds an ordered list of Block pointers
	Source []*Block
}

type Formatter

type Formatter interface {
	String() string
	Parse([]byte) (*Block, error)
	Render(io.Writer, *Block) error
}

Formatter is an interface that can return a string reprentation and a byte array representation of one or more blocks

Directories

Path Synopsis
cmd
cashew command
peanut command
peanut - an experiment in tui (Text User Interface) fruits and seeds
peanut - an experiment in tui (Text User Interface) fruits and seeds

Jump to

Keyboard shortcuts

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