jroimartin / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
9.92k stars 608 forks source link

Editor #41

Closed shibukraj closed 8 years ago

shibukraj commented 8 years ago

Do you have any examples that shows the right usage of editor struct?

jroimartin commented 8 years ago

First of all, please note that Editor is an interface. You have more information in the documentation.

On the other hand, DefaultEditor can be used as example:

https://github.com/jroimartin/gocui/blob/master/edit.go#L25

Specifically:

https://github.com/jroimartin/gocui/blob/master/edit.go#L28-L51

shibukraj commented 8 years ago

Hi there,

Thanks for the note. I did review the code and I would say I am getting better every day with my GO Lang lerning as well.

Let me give you an outline of what I am trying to do, so that the question I am going to ask will make more sense to you.

I am developing a terminal UI using the GOCUI lib. The UI will look like this - more like a POS terminal.

Main Menu

01 - Menu 1 02 - Menu 2 03 - Menu 3

Enter your Selection : __

Now the question is this. I want to build this using GOCUI. So I will have a view corresponding to the main menu. When the view is rendered, would like the cursor to position after the "Enter Your Selection :" text. Now say the user enters "01" and hit enter, I need to read the selection and how the next sub menu or may need to execute a logic to accomplish the activity.

Now I am in the process of reading the data the user entered in the editor, when the user hits enter. Any help in that direction will be really helpful

Thanks

jroimartin commented 8 years ago

Maybe it would be easier for you to implement this kind on application having multiple views. For instance, a non-editable one for the menus and the output given to the user and an editable one for the user input.

Another option is to allow to select the options using the arrows. You can take demo.go as example (see https://github.com/jroimartin/gocui/blob/master/_examples/demo.go#L50)

On the other hand, for what you want to do, you can use the default Editor and just set a Keybinding for the Enter key.

Does this answer your question? :)

jroimartin commented 8 years ago

Closed due to inactivity.