Commit Graph

397 Commits

Author SHA1 Message Date
Kornel Benko
bf4394e282 FindAdv: Expand the list of handled chars for ogonek 2019-03-17 13:06:56 +01:00
Kornel Benko
9a1a806b60 FindAdv: Correct start of search if not using regex
Do not try to find pattern inside the leading string.
2019-03-16 11:26:20 +01:00
Kornel Benko
8e7c427c7c Amend 7ac04a2b: Count and display number of replaced strings in FindAdv
We have to know if the previous call to search was a single replace or not,
so that we can correctly initialize the numer of replaed strings.
2019-03-16 08:17:09 +01:00
Kornel Benko
4eacc492a3 Typo 2019-03-13 14:14:35 +01:00
Kornel Benko
7ac04a2b75 Fix #11505. Count and display number of replaced strings in FindAdv 2019-03-13 14:06:18 +01:00
Kornel Benko
c041439c51 FindAdv: Special handling for \dot{i} and 'ß'
Different behaviour in regexp{..} for 'İ' and 'ß':
1.) lowercase routine for 'İ' gives 'İ', so that if we are searching
  while ignoring case, the string '\dot{I}' is converted to '\dot{i}'.
  In this case we have to change it to 'İ' (instead of 'i', as one would expect).

2.) If 'ß' is inserted via keybord on fresh created regexp box it appears as \lyxmathsym{ß},
  if pasted from the lyx-screen it appears as \text{ß}
2019-03-10 00:29:56 +01:00
Kornel Benko
f848183fa8 FindAdv: Expand the list of handled chars for dot below and ring above 2019-03-08 22:44:00 +01:00
Kornel Benko
b702eda4ed FindAdv: Amend cd4ae51f
Prevent to match only part of a macro.
For instance, we want find '\imath' but not '\imathxxxx'
while checking for accents.
2019-03-04 14:37:10 +01:00
Kornel Benko
cd4ae51f77 FindAdv: Amend b21c8b21: Expand the list for handled latin characters
1.) Added for 'breve' and 'grave' accents
2.) Corrected handling for 'i'-accents (allowed \hat{i} _and_ \hat{\imath})
	because of problems with ignoring case
3.) Spaces: Changed some indents in source
2019-03-04 14:05:44 +01:00
Kornel Benko
99bacf006e FindAdv: Handle some more accented latin characters.
Also try to use UTF8 encoded chars instead of their
latex equivalent if possible.
2019-03-03 14:08:27 +01:00
Kornel Benko
b21c8b214d FindAdv: Expand the list for handled latin characters 2019-03-02 22:00:20 +01:00
Kornel Benko
3541a49db4 FindAdv: Try to add the possibility to search for accented characters in regex
The problem is the handling of regex as using math-mode. That is
any accented character is converted to a math macro.
For instance "ä" --> "\\ddot{a}".
Outside of math or regex it is not converted (if used xetex flavour),
but there are other chars which are converted in math and in text (but differently)
For instance "ů"
	in math --> "\\mathring{u}"
	in text --> "\\r{u}"

TODO: determine the still not handled conversions.
It would be nice, if we could persuade math factory to not convert
these characters, but I was unable to find the place where the
conversion actually takes place.
2019-03-02 15:42:38 +01:00
Kornel Benko
9d6b71c6b3 FindAdv: Use isAlnumASCII() instead of std::isalnum()
Thanks Jean-Marc
2019-02-28 13:00:12 +01:00
Kornel Benko
2c5c397afa Amend aaffcd0b: Remove some remnants ... 2019-02-27 10:33:25 +01:00
Kornel Benko
aaffcd0b39 FindAdv: Do not use data from included listing if in search mode
Fixes #11496 	"Find and replace (advanced)" is too slow
2019-02-27 10:17:56 +01:00
Kornel Benko
b1f93e0982 FindAdv: Try to use a better algorithm to find begin of a searched string 2019-02-26 23:00:31 +01:00
Kornel Benko
babb291ef3 FindAdv: Partially revert e69f7022
The slowness returns, but the search works again
2019-02-26 13:24:36 +01:00
Kornel Benko
e69f702275 FindAdv: Fix #11496 -- too slow find
Also added some more macros to handle
2019-02-25 12:12:19 +01:00
Kornel Benko
6a6b670bbd FindAdv: Correctly match '\[' and '\]' in regular expressions with format enabled
We have to check for instances of '{[}' and '{]}' and
omit removing the enclosing parentheses
2019-02-23 13:11:34 +01:00
Kornel Benko
44a06adb6c FindAdv: debug info
1.) Fill the 'head'-member to easier recognize the macro. May be discarded
 later, although it does not take too much run-time
