In breakRow set left and right margin properly for RTL paragraphs.
Remove corresponding code from ComputeRowMetrics.
In row painter, check the use of left and right margin depending on
context. The problem in the original text is that the various
leftMargin() methods actually represent right margin for RTL
paragraphs. This should be fixed eventually.
The document iterator now skips math insets and insets like notes where spell check is disabled.
The continuous spell checking is part of the row painter drawing and the spell check disabled state
has to be passed down recursively while doing the inset painting.
* Remove the UndoKind parameter in the general interface
* move recordUndoInset to Cursor
* remove one variant of Undo::recordUndo.
* get rid of Text::recUndo.
The computation of length on screen depend in particular of the computation of the size of an em. Many places of the code used to rely on the width of the M character, which is not really correct:
http://en.wikipedia.org/wiki/Em_%28typography%29
In digital typography, the best value to use is the point size of the font.
* Implement FontMetrics::em(), which returns the value in pixels of the EM unit.
Convert code to use it.
* Introduce Length::inPixel(MetricsBase const &), which takes the textwidth and em information from the MetricsBase object. Convert code to use it.
* Fix several places where Length::inPixel is used without a proper em value.
* add mathed_font_em() helper function. It should eventually be removed like some other functions in MathSupport.
* Add dummy implementation of FontMetrics to tex2lyx for linking purposes.
There are several places in the code where a row is painted with drawing disabled in the painter. The goal is only to recompute inset positions.
Such a case happens in BufferView::checkCursorScrollOffset, as part of the horizontal scrolling patch. Note that this particular piece of code should eventually be removed, since it is a performance problem.
It makes sense to consider that only a real painting of a row should change its status. However, I would not be surprised if this change would break other things.
Fixes: #9388
There are several places in the code where a row is painted with drawing disabled in the painter. The goal is only to recompute inset positions.
Such a case happens in BufferView::checkCursorScrollOffset, as part of the horizontal scrolling patch.
It makes sens to consider that only a real painting of a row should change its status. However, I would not be surprised if this change would break other things.
Fixes: #9388
This implement horizontal scrolling of rows to allow editing insets
(math, tabular...) that are larger then the screen. The scrolling happens
as the cursor moves, in order to make sure that the cursor is always visible.
This effectively closes an 11 years old bug.
This feature is the result of the work of Hashini Senaratne as part of
Google Summer of Code 2013. The code has been cleaned-up for inclusion
and remaining bugs have been fixed.
Fixes bug: #1083.
* When doing a redraw with drawing disabled (to set inset positions properly), take horizontal scroll offset in account
* reset horizontal scroll offset when it is smaller than the left margin.
* when drawing a paragraph, do not modify x globally, only for the row that is offset.
[This commit is the output of the "horizontal scrolling" GSoC 2013
project, by Hashini Senaratne. The code has been cleaned up, some
variables have been renamed and moved from the Cursor class to
BufferView::Private. This is the base from which I (jmarc) will polish
the feature for landing on master.
Below is the original commit log of Hashini, updated to reflect the
changes that have been done.]
This feature also applicable for other insets; graphics and labels.
This implementation is capable of scrolling a single row when reaching
its content which is beyond the screen limits, using left and right
arrow keys.
The attribute 'horiz_scroll_offset_' introduced in the
BufferView::Private class plays a main role in horizontal scrolling of
the wide rows that grow beyond the screen limits. This attribute
represents by how much pixels the current row that the text cursor
lies in should be get scrolled.
The main logic that is responsible for drawing the scrolled rows is
within the BufferView class, BufferView::checkCursorScrollOffset.
* The main logic is called via BufferView::draw.
* What this does is set the horiz_scroll_offset_ attribute in in order to
show the position that the text cursor lies in.
* To make sure that BufferView::draw gets involved when Update flag is
FitCursor, necessary changes are made in BufferView::processUpdateFlags.
Basically what the logic that used to set the horiz_scroll_offset_
does is,
* The row which the text cursor lies in is identified by a
CursorSlice that points to the beginning of the row. This is the
'rowSlice' variable used in BufferView::checkCursorScrollOffset. Acessors
are added to obtain this variable. Here row objects were not used to
identify the current row, because it appears that row objects can
disappear when doing a decoration update for example. This means that
comparing row pointers is not a good idea, because they can change
without notice.
* Stop calculations of horiz_scroll_offset_ variable, if metrics have not been
computed yet. Otherwise the calls to TextMetrics::parMetrics, calls
redoParagraph and may change the row heigths. Therefore vertical scrolling
feature may get disturbed. This is avoided.
* Using BufferView::::setCurrentRowSlice resets horiz_scroll_offset_
when changing cursor row. This is done in order to prevent unwanted
scrolling that happens when changing the selected row using up and
down arrow keys.
* Recompute inset positions before checking scoll offset of the row, by
painting the row insets with drawing disabled. This is done because the
position of insets is computed within the drawing procedure.
* Current x position of the text cursor is compared with the
horiz_scroll_offset_ value and the other variables like row.width(),
bv.workWidth(). Compute the new horiz_scroll_offset_ value in order
to show where the text cursor lies in. The basics conditions that we
check before recomputing it are, if the text cursor lies rightward to
the current right screen boundary, if the text cursor lies leftward
to the current left screen boundary, if the text cursor lies within
screen boundaries but the length of the row is less than the left
boundary of the screen (this happens when we delete some content of
the row using delete key or backspace key).
* Change update strategy when scrooll offset has changed. This allows to
redraw the row when no drawing was scheduled. By doing so, it was
possible to redraw a wide row when moving to the leftmost position of the
wide row, from the leftmost position of the row below, using the left
arrow key.
In TextMetrics::drawParagraph it is checked whether the current row is
what is drawing now. If it is so, the value used to the x value of the row
for drawing is adapted according to BufferView::horizScrollOffset.
The method used to pass boundary() was fixed to get row when cursor was in
a nested inset. This matter is considered in Cursor::textRow and it is
modified accordingly.
GuiWorkArea::Private::showCursor() is modified to show the cursor position
in a scrolled row.
All the code that is run before row metrics have been computed should use int arithmetic. After metrics have been computed, we still need doubles because fully justified rows use double for Row::Element::extra.
Rename Row::x to Row::left_margin and change its type to int.
Rename Row::Element::width() to full_width(). In some places of the code, use dim.wid (the int version without the extra separator) because metrics have not been computed.
Let Row::Element::x2pos take a int& argument instead of double&
Let Row::Element::breakAt take a int argument instead of double
The problem was that some parts of the code assume that the right margin is part of the width of the row. This is not the case, only the left margin (Row::x) is counted.
The code has been fixed and documented to reflect this.
This can only be done where splitting of string is identical in row breaking and display. It will be possible to reintroduce this when row painting uses the tokenized row information.
This variable was introduced to guard against any bad consequence of the then-new right-to-left
languages support. Let's be bold and get rid of it altogether!
Now right to left support is always enabled.
This commits (tries to) reintroduce properly the code that was reverted at the beginning of this branch. This had to be done because these patches interefered with the big refactoring of TextMetrics.cpp.
This commit reintroduces the changes to TextMetrics.cpp contained in c668ebf6, c85dbfea9 and 061509bf.
Moreover, breaks row at insets when there is no suitable separator.
Also make the code of Row::shorten_if_needed somewhat simpler by using
iterators and factoring the code.
Fixes: #9120
All these problems are related to what happens at the extreme points of rows
* since VIRTUAL elements have a width but no contents, they have to
be treated specially at some places. It would have been better to
avoid testing for them explicitly, but I did not find a way.
* Improve and cleanup the code in breakRow and fix in passing a crash
when clicking on the right of an incomplete MARGIN_MANUAL
paragraph.
* improve the computation of row width in TextMetrics::computeRowMetrics.
* handle properly the case where a position if not found on the row
in both cursorX and getPosNearX (actually, this happens when
selecting).
* Some code cleanup and comments.
* fix handling of boundary situations in Row::Elements::x2pos;
* fix handling of boundary situations in TextMetrics::getColumnNearX;
* make sure to always use Font::isVisibleRightToLeft instead of Font::isRightToLeft;
* Improve debug messages.
The horizontal position of the inset was not taken in account.
The rounding is not always the same as with the old code, but this
is not really important.
Additional changes:
* improve debug output of rows
* remove Bidi& argument of the RowPainter constructor, since it is always
an empty Bifi that is passed. This means that the Bidi class is not
used at all any more in TextMetrics.cpp. The only remaining user is
RowPainter.
Break words longer than the screen width. The code is more complicated
than I would like, but I have no better idea right now.
Implement properly the notion of a row broken by a display inset. This is useful in different places.
Also fix a bug with last line of a paragraph spotted by Kornel.
Use proper font everywhere for end-of-par marker
Fix getColumnNearX for RTL text and for centered/right-justified paragraphs.
Let computeRowMetrics update the row width.
* convert cursorX to new scheme; old computation is still there for the sake of comparison.
* use Row to compute separator width in computeRowMetrics; again, the old code is retained for now.
* Get rid of rowWidth()
* Row now contains a vector of Elements
* replace Row::dump by a proper << operator
* the width is updated as elements are added
* breakRow is reimplmented to use this infrastructure