1
0
mirror of https://github.com/rivo/tview.git synced 2025-04-24 13:48:56 +08:00

Merge branch 'rivo:master' into master

This commit is contained in:
wellcomez 2024-10-25 15:21:02 +08:00 committed by GitHub
commit d063781b8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 8 deletions

View File

@ -77,7 +77,6 @@ For a presentation highlighting this package, compile and run the program found
- [Test your typing speed in the terminal!](https://github.com/shilangyu/typer-go)
- [TUI Client for Docker](https://github.com/skanehira/docui)
- [SSH client using certificates signed by HashiCorp Vault](https://github.com/stephane-martin/vssh)
- [A go terminal based pos software.](https://github.com/thebmw/y2kpos)
- [VMware vCenter Text UI](https://github.com/thebsdbox/vctui)
- [Bookmarks on terminal](https://github.com/tryffel/bookmarker)
- [A UDP testing utility](https://github.com/vaelen/udp-tester)
@ -134,6 +133,8 @@ For a presentation highlighting this package, compile and run the program found
- [DBee: Simple database browser](https://github.com/murat-cileli/dbee)
- [oddshub: A TUI for sports betting odds](https://github.com/dos-2/oddshub)
- [envolve: Terminal based interactive app for manage enviroment variables](https://github.com/erdemkosk/envolve)
- [zfs-file-history: Terminal UI for inspecting and restoring file history on ZFS snapshots](https://github.com/markusressel/zfs-file-history)
- [fan2go-tui: Terminal UI for fan2go](https://github.com/markusressel/fan2go-tui)
## Documentation

View File

@ -250,7 +250,13 @@ func (a *Application) EnablePaste(enable bool) *Application {
}
// Run starts the application and thus the event loop. This function returns
// when Stop() was called.
// when [Application.Stop] was called.
//
// Note that while an application is running, it fully claims stdin, stdout, and
// stderr. If you use these standard streams, they may not work as expected.
// Consider stopping the application first or suspending it (using
// [Application.Suspend]) if you have to interact with the standard streams, for
// example when needing to print a call stack during a panic.
func (a *Application) Run() error {
var (
err, appErr error

View File

@ -380,9 +380,6 @@ func (d *DropDown) Draw(screen tcell.Screen) {
fieldWidth = rightLimit - x
}
fieldStyle := tcell.StyleDefault.Background(d.fieldBackgroundColor)
if d.HasFocus() && !d.open {
fieldStyle = fieldStyle.Background(d.fieldTextColor)
}
if d.disabled {
fieldStyle = fieldStyle.Background(d.backgroundColor)
}
@ -408,9 +405,6 @@ func (d *DropDown) Draw(screen tcell.Screen) {
text = d.currentOptionPrefix + d.options[d.currentOption].Text + d.currentOptionSuffix
}
// Just show the current selection.
if d.HasFocus() && !d.open && !d.disabled {
color = d.fieldBackgroundColor
}
Print(screen, text, x, y, fieldWidth, AlignLeft, color)
}

View File

@ -135,6 +135,11 @@ func NewInputField() *InputField {
if i.changed != nil {
i.changed(i.textArea.GetText())
}
}).SetFocusFunc(func() {
// Forward focus event to the input field.
if i.Box.focus != nil {
i.Box.focus()
}
})
i.textArea.textStyle = tcell.StyleDefault.Background(Styles.ContrastBackgroundColor).Foreground(Styles.PrimaryTextColor)
i.textArea.placeholderStyle = tcell.StyleDefault.Background(Styles.ContrastBackgroundColor).Foreground(Styles.ContrastSecondaryTextColor)

View File

@ -1,6 +1,7 @@
package tview
import (
"math"
"strings"
"unicode"
"unicode/utf8"
@ -363,6 +364,8 @@ func NewTextArea() *TextArea {
lastAction: taActionOther,
minCursorPrefix: minCursorPrefixDefault,
minCursorSuffix: minCursorSuffixDefault,
lastWidth: math.MaxInt / 2, // We need this so some functions work before the first draw.
lastHeight: 1,
}
t.editText.Grow(editBufferMinCap)
t.spans[0] = textAreaSpan{previous: -1, next: 1}