diff options
Diffstat (limited to 'gosrc/workspace.go')
-rw-r--r-- | gosrc/workspace.go | 88 |
1 files changed, 77 insertions, 11 deletions
diff --git a/gosrc/workspace.go b/gosrc/workspace.go index 84bea64..7b1d3ce 100644 --- a/gosrc/workspace.go +++ b/gosrc/workspace.go @@ -5,6 +5,14 @@ import ( "github.com/gizak/termui/v3/widgets" ) +type nodeValue string + +func (nv nodeValue) String() string { + return string(nv) +} + +// +// func (d DisplayGrid) handleEnter(config Config) { switch d.name { case "main": @@ -20,8 +28,8 @@ func (d DisplayGrid) handleEnter(config Config) { } } - -func createMainWorkspace(config Config) DisplayGrid { +// create workspace one, where general information is displayed and fetched +func createMainWorkspace(config Config) *DisplayGrid { // set widgets p1 := widgets.NewParagraph() requestTree := []*widgets.TreeNode{ @@ -35,8 +43,7 @@ func createMainWorkspace(config Config) DisplayGrid { { Value: nodeValue("Available Coins"), Nodes: nil, - }, - { + }, { Value: nodeValue("Deposit Address"), Nodes: nil, }, @@ -56,10 +63,10 @@ func createMainWorkspace(config Config) DisplayGrid { }, }, } - l := widgets.NewTree() - l.WrapText = false - l.SetNodes(requestTree) - l.TextStyle = ui.NewStyle(ui.ColorYellow) + tree := widgets.NewTree() + tree.WrapText = false + tree.SetNodes(requestTree) + tree.TextStyle = ui.NewStyle(ui.ColorYellow) p2 := widgets.NewParagraph() output := widgets.NewParagraph() @@ -91,14 +98,73 @@ func createMainWorkspace(config Config) DisplayGrid { ui.NewRow(0.1, p5), ui.NewRow(0.1, p2), ui.NewRow(0.8, - ui.NewCol(0.2, l), + ui.NewCol(0.2, tree), ui.NewCol(0.8, output), ), ) - return DisplayGrid{ + + grid := DisplayGrid{ output: output, - tree: l, + tree: tree, grid: main_grid, name: "main", } + return &grid +} + +// create workspace two, where the user can trade symbols +func createTradeWorkspace(config Config) *DisplayGrid { + output := widgets.NewParagraph() + ticker := widgets.NewParagraph() + strategy := widgets.NewParagraph() + tree := widgets.NewTree() + main_grid := ui.NewGrid() + + ticker.Title = "symbol" + ticker.Text = "<pick a symbol>" + strategy.Title = "strategy" + strategy.Text = "<then, pick a strategy>" + + requestTree := []*widgets.TreeNode{ + { + Value: nodeValue("Available Symbols"), + Nodes:[]*widgets.TreeNode{ + { + Value: nodeValue("BTCETH"), + Nodes:nil, + }, + }, + }, + { + Value: nodeValue("Available Strategies"), + Nodes:[]*widgets.TreeNode{ + { + Value: nodeValue("FizzBozzNacci(TM)"), + Nodes:nil, + }, + }, + }, + } + tree.WrapText = false + tree.SetNodes(requestTree) + tree.TextStyle = ui.NewStyle(ui.ColorYellow) + + termWidth, termHeight := ui.TerminalDimensions() + main_grid.SetRect(0, 0, termWidth, termHeight) + main_grid.Border = true + main_grid.Set( + ui.NewRow(0.1, ticker), + ui.NewRow(0.1, strategy), + ui.NewRow(0.8, + ui.NewCol(0.2, tree), + ui.NewCol(0.8, output), + ), + ) + grid := DisplayGrid{ + output: output, + tree: tree, + grid: main_grid, + name: "trading", + } + return &grid } |