package main import ( "github.com/br0xen/termbox-util" "github.com/nsf/termbox-go" ) const ( modalNone = iota modalNewFile modalSaveFile ) type browserScreen struct { initialized bool currentModal int confirmModal *termboxUtil.ConfirmModal } func (screen *browserScreen) handleEvent(event termbox.Event) int { // TODO: Handle user input if event.Ch == '?' { return aboutScreenIndex } else if event.Ch == 'q' { return exitScreenIndex } return browserScreenIndex } func (screen *browserScreen) performLayout(style Style) { if !screen.initialized { if state.isNewDB { screen.currentModal = modalNewFile screen.confirmModal = termboxUtil.CreateConfirmModal( "Create New Database ("+state.filename+")?", (screenWidth/2 - 10), (screenHeight/2 - 10), 20, 20, style.defaultFg, style.defaultBg, ) } } screen.initialized = true } func (screen *browserScreen) drawScreen(style Style) { exitTxt := "Press '?' for about screen. ('q' to quit)" if screen.currentModal > modalNone { exitTxt += " Show Modal" switch screen.currentModal { case modalNewFile: exitTxt += " New File" screen.confirmModal.Draw() } } termboxUtil.DrawStringAtPoint(exitTxt, (screenWidth-len(exitTxt))/2, screenHeight-1, style.titleFg, style.titleBg) }