Documentation ¶
Index ¶
- Variables
- func AllowedEntry(te termbox.Event) bool
- func Cells() [][]Cell
- func Close()
- func CurrentHz(currentSecs int) float64
- func Debug(s string)
- func DeselectAllInputs()
- func DrawAll()
- func Fill(x, y, w, h int, r rune)
- func FormatTimer(seconds int) string
- func Init(version string) error
- func RecordedKeyText(key rune, seconds int) string
- func ReloadInputs(c Config)
- func ResetText()
- func ResetTimer()
- func Scan(startX, endX, y int) string
- func Text(x, y int, s string) (maxX, maxY int)
- func UpdateConfig(c Config)
- func UpdateText(text string)
- func UpdateTimer(seconds int)
- type Capture
- type Cell
- type Config
- func (c Config) BaseHzS() string
- func (c Config) EndHzS() string
- func (c *Config) Load() error
- func (c Config) ModeS() string
- func (c Config) OffsetS() string
- func (c Config) Save() error
- func (c Config) StartHzS() string
- func (c Config) TotalTimeS() string
- func (c *Config) Update(m map[string]interface{}) error
- func (c Config) Validate() error
- type ConfigField
- type Entry
- type Input
- func (in *Input) ClearBuf()
- func (in Input) ClearText()
- func (in Input) Draw()
- func (in Input) MaxX() int
- func (in Input) MaxY() int
- func (in Input) ResetText()
- func (in Input) Selected() bool
- func (in *Input) SetBuf(e *Entry)
- func (in *Input) SetSelected(selected bool)
- func (in Input) SetText(s string)
- func (in *Input) Switch() error
- func (in Input) TextEndX() int
- func (in Input) TextStartX() int
- func (in Input) TextY() int
- func (in *Input) Valid() error
- func (in *Input) ValueMap() (map[string]interface{}, error)
- type InputType
- type KeyLabel
- type StatusBar
Constants ¶
This section is empty.
Variables ¶
var Labels = map[rune]string{
'a': "Visual imagination",
'd': "Language thought",
'e': "Language voice",
'q': "Visual memory",
's': "Auditory imagination",
'w': "Auditory memory",
}
Labels is a map of each allowed key press (rune) to it's full string label.
var (
// Version holds the program version.
Version = "devel"
)
Functions ¶
func AllowedEntry ¶
func AllowedEntry(te termbox.Event) bool
AllowedEntry returns true if the termbox event received is a valid entry for the input. These include 0-9, '.', delete, backspaces and enter.
func Cells ¶
func Cells() [][]Cell
Cells initializes all cells on screen and registers the inputs on the cells that should have them.
func Close ¶
func Close()
Close should be deferred after initialization. It finalizes termbox library.
func CurrentHz ¶
CurrentHz given the seconds passed, it returns the current Gz based on the formula: CurrentHz = ( Seconds * Abs((EndHz - StartHz)) / ((TotalTime - Offset) * 60) ) + StartHz for Offset < TotalTime
func CurrentHz(seconds int) float64 { offset := config.Offset if offset >= config.TotalTime { offset = 0 } return (float64(seconds) * (math.Abs(config.EndHz - config.StartHz)) / float64((config.TotalTime-offset)*60)) + config.StartHz }
func DeselectAllInputs ¶
func DeselectAllInputs()
DeselectAllInputs sets all inputs selected as false.
func DrawAll ¶
func DrawAll()
DrawAll draws the title, the inputs, the key labels and the status bar. It should also be called when a resize event is received.
func Fill ¶
Fill fills cells of the screen with a rune r, starting from x, y and reaching a certain width w and height h.
func FormatTimer ¶
FormatTimer accepts seconds and returns them in a timer format.
func Init ¶
Init must be called before any other function. It initializes configuration and termbox.
func RecordedKeyText ¶
RecordedKeyText returns a message indicating the key pressed, it's hz value and a timestamp of when it was received.
func ReloadInputs ¶
func ReloadInputs(c Config)
ReloadInputs updates each input with the values of a new configuration. It should be called after receiving a valid value from en enabled input.
func Scan ¶
Scan scans the cells of the screen that are contained at a certain y, between startX and endX. It returns the content of the scanned cells as a string.
func Text ¶
Text draws text on the screen. When it encounters a new line it continues to draw from the next line.
func UpdateText ¶
func UpdateText(text string)
UpdateText is a helper function that updates the status bar's text.
func UpdateTimer ¶
func UpdateTimer(seconds int)
UpdateTimer is a helper function that updates the status bar's timer.
Types ¶
type Capture ¶
Capture represents a captured key press at a specific second of the timer along with the value of Hz that was recorded.
type Cell ¶
type Cell struct { Input *Input termbox.Cell }
Cell wraps a termbox cell. A single conceptual entity on the screen. A screen considered a 2d array of cells. Each cell also holds a reference to an input if it exists, thus by clicking a cell that contains an input we can easily access it.
type Config ¶
type Config struct { Mode string // A = Binaural, B = Isochronic TotalTime int Offset int BaseHz float64 StartHz float64 EndHz float64 }
Config represents the program's configuration.
func (Config) TotalTimeS ¶
TotalTimeS returns a string representation of the total time.
type ConfigField ¶
type ConfigField string
ConfigField is a key of each configuration value. Each input holds a configuration field so it's easier to update the config.
func (ConfigField) Val ¶
func (cf ConfigField) Val() string
Val returns the configuration field's value.
type Entry ¶
Entry represents a key entry that an input accpets. These include a character, backspace, delete and enter.
type Input ¶
type Input struct {
X, Y int
LabelW int // label width
LabelT string // label text
W int // width
T string // text
Type InputType
Field ConfigField
// contains filtered or unexported fields
}
Input represents an input box on the screen.
func NewInput ¶
func NewInput(x, y, labelW int, labelT string, w, bufW int, t string, a bool, it InputType, cf ConfigField) *Input
NewInput returns a new Input.
func SelectedInput ¶
func SelectedInput() *Input
SelectedInput returns the input that is currently selected.
func (Input) ResetText ¶
func (in Input) ResetText()
ResetText clears the input's text and then resets it to it's original value.
func (*Input) SetSelected ¶
SetSelected sets the input as selected after deselecting all other inputs.
func (Input) TextStartX ¶
TextStartX returns the x where the input's text starts.
type InputType ¶
type InputType uint8
InputType is the type of each input which can be either an input that accepts integers, an input that accepts float or an input that switches value on click.
type KeyLabel ¶
type KeyLabel struct { X int Y int LabelW int // label width LabelT string // label text W int // rest of width T string // text describing the key S bool // contains filtered or unexported fields }
KeyLabel holds a label with each allowed key press and right next, the coresponding text that describes the label.
func NewKeyLabel ¶
NewKeyLabel creates a new KeyLabel.
type StatusBar ¶
type StatusBar struct { X int Y int Width int Text string // contains filtered or unexported fields }
StatusBar holds the data for drawing a status bar with a specified width and text. It also has space to the left for the timer.
func NewStatusBar ¶
NewStatusBar returns a new StatusBar.
func (StatusBar) UpdateText ¶
UpdateText updates the text of the status bar.
func (StatusBar) UpdateTimer ¶
UpdateTimer updates the timer of the status bar by a specified amount of seconds.