-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: terminal user interface added (#3)
* feat: terminal user interface added * fix: gosimple recommendations Co-authored-by: Britton Hayes <[email protected]>
- Loading branch information
1 parent
dbdeb53
commit aa14f63
Showing
10 changed files
with
436 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package ui | ||
|
||
import ( | ||
"github.com/charmbracelet/bubbles/key" | ||
) | ||
|
||
type keymap struct { | ||
Up key.Binding | ||
Down key.Binding | ||
Left key.Binding | ||
Right key.Binding | ||
Roll key.Binding | ||
Clear key.Binding | ||
Help key.Binding | ||
Quit key.Binding | ||
} | ||
|
||
var DefaultKeyMap = keymap{ | ||
Up: key.NewBinding( | ||
key.WithKeys("k", "up"), | ||
key.WithHelp("↑/k", "add dice"), | ||
), | ||
Down: key.NewBinding( | ||
key.WithKeys("j", "down"), | ||
key.WithHelp("↓/j", "remove dice"), | ||
), | ||
Left: key.NewBinding( | ||
key.WithKeys("h", "left"), | ||
key.WithHelp("🡠/h", "prev die"), | ||
), | ||
Right: key.NewBinding( | ||
key.WithKeys("l", "right"), | ||
key.WithHelp("🡢/l", "next die"), | ||
), | ||
Roll: key.NewBinding( | ||
key.WithKeys("e", "enter"), | ||
key.WithHelp("e/enter", "roll dice"), | ||
), | ||
Clear: key.NewBinding( | ||
key.WithKeys("c", "ctrl+l"), | ||
key.WithHelp("c", "clear"), | ||
), | ||
Help: key.NewBinding( | ||
key.WithKeys("?"), | ||
key.WithHelp("?", "help"), | ||
), | ||
Quit: key.NewBinding( | ||
key.WithKeys("q", "ctrl+c", "esc"), | ||
key.WithHelp("q", "quit"), | ||
), | ||
} | ||
|
||
// ShortHelp returns keybindings to be shown in the mini help view. It's part | ||
// of the key.Map interface. | ||
func (k keymap) ShortHelp() []key.Binding { | ||
return []key.Binding{k.Help, k.Roll} | ||
} | ||
|
||
// FullHelp returns keybindings for the expanded help view. It's part of the | ||
// key.Map interface. | ||
func (k keymap) FullHelp() [][]key.Binding { | ||
return [][]key.Binding{ | ||
{k.Up, k.Down, k.Roll}, | ||
{k.Quit, k.Help}, | ||
} | ||
} |
Oops, something went wrong.