Documentation
¶
Index ¶
- Constants
- Variables
- func CellInModal(x, y, top, left, width, height int) bool
- func MatchEmoji(emoji, query string) bool
- func ModalCellSize(s string) (width, height int)
- func MouseToModalCoords(screenX, screenY, overlayLeft, overlayTop int) (relX, relY int)
- func OverlayView(bgView, modalView string, bgW, bgH, top, left int) string
- type Config
- type EmojiCanceledMsg
- type EmojiChangedMsg
- type EmojiChosenMsg
- type Focus
- type Model
- type Option
- type Palette
- type Placement
- type SwatchPicker
- func (s *SwatchPicker) Emoji() string
- func (s *SwatchPicker) Focused() bool
- func (s *SwatchPicker) Open() bool
- func (s *SwatchPicker) SetBounds(row, col, w, h int)
- func (s *SwatchPicker) SetEmoji(e string)
- func (s *SwatchPicker) SetFocused(f bool)
- func (s *SwatchPicker) SetPickerOptions(opts ...Option)
- func (s *SwatchPicker) SetZoneManager(zm *zone.Manager)
- func (s *SwatchPicker) Size() (width, height int)
- func (s *SwatchPicker) SwatchView() string
- func (s *SwatchPicker) Update(msg tea.Msg) (*SwatchPicker, tea.Cmd)
- func (s *SwatchPicker) ViewWithOverlay(mainView string, viewWidth, viewHeight int) string
- type TextInput
- func (t *TextInput) Blur()
- func (t *TextInput) Focus() tea.Cmd
- func (t *TextInput) Focused() bool
- func (t *TextInput) SetValue(s string)
- func (t *TextInput) SetWidth(w int)
- func (t TextInput) Update(msg tea.Msg) (TextInput, tea.Cmd)
- func (t *TextInput) Value() string
- func (t TextInput) View() string
- type Theme
Constants ¶
const ( // === Smileys & Emotion === EmojiGrinningFace = "😀" EmojiGrinningWithEyes = "😃" EmojiSmilingWithOpen = "😄" EmojiGrinningSquinting = "😆" EmojiSmilingSweat = "😅" EmojiTearsOfJoy = "😂" EmojiRollingOnFloor = "🤣" EmojiSmilingFace = "😊" EmojiAngelFace = "😇" EmojiSlightlySmiling = "🙂" EmojiUpsideDown = "🙃" EmojiWinkingFace = "😉" EmojiRelievedFace = "😌" EmojiHeartEyes = "😍" EmojiSmilingWithHearts = "🥰" EmojiKissingFace = "😘" EmojiThinkingFace = "🤔" EmojiShushingFace = "🤫" EmojiGrimacingFace = "😬" EmojiZippedMouth = "🤐" EmojiSweatFace = "😓" EmojiCryingFace = "😢" EmojiLoudlyCrying = "😭" EmojiAngryFace = "😠" EmojiRedAngryFace = "😡" EmojiExplodingHead = "🤯" EmojiHotFace = "🥵" EmojiColdFace = "🥶" EmojiSleepingFace = "😴" EmojiNerdFace = "🤓" EmojiCoolFace = "😎" EmojiPartyFace = "🥳" // === Hands & Gestures === EmojiWave = "👋" EmojiRaisedHand = "✋" EmojiVulcanSalute = "🖖" EmojiOkHand = "👌" EmojiCrossedFingers = "🤞" EmojiThumbsUp = "👍" EmojiThumbsDown = "👎" EmojiClappingHands = "👏" EmojiRaisedHands = "🙌" EmojiFoldedHands = "🙏" EmojiFlexedBiceps = "💪" // === Animals & Nature === EmojiCatFace = "🐱" EmojiCat = "🐈" EmojiDogFace = "🐶" EmojiDog = "🐕" EmojiFox = "🦊" EmojiLion = "🦁" EmojiTigerFace = "🐯" EmojiMonkeyFace = "🐵" EmojiCowFace = "🐮" EmojiPigFace = "🐷" EmojiFrog = "🐸" EmojiOctopus = "🐙" EmojiBee = "🐝" EmojiBug = "🐛" EmojiPenguin = "🐧" EmojiOwl = "🦉" EmojiTurtle = "🐢" EmojiSnake = "🐍" EmojiDolphin = "🐬" EmojiTree = "🌲" EmojiEvergreen = "🌲" EmojiDeciduousTree = "🌳" EmojiCactus = "🌵" EmojiMapleLeaf = "🍁" EmojiSun = "🌞" EmojiRainbow = "🌈" EmojiSnowman = "⛄" EmojiLightning = "⚡" EmojiFire = "🔥" EmojiWaterWave = "🌊" EmojiGlobe = "🌍" // === Food & Drink === EmojiGreenApple = "🍏" EmojiRedApple = "🍎" EmojiBanana = "🍌" EmojiWatermelon = "🍉" EmojiGrapes = "🍇" EmojiStrawberry = "🍓" EmojiPizza = "🍕" EmojiHamburger = "🍔" EmojiFrenchFries = "🍟" EmojiHotDog = "🌭" EmojiTaco = "🌮" EmojiPopcorn = "🍿" EmojiRiceBall = "🍙" EmojiSushi = "🍣" EmojiIceCream = "🍦" EmojiDoughnut = "🍩" EmojiCookie = "🍪" EmojiBirthdayCake = "🎂" EmojiCoffee = "☕" EmojiTea = "🍵" EmojiBeerMug = "🍺" EmojiWineGlass = "🍷" EmojiCocktail = "🍸" // === Status, UI & Shapes === EmojiCheckMarkButton = "✅" EmojiCrossMark = "❌" EmojiWarning = "🚨" EmojiInfo = "📢" EmojiRedCircle = "🔴" EmojiYellowCircle = "🟡" EmojiGreenCircle = "🟢" EmojiBlueCircle = "🔵" EmojiPurpleCircle = "🟣" EmojiBlackSquare = "⬛" EmojiWhiteSquare = "⬜" EmojiStopSign = "🛑" EmojiConstruction = "🚧" EmojiChequeredFlag = "🏁" EmojiTriangularFlag = "🚩" EmojiBell = "🔔" EmojiMutedBell = "🔕" EmojiMegaphone = "📣" EmojiHourglass = "⏳" EmojiHourglassEmpty = "⌛" EmojiSpeechBalloon = "💬" EmojiHeart = "💖" EmojiBrokenHeart = "💔" EmojiSparkles = "✨" EmojiCollision = "💥" EmojiRocket = "🚀" // === Objects & Tools === EmojiComputer = "💻" EmojiDesktop = "🖥️" EmojiFloppyDisk = "💾" EmojiCamera = "📷" EmojiFolder = "📁" EmojiOpenFolder = "📂" EmojiCalendar = "📅" EmojiBarChart = "📊" EmojiChartUp = "📈" EmojiChartDown = "📉" EmojiMemo = "📝" EmojiEnvelope = "📩" EmojiIncomingMail = "📨" EmojiPackage = "📦" EmojiGear = "🔧" EmojiWrench = "🔧" EmojiHammer = "🔨" EmojiToolbox = "🧰" EmojiKey = "🔑" EmojiLock = "🔒" EmojiUnlock = "🔓" EmojiPaperclip = "📎" EmojiLightBulb = "💡" EmojiMagnifyingGlass = "🔍" // === Navigation === EmojiArrowUp = "🔼" EmojiArrowDown = "🔽" EmojiArrowLeft = "👈" EmojiArrowRight = "👉" EmojiRefresh = "🔄" )
Emoji constants for standard, widely supported TUI-friendly emojis. Using constants helps developers reference emojis programmatically by name.
NOTE: To ensure pixel-perfect TUI borders and layout alignment, all emojis defined here are strictly curated to have a visual width of 2 columns. Emojis containing variation selectors (like \ufe0f, e.g., ⚠️ or 🌧️) are avoided because they cause rendering conflicts: standard libraries (Lip Gloss / uniseg) report them as 2 columns, but terminal emulators render them as 1 column.
const ( ZonePresets = "picker-presets" ZoneCategories = "picker-categories" ZoneGrid = "picker-grid" ZoneSearch = "picker-search" )
Variables ¶
var DefaultPalettes = []Palette{ { Name: "Smileys", Icon: EmojiGrinningFace, Emojis: []string{ EmojiGrinningFace, EmojiGrinningWithEyes, EmojiSmilingWithOpen, EmojiGrinningSquinting, EmojiSmilingSweat, EmojiTearsOfJoy, EmojiRollingOnFloor, EmojiSmilingFace, EmojiAngelFace, EmojiSlightlySmiling, EmojiUpsideDown, EmojiWinkingFace, EmojiRelievedFace, EmojiHeartEyes, EmojiSmilingWithHearts, EmojiKissingFace, EmojiThinkingFace, EmojiShushingFace, EmojiGrimacingFace, EmojiZippedMouth, EmojiSweatFace, EmojiCryingFace, EmojiLoudlyCrying, EmojiAngryFace, EmojiRedAngryFace, EmojiExplodingHead, EmojiHotFace, EmojiColdFace, EmojiSleepingFace, EmojiNerdFace, EmojiCoolFace, EmojiPartyFace, }, }, { Name: "Gestures", Icon: EmojiThumbsUp, Emojis: []string{ EmojiWave, EmojiRaisedHand, EmojiVulcanSalute, EmojiOkHand, EmojiCrossedFingers, EmojiThumbsUp, EmojiThumbsDown, EmojiClappingHands, EmojiRaisedHands, EmojiFoldedHands, EmojiFlexedBiceps, }, }, { Name: "Animals & Nature", Icon: EmojiCatFace, Emojis: []string{ EmojiCatFace, EmojiCat, EmojiDogFace, EmojiDog, EmojiFox, EmojiLion, EmojiTigerFace, EmojiMonkeyFace, EmojiCowFace, EmojiPigFace, EmojiFrog, EmojiOctopus, EmojiBee, EmojiBug, EmojiPenguin, EmojiOwl, EmojiTurtle, EmojiSnake, EmojiDolphin, EmojiTree, EmojiDeciduousTree, EmojiCactus, EmojiMapleLeaf, EmojiSun, EmojiRainbow, EmojiSnowman, EmojiLightning, EmojiFire, EmojiWaterWave, EmojiGlobe, }, }, { Name: "Food & Drink", Icon: EmojiCoffee, Emojis: []string{ EmojiGreenApple, EmojiRedApple, EmojiBanana, EmojiWatermelon, EmojiGrapes, EmojiStrawberry, EmojiPizza, EmojiHamburger, EmojiFrenchFries, EmojiHotDog, EmojiTaco, EmojiPopcorn, EmojiRiceBall, EmojiSushi, EmojiIceCream, EmojiDoughnut, EmojiCookie, EmojiBirthdayCake, EmojiCoffee, EmojiTea, EmojiBeerMug, EmojiWineGlass, EmojiCocktail, }, }, { Name: "Status & Shapes", Icon: EmojiGreenCircle, Emojis: []string{ EmojiRedCircle, EmojiYellowCircle, EmojiGreenCircle, EmojiBlueCircle, EmojiPurpleCircle, EmojiBlackSquare, EmojiWhiteSquare, EmojiStopSign, EmojiConstruction, EmojiChequeredFlag, EmojiTriangularFlag, EmojiBell, EmojiMutedBell, EmojiMegaphone, EmojiHourglass, EmojiHourglassEmpty, EmojiSpeechBalloon, EmojiHeart, EmojiBrokenHeart, EmojiSparkles, EmojiCollision, EmojiRocket, EmojiCheckMarkButton, EmojiCrossMark, EmojiWarning, EmojiInfo, }, }, { Name: "Symbols & Tools", Icon: EmojiGear, Emojis: []string{ EmojiGear, EmojiWrench, EmojiHammer, EmojiToolbox, EmojiKey, EmojiLock, EmojiUnlock, EmojiPackage, EmojiFolder, EmojiOpenFolder, EmojiCalendar, EmojiBarChart, EmojiChartUp, EmojiChartDown, EmojiMemo, EmojiEnvelope, EmojiIncomingMail, EmojiPaperclip, EmojiLightBulb, EmojiMagnifyingGlass, }, }, { Name: "Navigation", Icon: EmojiArrowRight, Emojis: []string{ EmojiArrowUp, EmojiArrowDown, EmojiArrowLeft, EmojiArrowRight, EmojiRefresh, }, }, }
DefaultPalettes is a list of curated TUI-safe emojis grouped by category.
var DefaultTheme = Theme{ FrameBorder: lipgloss.DoubleBorder(), FrameBorderColor: lipgloss.Color("93"), BorderFocusedColor: lipgloss.Color("255"), BorderUnfocusedColor: lipgloss.Color("240"), TitleStyle: lipgloss.NewStyle().Bold(true), HelpStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("241")), ActiveTabStyle: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("15")).Background(lipgloss.Color("57")), InactiveTabStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("246")), SelectedCellStyle: lipgloss.NewStyle().Background(lipgloss.Color("57")).Foreground(lipgloss.Color("255")).Bold(true), SelectedUnfocusedCellStyle: lipgloss.NewStyle().Background(lipgloss.Color("240")).Foreground(lipgloss.Color("255")), UnselectedCellStyle: lipgloss.NewStyle(), SelectedPresetStyle: lipgloss.NewStyle().Background(lipgloss.Color("238")).Foreground(lipgloss.Color("255")).Bold(true), UnselectedPresetStyle: lipgloss.NewStyle(), SearchPromptStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("93")), SearchTextStyle: lipgloss.NewStyle(), SearchPlaceholderStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("240")), SearchCursorStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("93")), }
DefaultTheme provides a dark, purple-accented modern theme.
var EmojiTags = map[string][]string{}/* 105 elements not displayed */
EmojiTags maps common emojis to searchable keywords.
Functions ¶
func CellInModal ¶
CellInModal returns true if the coordinate (x, y) falls inside the modal bounds.
func MatchEmoji ¶
MatchEmoji returns true if the emoji matches the query based on tags.
func ModalCellSize ¶
ModalCellSize calculates the cell-width and cell-height of the modal content string.
func MouseToModalCoords ¶
MouseToModalCoords converts screen coordinates to modal-relative coordinates.
func OverlayView ¶
OverlayView overlays the modalView content on top of the bgView at coordinates (top, left).
Types ¶
type Config ¶
type Config struct {
InitialEmoji string
Presets []string
Palettes []Palette
FrameStyle lipgloss.Style
CustomFrame bool
AutoDismiss bool
ShowSearch bool
Theme Theme
}
Config holds the configuration options for the emoji picker.
type EmojiCanceledMsg ¶
type EmojiCanceledMsg struct{}
EmojiCanceledMsg is emitted when the user cancels the picker (e.g. presses Esc).
type EmojiChangedMsg ¶
type EmojiChangedMsg struct {
Emoji string // The selected emoji
Dismiss bool // Whether the picker should be dismissed automatically
}
EmojiChangedMsg is emitted when the user confirms their emoji selection.
type EmojiChosenMsg ¶
type EmojiChosenMsg = EmojiChangedMsg
EmojiChosenMsg is an alias for EmojiChangedMsg for compatibility.
type Model ¶
type Model struct {
Palettes []Palette
Presets []string
ActiveTab int
GridCursorX int
GridCursorY int
PresetCursor int
Focus Focus
SearchInput TextInput
ShowSearch bool
AutoDismiss bool
Selected string
Width int
Height int
GridCols int
GridRows int
Theme Theme
// contains filtered or unexported fields
}
Model represents the emoji picker component state.
func (Model) SelectedEmoji ¶
SelectedEmoji returns the emoji under the grid cursor.
func (*Model) SetZoneManager ¶
SetZoneManager configures the zone manager for mouse hit testing.
type Option ¶
type Option func(*Config)
Option configures an emoji picker.
func WithAutoDismiss ¶
WithAutoDismiss sets whether the picker emits EmojiChangedMsg with Dismiss=true to let the host immediately close/dismiss the picker.
func WithInitialEmoji ¶
WithInitialEmoji sets the starting emoji selection.
func WithPalettes ¶
WithPalettes sets custom emoji palettes for the picker.
func WithPresets ¶
WithPresets configures a list of preset/recent emojis displayed at the top.
func WithShowSearch ¶
WithShowSearch toggles the search input bar.
type Palette ¶
type Palette struct {
Name string // Display name of the category (e.g. "Smileys")
Icon string // Single emoji representing the category tab
Emojis []string // Slice of emojis in this palette
}
Palette represents a category of emojis for the picker.
type Placement ¶
type Placement struct {
// contains filtered or unexported fields
}
Placement represents the position of the overlay.
func (Placement) ClampedOrigin ¶
ClampedOrigin returns topPad, leftPad centering/clamping the overlay on the background space.
type SwatchPicker ¶
type SwatchPicker struct {
// contains filtered or unexported fields
}
SwatchPicker represents a clickable UI element (emoji + arrow) that opens the emoji picker overlay modal when activated.
func NewSwatchPicker ¶
func NewSwatchPicker(initialEmoji, label string) *SwatchPicker
NewSwatchPicker returns a new SwatchPicker instance.
func (*SwatchPicker) Emoji ¶
func (s *SwatchPicker) Emoji() string
Emoji returns the active emoji value.
func (*SwatchPicker) Focused ¶
func (s *SwatchPicker) Focused() bool
Focused returns whether the swatch is currently focused.
func (*SwatchPicker) Open ¶
func (s *SwatchPicker) Open() bool
Open returns whether the modal is currently displayed.
func (*SwatchPicker) SetBounds ¶
func (s *SwatchPicker) SetBounds(row, col, w, h int)
SetBounds sets where the swatch is positioned in terminal cells.
func (*SwatchPicker) SetEmoji ¶
func (s *SwatchPicker) SetEmoji(e string)
SetEmoji sets the active emoji value.
func (*SwatchPicker) SetFocused ¶
func (s *SwatchPicker) SetFocused(f bool)
SetFocused toggles highlight focus status.
func (*SwatchPicker) SetPickerOptions ¶
func (s *SwatchPicker) SetPickerOptions(opts ...Option)
SetPickerOptions configures options that are passed to the EmojiPicker model when it opens.
func (*SwatchPicker) SetZoneManager ¶
func (s *SwatchPicker) SetZoneManager(zm *zone.Manager)
SetZoneManager configures the bubblezone manager.
func (*SwatchPicker) Size ¶
func (s *SwatchPicker) Size() (width, height int)
Size returns the display size of the swatch (width, height in cells).
func (*SwatchPicker) SwatchView ¶
func (s *SwatchPicker) SwatchView() string
SwatchView renders the swatch preview (emoji + down arrow symbol).
func (*SwatchPicker) Update ¶
func (s *SwatchPicker) Update(msg tea.Msg) (*SwatchPicker, tea.Cmd)
Update forwards tea.Msg events to the swatch picker.
func (*SwatchPicker) ViewWithOverlay ¶
func (s *SwatchPicker) ViewWithOverlay(mainView string, viewWidth, viewHeight int) string
ViewWithOverlay renders the overlay modal on top of mainView when the picker is open.
type TextInput ¶
type TextInput struct {
Placeholder string
Prompt string
PromptStyle lipgloss.Style
TextStyle lipgloss.Style
PlaceholderStyle lipgloss.Style
CursorStyle lipgloss.Style
// contains filtered or unexported fields
}
TextInput is a lightweight, zero-dependency text input component for Go and Bubble Tea. It avoids importing external clipboard packages to keep compilation lightweight and CG0-free.
func (TextInput) Update ¶
Update handles keyboard messages to mutate the text input value and cursor.
type Theme ¶
type Theme struct {
// Outer frame styling
FrameBorder lipgloss.Border
FrameBorderColor color.Color
// Inner focus borders
BorderFocusedColor color.Color
BorderUnfocusedColor color.Color
// Text styling
TitleStyle lipgloss.Style
HelpStyle lipgloss.Style
// Tabs/Categories styling
ActiveTabStyle lipgloss.Style
InactiveTabStyle lipgloss.Style
// Emoji grid cell styling
SelectedCellStyle lipgloss.Style
SelectedUnfocusedCellStyle lipgloss.Style
UnselectedCellStyle lipgloss.Style
// Preset cell styling
SelectedPresetStyle lipgloss.Style
UnselectedPresetStyle lipgloss.Style
// Search text input styling
SearchPromptStyle lipgloss.Style
SearchTextStyle lipgloss.Style
SearchPlaceholderStyle lipgloss.Style
SearchCursorStyle lipgloss.Style
}
Theme defines the visual styles for the emoji picker.