mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
Implemented ErrorDialogBox, fixed TODO for keymap
This commit is contained in:
parent
623def1263
commit
0fe810871e
174
config/config.go
174
config/config.go
@ -57,6 +57,18 @@ type Config struct {
|
|||||||
Bottombar ThemeItemConfig
|
Bottombar ThemeItemConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorDialogBox struct {
|
||||||
|
Window struct {
|
||||||
|
Focused ThemeItemConfig
|
||||||
|
Blurred ThemeItemConfig
|
||||||
|
}
|
||||||
|
Titlebar struct {
|
||||||
|
Focused ThemeItemConfig
|
||||||
|
Blurred ThemeItemConfig
|
||||||
|
}
|
||||||
|
Bottombar ThemeItemConfig
|
||||||
|
}
|
||||||
|
|
||||||
PostsList struct {
|
PostsList struct {
|
||||||
List struct {
|
List struct {
|
||||||
Focused ThemeItemConfig
|
Focused ThemeItemConfig
|
||||||
@ -153,6 +165,114 @@ func SetDefaults(cacheDir string) {
|
|||||||
viper.SetDefault("Debug", "true")
|
viper.SetDefault("Debug", "true")
|
||||||
viper.SetDefault("Log", path.Join(cacheDir, "gobbs.log"))
|
viper.SetDefault("Log", path.Join(cacheDir, "gobbs.log"))
|
||||||
|
|
||||||
|
// DialogBox Window:Focused
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Focused.Margin",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Focused.Padding",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Border",
|
||||||
|
lipgloss.ThickBorder())
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Sides",
|
||||||
|
[]bool{false, true, true, true},
|
||||||
|
)
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#00ffff", Dark: "#00ffff"})
|
||||||
|
|
||||||
|
// DialogBox Window:Blurred
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Blurred.Margin",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Blurred.Padding",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Border",
|
||||||
|
lipgloss.ThickBorder())
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Sides",
|
||||||
|
[]bool{false, true, true, true},
|
||||||
|
)
|
||||||
|
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
||||||
|
|
||||||
|
// DialogBox Titlebar:Focused
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Margin",
|
||||||
|
[]int{0, 0, 1, 0})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Padding",
|
||||||
|
[]int{0, 1, 0, 1})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Background",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#00cccc", Dark: "#00cccc"})
|
||||||
|
|
||||||
|
// DialogBox Titlebar:Blurred
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Margin",
|
||||||
|
[]int{0, 0, 1, 0})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Padding",
|
||||||
|
[]int{0, 1, 0, 1})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Background",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
||||||
|
|
||||||
|
// DialogBox Bottombar
|
||||||
|
viper.SetDefault("Theme.DialogBox.Bottombar.Margin",
|
||||||
|
[]int{1, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Bottombar.Padding",
|
||||||
|
[]int{0, 1, 0, 1})
|
||||||
|
viper.SetDefault("Theme.DialogBox.Bottombar.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#aaaaaa", Dark: "#999999"})
|
||||||
|
|
||||||
|
// ErrorDialogBox Window:Focused
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Focused.Margin",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Focused.Padding",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Focused.Border.Border",
|
||||||
|
lipgloss.ThickBorder())
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Focused.Border.Sides",
|
||||||
|
[]bool{false, true, true, true},
|
||||||
|
)
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Focused.Border.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#00ffff", Dark: "#00ffff"})
|
||||||
|
|
||||||
|
// ErrorDialogBox Window:Blurred
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Blurred.Margin",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Blurred.Padding",
|
||||||
|
[]int{0, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Blurred.Border.Border",
|
||||||
|
lipgloss.ThickBorder())
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Blurred.Border.Sides",
|
||||||
|
[]bool{false, true, true, true},
|
||||||
|
)
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Window.Blurred.Border.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
||||||
|
|
||||||
|
// ErrorDialogBox Titlebar:Focused
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Focused.Margin",
|
||||||
|
[]int{0, 0, 1, 0})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Focused.Padding",
|
||||||
|
[]int{0, 1, 0, 1})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Focused.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Focused.Background",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#00cccc", Dark: "#00cccc"})
|
||||||
|
|
||||||
|
// ErrorDialogBox Titlebar:Blurred
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Blurred.Margin",
|
||||||
|
[]int{0, 0, 1, 0})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Blurred.Padding",
|
||||||
|
[]int{0, 1, 0, 1})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Blurred.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Titlebar.Blurred.Background",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
||||||
|
|
||||||
|
// ErrorDialogBox Bottombar
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Bottombar.Margin",
|
||||||
|
[]int{1, 0, 0, 0})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Bottombar.Padding",
|
||||||
|
[]int{0, 1, 0, 1})
|
||||||
|
viper.SetDefault("Theme.ErrorDialogBox.Bottombar.Foreground",
|
||||||
|
lipgloss.AdaptiveColor{Light: "#aaaaaa", Dark: "#999999"})
|
||||||
|
|
||||||
// PostsList List:Focused
|
// PostsList List:Focused
|
||||||
viper.SetDefault("Theme.PostsList.List.Focused.Margin",
|
viper.SetDefault("Theme.PostsList.List.Focused.Margin",
|
||||||
[]int{0, 0, 0, 0})
|
[]int{0, 0, 0, 0})
|
||||||
@ -229,60 +349,6 @@ func SetDefaults(cacheDir string) {
|
|||||||
viper.SetDefault("Theme.PostsList.ItemDetail.Selected.Foreground",
|
viper.SetDefault("Theme.PostsList.ItemDetail.Selected.Foreground",
|
||||||
lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"})
|
lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"})
|
||||||
|
|
||||||
// DialogBox Window:Focused
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Margin",
|
|
||||||
[]int{0, 0, 0, 0})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Padding",
|
|
||||||
[]int{0, 0, 0, 0})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Border",
|
|
||||||
lipgloss.ThickBorder())
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Sides",
|
|
||||||
[]bool{false, true, true, true},
|
|
||||||
)
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Foreground",
|
|
||||||
lipgloss.AdaptiveColor{Light: "#00ffff", Dark: "#00ffff"})
|
|
||||||
|
|
||||||
// DialogBox Window:Blurred
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Margin",
|
|
||||||
[]int{0, 0, 0, 0})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Padding",
|
|
||||||
[]int{0, 0, 0, 0})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Border",
|
|
||||||
lipgloss.ThickBorder())
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Sides",
|
|
||||||
[]bool{false, true, true, true},
|
|
||||||
)
|
|
||||||
viper.SetDefault("Theme.DialogBox.Window.Blurred.Border.Foreground",
|
|
||||||
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
|
||||||
|
|
||||||
// DialogBox Titlebar:Focused
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Margin",
|
|
||||||
[]int{0, 0, 1, 0})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Padding",
|
|
||||||
[]int{0, 1, 0, 1})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Foreground",
|
|
||||||
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Background",
|
|
||||||
lipgloss.AdaptiveColor{Light: "#00cccc", Dark: "#00cccc"})
|
|
||||||
|
|
||||||
// DialogBox Titlebar:Blurred
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Margin",
|
|
||||||
[]int{0, 0, 1, 0})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Padding",
|
|
||||||
[]int{0, 1, 0, 1})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Foreground",
|
|
||||||
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Background",
|
|
||||||
lipgloss.AdaptiveColor{Light: "#cccccc", Dark: "#333333"})
|
|
||||||
|
|
||||||
// DialogBox Bottombar
|
|
||||||
viper.SetDefault("Theme.DialogBox.Bottombar.Margin",
|
|
||||||
[]int{1, 0, 0, 0})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Bottombar.Padding",
|
|
||||||
[]int{0, 1, 0, 1})
|
|
||||||
viper.SetDefault("Theme.DialogBox.Bottombar.Foreground",
|
|
||||||
lipgloss.AdaptiveColor{Light: "#aaaaaa", Dark: "#999999"})
|
|
||||||
|
|
||||||
// Post Author
|
// Post Author
|
||||||
viper.SetDefault("Theme.Post.Author.Padding",
|
viper.SetDefault("Theme.Post.Author.Padding",
|
||||||
[]int{0, 1, 0, 1})
|
[]int{0, 1, 0, 1})
|
||||||
|
@ -18,6 +18,18 @@ type Theme struct {
|
|||||||
Bottombar lipgloss.Style
|
Bottombar lipgloss.Style
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorDialogBox struct {
|
||||||
|
Window struct {
|
||||||
|
Focused lipgloss.Style
|
||||||
|
Blurred lipgloss.Style
|
||||||
|
}
|
||||||
|
Titlebar struct {
|
||||||
|
Focused lipgloss.Style
|
||||||
|
Blurred lipgloss.Style
|
||||||
|
}
|
||||||
|
Bottombar lipgloss.Style
|
||||||
|
}
|
||||||
|
|
||||||
PostsList struct {
|
PostsList struct {
|
||||||
List struct {
|
List struct {
|
||||||
Focused lipgloss.Style
|
Focused lipgloss.Style
|
||||||
@ -48,6 +60,28 @@ type Theme struct {
|
|||||||
func New(cfg *config.Config) *Theme {
|
func New(cfg *config.Config) *Theme {
|
||||||
t := new(Theme)
|
t := new(Theme)
|
||||||
|
|
||||||
|
t.DialogBox.Window.Focused =
|
||||||
|
t.fromConfig(&cfg.Theme.DialogBox.Window.Focused)
|
||||||
|
t.DialogBox.Window.Blurred =
|
||||||
|
t.fromConfig(&cfg.Theme.DialogBox.Window.Blurred)
|
||||||
|
t.DialogBox.Titlebar.Focused =
|
||||||
|
t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Focused)
|
||||||
|
t.DialogBox.Titlebar.Blurred =
|
||||||
|
t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Blurred)
|
||||||
|
t.DialogBox.Bottombar =
|
||||||
|
t.fromConfig(&cfg.Theme.DialogBox.Bottombar)
|
||||||
|
|
||||||
|
t.ErrorDialogBox.Window.Focused =
|
||||||
|
t.fromConfig(&cfg.Theme.ErrorDialogBox.Window.Focused)
|
||||||
|
t.ErrorDialogBox.Window.Blurred =
|
||||||
|
t.fromConfig(&cfg.Theme.ErrorDialogBox.Window.Blurred)
|
||||||
|
t.ErrorDialogBox.Titlebar.Focused =
|
||||||
|
t.fromConfig(&cfg.Theme.ErrorDialogBox.Titlebar.Focused)
|
||||||
|
t.ErrorDialogBox.Titlebar.Blurred =
|
||||||
|
t.fromConfig(&cfg.Theme.ErrorDialogBox.Titlebar.Blurred)
|
||||||
|
t.ErrorDialogBox.Bottombar =
|
||||||
|
t.fromConfig(&cfg.Theme.ErrorDialogBox.Bottombar)
|
||||||
|
|
||||||
t.PostsList.List.Focused =
|
t.PostsList.List.Focused =
|
||||||
t.fromConfig(&cfg.Theme.PostsList.List.Focused)
|
t.fromConfig(&cfg.Theme.PostsList.List.Focused)
|
||||||
t.PostsList.List.Blurred =
|
t.PostsList.List.Blurred =
|
||||||
@ -64,16 +98,7 @@ func New(cfg *config.Config) *Theme {
|
|||||||
t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Blurred)
|
t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Blurred)
|
||||||
t.PostsList.ItemDetail.Selected =
|
t.PostsList.ItemDetail.Selected =
|
||||||
t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Selected)
|
t.fromConfig(&cfg.Theme.PostsList.ItemDetail.Selected)
|
||||||
t.DialogBox.Window.Focused =
|
|
||||||
t.fromConfig(&cfg.Theme.DialogBox.Window.Focused)
|
|
||||||
t.DialogBox.Window.Blurred =
|
|
||||||
t.fromConfig(&cfg.Theme.DialogBox.Window.Blurred)
|
|
||||||
t.DialogBox.Titlebar.Focused =
|
|
||||||
t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Focused)
|
|
||||||
t.DialogBox.Titlebar.Blurred =
|
|
||||||
t.fromConfig(&cfg.Theme.DialogBox.Titlebar.Blurred)
|
|
||||||
t.DialogBox.Bottombar =
|
|
||||||
t.fromConfig(&cfg.Theme.DialogBox.Bottombar)
|
|
||||||
t.Post.Author =
|
t.Post.Author =
|
||||||
t.fromConfig(&cfg.Theme.Post.Author)
|
t.fromConfig(&cfg.Theme.Post.Author)
|
||||||
t.Post.Subject =
|
t.Post.Subject =
|
||||||
|
@ -19,9 +19,17 @@ func (tk *ToolKit) Dialog(title string, content string) string {
|
|||||||
Width(tk.ViewWidth()).
|
Width(tk.ViewWidth()).
|
||||||
Render(title)
|
Render(title)
|
||||||
|
|
||||||
|
var bindings []string
|
||||||
|
for _, binding := range tk.keybindings {
|
||||||
|
var tmp string = ""
|
||||||
|
tmp = binding.Help().Key + " " + binding.Help().Desc
|
||||||
|
bindings = append(bindings, tmp)
|
||||||
|
}
|
||||||
|
bindings = append(bindings, "esc close")
|
||||||
|
|
||||||
bottombar := tk.theme.DialogBox.Bottombar.
|
bottombar := tk.theme.DialogBox.Bottombar.
|
||||||
Width(tk.ViewWidth()).
|
Width(tk.ViewWidth()).
|
||||||
Render("[#]r reply · esc close") // TODO
|
Render(strings.Join(bindings, " · "))
|
||||||
|
|
||||||
ui := lipgloss.JoinVertical(
|
ui := lipgloss.JoinVertical(
|
||||||
lipgloss.Center,
|
lipgloss.Center,
|
||||||
|
@ -61,6 +61,14 @@ func (tk *ToolKit) IsCached() bool {
|
|||||||
return tk.viewcache != ""
|
return tk.viewcache != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tk *ToolKit) DefaultCaching(cached bool) string {
|
||||||
|
if cached && !tk.IsFocused() && tk.IsCached() {
|
||||||
|
return tk.GetCachedView()
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (tk *ToolKit) View(m interface{}, cached bool) string {
|
func (tk *ToolKit) View(m interface{}, cached bool) string {
|
||||||
return tk.viewfunc(m, cached)
|
return tk.viewfunc(m, cached)
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,12 @@ func (m Model) View() string {
|
|||||||
|
|
||||||
func buildView(mi interface{}, cached bool) string {
|
func buildView(mi interface{}, cached bool) string {
|
||||||
var m *Model = mi.(*Model)
|
var m *Model = mi.(*Model)
|
||||||
if cached && !m.tk.IsFocused() && m.tk.IsCached() {
|
|
||||||
m.ctx.Logger.Debugln("Cached View()")
|
|
||||||
|
|
||||||
return m.tk.GetCachedView()
|
if vcache := m.tk.DefaultCaching(cached); vcache != "" {
|
||||||
|
m.ctx.Logger.Debugln("Cached View()")
|
||||||
|
return vcache
|
||||||
}
|
}
|
||||||
|
|
||||||
m.ctx.Logger.Debugln("View()")
|
m.ctx.Logger.Debugln("View()")
|
||||||
m.ctx.Logger.Debugf("IsFocused: %v\n", m.tk.IsFocused())
|
m.ctx.Logger.Debugf("IsFocused: %v\n", m.tk.IsFocused())
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ func NewModel(c *ctx.Ctx) Model {
|
|||||||
replyIDs: []string{},
|
replyIDs: []string{},
|
||||||
}
|
}
|
||||||
|
|
||||||
m.tk.KeymapAdd("reply", "reply", "r")
|
m.tk.KeymapAdd("reply", "reply (prefix with #, e.g. '2r')", "r")
|
||||||
|
|
||||||
m.a, _ = aggregator.New(m.ctx)
|
m.a, _ = aggregator.New(m.ctx)
|
||||||
|
|
||||||
|
@ -17,10 +17,9 @@ func (m Model) View() string {
|
|||||||
func buildView(mi interface{}, cached bool) string {
|
func buildView(mi interface{}, cached bool) string {
|
||||||
var m *Model = mi.(*Model)
|
var m *Model = mi.(*Model)
|
||||||
|
|
||||||
if cached && !m.tk.IsFocused() && m.tk.IsCached() {
|
if vcache := m.tk.DefaultCaching(cached); vcache != "" {
|
||||||
m.ctx.Logger.Debugln("Cached View()")
|
m.ctx.Logger.Debugln("Cached View()")
|
||||||
|
return vcache
|
||||||
return m.tk.GetCachedView()
|
|
||||||
}
|
}
|
||||||
m.ctx.Logger.Debugln("View()")
|
m.ctx.Logger.Debugln("View()")
|
||||||
m.ctx.Logger.Debugf("IsFocused: %v\n", m.tk.IsFocused())
|
m.ctx.Logger.Debugf("IsFocused: %v\n", m.tk.IsFocused())
|
||||||
|
Loading…
Reference in New Issue
Block a user