Commit Graph

220 Commits

Author SHA1 Message Date
Kornel Benko
8b21b2f8fb Amend(2) 7a03fa6: Advanced search with format:
Further tweeking.
2018-10-14 20:39:13 +02:00
Kornel Benko
1967d5411c Amend edca2e0: copy && paste error 2018-10-13 22:22:48 +02:00
Kornel Benko
edca2e0c4a Amend 7a03fa6: Advanced search with format:
In the latexified text:
* Check and handle contained regex properly
* Discard superfluos '{' preventing our search engine
  to match with the search pattern
2018-10-13 21:08:26 +02:00
Kornel Benko
7a03fa6f1d Advanced search with format: Prepare latex for find
Our findadv expects something like
	prefix + 'search'
so that the regex (which is latexified too)
can work on 'search'
(In the source, the prefix is denoted by lead_as_string)

The latex output contains structs like
	\foreignlaguage(abc}{xx\textbf{boldxx\textcolor{blue}{blue 1 blue 2} XX}}
which would never match the simple prefix.

Now the above is converted to
	\foreignlaguage(abc}{xx}\\
	\foreignlaguage(abc}{\textbf{boldxx}}
	\foreignlaguage(abc}{\textbf{\textcolor{blue}{blue 1 blue 2}}}\\
	\foreignlaguage(abc}{\textbf{ XX}}
Of course, more than one language or color in an inset can be searched for now.
2018-10-12 16:47:07 +02:00
Kornel Benko
ff933b52f5 Amend(2) b78bdf8
Modified language handling

Still, there are problems, because sometimes the search pattern
does not contain the the requested info. So the 'find' often fails
for strings inside a list environment.
2018-10-06 23:50:50 +02:00
Kornel Benko
f2d82f879e Amend(1) b78bdf8
In advanced search:
* Ignore font sizes
* ignore \\[a-z]+par{} macros
* ignore \\inputencoding{...} macros
2018-10-06 09:58:29 +02:00
Kornel Benko
b78bdf80a8 Added better handling for languages and colors for advanced F&R
The change is significant if the search format is not disabled.
We try to analyze the pattern string first to get needed features
for the search.
We try to analyse the searched string and if it does not
contain all expected featers (color, language, char style, char decoration)

Still some problems though
2018-10-05 20:26:44 +02:00
Kornel Benko
2348e0b615 Advaced search: Added handling to search for colored text
if used with format enabled
2018-10-02 11:53:01 +02:00
Kornel Benko
4eb5ac9a2c Amend(4) 73188e3
* Added textsl, texttt, uline, uuline, sout, xout to the list of possible
  leading strings.
* Account for correct number of open braces in regex.
  Now the search works for enbled format too.

This is hopefully the last amend
2018-10-01 12:06:42 +02:00
Kornel Benko
cc0c58839f Amend(3) 73188e3
Adapt the positional references in regex supplied by user
so that for instance '([a-z]+)\s\1' to find identical words in sequence
is changed to '([a-z]+)\s\2'.
2018-09-30 18:37:55 +02:00
Kornel Benko
2fdc52df19 Amend(2) 73188e3.
Added noun, textsf and texit to the list of possible
leading strings if searche with format enabled.
Searching seems to work as intended now.
2018-09-30 16:15:45 +02:00
Kornel Benko
0e61e6f014 Amend(1) 73188e3.
This is slightly better, but still not satisfying.

Enable format search
Given the latexified string
	\emph{Fox jUMps}
and using emphasized regex '\w*', we find 'Fox'. That is OK.
But the next find finds ' ', which is not OK.
In contrast, searching with '\w+', we find the correct string 'jUMps'.
2018-09-29 18:46:21 +02:00
Kornel Benko
ded0dc4c1c Try to make findadv more robust if not ignoring format
If searching for instance '.+' , the found string expanded
to the end of search buffer. So we have to replace
'.' with '[^\}]'.
Also all constructs like '[^abc]' had to be changed to '[^abc\}]'
to not go behind the actual format.
There is still problem using '*', but constructs usin '+' seem to work now.
('.*' finds everything from first char in correct format
 to (including) end of next format change
 while '.+' find _only_ characters in correct format)
2018-09-29 09:38:45 +02:00
Jean-Marc Lasgouttes
e4dba53232 Do not remove character at start of paragraph when cutting
The part of code that removed space at start of paragraph have been
there forever, but its intent is unclear. For example, cutting text at
the end of a paragraph will lead to remove space at the start of this
same paragraph.

The removal of this functionality is offset by a rewrite of DEPM that
makes it more thorough.

