func (c *Cursor) Listen(line []rune, pos int, key rune) ([]rune, int, bool) {
	if line != nil {
		// no matter what, update our internal representation.
		c.Update(string(line))
	}

	switch key {
	case 0: // empty
	case KeyEnter:
		return []rune(c.Get()), c.Position, false
	case KeyBackspace:
		if c.erase {
			c.erase = false
			c.Replace("")
		}
		c.Backspace()
	case KeyForward:
		// the user wants to edit the default, despite how we set it up. Let
		// them.
		c.erase = false
		c.Move(1)
	case KeyBackward:
		c.Move(-1)
	default:
		if c.erase {
			c.erase = false
			c.Replace("")
			c.Update(string(key))
		}
	}

	return []rune(c.Get()), c.Position, true
}
func (c *Cursor) Listen(line []rune, pos int, key rune) ([]rune, int, bool) {
	if line != nil {
		
		c.Update(string(line))
	}

	switch key {
	case 0: 
	case KeyEnter:
		return []rune(c.Get()), c.Position, false
	case KeyBackspace:
		if c.erase {
			c.erase = false
			c.Replace("")
		}
		c.Backspace()
	case KeyForward:
		
		
		c.erase = false
		c.Move(1)
	case KeyBackward:
		c.Move(-1)
	default:
		if c.erase {
			c.erase = false
			c.Replace("")
			c.Update(string(key))
		}
	}

	return []rune(c.Get()), c.Position, true
}
func ( c * Cursor ) Listen ( line [ ] rune , pos int , key rune ) ( [ ] rune , int , bool ) { if line != nil { // no matter what, update our internal representation. c . Update ( string ( line ) ) } switch key { case 0 : // empty case KeyEnter : return [ ] rune ( c . Get ( ) ) , c . Position , false case KeyBackspace : if c . erase { c . erase = false c . Replace ( " " ) } c . Backspace ( ) case KeyForward : // the user wants to edit the default, despite how we set it up. Let // them. c . erase = false c . Move ( 1 ) case KeyBackward : c . Move ( - 1 ) default : if c . erase { c . erase = false c . Replace ( " " ) c . Update ( string ( key ) ) } } return [ ] rune ( c . Get ( ) ) , c . Position , true }
// Listen is a readline Listener that updates internal cursor state appropriately.
Listen is a readline Listener that updates internal cursor state appropriately .