diff --git a/demos/box/main.go b/demos/box/main.go index ec114ee..b3fc654 100644 --- a/demos/box/main.go +++ b/demos/box/main.go @@ -1,3 +1,4 @@ +// Demo code for the Box primitive. package main import "github.com/rivo/tview" diff --git a/demos/button/main.go b/demos/button/main.go index ba525e5..13710c4 100644 --- a/demos/button/main.go +++ b/demos/button/main.go @@ -1,3 +1,4 @@ +// Demo code for the Button primitive. package main import "github.com/rivo/tview" diff --git a/demos/checkbox/main.go b/demos/checkbox/main.go index e6c4022..f13c179 100644 --- a/demos/checkbox/main.go +++ b/demos/checkbox/main.go @@ -1,3 +1,4 @@ +// Demo code for the Checkbox primitive. package main import "github.com/rivo/tview" diff --git a/demos/dropdown/main.go b/demos/dropdown/main.go index 6ca1d67..43bd75a 100644 --- a/demos/dropdown/main.go +++ b/demos/dropdown/main.go @@ -1,3 +1,4 @@ +// Demo code for the DropDown primitive. package main import "github.com/rivo/tview" diff --git a/demos/flex/main.go b/demos/flex/main.go index 5410c55..d2b7da6 100644 --- a/demos/flex/main.go +++ b/demos/flex/main.go @@ -1,3 +1,4 @@ +// Demo code for the Flex primitive. package main import ( diff --git a/demos/form/main.go b/demos/form/main.go index 6bbe73e..a8c3357 100644 --- a/demos/form/main.go +++ b/demos/form/main.go @@ -1,3 +1,4 @@ +// Demo code for the Form primitive. package main import ( diff --git a/demos/frame/main.go b/demos/frame/main.go index 021f292..bc85976 100644 --- a/demos/frame/main.go +++ b/demos/frame/main.go @@ -1,3 +1,4 @@ +// Demo code for the Frame primitive. package main import ( diff --git a/demos/inputfield/main.go b/demos/inputfield/main.go index 721d68b..501083c 100644 --- a/demos/inputfield/main.go +++ b/demos/inputfield/main.go @@ -1,3 +1,4 @@ +// Demo code for the InputField primitive. package main import ( diff --git a/demos/list/main.go b/demos/list/main.go index a05e56c..7188863 100644 --- a/demos/list/main.go +++ b/demos/list/main.go @@ -1,3 +1,4 @@ +// Demo code for the List primitive. package main import ( diff --git a/demos/modal/main.go b/demos/modal/main.go index 03c5bd5..b3eafef 100644 --- a/demos/modal/main.go +++ b/demos/modal/main.go @@ -1,3 +1,4 @@ +// Demo code for the Modal primitive. package main import ( diff --git a/demos/pages/main.go b/demos/pages/main.go index 6023a70..d60fbdb 100644 --- a/demos/pages/main.go +++ b/demos/pages/main.go @@ -1,3 +1,4 @@ +// Demo code for the Pages primitive. package main import ( diff --git a/demos/presentation/main.go b/demos/presentation/main.go index d96af03..b86af38 100644 --- a/demos/presentation/main.go +++ b/demos/presentation/main.go @@ -1,6 +1,12 @@ /* +A presentation of the tview package, implemented with tview. + Navigation +The presentation will advance to the next slide when the primitive demonstrated +in the current slide is left (usually by hitting Enter or Escape). Additionally, +the following shortcuts can be used: + - Ctrl-N: Jump to next slide - Ctrl-P: Jump to previous slide */ diff --git a/demos/table/main.go b/demos/table/main.go index d45cd20..abecd1f 100644 --- a/demos/table/main.go +++ b/demos/table/main.go @@ -1,3 +1,4 @@ +// Demo code for the Table primitive. package main import ( diff --git a/demos/textview/main.go b/demos/textview/main.go index e4bc2a2..528827b 100644 --- a/demos/textview/main.go +++ b/demos/textview/main.go @@ -1,3 +1,4 @@ +// Demo code for the TextView primitive. package main import ( diff --git a/doc.go b/doc.go index 8a45438..5d98185 100644 --- a/doc.go +++ b/doc.go @@ -1,10 +1,34 @@ /* -Package tview implements primitives for terminal based applications. It uses -github.com/gdamore/tcell. +Package tview implements rich widgets for terminal based user interfaces. The +widgets provided with this package are useful for data exploration and data +entry. + +Widgets + +The package implements the following widgets: + + - TextView: Scrollable windows that display multi-colored text. Text may also + be highlighted. + - Table: Scrollable display of tabular data. Table cells, rows, or columns may + also be highlighted. + - List: A navigable text list with optional keyboard shortcuts. + - InputField: One-line input fields to enter text. + - DropDown: Drop-down selection fields. + - Checkbox: Selectable checkbox for boolean values. + - Button: Buttons which get activated when the user selects them. + - Form: Forms composed of input fields, drop down selections, checkboxes, and + buttons. + - Modal: A centered window with a text message and one or more buttons. + - Flex: A Flexbox based layout manager. + - Pages: A page based layout manager. + +The package also provides Application which is used to poll the event queue and +draw widgets on screen. Hello World -Here is a very basic example showing a box with the title "Hello, world!": +The following is a very basic example showing a box with the title "Hello, +world!": package main @@ -20,15 +44,32 @@ Here is a very basic example showing a box with the title "Hello, world!": } First, we create a box primitive with a border and a title. Then we create an -application, set the box as its root primitive, and run the event loop. It -exits when the application's Stop() function is called or when Ctrl-C is -pressed. +application, set the box as its root primitive, and run the event loop. The +application exits when the application's Stop() function is called or when +Ctrl-C is pressed. If we have a primitive which consumes key presses, we call the application's SetFocus() function to redirect all key presses to that primitive. Most primitives then offer ways to install handlers that allow you to react to any actions performed on them. -No mouse input (yet). +More Demos + +You will find more demos in the "demos" subdirectory. It also contains a +presentation (written using tview) which gives an overview of the different +widgets and how they can be used. + +Type Hierarchy + +All widgets listed above contain the Box type. All of Box's functions are +therefore available for all widgets, too. + +All widgets also implement the Primitive interface. There is also the Focusable +interface which is used to override functions in subclassing types. + +The tview package is based on github.com/gdamore/tcell. It uses types and +constants from that package (e.g. colors and keyboard values). + +This package does not process mouse input (yet). */ package tview