This commit is contained in:
2025-02-05 10:16:25 +03:00
parent 757358fded
commit be9f37a459
6 changed files with 173 additions and 33 deletions

View File

@@ -11,17 +11,16 @@ Create a file `screen_example.vsh`:
import freeflowuniverse.herolib.osal.screen
// Create a new screen session with hardcoded parameters
mut s := screen.Screen{
name: 'test_session'
cmd: '/bin/bash' // Default shell
}
// Create a new screen factory
mut sf := screen.new()!
// Check if screen is running
is_running := s.is_running() or {
println('Error checking screen status: ${err}')
return
}
// Add a new screen session
mut s := sf.add(
name: 'myscreen'
cmd: '/bin/bash' // optional, defaults to /bin/bash
start: true // optional, defaults to true
attach: false // optional, defaults to false
)!
// Get session status
status := s.status() or {
@@ -40,6 +39,12 @@ s.attach() or {
println('Error attaching: ${err}')
return
}
// Kill the screen when done
sf.kill('myscreen') or {
println('Error killing screen: ${err}')
return
}
```
## Basic Screen Commands

View File

@@ -7,8 +7,8 @@ import os
import time
@[heap]
struct Screen {
mut:
pub struct Screen {
pub mut:
cmd string
name string
pid int
@@ -16,7 +16,7 @@ mut:
// factory ?&ScreensFactory @[skip; str: skip]
}
enum ScreenState {
pub enum ScreenState {
unknown
detached
}