Fixes bug #10503.
2018-07-22 23:20:21 +02:00
Richard Heck
b98cb77364 Fix bug #10933. 2018-02-24 00:32:14 -05:00
Christian Ridderström
e30f3d76d2 Bulk cleanup/fix incorrect annotation at the end of namespaces.
This commit does a bulk fix of incorrect annotations (comments) at the
end of namespaces.

The commit was generated by initially running clang-format, and then
from the diff of the result extracting the hunks corresponding to
fixes of namespace comments. The changes being applied and all the
results have been manually reviewed. The source code successfully
builds on macOS.

Further details on the steps below, in case they're of interest to
someone else in the future.

1. Checkout a fresh and up to date version of src/

    git pull && git checkout -- src && git status src

2. Ensure there's a suitable .clang-format in place, i.e. with options
   to fix the comment at the end of namespaces, including:

    FixNamespaceComments:                           true
    SpacesBeforeTrailingComments:                   1

and that clang-format is >= 5.0.0, by doing e.g.:

    clang-format -dump-config | grep Comments:
    clang-format --version

3. Apply clang-format to the source:

    clang-format -i $(find src -name "*.cpp" -or -name "*.h")

4. Create and filter out hunks related to fixing the namespace

    git diff -U0 src > tmp.patch
    grepdiff '^} // namespace' --output-matching=hunk tmp.patch  > fix_namespace.patch

5. Filter out hunks corresponding to simple fixes into to a separate patch:

    pcregrep -M -e '^diff[^\n]+\nindex[^\n]+\n--- [^\n]+\n\+\+\+ [^\n]+\n'  \
        -e '^@@ -[0-9]+ \+[0-9]+ @@[^\n]*\n-\}[^\n]*\n\+\}[^\n]*\n'         \
        fix_namespace.patch > fix_namespace_simple.patch

6. Manually review the simple patch and then apply it, after first
   restoring the source.

    git checkout -- src
    patch -p1 < fix_namespace_simple.path

7. Manually review the (simple) changes and then stage the changes

    git diff src
    git add src

8. Again apply clang-format and filter out hunks related to any
   remaining fixes to the namespace, this time filter with more
   context. There will be fewer hunks as all the simple cases have
   already been handled:

    clang-format -i $(find src -name "*.cpp" -or -name "*.h")
    git diff src > tmp.patch
    grepdiff '^} // namespace' --output-matching=hunk tmp.patch  > fix_namespace2.patch

9. Manually review/edit the resulting patch file to remove hunks for files
   which need to be dealt with manually, noting the file names and
   line numbers. Then restore files to as before applying clang-format
   and apply the patch:

    git checkout src
    patch -p1 < fix_namespace2.patch

10. Manually fix the files noted in the previous step. Stage files,
    review changes and commit.
