Commit Graph

28246 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
045aff3d9f Avoid duplicates in minibuffer history
The removal of duplicates is done in LastCommandsSection::add and uses
the erase-remove idiom for performance.

Most of the patch is a cleanup of GuiCommandBuffer:

* remove history_ member, that was a copy of the session lastcommands
  vector. Use instead a wrapper history() around it and a addHistory
  wrapper for adding new entries.

* Make sure that there is only one place where commands are added to
  history. The code used to maintain a list for interactive editing,
  and a list for saving the session. They could be different in terms
  of leading/trailing spaces.

* [unrelated] remove command_ member, which is just a copy of
  LyXAction list of commmands. Use directly lyxaction instead.
2022-07-13 19:53:08 +02:00
Enrico Forestieri
4a7a19352c Fix bug #12561
In mathed it is assumed that a labeled line is also implicitly numbered.
However, latex allows to label an equation without numbering it.
The label is then assigned the value of a nearby numbered one.
This commit drops the above mathed assumption in order to allow to import
valid latex code with a labeled but not numbered equation line.

The screen representation omits the line number and encloses the label
in square brackets for further differentiation. However, it is still not
possible to label an equation without numbering it using the GUI.
2022-07-13 19:11:03 +02:00
Jean-Marc Lasgouttes
f71a11f693 Fixup 95da2707: document getAlias. 2022-07-13 13:10:57 +02:00
Scott Kostyshak
c63e9d4caa Style 2022-07-12 17:55:04 -04:00
Daniel Ramoeller
95da270711 Check for icon aliases
The aliases are defined by a file in the (system or user) image
directory. The format is pretty simple: each line is like
  <str1> <str2>
Where every instance of <str1> will be replaced with <str2>.

Fixes bug #12509.
2022-07-12 23:35:48 +02:00
Scott Kostyshak
21eb2c4f74 Allow negative values for counters
enumi, for example, can be negative.
2022-07-09 16:40:22 -04:00
Jean-Marc Lasgouttes
2104ae8068 Fixup c30b0aac: protect against bad recursion
Adding this particular line created bad redraw interactions. See
thread on lyx-devel here:
https://marc.info/?l=lyx-devel&m=165648365808777&w=2

The code is reorganized a bit:

- the part of updateGUI() that (en|dis)abled elements is not moved to
  updateBottons ; the rest is renamed updateWorkAreas()

- only updateButtons is called now in eventFilter

- finally the recursion curse is fixed now in updateWorkAreas() by
  setting the old_buffer value _before_ calling copy_params. This
  avoid recursion if some bad update were to happen again.
2022-07-02 13:10:16 +02:00
Jean-Marc Lasgouttes
4c6dce1b0b Remove useless message (and avoid endless loop)
When changing the document class, the message "Converting document to
new document class..." is shown in minibuffer. This message leads to
weird GUI update interactions with the FindAndReplace panel, and
ultimately infinite loops. It would only be useful if the conversion
took a long time.

See this thread for rreference:
https://marc.info/?l=lyx-devel&m=165648365808777&w=2

Therefore, just remove it.
2022-06-30 12:30:01 +02:00
Jean-Marc Lasgouttes
c75522bbb7 Fix crash when dissolving a top level math inset
This should be disabled not only for math hull, but also macro template.

Fixes bug #12562.
2022-06-29 22:52:16 +02:00
Jean-Marc Lasgouttes
ae528715d3 Fix ToC action when cursor is in adv. F&R pane
This important part is the last point, the rest is what is needed to
make it happen.

* implement (FindAndReplace|FindAndReplaceWidget)::hasWorkArea, that
  tell whether a work area is own by the advanced find & replace
  widget.

* factor out method find() from GuiView::findOrBuild.

* implement GuiView::hasVisibleWorkArea, that tells whether a workarea
  is visible in the view (current tab in a split or adv. f&r
  workarea).

* Finally, in TocWidget::sendDispatch, change the current workarea
  temporarily to the document workarea before dispatching the
  function. The code tries to be as careful as possible to handle all
  cases. The future will tell whether it is good enough.