2.) Add some comment
3.) Ignore any macro inside the regex.
2019-02-22 13:21:23 +01:00
Kornel Benko
01fd1f7679 FindAdv: Discard \parbox, \input macros
The languge of these macros does not matter. What's more,
without removing them we may obtain wrong matching.
2019-02-21 20:32:08 +01:00
Kornel Benko
8a0db92523 FindAdv: Handle \shortcut
Essentially remove the header and handle the language inside
\shortcut{...} appropriately
2019-02-21 14:45:41 +01:00
Kornel Benko
a298fc55d9 FindAdv: Added handling for latex environments
1.) Make sure the environment is mentioned in the string for search
  (Added the keyword \latexenvironment{...})
2.) Handle it similar to \textcolor{}

That way we can also search for 'conclusion*' or 'summary' etc
in Additional.lyx.
2019-02-20 14:14:50 +01:00
Kornel Benko
0a2dda0904 Findadv: Added handling for frontmatter macros
title, subtitle, author etc.
2019-02-19 23:11:09 +01:00
Kornel Benko
96ca66d664 FindAdv: Handle more cases
Some macros need:
1.) Take care of case sensitivity
2.) Better handling of used argument values
3.) Cleaner list-environment search
4.) Remove superfluous '~' if searching for description or labeling env
2019-02-18 00:40:55 +01:00
Kornel Benko
dfbe29317d FindAdv: Even more fine tuning 2019-02-16 18:39:10 +01:00
Kornel Benko
faf7f0666f FindAdv: More fine tuning 2019-02-13 13:41:57 +01:00
Kornel Benko
8d752b68e9 FindAdv: Fine tuning 2019-02-12 14:21:14 +01:00
Kornel Benko
a47dbed6bd FindAdv: Try to find real start of found match
Sometime it happen that the selection contains area which was skipped
in splitOnKnownMacros().
So we check, if a shorter selection would give the same mach size.
2019-02-11 13:13:28 +01:00
Kornel Benko
f19bd163de FindAdv: Add handling of begin{multicols}[...][...]{...}
Also
a.) try to speed up regex search using non-greedy mode (.*?)
b.) remove '\n' completely in searched strings if it is not surrounded with
	aplanumerical chars
2019-02-10 18:00:55 +01:00
Kornel Benko
7fa1244dd8 Findadv: Add handling for powerdot macros
With format enabled, these macros were hard to process:
	lyxslide, twocolumn
2019-02-07 13:35:47 +01:00
Kornel Benko
50550a215f Findadv: Handle \lettrine{} in initials.module
The problem here is, that selecting any subset of a \lettrine{}
line always creates an initials header. That makes it impossible
to our search engine to find strings, because the regex does not
contain that info. So we have to discard the leading \lettrine part
completely.
We place now a marker (\endarguments) to determine that removable
part.
2019-02-05 08:04:47 +01:00
Kornel Benko
187b518648 FindAdv: to please cppcheck ...
Initialize class elements
Removed unused method
Added 'explicit' keyword
Optimize handling for sizes ( \tiny, \small, etc)
2018-12-18 06:53:58 +01:00
Kornel Benko
a1a7c21871 FindAdv: Amend 4276e1b0 2018-12-17 10:33:23 +01:00
Kornel Benko
4276e1b01e FindAdv: Handle also sizes of characters 2018-12-16 14:50:38 +01:00
Kornel Benko
2682170556 FindAdv: Comments 2018-12-14 19:51:24 +01:00
Kornel Benko
358626b735 FindAdv: Add handling spaces, dots, quotes ...
Treate spaces, dots and quotes as ordinary characters
Also discard length values for hspace,vspace and mspace
2018-12-13 17:12:57 +01:00
Kornel Benko
8a29bdb3d1 FindAdv: Added code, href, url and footnote to handled search formats
Remark: Inside code{} and footnote{} are the language settings ignored.
2018-12-11 17:27:50 +01:00
Kornel Benko
cd94180492 FindAdv: Simplify search for chars '&', '%', '#' and '_'
This is not possible for '$', because of the latex-meaning to
start/end math inset.
Therefore, if not ignoring format, we still have to use
[\\][\$] in regex in order to find '$' in text.
2018-12-05 13:36:43 +01:00
Kornel Benko
1cd80ff6c8 FindAdv: Eliminate a corner case in the binary search
Given the regex 'r.*r\b' and a string
"abc regular something cursor currently"
we expect to find "regular something cursor".
But while searching we may be confronted with input
"regular something cursor curr"
and so the searched string would be seen longer.
2018-11-27 19:10:27 +01:00
Kornel Benko
8549fbb326 FindAdv: Avoid crash finding char at end of inset
Testcase without this patch:
1.) open de/Additional.lyx
2.) goto 6.1 Astronomy & Astrophysics
3.) open the index
4.) find advaced
	a.) not ignoring format
	b.) regex = .+
	c.) language of regex: English
	4.) search next
