Compare commits

...

19 Commits

Author SHA1 Message Date
Juergen Spitzmueller
2ac0db401e Better fix for Spanish Tufte problem
The option "nohyper" causes the issue
2024-09-22 17:20:59 +02:00
Pavel Sanda
07df92108e * LFUNs.lyx 2024-09-22 16:48:29 +02:00
Kornel Benko
c0f969ea35 Update sk.po 2024-09-22 13:33:46 +02:00
Juergen Spitzmueller
2273ab1c20 de.po 2024-09-22 12:34:38 +02:00
Juergen Spitzmueller
32bc034ef7 document changes for #1624 2024-09-22 11:59:39 +02:00
Juergen Spitzmueller
d9d81b3f7a Some documentation for reference-to-paragraph
(cherry picked from commit 01ab4c151e)
2024-09-22 11:57:10 +02:00
Juergen Spitzmueller
a1cf383a50 reference-to-paragraph for footnotes
(cherry picked from commit 1c5fd2ea4e)
2024-09-22 11:57:10 +02:00
Juergen Spitzmueller
608e678217 Amend 9464f0526e
Simplify function

(cherry picked from commit 9fc1194494)
2024-09-22 11:57:10 +02:00
Juergen Spitzmueller
173464b8a3 Fixup LFUN_REFERENCE_TO_PARAGRAPH for captions in other buffers
The movement to the caption is now done in the LFUN function itself,
as we need the DocIterator in the caption

This greatly simplifies the code in the TocWidget and shifts all the
complexity to the LFUN itself

(cherry picked from commit 9464f0526e)
2024-09-22 11:57:09 +02:00
Juergen Spitzmueller
0c77174406 fixup REFERENCE_TO_PARAGRAPH:
* par id actually can be 0
* properly move on in the buffer list if paragraph is not found
  in the current buffer
* use dit to get label (as this might be in a different buffer)

(cherry picked from commit 4ed822925f)
2024-09-22 11:57:09 +02:00
Juergen Spitzmueller
8fc5266996 typo
(cherry picked from commit 2c4536c709)
2024-09-22 11:57:09 +02:00
Juergen Spitzmueller
454800a096 rename Paragraph::getLabel()
getLabel() usually refers to a paragraph label (e.g. \item) in this
context, not \label as in the case here.

(cherry picked from commit 7d46ddaa95)
2024-09-22 11:57:09 +02:00
Juergen Spitzmueller
2f6838cab3 fixup definition of LFUN_REFERENCE_TO_PARAGRAPH
(cherry picked from commit 2fdeee4bf7)
2024-09-22 11:57:09 +02:00
Juergen Spitzmueller
179983a7fb Implement reference-to-paragraph in outliner (#1624)
This allows to insert a cross-reference to headings, figures or tables
by right-clicking on the outliner item.

If the item in question does not have a label yet, it is inserted.

(cherry picked from commit 143e534d1e)
2024-09-22 11:57:09 +02:00
Juergen Spitzmueller
69614db1ec Implement LFUN_REFERENCE_TO_PARAGRAPH
This function checks whether a paragraph (specified by ID) has a label.
If so, it simply inserts a reference to this at cursor position, if
not it inserts a label to that paragraph (pos 0) and then inserts
a reference at cursor position.

Needed to implement #1624 (insert cross references to items that do not
have yet a label)

(cherry picked from commit 3fe99bf6f5)
2024-09-22 11:57:08 +02:00
Juergen Spitzmueller
ce64021ce9 Allow DocIterator::paragraphGotoArgument() to return id() without pos()
We need this for the forthcoming reference-to-paragraph function

(cherry picked from commit e3b36208ed)
2024-09-22 11:57:08 +02:00
Juergen Spitzmueller
dcc91b4a85 Implement Paragraph::getLabel()
This function returns the first label (as string) if there is any

(cherry picked from commit a303600b54)
2024-09-22 11:57:07 +02:00
Juergen Spitzmueller
18d9d7ee9d re-implement LFUN_REFERENCE_INSERT
this is in preparation of another feature

(cherry picked from commit 181c8ce7c1)
2024-09-22 11:57:07 +02:00
Juergen Spitzmueller
a6a2cdcf92 Work around fragility problem in Spanish Tufte Handout
It is unclear what the actual problem is; it only shows up in this
document (not the other l7ns)
2024-09-22 11:51:39 +02:00
20 changed files with 697 additions and 248 deletions

View File

