File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ type model struct {
2121
2222 done bool
2323 fistChar bool
24+ prevKey string
2425}
2526
2627type row struct {
Original file line number Diff line number Diff line change @@ -62,15 +62,22 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6262 // Keyboard input
6363 case tea.KeyMsg :
6464 switch msg .Type {
65+ case tea .KeyTab :
66+ if ! m .done {
67+ m .prevKey = "tab"
68+ }
69+
6570 case tea .KeyEnter :
6671 // new Sentence creation and States reset
67- if m .done {
72+ if m .done || m . prevKey == "tab" {
6873 m .sentence = generator .Sentence ()
6974 m .runeCount = utf8 .RuneCountInString (m .sentence )
7075 m .done = false
7176 m .fistChar = true
77+ m .prevKey = ""
7278 }
7379
80+
7481 case tea .KeyEscape , tea .KeyCtrlC :
7582 // bay bay
7683 return m , tea .Quit
@@ -109,6 +116,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
109116 m .termHeight = msg .Height
110117 }
111118
119+
120+
112121 return m , nil
113122}
114123
You can’t perform that action at this time.
0 commit comments