Commit Graph

476 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
b9c7594167 Revert "Reset beginOfBody() when changing paragraph layout"
This reverts commit ef8e499821.
2016-07-21 10:15:39 +02:00
Jean-Marc Lasgouttes
ef8e499821 Reset beginOfBody() when changing paragraph layout
This looks like a trivial thing to do, and it avoids some drawing problems.

Fixes bug #10163.
2016-07-21 01:56:22 +02:00
Richard Heck
b3ab0190c1 Rename some variables and routines. 2016-07-10 00:00:03 -04:00
Richard Heck
31e25c8ec6 Fix problem with branch handling. The problem was that we were not
dealing properly with the paragraph separator tag.

We really need to use that tag as a kind of general marker for which
tags we're responsible for in a given paragraph and which tags we are
not. So the changes to InsetText.cpp use the tag as that kind of marker.

Note that, as of this commit, the User Guide again exports without any
kind of error. I haven't yet checked the other manuals.

This fixes bug #8022.
2016-07-09 23:58:34 -04:00
Guillaume Munch
670efa8f64 Rationalise includes
Modifying TexRow.h or texstream.h no longer triggers the recompilation of the
complete source tree.
2016-07-04 02:42:17 +02:00
Richard Heck
fa190691a8 When we use InPremable styles, we want to write as many versions
to the premable as the user enters.
2016-06-12 00:58:33 -04:00
Jean-Marc Lasgouttes
ac759b4368 Rewrite setRowHeight using row information
The initial values for maxasc and maxdes (renamed from maxdesc) is obtained as a maximum of max ascents/descents of all row elements.

This allows to get rid of Paragraph::highestFontInRange and FontList::highestInRange.