@ -4433,6 +4433,27 @@ Action Redoes the last thing undone.
Syntax redo Syntax redo
\end_layout \end_layout
\begin_layout Subsection*
reference-insert
\end_layout
\begin_layout Description
Action Inserts a cross-reference into the document.
\end_layout
\begin_layout Description
Notion Optional <TYPE> can be used to set the type of reference
\end_layout
\begin_layout Description
Syntax reference-insert <LABEL> [<TYPE>]
\end_layout
\begin_layout Description
Origin spitz,
28 Jul 2024
\end_layout
\begin_layout Subsection* \begin_layout Subsection*
reference-next reference-next
\end_layout \end_layout
@ -4450,6 +4471,45 @@ Origin Dekel,
14 Jan 2001 14 Jan 2001
\end_layout \end_layout
\begin_layout Subsection*
reference-to-paragraph
\end_layout
\begin_layout Description
Action Inserts a cross-reference to the paragraph with a given ID
\end_layout
\begin_layout Description
Notion The function checks of the paragraph already has a label.
If so,
it uses that.
Otherwise it inserts a label and uses this.
\end_layout
\begin_layout Description
Syntax reference-to-paragraph <PAR_ID> [<TYPE>]
\end_layout
\begin_layout Description
Params <PAR_IDs>:
paragraph ids,
might be a comma-separated list
\begin_inset Newline newline
\end_inset
if it is in a nested inset
\begin_inset Newline newline
\end_inset
<TYPE>:
cross-references type
\end_layout
\begin_layout Description
Origin spitz,
28 Jul 2024
\end_layout
\begin_layout Subsection* \begin_layout Subsection*
repeat repeat
\end_layout \end_layout
@ -4657,8 +4717,12 @@ Action Pastes the internal selection text in permanent selection.
\end_layout \end_layout
\begin_layout Description \begin_layout Description
Notion Created in order to have middle mouse button pasting correct (bound to command-alternatives selection-paste ; Notion Created in order to have middle mouse button pasting correct.
primary-selection-paste paragraph). The middle button is bound to "command-alternatives selection-paste ;
primary-selection-paste".
selection-paste makes sure that if something is highlighted in LyX window it gets into selection buffer and pasted.
If nothing is highlighted,
then primary-selection-paste covers the cases of pasting from selection buffer from another apps (or from LyX once the highlight is gone).
\end_layout \end_layout
\begin_layout Description \begin_layout Description

View File

@ -30993,11 +30993,30 @@ name "sec:Cross-References"
\begin_layout Standard \begin_layout Standard
One of \SpecialChar LyX One of \SpecialChar LyX
's strengths is cross-references. 's strengths is cross-references.
You can reference every section, You can reference every
\change_inserted -712698321 1723183496
thing in the document that has a counter
\change_unchanged
\change_inserted -712698321 1723183501
(e.
\begin_inset space \thinspace{}
\end_inset
g.,
\change_unchanged
section,
float, float,
footnote, footnote,
formula, formula,
and list in the document. and list
\change_inserted -712698321 1723183507
)
\change_deleted -712698321 1723183511
in the document
\change_unchanged
.
To reference a document part, To reference a document part,
you have to insert a label into it. you have to insert a label into it.
The label is used as an anchor and a name for the reference. The label is used as an anchor and a name for the reference.
@ -31133,16 +31152,79 @@ enu:Second-item
. .
At the position of the cross-reference box the item number will appear in the output. At the position of the cross-reference box the item number will appear in the output.
\change_inserted -712698321 1723183607
\end_layout \end_layout
\begin_layout Standard \begin_layout Standard
As an alternative to
\change_inserted -712698321 1723185545
For section headings,
footnotes,
table and figure floats,
this procedure can be simplified by using the outliner (see section
\begin_inset space ~
\end_inset
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:The-Outliner"
\end_inset
).
To insert a reference,
simply right-click on the item you want to refer to,
select
\family sans
Insert Cross-Reference to this Item
\family default
and the desired cross-reference format (see below for those) in the context menu.
\SpecialChar LyX
will check if the item already has a label and if not,
creates one before inserting the reference.
So all of the above boils down to two clicks!
\end_layout
\begin_layout Standard
\change_deleted -712698321 1723184542
A
\change_inserted -712698321 1723184543
Other
\change_deleted -712698321 1723184013
s an
\change_unchanged
alternative
\change_inserted -712698321 1723184545
s
\change_unchanged
to
\family sans \family sans
Insert\SpecialChar menuseparator Insert\SpecialChar menuseparator
Cross-Reference Cross-Reference
\change_inserted -712698321 1723184603
\family default \family default
which work for all item types (but require a label to exist already) are the following:
\change_deleted -712698321 1723184051
, ,
you can right-click on a label and in the popup menu select you can
\change_inserted -712698321 1723184553
\end_layout
\begin_layout Itemize
\change_deleted -712698321 1723184557
\change_inserted -712698321 1723184638
R
\change_deleted -712698321 1723184638
r
\change_unchanged
ight-click on a label and in the popup menu select
\family sans \family sans
Copy as Reference Copy as Reference
\family default \family default
@ -31159,10 +31241,45 @@ arg "paste"
\end_inset \end_inset
). ).
\change_inserted -712698321 1723184640
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1723184714
In the outliner,
section
\family sans
Labels and Cross-References
\family default
,
right-click on the label you want to refer to and select
\family sans
Insert Reference at Cursor Position
\family default
from the context menu.
\end_layout \end_layout
\begin_layout Standard \begin_layout Standard
Here is our cross-reference:
\change_inserted -712698321 1723184132
Whatever approach you take,
\change_deleted -712698321 1723184093
H
\change_inserted -712698321 1723184094
h
\change_unchanged
ere is
\change_inserted -712698321 1723184100
how
\change_unchanged
our cross-reference
\change_inserted -712698321 1723185807
ultimately comes out
\change_unchanged
:
Item Item
\begin_inset space ~ \begin_inset space ~
\end_inset \end_inset

