diff_screen: Compare two screen buffers

View source: R/diff.R

diff_screenR Documentation

Compare two screen buffers

Description

Computes the minimal set of horizontal runs of cells that must be rewritten to turn the screen old into new. Nearby runs on the same row are merged when rewriting the unchanged cells between them is cheaper than an extra cursor movement.

Usage

diff_screen(old, new, merge_gap = 3L)

Arguments

old, new

ScreenBuffer objects (old may be NULL).

merge_gap

Runs separated by at most this many unchanged cells are merged.

Details

If old is NULL or has different dimensions, the patch covers every non-blank cell of new and is marked full = TRUE; the renderer then clears the screen first.

Value

A termr_patch: a list with full (logical), width, height and runs, a list of runs. Each run has y, x and vectors chars, fg, bg, attrs copied from new.

Examples

a <- screen_buffer(10, 2)
b <- a$copy()
b$put_text(3, 2, "hi")
diff_screen(a, b)

termr documentation built on Oct. 21, 2026, 5:13 p.m.