mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Add support for medspace and thickspace (in text) (#11893)
File format change.
This commit is contained in:
parent
8ceb4f6b58
commit
a68b0389bc
@ -353,7 +353,7 @@ def revert_undertilde(document):
|
||||
|
||||
|
||||
def revert_negative_space(document):
|
||||
"Revert InsetSpace negmedspace and negthickspace into its TeX-code counterpart"
|
||||
"Revert InsetSpace negmedspace and negthickspace into their TeX-code counterparts"
|
||||
i = 0
|
||||
j = 0
|
||||
reverted = False
|
||||
@ -366,7 +366,7 @@ def revert_negative_space(document):
|
||||
if reverted == True:
|
||||
i = find_token(document.header, "\\use_amsmath 2", 0)
|
||||
if i == -1:
|
||||
add_to_preamble(document, ["\\@ifundefined{negthickspace}{\\usepackage{amsmath}}"])
|
||||
add_to_preamble(document, ["\\@ifundefined{negthickspace}{\\usepackage{amsmath}}{}"])
|
||||
return
|
||||
if i == -1:
|
||||
return
|
||||
|
@ -3754,6 +3754,28 @@ def revert_counter_inset(document):
|
||||
add_to_preamble(document, pretext)
|
||||
|
||||
|
||||
def revert_ams_spaces(document):
|
||||
"Revert InsetSpace medspace and thickspace into their TeX-code counterparts"
|
||||
Found = False
|
||||
insets = ["\\medspace{}", "\\thickspace{}"]
|
||||
for inset in insets:
|
||||
i = 0
|
||||
j = 0
|
||||
i = find_token(document.body, "\\begin_inset space " + inset, i)
|
||||
if i == -1:
|
||||
continue
|
||||
end = find_end_of_inset(document.body, i)
|
||||
subst = put_cmd_in_ert(inset)
|
||||
document.body[i : end + 1] = subst
|
||||
Found = True
|
||||
|
||||
if Found == True:
|
||||
# load amsmath in the preamble if not already loaded
|
||||
i = find_token(document.header, "\\use_package amsmath 2", 0)
|
||||
if i == -1:
|
||||
add_to_preamble(document, ["\\@ifundefined{thickspace}{\\usepackage{amsmath}}{}"])
|
||||
return
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -3809,10 +3831,12 @@ convert = [
|
||||
[591, [convert_postpone_fragile]],
|
||||
[592, []],
|
||||
[593, [convert_counter_maintenance]],
|
||||
[594, []]
|
||||
[594, []],
|
||||
[595, []]
|
||||
]
|
||||
|
||||
revert = [[593, [revert_counter_inset]],
|
||||
revert = [[594, [revert_ams_spaces]],
|
||||
[593, [revert_counter_inset]],
|
||||
[592, [revert_counter_maintenance]],
|
||||
[591, [revert_colrow_tracking]],
|
||||
[590, [revert_postpone_fragile]],
|
||||
|
@ -244,6 +244,8 @@ Menuset
|
||||
Item "Protected Space|o" "inset-modify space ~"
|
||||
Item "Visible Space|a" "inset-modify space \textvisiblespace{}"
|
||||
Item "Thin Space|T" "inset-modify space \thinspace{}"
|
||||
Item "Medium Space|M" "inset-modify space \medspace{}"
|
||||
Item "Thick Space|i" "inset-modify space \thickspace{}"
|
||||
Item "Negative Thin Space|N" "inset-modify space \negthinspace{}"
|
||||
Item "Negative Medium Space|v" "inset-modify space \negmedspace{}"
|
||||
Item "Negative Thick Space|h" "inset-modify space \negthickspace{}"
|
||||
@ -252,7 +254,7 @@ Menuset
|
||||
Item "Quad Space|Q" "inset-modify space \quad{}"
|
||||
Item "Double Quad Space|u" "inset-modify space \qquad{}"
|
||||
Item "Horizontal Fill|F" "inset-modify space \hfill{}"
|
||||
Item "Protected Horizontal Fill|i" "inset-modify space \hspace*{\fill}"
|
||||
Item "Protected Horizontal Fill|z" "inset-modify space \hspace*{\fill}"
|
||||
Item "Horizontal Fill (Dots)|D" "inset-modify space \dotfill{}"
|
||||
Item "Horizontal Fill (Rule)|R" "inset-modify space \hrulefill{}"
|
||||
Item "Horizontal Fill (Left Arrow)|L" "inset-modify space \leftarrowfill{}"
|
||||
|
@ -41,32 +41,20 @@ GuiHSpace::GuiHSpace(bool math_mode, QWidget * parent)
|
||||
setupUi(this);
|
||||
|
||||
spacingCO->clear();
|
||||
if (math_mode_) {
|
||||
spacingCO->addItem(qt_("Interword Space"), "normal");
|
||||
spacingCO->addItem(qt_("Thin Space"), "thinspace");
|
||||
spacingCO->addItem(qt_("Medium Space"), "medspace");
|
||||
spacingCO->addItem(qt_("Thick Space"), "thickspace");
|
||||
spacingCO->addItem(qt_("Negative Thin Space"), "negthinspace");
|
||||
spacingCO->addItem(qt_("Negative Medium Space"), "negmedspace");
|
||||
spacingCO->addItem(qt_("Negative Thick Space"), "negthickspace");
|
||||
spacingCO->addItem(qt_("Half Quad (0.5 em)"), "halfquad");
|
||||
spacingCO->addItem(qt_("Quad (1 em)"), "quad");
|
||||
spacingCO->addItem(qt_("Double Quad (2 em)"), "qquad");
|
||||
spacingCO->addItem(qt_("Horizontal Fill"), "hfill");
|
||||
spacingCO->addItem(qt_("Custom"), "custom");
|
||||
} else {
|
||||
spacingCO->addItem(qt_("Interword Space"), "normal");
|
||||
spacingCO->addItem(qt_("Thin Space"), "thinspace");
|
||||
spacingCO->addItem(qt_("Negative Thin Space"), "negthinspace");
|
||||
spacingCO->addItem(qt_("Negative Medium Space"), "negmedspace");
|
||||
spacingCO->addItem(qt_("Negative Thick Space"), "negthickspace");
|
||||
spacingCO->addItem(qt_("Half Quad (0.5 em)"), "halfquad");
|
||||
spacingCO->addItem(qt_("Quad (1 em)"), "quad");
|
||||
spacingCO->addItem(qt_("Double Quad (2 em)"), "qquad");
|
||||
spacingCO->addItem(qt_("Horizontal Fill"), "hfill");
|
||||
spacingCO->addItem(qt_("Custom"), "custom");
|
||||
spacingCO->addItem(qt_("Interword Space"), "normal");
|
||||
spacingCO->addItem(qt_("Thin Space"), "thinspace");
|
||||
spacingCO->addItem(qt_("Medium Space"), "medspace");
|
||||
spacingCO->addItem(qt_("Thick Space"), "thickspace");
|
||||
spacingCO->addItem(qt_("Negative Thin Space"), "negthinspace");
|
||||
spacingCO->addItem(qt_("Negative Medium Space"), "negmedspace");
|
||||
spacingCO->addItem(qt_("Negative Thick Space"), "negthickspace");
|
||||
spacingCO->addItem(qt_("Half Quad (0.5 em)"), "halfquad");
|
||||
spacingCO->addItem(qt_("Quad (1 em)"), "quad");
|
||||
spacingCO->addItem(qt_("Double Quad (2 em)"), "qquad");
|
||||
spacingCO->addItem(qt_("Horizontal Fill"), "hfill");
|
||||
if (!math_mode_)
|
||||
spacingCO->addItem(qt_("Visible Space"), "visible");
|
||||
}
|
||||
spacingCO->addItem(qt_("Custom"), "custom");
|
||||
|
||||
connect(spacingCO, SIGNAL(highlighted(QString)),
|
||||
this, SLOT(changedSlot()));
|
||||
|
@ -516,9 +516,9 @@ void InsetSpaceParams::read(Lexer & lex)
|
||||
kind = InsetSpaceParams::VISIBLE;
|
||||
else if (command == "\\thinspace{}")
|
||||
kind = InsetSpaceParams::THIN;
|
||||
else if (math && command == "\\medspace{}")
|
||||
else if (command == "\\medspace{}")
|
||||
kind = InsetSpaceParams::MEDIUM;
|
||||
else if (math && command == "\\thickspace{}")
|
||||
else if (command == "\\thickspace{}")
|
||||
kind = InsetSpaceParams::THICK;
|
||||
else if (command == "\\quad{}")
|
||||
kind = InsetSpaceParams::QUAD;
|
||||
@ -597,10 +597,16 @@ void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
|
||||
os << (runparams.free_spacing ? " " : "\\,");
|
||||
break;
|
||||
case InsetSpaceParams::MEDIUM:
|
||||
os << (runparams.free_spacing ? " " : "\\:");
|
||||
if (params_.math)
|
||||
os << (runparams.free_spacing ? " " : "\\:");
|
||||
else
|
||||
os << (runparams.free_spacing ? " " : "\\medspace{}");
|
||||
break;
|
||||
case InsetSpaceParams::THICK:
|
||||
os << (runparams.free_spacing ? " " : "\\;");
|
||||
if (params_.math)
|
||||
os << (runparams.free_spacing ? " " : "\\;");
|
||||
else
|
||||
os << (runparams.free_spacing ? " " : "\\thickspace{}");
|
||||
break;
|
||||
case InsetSpaceParams::QUAD:
|
||||
os << (runparams.free_spacing ? " " : "\\quad{}");
|
||||
@ -867,8 +873,11 @@ docstring InsetSpace::xhtml(XMLStream & xs, OutputParams const &) const
|
||||
|
||||
void InsetSpace::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
|
||||
params_.kind == InsetSpaceParams::NEGTHICK)
|
||||
if ((params_.kind == InsetSpaceParams::NEGMEDIUM
|
||||
|| params_.kind == InsetSpaceParams::NEGTHICK)
|
||||
|| (!params_.math
|
||||
&& (params_.kind == InsetSpaceParams::MEDIUM
|
||||
|| params_.kind == InsetSpaceParams::THICK)))
|
||||
features.require("amsmath");
|
||||
}
|
||||
|
||||
|
@ -318,16 +318,16 @@ char const * const known_tex_extensions[] = {"tex", 0};
|
||||
/// spaces known by InsetSpace
|
||||
char const * const known_spaces[] = { " ", "space", ",",
|
||||
"thinspace", "quad", "qquad", "enspace", "enskip",
|
||||
"negthinspace", "negmedspace", "negthickspace", "textvisiblespace",
|
||||
"hfill", "dotfill", "hrulefill", "leftarrowfill", "rightarrowfill",
|
||||
"upbracefill", "downbracefill", 0};
|
||||
"medspace", "thickspace", "negthinspace", "negmedspace", "negthickspace",
|
||||
"textvisiblespace", "hfill", "dotfill", "hrulefill", "leftarrowfill",
|
||||
"rightarrowfill", "upbracefill", "downbracefill", 0};
|
||||
|
||||
/// the same as known_spaces with .lyx names
|
||||
char const * const known_coded_spaces[] = { "space{}", "space{}",
|
||||
"thinspace{}", "thinspace{}", "quad{}", "qquad{}", "enspace{}", "enskip{}",
|
||||
"negthinspace{}", "negmedspace{}", "negthickspace{}", "textvisiblespace{}",
|
||||
"hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}", "rightarrowfill{}",
|
||||
"upbracefill{}", "downbracefill{}", 0};
|
||||
"medspace{}", "thickspace{}", "negthinspace{}", "negmedspace{}", "negthickspace{}",
|
||||
"textvisiblespace{}", "hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}",
|
||||
"rightarrowfill{}", "upbracefill{}", "downbracefill{}", 0};
|
||||
|
||||
/// known TIPA combining diacritical marks
|
||||
char const * const known_tipa_marks[] = {"textsubwedge", "textsubumlaut",
|
||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 594 // rikiheck: counter insets
|
||||
#define LYX_FORMAT_TEX2LYX 594
|
||||
#define LYX_FORMAT_LYX 595 // spitz: medspace and thickspace
|
||||
#define LYX_FORMAT_TEX2LYX 595
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user