Commit Graph

304 Commits

Author SHA1 Message Date
Yuriy Skalko
b0db575dc1 Show custom text styles in status bar
Fixes bug #11951.
2020-09-14 11:38:29 +02:00
Stephan Witt
320b6b6656 #6401 correct cursor movement for word forward/backward with enabled Mac style (mac_like_cursor_movement)
The change includes a rewrite of the cursor movement when „mac style“ is enabled and don’t change anything otherwise.
The new code for mac uses the document iterator to go forward or backward. The traversal stops at word boundaries.
If going forward the position increments until a word is reached (if not already inside) and stops at the end of the word.
If going backward it does the same in opposite direction. The cursor jumps over non-editable insets and math.
Editable (open) insets are entered and the cursor move detects word boundaries inside them.
2020-09-12 14:34:56 +02:00
Jean-Marc Lasgouttes
efc8d44d09 Fixup 2e784b2f: consider default layout too.
And simplify the test at the same time.
2020-09-03 12:56:33 +02:00
Stephan Witt
0fa4b7e736 #9376 prepare use of Length in lyxrc - move the class Length to support 2020-08-07 09:24:31 +02:00
Richard Kimberly Heck
6834321a50 Allow backspace, etc, to merge paragraphs even if they have different styles.
Patch from Daniel.

This is bug #11917. Master only.
2020-08-02 23:24:22 -04:00
Jean-Marc Lasgouttes
f758894c2f Use Common Number separator instead of European to detect numbers
The is a fixup to commit 611df441. It seems that the wrong unicode
property was selected. It could be that both classes should be used.

Fixes bug #11900.
2020-07-10 18:06:41 +02:00
Juergen Spitzmueller
2c0b650aa6 Do not attempt to mark par break in single-line insets 2020-07-09 18:47:53 +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
Richard Kimberly Heck
1344caa67a Fix problem with c67b6be77 noted by JMarc. 2020-04-26 16:10:50 -04:00
Richard Kimberly Heck
c67b6be77e Refactor code to avoid the problem fixed at the last commit. 2020-04-25 01:11:30 -04:00
Richard Kimberly Heck
b5a5a529a3 Fix bug #11850.
When we copy the paragraphs, the Buffer members for the insets are
not set. As a result, we crash when attempting to access them.
2020-04-25 01:05:15 -04:00
Richard Kimberly Heck
f7065fa22e Fix bug #11817.
Preserve line spacing when breaking a paragraph at the beginning.
2020-04-08 17:21:43 -04:00
Juergen Spitzmueller
52cd43dfdc Paste some special chars as insets
See #11790
2020-03-23 12:07:47 +01:00
Juergen Spitzmueller
7b3404fcab Don't omit ZERO WIDTH NON-JOINER on clipboard paste
Fixes #11790
2020-03-22 11:07:57 +01:00
Richard Kimberly Heck
7c7ea3113f Use ranges and fix nullptr warnings. 2020-03-16 01:31:30 -04:00
Juergen Spitzmueller
5fc2662b13 Add pref to keep ct markup on copy/paste
Fixes #10278, #10128
2020-01-13 15:20:48 +01:00
Juergen Spitzmueller
ff85641cc0 Whitespace 2020-01-13 09:21:32 +01:00
Juergen Spitzmueller
ac8aa981db Do not track deletion of empty paragraph
Fixes #10412
2020-01-11 18:11:26 +01:00
Juergen Spitzmueller
b2c2a6e15d Correctly handle deleted text on inset-dissolve
Part of #10128
2019-12-27 14:32:20 +01:00
Jean-Marc Lasgouttes
2e784b2f06 Fixup e1be71da: do not enforce plain layout when dissolving
Instead of checking whether the dissolved inset enforces plain layout,
it is better to check whether is uses plain layout.

Fixes #10369.
2019-12-06 10:23:03 +01:00
Richard Kimberly Heck
2c0421f00c Constify 2019-09-11 19:39:03 -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
Jean-Marc Lasgouttes
283ac91aa7 Put end label on own row after display inset
This corresponds to what is done on display. The same should be done
for start label too (e.g. beginning of a proof), but this requires more
work.

This required to move the static function getEndLabel to Text.

Fixes bug #11536.
2019-04-03 11:17:14 +02:00
Juergen Spitzmueller
3ae6bff538 Do not consider deleted labels in ambiguity check
This adds a new (boolean) parameter "active" to the label cache, where
we track whether a label is deleted in ct mode (the same could be done,
if wanted, for labels in notes and inactive branches).

Deleted (inactive) labels are neither considered in the uniqueness check
nor added to the outliner. This also means that undeleted references to
deleted labels are now (correctly) marked as BROKEN.

Fixes: #6563
2018-12-29 10:08:02 +01: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
Juergen Spitzmueller
611df441b6 Consider EuropeanNumberTerminator property when determining text direction
Also, use EuropeanNumberSeparator information rather than relying on an
own (incomplete) list of number separators.

Fixes: #4057
2018-07-22 12:38:22 +02:00
Jean-Marc Lasgouttes
789acb4a95 Do not allow completion when there is an active selection
We do it in texted only, mathed is more difficult and not so relevant IMO.
2018-07-03 17:01:20 +02:00
Richard Kimberly Heck
7af1a065e8 update assertion. 2018-06-26 00:26:35 -04:00
Juergen Spitzmueller
57dc817581 Add \nospellcheck font property
This revives a ten year old idea (and patch) by Dov.

You can now mark in the character dialog text and exclude it from spell
checking.

Fixes: #1042

File format change

