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

New input element #129

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

New input element #129

wants to merge 6 commits into from

Conversation

sapessi
Copy link

@sapessi sapessi commented Mar 7, 2017

Still missing lots of unit tests :( I'll keep working on them

@meetmangukiya
Copy link

@sapessi does this work? Then I'll use your fork as the dep unless this is merged :D

@sapessi
Copy link
Author

sapessi commented Apr 28, 2017

@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.

@meetmangukiya
Copy link

Ok, I'll have a go at it

@sapessi
Copy link
Author

sapessi commented May 5, 2017

@meetmangukiya Did this work for you?

@liushuchun
Copy link

liushuchun commented May 8, 2017

hi,body,I have tried this method.but when I input the Chinese words,it will be in the wrong sequence.
image

@sapessi
Copy link
Author

sapessi commented May 8, 2017

@liushuchun Do you expect it to be right to left or also vertical? This is definitely something that can be added.

@pradeepto
Copy link

@sapessi Great stuff. Would love to see this merged. What is blocking it?

@Griesbacher
Copy link

Griesbacher commented Jul 14, 2017

@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.

@sapessi
Copy link
Author

sapessi commented Jul 14, 2017

@Griesbacher could be a bug, I'll look into it this weekend.

@sapessi
Copy link
Author

sapessi commented Jul 18, 2017

@Griesbacher fixed those issues and added unit tests for them in the latest commit.

@stephencheng
Copy link

what's preventing this to be merged? can we get this one going into master?

stephencheng added a commit to stephencheng/termui that referenced this pull request Dec 14, 2017
@sapessi
Copy link
Author

sapessi commented Dec 18, 2017

@gizak Should we close this pull request now that you've imported the input in a commit?

@pjebs
Copy link

pjebs commented Jan 2, 2018

@sapessi which commit?

@sapessi
Copy link
Author

sapessi commented Jan 9, 2018

Never mind, I confused the pull to another repo for this. @gizak, any idea whether this will be merged?

@kellabyte
Copy link

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.

@cjbassi
Copy link
Contributor

cjbassi commented Jan 3, 2019

@kellabyte I'm currently finishing up rewriting termui but once I'm done with that I'll merge this and the other PRs too.

@cjbassi cjbassi force-pushed the master branch 5 times, most recently from 16a8706 to 0819f87 Compare January 24, 2019 17:00
@cjbassi cjbassi force-pushed the master branch 2 times, most recently from d3e2ed4 to 0eb6d61 Compare January 24, 2019 18:28
@cjbassi cjbassi force-pushed the master branch 2 times, most recently from d95d1d6 to a795c07 Compare February 7, 2019 11:22
@cjbassi cjbassi force-pushed the master branch 4 times, most recently from 32a5f54 to 6d201dc Compare March 12, 2019 05:30
@andre-l-mm
Copy link

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.

@cjbassi
Copy link
Contributor

cjbassi commented Mar 16, 2019

@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:

  1. add support for scrolling the view of the widget
  2. fix the text wrapping
  3. fix the cursor position on text wrap
  4. add support for line numbers

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.

@andre-l-mm
Copy link

Thanks @cjbassi, I will try the code on wip/input-widget branch today.

@andre-l-mm
Copy link

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 tags
  • GetRawText(): Converts text [][]Cell to a string representation without any formatting tags.

@cjbassi
Copy link
Contributor

cjbassi commented Mar 18, 2019

@andre-l-mm Both of those sound good!

@henri9813
Copy link

Hello,

Have you an idea when this will be released ? :D

Regards

@thehaiwave
Copy link

God has left us.

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

Successfully merging this pull request may close these issues.