mirror of
https://github.com/taigrr/gico.git
synced 2026-04-02 03:09:07 -07:00
make settings list fit screen size, use batch message to ensure all callbacks used
This commit is contained in:
@@ -25,11 +25,18 @@ func (s selectableDelegate) Render(w io.Writer, m list.Model, index int, item li
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
str := ""
|
||||
if x.selected {
|
||||
w.Write([]byte(" [X] " + x.text))
|
||||
str += " [X] "
|
||||
} else {
|
||||
w.Write([]byte(" [ ] " + x.text))
|
||||
str += " [ ] "
|
||||
}
|
||||
str += x.text
|
||||
if m.Index() == index {
|
||||
sty := list.NewDefaultItemStyles()
|
||||
str = sty.SelectedTitle.Render(str)
|
||||
}
|
||||
w.Write([]byte(str))
|
||||
}
|
||||
|
||||
type delegateKeyMap struct {
|
||||
|
||||
@@ -53,6 +53,10 @@ var settingsKey = key.NewBinding(
|
||||
)
|
||||
|
||||
func (m Settings) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
if msg, ok := msg.(tea.WindowSizeMsg); ok {
|
||||
m.AuthorList.SetHeight(msg.Height - 8)
|
||||
m.RepoList.SetHeight(msg.Height - 8)
|
||||
}
|
||||
switch m.cursor {
|
||||
case authors:
|
||||
var cmd tea.Cmd
|
||||
|
||||
13
ui/ui.go
13
ui/ui.go
@@ -96,6 +96,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
default:
|
||||
}
|
||||
var b tea.BatchMsg
|
||||
switch m.cursor {
|
||||
// multiple cursors defined for extensibility, but only graph is used
|
||||
case graph, commitLog:
|
||||
@@ -104,8 +105,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
m.CommitLogModel.Authors = m.SettingsModel.SelectedAuthors
|
||||
m.CommitLogModel.Repos = m.SettingsModel.SelectedRepos
|
||||
|
||||
tmp, _ := m.GraphModel.Update(msg)
|
||||
tmp, c := m.GraphModel.Update(msg)
|
||||
b = append(b, c)
|
||||
m.GraphModel, _ = tmp.(Graph)
|
||||
|
||||
m.CommitLogModel.Year = m.GraphModel.Year
|
||||
@@ -114,12 +115,16 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.CommitLogModel.Table.SetCursor(0)
|
||||
}
|
||||
tmpC, cmd := m.CommitLogModel.Update(msg)
|
||||
b = append(b, cmd)
|
||||
m.CommitLogModel, _ = tmpC.(CommitLog)
|
||||
return m, cmd
|
||||
fallthrough
|
||||
case settings:
|
||||
tmp, cmd := m.SettingsModel.Update(msg)
|
||||
|
||||
b = append(b, cmd)
|
||||
m.SettingsModel, _ = tmp.(Settings)
|
||||
return m, cmd
|
||||
return m, tea.Batch(b...)
|
||||
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user