Compare commits
2 Commits
1cc6d923fc
...
fcb23827e4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fcb23827e4 | ||
![]() |
117fa5085b |
22
bubbletea.go
22
bubbletea.go
@ -50,10 +50,17 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
// new task
|
||||
case "n":
|
||||
m.addTask = true
|
||||
if !m.addTask {
|
||||
m.addTask = true
|
||||
m.textinput.Focus()
|
||||
m.textinput.Reset()
|
||||
}
|
||||
|
||||
case "esc":
|
||||
m.addTask = false
|
||||
if m.addTask {
|
||||
m.addTask = false
|
||||
m.textinput.Reset()
|
||||
}
|
||||
|
||||
// The "enter" key and the spacebar (a literal space) toggle
|
||||
// the selected state for the item that the cursor is pointing at.
|
||||
@ -66,9 +73,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m.textinput, cmd = m.textinput.Update(msg)
|
||||
|
||||
if m.addTask {
|
||||
m.textinput, cmd = m.textinput.Update(msg)
|
||||
}
|
||||
// Return the updated model to the Bubble Tea runtime for processing.
|
||||
// Note that we're not returning a command.
|
||||
return m, cmd
|
||||
@ -118,8 +125,7 @@ func (m model) View() string {
|
||||
// render tab bar
|
||||
for i, v := range []string{"Inbox", "Today", "Tomorrow", "Scheduled", "Anytime"} {
|
||||
if i == m.tab {
|
||||
s += lipgloss.
|
||||
NewStyle().
|
||||
s += lipgloss.NewStyle().
|
||||
Bold(true).
|
||||
Underline(true).
|
||||
PaddingRight(3).
|
||||
@ -136,8 +142,6 @@ func (m model) View() string {
|
||||
|
||||
if m.addTask {
|
||||
s += ": "
|
||||
m.textinput.Focus()
|
||||
m.textinput.Cursor.BlinkCmd()
|
||||
s += m.textinput.View()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user