View File

@ -9302,10 +9302,12 @@ Unformatiert
\end_layout \end_layout
\begin_layout Verbatim \begin_layout Verbatim
Dies ist Unformatiert. Dies ist Unformatiert.
\end_layout \end_layout
\begin_layout Verbatim \begin_layout Verbatim
Die folgenden 2 Zeilen sind leer: Die folgenden 2 Zeilen sind leer:
\end_layout \end_layout
@ -9318,6 +9320,7 @@ Die folgenden 2 Zeilen sind leer:
\end_layout \end_layout
\begin_layout Verbatim \begin_layout Verbatim
Fast alles ist in Unformatiert erlaubt:"%&$§#~'` Fast alles ist in Unformatiert erlaubt:"%&$§#~'`
\backslash \backslash
}][{| }][{|
@ -9343,6 +9346,7 @@ Unformatiert
\end_layout \end_layout
\begin_layout Verbatim* \begin_layout Verbatim*
Dies ist Unformatiert*. Dies ist Unformatiert*.
\end_layout \end_layout
@ -30219,10 +30223,12 @@ name "sec:Querverweise"
\begin_layout Standard \begin_layout Standard
Eine von \SpecialChar LyX Eine von \SpecialChar LyX
Stärken sind Querverweise. Stärken sind Querverweise.
Sie können auf jeden Abschnitt, Sie können auf jeden alles im Dokument verweisen,
jedes Gleitobjekt, was einen Zähler hat (Kapitel\SpecialChar breakableslash
jede Fußnote, Abschnitte,
Formel und Liste im Dokument referenzieren. Gleitobjekte,
Fußnote,
Formel und Listen).
Für eine Referenz müssen Sie zuerst eine Marke in den zu referenzieren Teil einfügen. Für eine Referenz müssen Sie zuerst eine Marke in den zu referenzieren Teil einfügen.
Die Marke dient als Anker und Name für die Referenz. Die Marke dient als Anker und Name für die Referenz.
Angenommen Sie wollen den zweiten Eintrag der folgenden Liste referenzieren: Angenommen Sie wollen den zweiten Eintrag der folgenden Liste referenzieren:
@ -30349,16 +30355,52 @@ Format
\end_layout \end_layout
\begin_layout Standard \begin_layout Standard
Alternativ zu Für Kapitel\SpecialChar breakableslash
Abschnitte,
Fußnoten,
Tabellen- und Abbildungsgleitobjekte geht das Ganze auch noch einfacher,
wenn Sie die Gliederungsansicht (siehe Abschnitt
\begin_inset space ~
\end_inset
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Gliederung"
\end_inset
) verwenden.
Um einen Querverweis einzufügen,
klicken Sie dort einfach mit der rechten Maustaste auf den Eintrag,
auf den Sie verweisen wollen,
wählen dann Querverweis auf diesen Eintrag einfügen und den gewünschten Querverweisstil (s.
dazu unten) aus dem Kontextmenü.
\SpecialChar LyX
prüft,
ob eine entsprechende Marke vorhanden ist,
falls nicht,
legt es diese an,
bevor es den Querverweis einfügt.
Das ganze Prozedere reduziert sich damit auf zwei Klicks!
\end_layout
\begin_layout Standard
Andere Alternativen zu
\family sans \family sans
Einfügen\SpecialChar menuseparator Einfügen\SpecialChar menuseparator
Querverweis Querverweis
\family default \family default
können Sie mit rechts auf die Marke klicken und im erscheinenden Kontextmenü ,
die für alle Eintragstypen funktionieren (so lange ein Label vorhanden ist) sind diese:
\end_layout
\begin_layout Itemize
Klicken Sie mit rechts auf die Marke und verwenden Sie dann im erscheinenden Kontextmenü
\family sans \family sans
Als Querverweis kopieren Als Querverweis kopieren
\family default \family default
verwenden. .
Der Querverweis zu dieser Marke ist nun in der Zwischenablage und kann an der aktuellen Cursorposition mit dem Menü Der Querverweis zu dieser Marke ist nun in der Zwischenablage und kann an der aktuellen Cursorposition mit dem Menü
\family sans \family sans
Bearbeiten\SpecialChar menuseparator Bearbeiten\SpecialChar menuseparator
@ -30371,8 +30413,24 @@ Ctrl+V
) eingefügt werden. ) eingefügt werden.
\end_layout \end_layout
\begin_layout Itemize
In der Gliederungsansicht,
Abschnitt
\family sans
Marken und Querverweise
\family default
,
klicken Sie mit rechts auf die Marke,
auf die Sie verweisen möchten und wählen dann im Kontextmenü
\family sans
Verweis an der Cursor-Position einfügen
\family default
.
\end_layout
\begin_layout Standard \begin_layout Standard
Hier ist unser Querverweis: Welche dieser Möglichkeiten Sie auch immer wählen,
so sieht unser Querverweis schließlich aus:
Eintrag Eintrag
\begin_inset space ~ \begin_inset space ~
\end_inset \end_inset
@ -30386,13 +30444,6 @@ nolink "false"
\end_inset \end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout \end_layout
\begin_layout Standard \begin_layout Standard