Remaining issue: The instant spell checking marks are not immediately
removed, but only after some editing.
2018-05-06 19:48:21 +02:00
Richard Kimberly Heck
ea9fe52336 Note. 2018-05-04 12:39:07 -04:00
Richard Heck
dd2efe8d0d Fix for #10624.
If we're in the first paragraph after a division (section, etc),
use the prefix for it.
2018-04-20 23:27:29 -04:00
Richard Heck
d9ebf6e2c7 Fix bug #11102.
Ignore deleted material when generating a proposed label.
2018-04-03 18:39:28 -04:00
Jean-Marc Lasgouttes
e90b6f5a3b Add cell number to current state in devel mode
This value is added when inside a texted inset with several cells
(aka a tabular inset).
2018-03-07 11:54:40 +01:00
Richard Heck
68b959ff06 Fix bug #10924. 2018-02-24 00:08:28 -05:00
Juergen Spitzmueller
931f87f508 Introduce "inherit" encoding for latex_language
This gets rid of the hardcoded latin1 encoding for verbatim. Instead,
verbatim now inherits the encoding from the context, which is what is
actually wanted here.

Fixes: #9012, #9258
2017-12-24 17:10:42 +01:00
Jean-Marc Lasgouttes
02028c0b12 Move some Cursor methods to CursorData
Basically, everything that does not depend on a BufferView should move
there. Some methods that do not seem to need a BufferView, like
selHandle or IdxFirst or push actually depend on it and could not be
moved.

This allows to simplify a few uses of recordUndo helpers.

- Move some methods to DocIterator: nextMath, prevMath, getPossibleLabel,
  getEncoding;

- Move some methods to CursorData: setCursor, setCursorSelectionTo,
  (setCursorTo|normal|reset)Anchor, (set|clear)Selection,
  sel(|ection)(Begin|End), selectionAsString, info, currentState,
  (mark|clear|check)NewWordPosition, fixIfBroken, sanitize, all undo
  related methods, reset, isInside, leaveInset, current mode;

- kill some unused methods: macromode, replaceWord, setScreenPos, touch,
  markInsert, markErase;

- Move code around to group things, and add a few comments (a lot remains to be done).

This changes lead to some related changes in other classes: removal,
change of parameter.

No intended change.
2017-10-25 16:20:27 +02:00
Jean-Marc Lasgouttes
9fe8190364 Make "devel mode" configurable at run time
Traditionally LyX behaves differently when the directive DEVEL_VERSION
is defined at compile time. This covers
* more detailed description of current position in status bar
* the help files are open in read/write mode
* more detailed debug output in the View Source panel

This patch introduces the new function devel-mode-toggle that allows
to use devel mode in stable releases, and vice versa.

The information is saved in the session file. The default is to
disable devel mode.

Remove all traces of DEVEL_VERSION in autoconf and cmake
2017-07-24 22:00:44 +02: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
Jean-Marc Lasgouttes
cfd27dd219 Do not record undo when typing two spaces has been blocked
Move the code that forbids character insertion in its own helper function.

Call this function before doing a recordUndo. This avoids to mark the
document dirty in cases where nothing happens.

Part of bug #10721.
2017-07-11 12:15:29 +02:00
Jean-Marc Lasgouttes
8910a8a1cc Fixup 9c92494e1a: avoid crash in Inset::dissolve()
The code path when the inset is empty did not fixup the cursor
position correctly.

Part of bug #10667.
2017-06-23 19:44:54 +02:00
Jean-Marc Lasgouttes
9c92494e1a Avoid memory reuse problems with inset-dissolve
If
 1. the inset is deleted before pasting its contents in the outer text, and
 2. the inset contents begins with an inset, and
 3. the clone of this inner inset is allocated at the memory location just
    made free,
then bad things can happen.

To avoid this, we delete the inset only after its contents has been pasted.

Fixes bug #10667.
2017-06-15 11:53:33 +02:00
Uwe Stöhr
e575e7eebd Add support to cross out characters
- adds support for the command \xout of the LateX package ulem
- fileformat change
2017-04-05 00:01:19 +02:00
Enrico Forestieri
3c329db0a5 Allow inserting consecutive dashes
Because latex allows to do so, and there is no easy way to achieve this.
This was apparently implemented to allow cycling between the various dash
types, but it was a bad idea bringing no benefit and causing griefs.
2017-02-25 14:13:02 +01:00
Guillaume Munch
71623b88b2 Generalise the deletion protection mechanism from math to text (#9540)
Now backspace and delete in text will select non-empty math and text insets
before deleting them. This is consistent with what happens in math already.

This is implemented for InsetText as well but can be disabled in case of
negative feedback.

This can be set for any sort of inset with the new virtual method
Inset::confirmDeletion.

New option "force" for the LFUN_*_DELETE_* commands, that bypasses the
confirmDeletion check.
2017-02-18 23:03:23 +01:00
Guillaume Munch
68109443f3 Implement AddToToc for paragraph layouts
Enables table of Theorems & Definitions
2017-01-09 18:27:25 +01:00
Guillaume Munch
0eb0b8531a Convert a pointer to a reference
The validity of the reference is guaranteed by QThreadLocalStorage
2016-12-31 15:28:43 +01:00
Guillaume Munch
e1492a3ab1 Use the new infrastructure to select rows during error reporting 2016-10-22 23:24:00 +02:00
Jean-Marc Lasgouttes
b162bd6d2b When breaking an empty paragraph reduces depth, set layout too
This requires an adaptation of the Separator inset insertion code,
which has been duly provided by Enrico.
2016-10-20 14:38:12 +02:00