Merge pull request #1542 from charmbracelet/charm-853-cursor-flash-interruptions-mode-2026
v2: Support mode 2026 (synchronized output updates)
This commit is contained in:
commit
55b3503a2a
30 changed files with 324 additions and 217 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package tea
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io"
|
||||
|
|
@ -15,8 +16,9 @@ import (
|
|||
|
||||
type cursedRenderer struct {
|
||||
w io.Writer
|
||||
buf bytes.Buffer // updates buffer to be flushed to [w]
|
||||
scr *uv.TerminalRenderer
|
||||
buf uv.ScreenBuffer
|
||||
cellbuf uv.ScreenBuffer
|
||||
lastView *View
|
||||
env []string
|
||||
term string // the terminal type $TERM
|
||||
|
|
@ -28,6 +30,7 @@ type cursedRenderer struct {
|
|||
hardTabs bool // whether to use hard tabs to optimize cursor movements
|
||||
backspace bool // whether to use backspace to optimize cursor movements
|
||||
mapnl bool
|
||||
syncdUpdates bool // whether to use synchronized output mode for updates
|
||||
prependLines []string
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +42,7 @@ func newCursedRenderer(w io.Writer, env []string, width, height int) (s *cursedR
|
|||
s.env = env
|
||||
s.term = uv.Environ(env).Getenv("TERM")
|
||||
s.width, s.height = width, height // This needs to happen before [cursedRenderer.reset].
|
||||
s.buf = uv.NewScreenBuffer(s.width, s.height)
|
||||
s.cellbuf = uv.NewScreenBuffer(s.width, s.height)
|
||||
reset(s)
|
||||
return
|
||||
}
|
||||
|
|
@ -48,7 +51,6 @@ func newCursedRenderer(w io.Writer, env []string, width, height int) (s *cursedR
|
|||
func (s *cursedRenderer) setLogger(logger uv.Logger) {
|
||||
s.mu.Lock()
|
||||
s.logger = logger
|
||||
s.scr.SetLogger(logger)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
|
|
@ -76,8 +78,8 @@ func (s *cursedRenderer) start() {
|
|||
if s.lastView.AltScreen {
|
||||
enableAltScreen(s, true)
|
||||
}
|
||||
enableTextCursor(s, s.lastView.Cursor != nil)
|
||||
if s.lastView.Cursor != nil {
|
||||
enableTextCursor(s, true)
|
||||
if s.lastView.Cursor.Color != nil {
|
||||
col, ok := colorful.MakeColor(s.lastView.Cursor.Color)
|
||||
if ok {
|
||||
|
|
@ -102,17 +104,17 @@ func (s *cursedRenderer) start() {
|
|||
}
|
||||
}
|
||||
if !s.lastView.DisableBracketedPasteMode {
|
||||
_, _ = s.scr.WriteString(ansi.SetBracketedPasteMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeBracketedPaste)
|
||||
}
|
||||
if s.lastView.ReportFocus {
|
||||
_, _ = s.scr.WriteString(ansi.SetFocusEventMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeFocusEvent)
|
||||
}
|
||||
switch s.lastView.MouseMode {
|
||||
case MouseModeNone:
|
||||
case MouseModeCellMotion:
|
||||
_, _ = s.scr.WriteString(ansi.SetButtonEventMouseMode + ansi.SetSgrExtMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeMouseButtonEvent + ansi.SetModeMouseExtSgr)
|
||||
case MouseModeAllMotion:
|
||||
_, _ = s.scr.WriteString(ansi.SetAnyEventMouseMode + ansi.SetSgrExtMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeMouseAnyEvent + ansi.SetModeMouseExtSgr)
|
||||
}
|
||||
if s.lastView.WindowTitle != "" {
|
||||
_, _ = s.scr.WriteString(ansi.SetWindowTitle(s.lastView.WindowTitle))
|
||||
|
|
@ -138,27 +140,27 @@ func (s *cursedRenderer) close() (err error) {
|
|||
// used when the user suspends the program and then resumes it.
|
||||
if lv := s.lastView; lv != nil { //nolint:nestif
|
||||
if lv.AltScreen {
|
||||
s.scr.ExitAltScreen()
|
||||
enableAltScreen(s, false)
|
||||
} else {
|
||||
// Go to the bottom of the screen.
|
||||
s.scr.MoveTo(0, s.buf.Height()-1)
|
||||
_, _ = s.scr.WriteString("\r" + ansi.EraseScreenBelow)
|
||||
s.scr.MoveTo(0, s.cellbuf.Height()-1)
|
||||
_, _ = s.scr.WriteString(ansi.EraseScreenBelow)
|
||||
}
|
||||
if lv.Cursor == nil {
|
||||
s.scr.ShowCursor()
|
||||
enableTextCursor(s, true)
|
||||
}
|
||||
if !lv.DisableBracketedPasteMode {
|
||||
_, _ = s.scr.WriteString(ansi.ResetBracketedPasteMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeBracketedPaste)
|
||||
}
|
||||
if lv.ReportFocus {
|
||||
_, _ = s.scr.WriteString(ansi.ResetFocusEventMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeFocusEvent)
|
||||
}
|
||||
switch lv.MouseMode {
|
||||
case MouseModeNone:
|
||||
case MouseModeCellMotion, MouseModeAllMotion:
|
||||
_, _ = s.scr.WriteString(ansi.ResetButtonEventMouseMode +
|
||||
ansi.ResetAnyEventMouseMode +
|
||||
ansi.ResetSgrExtMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeMouseButtonEvent +
|
||||
ansi.ResetModeMouseAnyEvent +
|
||||
ansi.ResetModeMouseExtSgr)
|
||||
}
|
||||
|
||||
if lv.WindowTitle != "" {
|
||||
|
|
@ -196,6 +198,16 @@ func (s *cursedRenderer) close() (err error) {
|
|||
return fmt.Errorf("bubbletea: error closing screen writer: %w", err)
|
||||
}
|
||||
|
||||
if s.buf.Len() > 0 {
|
||||
if s.logger != nil {
|
||||
s.logger.Printf("output: %q", s.buf.String())
|
||||
}
|
||||
if _, err := io.Copy(s.w, &s.buf); err != nil {
|
||||
return fmt.Errorf("bubbletea: error writing to screen: %w", err)
|
||||
}
|
||||
s.buf.Reset()
|
||||
}
|
||||
|
||||
x, y := s.scr.Position()
|
||||
|
||||
// We want to clear the renderer state but not the cursor position. This is
|
||||
|
|
@ -228,9 +240,23 @@ func (s *cursedRenderer) flush(closing bool) error {
|
|||
}
|
||||
|
||||
// Alt screen mode.
|
||||
enableAltScreen(s, view.AltScreen)
|
||||
updateAltScreen := (s.lastView == nil && view.AltScreen) || (s.lastView != nil && s.lastView.AltScreen != view.AltScreen)
|
||||
if updateAltScreen {
|
||||
enableAltScreen(s, view.AltScreen)
|
||||
}
|
||||
// Cursor visibility.
|
||||
enableTextCursor(s, view.Cursor != nil)
|
||||
updateCursorVis := s.lastView == nil || (s.lastView.Cursor != nil) != (view.Cursor != nil)
|
||||
if (updateCursorVis || updateAltScreen) && (s.syncdUpdates || view.Cursor == nil) {
|
||||
// We need to update the cursor visibility if we're entering or exiting
|
||||
// alt screen mode because some terminals have a different cursor
|
||||
// visibility state in alt screen mode.
|
||||
// Note that cursor visibility is also affected by synchronized output
|
||||
// and whether the cursor is already visible or not. If synchronized
|
||||
// output is not enabled, we show the cursor at the end of the update
|
||||
// to avoid flickering. If synchronized output is enabled, we update
|
||||
// cursor visibility here.
|
||||
enableTextCursor(s, view.Cursor != nil)
|
||||
}
|
||||
|
||||
// Push prepended lines if any.
|
||||
if len(s.prependLines) > 0 {
|
||||
|
|
@ -243,18 +269,18 @@ func (s *cursedRenderer) flush(closing bool) error {
|
|||
// bracketed paste mode.
|
||||
if s.lastView == nil || view.DisableBracketedPasteMode != s.lastView.DisableBracketedPasteMode {
|
||||
if !view.DisableBracketedPasteMode {
|
||||
_, _ = s.scr.WriteString(ansi.SetBracketedPasteMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeBracketedPaste)
|
||||
} else if s.lastView != nil {
|
||||
_, _ = s.scr.WriteString(ansi.ResetBracketedPasteMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeBracketedPaste)
|
||||
}
|
||||
}
|
||||
|
||||
// report focus events mode.
|
||||
if s.lastView == nil || s.lastView.ReportFocus != view.ReportFocus {
|
||||
if view.ReportFocus {
|
||||
_, _ = s.scr.WriteString(ansi.SetFocusEventMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeFocusEvent)
|
||||
} else if s.lastView != nil {
|
||||
_, _ = s.scr.WriteString(ansi.ResetFocusEventMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeFocusEvent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -263,20 +289,20 @@ func (s *cursedRenderer) flush(closing bool) error {
|
|||
switch view.MouseMode {
|
||||
case MouseModeNone:
|
||||
if s.lastView != nil && s.lastView.MouseMode != MouseModeNone {
|
||||
_, _ = s.scr.WriteString(ansi.ResetButtonEventMouseMode +
|
||||
ansi.ResetAnyEventMouseMode +
|
||||
ansi.ResetSgrExtMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeMouseButtonEvent +
|
||||
ansi.ResetModeMouseAnyEvent +
|
||||
ansi.ResetModeMouseExtSgr)
|
||||
}
|
||||
case MouseModeCellMotion:
|
||||
if s.lastView != nil && s.lastView.MouseMode == MouseModeAllMotion {
|
||||
_, _ = s.scr.WriteString(ansi.ResetAnyEventMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeMouseAnyEvent)
|
||||
}
|
||||
_, _ = s.scr.WriteString(ansi.SetButtonEventMouseMode + ansi.SetSgrExtMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeMouseButtonEvent + ansi.SetModeMouseExtSgr)
|
||||
case MouseModeAllMotion:
|
||||
if s.lastView != nil && s.lastView.MouseMode == MouseModeCellMotion {
|
||||
_, _ = s.scr.WriteString(ansi.ResetButtonEventMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeMouseButtonEvent)
|
||||
}
|
||||
_, _ = s.scr.WriteString(ansi.SetAnyEventMouseMode + ansi.SetSgrExtMouseMode)
|
||||
_, _ = s.scr.WriteString(ansi.SetModeMouseAnyEvent + ansi.SetModeMouseExtSgr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -369,7 +395,7 @@ func (s *cursedRenderer) flush(closing bool) error {
|
|||
}
|
||||
|
||||
// Render and queue changes to the screen buffer.
|
||||
s.scr.Render(s.buf.Buffer)
|
||||
s.scr.Render(s.cellbuf.Buffer)
|
||||
|
||||
if cur := view.Cursor; cur != nil {
|
||||
// MoveTo must come after [uv.TerminalRenderer.Render] because the
|
||||
|
|
@ -392,6 +418,46 @@ func (s *cursedRenderer) flush(closing bool) error {
|
|||
return fmt.Errorf("bubbletea: error flushing screen writer: %w", err)
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
hideShowCursor := !s.syncdUpdates && view.Cursor != nil
|
||||
if s.buf.Len() > 0 {
|
||||
if hideShowCursor && s.lastView != nil && s.lastView.Cursor != nil {
|
||||
// If we have the cursor visible, we want to hide it during the update
|
||||
// to avoid flickering. Unless we have synchronized updates enabled, in
|
||||
// which case the terminal will handle it for us.
|
||||
buf.WriteString(ansi.ResetModeTextCursorEnable)
|
||||
} else if s.syncdUpdates {
|
||||
// We have synchronized output updates enabled.
|
||||
buf.WriteString(ansi.SetModeSynchronizedOutput)
|
||||
}
|
||||
}
|
||||
|
||||
buf.Write(s.buf.Bytes())
|
||||
|
||||
// We need to ensure we're showing the cursor if it was requested in the
|
||||
// view. There is no s.buf.Len() check here because when the update is only
|
||||
// a cursor visibility change, s.buf.Len() will be zero and the
|
||||
// updateCursorVis check above will not write anything to s.buf.
|
||||
if hideShowCursor {
|
||||
// Now restore the cursor visibility.
|
||||
buf.WriteString(ansi.SetModeTextCursorEnable)
|
||||
} else if s.buf.Len() > 0 && s.syncdUpdates {
|
||||
// Close synchronized output mode.
|
||||
buf.WriteString(ansi.ResetModeSynchronizedOutput)
|
||||
}
|
||||
|
||||
// Reset internal screen renderer buffer.
|
||||
s.buf.Reset()
|
||||
|
||||
if buf.Len() > 0 {
|
||||
if s.logger != nil {
|
||||
s.logger.Printf("output: %q", buf.String())
|
||||
}
|
||||
if _, err := io.Copy(s.w, &buf); err != nil {
|
||||
return fmt.Errorf("bubbletea: error flushing update to the writer: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
s.lastView = &view
|
||||
|
||||
return nil
|
||||
|
|
@ -429,25 +495,25 @@ func (s *cursedRenderer) render(v View) {
|
|||
}
|
||||
}
|
||||
|
||||
if frameArea != s.buf.Bounds() {
|
||||
if frameArea != s.cellbuf.Bounds() {
|
||||
// Resize the screen buffer to match the frame area. This is necessary
|
||||
// to ensure that the screen buffer is the same size as the frame area
|
||||
// and to avoid rendering issues when the frame area is smaller than
|
||||
// the screen buffer.
|
||||
s.buf.Resize(frameArea.Dx(), frameArea.Dy())
|
||||
s.cellbuf.Resize(frameArea.Dx(), frameArea.Dy())
|
||||
}
|
||||
|
||||
// Clear our screen buffer before copying the new frame into it to ensure
|
||||
// we erase any old content.
|
||||
s.buf.Clear()
|
||||
s.cellbuf.Clear()
|
||||
if v.Content != nil {
|
||||
v.Content.Draw(s.buf, frameArea)
|
||||
v.Content.Draw(s.cellbuf, frameArea)
|
||||
}
|
||||
|
||||
// If the frame height is greater than the screen height, we drop the
|
||||
// lines from the top of the buffer.
|
||||
if frameHeight := frameArea.Dy(); frameHeight > s.height {
|
||||
s.buf.Lines = s.buf.Lines[frameHeight-s.height:]
|
||||
s.cellbuf.Lines = s.cellbuf.Lines[frameHeight-s.height:]
|
||||
}
|
||||
|
||||
s.view = v
|
||||
|
|
@ -485,23 +551,14 @@ func (s *cursedRenderer) reset() {
|
|||
}
|
||||
|
||||
func reset(s *cursedRenderer) {
|
||||
scr := uv.NewTerminalRenderer(s.w, s.env)
|
||||
s.buf.Reset()
|
||||
scr := uv.NewTerminalRenderer(&s.buf, s.env)
|
||||
scr.SetColorProfile(s.profile)
|
||||
scr.SetRelativeCursor(s.lastView == nil || !s.lastView.AltScreen)
|
||||
scr.SetRelativeCursor(true) // Always start in inline mode
|
||||
scr.SetFullscreen(false) // Always start in inline mode
|
||||
scr.SetTabStops(s.width)
|
||||
scr.SetBackspace(s.backspace)
|
||||
scr.SetMapNewline(s.mapnl)
|
||||
scr.SetLogger(s.logger)
|
||||
if s.lastView != nil && s.lastView.AltScreen {
|
||||
scr.EnterAltScreen()
|
||||
} else {
|
||||
scr.ExitAltScreen()
|
||||
}
|
||||
if s.lastView != nil && s.lastView.Cursor != nil {
|
||||
scr.ShowCursor()
|
||||
} else {
|
||||
scr.HideCursor()
|
||||
}
|
||||
s.scr = scr
|
||||
}
|
||||
|
||||
|
|
@ -527,7 +584,7 @@ func (s *cursedRenderer) resize(w, h int) {
|
|||
}
|
||||
|
||||
// We need to reset the touched lines buffer to match the new height.
|
||||
s.buf.Touched = nil
|
||||
s.cellbuf.Touched = nil
|
||||
|
||||
s.width, s.height = w, h
|
||||
s.scr.Resize(s.width, s.height)
|
||||
|
|
@ -551,43 +608,21 @@ func enableAltScreen(s *cursedRenderer, enable bool) {
|
|||
} else {
|
||||
s.scr.ExitAltScreen()
|
||||
}
|
||||
s.scr.SetRelativeCursor(!enable)
|
||||
}
|
||||
|
||||
// enterAltScreen implements renderer.
|
||||
func (s *cursedRenderer) enterAltScreen() {
|
||||
s.mu.Lock()
|
||||
enableAltScreen(s, true)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// exitAltScreen implements renderer.
|
||||
func (s *cursedRenderer) exitAltScreen() {
|
||||
s.mu.Lock()
|
||||
enableAltScreen(s, false)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// enableTextCursor sets the text cursor mode.
|
||||
func enableTextCursor(s *cursedRenderer, enable bool) {
|
||||
if enable {
|
||||
s.scr.ShowCursor()
|
||||
_, _ = s.scr.WriteString(ansi.SetModeTextCursorEnable)
|
||||
} else {
|
||||
s.scr.HideCursor()
|
||||
_, _ = s.scr.WriteString(ansi.ResetModeTextCursorEnable)
|
||||
}
|
||||
}
|
||||
|
||||
// showCursor implements renderer.
|
||||
func (s *cursedRenderer) showCursor() {
|
||||
// setSyncdUpdates implements renderer.
|
||||
func (s *cursedRenderer) setSyncdUpdates(syncd bool) {
|
||||
s.mu.Lock()
|
||||
enableTextCursor(s, true)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// hideCursor implements renderer.
|
||||
func (s *cursedRenderer) hideCursor() {
|
||||
s.mu.Lock()
|
||||
enableTextCursor(s, false)
|
||||
s.syncdUpdates = syncd
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
|
|
@ -601,10 +636,10 @@ func (s *cursedRenderer) insertAbove(lines string) {
|
|||
func prependLine(s *cursedRenderer, line string) {
|
||||
strLines := strings.Split(line, "\n")
|
||||
for i, line := range strLines {
|
||||
// If the line is wider than the screen, truncate it.
|
||||
strLines[i] = ansi.Truncate(line, s.width, "")
|
||||
// Always erase to the right of the line to avoid possible artifacts.
|
||||
strLines[i] = line + ansi.EraseLineRight
|
||||
}
|
||||
s.scr.PrependString(strings.Join(strLines, "\n"))
|
||||
s.scr.PrependString(s.cellbuf.Buffer, strings.Join(strLines, "\n"))
|
||||
}
|
||||
|
||||
func setProgressBar(s *cursedRenderer, pb *ProgressBar) {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ replace charm.land/bubbletea/v2 => ../
|
|||
require (
|
||||
charm.land/bubbles/v2 v2.0.0-beta.1.0.20251110211018-84a82dfeeed8
|
||||
charm.land/bubbletea/v2 v2.0.0-rc.1.0.20251106192006-06c0cda318b3
|
||||
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106193318-19329a3e8410
|
||||
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251114160003-3248589b24c9
|
||||
github.com/charmbracelet/colorprofile v0.3.3
|
||||
github.com/charmbracelet/glamour/v2 v2.0.0-20251106195642-800eb8175930
|
||||
github.com/charmbracelet/harmonica v0.2.0
|
||||
github.com/charmbracelet/x/ansi v0.11.1-0.20251110210702-903592506081
|
||||
github.com/charmbracelet/x/ansi v0.11.1
|
||||
github.com/charmbracelet/x/exp/charmtone v0.0.0-20250602192518-9e722df69bbb
|
||||
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0
|
||||
|
|
@ -23,7 +23,7 @@ require (
|
|||
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
|
||||
github.com/atotto/clipboard v0.1.4 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251112162901-46098fed0961 // indirect
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114211315-f6a8e3732033 // indirect
|
||||
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
|
||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||
github.com/charmbracelet/x/termios v0.1.1 // indirect
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
charm.land/bubbles/v2 v2.0.0-beta.1.0.20251110211018-84a82dfeeed8 h1:2bzaNBvZHgpLjxlQTDjoeY0YGjQtMflWiDZMEbviiRE=
|
||||
charm.land/bubbles/v2 v2.0.0-beta.1.0.20251110211018-84a82dfeeed8/go.mod h1:5AbN6cEd/47gkEf8TgiQ2O3RZ5QxMS14l9W+7F9fPC4=
|
||||
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106193318-19329a3e8410 h1:D9PbaszZYpB4nj+d6HTWr1onlmlyuGVNfL9gAi8iB3k=
|
||||
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106193318-19329a3e8410/go.mod h1:1qZyvvVCenJO2M1ac2mX0yyiIZJoZmDM4DG4s0udJkU=
|
||||
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251114160003-3248589b24c9 h1:FSmPSuQzHfyzens1NukU5wP76ttNcEa8MZQIZM77RbQ=
|
||||
charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251114160003-3248589b24c9/go.mod h1:1qZyvvVCenJO2M1ac2mX0yyiIZJoZmDM4DG4s0udJkU=
|
||||
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
|
||||
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
|
||||
github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
|
||||
|
|
@ -22,10 +22,10 @@ github.com/charmbracelet/glamour/v2 v2.0.0-20251106195642-800eb8175930 h1:+47Z2j
|
|||
github.com/charmbracelet/glamour/v2 v2.0.0-20251106195642-800eb8175930/go.mod h1:izs11tnkYaT3DTEH2E0V/lCb18VGZ7k9HLYEGuvgXGA=
|
||||
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
|
||||
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251112162901-46098fed0961 h1:qneAb6lrvZEaliI3g91vFDYf4kCpotKU0bRXijfHRqA=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251112162901-46098fed0961/go.mod h1:ung4G52QJm6rlFYPYqPelzBHWWy966P9VMonX7UGT5g=
|
||||
github.com/charmbracelet/x/ansi v0.11.1-0.20251110210702-903592506081 h1:gWeRo2N77OeiZAL47lzvIot9VPpTzxT5ahdzQIyHEDY=
|
||||
github.com/charmbracelet/x/ansi v0.11.1-0.20251110210702-903592506081/go.mod h1:M49wjzpIujwPceJ+t5w3qh2i87+HRtHohgb5iTyepL0=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114211315-f6a8e3732033 h1:8yh54FdK5bXVF9Oy51C+glAV/QblG6KpXl88alZNOtU=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114211315-f6a8e3732033/go.mod h1:6lfcr3MNP+kZR25sF1nQwJFuQnNYBlFy3PGX5rvslXc=
|
||||
github.com/charmbracelet/x/ansi v0.11.1 h1:iXAC8SyMQDJgtcz9Jnw+HU8WMEctHzoTAETIeA3JXMk=
|
||||
github.com/charmbracelet/x/ansi v0.11.1/go.mod h1:M49wjzpIujwPceJ+t5w3qh2i87+HRtHohgb5iTyepL0=
|
||||
github.com/charmbracelet/x/exp/charmtone v0.0.0-20250602192518-9e722df69bbb h1:oTM8tZxV7FY0ehvYjFuICouuhzE08UZYNqUIp/lDQdY=
|
||||
github.com/charmbracelet/x/exp/charmtone v0.0.0-20250602192518-9e722df69bbb/go.mod h1:T9jr8CzFpjhFVHjNjKwbAD7KwBNyFnj2pntAO7F2zw0=
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ var (
|
|||
|
||||
func newModel() model {
|
||||
p := progress.New(
|
||||
progress.WithDefaultGradient(),
|
||||
progress.WithDefaultBlend(),
|
||||
progress.WithWidth(40),
|
||||
progress.WithoutPercentage(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
|||
|
||||
func main() {
|
||||
m := model{
|
||||
progress: progress.New(progress.WithDefaultGradient()),
|
||||
progress: progress.New(progress.WithDefaultBlend()),
|
||||
}
|
||||
|
||||
if _, err := tea.NewProgram(m).Run(); err != nil {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func main() {
|
|||
|
||||
m := model{
|
||||
pw: pw,
|
||||
progress: progress.New(progress.WithDefaultGradient()),
|
||||
progress: progress.New(progress.WithDefaultBlend()),
|
||||
}
|
||||
// Start Bubble Tea
|
||||
p = tea.NewProgram(m)
|
||||
|
|
|
|||
|
|
@ -32,10 +32,14 @@ const (
|
|||
maxWidth = 80
|
||||
)
|
||||
|
||||
var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
||||
var (
|
||||
helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
||||
yellow = lipgloss.Color("#FDFF8C")
|
||||
pink = lipgloss.Color("#FF7CCB")
|
||||
)
|
||||
|
||||
func main() {
|
||||
prog := progress.New(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))
|
||||
prog := progress.New(progress.WithScaled(true), progress.WithColors(pink, yellow))
|
||||
|
||||
if _, err := tea.NewProgram(model{progress: prog}).Run(); err != nil {
|
||||
fmt.Println("Oh no!", err)
|
||||
|
|
|
|||
4
go.mod
4
go.mod
|
|
@ -8,8 +8,8 @@ toolchain go1.24.4
|
|||
|
||||
require (
|
||||
github.com/charmbracelet/colorprofile v0.3.3
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251112162901-46098fed0961
|
||||
github.com/charmbracelet/x/ansi v0.11.1-0.20251110210702-903592506081
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114211315-f6a8e3732033
|
||||
github.com/charmbracelet/x/ansi v0.11.1
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f
|
||||
github.com/charmbracelet/x/term v0.2.2
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0
|
||||
|
|
|
|||
8
go.sum
8
go.sum
|
|
@ -2,10 +2,10 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp
|
|||
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
|
||||
github.com/charmbracelet/colorprofile v0.3.3 h1:DjJzJtLP6/NZ8p7Cgjno0CKGr7wwRJGxWUwh2IyhfAI=
|
||||
github.com/charmbracelet/colorprofile v0.3.3/go.mod h1:nB1FugsAbzq284eJcjfah2nhdSLppN2NqvfotkfRYP4=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251112162901-46098fed0961 h1:qneAb6lrvZEaliI3g91vFDYf4kCpotKU0bRXijfHRqA=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251112162901-46098fed0961/go.mod h1:ung4G52QJm6rlFYPYqPelzBHWWy966P9VMonX7UGT5g=
|
||||
github.com/charmbracelet/x/ansi v0.11.1-0.20251110210702-903592506081 h1:gWeRo2N77OeiZAL47lzvIot9VPpTzxT5ahdzQIyHEDY=
|
||||
github.com/charmbracelet/x/ansi v0.11.1-0.20251110210702-903592506081/go.mod h1:M49wjzpIujwPceJ+t5w3qh2i87+HRtHohgb5iTyepL0=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114211315-f6a8e3732033 h1:8yh54FdK5bXVF9Oy51C+glAV/QblG6KpXl88alZNOtU=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114211315-f6a8e3732033/go.mod h1:6lfcr3MNP+kZR25sF1nQwJFuQnNYBlFy3PGX5rvslXc=
|
||||
github.com/charmbracelet/x/ansi v0.11.1 h1:iXAC8SyMQDJgtcz9Jnw+HU8WMEctHzoTAETIeA3JXMk=
|
||||
github.com/charmbracelet/x/ansi v0.11.1/go.mod h1:M49wjzpIujwPceJ+t5w3qh2i87+HRtHohgb5iTyepL0=
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f h1:UytXHv0UxnsDFmL/7Z9Q5SBYPwSuRLXHbwx+6LycZ2w=
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
|
||||
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
||||
|
|
|
|||
2
input.go
2
input.go
|
|
@ -47,6 +47,8 @@ func (p *Program) translateInputEvent(e uv.Event) Msg {
|
|||
return TerminalVersionMsg(e)
|
||||
case uv.KeyboardEnhancementsEvent:
|
||||
return KeyboardEnhancementsMsg(e)
|
||||
case uv.ModeReportEvent:
|
||||
return ModeReportMsg(e)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,6 @@ func (n nilRenderer) start() {}
|
|||
// clearScreen implements renderer.
|
||||
func (n nilRenderer) clearScreen() {}
|
||||
|
||||
// enterAltScreen implements renderer.
|
||||
func (n nilRenderer) enterAltScreen() {}
|
||||
|
||||
// exitAltScreen implements renderer.
|
||||
func (n nilRenderer) exitAltScreen() {}
|
||||
|
||||
// hideCursor implements renderer.
|
||||
func (n nilRenderer) hideCursor() {}
|
||||
|
||||
// insertAbove implements renderer.
|
||||
func (n nilRenderer) insertAbove(string) {}
|
||||
|
||||
|
|
@ -34,9 +25,6 @@ func (n nilRenderer) resize(int, int) {}
|
|||
// setColorProfile implements renderer.
|
||||
func (n nilRenderer) setColorProfile(colorprofile.Profile) {}
|
||||
|
||||
// showCursor implements renderer.
|
||||
func (n nilRenderer) showCursor() {}
|
||||
|
||||
// flush implements the Renderer interface.
|
||||
func (nilRenderer) flush(bool) error { return nil }
|
||||
|
||||
|
|
@ -54,3 +42,6 @@ func (nilRenderer) writeString(string) (int, error) { return 0, nil }
|
|||
|
||||
// hit implements the Renderer interface.
|
||||
func (n nilRenderer) hit(MouseMsg) []Msg { return nil }
|
||||
|
||||
// setSyncdUpdates implements the Renderer interface.
|
||||
func (n nilRenderer) setSyncdUpdates(bool) {}
|
||||
|
|
|
|||
13
renderer.go
13
renderer.go
|
|
@ -36,17 +36,8 @@ type renderer interface {
|
|||
// insertAbove inserts unmanaged lines above the renderer.
|
||||
insertAbove(string)
|
||||
|
||||
// enterAltScreen enters the alternate screen buffer.
|
||||
enterAltScreen()
|
||||
|
||||
// exitAltScreen exits the alternate screen buffer.
|
||||
exitAltScreen()
|
||||
|
||||
// showCursor shows the cursor.
|
||||
showCursor()
|
||||
|
||||
// hideCursor hides the cursor.
|
||||
hideCursor()
|
||||
// setSyncdUpdates sets whether to use synchronized updates.
|
||||
setSyncdUpdates(bool)
|
||||
|
||||
// resize notify the renderer of a terminal resize.
|
||||
resize(int, int)
|
||||
|
|
|
|||
44
screen.go
44
screen.go
|
|
@ -1,5 +1,7 @@
|
|||
package tea
|
||||
|
||||
import "github.com/charmbracelet/x/ansi"
|
||||
|
||||
// WindowSizeMsg is used to report the terminal size. It's sent to Update once
|
||||
// initially and then on every terminal resize. Note that Windows does not
|
||||
// have support for reporting when resizes occur as it does not support the
|
||||
|
|
@ -31,3 +33,45 @@ type LayerHitMsg struct {
|
|||
ID string
|
||||
Mouse MouseMsg
|
||||
}
|
||||
|
||||
// ModeReportMsg is a message that represents a mode report event (DECRPM).
|
||||
//
|
||||
// This is sent by the terminal in response to a request for a terminal mode
|
||||
// report (DECRQM). It indicates the current setting of a specific terminal
|
||||
// mode like cursor visibility, mouse tracking, etc.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// ```go
|
||||
// func (m model) Init() tea.Cmd {
|
||||
// // Does my terminal support reporting focus events?
|
||||
// return tea.Raw(ansi.RequestModeFocusEvent)
|
||||
// }
|
||||
//
|
||||
// func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
// switch msg := msg.(type) {
|
||||
// case tea.ModeReportMsg:
|
||||
// if msg.Mode == ansi.ModeFocusEvent && !msg.Value.IsNotRecognized() {
|
||||
// // Terminal supports focus events
|
||||
// m.supportsFocus = true
|
||||
// }
|
||||
// }
|
||||
// return m, nil
|
||||
// }
|
||||
//
|
||||
// func (m model) View() tea.View {
|
||||
// var view tea.View
|
||||
// view.ReportFocus = m.supportsFocus
|
||||
// view.SetContent(fmt.Sprintf("Terminal supports focus events: %v", m.supportsFocus))
|
||||
// return view
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// See: https://vt100.net/docs/vt510-rm/DECRPM.html
|
||||
type ModeReportMsg struct {
|
||||
// Mode is the mode number.
|
||||
Mode ansi.Mode
|
||||
|
||||
// Value is the mode value.
|
||||
Value ansi.ModeSetting
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ type testViewOpts struct {
|
|||
mouseMode MouseMode
|
||||
showCursor bool
|
||||
disableBp bool
|
||||
disableKe bool
|
||||
keyReleases bool
|
||||
bgColor color.Color
|
||||
}
|
||||
|
|
@ -49,6 +48,13 @@ func (m *testViewModel) Update(msg Msg) (Model, Cmd) {
|
|||
func (m *testViewModel) View() View {
|
||||
v := m.testModel.View()
|
||||
v.AltScreen = m.opts.altScreen
|
||||
v.MouseMode = m.opts.mouseMode
|
||||
v.DisableBracketedPasteMode = m.opts.disableBp
|
||||
v.KeyboardEnhancements.ReportEventTypes = m.opts.keyReleases
|
||||
v.BackgroundColor = m.opts.bgColor
|
||||
if m.opts.showCursor {
|
||||
v.Cursor = NewCursor(0, 0)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
|
@ -112,8 +118,8 @@ func TestViewModel(t *testing.T) {
|
|||
{
|
||||
name: "kitty_stop_startreleases",
|
||||
opts: []testViewOpts{
|
||||
{disableKe: true},
|
||||
{disableKe: false, keyReleases: true},
|
||||
{},
|
||||
{keyReleases: true},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
74
tea.go
74
tea.go
|
|
@ -96,6 +96,19 @@ type Hittable interface {
|
|||
|
||||
// NewView is a helper function to create a new [View] with the given string or
|
||||
// [Layer].
|
||||
//
|
||||
// This function accepts any type and tries to convert it to a [Layer]. If the
|
||||
// type is not a string, [fmt.Stringer], or [Layer], it will be converted to a
|
||||
// string using [fmt.Sprintf].
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// ```go
|
||||
// layer1 := lipgloss.NewLayer("Hello, ") // X == 0 and Y == 0
|
||||
// layer2 := lipgloss.NewLayer("World!").X(7).Y(1)
|
||||
// canvas := lipgloss.NewCanvas(layer1, layer2)
|
||||
// v := tea.NewView(canvas)
|
||||
// ```
|
||||
func NewView(s any) View {
|
||||
var view View
|
||||
view.SetContent(s)
|
||||
|
|
@ -111,10 +124,12 @@ type View struct {
|
|||
//
|
||||
// Example:
|
||||
//
|
||||
// ```go
|
||||
// layer1 := lipgloss.NewLayer("Hello, ") // X == 0 and Y == 0
|
||||
// layer2 := lipgloss.NewLayer("World!").X(7).Y(1)
|
||||
// canvas := lipgloss.NewCanvas(layer1, layer2)
|
||||
// v := tea.NewView(canvas)
|
||||
// ```
|
||||
Content Layer
|
||||
|
||||
// Cursor represents the cursor position, style, and visibility on the
|
||||
|
|
@ -240,6 +255,20 @@ type KeyboardEnhancements struct {
|
|||
}
|
||||
|
||||
// SetContent sets the content of the view to the value.
|
||||
//
|
||||
// This function accepts any type and tries to convert it to a [Layer]. If the
|
||||
// type is not a string, [fmt.Stringer], or [Layer], it will be converted to a
|
||||
// string using [fmt.Sprintf].
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// ```go
|
||||
// var v tea.View
|
||||
// layer1 := lipgloss.NewLayer("Hello, ") // X == 0 and Y == 0
|
||||
// layer2 := lipgloss.NewLayer("World!").X(7).Y(1)
|
||||
// canvas := lipgloss.NewCanvas(layer1, layer2)
|
||||
// v.SetContent(canvas)
|
||||
// ```
|
||||
func (v *View) SetContent(s any) {
|
||||
switch vi := s.(type) {
|
||||
case string:
|
||||
|
|
@ -761,6 +790,13 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
|
|||
go p.Send(m) // send hit messages
|
||||
}
|
||||
|
||||
case ModeReportMsg:
|
||||
if msg.Mode == ansi.ModeSynchronizedOutput && msg.Value.IsReset() {
|
||||
// The terminal supports synchronized output and it's
|
||||
// currently disabled, so we can enable it on the renderer.
|
||||
p.renderer.setSyncdUpdates(true)
|
||||
}
|
||||
|
||||
case readClipboardMsg:
|
||||
p.execute(ansi.RequestSystemClipboard)
|
||||
|
||||
|
|
@ -911,6 +947,34 @@ func (p *Program) execBatchMsg(msg BatchMsg) {
|
|||
wg.Wait() // wait for all commands from batch msg to finish
|
||||
}
|
||||
|
||||
// shouldQuerySynchronizedOutput determines whether the terminal should be
|
||||
// queried for synchronized output support (mode 2026).
|
||||
//
|
||||
// This function checks for terminals that are known to support mode 2026,
|
||||
// while excluding SSH sessions which may be unreliable, unless it's a
|
||||
// known-good terminal like Windows Terminal.
|
||||
//
|
||||
// The function returns true for:
|
||||
// - Terminals without TERM_PROGRAM set and not in SSH sessions
|
||||
// - Windows Terminal (WT_SESSION is set)
|
||||
// - Terminals with TERM_PROGRAM set (except Apple Terminal) and not in SSH sessions
|
||||
// - Specific terminal types: ghostty, wezterm, alacritty, kitty, rio
|
||||
func shouldQuerySynchronizedOutput(environ uv.Environ) bool {
|
||||
termType := environ.Getenv("TERM")
|
||||
termProg, okTermProg := environ.LookupEnv("TERM_PROGRAM")
|
||||
_, okSSHTTY := environ.LookupEnv("SSH_TTY")
|
||||
_, okWTSession := environ.LookupEnv("WT_SESSION")
|
||||
|
||||
return (!okTermProg && !okSSHTTY) ||
|
||||
okWTSession ||
|
||||
(okTermProg && !strings.Contains(termProg, "Apple") && !okSSHTTY) ||
|
||||
strings.Contains(termType, "ghostty") ||
|
||||
strings.Contains(termType, "wezterm") ||
|
||||
strings.Contains(termType, "alacritty") ||
|
||||
strings.Contains(termType, "kitty") ||
|
||||
strings.Contains(termType, "rio")
|
||||
}
|
||||
|
||||
// Run initializes the program and runs its event loops, blocking until it gets
|
||||
// terminated by either [Program.Quit], [Program.Kill], or its signal handler.
|
||||
// Returns the final model.
|
||||
|
|
@ -1014,13 +1078,15 @@ func (p *Program) Run() (returnModel Model, returnErr error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Hide the cursor before starting the renderer. This is handled by the
|
||||
// renderer so we don't need to write the sequence here.
|
||||
p.renderer.hideCursor()
|
||||
|
||||
// Start the renderer.
|
||||
p.startRenderer()
|
||||
|
||||
if shouldQuerySynchronizedOutput(p.environ) {
|
||||
// Query for synchronized updates support (mode 2026). If the terminal
|
||||
// supports it, the renderer will enable it once we get the response.
|
||||
p.execute(ansi.RequestModeSynchronizedOutput)
|
||||
}
|
||||
|
||||
// Initialize the program.
|
||||
initCmd := model.Init()
|
||||
if initCmd != nil {
|
||||
|
|
|
|||
2
testdata/TestClearMsg/bg_fg_cur_color.golden
vendored
2
testdata/TestClearMsg/bg_fg_cur_color.golden
vendored
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h]10;?]11;?]12;?
|
||||
[?25l[?2004h[=1;1u
success
[J[?25h[?2004l[=0;1u[?2026$p]10;?]11;?]12;?
|
||||
2
testdata/TestClearMsg/clear_screen.golden
vendored
2
testdata/TestClearMsg/clear_screen.golden
vendored
|
|
@ -1 +1 @@
|
|||
[?25l
[?2004h[=1;1u[Jsuccess[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[=1;1u[Jsuccess
[J[?25h[?2004l[=0;1u[?2026$p
|
||||
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h]52;c;?]52;c;c3VjY2Vzcw==
|
||||
[?25l[?2004h[=1;1u
success
[J[?25h[?2004l[=0;1u[?2026$p]52;c;?]52;c;c3VjY2Vzcw==
|
||||
2
testdata/TestViewModel/altscreen.golden
vendored
2
testdata/TestViewModel/altscreen.golden
vendored
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[=1;1u
success
[J[?25h[?2004l[=0;1u[?2026$p
|
||||
|
|
@ -1 +1 @@
|
|||
[?25l[?1049h[?2004h[=1;1u[H[2Jsuccess[?25l[?1049l[?25h[?2004l[=0;1u[?25h
|
||||
[?1049h[?25l[?2004h[=1;1u[H[2Jsuccess[?1049l[?25h[?2004l[=0;1u[?2026$p
|
||||
2
testdata/TestViewModel/bg_set_color.golden
vendored
2
testdata/TestViewModel/bg_set_color.golden
vendored
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[=1;1u]11;#ffffff
success
[J[?25h[?2004l]111[=0;1u[?2026$p
|
||||
2
testdata/TestViewModel/bp_stop_start.golden
vendored
2
testdata/TestViewModel/bp_stop_start.golden
vendored
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[=1;1u
success
[J[?25h[?2004l[=0;1u[?2026$p
|
||||
2
testdata/TestViewModel/cursor_hide.golden
vendored
2
testdata/TestViewModel/cursor_hide.golden
vendored
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[=1;1u
success
[J[?25h[?2004l[=0;1u[?2026$p
|
||||
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?2004h[=1;1u[1 q
success
[?25h[J[?2004l[=0;1u[?2026$p
|
||||
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[=3;1u
success
[J[?25h[?2004l[=0;1u[?2026$p
|
||||
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[?1003h[?1006h[=1;1u
success
[J[?25h[?2004l[?1002l[?1003l[?1006l[=0;1u[?2026$p
|
||||
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[?1002h[?1006h[=1;1u
success
[J[?25h[?2004l[?1002l[?1003l[?1006l[=0;1u[?2026$p
|
||||
2
testdata/TestViewModel/mouse_disable.golden
vendored
2
testdata/TestViewModel/mouse_disable.golden
vendored
|
|
@ -1 +1 @@
|
|||
[?25l[?2004h[=1;1u
success[?25l
[J[?25h[?2004l[=0;1u[?25h
|
||||
[?25l[?2004h[=1;1u
success
[J[?25h[?2004l[=0;1u[?2026$p
|
||||
|
|
@ -1,37 +1,29 @@
|
|||
module tutorial
|
||||
|
||||
go 1.23.0
|
||||
go 1.24.2
|
||||
|
||||
toolchain go1.23.7
|
||||
toolchain go1.24.10
|
||||
|
||||
require github.com/charmbracelet/bubbletea/v2 v2.0.0-20240918180721-14cb6b5de1d2
|
||||
|
||||
require (
|
||||
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.3.1 // indirect
|
||||
github.com/charmbracelet/glamour/v2 v2.0.0-20250513163904-eeeced3bb3c6 // indirect
|
||||
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.1.0.20250513162854-28902d027c40 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.9.3-0.20250516160309-24eee56f89fa // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.14-0.20250516160309-24eee56f89fa // indirect
|
||||
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
|
||||
github.com/charmbracelet/x/input v0.3.5-0.20250509021451-13796e822d86 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/charmbracelet/x/windows v0.2.1 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.0 // indirect
|
||||
github.com/gorilla/css v1.0.1 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.3.3 // indirect
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114171239-77547d5f3edd // indirect
|
||||
github.com/charmbracelet/x/ansi v0.11.1 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||
github.com/charmbracelet/x/termios v0.1.1 // indirect
|
||||
github.com/charmbracelet/x/windows v0.2.2 // indirect
|
||||
github.com/clipperhouse/displaywidth v0.5.0 // indirect
|
||||
github.com/clipperhouse/stringish v0.1.1 // indirect
|
||||
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.19 // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
github.com/yuin/goldmark v1.7.8 // indirect
|
||||
github.com/yuin/goldmark-emoji v1.0.5 // indirect
|
||||
golang.org/x/net v0.39.0 // indirect
|
||||
golang.org/x/sync v0.13.0 // indirect
|
||||
golang.org/x/sys v0.32.0 // indirect
|
||||
golang.org/x/text v0.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
|
||||
golang.org/x/sync v0.18.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/charmbracelet/bubbletea/v2 => ../
|
||||
|
|
|
|||
|
|
@ -1,62 +1,38 @@
|
|||
github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E=
|
||||
github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I=
|
||||
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
|
||||
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
|
||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||
github.com/charmbracelet/colorprofile v0.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40=
|
||||
github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0=
|
||||
github.com/charmbracelet/glamour/v2 v2.0.0-20250513163904-eeeced3bb3c6 h1:AKhOV8dSRU3KpqMgpGME9JU7ouumB2S6hMmD6PRJeTc=
|
||||
github.com/charmbracelet/glamour/v2 v2.0.0-20250513163904-eeeced3bb3c6/go.mod h1:7xBAUTCSADx9mHG0uBf4NDoVpYxMzIQ2j/NMLGdFsFM=
|
||||
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.1.0.20250513162854-28902d027c40 h1:SxOUomYAVo5zh+6WCH1bGshlAnSKP0ZeovI0FHAl9kg=
|
||||
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.1.0.20250513162854-28902d027c40/go.mod h1:tRlx/Hu0lo/j9viunCN2H+Ze6JrmdjQlXUQvvArgaOc=
|
||||
github.com/charmbracelet/x/ansi v0.9.2 h1:92AGsQmNTRMzuzHEYfCdjQeUzTrgE1vfO5/7fEVoXdY=
|
||||
github.com/charmbracelet/x/ansi v0.9.2/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
||||
github.com/charmbracelet/x/ansi v0.9.3-0.20250516160309-24eee56f89fa h1:JU05TLAB6nOEL46bxHDV/+e8umBX32ODsGbVkc7o7bk=
|
||||
github.com/charmbracelet/x/ansi v0.9.3-0.20250516160309-24eee56f89fa/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.14-0.20250505150409-97991a1f17d1 h1:MTSs/nsZNfZPbYk/r9hluK2BtwoqvEYruAujNVwgDv0=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.14-0.20250505150409-97991a1f17d1/go.mod h1:xBlh2Yi3DL3zy/2n15kITpg0YZardf/aa/hgUaIM6Rk=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.14-0.20250516160309-24eee56f89fa h1:lphz0Z3rsiOtMYiz8axkT24i9yFiueDhJbzyNUADmME=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.14-0.20250516160309-24eee56f89fa/go.mod h1:xBlh2Yi3DL3zy/2n15kITpg0YZardf/aa/hgUaIM6Rk=
|
||||
github.com/charmbracelet/colorprofile v0.3.3 h1:DjJzJtLP6/NZ8p7Cgjno0CKGr7wwRJGxWUwh2IyhfAI=
|
||||
github.com/charmbracelet/colorprofile v0.3.3/go.mod h1:nB1FugsAbzq284eJcjfah2nhdSLppN2NqvfotkfRYP4=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114171239-77547d5f3edd h1:oSO6mMvVUMsxAceDne7XfMr1KPzxFwCkFf8Yw8zkb7I=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251114171239-77547d5f3edd/go.mod h1:6lfcr3MNP+kZR25sF1nQwJFuQnNYBlFy3PGX5rvslXc=
|
||||
github.com/charmbracelet/x/ansi v0.11.1 h1:iXAC8SyMQDJgtcz9Jnw+HU8WMEctHzoTAETIeA3JXMk=
|
||||
github.com/charmbracelet/x/ansi v0.11.1/go.mod h1:M49wjzpIujwPceJ+t5w3qh2i87+HRtHohgb5iTyepL0=
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f h1:UytXHv0UxnsDFmL/7Z9Q5SBYPwSuRLXHbwx+6LycZ2w=
|
||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
|
||||
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf h1:rLG0Yb6MQSDKdB52aGX55JT1oi0P0Kuaj7wi1bLUpnI=
|
||||
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf/go.mod h1:B3UgsnsBZS/eX42BlaNiJkD1pPOUa+oF1IYC6Yd2CEU=
|
||||
github.com/charmbracelet/x/input v0.3.5-0.20250509021451-13796e822d86 h1:BxAEmOBIDajkgao3EsbBxKQCYvgYPGdT62WASLvtf4Y=
|
||||
github.com/charmbracelet/x/input v0.3.5-0.20250509021451-13796e822d86/go.mod h1:62Rp/6EtTxoeJDSdtpA3tJp3y3ZRpsiekBSje+K8htA=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
github.com/charmbracelet/x/windows v0.2.1 h1:3x7vnbpQrjpuq/4L+I4gNsG5htYoCiA5oe9hLjAij5I=
|
||||
github.com/charmbracelet/x/windows v0.2.1/go.mod h1:ptZp16h40gDYqs5TSawSVW+yiLB13j4kSMA0lSCHL0M=
|
||||
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
||||
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
||||
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
||||
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
||||
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
||||
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
||||
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
|
||||
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
|
||||
github.com/clipperhouse/displaywidth v0.5.0 h1:AIG5vQaSL2EKqzt0M9JMnvNxOCRTKUc4vUnLWGgP89I=
|
||||
github.com/clipperhouse/displaywidth v0.5.0/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o=
|
||||
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
|
||||
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
|
||||
github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4=
|
||||
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
|
||||
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
github.com/yuin/goldmark-emoji v1.0.5 h1:EMVWyCGPlXJfUXBXpuMu+ii3TIaxbVBnEX9uaDC4cIk=
|
||||
github.com/yuin/goldmark-emoji v1.0.5/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
|
||||
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
|
||||
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
|
||||
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
|
||||
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
|
||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
|
|
|
|||
Loading…
Reference in a new issue