code: func prepare_diff_messages() {
  	// clear buffers
  	diffbuf = diffbuf[:0]
  	charbuf = charbuf[:0]
  
  	var diff diff_msg
  	gbeg := 0
  	for y := 0; y < front_buffer.height; y++ {
  		same := true
  		line_offset := y * front_buffer.width
  		for x := 0; x < front_buffer.width; x++ {
  			cell_offset := line_offset + x
  			back := &back_buffer.cells[cell_offset]
  			front := &front_buffer.cells[cell_offset]
  			if *back != *front {
  				same = false
  				break
  			}
  		}
  		if same && diff.lines > 0 {
  			diffbuf = append(diffbuf, diff)
  			diff = diff_msg{}
  		}
  		if !same {
  			beg := len(charbuf)
  			end := beg + append_diff_line(y)
  			if diff.lines == 0 {
  				diff.pos = short(y)
  				gbeg = beg
  			}
  			diff.lines++
  			diff.chars = charbuf[gbeg:end]
  		}
  	}
  	if diff.lines > 0 {
  		diffbuf = append(diffbuf, diff)
  		diff = diff_msg{}
  	}
  }
docs: // compares 'back_buffer' with 'front_buffer' and prepares all changes in the form of
  // 'diff_msg's in the 'diff_buf'