Ejemplo n.º 1
0
func initReadLine() {
	C.rl_catch_sigwinch = 0
	C.rl_catch_signals = 0
	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGWINCH)
	signal.Notify(c, os.Interrupt)
	go func() {
		for sig := range c {
			switch sig {
			case syscall.SIGWINCH:
				C.rl_resize_terminal()

			case os.Interrupt:
				C.rl_cleanup_after_signal()
			default:

			}
		}
	}()
}
Ejemplo n.º 2
0
// Cleanup() frees internal memory and restores terminal
// attributes. This function should be called when program execution
// stops before the return of a String() call, so as not to leave the
// terminal in a corrupted state.
func Cleanup() {
	C.rl_free_line_state()
	C.rl_cleanup_after_signal()
}
Ejemplo n.º 3
0
func Cleanup() {
	C.rl_cleanup_after_signal()
	os.Exit(0)
}