On Tue, Dec 01, 2020 at 07:36:20PM -0500, James K. Lowden wrote: > I have a basic how-does-one question about scrolling text in a window. > > I have the beginnings of an application that reads troff ditroff output > and renders it on-screen. The underlying libraries are > > -lGL -lglut -lX11 -lXi -lXft -lfontconfig -lcairo -lfreetype > > Let's say the rendering has room for improvement, and is already better > than xman(1). > > My question is: how to scroll pages of text? > > The troff output is potentially many pages, and the user will want to > scroll up and down, as he does, say, viewing the bash(1) manual in GNU > less(1). > > Currently I open a cairo surface on the main window. Scrolling a > screen of text up one line would require ... something. I could erase > the whole thing and start over with line 2 at the top, replacing line > 1. > > An alternative, I think, is to render the whole document to a bitmap, > and scroll the bitmap up and down using just X primitives. That
I suggest to use some pixmap (or perhaps pixmap-backed cairo surface) reasonably larger than a window, but not a whole docu- ment. Simple scrolling would be rather fast (all the data is al- ready rendered, you should just copy it somehow inside one pixmap), and you could draw the new areas off-screen somewhat later. On the other side, a whole troff document with hundreds A4 pages with a reasonable 200 dpi resolution and 8-bit grayscale an- tialiasing render -- may take more that a gig of RAM, causing un- neccessary paging. _______________________________________________ [email protected]: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: https://lists.x.org/mailman/listinfo/xorg Your subscription address: %(user_address)s
