code: func (state *TextEditor) tonl(start int, dir int) int {
  	sz := len(state.Buffer)
  
  	i := start
  	if i < 0 {
  		return 0
  	}
  	if i >= sz {
  		i = sz - 1
  	}
  	for ; (i >= 0) && (i < sz); i += dir {
  		c := state.Buffer[i]
  
  		if c == '\n' {
  			if dir >= 0 {
  				return i
  			} else {
  				return i + 1
  			}
  		}
  	}
  	if dir < 0 {
  		return 0
  	} else {
  		return sz
  	}
  }
docs: // Moves to the beginning or end of a line