Closed troyengel closed 2 years ago
Can add a flag too :)
@ericm It's still not consistent, though :(
Sometimes it prints like 80 columns, sometimes 79, sometimes 81. Depends if the price (the left bar) is 3, 2 or 4 digits.
https://i.imgur.com/ZzK0ZCN.png https://i.imgur.com/sZjHoJn.png
This dirty patch may fix it:
---
graph/graph.go | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/graph/graph.go b/graph/graph.go
index e858287..7eda517 100644
--- a/graph/graph.go
+++ b/graph/graph.go
@@ -37,6 +37,15 @@ func borderHorizontal(out *string, width int) {
func GenerateGraph(chart *api.Chart, width int, height int, chartTheme ChartTheme, timezone *time.Location) (string, error) {
out := "┏"
maxSize := len(strings.Split(chart.High.String(), ".")[0]) + 3
+ // add padding
+ switch maxSize {
+ case 4:
+ maxSize += 3
+ case 5:
+ maxSize += 2
+ case 6:
+ maxSize += 1
+ }
borderHorizontal(&out, width+maxSize+3)
out += "┓"
colour := 92
@@ -58,7 +67,7 @@ func GenerateGraph(chart *api.Chart, width int, height int, chartTheme ChartThem
colour = 91
}
info := fmt.Sprintf(
- "\n┃\033[95m %s | \033[%dm%s %s (%s%% | %s)\033[95m on %s | ",
+ "\n┃\033[95m %5s | \033[%dm%s %s (%s%% | %s)\033[95m on %s | ",
chart.Ticker,
colour,
chart.Close.StringFixed(2),
--
2.7.4
I will make the statement "pretty much every terminal in Linux defaults to 80x24 when opened" and hope that's agreeable. :) (I've even tested good old xterm for this request, it's the same). Is there any way we can shave off 9 columns from the output so that it displays nicely in a standard 80x24 by default?
I used xterm for this screenshot as it does not resize the previous output like modern terminals do, at the top is where it opened in 80x24 and the display is wrapped, then I increased the window to 89 wide to get it nicely formatted. For example maybe
8,30a
(losing the 'm' off 'am' and 'pm') could do it perhaps? (or even convert to 24H but that uses the same number as dropping 'm', it's a wash).