2018-01-03 20:13:32 +00:00
|
|
|
// Demo code for the TextView primitive.
|
2017-12-27 15:05:00 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gdamore/tcell"
|
|
|
|
"github.com/rivo/tview"
|
|
|
|
)
|
|
|
|
|
|
|
|
const corporate = `Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
|
|
|
|
|
|
|
|
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
|
|
|
|
|
|
|
|
Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
|
|
|
|
|
|
|
|
[yellow]Press Enter, then Tab/Backtab for word selections`
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := tview.NewApplication()
|
|
|
|
textView := tview.NewTextView().
|
|
|
|
SetDynamicColors(true).
|
|
|
|
SetRegions(true).
|
2018-01-13 13:16:49 +00:00
|
|
|
SetWordWrap(true).
|
2017-12-27 15:05:00 +00:00
|
|
|
SetChangedFunc(func() {
|
|
|
|
app.Draw()
|
|
|
|
})
|
|
|
|
numSelections := 0
|
|
|
|
go func() {
|
|
|
|
for _, word := range strings.Split(corporate, " ") {
|
|
|
|
if word == "the" {
|
2018-01-12 08:09:01 +00:00
|
|
|
word = "[#ff0000]the[white]"
|
2017-12-27 15:05:00 +00:00
|
|
|
}
|
|
|
|
if word == "to" {
|
|
|
|
word = fmt.Sprintf(`["%d"]to[""]`, numSelections)
|
|
|
|
numSelections++
|
|
|
|
}
|
|
|
|
fmt.Fprintf(textView, "%s ", word)
|
|
|
|
time.Sleep(200 * time.Millisecond)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
textView.SetDoneFunc(func(key tcell.Key) {
|
|
|
|
currentSelection := textView.GetHighlights()
|
|
|
|
if key == tcell.KeyEnter {
|
|
|
|
if len(currentSelection) > 0 {
|
|
|
|
textView.Highlight()
|
|
|
|
} else {
|
|
|
|
textView.Highlight("0").ScrollToHighlight()
|
|
|
|
}
|
|
|
|
} else if len(currentSelection) > 0 {
|
|
|
|
index, _ := strconv.Atoi(currentSelection[0])
|
|
|
|
if key == tcell.KeyTab {
|
|
|
|
index = (index + 1) % numSelections
|
|
|
|
} else if key == tcell.KeyBacktab {
|
|
|
|
index = (index - 1 + numSelections) % numSelections
|
|
|
|
} else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
textView.Highlight(strconv.Itoa(index)).ScrollToHighlight()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
textView.SetBorder(true)
|
2018-03-05 15:37:10 +00:00
|
|
|
if err := app.SetRoot(textView, true).Run(); err != nil {
|
2017-12-27 15:05:00 +00:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|