Skip to content

Commit 9e6c0eb

Browse files
authored
Merge pull request #1 from 17twenty/feature/multi-connection
Add SSH/multi-session support without exposing tcell types.
2 parents 1656a71 + c3c9202 commit 9e6c0eb

File tree

9 files changed

+759
-47
lines changed

9 files changed

+759
-47
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
.vscode/
33
.mypy_cache/
44
.idea
5+
hostkey
6+
hostkey.pub
7+
.pub
8+
ssh_dashboard

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- **Flex**: Mixed fixed/proportional layouts.
2626
- **Grid**: 12-column dynamic grid system.
2727
- **Absolutes**: Exact coordinates when needed.
28+
- **🌐 SSH / Remote Apps**: Turn any TUI into a zero-install SSH accessible application (multi-tenant support).
2829
- **📊 Rich Widgets**:
2930
- **Charts**: BarChart, StackedBarChart, PieChart, DonutChart, RadarChart (Spider), FunnelChart, TreeMap, Sparkline, Plot (Scatter/Line).
3031
- **Gauges**: Gauge, LineGauge (with pixel-perfect Braille/Block styles).
@@ -45,6 +46,7 @@
4546
| **Pixel-Perfect** | **Yes** (Braille/Block/Space) | No |
4647
| **Mouse Support** | **Full** (Wheel/Click/Drag) | Click |
4748
| **TrueColor** | **Yes** | No |
49+
| **SSH / Multi-User** | **Native** (Backend API) | No (Global State) |
4850
| **Modern Terminal Support** | **All** (iterm, ghostty, etc.) | No |
4951

5052
## 📦 Installation
@@ -138,6 +140,7 @@ Run individual examples: `go run _examples/<name>/main.go`
138140
| **Radarchart** | <img src="_examples/radarchart/screenshot.png" height="80" /> | [View Example Code](_examples/radarchart/main.go) |
139141
| **Scrollbar** | <img src="_examples/scrollbar/screenshot.png" height="80" /> | [View Example Code](_examples/scrollbar/main.go) |
140142
| **Sparkline** | <img src="_examples/sparkline/screenshot.png" height="80" /> | [View Example Code](_examples/sparkline/main.go) |
143+
| **SSH Dashboard** | <img src="_examples/dashboard/screenshot.png" height="80" /> | [View Example Code](_examples/ssh-dashboard/main.go) |
141144
| **Stacked Barchart** | <img src="_examples/stacked_barchart/screenshot.png" height="80" /> | [View Example Code](_examples/stacked_barchart/main.go) |
142145
| **Table** | <img src="_examples/table/screenshot.png" height="80" /> | [View Example Code](_examples/table/main.go) |
143146
| **Tabs** | <img src="_examples/tabs/screenshot.png" height="80" /> | [View Example Code](_examples/tabs/main.go) |
@@ -172,6 +175,29 @@ for e := range uiEvents {
172175
}
173176
```
174177

178+
### 🌐 Serving over SSH
179+
180+
You can easily serve your TUI over SSH (like standard CLI apps) using `ui.InitWithConfig` and a library like `gliderlabs/ssh`.
181+
182+
```go
183+
func sshHandler(sess ssh.Session) {
184+
// 1. Create a custom backend for this session
185+
app, _ := ui.NewBackend(&ui.InitConfig{
186+
CustomTTY: sess, // ssh.Session implements io.ReadWriter
187+
})
188+
defer app.Close()
189+
190+
// 2. Use the app instance instead of global ui.* functions
191+
p := widgets.NewParagraph()
192+
p.Text = "Hello SSH User!"
193+
p.SetRect(0, 0, 20, 5)
194+
195+
app.Render(p) // Renders to the SSH client only!
196+
}
197+
```
198+
199+
Check `_examples/ssh-dashboard` for a full multi-user demo.
200+
175201
## 🤝 Contributing
176202

177203
Contributions are welcome! Please submit a Pull Request.

_examples/ssh-dashboard/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SSH Dashboard Example
2+
3+
This example demonstrates the **SSH Dashboard** widget/feature.
4+
5+
## 🚀 Run
6+
7+
```bash
8+
$ ssh-keygen -t ed25519 -f hostkey -N "" # Generate sample host key
9+
$ go run _examples/stacked_barchart/main.go
10+
```
11+
12+
In a separate window:
13+
14+
```bash
15+
$ ssh 0.0.0.0 -p 2222
16+
```
17+
18+
## 📝 Code
19+
20+
See [main.go](main.go) for the implementation.

0 commit comments

Comments
 (0)