fix(commander): capture output via CombinedOutput instead of piping streams
Some checks failed
gobuild / build (push) Failing after 7s
Some checks failed
gobuild / build (push) Failing after 7s
- Remove os import and manual Stdin/Stdout/Stderr assignment from subExecute - Replace cmd.Run() followed by cmd.CombinedOutput() with single CombinedOutput call - Adjust volume bar height to exactly match metadata display and increase gap to 2 spaces
This commit is contained in:
parent
c64c80448c
commit
07586a8fc0
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
)
|
||||
@ -27,12 +26,9 @@ func isInstalled(name string) bool {
|
||||
|
||||
func subExecute(program string, args ...string) ([]byte, error) {
|
||||
cmd := exec.Command(program, args...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err := cmd.Run()
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Printf("%v\n", err)
|
||||
}
|
||||
return cmd.CombinedOutput()
|
||||
return output, err
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ func (a *App) renderPlayback() string {
|
||||
Padding(1, 2).
|
||||
Width(boxW)
|
||||
|
||||
dispW := min(boxW-10, 50) // leave room for vertical vol bar (~2) + separator
|
||||
dispW := min(boxW-11, 50) // leave room for vertical vol bar (2) + slightly larger gap (2)
|
||||
display := lipgloss.NewStyle().
|
||||
Background(lipgloss.Color("235")).
|
||||
Foreground(lipgloss.Color("46")). // classic green lcd
|
||||
@ -504,11 +504,12 @@ func (a *App) renderPlayback() string {
|
||||
|
||||
metadata := display.Render(strings.Join(metaLines, "\n"))
|
||||
|
||||
// vertical volume bar to the right of the metadata display
|
||||
volBar := renderVolumeBar(a.currentVolume, 5, 2)
|
||||
// vertical volume bar to the right of the metadata display, matching its exact height
|
||||
barHeight := lipgloss.Height(metadata)
|
||||
volBar := renderVolumeBar(a.currentVolume, barHeight, 2)
|
||||
|
||||
// place side-by-side (top aligned). Add a small separator space.
|
||||
viewer := lipgloss.JoinHorizontal(lipgloss.Top, metadata, " ", volBar)
|
||||
// place side-by-side (top aligned). Slightly increased gap.
|
||||
viewer := lipgloss.JoinHorizontal(lipgloss.Top, metadata, " ", volBar)
|
||||
|
||||
// button row (text buttons, stateful)
|
||||
playBtn := "[ > ]"
|
||||
@ -544,7 +545,7 @@ func min(a, b int) int {
|
||||
}
|
||||
|
||||
// renderVolumeBar draws a vertical volume indicator bar.
|
||||
// height matches the metadata display (e.g. 5).
|
||||
// height is passed in to exactly match the metadata window's rendered height.
|
||||
// background is dark gray ("236"), filled indicator uses the green ("46") from the lcd display.
|
||||
func renderVolumeBar(vol int, height, width int) string {
|
||||
if height <= 0 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user