gizak / termui

Golang terminal dashboard
MIT License
13.2k stars 786 forks source link

EditBox / Input / Text editing #34

Open yesnault opened 9 years ago

yesnault commented 9 years ago

Hi,

Is there an easy way to make an edit box with termui ?

Tks,

gizak commented 9 years ago

I think for now you have to do:

  1. listen keyboard events
  2. get every pressed key stored
  3. put the captured char into the dataset of a component
  4. refresh

Input widget is planed but we are not getting there yet, since there is an undergoing refactoring and only after this I will switch to the event system and new widgets :)

weberc2 commented 8 years ago

+1

mikepea commented 8 years ago

I've got a basic implementation of a termui-based editbox working in https://github.com/mikepea/go-jira-ui

It's basically a port of the EditBox example code from termbox-go.

It's not in a state where it'd be contributable upstream (yet), but it'd be a reasonable base to use in your own projects. See ui_controls.go for how it's connected to the keyboard event handler.

liushuchun commented 8 years ago

yeah.I need this feature too.it's not easy to get the input text string in termui.

brianbianco commented 8 years ago

Any info of if this is still in the roadmap or not? I think this is a pretty essential feature.

liushuchun commented 8 years ago

I am also waiting for this basic feature.

liushuchun commented 8 years ago

hi all,I have solved this problem. https://github.com/liushuchun/wechatcmd

sapessi commented 7 years ago

Hi all,

I have created a basic input component for termui, you can see it in my fork here: https://github.com/SAPessi/termui/commit/71d140f624b87461a4ed362e55fc2d1c13c0c7a4

You can use it like this:

// first param is the string content, the second whether it should be multi-line or not
input := termui.NewInput("", true)
input.Height = termui.TermHeight()
input.BorderFg = termui.ColorYellow
// same properties as other Block
termui.Render(input)

// the StartCapture method tells the editor to begin listening for /sys/kbd events
input.StartCapture()

@gizak interested in a pull request?

Update Made a few changes since the original commit, take a look at the file here: https://github.com/SAPessi/termui/blob/master/input.go

Also working on a dropdown component

gizak commented 7 years ago

@SAPessi Hi pull requests are very welcome!

sapessi commented 7 years ago

Sent as pull requests #129

max123926 commented 4 years ago

Hi all,

I have created a basic input component for termui, you can see it in my fork here: sapessi@71d140f

You can use it like this:

// first param is the string content, the second whether it should be multi-line or not
input := termui.NewInput("", true)
input.Height = termui.TermHeight()
input.BorderFg = termui.ColorYellow
// same properties as other Block
termui.Render(input)

// the StartCapture method tells the editor to begin listening for /sys/kbd events
input.StartCapture()

@gizak interested in a pull request?

Update Made a few changes since the original commit, take a look at the file here: https://github.com/SAPessi/termui/blob/master/input.go

Also working on a dropdown component

Excuse me, I use go version 12.9 on Windows 10. I put "input.go" in "$GOPATH\src\gopkg.in\gizak\termui.v2" and ran the example you offered. However, it occurred fatal error. I've posted the problem here.

Thank you very much! Max