2022-06-29 11:09:14 +02:00
Jean-Marc Lasgouttes
2283440e77 whitespace 2022-06-28 23:51:09 +02:00
Pavel Sanda
6874c86cb5 Fix gcc 13 compilation.
Spotted by Jose.
2022-06-28 10:26:42 +02:00
Jean-Marc Lasgouttes
f2f0b30222 Fix line breaking thinko with Qt4
The test on whether to keep trailing spaces was inverted.
2022-06-27 16:12:02 +02:00
Juergen Spitzmueller
b7f0a90364 Amend [7efdbeaddf226/lyxgit]
We do not ship the nonfloat module, actually (I had a private copy).
2022-06-13 16:12:16 +02:00
Juergen Spitzmueller
7efdbeaddf Better UI for captions outside floats (#12554) 2022-06-13 13:22:58 +02:00
Jean-Marc Lasgouttes
ab54158447 Honor key bindings for commit string
When the commit string from the inputMethodEvent can be interpreted as
characters bound to some action, dispatch this action instead of
inserting the string.

This is useful on an international keyboard, when diaresis+space gives
a plain double quote. It is better in this case to enter a smart
quote.

Adapted from a patch from Daniel Ramoeller <d.lyx@web.de>.

Fixes bug #10377.
2022-06-13 11:22:50 +02:00
Juergen Spitzmueller
c29f31e982 Merge branch 'master' of git.lyx.org:lyx 2022-06-12 13:35:52 +02:00
Daniel Ramoeller
b2a7b715a2 Make space names more standard
Fix for bug #12547.

- "Interword" becomes "Normal"
- "Protected" becomes "Non-Breaking"

Plus a minor fixes to the "Horizontal Space Settings" dialog:
- Indicate that when "Non-Breaking" is disabled, the space will be non-breaking
2022-06-12 13:35:29 +02:00
Jean-Marc Lasgouttes
9ee952ce14 Allow to break rows before and after label and index insets
Since they are elements that do not appear in output, there is no
reason to make breaking around them difficult.
2022-06-09 21:29:21 +02:00
Jean-Marc Lasgouttes
254b2b0bfa Implement CanBreakBefore row flag
This is used for elements that allow to break a row before them
(similar to CanBreakAfter).
2022-06-09 21:27:43 +02:00
Kornel Benko
d0862d59e6 FindAdv: Remove needless functions 2022-06-06 13:18:08 +02:00
Daniel Ramoeller
d9f51be6ed Show size of named spaces in dialog
Fix for bug #12467.
2022-06-03 12:37:39 +02:00
Enrico Forestieri
0aad230154 Always validate a macro definition
If a user-defined macro appears only in the argument of another
macro its definition is not validated and this leads to errors.

Fixes bug #12524.
2022-05-31 22:17:14 +02:00
Jean-Marc Lasgouttes
e82cead90f Fix documentation of Row::splitAt 2022-05-31 17:04:20 +02:00
Kornel Benko
46c573c082 FindAdv: Use modified check to determine if char is a word-char.
Amends 652ffc9c(3)
2022-05-29 14:12:38 +02:00
Kornel Benko
5f5a43eb9e Guard 'isNumberChar()' from char outside ucs4-range 2022-05-29 14:08:36 +02:00
Kornel Benko
82af8778f1 Introduce isNumberChar(char_type) function
In FindAdv we use Qt to interpret regular expressions.
Regex uses for instance '\w', '\d' etc.
'\d' finds not just '0-9' but also e.g. '߂' (Nko Digit Two: U+07c2)
'\w' includes also such numbers.

ATM, only FindAdv uses this function.
2022-05-29 12:16:53 +02:00
Kornel Benko
0d6e3bcdc3 FindAdv: Amend 652ffc9c(2): Fix handling search for whole words if in mathed.
Didn't know, how to get char-value cursor is pointing to.
Hopefully someone knows a better way as in this patch.
2022-05-28 21:17:13 +02:00
Juergen Spitzmueller
52c5084d63 Forgot to pass third parameter 2022-05-28 20:41:56 +02:00
Juergen Spitzmueller
cd3116bbf9 Fix subfloat inset label (#11757)
This was broken at 9b7ccbfc/lyxgit
2022-05-27 09:26:40 +02:00
Kornel Benko
567d0e8fb4 FindAdv: Amend 652ffc9c: have to check inTexted() before using Paragraph 2022-05-26 17:17:49 +02:00
Kornel Benko
1ef1808c93 Amend b73ab025: Fix compilation with gcc-12 2022-05-26 14:05:49 +02:00
Kornel Benko
652ffc9c84 FindAdv: If searching for whole words, handle also the case that we are starting in the mid of a word.
In this case we skip the undesired word-characters before starting the search.

There are still some inconsistencies between LyX and Qt of 'what counts as a word-character',
but too hard to resolve.
2022-05-26 13:32:25 +02:00
Kornel Benko
bf60c61066 FindAdv: Fix expression checking for 'int' as if it were bool
Since the element 'match_len' in class MatchResult is an integer,
the check 'if (!match(...).match_len))' is changed to
'if (match(...).match_len) <= 0)'
2022-05-25 21:34:17 +02:00
Kornel Benko
df82386ce6 FindAdv: Attempt to make the code less crabbed
1.) The type of variable at_begin changes from bool to enum matchType
        true -> MatchStringAdv::MatchFromStart,
        false -> MatchStringAdv::MatchAnyPlace
2.) discard default parameter-values of
        MatchStringAdv::operator()
        MatchStringAdv::findAux()
