Remove GetCurrentView()

This commit is contained in:
aditya-K2
2023-05-02 01:17:07 +05:30
parent ec0cd52763
commit 49c38ecf8f
3 changed files with 10 additions and 14 deletions

View File

@@ -128,7 +128,7 @@ func NewApplication() *tview.Application {
// Define Actions
globalActions := map[string]*Action{
"open_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
GetCurrentView().OpenEntry()
CurrentView.OpenEntry()
return nil
}, progressBar),
"focus_search": NewAction(func(e *tcell.EventKey) *tcell.EventKey {

View File

@@ -171,7 +171,7 @@ func (i *interactiveView) capture(e *tcell.EventKey) *tcell.EventKey {
}
case 'v':
{
if !GetCurrentView().DisableVisualMode() {
if !CurrentView.DisableVisualMode() {
i.toggleVisualMode()
}
return nil
@@ -187,17 +187,17 @@ func (i *interactiveView) capture(e *tcell.EventKey) *tcell.EventKey {
default:
{
if e.Key() == tcell.KeyEscape {
if !GetCurrentView().DisableVisualMode() {
if !CurrentView.DisableVisualMode() {
return i.getHandler("exitvisual")(e)
}
} else if i.visual && !GetCurrentView().DisableVisualMode() &&
GetCurrentView().VisualCapture() != nil {
} else if i.visual && !CurrentView.DisableVisualMode() &&
CurrentView.VisualCapture() != nil {
if i.visual {
i.toggleVisualMode()
}
return GetCurrentView().VisualCapture()(i.vrange.Start, i.vrange.End, e)
} else if GetCurrentView().ExternalInputCapture() != nil {
return GetCurrentView().ExternalInputCapture()(e)
return CurrentView.VisualCapture()(i.vrange.Start, i.vrange.End, e)
} else if CurrentView.ExternalInputCapture() != nil {
return CurrentView.ExternalInputCapture()(e)
}
return e
}
@@ -213,8 +213,8 @@ func GetCell(text string, st tcell.Style) *tview.TableCell {
func (i *interactiveView) update() {
n := 3
i.Table.Clear()
if GetCurrentView().Content() != nil {
s := GetCurrentView().Content()()
if CurrentView.Content() != nil {
s := CurrentView.Content()()
_, _, w, _ := i.Table.GetInnerRect()
for x := range s {
b := ""

View File

@@ -27,7 +27,3 @@ type View interface {
func SetCurrentView(v View) {
CurrentView = v
}
func GetCurrentView() View {
return CurrentView
}