abstract terminal interface

This commit is contained in:
alu
2026-08-07 14:49:21 -07:00
parent 691dba7687
commit 5c4d16857b
10 changed files with 91 additions and 40 deletions
+6 -9
View File
@@ -1,12 +1,12 @@
package app
import (
"finally-a-monolithic-linux-hw-monitor/app/common"
"finally-a-monolithic-linux-hw-monitor/app/mem"
"finally-a-monolithic-linux-hw-monitor/app/proc"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
"time"
)
@@ -25,22 +25,19 @@ func Run() {
os.Exit(0)
}()
term := common.NewTerminal()
proc, _ := proc.GetProc()
mem, _ := mem.GetMem()
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
for {
console := &strings.Builder{}
// Move cursor to top-left (0,0) without clearing full buffer (flicker-free)
fmt.Fprint(console, "\033[H")
term.Start()
proc.RenderProc(console)
mem.Render(console)
proc.Render(term)
mem.Render(term)
fmt.Fprint(console, "\nPress Ctrl+C to exit.\033[K\n")
fmt.Fprint(console, "\033[0J")
fmt.Print(console.String())
term.End()
<-ticker.C
}