View File

@ -5,7 +5,7 @@
\save_transient_properties true \save_transient_properties true
\origin /systemlyxdir/examples/es/Handouts/ \origin /systemlyxdir/examples/es/Handouts/
\textclass tufte-handout \textclass tufte-handout
\use_default_options true \use_default_options false
\maintain_unincluded_children no \maintain_unincluded_children no
\language spanish \language spanish
\language_package default \language_package default
@ -30,6 +30,8 @@
\output_sync 0 \output_sync 0
\bibtex_command bibtex \bibtex_command bibtex
\index_command default \index_command default
\float_placement class
\float_alignment class
\paperfontsize default \paperfontsize default
\spacing single \spacing single
\use_hyperref false \use_hyperref false
@ -45,7 +47,7 @@
\use_package stackrel 1 \use_package stackrel 1
\use_package stmaryrd 1 \use_package stmaryrd 1
\use_package undertilde 1 \use_package undertilde 1
\cite_engine basic \cite_engine natbib
\cite_engine_type default \cite_engine_type default
\biblio_style plain \biblio_style plain
\use_bibtopic false \use_bibtopic false
@ -54,6 +56,7 @@
\suppress_date false \suppress_date false
\justification true \justification true
\use_refstyle 0 \use_refstyle 0
\use_formatted_ref 0
\use_minted 0 \use_minted 0
\use_lineno 0 \use_lineno 0
\index Índice \index Índice
@ -1735,7 +1738,7 @@ GitHub
\begin_layout Standard \begin_layout Standard
\begin_inset CommandInset bibtex \begin_inset CommandInset bibtex
LatexCommand bibtex LatexCommand bibtex
bibfiles "../../biblioExample" bibfiles "../../../../../lyx-devel/lib/examples/biblioExample"
options "plainnat" options "plainnat"
\end_inset \end_inset

View File

@ -584,6 +584,17 @@ Menuset
Menu "context-toc-figure" Menu "context-toc-figure"
Item "Settings...|S" "inset-settings" Item "Settings...|S" "inset-settings"
Separator
SubMenu "Insert Cross-Reference to this Item|C" "context-toc-ref-to-par"
End
#
# Toc Footnotes context menu
#
Menu "context-toc-footnote"
SubMenu "Insert Cross-Reference to this Item|C" "context-toc-ref-to-par"
End End
# #
@ -600,6 +611,8 @@ Menuset
Menu "context-toc-table" Menu "context-toc-table"
Item "Settings...|S" "inset-settings" Item "Settings...|S" "inset-settings"
Separator
SubMenu "Insert Cross-Reference to this Item|C" "context-toc-ref-to-par"
End End
# #
@ -707,6 +720,18 @@ Menuset
# Toc Table of Context context menu # Toc Table of Context context menu
# #
Menu "context-toc-ref-to-par"
Item "<Reference>|R" "reference-to-paragraph ref"
Item "(<Reference>)|e" "reference-to-paragraph eqref"
Item "<Page>|P" "reference-to-paragraph pageref"
Item "On Page <Page>|O" "reference-to-paragraph vpageref"
Item "<Reference> on Page <Page>|f" "reference-to-paragraph vref"
Item "Formatted Reference|t" "reference-to-paragraph formatted"
Item "Textual Reference|x" "reference-to-paragraph nameref"
Item "Label Only|L" "reference-to-paragraph labelonly"
End
Menu "context-toc-tableofcontents" Menu "context-toc-tableofcontents"
Item "Promote Section|P" "outline-out" Item "Promote Section|P" "outline-out"
Item "Demote Section|D" "outline-in" Item "Demote Section|D" "outline-in"
@ -714,6 +739,8 @@ Menuset
Item "Move Section Down|w" "outline-down" Item "Move Section Down|w" "outline-down"
Separator Separator
Item "Select Section|S" "section-select" Item "Select Section|S" "section-select"
Separator
SubMenu "Insert Cross-Reference to this Item|C" "context-toc-ref-to-par"
End End
# #

