@@ -16,8 +16,8 @@ import (
1616
1717 "sync"
1818
19- ui "github.com/metaspartan/gotui/v4 "
20- w "github.com/metaspartan/gotui/v4 /widgets"
19+ ui "github.com/metaspartan/gotui/v5 "
20+ w "github.com/metaspartan/gotui/v5 /widgets"
2121)
2222
2323var renderMutex sync.Mutex
@@ -151,6 +151,23 @@ func setupUI() {
151151 eCoreCount ,
152152 pCoreCount ,
153153 )
154+
155+ confirmModal = w .NewModal ("CONFIRM KILL" )
156+ confirmModal .Title = " CONFIRM "
157+ confirmModal .Border = true
158+ confirmModal .BorderRounded = true
159+ confirmModal .BorderStyle .Fg = ui .ColorRed
160+ confirmModal .BorderStyle .Bg = ui .ColorBlack
161+ confirmModal .TextStyle .Fg = ui .ColorWhite
162+ confirmModal .TextStyle .Bg = ui .ColorBlack
163+ confirmModal .ActiveButtonIndex = 1 // Default to No (Safe)
164+
165+ _ = confirmModal .AddButton ("Yes" , func () {
166+ // Callback logic will be handled elsewhere or reused
167+ })
168+ _ = confirmModal .AddButton ("No" , func () {
169+ // Callback logic
170+ })
154171}
155172
156173func updateModelText () {
@@ -219,17 +236,22 @@ func updateHelpText() {
219236 "- c: Cycle through UI color themes\n " +
220237 "- p: Toggle party mode (color cycling)\n " +
221238 "- l: Cycle through the 6 available layouts\n " +
239+ "- F9: Kill selected process (y/n confirm)\n " + // Updated text
240+ "- /: Search process list\n " + // Added help
241+ "- g/G: Jump to top/bottom of process list\n " + // Added help
222242 "- + or -: Adjust update interval (faster/slower)\n " +
223- "- F9: Kill selected process\n " +
224243 "- h or ?: Toggle this help menu\n " +
225244 "- q or <C-c>: Quit the application\n \n " +
226245 "Start Flags:\n " +
227246 "--help, -h: Show this help menu\n " +
228247 "--version, -v: Show the version of mactop\n " +
229248 "--interval, -i: Set the update interval in milliseconds. Default is 1000.\n " +
230249 "--prometheus, -p: Set and enable a Prometheus metrics port. Default is none. (e.g. --prometheus=9090)\n " +
231- "--headless: Run in headless mode (no TUI, output JSON to stdout)\n " +
250+ "--headless: Run in headless mode (no TUI, output to stdout)\n " +
251+ "--format: Output format for headless mode (json, yaml, xml, csv, toon). Default is json.\n " +
252+ "--pretty: Pretty print output in headless mode\n " +
232253 "--count: Number of samples to collect in headless mode (0 = infinite)\n " +
254+ "--dump-ioreport, -d: Dump all available IOReport channels and exit\n " +
233255 "--unit-network: Network unit: auto, byte, kb, mb, gb (default: auto)\n " +
234256 "--unit-disk: Disk unit: auto, byte, kb, mb, gb (default: auto)\n " +
235257 "--unit-temp: Temperature unit: celsius, fahrenheit (default: celsius)\n " +
@@ -313,7 +335,11 @@ func renderUI() {
313335 defer renderMutex .Unlock ()
314336 w , h := ui .TerminalDimensions ()
315337 if w > 2 && h > 2 {
316- ui .Render (mainBlock , grid )
338+ if killPending {
339+ ui .Render (mainBlock , grid , confirmModal ) // Render on top
340+ } else {
341+ ui .Render (mainBlock , grid )
342+ }
317343 } else {
318344 ui .Render (mainBlock )
319345 }
@@ -346,8 +372,9 @@ func Run() {
346372 flag .StringVar (& prometheusPort , "prometheus" , "" , "Port to run Prometheus metrics server on (e.g. :9090)" )
347373 flag .StringVar (& prometheusPort , "p" , "" , "Port to run Prometheus metrics server on (e.g. :9090)" )
348374 flag .BoolVar (& headless , "headless" , false , "Run in headless mode (no TUI, output JSON to stdout)" )
349- flag .BoolVar (& headlessPretty , "pretty" , false , "Pretty print JSON output in headless mode" )
375+ flag .BoolVar (& headlessPretty , "pretty" , false , "Pretty print output in headless mode" )
350376 flag .IntVar (& headlessCount , "count" , 0 , "Number of samples to collect in headless mode (0 = infinite)" )
377+ flag .StringVar (& headlessFormat , "format" , "json" , "Output format for headless mode: json, yaml, xml, csv, toon" )
351378 flag .IntVar (& updateInterval , "interval" , 1000 , "Update interval in milliseconds" )
352379 flag .IntVar (& updateInterval , "i" , 1000 , "Update interval in milliseconds" )
353380 flag .Bool ("d" , false , "Dump all available IOReport channels and exit" )
0 commit comments