-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexandre Bourget
committed
Aug 6, 2024
1 parent
f1124cd
commit 35a720a
Showing
24 changed files
with
703 additions
and
372 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ type Component interface { | |
tea.Model | ||
help.KeyMap | ||
SetSize(width, height int) | ||
GetWidth() int | ||
GetHeight() int | ||
} |
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,33 @@ | ||
package common | ||
|
||
import "github.com/charmbracelet/bubbles/key" | ||
|
||
func ShortToFullHelp(comp Component) [][]key.Binding { | ||
shortHelp := comp.ShortHelp() | ||
fullHelp := make([][]key.Binding, len(shortHelp)) | ||
for i, binding := range shortHelp { | ||
fullHelp[i] = []key.Binding{binding} | ||
} | ||
return fullHelp | ||
} | ||
|
||
type SimpleHelp struct { | ||
Bindings []key.Binding | ||
} | ||
|
||
func NewSimpleHelp(bindings ...key.Binding) SimpleHelp { | ||
return SimpleHelp{Bindings: bindings} | ||
} | ||
|
||
func (h SimpleHelp) ShortHelp() []key.Binding { | ||
return h.Bindings | ||
} | ||
|
||
func (h SimpleHelp) FullHelp() [][]key.Binding { | ||
shortHelp := h.ShortHelp() | ||
fullHelp := make([][]key.Binding, len(shortHelp)) | ||
for i, binding := range shortHelp { | ||
fullHelp[i] = []key.Binding{binding} | ||
} | ||
return fullHelp | ||
} |
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
Oops, something went wrong.