2022-05-25 20:43:49 +02:00
Kornel Benko
d12bf6f979 FindAdv:
1.) Changed arrays dept and closes to vector-type because of runtime error in UserGuide.lyx
    with a big paragraph (size > 8900 chars) contained too many opening parentheses
2.) Removed one creation 'textcyrillic'-key because it is later anyway created
3.) Most important (thanks to Scott who found the failure)
    Move the check if the found string really is part of MATH to
    the relevant place.
    Without this change the search using 'Search only in maths' will fail miserably.
2022-05-24 23:41:31 +02:00
Juergen Spitzmueller
cd27fec2d7 BufferParams::copyForAdvFR(): include quote style 2022-05-23 14:32:01 +02:00
Kornel Benko
9e19258478 FindAdv: Do not search for accents if the command-parameter contains '\\'
The only exception are command-parameters '\\i', '\\imath' or '\\jmath'.

Example '\ddot{\\imath}'
2022-05-20 12:46:26 +02:00
Jean-Marc Lasgouttes
c6725df2db Fixup d723b903: Fix slow display of large paragraphs
When implementing multi-row string breaking, an extra createLine()
statement, which made sense in the original code, was kept by mistake.
This basically made the mechanism ineffective, because it created one
row with the correct length, plus a second one with all the remaining
text, which would have to be itself broken. This went undetected
because the display is still correct.

Additionally, this issue polluted the break cache to the extent that
the hit rate could be 0%.

Together, these two effects created a major slowdown with a document
containing a single ~30000 characters paragraph.

Fixes bug #12534.
2022-05-19 16:18:24 +02:00
Jean-Marc Lasgouttes
6dd5656a2c pmprof: fix missing output in the 100% miss case
Also update to the latest version of pmprof.
2022-05-19 11:37:51 +02:00
Juergen Spitzmueller
a77c84a0b4 Allow for several (comma-separated) PackageOptions 2022-05-19 10:31:37 +02:00
Jean-Marc Lasgouttes
32437bd59f Fixup 5f8959d4: keep cursor font when there was no selection
When toggleFree is called without a selection, the only result is to
change the cursor currentfont.

In the other cases (selection or implicit selection), we want to reset
the cursor font from the text font.

Fixes bug #12518.
2022-05-17 23:10:31 +02:00
Daniel Ramoeller
2b493ff70f Word selection on mouse motion
Partial fix for bug #9160.
2022-05-17 18:45:31 +02:00
Jean-Marc Lasgouttes
5f8959d40e Make sure that current cursor font is updated when changing font
Fixes bug #12518.
2022-05-17 12:15:58 +02:00
Kornel Benko
1464bd3f3f FindAdv: Amend(2) f845a4e9
Removing '\n' like in previous version with utf8-strings
This is needed e.g. for display math, which comes as
	"\n\\[\n.....\n\\]\n"
2022-05-14 14:49:52 +02:00
Kornel Benko
cd6d21ebb3 FindAdv: Amend f845a4e9
Also do not remove '\n' if in non-format-search mode. Otherwise
'\n' cannot be found with regex '\s'
2022-05-14 09:51:23 +02:00
Kornel Benko
f845a4e9a3 FindAdv: Do not handle stale empty latex commands if not in format-search mode
In non-format-search mode, we do not have any latex commands here.
2022-05-14 09:25:06 +02:00
Kornel Benko
115d6ceedd FindAdv: Don't check on '\\\\\n' if ignoring format
Since it can only happen if the lyx source contains two backslasches before
the inserted newline. And here it is the wrong case.
2022-05-14 08:56:00 +02:00
Kornel Benko
b0323628af FindAdv: Amend 6c735efb: Resolve some conflicts regex vs. math meaning of '$' 2022-05-13 12:00:47 +02:00
Kornel Benko
6c735efb1f FindAdv: In format search could '$'-char be interpreted as math-start.
To handle this case, we use '\lyxdollar' string instead.

Also try to handle '\n' in the docstring directly instead in the
string already converted to utf8.
(The utf8-version is still there, but commented out)
2022-05-13 09:30:30 +02:00