Skip to content

Manage graphics placements vertical position on text reflow.

Matan Ziv-Av requested to merge matan/konsole:reflow-images into master

When a line is reflowed then the vertical position of all graphics placements above or below it (as appropriate) are adjusted, so they remain in the same place relative to the text lines.

Until now only the vertical resize of the terminal was handled separately in terminalDisplat.cpp. Now all cases are handled in Screen.cpp, where it makes more sense. This also allows the scrollPlacements function to become private.

It is not possible to handle all cases (without a lot of semantic hints from the application, and even with). For example, even text only tables are broken by reflow:

abc def
xyz xyz
123 456

reflows to:

abc d
ef
xyz x
yz
123 4
56

This MR aims to handle the simple case of images and text on separate lines. e.g.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
+--+
|  |
+--+

 tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in 
+----+
|    |
+----+
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
+-+
| |
| |
| |
| |
+=+

In my testing this seems to be handled properly (the images start below the same lines of text) for all text reflows resulting from window resizes and font changed.

The images are not scaled and the number of lines they occupy is not changed. Changing to a taller font will increase the space from the bottom of the image to the line of text below it. Changing to a less tall font will cause the line below to intersect with the image.

Merge request reports