Open sapessi opened 7 years ago
@SAPessi does this work? Then I'll use your fork as the dep unless this is merged :D
@meetmangukiya It does work, although I have tested all of the use-cases. Have a go and see if it works for you. If you find an issue let me know.
Ok, I'll have a go at it
@meetmangukiya Did this work for you?
hi,body,I have tried this method.but when I input the Chinese words,it will be in the wrong sequence.
@liushuchun Do you expect it to be right to left or also vertical? This is definitely something that can be added.
@SAPessi Great stuff. Would love to see this merged. What is blocking it?
@SAPessi Thanks for the PR. If found a little bug within your PR, this the code I've tested:
input := ui.NewInput("FOO BAR", false)
input.StartCapture()
On startup just press backspace when the courser is on the first position. Which results in such a panic:
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/gizak/termui.(*Input).backspace(0xc4200fa000)
/root/dev/go/src/github.com/gizak/termui/input.go:179 +0x2c7
github.com/gizak/termui.(*Input).StartCapture.func1(0x52f564, 0x8, 0xc4202e8bc4, 0xc, 0x52f2e8, 0x7, 0x0, 0x0, 0x50ca40, 0xc4202e8bd0, ...)
/root/dev/go/src/github.com/gizak/termui/input.go:115 +0x5a1
github.com/gizak/termui.(*EvtStream).Loop.func1(0xc420046500, 0x52f564, 0x8, 0xc4202e8bc4, 0xc, 0x52f2e8, 0x7, 0x0, 0x0, 0x50ca40, ...)
/root/dev/go/src/github.com/gizak/termui/events.go:251 +0xff
github.com/gizak/termui.(*EvtStream).Loop(0xc420046500)
/root/dev/go/src/github.com/gizak/termui/events.go:253 +0x157
github.com/gizak/termui.Loop()
/root/dev/go/src/github.com/gizak/termui/events.go:282 +0x2d
main.main()
...
If no string has been passed to the constructor everything works fine. I'm not sure if I did something wrong with the initialisation.
Edit: This happens also if an empty string has been passed and the first key pressed is a backspace.
Edit 2: If the arrow keys are pressed first also a out of bound error raises, in line 311 or 125 depending on the key pressed.
@Griesbacher could be a bug, I'll look into it this weekend.
@Griesbacher fixed those issues and added unit tests for them in the latest commit.
what's preventing this to be merged? can we get this one going into master?
@gizak Should we close this pull request now that you've imported the input in a commit?
@SAPessi which commit?
Never mind, I confused the pull to another repo for this. @gizak, any idea whether this will be merged?
Any chances this could get merged? I think an input control would be really handy and I would love to use something already pre-existing. I don’t think it’s useful everyone implements a from scratch input control every time.
@kellabyte I'm currently finishing up rewriting termui but once I'm done with that I'll merge this and the other PRs too.
Hello @cjbassi and @gizak ,
I am wondering if the rewrite is included in version v3.0.0 released a week ago?
I am using termui and now need to implement some sort of input form. Is this pull request still planned to be included at some point?
I tried creating a local copy of input.go
submitted in the pull request but it seems the code is not compatible anymore with version 3.
@andre-l-mm
The rewrite is included in v3.0.0.
So this PR is incompatible with the recent changes, so I've been working on rewriting it. You can check out the progress at the wip/input-widget
branch. It's mostly functional, and it may work for you, but I still need to:
The widget is called TextBox
, and it's going to supersede the Paragraph
widget. I've added a few examples for it in the _examples/textbox.go
file. All of the event handling is done client side vs library side since we don't have support for focusable widgets yet.
Feel free to create PR's against that branch if you end up using it.
Thanks @cjbassi, I will try the code on wip/input-widget
branch today.
Hi @cjbassi , I started using the textbox widget and it looks cool. I was not able to find a method to retrieve back the text inputted and I am thinking of submitting a pull request adding a GetText() function. Does that make sense to you? For completion I am actually thinking of two functions:
GetText()
: Converts text [][]Cell
to a string representation including all the formatting tagsGetRawText()
: Converts text [][]Cell
to a string representation without any formatting tags. @andre-l-mm Both of those sound good!
Hello,
Have you an idea when this will be released ? :D
Regards
God has left us.
Still missing lots of unit tests :( I'll keep working on them