Пример #1
0
func TestRawMode(t *testing.T) {
	term, err := terminal.New(INPUT_FD)
	if err != nil {
		t.Fatal(err)
	}

	//	oldState := term.oldState

	if err = term.RawMode(); err != nil {
		t.Error("expected set raw mode:", err)
	}

	/*name, err := term.GetName()
	  if err != nil {
	  	log.Print(err)
	  }
	  println("Console", name)*/

	if err = term.Restore(); err != nil {
		t.Error("expected to restore:", err)
	}

	/*	lastState := term.State
		if oldState != lastState {
			t.Error("expected to restore settings")
		}
	*/
	// Restore from a saved state
	term, _ = terminal.New(INPUT_FD)
	state := term.OriginalState()

	if err = terminal.Restore(INPUT_FD, state); err != nil {
		t.Error("expected to restore from saved state:", err)
	}
}
Пример #2
0
// Restore restores terminal settings.
func (q *Question) Restore() error {
	if err := terminal.Restore(q.termFD, q.termState); err != nil {
		return err
	}
	return nil
}