Commit Graph

21802 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
fe8c3b4348 Cleanup TextMetrics::rowBreakPoint.
Collect properly all strings to compute string metrics

Some changes with respect to existing code
 - end of paragraph font is now the one of the text
 - words longer than a line are not broken anymore. I think this is not useful  if we have horizontal scrollbar

Other than that, the code is still compatible with rowWidth and friends.
2014-06-25 17:53:34 +02:00
Jean-Marc Lasgouttes
edcedf3324 Revert temporarily changes related to InsetSeparator
This is to avoid many conflicts with the str-metrics branch.
2014-06-25 17:53:09 +02:00
Scott Kostyshak
c62a53b78b Remove an incorrect/expired FIXME
Both Richard and JMarc think it is incorrect. See
  https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg184758.html
2014-06-23 08:03:44 -04:00
Peter Kümmel
2f17858115 On Linux show in crash message box the backtrace 2014-06-14 11:25:25 +02:00
Scott Kostyshak
bcbc162665 Select word on double click even when at boundary
Now when double clicking on a boundary of a word, the
word is selected. This also causes single-letter words
to now be selected (fixes #9159).
2014-06-13 10:48:49 -04:00
Jean-Marc Lasgouttes
01ba22efff Fix checkmark on current entry for InsetSeparator context menu
The code supposed to do that contained a typo and was not completely correct.
2014-06-13 10:30:25 +02:00
Kornel Benko
3b14de740d Cmake build: Symplify use of linking optional libraries found via find_package 2014-06-12 19:02:29 +02:00
Kornel Benko
2b0511510a Cmake build: Added magic library to some link commands.
Needed due to the use of magic_(open|load|error|file|close) after recent changes.
2014-06-12 07:49:17 +02:00
Enrico Forestieri
f439609304 Make binary file detection more robust.
The magic library can detect the charset used by a file. While this
detection is not full proof, actually the library seems to be infallible
as regards the binary nature of a file. So, use libmagic for the detection
and fallback to the previous method if the library is not installed or
its database cannot be loaded.
2014-06-11 23:04:39 +02:00
Enrico Forestieri
82faa66192 Set the default locale at startup.
On startup, the default locale is "C", meaning that all system
functions assume an ascii codeset. The environment's locale
settings should be selected by calling setlocale(LC_ALL,"").
This is done by Qt during the QCoreApplication initialization
but this inizialization is never performed for batch processing
and, as a result, LyX is not able to process files whose names
contain non-ascii characters. This is not an issue on Windows,
where the file names are always stored as UTF-16, so the call is
only performed for unix-like platforms (this also includes cygwin,
due to its own filenames management that allows using characters
which are forbidden to native programs).
2014-06-11 18:23:44 +02:00
Georg Baum
f76d6997b7 Fix thinko in loop detection 2014-06-09 22:06:58 +02:00
Georg Baum
f792e70d0a Fix wrong "externally modified" message
This was a regression of 10364082c8.
2014-06-09 13:17:40 +02:00
Georg Baum
f09a9fe2e6 Remove unsafe method FileName::tempName()
FileName::tempName() created a new temp file name by using qt to create a
temporary file with a unique name, and then deleting that file and returning
the name. This was unsafe, since other processes or even other threads of the
running LyX could create files with the same name between deletion and then
using the temp name.
This is fixed by using the TempFile class instead. As a side effect, a few
cases where the temp files were not deleted after usage were fixed as well.
The only place that is still unsafe is createTmpDir().
2014-06-09 13:05:50 +02:00
Georg Baum
ae15b59734 Don't double delete by making TempFile noncopyable
The compiler generated copy constructor and assignment operator are wrong.
This could easily be fixed by implementing them manually, but a) they are
not needed, and b) the semantics would be unclear (should the copy point
to a new temp file or not?), so it is better to forbid them.
2014-06-09 13:03:32 +02:00
Georg Baum
bf782ee02a Improve file saving strategy
- The TempFile class guarantees to generate a file name, we are not limited to
  100 tries of a predictable scheme anymore, which could break if LyX
  frequently crashes.
- The temp file name generation has no race condition against another LyX
  instance in the same directory anymore.
