mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #321] Colorized input field #245
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#245
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @antonmedv on GitHub (Jul 4, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/321
Hi,
How to colorize user’s input while user typing in input field?
Thanks for awesome library. I think it’s really gold :)
@rivo commented on GitHub (Jul 10, 2019):
Yeah, I don't think this is possible at the moment and it would be quite difficult to implement, I think. (Is this even possible in HTML's
<input>tag? I've never seen anything like this.)@antonmedv commented on GitHub (Jul 10, 2019):
This is kinda possible in html in ace or codemirror editor. Also for example in micro terminal editor it's possible to type code with highlighting. I was wondering if it possible in tview as well. I'd like to implement terminal calculator where input is colorized as users types and expression. For example,
1+2there are 1 and 2 have a blue colour.@rivo commented on GitHub (Jul 10, 2019):
I'm sure in HTML, one could imitate an input field by handling keyboard/mouse input and outputting a whole bunch of tags which make it look like the input field can display colourized text. But I don't know of a way to make the native
<input>tag do the same. To my knowledge, it simply displays thevalueattribute which cannot contain any HTML tags itself.Correspondingly, you can make a more complex input field yourself. Check out this Wiki page for pointers. You could use
Application.SetAfterDrawFunc()to "post-process" screen output, i.e. colourize your numbers. To find out where the numbers are located on screen, you could useInputField.SetDrawFunc(). It's not exactly pretty but I think you could make it work that way.Let me know if this helps.