// NewTerminal creates a terminal and sets it to raw input mode.

NewTerminal creates a terminal and sets it to raw input mode.
// NewTerminal creates a terminal and sets it to raw input mode .
func NewTerminal() (*Terminal, error) {
	term := &Terminal{
		In:       os.Stdin,
		Out:      os.Stdout,
		History:  make([]string, 0, 10),
		histIdx:  -1,
		terminal: new(terminal),
	}
	err := syscall.GetConsoleMode(syscall.Handle(term.In.Fd()), &term.origMode)
	if err != nil {
		return term, nil
	}
	mode := term.origMode
	term.isTerm = true
	mode &^= (echoInputFlag | insertModeFlag | lineInputFlag | mouseInputFlag |
		processedInputFlag | windowInputFlag)
	ret, _, err := setConsoleMode.Call(term.In.Fd(), uintptr(mode))
	if ret == 0 {
		return nil, err
	}
	return term, nil
}
func NewTerminal ( ) ( * Terminal , error ) { term := & Terminal { In : os . Stdin , Out : os . Stdout , History : make ( [ ] string , 0 , 10 ) , histIdx : - 1 , terminal : new ( terminal ) , } err := syscall . GetConsoleMode ( syscall . Handle ( term . In . Fd ( ) ) , & term . origMode ) if err != nil { return term , nil } mode := term . origMode term . isTerm = true mode &^= ( echoInputFlag | insertModeFlag | lineInputFlag | mouseInputFlag | processedInputFlag | windowInputFlag ) ret , _ , err := setConsoleMode . Call ( term . In . Fd ( ) , uintptr ( mode ) ) if ret == 0 { return nil , err } return term , nil }
NewTerminal creates a terminal and sets it to raw input mode.
NewTerminal creates a terminal and sets it to raw input mode .
// Set new mode flags.