BIN
po/de.gmo

Binary file not shown.

441
po/de.po

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: LyX-2.4\n" "Project-Id-Version: LyX-2.4\n"
"Report-Msgid-Bugs-To: lyx-devel@lists.lyx.org\n" "Report-Msgid-Bugs-To: lyx-devel@lists.lyx.org\n"
"POT-Creation-Date: 2024-09-18 09:39+0200\n" "POT-Creation-Date: 2024-09-22 11:38+0200\n"
"PO-Revision-Date: 2024-09-21 19:58+0000\n" "PO-Revision-Date: 2024-09-22 11:32+0000\n"
"Last-Translator: Kornel Benko <kornel@lyx.org>\n" "Last-Translator: Kornel Benko <kornel@lyx.org>\n"
"Language-Team: Slovak <kornel@lyx.org>\n" "Language-Team: Slovak <kornel@lyx.org>\n"
"Language: sk\n" "Language: sk\n"
@ -313,7 +313,7 @@ msgstr "&Pridať lokálnu…"
#: src/frontends/qt/ui/BibtexUi.ui:91 #: src/frontends/qt/ui/BibtexUi.ui:91
msgid "Transfer an absolute local path to a relative one or vice versa" msgid "Transfer an absolute local path to a relative one or vice versa"
msgstr "" msgstr "Preniesť absolútnu lokálnu cestu na relatívnu alebo naopak"
#: src/frontends/qt/ui/BibtexUi.ui:91 #: src/frontends/qt/ui/BibtexUi.ui:91
msgid "Inherit bibliography databases from the master document" msgid "Inherit bibliography databases from the master document"
@ -20929,6 +20929,11 @@ msgstr "Pridať neznámu vetvu|P"
msgid "Insert Reference at Cursor Position|I" msgid "Insert Reference at Cursor Position|I"
msgstr "Vložiť referenciu na pozícii kurzoru|V" msgstr "Vložiť referenciu na pozícii kurzoru|V"
#: lib/ui/stdcontext.inc:588 lib/ui/stdcontext.inc:597
#: lib/ui/stdcontext.inc:615 lib/ui/stdcontext.inc:743
msgid "Insert Cross-Reference to this Item|C"
msgstr "Vložiť krížovú referenciu na túto položku|k"
#: lib/ui/stdcontext.inc:625 #: lib/ui/stdcontext.inc:625
msgid "Insert Copy at Cursor Position|I" msgid "Insert Copy at Cursor Position|I"
msgstr "Vložiť kópiu k pozícii kurzoru|V" msgstr "Vložiť kópiu k pozícii kurzoru|V"
@ -32322,11 +32327,11 @@ msgstr "Kódovanie dokumentu"
#: src/frontends/qt/GuiBibtex.cpp:365 src/frontends/qt/ui/BibtexUi.ui:94 #: src/frontends/qt/GuiBibtex.cpp:365 src/frontends/qt/ui/BibtexUi.ui:94
msgid "&Make Relative" msgid "&Make Relative"
msgstr "" msgstr "&Vytvoriť relatívne"
#: src/frontends/qt/GuiBibtex.cpp:369 #: src/frontends/qt/GuiBibtex.cpp:369
msgid "&Make Absolute" msgid "&Make Absolute"
msgstr "" msgstr "&Vytvoriť absolútne"
#: src/frontends/qt/GuiBibtex.cpp:312 #: src/frontends/qt/GuiBibtex.cpp:312
msgid "Database" msgid "Database"

View File