The seach finds the next break (which is outside of the index)
The following try to display the selection leads to crash
2018-11-26 12:37:18 +01:00
Kornel Benko
578a4b6fb0 find: This change was not intended, amend e96a9d6329 2018-11-25 18:25:14 +01:00
Kornel Benko
e96a9d6329 Find: Use greedy behaviour
This change is valid for findadv too.
Patterns like '.*' now are greedy, like it is normal in regex
Searching for whole words is corrected, but can be slow.
One can speed up the search with adapted pattern.
So for instance searching for words starting and ending with 'r'
the normal pattern is 'r.*r'. The speed-up pattern could be
'\br[^\s]*r\b'. This halves the search time.

Search results are now different to that of lyx2.3, because the greedy
'.*' is now really greedy.
To achive the same results, we have to use '.*?' instead.
2018-11-25 17:51:20 +01:00
Jean-Marc Lasgouttes
e2a3dd1167 Fix compilation with msvc 2015
Without this, the compiler does not know whether 0 is a size_t or char
const *.
2018-11-24 19:17:31 +01:00
Kornel Benko
e9e3c50c65 FindAdv: Optimization
A try to decrement the number of tests for a match.

Also a try to handle Hebrew documents. Unfortunatelly
the latex output is missing the language specification
(only the change of encoding is available there).
I failed to find a proper place to add the lang.
That means, searching for e.g. English text in Hebrew documents
is not satisfying.
2018-11-20 14:36:11 +01:00
Kornel Benko
17ee4cafb1 FindAdv: Enable search for different languages in Korean documents too
The problem here was that for european languages only the encoding
was visible in latex output. Now also the language is provided.
2018-11-18 10:40:42 +01:00
Kornel Benko
0964ffb266 FindAdv: Remove left over comment character
Sometimes language spec starts with "% ". This happens in Japaneese documents
containig English text at start of paragraph.
2018-11-16 12:12:06 +01:00
Kornel Benko
06c05430d9 FindAdv: Added lyx-function search-ignore
Enable/disable ignoring the specified type
	language: e.g. british, slovak, latin, ...
	color:	blue, red, ...
	sectioning: part, chapter, ..
	font:
		series: bold, ...
		shape: upright, italic, slanted
		family: serif, monospace ...
	markup: enphasize, noun
	underline:
	strike:

Examples:
	search-ignore language true
	search-ignore shape true
2018-11-15 14:20:50 +01:00
Kornel Benko
702c495e98 FindAdv: Significantly increase the search speed
The needed time to find a simple string dependes on the
paragraph length was O(n^2)
Now it is down to O(n).
Before:
	To determine if the pattern matches we compared the
	paragraph from current position to the its end.
	Increment current position if no match
Now:
	Check if the character at current position has at least
	the needed features (text, color, language etc)
	If not, Increment current position
	else proceed as before
