|
|
|
@ -84,7 +84,7 @@ func (w TextViewWriter) HasFocus() bool {
|
|
|
|
|
// but if a handler is installed via SetChangedFunc(), you can cause it to be
|
|
|
|
|
// redrawn. (See SetChangedFunc() for more details.)
|
|
|
|
|
//
|
|
|
|
|
// Navigation
|
|
|
|
|
// # Navigation
|
|
|
|
|
//
|
|
|
|
|
// If the text view is scrollable (the default), text is kept in a buffer which
|
|
|
|
|
// may be larger than the screen and can be navigated similarly to Vim:
|
|
|
|
@ -103,27 +103,27 @@ func (w TextViewWriter) HasFocus() bool {
|
|
|
|
|
//
|
|
|
|
|
// Use SetInputCapture() to override or modify keyboard input.
|
|
|
|
|
//
|
|
|
|
|
// Colors
|
|
|
|
|
// # Colors
|
|
|
|
|
//
|
|
|
|
|
// If dynamic colors are enabled via SetDynamicColors(), text color can be
|
|
|
|
|
// changed dynamically by embedding color strings in square brackets. This works
|
|
|
|
|
// the same way as anywhere else. Please see the package documentation for more
|
|
|
|
|
// information.
|
|
|
|
|
//
|
|
|
|
|
// Regions and Highlights
|
|
|
|
|
// # Regions and Highlights
|
|
|
|
|
//
|
|
|
|
|
// If regions are enabled via SetRegions(), you can define text regions within
|
|
|
|
|
// the text and assign region IDs to them. Text regions start with region tags.
|
|
|
|
|
// Region tags are square brackets that contain a region ID in double quotes,
|
|
|
|
|
// for example:
|
|
|
|
|
//
|
|
|
|
|
// We define a ["rg"]region[""] here.
|
|
|
|
|
// We define a ["rg"]region[""] here.
|
|
|
|
|
//
|
|
|
|
|
// A text region ends with the next region tag. Tags with no region ID ([""])
|
|
|
|
|
// don't start new regions. They can therefore be used to mark the end of a
|
|
|
|
|
// region. Region IDs must satisfy the following regular expression:
|
|
|
|
|
//
|
|
|
|
|
// [a-zA-Z0-9_,;: \-\.]+
|
|
|
|
|
// [a-zA-Z0-9_,;: \-\.]+
|
|
|
|
|
//
|
|
|
|
|
// Regions can be highlighted by calling the Highlight() function with one or
|
|
|
|
|
// more region IDs. This can be used to display search results, for example.
|
|
|
|
@ -131,7 +131,7 @@ func (w TextViewWriter) HasFocus() bool {
|
|
|
|
|
// The ScrollToHighlight() function can be used to jump to the currently
|
|
|
|
|
// highlighted region once when the text view is drawn the next time.
|
|
|
|
|
//
|
|
|
|
|
// Large Texts
|
|
|
|
|
// # Large Texts
|
|
|
|
|
//
|
|
|
|
|
// This widget is not designed for very large texts as word wrapping, color and
|
|
|
|
|
// region tag handling, and proper Unicode handling will result in a significant
|
|
|
|
@ -756,13 +756,13 @@ func (t *TextView) write(p []byte) (n int, err error) {
|
|
|
|
|
// BatchWriter is called, and will be released when the returned writer is
|
|
|
|
|
// closed. Example:
|
|
|
|
|
//
|
|
|
|
|
// tv := tview.NewTextView()
|
|
|
|
|
// w := tv.BatchWriter()
|
|
|
|
|
// defer w.Close()
|
|
|
|
|
// w.Clear()
|
|
|
|
|
// fmt.Fprintln(w, "To sit in solemn silence")
|
|
|
|
|
// fmt.Fprintln(w, "on a dull, dark, dock")
|
|
|
|
|
// fmt.Println(tv.GetText(false))
|
|
|
|
|
// tv := tview.NewTextView()
|
|
|
|
|
// w := tv.BatchWriter()
|
|
|
|
|
// defer w.Close()
|
|
|
|
|
// w.Clear()
|
|
|
|
|
// fmt.Fprintln(w, "To sit in solemn silence")
|
|
|
|
|
// fmt.Fprintln(w, "on a dull, dark, dock")
|
|
|
|
|
// fmt.Println(tv.GetText(false))
|
|
|
|
|
//
|
|
|
|
|
// Note that using the batch writer requires you to manage any issues that may
|
|
|
|
|
// arise from concurrency yourself. See package description for details on
|
|
|
|
@ -1317,6 +1317,9 @@ func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMou
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch action {
|
|
|
|
|
case MouseLeftDown:
|
|
|
|
|
setFocus(t)
|
|
|
|
|
consumed = true
|
|
|
|
|
case MouseLeftClick:
|
|
|
|
|
if t.regions {
|
|
|
|
|
// Find a region to highlight.
|
|
|
|
@ -1331,7 +1334,6 @@ func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMou
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setFocus(t)
|
|
|
|
|
consumed = true
|
|
|
|
|
case MouseScrollUp:
|
|
|
|
|
t.trackEnd = false
|
|
|
|
|