Support halfline and fullline also in vspace.

This commit is contained in:
Juergen Spitzmueller 2020-06-28 18:27:59 +02:00
parent 361d4d43e3
commit e121bd04bb
7 changed files with 128 additions and 30 deletions

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 595
\lyxformat 596
\begin_document
\begin_header
\save_transient_properties true
@ -46,6 +46,9 @@
% only uncomment this when you are using makindex
%\let\OrgIndex\index
%\renewcommand*{\index}[1]{\OrgIndex{#1}}
% Added by lyx2lyx
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\end_preamble
\options refpage,intoc,bibliography=totoc,index=totoc,BCOR7.5mm,captions=tableheading
\use_default_options false
@ -137,8 +140,8 @@ logicalmkup
\end_index
\secnumdepth 3
\tocdepth 2
\paragraph_separation skip
\defskip medskip
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
@ -12119,6 +12122,25 @@ DefSkip
MedSkip
\family default
.
\change_inserted -712698321 1593360527
\end_layout
\begin_layout Standard
\change_inserted -712698321 1593360570
\family sans
Half line height
\family default
and
\family sans
Line height
\family default
equal to the height, or half the height, of a line in the current font
size including line spacing.
\change_unchanged
\end_layout
\begin_layout Standard

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 595
\lyxformat 596
\begin_document
\begin_header
\save_transient_properties true
@ -53,6 +53,9 @@
% Trennausnahmen
\hyphenation{Text-ei-gen-schaf-ten}
% Added by lyx2lyx
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\end_preamble
\options refpage,intoc,bibliography=totoc,index=totoc,BCOR7.5mm,captions=tableheading
\use_default_options false
@ -142,8 +145,8 @@ logicalmkup
\end_index
\secnumdepth 3
\tocdepth 2
\paragraph_separation skip
\defskip medskip
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style german
@ -12157,21 +12160,21 @@ Abstand
\begin_layout Standard
\family sans
SmallSkip
Klein
\family default
,
\family sans
MedSkip
Mittel
\family default
und
\family sans
BigSkip
Groß
\family default
sind \SpecialChar LaTeX
entsprechen \SpecialChar LaTeX
-Größen, die von der Schriftgröße des Dokuments abhängen.
\family sans
DefSkip
Standard
\family default
ist der Abstand, der im Dialog
\family sans
@ -12192,15 +12195,29 @@ Dokument ! Einstellungen
für die Absatztrennung eingestellt ist.
Wenn Sie Absätze per Einrückung voneinander trennen, ist
\family sans
DefSkip
Standard
\family default
gleich
\family sans
MedSkip
Mittel
\family default
.
\end_layout
\begin_layout Standard
\family sans
Halbe Zeilenhöhe
\family default
und
\family sans
Zeilenhöhe
\family default
entsprechen der Höhe (bzw.
der halben Höhe) einer Zeile in der gewählten Schriftgröße inklusive des
Zeilenabstands.
\end_layout
\begin_layout Standard
Der
\family sans

View File

@ -3831,6 +3831,25 @@ def revert_parskip(document):
document.header[j] = "\\paragraph_indentation default"
def revert_line_vspaces(document):
" Revert fulline and halfline vspaces to TeX "
insets = {
"fullline*" : "\\vspace*{\\baselineskip}",
"fullline" : "\\vspace{\\baselineskip}",
"halfline*" : "\\vspace*{0.5\\baselineskip}",
"halfline" : "\\vspace{0.5\\baselineskip}",
}
for inset in insets.keys():
i = 0
j = 0
i = find_token(document.body, "\\begin_inset VSpace " + inset, i)
if i == -1:
continue
end = find_end_of_inset(document.body, i)
subst = put_cmd_in_ert(insets[inset])
document.body[i : end + 1] = subst
##
# Conversion hub
#
@ -3891,7 +3910,7 @@ convert = [
[596, [convert_parskip]]
]
revert = [[595, [revert_parskip]],
revert = [[595, [revert_parskip,revert_line_vspaces]],
[594, [revert_ams_spaces]],
[593, [revert_counter_inset]],
[592, [revert_counter_maintenance]],

View File

@ -292,6 +292,8 @@ Menuset
Item "SmallSkip|S" "inset-modify vspace smallskip"
Item "MedSkip|M" "inset-modify vspace medskip"
Item "BigSkip|B" "inset-modify vspace bigskip"
Item "Half line height|H" "inset-modify vspace halfline"
Item "Line height|L" "inset-modify vspace fullline"
Item "VFill|F" "inset-modify vspace vfill"
Item "Custom|C" "command-sequence inset-modify vspace custom; inset-settings"
Separator

View File

@ -66,7 +66,7 @@ GuiVSpace::GuiVSpace(QWidget * parent) : InsetParamsWidget(parent)
void GuiVSpace::enableCustom(int selection)
{
bool const enable = selection == 5;
bool const enable = selection == 7;
valueLE->setEnabled(enable);
if (enable)
valueLE->setFocus();
@ -96,15 +96,17 @@ static void setWidgetsFromVSpace(VSpace const & space,
case VSpace::BIGSKIP:
item = 3;
break;
case VSpace::VFILL:
case VSpace::HALFLINE:
item = 4;
break;
case VSpace::LENGTH:
case VSpace::FULLLINE:
item = 5;
break;
case VSpace::HALFLINE:
case VSpace::FULLLINE:
// not supported here yet
case VSpace::VFILL:
item = 6;
break;
case VSpace::LENGTH:
item = 7;
break;
}
spacing->setCurrentIndex(item);
@ -131,12 +133,30 @@ static VSpace setVSpaceFromWidgets(int spacing,
VSpace space;
switch (spacing) {
case 0: space = VSpace(VSpace::DEFSKIP); break;
case 1: space = VSpace(VSpace::SMALLSKIP); break;
case 2: space = VSpace(VSpace::MEDSKIP); break;
case 3: space = VSpace(VSpace::BIGSKIP); break;
case 4: space = VSpace(VSpace::VFILL); break;
case 5: space = VSpace(GlueLength(widgetsToLength(value, unit))); break;
case 0:
space = VSpace(VSpace::DEFSKIP);
break;
case 1:
space = VSpace(VSpace::SMALLSKIP);
break;
case 2:
space = VSpace(VSpace::MEDSKIP);
break;
case 3:
space = VSpace(VSpace::BIGSKIP);
break;
case 4:
space = VSpace(VSpace::HALFLINE);
break;
case 5:
space = VSpace(VSpace::FULLLINE);
break;
case 6:
space = VSpace(VSpace::VFILL);
break;
case 7:
space = VSpace(GlueLength(widgetsToLength(value, unit)));
break;
}
space.setKeep(keep);
@ -148,7 +168,7 @@ docstring GuiVSpace::dialogToParams() const
{
// If a vspace choice is "Length" but there's no text in
// the input field, do not insert a vspace at all.
if (spacingCO->currentIndex() == 5 && valueLE->text().isEmpty())
if (spacingCO->currentIndex() == 7 && valueLE->text().isEmpty())
return docstring();
VSpace const params = setVSpaceFromWidgets(spacingCO->currentIndex(),
@ -175,7 +195,7 @@ bool GuiVSpace::checkWidgets(bool readonly) const
spacingCO->setEnabled(false);
unitCO->setEnabled(false);
} else {
bool const enable = (spacingCO->currentIndex() == 5);
bool const enable = (spacingCO->currentIndex() == 7);
valueLE->setEnabled(enable);
valueL->setEnabled(enable);
unitCO->setEnabled(enable);

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VSpaceUi</class>
<widget class="QWidget" name="VSpaceUi">
@ -5,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>215</width>
<height>96</height>
<width>288</width>
<height>118</height>
</rect>
</property>
<property name="windowTitle">
@ -97,6 +98,16 @@
<string>BigSkip</string>
</property>
</item>
<item>
<property name="text">
<string>Half line height</string>
</property>
</item>
<item>
<property name="text">
<string>Line height</string>
</property>
</item>
<item>
<property name="text">
<string>VFill</string>

View File

@ -5709,12 +5709,19 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
} else if (unit == "\\bigskipamount") {
unit = "bigskip";
known_vspace = true;
} else if (length == "\\baselineskip") {
unit = "fullline";
known_vspace = true;
} else if (unit == "\\fill") {
unit = "vfill";
known_vspace = true;
}
}
}
if (value == 0.5 && t.cs()[0] != 'h' && unit == "\\baselineskip") {
unit = "halfline";
known_vspace = true;
}
if (!known_hspace && !known_vspace) {
switch (unitFromString(unit)) {
case Length::SP: