Remove barFocused boolean from main loop
This commit is contained in:
parent
8db551ceae
commit
3cf168355a
13
main.go
13
main.go
@ -83,8 +83,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
barFocused := false
|
|
||||||
|
|
||||||
menuBar = ui.NewMenuBar(&theme)
|
menuBar = ui.NewMenuBar(&theme)
|
||||||
|
|
||||||
fileMenu := ui.NewMenu("_File", &theme)
|
fileMenu := ui.NewMenu("_File", &theme)
|
||||||
@ -113,7 +111,6 @@ func main() {
|
|||||||
dialog = nil // Hide the file selector
|
dialog = nil // Hide the file selector
|
||||||
|
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
}
|
}
|
||||||
dialog = ui.NewFileSelectorDialog(
|
dialog = ui.NewFileSelectorDialog(
|
||||||
&s,
|
&s,
|
||||||
@ -124,7 +121,6 @@ func main() {
|
|||||||
func() { // Dialog is canceled
|
func() { // Dialog is canceled
|
||||||
dialog = nil
|
dialog = nil
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
changeFocus(dialog)
|
changeFocus(dialog)
|
||||||
@ -145,14 +141,12 @@ func main() {
|
|||||||
te.Dirty = false
|
te.Dirty = false
|
||||||
}
|
}
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
}
|
}
|
||||||
}}, &ui.ItemEntry{Name: "Save _As...", Callback: func() {
|
}}, &ui.ItemEntry{Name: "Save _As...", Callback: func() {
|
||||||
// TODO: implement a "Save as" dialog system, and show that when trying to save noname files
|
// TODO: implement a "Save as" dialog system, and show that when trying to save noname files
|
||||||
callback := func(filePaths []string) {
|
callback := func(filePaths []string) {
|
||||||
dialog = nil // Hide the file selector
|
dialog = nil // Hide the file selector
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog = ui.NewFileSelectorDialog(
|
dialog = ui.NewFileSelectorDialog(
|
||||||
@ -164,7 +158,6 @@ func main() {
|
|||||||
func() { // Dialog canceled
|
func() { // Dialog canceled
|
||||||
dialog = nil
|
dialog = nil
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
changeFocus(dialog)
|
changeFocus(dialog)
|
||||||
@ -212,7 +205,6 @@ func main() {
|
|||||||
_ = ClipWrite(selectedStr) // Add the selectedStr to clipboard
|
_ = ClipWrite(selectedStr) // Add the selectedStr to clipboard
|
||||||
}
|
}
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
}
|
}
|
||||||
}}, &ui.ItemEntry{Name: "_Copy", Shortcut: 'c', Callback: func() {
|
}}, &ui.ItemEntry{Name: "_Copy", Shortcut: 'c', Callback: func() {
|
||||||
if tabContainer.GetTabCount() > 0 {
|
if tabContainer.GetTabCount() > 0 {
|
||||||
@ -223,7 +215,6 @@ func main() {
|
|||||||
_ = ClipWrite(selectedStr) // Add selectedStr to clipboard
|
_ = ClipWrite(selectedStr) // Add selectedStr to clipboard
|
||||||
}
|
}
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
}
|
}
|
||||||
}}, &ui.ItemEntry{Name: "_Paste", Shortcut: 'v', Callback: func() {
|
}}, &ui.ItemEntry{Name: "_Paste", Shortcut: 'v', Callback: func() {
|
||||||
if tabContainer.GetTabCount() > 0 {
|
if tabContainer.GetTabCount() > 0 {
|
||||||
@ -237,7 +228,6 @@ func main() {
|
|||||||
te.Insert(contents)
|
te.Insert(contents)
|
||||||
|
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
barFocused = false
|
|
||||||
}
|
}
|
||||||
}}, &ui.ItemSeparator{}, &ui.ItemEntry{Name: "Select _All", Shortcut: 'a', Callback: func() {
|
}}, &ui.ItemSeparator{}, &ui.ItemEntry{Name: "Select _All", Shortcut: 'a', Callback: func() {
|
||||||
|
|
||||||
@ -318,8 +308,7 @@ func main() {
|
|||||||
// On Escape, we change focus between editor and the MenuBar.
|
// On Escape, we change focus between editor and the MenuBar.
|
||||||
if dialog == nil { // While no dialog is present...
|
if dialog == nil { // While no dialog is present...
|
||||||
if ev.Key() == tcell.KeyEscape {
|
if ev.Key() == tcell.KeyEscape {
|
||||||
barFocused = !barFocused
|
if focusedComponent == tabContainer {
|
||||||
if barFocused {
|
|
||||||
changeFocus(menuBar)
|
changeFocus(menuBar)
|
||||||
} else {
|
} else {
|
||||||
changeFocus(tabContainer)
|
changeFocus(tabContainer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user