Lines that wrap the right-most column of the terminal are not currently managed in the CLI pager code meaning that such output is treated as a single line when it may occupy two or more on-screen; this means that more actual lines than one page of output will be displayed.
Related to this, if the terminal is resized while the pager is active, the current page is not redrawn with the new dimensions.
To track this efficiently, instead of chopping incoming lines on \n, store a copy of the whole line in a vector. Alongside this maintain an index of screen lines that maps a displayable line to the start and end of the text to be displayed. The lines in this index are cropped at the terminal width or on \n's.
The pager then uses the lines in the index to determine a page, rather than chopping the input only on \n's.
If a resize event occurs, the index can be rebuilt and the current page re-displayed.