2018-11-13 12:11:33 +01:00
Kornel Benko
636bb6c2d9 FindAdv: Polishing search with regex containing '.'
Also added missing math env alignat
Modified handling of longtable/tabular
Added a routine to count for valid chars. This is needed
for detection of word boundaries.

Due to detection conflicts
	regex '.*' vs match of word-boundaries in MatchStringAdv::operator()
we need to use '\b' in regex explicitly. E.g. '\b.*\b'

The backward search works, but
1.) only in current paragraph (this is the same as before)
2.) only in the same language environment.
2018-11-12 12:28:31 +01:00
Jean-Marc Lasgouttes
7055bb0098 Change IgnoreFormats to a proper class
Instantiate a global variabble holding the formats and allow to modify
it using the helper function setIgnoreFormat.
2018-11-09 16:05:09 +00:00
Kornel Benko
f5d5777a86 FindAdv: Polishing
1.) Added \textmd to be ignored (sometimes it is used and sometimes not)
2.) Typo: multiline --> multline. Searching in 'multline' caused a crash
	because processing all of the '{' and '}' in the content of this math
	exceeded the size of the interval field.
2018-11-09 13:49:05 +01:00
Kornel Benko
0c05432284 FindAdv: Polishing
1.) Handle some unclosed parentheses
	Sometimes \shortcut is not correctly closed
2.) Added \ldots as known char
3.) Discard some shapes (circlepar, droppar, ...)
4.) Omit resulting empty string and use some value
	which cannot be matched instead
2018-11-08 09:59:51 +01:00
Kornel Benko
88428123ea FindAdv: Optimize for long matches
Still, if the matched string is at a rear part of a very long
paragraph, the search is way too slow.
2018-11-07 13:14:50 +01:00
Kornel Benko
9d304c0a1d FindAdv: Discard table decorations
That way we do not match the whole table but only the cell contents.
The problem I had was
1.) Document language Spanish
2.) Table (copied from English doc) => language English
3.) All cell contents Spanish

Now search for English text led to a selection of the whole
table, although there was no English content in any cell.
2018-11-07 09:35:16 +01:00
Kornel Benko
4f1cd00b02 Findadv: Initialize the position of first unprocessed open parentheses
Not initializing caused some wrong matches.
2018-11-06 15:28:43 +01:00
Kornel Benko
e487274ff4 Findadv: Polishing
1.) Do not remove '{}' unconditionally from \item parameter
2.) Do not output last empty entry
2018-11-05 12:58:45 +01:00
Kornel Benko
70e2f09c4f Findadv: Some glitches found while searching for English text in fr/UserGuide.lyx
Ignore \index
Handle \og and \bg as characters
Remove space in empty list-item (description or labeling)
2018-11-04 21:41:04 +01:00
Kornel Benko
aa68dcefa0 Findadv: 'Optimized' detection of matched string
This is clearly a hack, because I don't understand why the
previous code did not work.
2018-11-04 14:57:40 +01:00
Kornel Benko
e6418431dd Findadv: Handle the problem with list environments
The problem was, that the different list ennvironments
did not look different in tha latex output used for
search.
So the input of "\item ..." did not give information
if it is description, lyxlist, enumeration or labeling.

In search modus we use now "\item{enumeration}" etc.
2018-11-03 11:15:12 +01:00
Kornel Benko
5c83ad37d0 Findadv: Use '\n' as delimiter for end of data with same features
This allows to use '.' in regex without matching also wrong data.

