Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.
96 changes: 0 additions & 96 deletions cmd/cryptstream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
tuikit "github.com/moneycaringcoder/tuikit-go"
"github.com/moneycaringcoder/cryptstream-tui/internal/binance"
"github.com/moneycaringcoder/cryptstream-tui/internal/config"
Expand Down Expand Up @@ -37,14 +36,6 @@ func main() {

commandBar := tuikit.NewCommandBar(buildCommands(cryptoView))

detailOverlay := tuikit.NewDetailOverlay(tuikit.DetailOverlayOpts[ticker.Ticker]{
Title: "Coin Detail",
Render: func(t ticker.Ticker, w, h int, theme tuikit.Theme) string {
return renderCoinDetail(t, cryptoView, w)
},
})
cryptoView.DetailOverlay = detailOverlay

statusLeft := func() string {
filterLabel := ""
switch cryptoView.FilterMode() {
Expand Down Expand Up @@ -103,7 +94,6 @@ func main() {
tuikit.WithHelp(),
tuikit.WithOverlay("Settings", "c", configEditor),
tuikit.WithOverlay("Command", ":", commandBar),
tuikit.WithOverlay("Detail", "", detailOverlay),
tuikit.WithStatusBar(statusLeft, statusRight),
tuikit.WithTickInterval(100*time.Millisecond),
tuikit.WithMouseSupport(),
Expand Down Expand Up @@ -344,92 +334,6 @@ func buildConfigFields(cfg *config.Config, cv *ui.CryptoView) []tuikit.ConfigFie
}
}

func renderCoinDetail(t ticker.Ticker, cv *ui.CryptoView, w int) string {
labelStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#888888"))
valStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#ffffff"))
posStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#00ff88"))
negStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#ff4444"))

chgStyle := posStyle
if t.PriceChangePercent < 0 {
chgStyle = negStyle
}

lines := []string{
labelStyle.Render("Symbol: ") + valStyle.Render(t.DisplaySymbol()),
labelStyle.Render("Price: ") + valStyle.Render(ticker.FormatPrice(t.LastPrice)),
labelStyle.Render("Change: ") + chgStyle.Render(fmt.Sprintf("%+.2f%%", t.PriceChangePercent)),
labelStyle.Render("High 24h: ") + valStyle.Render(ticker.FormatPrice(t.HighPrice)),
labelStyle.Render("Low 24h: ") + valStyle.Render(ticker.FormatPrice(t.LowPrice)),
labelStyle.Render("Volume: ") + valStyle.Render(ticker.FormatVolume(t.QuoteVolume)),
}

// Funding rate if available
fr := cv.FundingRate(t.Symbol)
if fr.Rate != 0 {
frStyle := posStyle
if fr.Rate > 0 {
frStyle = negStyle
}
lines = append(lines, labelStyle.Render("Funding: ")+frStyle.Render(fmt.Sprintf("%+.4f%%", fr.Rate)))
}

// Volume spike
if t.VolumeSpiking {
lines = append(lines, labelStyle.Render("Vol Spike: ")+posStyle.Render(fmt.Sprintf("%.1fx avg", t.VolumeSpikeRatio)))
}

// Sparkline
hist := cv.PriceHistory(t.Symbol)
if len(hist) > 1 {
lines = append(lines, "")
lines = append(lines, labelStyle.Render("Price Trend:"))
lines = append(lines, renderSparkline(hist, w-2))
}

return strings.Join(lines, "\n")
}

func renderSparkline(data []float64, width int) string {
blocks := []rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
min, max := data[0], data[0]
for _, v := range data {
if v < min {
min = v
}
if v > max {
max = v
}
}

span := max - min
if span == 0 {
span = 1
}

// Sample data to fit width
n := len(data)
if n > width {
step := float64(n) / float64(width)
sampled := make([]float64, width)
for i := range sampled {
sampled[i] = data[int(float64(i)*step)]
}
data = sampled
}

var sb strings.Builder
style := lipgloss.NewStyle().Foreground(lipgloss.Color("#00ccff"))
for _, v := range data {
idx := int((v - min) / span * float64(len(blocks)-1))
if idx >= len(blocks) {
idx = len(blocks) - 1
}
sb.WriteRune(blocks[idx])
}
return style.Render(sb.String())
}

func buildCommands(cv *ui.CryptoView) []tuikit.Command {
return []tuikit.Command{
{
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0
github.com/gorilla/websocket v1.5.3
github.com/moneycaringcoder/tuikit-go v0.5.4
github.com/moneycaringcoder/tuikit-go v0.7.0
)

require (
Expand All @@ -27,8 +27,9 @@ require (
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/rcarmo/go-te v0.1.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.3.8 // indirect
golang.org/x/text v0.34.0 // indirect
)
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2J
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/moneycaringcoder/tuikit-go v0.5.4 h1:JVd7C7k01NnT5btty6prc6oVTx3LWYJXM1HDtLnZSeU=
github.com/moneycaringcoder/tuikit-go v0.5.4/go.mod h1:NNJ8NSFnHrd4A7dqmb0DO1kA6vtk8jmdCTKYJFL+h50=
github.com/moneycaringcoder/tuikit-go v0.7.0 h1:DEI3CGNhndFfpxYHjwDvd/TkDndQfTbFrixMy/QVj3E=
github.com/moneycaringcoder/tuikit-go v0.7.0/go.mod h1:2P2MPQGh/A+vpCcrgh5Taz+XqMlrpPgAsc2cd4W8ucg=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/rcarmo/go-te v0.1.0 h1:BH9Ub+A0AVBY5Q00El4QMVaWAMbycVHgMHQI2Kz8J/o=
github.com/rcarmo/go-te v0.1.0/go.mod h1:cLsrtroxCubS+OHHwH0riB6xeNESfntaHEeI1jPAedk=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
Expand All @@ -50,5 +52,5 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
16 changes: 8 additions & 8 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ func Default() Config {
MaxBackoff: Duration(30 * time.Second),

Theme: ThemeConfig{
Green: "#00ff88",
Red: "#ff4444",
Dim: "#555555",
Separator: "#333333",
Cursor: "#1a1a2e",
Footer: "#666666",
FlashGreen: "#1a3a2a",
FlashRed: "#3a1a1a",
Green: "#22c55e",
Red: "#ef4444",
Dim: "#6b7280",
Separator: "#3b3b3b",
Cursor: "#1e293b",
Footer: "#6b7280",
FlashGreen: "#1a2e1a",
FlashRed: "#2e1a1a",
Star: "#ffaa00",
},
}
Expand Down
68 changes: 0 additions & 68 deletions internal/news/news.go

This file was deleted.

Loading
Loading