From b04cea1669fc9fe742509646b4a6a50b008ac0be Mon Sep 17 00:00:00 2001 From: Malte Bauch <malte.bauch@stud.h-da.de> Date: Wed, 14 Oct 2020 11:22:18 +0200 Subject: [PATCH] refactoring struct - commandsListView - mainView -resultAndInputView --- cmd/gosdn-tview/views/commandsListView.go | 8 ++++---- cmd/gosdn-tview/views/mainView.go | 12 ++++++------ cmd/gosdn-tview/views/resultAndInputView.go | 5 +++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/gosdn-tview/views/commandsListView.go b/cmd/gosdn-tview/views/commandsListView.go index e69223dfa..31c18ff65 100644 --- a/cmd/gosdn-tview/views/commandsListView.go +++ b/cmd/gosdn-tview/views/commandsListView.go @@ -11,10 +11,10 @@ type CommandListView struct { } func NewCommandListView(rootTitle string) *CommandListView { - - v := &CommandListView{} - v.rootNode = tview.NewTreeNode(rootTitle) - v.commandsTree = tview.NewTreeView() + v := &CommandListView{ + rootNode: tview.NewTreeNode(rootTitle), + commandsTree: tview.NewTreeView(), + } v.commandsTree. SetRoot(v.rootNode). SetTitle("Commands"). diff --git a/cmd/gosdn-tview/views/mainView.go b/cmd/gosdn-tview/views/mainView.go index 8db872954..a54339906 100644 --- a/cmd/gosdn-tview/views/mainView.go +++ b/cmd/gosdn-tview/views/mainView.go @@ -10,14 +10,14 @@ type MainView struct { } func NewMainView() *MainView { - v := &MainView{} - v.pages = tview.NewPages() - v.resultAndInputView = NewResultAndInputView() - v.commandsListView = NewCommandListView("") + v := &MainView{ + pages: tview.NewPages(), + mainFlexBox: createFlexBox(tview.FlexColumn), + commandsListView: NewCommandListView(""), + resultAndInputView: NewResultAndInputView(), + } v.commandsListView.GetCommands("../") - v.mainFlexBox = createFlexBox(tview.FlexColumn) - commandsFlexBox := createFlexBox(tview.FlexRow) commandsFlexBox.AddItem(v.commandsListView.GetContent(), 0, 40, true) diff --git a/cmd/gosdn-tview/views/resultAndInputView.go b/cmd/gosdn-tview/views/resultAndInputView.go index b16b10427..89e9d77ba 100644 --- a/cmd/gosdn-tview/views/resultAndInputView.go +++ b/cmd/gosdn-tview/views/resultAndInputView.go @@ -10,8 +10,9 @@ type ResultAndInputView struct { } func NewResultAndInputView() *ResultAndInputView { - v := &ResultAndInputView{} - v.resultAndInputView = tview.NewTextView() + v := &ResultAndInputView{ + resultAndInputView: tview.NewTextView(), + } v.resultAndInputView. SetDynamicColors(true). SetRegions(true). -- GitLab