2017-07-23 13:11:54 +02:00
Richard Heck
75bfed5507 Fix trailing whitespace in cpp files. 2017-07-03 13:53:14 -04:00
Tommaso Cucinotta
cf6bbe2147 findadv: amend [8c101829/lyxgit] check that opt.find_buf_name is found in theBuffers(). 2017-05-03 17:32:31 +02:00
Tommaso Cucinotta
3610cdf669 findadv: fix crash on wrong syntax/usage of word-findadv LFUN from mini-command. 2017-05-03 01:31:57 +02:00
Tommaso Cucinotta
4f75026176 lyxfind: cleanup regex_replace() and back to a sane amount of logging during findadv operations. 2017-04-17 00:41:29 +02:00
Tommaso Cucinotta
6d05a96546 findadv: match \textbackslash and \textasciicircum also without trailing {} (fixes autotest findadv-re-02-in.txt). 2017-04-17 00:38:31 +02:00
Tommaso Cucinotta
664798128a findadv: almost all test cases, including \regex[{}, back to working with std::regex. 2017-04-17 00:15:26 +02:00
Kornel Benko
28c320e1a0 findadv: fix compilation issue from [lyxgit/ecc36be6], when using boost instead of std regex. 2017-04-16 19:43:54 +02:00
Tommaso Cucinotta
ecc36be60b findadv: avoid crash when regexp-based search fails (mitigates #10625). 2017-04-16 11:27:34 +02:00
Jean-Marc Lasgouttes
cb888293d4 A better way to tell coverity that we do not care about result 2017-03-31 11:38:30 +02:00
Jean-Marc Lasgouttes
d7dfa27574 Try alternative syntax for signaling false positive 2017-03-24 15:54:16 +01:00
Richard Heck
ed0e4064d2 Don't need the else, since all codepaths return. 2016-12-30 11:05:01 -05:00
Richard Heck
410b0fa581 Invert logic. 2016-12-30 11:05:01 -05:00
Richard Heck
ee251c626c Re-organize, whitespace. 2016-12-30 11:05:01 -05:00
Richard Heck
b8216513d6 Remove useless for loop. 2016-12-30 11:05:01 -05:00
Tommaso Cucinotta
9740c36e80 Remove assert on advanced find with knitr module (#10444). 2016-10-27 09:38:35 +02:00
Juergen Spitzmueller
f089f60f4e Implement wrapping in next-change (#10388). 2016-10-15 16:34:16 +02:00
Jean-Marc Lasgouttes
84050268ee Remove useless #include
Including MathData.h in InsetMath.h is expensive and not required.
2016-10-14 11:08:04 +02:00
Guillaume Munch
3fd2398a28 Remove option to disable texrow
I suspect that the gain was negligible, yet it made debugging and maintainance
harder.
2016-09-23 23:39:48 +02:00
Juergen Spitzmueller
c0a425a319 Move wrap check for simple search/replace to lyxfind
This gets rid of some dirty dispatch tricks and fixes wrap-around
on replace and in the spellchecker

Fixes: #10378
2016-09-14 10:23:39 +02: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
355395174b Mark a number of coverity false positives.
Fixes coverity #23284, 23285, 23286, 23287, 23289.
2016-06-11 23:09:30 -04:00
Scott Kostyshak
62190855bf Revert "Now math previews are correctly updated when replacing math contents inside"
Updating all previews (even if only one has changed) is more costly
than I thought. Thanks to Guillaume for tracking down this
performance issue.

This reversion is related to the reversions at 358745d0 and
a7a14395. See also #7242 and #9855.

This reverts commit 29948eec26.
2015-11-13 00:54:15 -05:00
Scott Kostyshak
a7a143950a Revert "Update previews after doing a find/replace (#7242)"
Updating all previews (even if only one has changed) is more costly
than I thought. Thanks to Guillaume for tracking down this
performance issue.

This reversion is related to the reversion at 358745d0.
See also #7242 and #9855.

This reverts commit 66f527e417.
2015-11-13 00:50:39 -05:00
Guillaume Munch
460a764b7f Adding TexRow information on math latex output (#4725)
WriteStream is now built from an otexstream instead of an odocstream, and
therefore counts lines in a TexRow. Calls to TexRow are added in relevant places
in math insets.

This finishes adding line tracking for math in the source panel and for forward
search.
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
Georg Baum
60e594a0f7 Fix duplicated pointer check
Found by cppcheck: (style) Same expression on both sides of '&&'.
2015-10-10 21:23:52 +02:00
Stephan Witt
d5f7ed38fc Add missing adjustment of end_pos if given length exceeds last pos 2015-10-09 08:16:23 +02:00
Stephan Witt
77cc2c7c8c Fix "dead store" warnings of Xcode analyze tool 2015-10-09 08:16:23 +02:00
Guillaume Munch
afed7d06fa Improvements to cursor highlighting in the source panel
* TexRow now computes rows from a DocIterator. In practice, the cursor
  highlighting is now correct inside insets, it is no longer restricted to the
  topmost level. It certainly also makes forward-search more precise.

* Added the option to disable a texrow when not needed, for perf.

* Fixed a bug where the last paragraph was not properly highlighted.

Limitations:

* TexRow still does not handle: math (e.g. multi-cell), sub-captions, inset
  arguments.
2015-10-01 21:51:08 +01: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
Georg Baum
84cca2dd94 Fix indentation 2015-05-17 17:27:27 +02:00
Georg Baum
b596330093 Fix compilation with boost 1.58
Newer boost versions use complicated type traits for boost::next and
boost::prior, which do not work with the RandomAccessList iterators.
The long term solution is to use std::next and std::prev, for now supply
simple replacements for compilers that do not support C++11 yet.
2015-05-16 00:05:23 +02:00
Scott Kostyshak
66f527e417 Update previews after doing a find/replace (#7242)
This commit addresses #7242 for normal Find/Replace. That issue was
fixed for Advanced Find at 29948eec.
2015-04-18 21:47:21 -04:00
Alfredo Braunstein
8f821dba70 Rewrite of change-related helpers
lyxfind.cpp(findNextChange, findPreviousChange, findChange, selectChange): factor the change-selection part out of the change-finding part
Text.cpp (acceptOrRejectChanges): call only selectChange
2014-10-14 17:40:44 +02:00