code: func DrawTerminalf(w io.Writer, f DrawTextFormatFunc) DrawFunc {
  	var maxLength int
  
  	return func(progress, total int64) error {
  		if progress == -1 && total == -1 {
  			_, err := fmt.Fprintf(w, "\n")
  			return err
  		}
  
  		// Make sure we pad it to the max length we've ever drawn so that
  		// we don't have trailing characters.
  		line := f(progress, total)
  		if len(line) < maxLength {
  			line = fmt.Sprintf(
  				"%s%s",
  				line,
  				strings.Repeat(" ", maxLength-len(line)))
  		}
  		maxLength = len(line)
  
  		_, err := fmt.Fprint(w, line+"\r")
  		return err
  	}
  }
docs: // DrawTerminalf returns a DrawFunc that draws a progress bar to an io.Writer
  // that is formatted with the given formatting function.