github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/readline/raw_js.go (about)

     1  //go:build js
     2  // +build js
     3  
     4  package readline
     5  
     6  import "github.com/lmorg/murex/utils/virtualterm"
     7  
     8  // VTern is a virtual terminal
     9  var VTerm = virtualterm.NewTerminal(120, 40)
    10  
    11  type State struct {
    12  	state virtualterm.PtyState
    13  }
    14  
    15  func MakeRaw(_ int) (*State, error) {
    16  	state := State{state: VTerm.MakeRaw()}
    17  	return &state, nil
    18  }
    19  
    20  func Restore(_ int, state *State) error {
    21  	VTerm.Restore(state.state)
    22  	return nil
    23  }
    24  
    25  // GetSize the default terminal size in the webpage
    26  func GetSize(_ int) (width, height int, err error) {
    27  	return VTerm.GetSize()
    28  }