- Symlinks survive saving again (regression of 10364082c8).
2014-06-09 11:08:24 +02:00
Georg Baum
47721216f0 Fix typo 2014-06-09 10:26:39 +02:00
Scott Kostyshak
4cfc110d4a Combine OutlineIn and OutlineOut blocks
They differ only by adding/subtracting 1.
2014-06-08 03:33:32 -04:00
Georg Baum
4bea5b9d18 Explain why the binary detection works
Extracted from Enricos comment at bug 9146.
2014-06-07 17:48:23 +02:00
Georg Baum
c1ac09e11f Fix bug #7954 (now really)
Thanks to maciejr we know now what the remaining problem was with bug 7954:
My unicode symbol fallback works fine, the problem was that a font named
"Symbol" is available on OS X, but it does not use the font-specific encoding
we expect: Almost all glyphs are at their unicode code point.
Therefore the bug is fixed by re-enabling the unicode workaround and blocking
the Symbol font on OS X.
2014-06-07 10:54:17 +02:00
Peter Kümmel
6b4c3036aa std::min/max are defined in <algorithm>
handle error in msvc12 when linking against msvc10 libs
2014-06-07 08:17:20 +02:00
Peter Kümmel
080fca85a8 build with mingw on Windows and Linux 2014-06-07 08:06:13 +02:00
Scott Kostyshak
de091e6ceb Expand module names instead of buttons in settings
Maximizing the document settings window when on the modules pane,
the horizontal space is now given to the module names and so no
scrollbar is needed. Before, even when maximized, a scrollbar was
sometimes needed because the horizontal space was given to the
buttons in the middle, which did not provide an extra benefit.

The default sizeType was "Expanding" and is now changed to "Minimum"
for the horizontal spacer above the middle buttons.
2014-06-07 00:43:07 -04:00
Enrico Forestieri
ba603db942 Fix bug #9153 (Using mathpanel to insert matrix creates extra space on top)
The code was setting the current index before filling the
combo box items.
2014-06-06 16:14:24 +02:00
Enrico Forestieri
79dcf402b1 Refine fix for bug #9151.
Now the cursor in LyX jumps to the right spot instead of simply the
beginning of the paragraph. This is most useful for branch insets,
for example, which may contain long paragraphs.
2014-06-06 15:35:24 +02:00
Enrico Forestieri
44e09b223e Fix bug #9151 (Wrong reverse search for images and tables).
If the reverse position corresponds to an inset, its paragraph id
does not follow the main text numbering. Typically, an inset has
only a few paragraph, so that we would jump near the beginning of
the document. In this way we at least jump at the beginning of the
inset.
2014-06-05 23:46:18 +02:00
Enrico Forestieri
7d31194085 Fix bug #9146.
If LyX does not know about a given file format, it may easily
happen that the format is recognized as "latex" and this causes
bug #9146. This patch limits the check for a latex format to
non-binary files. The strategy for deciding that a file has
binary content is the same as that adopted by the "less" program.
2014-06-05 17:33:25 +02:00
Jean-Marc Lasgouttes
7c3d1d7423 Fix crash when accepting change
The problem is the use of cursor movement methods to update cursor.
Cursor::forwardPos() steps into insets, which is not always what we
want. The problem here is that there is a math inset just after the
accepted change, and that the cursor steps into it for some reason.

This code is a nightmare anyway.

