PanelContainer: Bug fixes and integration

This commit is contained in:
Luke I. Wilson
2021-04-06 11:14:17 -05:00
parent c40be89564
commit 389276ee34
2 changed files with 51 additions and 10 deletions

15
main.go
View File

@@ -199,6 +199,10 @@ func main() {
fileMenu.AddItems([]ui.Item{&ui.ItemEntry{Name: "New File", Shortcut: "Ctrl+N", Callback: func() {
textEdit := ui.NewTextEdit(screen, "", []byte{}, &theme) // No file path, no contents
tabContainer := getActiveTabContainer()
if tabContainer == nil {
tabContainer = ui.NewTabContainer(&theme)
panelContainer.SetSelected(tabContainer)
}
tabContainer.AddTab("noname", textEdit)
tabContainer.FocusTab(tabContainer.GetTabCount() - 1)
changeFocus(panelContainer)
@@ -224,6 +228,10 @@ func main() {
}
textEdit := ui.NewTextEdit(screen, path, bytes, &theme)
if tabContainer == nil {
tabContainer = ui.NewTabContainer(&theme)
panelContainer.SetSelected(tabContainer)
}
tabContainer.AddTab(path, textEdit)
}
@@ -276,7 +284,12 @@ func main() {
if tabContainer != nil && tabContainer.GetTabCount() > 0 {
tabContainer.RemoveTab(tabContainer.GetSelectedTabIdx())
} else { // No tabs open; close the editor
closing = true
// if the selected is root: close editor. otherwise close panel
if panelContainer.IsRootSelected() {
closing = true
} else {
panelContainer.DeleteSelected()
}
}
}}})