99 "github.com/cego/gitte/config"
1010 "github.com/cego/gitte/state"
1111
12- tea "github.com/charmbracelet/ bubbletea"
13- "github.com/charmbracelet/ lipgloss"
12+ tea "charm.land/ bubbletea/v2 "
13+ "charm.land/ lipgloss/v2 "
1414)
1515
1616type screen int
@@ -231,7 +231,7 @@ func (m *featuresModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
231231 m .height = msg .Height
232232 return m , nil
233233
234- case tea.KeyMsg :
234+ case tea.KeyPressMsg :
235235 if m .screen == screenGateList {
236236 return m .updateGateList (msg )
237237 }
@@ -241,16 +241,21 @@ func (m *featuresModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
241241}
242242
243243// View renders the current screen.
244- func (m * featuresModel ) View () string {
244+ func (m * featuresModel ) View () tea.View {
245+ var s string
245246 if m .screen == screenScopeTree {
246- return m .viewScopeTree ()
247+ s = m .viewScopeTree ()
248+ } else {
249+ s = m .viewGateList ()
247250 }
248- return m .viewGateList ()
251+ v := tea .NewView (s )
252+ v .AltScreen = true
253+ return v
249254}
250255
251- func (m * featuresModel ) updateGateList (msg tea.KeyMsg ) (tea.Model , tea.Cmd ) {
252- switch msg .Type {
253- case tea .KeyCtrlC , tea . KeyEsc :
256+ func (m * featuresModel ) updateGateList (msg tea.KeyPressMsg ) (tea.Model , tea.Cmd ) {
257+ switch msg .Key (). Code {
258+ case tea .KeyEsc :
254259 m .save ()
255260 return m , tea .Quit
256261 case tea .KeyUp :
@@ -271,7 +276,7 @@ func (m *featuresModel) updateGateList(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
271276 }
272277 default :
273278 switch msg .String () {
274- case "q" :
279+ case "ctrl+c" , " q" :
275280 m .save ()
276281 return m , tea .Quit
277282 case "k" :
@@ -287,12 +292,8 @@ func (m *featuresModel) updateGateList(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
287292 return m , nil
288293}
289294
290- func (m * featuresModel ) updateScopeTree (msg tea.KeyMsg ) (tea.Model , tea.Cmd ) {
291- switch msg .Type {
292- case tea .KeyCtrlC :
293- m .applyScopeChanges ()
294- m .save ()
295- return m , tea .Quit
295+ func (m * featuresModel ) updateScopeTree (msg tea.KeyPressMsg ) (tea.Model , tea.Cmd ) {
296+ switch msg .Key ().Code {
296297 case tea .KeyEsc :
297298 m .applyScopeChanges ()
298299 m .screen = screenGateList
@@ -307,14 +308,14 @@ func (m *featuresModel) updateScopeTree(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
307308 m .scopeMoveNextPage ()
308309 case tea .KeySpace , tea .KeyEnter :
309310 m .scopeToggle ()
310- case tea .KeyCtrlZ :
311- m .scopeUndo ()
312311 default :
313312 switch msg .String () {
314- case "q" :
313+ case "ctrl+c" , " q" :
315314 m .applyScopeChanges ()
316315 m .save ()
317316 return m , tea .Quit
317+ case "ctrl+z" :
318+ m .scopeUndo ()
318319 case "k" :
319320 m .scopeMovePrev ()
320321 case "j" :
@@ -554,7 +555,7 @@ func Run(cfg *config.GitteConfig, cwd string, st *state.GitteState) error {
554555 return ErrNoFeatureGates
555556 }
556557 model := newFeaturesModel (cfg , cwd , st )
557- p := tea .NewProgram (model , tea . WithAltScreen () )
558+ p := tea .NewProgram (model )
558559 _ , err := p .Run ()
559560 return err
560561}
0 commit comments