Documentation
¶
Overview ¶
Package emailinput is a thin wrapper over textinput.Model that rejects whitespace runes as typed input. Everything else (navigation, deletion, paste, focus, styling, View) behaves exactly like textinput.Model. It also exposes a lightweight Valid heuristic for whether the current value looks like an email address.
Example ¶
An emailinput is a textinput that rejects whitespace as typed input and can say whether its value looks like an address.
package main
import (
"fmt"
"github.com/ows4444/tui"
"github.com/ows4444/tui/emailinput"
)
func main() {
m := emailinput.New()
m.Focus()
for _, r := range "a b@c.io" {
m, _ = m.Update(tui.Key{Type: tui.KeyRunes, Text: string([]rune{r})})
}
fmt.Println(m.Value(), m.Valid())
}
Output: ab@c.io true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
Model wraps a textinput.Model, filtering the runes it accepts. Its promoted Mouse and Bounds fields turn on click-to-place-cursor and drag-select exactly as on textinput.Model.
func (Model) LayoutNode ¶
LayoutNode adapts the field to a layout.Node. It is the embedded textinput.Model's node (natural size on one row, exact size on Render); the wrapper filters typed runes only, so View and layout are unchanged.
func (Model) Linearize ¶
Linearize is the embedded textinput's line with the field named "email field". The value is spoken, as an email address is not a secret.
func (Model) SetTheme ¶
SetTheme returns m with t applied to the embedded textinput.Model. It is defined here so it returns this package's Model; the promoted textinput.Model.SetTheme would return the embedded type and drop the wrapper's filtering.
func (Model) Tokens ¶
Tokens returns the embedded textinput's colour overrides, as set by WithTokens. The widget shares theme.ComponentTextInput with textinput.
func (Model) Update ¶
Update intercepts tui.KeyRunes to reject any whitespace rune (space, tab, and everything else unicode.IsSpace reports) so it can never be inserted into the value (criterion #514). Every other key or Msg (navigation, deletion, paste, blink ticks, ...) is forwarded unchanged to the embedded textinput.Model.