@ -1282,6 +1282,19 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|| getInsetByCode<InsetMathRef>(cur, MATH_REF_CODE)); || getInsetByCode<InsetMathRef>(cur, MATH_REF_CODE));
break; break;
case LFUN_REFERENCE_TO_PARAGRAPH: {
vector<string> const pids = getVectorFromString(cmd.getArg(0));
for (string const & s : pids) {
int const id = convert<int>(s);
if (id < 0) {
flag.setEnabled(false);
break;
}
}
flag.setEnabled(true);
break;
}
case LFUN_CHANGES_MERGE: case LFUN_CHANGES_MERGE:
case LFUN_CHANGE_NEXT: case LFUN_CHANGE_NEXT:
case LFUN_CHANGE_PREVIOUS: case LFUN_CHANGE_PREVIOUS:
@ -1641,6 +1654,58 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break; break;
} }
case LFUN_REFERENCE_TO_PARAGRAPH: {
vector<string> const pids = getVectorFromString(cmd.getArg(0));
string const type = cmd.getArg(1);
int id = convert<int>(pids.back());
if (id < 0)
break;
int i = 0;
for (Buffer * b = &buffer_; i == 0 || b != &buffer_;
b = theBufferList().next(b)) {
DocIterator dit = b->getParFromID(id);
if (dit.empty()) {
LYXERR(Debug::INFO, "No matching paragraph found! [" << id << "].");
++i;
continue;
}
string label = dit.innerParagraph().getLabelForXRef();
if (!label.empty()) {
// if the paragraph has a label, we refer to this
string const arg = (type.empty()) ? label : label + " " + type;
lyx::dispatch(FuncRequest(LFUN_REFERENCE_INSERT, arg));
break;
} else {
// if there is not a label yet
// go to the paragraph (including nested insets) ...
lyx::dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
for (string const & s : pids) {
id = convert<int>(s);
if (id < 0)
break;
dit = b->getParFromID(id);
lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, s));
}
// ... if not, insert a new label
// we do not want to open the dialog, hence we
// do not employ LFUN_LABEL_INSERT
InsetCommandParams p(LABEL_CODE);
docstring const new_label = dit.getPossibleLabel();
p["name"] = new_label;
string const data = InsetCommand::params2string(p);
lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data));
string const arg = (type.empty()) ? to_utf8(new_label)
: to_utf8(new_label) + " " + type;
// ... and go back to the original position
lyx::dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
// ... to insert the ref
lyx::dispatch(FuncRequest(LFUN_REFERENCE_INSERT, arg));
break;
}
}
break;
}
case LFUN_NOTE_NEXT: case LFUN_NOTE_NEXT:
if (gotoInset(this, { NOTE_CODE }, false)) if (gotoInset(this, { NOTE_CODE }, false))
dr.screenUpdate(Update::Force); dr.screenUpdate(Update::Force);

View File

@ -225,11 +225,12 @@ CursorSlice const & DocIterator::innerTextSlice() const
} }
docstring DocIterator::paragraphGotoArgument() const docstring DocIterator::paragraphGotoArgument(bool const nopos) const
{ {
CursorSlice const & s = innerTextSlice(); CursorSlice const & s = innerTextSlice();
return convert<docstring>(s.paragraph().id()) + ' ' + return nopos ? convert<docstring>(s.paragraph().id())
convert<docstring>(s.pos()); : convert<docstring>(s.paragraph().id())
+ ' ' + convert<docstring>(s.pos());
} }

View File

@ -167,8 +167,9 @@ public:
Paragraph & innerParagraph() const; Paragraph & innerParagraph() const;
/// return the inner text slice. /// return the inner text slice.
CursorSlice const & innerTextSlice() const; CursorSlice const & innerTextSlice() const;
// convert a DocIterator into an argument to LFUN_PARAGRAPH_GOTO /// convert a DocIterator into an argument to LFUN_PARAGRAPH_GOTO
docstring paragraphGotoArgument() const; /// \p nopos determines whether the cursor position is returned
docstring paragraphGotoArgument(bool const nopos = false) const;
/// returns a DocIterator for the containing text inset /// returns a DocIterator for the containing text inset
DocIterator getInnerText() const; DocIterator getInnerText() const;
/// the first and last positions of a word at top cursor slice /// the first and last positions of a word at top cursor slice

View File

@ -509,6 +509,9 @@ enum FuncCode
LFUN_TAB_GROUP_PREVIOUS, // daniel 20220130 LFUN_TAB_GROUP_PREVIOUS, // daniel 20220130
LFUN_BIBTEX_DATABASE_LIST, // bpiwowar, 20221218 LFUN_BIBTEX_DATABASE_LIST, // bpiwowar, 20221218
LFUN_STATISTICS_REFERENCE_CLAMP,// sanda, 20240324 LFUN_STATISTICS_REFERENCE_CLAMP,// sanda, 20240324
LFUN_REFERENCE_INSERT, // spitz, 20240728
// 400
LFUN_REFERENCE_TO_PARAGRAPH, // spitz, 20240728
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };

View File

