Commit Graph

22654 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
b68f391232 Re-implement text justification
* GuiFontMetrics::pos2x, x2pos: add support for inter-word spacing.
* GuiPainter::text: idem

* Row::Element::countSeparators:
  Row::countSeparators: new methods that count spaces in strings.
  Row::setSeparatorExtraWidth: new method (code lifted from TextMetrics.cpp).

* TextMetrics::computeRowMetrics: rely on the above methods.

* RowPainter::paintMispelledMarked: pass only a Row::Element object reference
  RowPainter::paintStringAndSel: idem; do not rely on values returned by
      Painter::text (trailing spaces do not honor wordspacing value).
2015-07-20 23:43:05 +02:00
Jean-Marc Lasgouttes
f65f3adbf7 Do not break row elements at spaces
The goal of this commit is to make painting faster by reducing the
number of strings to paint. To this end, it is necessary to include
spaces in row elements.

Also importantly, this commit should fix existing problems with line
breaking in chinese text.

* TextMetrics::breakRow: do not do anything special for word separators.

* Row::add: when adding a character to a row element, keep the string
  width updated. If need be, it is possible to tweak this by updating
  every 10 characters, for example.

* GuiFontMetrics::breakAt (new): use QTextLayout to break text either
  at word boundary or at an arbitrary width.

* Row::Element::breakAt: use the above method.

* Row::shortenIfNeeded: simplify now that because there is no need for
  handling separator elements. This will be taken care of by the
  improved breakAt.

Two things remain to be done:

* remove all traces of separator row element

* re-implement text justification.
2015-07-20 21:22:53 +02:00
Jean-Marc Lasgouttes
038f003be6 Rewrite RowPainter::paintOnlyInsets to use row elements 2015-07-18 20:37:53 +02:00
Jean-Marc Lasgouttes
d328fb2021 Rewrite Cursor::posVisToRowExtremity without Bidi class
It is trivial to implement it using TextMetrics::getPosNearX.
2015-07-18 00:39:55 +02:00
Jean-Marc Lasgouttes
412a724aaf Some fixups to row margins
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.
2015-07-18 00:17:00 +02:00
Jean-Marc Lasgouttes
f750d9b5cf Remove old cruft
There are many things that are not necessary anymore:

* remove methods paintText2, paintFromPos, leftMargin, paintInlineCompletion

* Remove use of Bidi class.

* add a Font and a Change parameter to paintInset.

Also remove a comment that describes what we have just done.
2015-07-16 23:56:24 +02:00
Jean-Marc Lasgouttes
83afe2e547 Rely on Row elements to draw rows.
The new version of paintText is quite short. Elements are treated one
by one. They are already in the right ordering.

The other changes are:

* a new paintChange method is added (using code lifted from old version)

