• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

charmbracelet / bubbletea / 10635500654
50%
main: 72%

Build:
Build:
LAST BUILD BRANCH: windows-fkeys
DEFAULT BRANCH: main
Ran 30 Aug 2024 03:46PM UTC
Jobs 1
Files 29
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

30 Aug 2024 03:45PM UTC coverage: 63.238% (-8.6%) from 71.831%
10635500654

Pull #1118

github

web-flow
(v2) Use KeyMsg/MouseMsg interfaces (#1111)

This replaces KeyMsg and MouseMsg with interfaces that catch their
respective types. For example, both KeyPressMsg and KeyReleaseMsg
implement KeyMsg. Same goes for MouseClickMsg, MouseReleaseMsg, etc,
they all implement MouseMsg. This makes it possible to switch on the
interface type to catch all events of the same input message type.

New API:

```go

// KeyMsg represents a key event. This can be either a key press or a key
// release event.
type KeyMsg interface {
	fmt.Stringer

	// Key returns the underlying key event.
	Key() Key
}


// Key represents a Key press or release event. It contains information about
// the Key pressed, like the runes, the type of Key, and the modifiers pressed.
// There are a couple general patterns you could use to check for key presses
// or releases:
//
//	// Switch on the string representation of the key (shorter)
//	switch msg := msg.(type) {
//	case KeyPressMsg:
//	    switch msg.String() {
//	    case "enter":
//	        fmt.Println("you pressed enter!")
//	    case "a":
//	        fmt.Println("you pressed a!")
//	    }
//	}
//
//	// Switch on the key type (more foolproof)
//	switch msg := msg.(type) {
//	case KeyMsg:
//	    // catch both KeyPressMsg and KeyReleaseMsg
//	    switch key := msg.Key(); key.Code {
//	    case KeyEnter:
//	        fmt.Println("you pressed enter!")
//	    default:
//	        switch key.Text {
//	        case "a":
//	            fmt.Println("you pressed a!")
//	        }
//	    }
//	}
//
// Note that [Key.Text] will be empty for special keys like [KeyEnter],
// [KeyTab], and for keys that don't represent printable characters like key
// combos with modifier keys. In other words, [Key.Text] is populated only for
// keys that represent printable characters shifted or unshifted (like 'a',
// 'A', '1', '!', etc.).
type Key struct {
	// Text contains the actual characters received. This usua... (continued)
Pull Request #1118: (v2) Bubble Tea API

1470 of 2335 new or added lines in 24 files covered. (62.96%)

13 existing lines in 4 files now uncovered.

2121 of 3354 relevant lines covered (63.24%)

243.77 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
6
64.52
-6.91% commands.go
6
33.33
input.go
6
40.0
-22.5% nil_renderer.go
8
88.41
driver.go
12
0.0
da1.go
12
90.7
-7.91% mouse.go
13
35.0
clipboard.go
13
46.15
7.69% screen.go
15
56.25
-38.19% key.go
15
60.33
6.67% tty.go
15
55.88
xterm.go
16
95.32
table.go
23
52.96
-7.86% standard_renderer.go
29
59.0
-24.1% options.go
29
0.0
termcap.go
40
61.9
kitty.go
62
74.27
terminfo.go
96
22.58
color.go
123
63.53
-9.49% tea.go
149
0.0
win32input.go
177
70.7
parse.go

Uncovered Existing Lines

Lines Coverage ∆ File
1
52.96
-7.86% standard_renderer.go
2
46.15
7.69% screen.go
4
63.53
-9.49% tea.go
6
56.25
-38.19% key.go
Jobs
ID Job ID Ran Files Coverage
1 10635500654.1 30 Aug 2024 03:46PM UTC 29
63.24
GitHub Action Run
Source Files on build 10635500654
  • Tree
  • List 29
  • Changed 10
  • Source Changed 0
  • Coverage Changed 9
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Pull Request #1118
  • PR Base - main (#10633431370)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc