lmorg/readline

how to block ctrl+c feature to exit?

Conanjun opened this issue · 2 comments

i have checked filterInput func and can't find readline.CharCtrlC while i saw the demo code

func filterInput(r rune) (rune, bool) {
	//fmt.Println(r)
	switch r {
	// block CtrlZ feature
	case readline.CharCtrlZ:
		return r, false
	}
	return r, true
}
lmorg commented

Hi @Conanjun

That behaviour is hardcoded in readline.go

case charCtrlC:
	rl.clearHelpers()
	return "", CtrlC

I can push an update this weekend to make that behaviour optional though.

With regards to the filterInput func you've found, that's for a different readline library (also written in Go). Coincidentally I had the same issues as yourself with regards to getting filterInput working properly which is what drove me to write my own readline library. However I've not check the status of that project in a while so it might have improved since.

lmorg commented

Sorry, real life had gotten in the way so never did pick up this piece of work. I'm going to close this ticket because you've not asked for it again since (and it's been a year). But happy to re-open if this is an issue.