wall_street

package module
v0.0.0-...-2bd9f79 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2014 License: MIT Imports: 8 Imported by: 0

README

wall_street

Build Status An implementation of libreadline in Go

wolf

Usage

package whatever

import (
  "github.com/tjarratt/wall_street"
)

func main() {
  input := wall_street.ReadLine("Are you a god?")
  if input == "yes" {
    println("oh okay. carry on then.")
  } else {
    println("then you shall die")
  }

  return
}

What's the deal with the name?

While building a CLI for my day job, I came to the realization that Go really needed a kickass implementation of readline in pure Go (without using CG0). This of course meant that I needed to think of a really kickass name. Just calling the package "readline" or "go-readline" would have been admitting defeat. We don't need anymore packages with "Go" in the name, and just naming something after its inspiration is boring.

So I thought for a bit and waited a few days. In a fever dream, I got to playing with words and thought that "read line" sounds a bit like "greed line". It's a small conceptual leap from "greed line" to "wall street". Well, it's a small leap when your brain is getting fried, at least.

Documentation

Index

Constants

View Source
const (
	Up    string = "^[A"
	Down  string = "^[B"
	Right string = "^[C"
	Left  string = "^[D"
)

Variables

This section is empty.

Functions

func AddHistory

func AddHistory(input string)

func HistoryGetTime

func HistoryGetTime(history *HistEntry) time.Time

func RemoveHistory

func RemoveHistory(which int)

Remove history element WHICH from the history

func ReplaceHistoryData

func ReplaceHistoryData(which int, oldData, newData interface{}) (err error)
Replace the DATA in the specified history entries, replacing OLD with
  NEW.  WHICH says which one(s) to replace:  WHICH == -1 means to replace
  all of the history entries where entry->data == OLD; WHICH == -2 means
  to replace the `newest' history entry where entry->data == OLD; and
  WHICH >= 0 means to replace that particular history entry's data, as

long as it matches OLD. nb: `which` offset is now relative to current history **BREAKING CHANGE**

func ReplaceHistoryEntry

func ReplaceHistoryEntry(which int, line string, data interface{}) (err error)
Make the history entry at WHICH have LINE and DATA.

nb: `which` offset is now relative to current history **BREAKING CHANGE**

func ResetHistory

func ResetHistory()

addition: just resets the world for test purposes

Types

type FunMap

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

data structure for mapping textual names to code addresses

type HistEntry

type HistEntry struct {
	Line      string
	Timestamp int64
	Data      interface{} // histdata_t #ifdef to void* or char*
}

func CurrentHistory

func CurrentHistory() *HistEntry

func HistoryGet

func HistoryGet(offset int) *HistEntry

Return the history entry which is logically at OFFSET in the history array.

OFFSET is relative to history_base.

func HistoryList

func HistoryList() (history []*HistEntry)

Return the current history array. The caller has to be careful, since this

is the actual array of data, and could be bashed or made corrupt easily.
The array is terminated with a NULL pointer.

func NextHistory

func NextHistory() *HistEntry

Move history_offset forward to the next history entry, and return

a pointer to that entry.  If there is no next entry then return a
nil pointer.

func PreviousHistory

func PreviousHistory() *HistEntry

Back up history_offset to the previous history entry, and return

a pointer to that entry.  If there is no previous entry then return
a NULL pointer.

type ReadlineReader

type ReadlineReader struct {
	Echo echo.Echoer

	MaskUserInput bool
	MaskChar      string
	// contains filtered or unexported fields
}

func NewReadline

func NewReadline() *ReadlineReader

func (*ReadlineReader) DisableEcho

func (rl *ReadlineReader) DisableEcho()

func (*ReadlineReader) DisablePrompt

func (rl *ReadlineReader) DisablePrompt()

func (*ReadlineReader) EnableEcho

func (rl *ReadlineReader) EnableEcho()

func (*ReadlineReader) EnablePrompt

func (rl *ReadlineReader) EnablePrompt()

func (*ReadlineReader) Readline

func (rl *ReadlineReader) Readline(prompt string) (value string)

func (*ReadlineReader) SetReadPipe

func (rl *ReadlineReader) SetReadPipe(r io.Reader)

func (*ReadlineReader) SetWritePipe

func (rl *ReadlineReader) SetWritePipe(w io.Writer)

type UndoEnum

type UndoEnum int

enums.go

type UndoList

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

Directories

Path Synopsis
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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