Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

styled placeholders #517

Open
simonasGit opened this issue May 1, 2024 · 2 comments
Open

styled placeholders #517

simonasGit opened this issue May 1, 2024 · 2 comments

Comments

@simonasGit
Copy link

m.input.SetValue(lipgloss.NewStyle().
Background(lipgloss.Color("#00ff00")).
Render("hah"))

image
Instead of using textinput.Model.TextStyle to style the whole text, one may want to only style certain words for example.

I think it might be in styleText because escape sequences are being applied to a lipgloss styled string.

  • OS [Arch]
  • Shell [zsh, fish]
  • Terminal Emulator [Alacritty]
@meowgorithm meowgorithm changed the title textinput doesn't render styling correctly styled placeholders May 1, 2024
@meowgorithm
Copy link
Member

Thanks for the issue! So as a baseline, we should definitely strip ansi from placeholders. Then the question becomes: should we allow placeholders to be styled as well? I think so.

@simonasGit
Copy link
Author

simonasGit commented May 4, 2024

Yeah I guess if PlaceholderStyle and TextStyle are deprecated, if one wants a style for the whole string - m.ti.Placeholder = style.Render(text) or

func (m model) View() string {
	v := style.Render(m.ti.Value())
        m.ti.SetValue(v)
	return m.ti.View()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants