-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support displaying images data from
tui i
(#55)
* Add lipgloss table Signed-off-by: Evan Harris <echarris@smcm.edu> * Add lipgloss table part 2 Signed-off-by: Evan Harris <echarris@smcm.edu> * Add stub for model Signed-off-by: Evan Harris <echarris@smcm.edu> * Make fmt Signed-off-by: Evan Harris <echarris@smcm.edu> * Add debug model stub Signed-off-by: Evan Harris <echarris@smcm.edu> * Rename welcome model -> home Signed-off-by: Evan Harris <echarris@smcm.edu> * Do not print to the console when in tui mode Signed-off-by: Evan Harris <echarris@smcm.edu> * Support tui -> i Signed-off-by: Evan Harris <echarris@smcm.edu> * Rm dead code Signed-off-by: Evan Harris <echarris@smcm.edu> * Reenable debug and dry up code Signed-off-by: Evan Harris <echarris@smcm.edu> * Run Fmt Signed-off-by: Evan Harris <echarris@smcm.edu> * Use a bubble tea specific name Signed-off-by: Evan Harris <echarris@smcm.edu> * Use bubble tea specific naming for image model Signed-off-by: Evan Harris <echarris@smcm.edu> * Delete duplicate images TUI model Signed-off-by: Evan Harris <echarris@smcm.edu> * Swap in bubble tea specific names for images model Signed-off-by: Evan Harris <echarris@smcm.edu> * Swap in bubble tea specific names for home model struct Signed-off-by: Evan Harris <echarris@smcm.edu> * Swap out Models for TUIs to improve naming for manging multiple tui models Signed-off-by: Evan Harris <echarris@smcm.edu> * Swap in bubble tea specific names for debug tui Signed-off-by: Evan Harris <echarris@smcm.edu> --------- Signed-off-by: Evan Harris <echarris@smcm.edu>
- Loading branch information
1 parent
d44918c
commit 89f9cf2
Showing
10 changed files
with
208 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package common | ||
|
||
const ( | ||
GetImagesEvent EventType = "getImages" | ||
) | ||
|
||
type ( | ||
// EventType identifies the type of event | ||
EventType string | ||
// Event represents an event in the lifecycle of a resource | ||
Event struct { | ||
Type EventType | ||
Data interface{} | ||
} | ||
) |
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,67 @@ | ||
package debug | ||
|
||
import ( | ||
"github.com/charmbracelet/bubbles/key" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/common" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/keys" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
// TUI represents the state of the TUI. | ||
type TUI struct { | ||
standalone bool | ||
} | ||
|
||
// InitialTUI returns the initial state of the model. | ||
func InitialTUI(standalone bool) *TUI { | ||
m := &TUI{ | ||
standalone: standalone, | ||
} | ||
|
||
return m | ||
} | ||
|
||
func (m TUI) Init() tea.Cmd { | ||
// Just return `nil`, which means "no I/O right now, please." | ||
return nil | ||
} | ||
|
||
// Update is called to handle user input and update the model's state. | ||
func (m TUI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch { | ||
case key.Matches(msg, keys.Global.Quit): | ||
return m, tea.Quit | ||
// NOTE -> We should only support this back navigation, | ||
// if the images tui is not standalone | ||
case key.Matches(msg, keys.Global.Back): | ||
return common.TUIsInstance.Home, nil | ||
} | ||
} | ||
return m, nil | ||
} | ||
|
||
// View returns the view that should be displayed. | ||
func (m TUI) View() string { | ||
var components []string | ||
|
||
content := "Debug support coming soon" | ||
|
||
components = append(components, content) | ||
|
||
components = append(components, m.help()) | ||
|
||
return lipgloss.JoinVertical(lipgloss.Left, | ||
components..., | ||
) | ||
} | ||
|
||
func (m TUI) help() string { | ||
if m.standalone { | ||
return common.HelpStyle("• q: quit") | ||
} | ||
return common.HelpStyle("• esc: back • q: quit") | ||
} |
Oops, something went wrong.