Also added modified patch from ajd (see #11241).
2018-11-02 10:32:28 +01:00
Kornel Benko
5af8ec3240 Findadv: Allow multiple math statements in a line 2018-10-30 20:54:32 +01:00
Kornel Benko
f0d7432608 Findadv: Remaining findadv tests pass now
Exception: findadv-21, but it is not a regression,
because this one never passed.
The problem here is, that we cannot differentiate
between enumeration, itemize, description and labeling
environment here.
2018-10-29 13:17:54 +01:00
Kornel Benko
aecd98dc46 Findadv: Adapt search for special chars '[', ']', '%' and '#' 2018-10-29 07:37:32 +01:00
Kornel Benko
2d477c5e0a Changes to match math equations
Now tests findadv-01 ... findadv-20 pass too.

keytest.py: Expanded time for controll keys (like \[Return])
findadv*: expanded time for normal keys
lyxfind.cpp: Handle math equations
2018-10-28 19:40:14 +01:00
Scott Kostyshak
645d42f451 Revert "Comment out unused functions to restore -Werror"
This reverts commit bceb2390b4.

For details, see:

https://www.mail-archive.com/search?l=mid&q=4724814.5HqUF52VLN%40amd64
2018-10-28 11:43:47 -04:00
Scott Kostyshak
bceb2390b4 Comment out unused functions to restore -Werror
This commit restores compilation with -Werror and g++ version 7.3.0.

Consistent with 6dc450bc.
2018-10-27 20:59:26 -04:00
Kornel Benko
0f72179a07 Amend(4) 74c849d Advanced search with format
Prepare for use with func request. For instance to
ignore language while searching:
	setIgnoreFormat("language", true);
2018-10-27 16:57:42 +02:00
Kornel Benko
0b3f644469 Amend(3) 74c849d Advanced search with format
* Discard now unneeded code
* Remove macro '\uldepth=...'
2018-10-24 11:07:11 +02:00
Kornel Benko
2dd522472a Amend(2) 74c849d Advanced search with format
Added missing handling for chapter/chapter*
Also added frontmatter (title, author etc), but disabled ATM
2018-10-23 21:12:22 +02:00
Kornel Benko
ff9c32b382 Amend 74c849d, Advanced search with format
Remove macros like '\tiny ' or '\tiny{}' or '\tiny' followed by
any other non-alpha char correctly
2018-10-23 20:03:50 +02:00
Kornel Benko
74c849d651 Advanced search with format, preparing for selective searching
As it is now, searching with format needs ALL the features set
in order to match the pattern.
What needs to be done is a GUI specifying which of the features are
important.
1.) language
2.) font (series, shape)
3.) markup, underline, strikeout
4.) color
Having this info, the implementation is easy. Set
some variables and be done
2018-10-22 20:19:36 +02:00
Kornel Benko
140f843690 Advanced search with format, consider also sectioning macros 2018-10-20 12:47:37 +02:00
Kornel Benko
0be01de61f Advanced search with format, refactoring 2018-10-19 19:11:20 +02:00
Kornel Benko
6dc450bc46 Commented out an unused function to please a picky compiler 2018-10-19 11:10:54 +02:00
Kornel Benko
d6cc58f4a3 Amend(4) 7a03fa6: Advanced search with format:
Further normalize the latex input in case of enabled format search.

It was not enough to split the latex input on \foreignlanguage and \textcolor
macros only.
Instead also macros like \textt, or \noun etc had to be accounted for.

This patch uses therefore a different algorithm.
2018-10-18 17:37:15 +02:00
Kornel Benko
162c1f316b Amend(3) 7a03fa6: Advanced search with format:
Grrr... enable the search without format again
2018-10-15 08:09:19 +02:00
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
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
Tommaso Cucinotta
cb79658e54 Workaround for #7987: deleted text in change-tracking mode is not found in Advanced F&R any more. 2014-04-21 11:51:59 -04:00
Tommaso Cucinotta
13cb7da11d Merged Paragraph::stringify into asString(). 2014-04-21 11:51:59 -04:00
Juergen Spitzmueller
ad6f96bf48 Do not substract cursors pos from two different cells (fix assertion while doing adv search)
Fixes: #7944.
2014-04-21 11:51:59 -04:00
Richard Heck
0a6ff99f28 Typos and style. 2014-04-21 11:51:59 -04:00
Vincent van Ravesteijn
53b60462ac Revert "Fixing #7987: deleted text in change-tracking mode is not found in Advanced F&R any more."
This reverts commit cb351665f4.
2014-03-29 22:21:40 +01:00
Tommaso Cucinotta
cb351665f4 Fixing #7987: deleted text in change-tracking mode is not found in Advanced F&R any more.
Merged Paragraph::stringify into asString().
Added ignore of deleted text to Advanced F&R.
2014-03-27 23:36:15 +00:00
Jean-Marc Lasgouttes
c98ce56a03 Fix bug #8884: Crash when "navigate to next change"
The two fixes here a obviously right, although it is not clear why they are sufficient to fix the bug. Anyway I cannot reproduce any crash with it.

 * the first part just conditions a whole if/else to change_next_pos.changed(). Originally, only the if branch was concerned.

 * the second part is to avoid calling CursorSlice::backwardPos() when position is 0. Doing this leads to an assertion.