Some auxilliary variables declarations are also moved to where they are needed.
2016-05-30 14:55:41 +02:00
Guillaume Munch
6d4e6aad24 Automatically show the review toolbar if the document has tracked changes
(#8738)

For efficiency, we add a new flag to the buffer indicating when changes are
present. This flag is updated at each buffer update, and also when explicitly
requested via a dispatch result flag.
2016-05-29 17:55:42 -04:00
Georg Baum
dc38ae873a Fix bug 10074 (regression)
This was a regression of 8aa37c43. I did not take into account that end_pos
could be -1, so the code that checked whether a pair of braces needs to be
inserted between two hyphens did not work for that case. Now we check for
the length of text_, which should be done anyway, and only take end_pos into
account when it is not -1.
2016-04-24 20:12:43 +02:00
Jean-Marc Lasgouttes
ba7e2113f3 Fix some display bugs related to end of paragraph markers
There are two regressions that are fixed here:

 * empty rows at the end of a paragraph (think after newline at end of
   paragraph or empty line in Verbatim) do not have an end-of-par
   marker. This is fixed by removing the early return in breakRow and
   letting the whole function be executed. This requires to relax an
   assertion in Paragraph::fontSpan. It makes sense here to query
   position at the end of the paragraph.

 * a newline at the end of a paragraph will be followed by and
   end-of-par marker. This is fixed by skipping the end-of-par marker
   when a new row has been requested.
2016-03-25 22:22:45 +01:00
Georg Baum
4ab1d77577 Fix regression of 0bf8b8a1 (bug 9884)
Unfortunately the footmisc package does not work together with hyperref:
Before 0bf8b8a1, a footnote in a section title was created as a link in pdf
outpout, after 0bf8b8a1 ist was no link anymore. For now we revert to the old
code, and wait until the footmisc and hyperref packages are made compatible.
2016-01-26 21:33:46 +01:00
Richard Heck
cf64064db7 Use the much faster forOutliner also to get the tooltip text. 2015-12-12 17:19:33 -05:00
Günter Milde
0eb9477be7 Fix 480937a103708a651/lyxgit, second attempt.
Prevent encoding changes whenever the TeX engine is XeTeX or LuaTeX,
as XeTeX/LuaTeX use only one encoding per document:

* with useNonTeXFonts: "utf8plain",
* with XeTeX and TeX fonts: "ascii" (inputenc fails),
* with LuaTeX and TeX fonts: only one encoding accepted by luainputenc.

+1 no needless encoding switches
+1 runparams.encoding matches the correct encoding at any time
+1 less complicated code.

-1 there may still be problems with CJK (possibly impossible to
   solve for Xe/LuaTeX with TeX fonts).

For LuaTeX & TeX fonts, the complete document uses the encoding
of the global document language.

See also #9740.
2015-11-12 16:55:04 +01:00
Günter Milde
9894e0be23 Fix 480937a103708a651/lyxgit. See also #9740.
Actually, the changed tests were used to prevent overwriting the encoding
changed in Buffer::writeLaTeX with a language-default encoding.
This is still required for XeTeX with TeX-fonts unless a proper solution is found.

Documents with more than one encoding and TeX-fonts fail with LuaTeX,
as "luainputenc" can only handle one encoding.
2015-11-11 00:11:06 +01:00
Günter Milde
480937a103 Reset encoding after insets and environments also for LuaTeX with TeX fonts.
With inputenc == "auto" or "default", the encoding changes with
the language and must be reset after an eventual language switch in insets
or environments (see #6216).

However, whether we need to do this does not depend on 8-bit TeX vs. LuaTeX
but on the possible use of more than one encoding for the document.
With "nonTeXFonts", the encoding is utf8,
LuaTeX with TeX fonts requires encoding handling similar to 8-bit TeX.

(Additionally, the value of "params.inputenc" could be tested: if it is
not "auto" or "default", we have just one common encoding and could skip
the reset as well.) Not sure how much time this saves, though.
2015-11-09 12:42:48 +01:00
Günter Milde
1523fc6023 Partial fix for #9740 "XeTeX/LuaTeX with TeX fonts problems".
Fixes output for 3 of the 4 test lyx-files.

Includes "FIXME"s at places where further action is required to get the XeTeX
export right but I don't know how.
2015-10-20 19:16:25 +02:00
Guillaume Munch
65d61e7a27 Add math cell positions to TexRow
This is preliminary work for extending the cursor<->row tracking to math.

TexRow used to associate, to each row, a location id/pos where id determines a
paragraph and pos the position in the paragraph.

TexRow now associates to each row a list of entries, text or math. A math is a
pair uid/idx where uid will determine a math inset and idx is the number of the
cell.

The analogy id/pos<->inset/idx works better than the analogy id/pos<->idx/pos,
because what matters for the TexRow algorithm(TM) is the behaviour in terms of
line breaks.

This only improves the source view and the forward search, not the error report
and the reverse search (though this could be easily added now).
2015-10-19 06:55:17 +01:00
Georg Baum
d3b5260f45 Remove unused variables
Found by cppcheck: (style) Unused variable: x
2015-10-10 21:28:28 +02:00
Guillaume Munch
bb344452c8 Consistency of ellipses across the UI
Use the function support:truncateWithEllipsis() to shorten a docstring with
... at the end. Actually we use U+2026 HORIZONTAL ELLIPSIS instead of "..." when
automatically shortening strings. This is to be consistent with Qt's own
truncation and is much nicer on the screen.

This includes the bugs #9575 and #9572 regarding broken text elision in the
outliner.

Known issues (non-regressions):

* TocBackend::updateItem() should be rewritten to update all TOCs. (#8386)

* "..." should be replaced with … everywhere else on the interface (including
  translation strings).

* We should prefer to rely on QFontMetrics::elidedText() to truncate strings
  with an ellipsis whenever possible, or an equivalent for the buffer view
  dependent on the font metrics. See the warning in src/support/lstrings.h.
2015-10-05 21:16:16 +01:00
Georg Baum
7450d24eec Fix wrong label found by cppcheck
It was not intended to ignore the return value of expandParagraphLabel().
2015-09-20 20:32:45 +02:00
Georg Baum
b6aed54c45 Fix cppcheck variable scope warnings
These were all flagged by "(style) The scope of the variable 'x' can be reduced."
Narowing the scope improves readability, and if it is in a loop then the
compiler will be clever enough to produce efficient code, we do not need
manual optimization for POD types.
2015-09-20 10:42:35 +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
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
Juergen Spitzmueller
88ecc18e30 Do not output \noindent if paragraph does not support indentation change
Part of: #7320.
2015-05-02 16:34:57 +02:00
Juergen Spitzmueller
897b2e73a1 New (Inset)Layout tag PassThruChars 2015-04-20 18:13:49 +02:00
Juergen Spitzmueller
5fec78f69f Properly determine active font encoding 2015-04-02 17:13:45 +02:00
Georg Baum
3e9e6e344a Replace automatic logofication with insets
Previously, LyX did replace some words with typeset logos, and there was no
way to prvent this except putting them, in ERT (bug #4752). Now we have
special insets for these words, and standard text is left alone.
2015-03-01 11:16:57 +01:00
Georg Baum
8aa37c43a1 Fix plaintext output of dashes (bug #3647)
Previously, consecutive dashes in .lyx files were combined to endash and emdash
in some cases, and in other cases they were output as is. This made the code
complicated, and resulted in inconsitencies ((bug #3647).
Now, a dash in a .lyx file is always a dash in the output, for all flavours.
The special handling is moved to the input side, so that you still get an
endash if you type two hyphens. If needed, this can be changed or made
customizable without the need to update the file format again. Many thanks
for the fruitful mailing list dicsussion, which contributed significantly to
the final version.
2015-02-24 22:06:12 +01:00
Jean-Marc Lasgouttes
b627b8701b Some performance stuff reported by cppcheck 2015-02-24 18:38:20 +01:00
Georg Baum
e4ec11e8a1 Output -- and --- in XHTML like in LaTeX
For exports based on LaTeX, consecutive hyphens are only converted to endash
and emdash if the current font family is not typewriter, and if none of the
parent insets is an IPA inset. Now this is done for XHTML export as well.
2015-02-15 20:17:21 +01:00
Juergen Spitzmueller
e5e8bff75b corrected_env: use breakln instead of hardcoded linebreak 2014-12-01 14:45:11 +01:00
Georg Baum
0bf8b8a1d2 Load footmisc.sty instead of using outdated code
This is a patch I originally sent to lyx-devel in 2012 with subject
'Load footmisc.sty instead of using copied code from obsolete stblftnt.sty'.
It now takes all comments into account: It works also if the user loads the
package herself, it can be disabled by providing the footmisc feature in a
layout, and it does not use the ugly \AtBeginDocument{}.
2014-11-14 20:20:35 +01:00
Georg Baum
8f93600d3f Prevent accidental usage of wrong copy constructor 2014-11-11 20:57:25 +01:00
Scott Kostyshak
5636906aee No space after inline math for text export (#9282)
This extra space was the result of the fix for #6094
(at 7e624928).
2014-10-15 19:21:18 -04:00
Jean-Marc
fca332bace Rename FontSpan::inside(pos) to contains(pos) 2014-07-28 20:42:01 +02:00
Jean-Marc
41740ea915 Merge remote-tracking branch 'features/str-metrics'
This branch implements string-wise metrics computation. The goal is to
have both good metrics computation (and font with proper kerning and
ligatures) and better performance than what we have with
force_paint_single_char. Moreover there has been some code
factorization in TextMetrics, where the same row-breaking algorithm
was basically implemented 3 times.

Globally, the new code is a bit shorter than the existing one, and it
is much cleaner.  There is still a lot of potential for code removal,
especially in the RowPainter, which should be rewritten to use the new
Row information.

The bugs fixed and caused by this branch are tracked at ticket #9003:
http://www.lyx.org/trac/ticket/9003

What is done:

* Make TextMetrics methods operate on Row objects: breakRow and
  setRowHeight instead of rowBreakPoint and rowHeight.

* Change breakRow operation to operate at strings level to compute
  metrics The list of elements is stored in the row object in visual
  ordering, not logical. This will eventually allow to get rid of the
  Bidi class.

* rename getColumnNearX to getPosNearX (and change code accordingly).
  It does not make sense to return a position relative to the start of
  row, since nobody needs this.

* Re-implement cursorX and getPosNearX using row elements.

* Get rid of lyxrc.force_paint_single_char. This was a workaround that
  is not necessary anymore.

* Implement proper string metrics computation (with cache). Remove
  useless workarounds which disable kerning and ligatures.

* Draw also RtL text string-wise. This speeds-up drawing.

* Do not cut strings at selection boundary in RowPainter. This avoids
  ligature/kerning breaking in latin text, and bad rendering problems
  in Arabic.

* Remove homebrew Arabic and Hebrew support from Encoding.cpp. We now
  rely on Qt to do handle complex scripts.

* Get rid of LyXRC::rtl_support, which does not have a real use case.

* Fix display of [] and {} delimiters in Arabic scripts.
2014-07-25 20:10:55 +02:00
Jean-Marc Lasgouttes
45eb314a86 Get rid of rtl_support preference
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.
2014-07-09 21:11:08 +02:00
Jean-Marc Lasgouttes
d6337a2488 Remove obsolete code to handle Hebrew and Arabic characters
This is handled by Qt now.

Note that a small optimization (do not draw text that is to the left
of WorkArea) is removed because it cannot be guaranteed to be exact
anymore. It was probably not very useful anyway, and would become
useless once the RowPainter is rewritten to use Row information.

Update 00README_STR_METRICS_BRANCH.
2014-07-08 21:30:06 +02:00
Richard Heck
c2de96d2ed The flush should be done on either branch. 2014-06-29 15:40:52 -04:00
Georg Baum
2896fe1bd0 Work around MSVC warning
The statement
	if (pos < from + lyxrc.completion_minlength)
triggers a signed vs. unsigned warning. I don't know why this happens, it
could be a MSVC bug, or related to LLP64 (windows) vs. LP64 (unix)
programming model, or the C++ standard might be ambigous in the section
defining the "usual arithmetic conversions". However, using a temporary
variable is safe and works on all compilers.
2014-06-26 21:05:40 +02:00
Jean-Marc Lasgouttes
d32f76f7fe Small Inset isXXX methods cleanup
* rename isStretchableSpace to isHfill
 * inline a trivial method
 * remove InsetIPAMacro::isLineSeparator, which has the same value as default.
2014-06-25 17:54:26 +02:00
Richard Heck
5536b0c7fe Flush stream more often to help figure out where the mystery crash
originates.
2014-06-04 09:19:42 -04:00
Juergen Spitzmueller
20bcaec061 Add layout tag that determines if/when a paragraph can be indented.
Fixes: #7327, #7458, #8670
2014-05-29 14:10:32 +02:00
Jean-Marc Lasgouttes
ee7c4db72a Do not forget last word of paragraph in completion
With the old code, the last word of a paragraph would not be added in
the completion list. The key difference is to pass `from' instead of `pos'
to FontList::fontiterator.

Slight cleanup of the code.
2014-05-16 15:22:51 +02:00
Enrico Forestieri
c668ebf611 Fix bugs #8546 and #9055, and introduce new separator inset.
The algorithm used for breaking a paragraph in LaTeX export is changed
for avoiding spurious blank lines causing too much vertical space.
This change is tied to the introduction of a new inset (with two
different specializations) helping in either outputing LaTeX paragraph
breaks or separating environments in LyX. Both of the above goals were
previously achieved by the ---Separator--- layout and can now be
accomplished by the new inset in a more natural way. As an example,
after leaving an environment by hitting the Return key for two times,
a third return automatically inserts a parbreak inset, which is
equivalent to the old separator layout, i.e., it also introduces a
blank line in the output. If this blank line is not wanted, the
parbreak separator can be changed to a plain separator by a right
click of the mouse. Of course, an environment can still be separated
by the following one by using the Alt+P+Return shortcut (or the
corresponding menu key), but now the plain separator inset is used
instead of the old separator layout, such that no blank line occurs in
the LaTeX output.

Old documents are converted such that the LaTeX output remains unchanged.
As a result of this conversion, the old separator layout is replaced by
the new parbreak inset, which may also appear in places where the old
algorithm was introducing blank lines while the new one is not.
Note that not all blank lines were actually affecting the LaTeX output,
because a blank line is simply ignored by the TeX engine when it occurs
in the so called "vertical mode" (e.g., after an alignment environment).
The old ---Separator--- layout is now gone and old layout files using it
are also automatically converted.

Round trip conversions between old and new format should leave a document
unchanged. This means that the new behavior about paragraph breaking is
not "carried back" to the old format. Indeed, this would need introducing
special LaTeX commands in ERT that would accumulate in roundtrip
conversions, horribly cluttering the document. So, when converting a
modified document to old formats, the LaTeX output may slightly differ in
vertical spacing if the document is processed by an old version of LyX.
In other words, forward compatibility is guaranteed, but not backwards.
2014-05-10 23:25:11 +02:00
Tommaso Cucinotta
13cb7da11d Merged Paragraph::stringify into asString(). 2014-04-21 11:51:59 -04:00
Richard Heck
0a6ff99f28 Typos and style. 2014-04-21 11:51:59 -04:00
Richard Heck
8b00b355ca Change forToc() to forOutliner(), to avoid confusion. The old name
is left over from when the outliner really did just display a TOC.
2014-04-21 11:51:59 -04:00
Jean-Marc Lasgouttes
f8da042312 Do not store Languages objects in completion words lists
In the current code each paragraph contains a map<Language,
WordList*>, which means that it contains a full copy of the language
object. Since these objects contain translation tables nowadays, this
is a very bad idea.

This patch simply replaces the Language key by a string.

When loading the Userguide on linux/x86_64, the total memory
consumption decreases from 36.27MB to 31.50MB.
2014-04-21 11:51:59 -04:00
Juergen Spitzmueller
0b2d89eaea In Paragraph::changeCase, correctly track the font of the changed characters (fix crash)
Fixes: #7943
2014-04-21 11:51:58 -04:00