Fixes: bug #9145
2014-06-05 12:23:19 +02:00
Scott Kostyshak
ab67ce3757 Fix a regression reported at #9146
This regression was introduced by me at 8b66f9ce. I did not take
into account that a call to a python script containing $$s is embedded
within a separate python script. Thus, when commandPrep() is called it
only sees the call to the outer python script, and does not see the
$$s contained in that python script. It therefore did not substitute
for it. This fix simply calls commandPrep() directly before writing
the embedded command.
2014-06-04 21:32:14 -04:00
Georg Baum
8be7da42e9 Detect binary EPS files correctly (bug #9146)
The Adobe EPS file format specification (TN-5002, currently available at
http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf) specifies
a binary version of EPS files with integrated preview, sometimes also called
DOS EPS binary files. LyX 2.0 did recognize these files unreliably by
extension, but since f4eae12d they are misdetected as latex (bug #9146).
This change adds proper detection for these files using the officially
documented binary header.
2014-06-04 22:04:46 +02:00
Richard Heck
533a05e0b8 Use a different naming scheme, per Enrico's suggestion. 2014-06-04 12:46:42 -04: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
Richard Heck
10364082c8 Per a suggestion of JMarc's, first write the saved file to a
temporary name, then move it to its real location if we succeed.
This prevents our over-writing the existing file with a corrupt
one.
2014-06-03 10:42:07 -04:00
Juergen Spitzmueller
95a7716998 Remove superfluous conversion 2014-05-31 10:46:49 +02:00
Juergen Spitzmueller
beb53ddbe2 Whitespace 2014-05-31 10:33:46 +02:00
Georg Baum
953a4d13d9 Add missing bits of layout file format update
This is needed so that the new format number is actually used. Since the
conversion is a noop I did not update the layout files (more updates will
come).
2014-05-29 21:25:08 +02:00
Georg Baum
53f8d6d6d3 Make layout test compile 2014-05-29 15:07:07 +02: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
Enrico Forestieri
061509bf75 Avoid an assertion.
Do not assert if an inset separator is the only item of a List
environment. Although it is a weird thing to do, both GUI and
latex output can deal with it.
2014-05-28 20:50:45 +02:00
Jean-Marc Lasgouttes
0212ef5426 Make TextMetrics::editXY more robust
This fixes a crash in examples/fa/splash.lyx when selecting text
representing menu entries. This happens because menu names are in LTR
English, while the inset itself is in RTL.

The problem is that the current code relies on the fact that
 1. getColumnNearX and checkInsetHit share the same idea about cursor
    position.
 2. pos and pos + 1 are in general consecutive on screen.

It seems that 1. is wrong here (for reasons I did not try to
understand); the second assumption is definitely false with
bi-directional text. This makes editXY very fragile.

The new code should be more robust in this respect. The logic is:
 * if checkInsetHit finds an inset, use its position,
 * otherwise, ask getColumnNearX for the cursor position.

Fixes: #9142
2014-05-28 14:22:21 +02:00
Enrico Forestieri
c85dbfea98 Fix indentation of paragraphs after an environment.
When deciding whether a paragraph should be indented or not, LyX
only takes into account default layouts. This is wrong, because
an environment could be nested into another one and thus a following
paragraph would not be "default". With this patch all paragraphs
after an environment are correctly indented, independently of
whether their layouts are "default" or not.
The latex output (which was modeled following the previous wrong
assumption) is also correspondingly adapted.
2014-05-28 01:07:47 +02:00
Georg Baum
4cea2efe21 Native support for \notag
This is mainly needed to reduce the amount of ERT if you convert AMS example
documents with tex2lyx. No GUI support is needed, since \notag is equivalent
to \nonumber.
2014-05-27 22:17:35 +02:00
Georg Baum
5dc9568f8d Native support for \smash[t] and \smash[b]
This is a follow-up of bug #8967. The implementation is self-explaining, the
only part which needs a comment is lyx2lyx: Since a 100% correct solution is
not possible, it has been decided not to switch amsmath off in the forward
conversion if no other ams command than \smash[t] and \smash[b] is used, but
to consider it a bug that older versions do not load amsmath automatically for
these commands. In the backward direction it is easy to keep the document
compilable, so just do that.
2014-05-27 22:13:58 +02:00
Georg Baum
ff8450f839 Add missing member initializations 2014-05-27 22:13:58 +02:00
Enrico Forestieri
d4c21b42dd Allow inserting a blank line also after a nested environment. 2014-05-26 21:29:33 +02:00
Richard Heck
643deb8aa0 Add a FIXME. 2014-05-23 11:36:12 -04:00
Richard Heck
b992968a15 Fix bug #9131 for development branch. There are two parts to the fix.
The firs tinvolves a thinko in BibTeXInfo::expandFormat. We were previously
counting passes through this routine, which means: one for every character,
more or less. So long strings would hit the "recursion limit". But what
we are worried about is an infinite loop caused by misues of macros, so that
is what we need to count.

This prevents the error we were previously getting, but it reveals a huge
slowdown when one tries to open a citation inset with a large nubmer of keys.
So we also limit the number of keys we try to process, and the length of the
string we try to display, when we are generating citation information.

I'm convinced that there is a deeper problem in how citation information is
generated (see the bug tracker for more info), but that will require major
surgery and a file format change
2014-05-23 11:26:45 -04:00
Richard Heck
ba17d842b4 Add some const-ref-ness, and remove some default arguments that are
never treated as defaults.
2014-05-23 11:03:17 -04:00
Richard Heck
344ea62dd0 Fix up logic of BibTeXInfo::getInfo. We don't need to process the
richtext stuff unless we actually need it.
2014-05-23 10:48:22 -04:00
Enrico Forestieri
a596736d76 Fix another glitch with on-screen indentation.
If a new paragraph is created just before a nested environment,
the indentation of the nested environment is not computed
correctly because the parindent of the previous layout would
also be erroneously taken into account. This would cause the
nested environment to move back and forth when something is
added to the new paragraph.
2014-05-22 23:58:23 +02:00
Georg Baum
85db1005b6 Fix another crash similar to #9030
This one occured after the fix for bug #9030 if the cursor is in a math inset
and the edit menu is opened.
2014-05-22 22:02:46 +02:00