Commit Graph

571 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
9b18a9b609 Fixup e1be71da5: avoid duplication of layout
If the containing paragraph has kept its layout, reset the layout of
the first paragraph of the newly inserted inset.
2020-09-07 14:16:47 +02:00
Pavel Sanda
28968b1f0d Add required elements in the layouts to support DocBook.
Slightly modified patch from Thibaut Cuvelier.
2020-07-07 09:49:48 +02:00
Juergen Spitzmueller
9f13bb73f8 Consider nesting level when autonesting 2020-06-25 10:37:04 +02:00
Jean-Marc Lasgouttes
fc5b22a2f1 Get rid of lyx::next uses for RandomAccessList
These uses are inefficient (a loop really) and require that pit_type
is ptrdiff_t.

Instead, RandomAccesslist::constIterator is renamed to iterator_at and
a version adding a non-const iterator is added. Additionally, the
method retirns end() when position is equal to the size of the
container (see #11861).

lyx::next and lyx::prev are removed, and std::prev is used in the few
places where the code requires it (for no good reason IMO).
2020-05-14 10:35:49 +02:00
Jean-Marc Lasgouttes
c756749991 Revert "Get rid of lyx::next uses for RandomAccessList"
This is not ready (see #11861).

This reverts commit 6d97e39934.
2020-05-13 10:45:25 +02:00
Jean-Marc Lasgouttes
6d97e39934 Get rid of lyx::next uses for RandomAccessList
These uses are inefficient (a loop really) and require that pit_type
is ptrdiff_t.

Instead, RandomAccesslist::constIterator is renamed to iterator_at and
a version adding a non-const iterator is added.

lyx::next and lyx::prev are removed, and std::prev is used in the few
places where the code requires it (for no good reason IMO).
2020-05-12 17:29:21 +02:00
Scott Kostyshak
a1169188c7 Fix assertion from setCursor() in outline-down/up
The function outline() itself can change the cursor position in some
cases so we need to store the old position before calling outline().

Spotted by Kornel. For an example file that triggered the assertion,
see:

  https://www.mail-archive.com/search?l=mid&q=20200326183314.09ad4c7c%40admin1-desktop

This commit amends adb7283b.
2020-03-26 19:00:37 -04:00
Richard Kimberly Heck
7c7ea3113f Use ranges and fix nullptr warnings. 2020-03-16 01:31:30 -04:00
Scott Kostyshak
adb7283b69 outline-up/down: preserve cursor's position
There is no need to change the cursor's position to the beginning of
the line.

This change does not affect the behavior of using the buttons in the
Outliner pane, but is useful for using the keyboard shortcuts.
2020-03-11 14:19:05 -04:00
Juergen Spitzmueller
228d738868 Account for changes in insets when checking changes in selection
This is not ideal, see FIXME.

Fixes #11774
2020-03-06 10:53:54 +01:00
Stephan Witt
f904fb2d61 Add missing initialization for local variable.
The autoargs variable is random for empty macro argument lists otherwise.
2020-02-18 08:59:20 +01:00
Stephan Witt
fe02f151f9 Remove useless assignments to a local variables never read later. 2020-02-18 08:55:45 +01:00
Scott Kostyshak
05f2494008 Remove a finishUndo() after a recordUndo()
finishUndo() is only helpful in the presence of undos of type INSERT
or DELETE.

See the following ML thread for details:

  https://www.mail-archive.com/search?l=mid&q=b721c098-c7ee-d12f-1cdf-067dda9aa5cf%40lyx.org
2020-02-02 16:10:59 -05:00
Juergen Spitzmueller
adfd38e4ef Fix backspace deletion of selected items with change tracking
Move cursor at beginning of selection after deletion. Else backspace
operation gets stuck in a loop (tries to remove the selection again
and again).

This also fixes backspace deletion of insets with confirmDeletion() == true.

Fixes #11630
2020-01-13 09:48:56 +01:00
Jean-Marc Lasgouttes
d9edf32b67 Remove some useless expressions
Spotted by cppcheck
2019-10-27 00:09:05 +02:00
Richard Kimberly Heck
94896166d4 Fix bug #11619. 2019-09-11 22:13:58 -04:00
Jean-Marc Lasgouttes
e1be71da59 Reset layout when inserting an inset over full paragraph(s)
1/ When inserting an inset over a selection, it makes sense if the
selection covers a complete or several paragraphs to reset the layout of
the paragraph that contains the inset to plain layout. In general the
inner inset will have the needed layout information and it does not
make sense to keep this information outside.

However, when the inset forces plain layout, it does not make sense to
do that and the outer layout is preserved.

Some code that duplicates what is done in pasteSelectionHelper is also
removed.

2/ Similarly, when dissolving an inset, do not reset the layout of the
first paragraph if the inset was alone in its own paragraph.

Note that this does not work as intended when change tracking is enabled.

Fixes bugs #10266 and #10369.
2019-09-11 10:39:02 +02:00
Scott Kostyshak
27f89144bb Enable change tracking if paragraph break change
When a selection spans more than one line, we now check for whether
there is a change at one position after the last position of each
fully selected line.

This fixes #11629.
2019-08-30 22:31:24 -04:00
Juergen Spitzmueller
9e6d22ea9c Add InsertOnNewline argument tag
This adds a paragraph break before auto-inserting arguments in flex
insets.

Useful for specific arguments (particularly ling glosses)
2019-06-02 18:07:10 +02:00
Juergen Spitzmueller
378c7e8edb Allow for auto-inserting multiple arguments 2019-06-02 09:26:32 +02:00
Juergen Spitzmueller
532765c03a Enable AutoInsert with post arguments 2019-06-02 09:25:56 +02:00
Kornel Benko
e0f5641089 Select the whole paragraph with tripple-left-click
Fixes #9175

Also added new function: paragraph-select.
2019-04-16 19:50:31 +02:00
Juergen Spitzmueller
6482ddee30 tabular-style-insert: add rows also for 1x and 2x tables
Fixes: #11537
2019-04-07 12:10:03 +02:00
Jean-Marc Lasgouttes
f609a4717f Pass a pit to Text::isRTL(), not a paragraph 2019-04-02 09:56:42 +02:00
Juergen Spitzmueller
4b3aacd13b Add TableStyle layout tag
Fixes: #8360
2019-03-26 17:42:56 +01:00
Juergen Spitzmueller
ecb2427f41 Add tablestyle buffer param
Fixes: #9901
2019-03-26 16:24:27 +01:00
Juergen Spitzmueller
683b3a05e2 Introducing table templates
The idea is simple: we insert a pre-formatted table (with a given border
style currently, but other attributes are possible as well) via file-insert
and scale it then to the requested size.

We need three sizes (1x1, 1x2 and 1x3) to generate all sizes properly (due
to border specifications).

Currently, these styles can only be accessed via lfun tabular-style-insert
and the Tabular Create dialog.

My plan is to add a buffer param to set a default style (#9901) which then
also is respected by the toolbar button and probably a layout tag to let
classes specify a default style (#8360).
2019-03-26 13:43:33 +01:00
Jean-Marc Lasgouttes
d52e04a9b3 Fix fonts used by sub/superscript in text
Several changes are needed to get things right:
* nested supersripts only work with inheritFonts=true.

* to get caret position right, it is necessary to remember the outside
  font of the inset before computing metrics.

* to get the size right at insertion time, it is necessary to trigger
  a metrics computation just after inset insertion.
2019-03-22 16:19:52 +01:00
Jean-Marc Lasgouttes
f659af339e Revert "Let tm be a reference here as elsewhere"
This commit was wrong because a reference variable can never be
re-assigned (it would change the original variable). I learn C++
pitfalls every day.

Fixes bug #11512.

This reverts commit 10e2c65835.
2019-03-12 16:03:22 +01:00
Jean-Marc Lasgouttes
10e2c65835 Let tm be a reference here as elsewhere 2019-02-18 15:47:27 +01:00
Juergen Spitzmueller
59d73f52b8 Do not auto-insert separator for keepempty layouts
Candidate for stable
2018-12-29 13:35:39 +01:00
Scott Kostyshak
c5301a6495 Fix assertion when checking if change in selection
The check for the iterator being in the same paragraph as the end of
selection was incorrect, because paragraphs in different cells could
have the same pit. We now additionally condition on having the same
idx.

This commit amends d1279875 (and thus 23de5e5e).

For discussion, see:

  https://www.mail-archive.com/search?l=mid&q=a5afd0c01a0eb9a84fd4d050d15eb23016d6f38a.camel%40lyx.org

Thanks to Jürgen.
2018-12-28 10:46:30 -05:00
Juergen Spitzmueller
2f9876a410 LFUN_TEXTSTYLE_UPDATE: Do not force any unspecified settings.
Fixes: #11111 (yay!)
2018-12-27 15:30:57 +01:00
Juergen Spitzmueller
2d876f8d9d Disable LFUN_FONT_DEFAULT if there's noting to reset. 2018-12-27 14:16:00 +01:00
Kornel Benko
9ee515c984 Amend 154b4fde 2018-12-26 17:45:34 +01:00
Juergen Spitzmueller
154b4fdece Give textstyle-apply a history
The last 20 applications are saved now and accessible both via the lfun
(textstyle-apply n) and the toolbar (via button menu)

Fixes: #7133

This also changes the default icon and toolbar position of the action,
as requested in #11427
2018-12-26 15:46:14 +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
Juergen Spitzmueller
4648f39a1e info-insert without arg is valid
it opens the info dialog.
2018-09-20 11:11:44 +02:00
Juergen Spitzmueller
92bfa07a62 Avoid infinite loop
Fixes: #11295
2018-09-19 10:19:19 +02:00
Juergen Spitzmueller
ed61ce74b7 So long, date-insert!
This function is superseded by info-insert date, which is much mightier
and more flexible.
2018-08-20 09:25:22 +02:00
Juergen Spitzmueller
b0f579655c InsetInfo: Move validateArgument() to params
and use it for LFUN_INFO_INSERT validation
2018-08-18 14:29:15 +02:00
Juergen Spitzmueller
307319e95e Introduce InsetInfoParams
This allows to open the dialog without having an inset already.
2018-08-06 20:07:15 +02:00
Juergen Spitzmueller
e730234e57 Add date-related info insets
With this commit, info insets leave the dark backstage room of an opaque
and quite hidden dev-only feature and come frontstage.

In the UI, they present themselves as "Fields" since this is what people
know from word processors. Other user-related fields that could be
implemented next: time, user name (I plan to do that for 2.4).

Since this supersedes date-insert, I removed Insert > Date from
the menu and propose to ditch date-insert and the corresponding rc.

The lyx2lyx reversion routine has lots of room for improvement and
attractive tasks for pythons (file timestamp, switch of localization).
Please feel invited!

This is a file format change.
2018-08-05 10:01:36 +02:00
Scott Kostyshak
d12798759a Fix crash when selecting text with changes
When selecting text, in some cases a DocIterator could be forwarded
to a (non-existant) paragraph after the end. The critical part of
this fix is to break the loop at the correct place. The following
are additional improvements:

- increase readability by defining a bool named "in_last_par"
- use cur.selectionEnd().pit() instead of cur.selectionEnd().paragraph().id()
- use it.lastpos() instead of it.paragraph().size()

This commit fixes a regression introduced by 23de5e5e, and reported
at #11204.

Thanks to Jürgen and JMarc.
2018-07-27 15:39:39 -04:00
Juergen Spitzmueller
803a88f243 Sort out problems with InsetInfo language settings
* use the context language of the info inset (rather than the buffer
language), and translate strings accordingly

* for menu and shortcuts, use the Gui language instead

* actually care that all translatable strings end in po
(this wasn't the case).

Fixes: #5348, rest of #10463
2018-07-27 12:14:37 +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
Jean-Marc Lasgouttes
ad5548cfe3 Fixes to input method handling
The goal of this patch is to make "self-insert <string>" act as a
sequence of individual self-insert calls. Once it is done, the
insertion of the commit string in GuiWorkArea can use that, which
fixes the issues described in bug 11183.

1/ in InsetMathNest, SELF_INSERT is rewritten to be a proper loop of
   interpretChar, instead of inserting the string as characters. This
   solves the issue of interpreting ^ properly.

2/ the text version does not need to be changed (the loop is rewritten
   using a range, though).

3/ Then {{{GuiWorkArea::inputMethodEvent}}} is changed to invoke
   directly self-insert. This removes the update issues.

Fixes bug 11183.
2018-07-05 14:32:37 +02:00
Jean-Marc Lasgouttes
3591aa833f Implement layout-toggle lfun
This is like `layout', except that the layout is reset to default if
it was already correct. In the case of a selection, the layout is set
normally if some layouts in the selection are not at the required
layout; it is reset only if all the layouts of the selection already
have the required layout.

Part of ticket #9864.
2018-05-15 00:03:55 +02:00
Jean-Marc Lasgouttes
255a5cf401 Clean up code of LFUN_LAYOUT
Factor out some code in helper functions. Improve getStatus so that
icon is selected only when the whole selection has the correct layout.

This work towards ticket #9864.
2018-05-14 16:45:46 +02:00
Scott Kostyshak
23de5e5e19 Only show Accept/Reject Change options if relevant
In the context menu for a selection, we now only show the options
"Accept Change" and "Reject Change" if there is actually a change in
the selection. Similarly, in the toolbar, the buttons are only
enabled when there is a change in the selection.

This fixes #10338.
2018-05-10 12:58:44 -04:00