2014-03-03 11:16:56 +01:00
Scott Kostyshak
f52eb9d823 Comment a minor bug not worth fixing (#8986) 2014-02-19 16:21:46 -05:00
Tommaso Cucinotta
b93f2c20d3 Added restrict-search-to-maths-only checkbox to advanced pane of Advanced F&R. 2013-10-13 00:59:46 +01:00
Tommaso Cucinotta
7081fed380 Fixed a number of bugs in "preserve first case" feature of Advanced F&R (addressing #8383). 2013-07-22 10:39:11 +01:00
Pavel Sanda
4c0ef38200 Header cleanup cont. 2013-05-19 18:07:53 -07:00
Jean-Marc Lasgouttes
249d96ed94 Small clanup (just move functions around) 2013-05-06 22:50:26 +02:00
Jean-Marc Lasgouttes
68202fdf44 Fix bug 6055: change-next does not work in tables
The problem was just the faulty use of CursorSlice::at_begin/end(), which does not look for end of cell, but end of inset.
2013-05-06 12:29:27 +02:00
Richard Heck
d79225ae98 Remove all messages to user related to assertions. We'll just use
a basic message which is defined in lassert.cpp now.
2013-04-27 17:52:55 -04:00
Richard Heck
1b1f8dd235 Audit all the LASSERT calls, and try to do something sensible at
each failure.

There are several places I was not sure what to do. These are marked
by comments beginning "LASSERT:" so they can be found easily. At the
moment, they are at:

Author.cpp:105: // LASSERT: What should we do here?
Author.cpp:121: // LASSERT: What should we do here?
Buffer.cpp:4525:        // LASSERT: Is it safe to continue here, or should we just return?
Cursor.cpp:345:         // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:403:         // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:1143:                // LASSERT: There have been several bugs around this code, that seem
CursorSlice.cpp:83:     // LASSERT: This should only ever be called from an InsetMath.
CursorSlice.cpp:92:     // LASSERT: This should only ever be called from an InsetMath.
LayoutFile.cpp:303:                     // LASSERT: Why would this fail?
Text.cpp:995:           // LASSERT: Is it safe to continue here?
2013-04-25 17:27:10 -04:00
Jean-Marc Lasgouttes
77bf805155 Fix bug #3199: change-next may leave empty lines behind
Using Cursor::setCursor or even BufferView::setCursor is often a bad
idea since it does not run DEPM. In this case (and other cases in
f&replace code) it is better to use BufferView::mouseSetCursor (which
should maybe be renamed...).
2013-04-25 15:37:15 +02:00
Jean-Marc Lasgouttes
a88e5cbf74 Fix bug #8370: crash when searching for next change
Cursor::backwardPos() may enter in a nested inset, while CursorSlice::backwardPos() will not.
2013-04-07 14:22:37 +02:00
Tommaso Cucinotta
6ea1479252 Just refactoring patch 5e5115c3 in simpler terms. 2013-04-04 00:50:02 +01:00
Tommaso Cucinotta
5e5115c376 Fixed issue #8543 also for advanced search (cursor moved at proper end of selection before starting Find Advanced operation). 2013-04-04 00:43:36 +01:00
Scott Kostyshak
2427e9b57a Remove exclamation mark from "String not found!"
When using 'find' and a string is not found, this is not an error or a
surprising event. It is often expected (e.g. after searching through
the whole document for a certain string eventually you will get this
message). The exclamation mark should be reserved for messages that
are unexpected or that need extra attention, such as errors.
2013-04-01 15:33:41 -04:00
Kornel Benko
415343d19b Advanced search: Allow faster searching for normal (non-regular) strings
Setting variable 'par_as_string_nolead' also in case we are ignoring format,
drastically accelerates the search.
2013-04-01 10:16:45 +02:00
Jean-Marc Lasgouttes
0082d183b3 Fix confusing behavior in search when changing directions (bug 8543) 2013-02-22 15:53:40 +01:00