@ -3512,6 +3512,16 @@ void LyXAction::init()
*/ */
{ LFUN_REDO, "redo", ReadOnly, Edit }, { LFUN_REDO, "redo", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_REFERENCE_INSERT
* \li Action: Inserts a cross-reference into the document.
* \li Notion: Optional <TYPE> can be used to set the type of reference
* \li Syntax: reference-insert <LABEL> [<TYPE>]
* \li Origin: spitz, 28 Jul 2024
* \endvar
*/
{ LFUN_REFERENCE_INSERT, "reference-insert", Noop, Edit },
/*! /*!
* \var lyx::FuncCode lyx::LFUN_REFERENCE_NEXT * \var lyx::FuncCode lyx::LFUN_REFERENCE_NEXT
* \li Action: Go to the next label or cross-reference. * \li Action: Go to the next label or cross-reference.
@ -3521,6 +3531,20 @@ void LyXAction::init()
*/ */
{ LFUN_REFERENCE_NEXT, "reference-next", ReadOnly, Edit }, { LFUN_REFERENCE_NEXT, "reference-next", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_REFERENCE_TO_PARAGRAPH
* \li Action: Inserts a cross-reference to the paragraph with a given ID
* \li Notion: The function checks of the paragraph already has a label.
* If so, it uses that. Otherwise it inserts a label and uses this.
* \li Syntax: reference-to-paragraph <PAR_ID> [<TYPE>]
* \li Params: <PAR_IDs>: paragraph ids, might be a comma-separated list\n
* if it is in a nested inset\n
* <TYPE>: cross-references type
* \li Origin: spitz, 28 Jul 2024
* \endvar
*/
{ LFUN_REFERENCE_TO_PARAGRAPH, "reference-to-paragraph", Noop, Edit },
/*! /*!
* \var lyx::FuncCode lyx::LFUN_REGEXP_MODE * \var lyx::FuncCode lyx::LFUN_REGEXP_MODE

View File

@ -3337,6 +3337,21 @@ string Paragraph::getID(Buffer const &, OutputParams const &)
} }
string Paragraph::getLabelForXRef() const
{
for (pos_type i = 0; i < size(); ++i) {
if (Inset const * inset = getInset(i)) {
InsetCode lyx_code = inset->lyxCode();
if (lyx_code == LABEL_CODE) {
InsetLabel const * const il = static_cast<InsetLabel const *>(inset);
return to_utf8(il->getParam("name"));
}
}
}
return string();
}
pos_type Paragraph::firstWordDocBook(XMLStream & xs, OutputParams const & runparams) const pos_type Paragraph::firstWordDocBook(XMLStream & xs, OutputParams const & runparams) const
{ {
pos_type i; pos_type i;

View File

@ -201,6 +201,10 @@ public:
/// Get the id of the paragraph, useful for DocBook /// Get the id of the paragraph, useful for DocBook
std::string getID(Buffer const & buf, OutputParams const & runparams) const; std::string getID(Buffer const & buf, OutputParams const & runparams) const;
/// Return the string of the (first) \label (cross-referencing target)
/// in this paragraph, or an empty string
std::string getLabelForXRef() const;
/// Output the first word of a paragraph, return the position where it left. /// Output the first word of a paragraph, return the position where it left.
pos_type firstWordDocBook(XMLStream & xs, OutputParams const & runparams) const; pos_type firstWordDocBook(XMLStream & xs, OutputParams const & runparams) const;

View File

@ -82,6 +82,7 @@
#include "insets/InsetIPAMacro.h" #include "insets/InsetIPAMacro.h"
#include "insets/InsetNewline.h" #include "insets/InsetNewline.h"
#include "insets/InsetQuotes.h" #include "insets/InsetQuotes.h"
#include "insets/InsetRef.h"
#include "insets/InsetSpecialChar.h" #include "insets/InsetSpecialChar.h"
#include "insets/InsetTabular.h" #include "insets/InsetTabular.h"
#include "insets/InsetText.h" #include "insets/InsetText.h"
@ -5480,6 +5481,18 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
break; break;
} }
case LFUN_REFERENCE_INSERT: {
string const label = cmd.getArg(0);
string const type = cmd.getArg(1);
InsetCommandParams p(REF_CODE, "ref");
if (!type.empty())
p.setCmdName(type);
p["reference"] = from_utf8(label);
string const data = InsetCommand::params2string(p);
lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data));
break;
}
case LFUN_INFO_INSERT: { case LFUN_INFO_INSERT: {
if (cmd.argument().empty()) { if (cmd.argument().empty()) {
bv->showDialog("info", cur.current_font.language()->lang()); bv->showDialog("info", cur.current_font.language()->lang());
@ -6739,6 +6752,13 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_PREVIEW_INSERT: case LFUN_PREVIEW_INSERT:
code = PREVIEW_CODE; code = PREVIEW_CODE;
break; break;
case LFUN_REFERENCE_INSERT: {
string const type = cmd.getArg(1);
if (!type.empty())
enable = InsetRef::isCompatibleCommand(type);
code = REF_CODE;
break;
}
case LFUN_SCRIPT_INSERT: case LFUN_SCRIPT_INSERT:
code = SCRIPT_CODE; code = SCRIPT_CODE;
break; break;

View File

@ -82,10 +82,15 @@ public:
bool isMissing() const { return missing_; } bool isMissing() const { return missing_; }
/// ///
void setAction(FuncRequest const & a) { action_ = a; } void setAction(FuncRequest const & a) { action_ = a; }
/// return comma-separated list of all par IDs (including nested insets)
/// this is used by captioned elements
docstring const parIDs() const { return par_ids_; }
///
void setParIDs(docstring const & ids) { par_ids_ = ids; }
/// custom action, or the default one (paragraph-goto) if not customised /// custom action, or the default one (paragraph-goto) if not customised
FuncRequest action() const; FuncRequest action() const;
/// /// return only main par ID
int id() const; int id() const;
/// String for display, e.g. it has a mark if output is inactive /// String for display, e.g. it has a mark if output is inactive
docstring const asString() const; docstring const asString() const;
@ -105,6 +110,8 @@ private:
bool missing_; bool missing_;
/// Custom action /// Custom action
FuncRequest action_; FuncRequest action_;
/// Paragraph IDs including nested insets (comma-separated).
docstring par_ids_;
}; };

View File

@ -46,10 +46,13 @@ void TocBuilder::captionItem(DocIterator const & dit, docstring const & s,
bool output_active) bool output_active)
{ {
// first show the float before moving to the caption // first show the float before moving to the caption
docstring parids = dit.paragraphGotoArgument(true);
docstring arg = "paragraph-goto " + dit.paragraphGotoArgument(); docstring arg = "paragraph-goto " + dit.paragraphGotoArgument();
if (!stack_.empty()) if (!stack_.empty()) {
arg = "paragraph-goto " + arg = "paragraph-goto " +
(*toc_)[stack_.top().pos].dit().paragraphGotoArgument() + ";" + arg; (*toc_)[stack_.top().pos].dit().paragraphGotoArgument() + ";" + arg;
parids = (*toc_)[stack_.top().pos].dit().paragraphGotoArgument(true) + "," + parids;
}
FuncRequest func(LFUN_COMMAND_SEQUENCE, arg); FuncRequest func(LFUN_COMMAND_SEQUENCE, arg);
if (!stack_.empty() && !stack_.top().is_captioned) { if (!stack_.empty() && !stack_.top().is_captioned) {
@ -58,6 +61,7 @@ void TocBuilder::captionItem(DocIterator const & dit, docstring const & s,
TocItem & captionable = (*toc_)[stack_.top().pos]; TocItem & captionable = (*toc_)[stack_.top().pos];
captionable.str(s); captionable.str(s);
captionable.setAction(func); captionable.setAction(func);
captionable.setParIDs(parids);
stack_.top().is_captioned = true; stack_.top().is_captioned = true;
} else { } else {
// This is a new entry. // This is a new entry.

View File

@ -27,6 +27,7 @@
#include "FuncStatus.h" #include "FuncStatus.h"
#include "LyX.h" #include "LyX.h"
#include "Menus.h" #include "Menus.h"
#include "Paragraph.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "insets/InsetCommand.h" #include "insets/InsetCommand.h"
@ -180,6 +181,7 @@ bool TocWidget::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_OUTLINE_DOWN: case LFUN_OUTLINE_DOWN:
case LFUN_OUTLINE_IN: case LFUN_OUTLINE_IN:
case LFUN_OUTLINE_OUT: case LFUN_OUTLINE_OUT:
case LFUN_REFERENCE_TO_PARAGRAPH:
case LFUN_SECTION_SELECT: case LFUN_SECTION_SELECT:
status.setEnabled((bool)item.dit()); status.setEnabled((bool)item.dit());
return true; return true;
@ -248,6 +250,18 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
break; break;
} }
case LFUN_REFERENCE_TO_PARAGRAPH: {
docstring const type = cmd.argument();
TocItem const & item =
gui_view_.tocModels().currentItem(current_type_, index);
docstring const id = (item.parIDs().empty())
? item.dit().paragraphGotoArgument(true)
: item.parIDs();
docstring const arg = (type.empty()) ? id : id + " " + type;
dispatch(FuncRequest(cmd, arg));
break;
}
case LFUN_OUTLINE_UP: case LFUN_OUTLINE_UP:
case LFUN_OUTLINE_DOWN: case LFUN_OUTLINE_DOWN:
case LFUN_OUTLINE_IN: case LFUN_OUTLINE_IN:

View File

@ -27,6 +27,9 @@ What's new
* USER INTERFACE * USER INTERFACE
- It is now possible to inserts cross references to sections via
the outliner, even of they do not have a label yet. In the latter
case, a label is autonatically inserted.
* DOCUMENTATION AND LOCALIZATION * DOCUMENTATION AND LOCALIZATION