* in paintLast, the support for end of paragraph markers is removed
  (this is already part of the Row object.
2015-07-16 23:24:45 +02:00
Jean-Marc Lasgouttes
1de0d2a19b Code cleanup in RowPainter
* move some code that handle selection to paintInset()

* change the arguments of paintSeparator()
2015-07-16 23:24:28 +02:00
Georg Baum
0cbcc8a166 Remove InsetGraphics noUnzip parameter
Being able to compile document with zipped .eps files was a useful feature of
the graphicxs package 20 years ago, but the LyX support is no longer relevant:
- The flag is ignored if preview is on
- If pdflatex is used then uncompressing happens during the compilation anyway
- If set, the flag prevents LyX from issuing proper error messages if
something with the image is wrong
- For hard disk capacities from 20 years ago not uncompressing is a useful
feature, but for current hard disk capacities it does not matter
- The external inset does not have it, and if we want to merge both insets
one day we would need to implement it there, which is even more difficult
than in InsetGraphics
2015-07-16 20:44:47 +02:00
Jean-Marc Lasgouttes
d87ce2c91f Update comment. 2015-07-16 19:33:29 +02:00
Jean-Marc Lasgouttes
a7896cb190 End all Undo::Private members names with an underscore 2015-07-16 14:48:23 +02:00
Jean-Marc Lasgouttes
96692bdbb0 Move some functions out of Bidi.*
The functions reverseDirectionNeeded() and reverseDirectionNeeded() do
not rely on the Bidi class. The first one is changed into a Cursor
method, and the second one is replaced with explicit code.
2015-07-16 11:57:40 +02:00
Jean-Marc Lasgouttes
f51d7fdd2a Compilation fix for windows
Since commit 7ac70092, lyx::dispatch returns a DispatchResult const &,
which is ignored in the cases below. Nevertheless, the windows
compiler complains that it does not know this type. Gcc and clang can
deal with it without problem.
2015-07-16 09:48:57 +02:00
Jean-Marc Lasgouttes
0f1fdaaa97 Remove extra row painting added by horizontal scroll branch
The bug workaround added an extra repaint, which can be very bad when
editing large tables.

It turns out that the bug this is trying to fix is due to the handling
of LFUN_LINE_END in InsetMathGrid. Adding the same code as in
InsetMathNest fixes the problem.

The workaround can therefore be removed.
2015-07-15 23:12:34 +02:00
Jean-Marc Lasgouttes
6c8520f100 Rename paintTextAndSel to paintStringAndSel 2015-07-15 22:47:47 +02:00
Jean-Marc Lasgouttes
75640b66e5 When adding completion to a row, add also the unique part
The unique and non-unique parts of the completion are show in different colors.
2015-07-15 21:38:55 +02:00
Jean-Marc Lasgouttes
cb0dbfdadb Avoid crash when inserting space in the middle of misspelled character
This is a fixup to commit 4796e6b3.
2015-07-15 20:38:07 +02:00
Günter Milde
605b933ec2 Add "TODO-comments" with link to textcyr/textgreek tickets.
Add links to tickets #9637 and  #9681 at places that require 
changes in the code and/or comments.
2015-07-15 18:55:30 +02:00
Jean-Marc Lasgouttes
7ac700920f Auto feature for minibuffer toolbar
Now the minibuffer toolbar is "auto" by default. It is opened by
command-execute (M-x) and closed when the command is executed without error.

* make lyx::dispatch return a DispatchResult struct

* there is a new MINIBUFFER type of toolbar, that can be used for this use.

* remove special handling of M-x in minnibuffer; Escape can be used instead. Fix focus in this case.

* when minibuffer toolbar is "auto", make the toolbar close itself after
  - a command has been executed without error
  - an empty command has been executed
  - the Escape key has been used

[this is actually commit fdcff02a, which was later reverted at dd61d8cf]
2015-07-15 17:41:09 +02:00
Jean-Marc Lasgouttes
4796e6b337 Avoid breaking kerning with continuous spell checking
There is a mismatch between the way text is tokenized in Row objects
and the way it is shown on screen. When metrics are computed,
continuous spell checking has not been done yet. Yet, the row painter
explicitly breaks words at spell status boundaries. This creates
problem with a text like "PMP," (see bug #9649), where there is a
negative kerning before the comma.

This is solved by not taking in account spell status when drawing
text, and drawing spell underlines separately.

* replace Paragraph::isSameSpellRange with new method getSpellRange.

* merge RowPainter::paintChars into RowPainter::paintFromPos

* move the actual text painting code into the new paintTextAndSel.

* merge some code from paintFromPos to paintMisspelledMark

* in paintMisspelledMark, scan the string which needs to be annotated
  and add dashed line below text marked as misspelled.

Fixes bug #9649.
2015-07-15 12:13:24 +02:00
Jean-Marc Lasgouttes
1136bc4fb2 Convert a few more variables to int
This avoids warnings with windows compiler. It is a pity that even
clang does not give those. Maybe I missed them with the large amount
of boost warnings that it spits.
2015-07-15 10:16:42 +02:00
Jean-Marc Lasgouttes
a05b8be4bf Always use unicode override characters to enforce direction
There is a second solution in the code which uses some undocumented Qt
stuff, but it does not work in some cases. The best is to rely on the
documented way.
2015-07-14 23:19:26 +02:00
Jean-Marc Lasgouttes
8f73d1e56b Fix comment. 2015-07-14 18:03:58 +02:00
Jean-Marc Lasgouttes
463bd17d75 Use integer line thickness in painter
There is no need for real-valued line width in painters. Actually, this even leads to uneven dashes for continuous spell checker.

The new code is supposed to be equivalent to the old one, just more readable. From this, we can try to see whether some lines need to be made thicker on HiDPI screens.
2015-07-14 17:42:45 +02:00
Günter Milde
468cedb923 Fix #9679 textcyr fails without fontenc 2015-07-14 14:47:44 +02:00
Kornel Benko
789e7f7ed9 Cmake tests: Add missing definition for check_Length_SOURCES
This was forgotten in previous commit ccbac353ea
2015-07-12 18:59:24 +02:00
Georg Baum
ccbac353ea Fix Length::inBP()
Length::inBP() returned the wrong values for most units. I guess that this was
caused by the default case in the switch statement: It did probably exist
before the other units were added.
inBP() is now correct for all units except the font dependent ones em, ex and
mu and the percent units: For these only approximate values are returned,
since not all needed information is available.
2015-07-12 18:36:19 +02:00
Georg Baum
7910502b8e Add unit test for the Length class
I noticed that inBP() is wrong for several units and want to fix it.
The unit test will help me to find regressions.
2015-07-12 18:10:43 +02:00
Günter Milde
3f6b034167 Fix Ticket #9607 (support comma below accent in unicodesymbols).
LaTeXFeatures defines \textcommabelow and \textcommaabove based on a 
generic \LyXTextAccent and declares TextCompositeCommands for the Baltic 
letters in the T1 font encoding, using \textcommaabove for the small letter g 
and \textcommabelow else.

This allows overwriting of the composite definition for other font encodings. 
Especially, it does not interfere with the polish/baltic font encoding L7x 
(supported by LatinModern and TeXGyre fonts)  that provides pre-composed 
glyphs.
2015-07-12 16:21:25 +02:00
Günter Milde
5a47e4bc70 Fix #9636 textgreek: restore compatibility with lgrenc.def.
Greek characters with perispomeni (tilde) accent were not properly shown
in the output document, because the "textgreek" feature re-defined \~ in
a way incompatible with lgrenc.def since version 0.8  (2013-05-13)
(package greek-fontenc).

The compatibility-definition is required for older versions of the font setup
(before the move of "lgrenc.def" from "babel" to "greek-fontenc").
It is now done with "ProvideTextCommand" to not overwrite the more complete
implementation in lgrenc.def.
With the compatibility definition, combined diacritics with tilde
must be input with the tilde first (e.g. \~>, not \>~).
"unicodesymbols" is changed accordingly.

Also, some LICRs for combining Greek diacritical characters were added to
Unicodesymbols.
2015-07-11 15:39:02 +02:00
Jean-Marc Lasgouttes
7d018853fc Position better the cursor after math-display
When the cursor had idx > 0 (since math-display does merging anyways),
reset cursor to the start of the inset. This looks less strange than
setting it at the end.

Now at least the basic case of a displayed equation with cursor
somewhere at top-level is handled correctly.

The math-display lfun operates at top level in the math inset.
Therefore, when the cursor is in an inner inset, it will after the
lfun be moved at top level. Unfortunately, there is no way that I know
f to detect this in Inset::doDispatch.

Even if we could, as things stand, it is difficult to keep the cursor in the
inner inset, especially if the inner inset moves : this happens for
example when moving from eqnarray to inline maths.

Therefore this fix is the best I can think of now.

Fixes part of bug #9664.
2015-07-09 12:00:25 +02:00
Stephan Witt
6e9bd23a1f Add paths of private frameworks to linker rpath options 2015-07-08 17:56:26 +02:00
Jean-Marc Lasgouttes
f41e423b30 Small clean-up to debug support 2015-07-08 11:03:42 +02:00
Enrico Forestieri
b7dd5ade94 Remove unneeded header
Forgot this at 4dff1394
2015-07-06 23:47:22 +02:00
Günter Milde
c56f0538a0 Fix clash between marvosym and bbding packages (fixes #7811).
Both marvosym and bbding define the "Cross" macro.
To prevent a compilation error due to conflicting definitions, 
we undefine the "Cross" macro if both packages are required.
2015-07-06 14:10:34 +02:00
Enrico Forestieri
4dff1394ab Avoid calling Buffer::getMacro inside the MathMacro copy constructor
It turns out that it is always better using the copy of the MacroData
for updating the macro_ pointer to avoid problems related to the cursor
position.
2015-07-05 20:44:54 +02:00
Stephan Witt
8a772549d7 Fix for #9659 - Qt may send more then one close event to a window. Therefore multiple calls to unregisterView for a GuiView are possible. The first one removes the view from the list of known views, subsequent calls do nothing. 2015-07-04 18:59:29 +02:00
Scott Kostyshak
0d52736061 Remove an incorrect horizontal size policy
This effectively makes the horizontal size policy "minimum", which
makes it clear that there is no advantage for this widget of
increasing the horizontal size past the minimum, allowing other
GUI elements to use the horizontal space if useful.

This change for caseCB is consistent with wordsCB and searchbackCB.
2015-07-02 10:33:38 -04:00
Enrico Forestieri
2072de8349 Avoid code duplication 2015-06-30 19:27:38 +02:00
Enrico Forestieri
305a712bbb Avoid using a dangling pointer
This can happen when a macro is copied and then the document where
it is defined is closed. In this case, the macro survives in the
cut stack but the the buffer pointer is dangling.
2015-06-30 18:54:19 +02:00
Jean-Marc Lasgouttes
dd61d8cf3f Revert "Auto feature for minibuffer toolbar"
This reverts commit fdcff02a31.

This was pushed too early, we are not ready yet.
2015-06-30 11:09:48 +02:00
Jean-Marc Lasgouttes
c8c1ee72bc Constify RowPainter (no intended change) 2015-06-29 16:12:11 +02:00
Jean-Marc Lasgouttes
fdcff02a31 Auto feature for minibuffer toolbar
Now the minibuffer toolbar is "auto" by default. It is opened by
command-execute (M-x) and closed when the command is executed without error.

* make lyx::dispatch return a DispatchResult struct

* there is a new MINIBUFFER type of toolbar, that can be used for this use.

* remove special handling of M-x in minnibuffer; Escape can be used instead. Fix focus in this case.

* when minibuffer toolbar is "auto", make the toolbar close itself after
  - a command has been executed without error
  - an empty command has been executed
  - the Escape key has been used
2015-06-29 09:21:15 +02:00
Georg Baum
8a27143e72 Test negative numbers as well 2015-06-28 11:27:17 +02:00
Georg Baum
b8eb4fffee Make it explicit that we need floating point abs
The 'using namespace std' at the top of the file makes it quite difficult to
understand which abs is used: double std::abs<double>(double) or
int ::abs(int)? Now it is explicit, and the code does not change in subtle
ways if somebody removes the using statement.
2015-06-28 11:27:17 +02:00
Scott Kostyshak
6c3a6ea9bd Give Advanced Find a minimum size
The horizontal size policy is now set to "MinimumExpanding", which
means that sizeHint() is enforced as a minimum, but that the widget
can make use of extra available space.

Before, the size policy was ignored, and often resulted in a
scrunched pane that had to have its size manually increased.
2015-06-28 05:16:49 -04:00
Scott Kostyshak
8f1b7f47fa FindAndReplaceUi: update format 2015-06-28 05:16:14 -04:00
Enrico Forestieri
9b0e5215d9 Was forgetting this 2015-06-26 22:54:23 +02:00
Enrico Forestieri
67c52ae773 Amend c9d9309c
It suffices taking the log of the absolute value.
2015-06-26 22:49:17 +02:00
Juergen Spitzmueller
c9d9309c1e Fix formatFPnumber with negative doubles. 2015-06-26 15:49:44 +02:00