func (t *Terminal) Run() { C.fargo_install_rl() interrupts := make(chan os.Signal, 1) signal.Notify(interrupts, os.Interrupt) /* "event loop" for the terminal */ err := 0 for err >= 0 { if t.promptChange { t.promptChange = false if t.prompt != nil { C.free(unsafe.Pointer(t.prompt)) } t.prompt = C.CString(t.nick + ":" + t.cwd + " $ ") C.rl_set_prompt(t.prompt) C.rl_redisplay() } /* Couldn't ever figure out FD_SET for select... */ err = int(C.fargo_select_stdin()) if err > 0 { C.rl_callback_read_char() } /* check for things to do from channels */ looping := true for looping { select { case msg := <-t.msgs: C.fargo_clear_rl() println(msg) C.rl_forced_update_display() case <-interrupts: t.quit() default: looping = false } } } C.rl_callback_handler_remove() }
// rl_forced_update_display / redraw func ForceUpdateDisplay() { C.rl_forced_update_display() }