mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Get rid of "CharStyle:", "Custom:", and "Element:" prefixes, per a
suggestion of JMarc's. Docs to follow. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35608 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
91411ca2e6
commit
d4634167cc
@ -2,10 +2,10 @@
|
|||||||
# Author : Martin vermeer <martin.vermeer@hut.fi>
|
# Author : Martin vermeer <martin.vermeer@hut.fi>
|
||||||
# Character Styles definition
|
# Character Styles definition
|
||||||
|
|
||||||
Format 28
|
Format 29
|
||||||
|
|
||||||
# Error fallback:
|
# Error fallback:
|
||||||
InsetLayout CharStyle
|
InsetLayout Flex
|
||||||
LyxType end
|
LyxType end
|
||||||
LabelString "UNDEFINED"
|
LabelString "UNDEFINED"
|
||||||
Font
|
Font
|
||||||
|
@ -2056,6 +2056,110 @@ def revert_mathrsfs(document):
|
|||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
|
def convert_flexnames(document):
|
||||||
|
"Convert \\begin_inset Flex Custom:Style to \\begin_inset Flex Style and similarly for CharStyle and Element."
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
rx = re.compile(r'^\\begin_inset Flex (?:Custom|CharStyle|Element):(.+)$')
|
||||||
|
while True:
|
||||||
|
i = find_token(document.body, "\\begin_inset Flex", i)
|
||||||
|
if i == -1:
|
||||||
|
return
|
||||||
|
m = rx.match(document.body[i])
|
||||||
|
if m:
|
||||||
|
document.body[i] = "\\begin_inset Flex " + m.group(1)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
|
flex_insets = [
|
||||||
|
["Alert", "CharStyle:Alert"],
|
||||||
|
["Code", "CharStyle:Code"],
|
||||||
|
["Concepts", "CharStyle:Concepts"],
|
||||||
|
["E-Mail", "CharStyle:E-Mail"],
|
||||||
|
["Emph", "CharStyle:Emph"],
|
||||||
|
["Expression", "CharStyle:Expression"],
|
||||||
|
["Initial", "CharStyle:Initial"],
|
||||||
|
["Institute", "CharStyle:Institute"],
|
||||||
|
["Meaning", "CharStyle:Meaning"],
|
||||||
|
["Noun", "CharStyle:Noun"],
|
||||||
|
["Strong", "CharStyle:Strong"],
|
||||||
|
["Structure", "CharStyle:Structure"],
|
||||||
|
["ArticleMode", "Custom:ArticleMode"],
|
||||||
|
["Endnote", "Custom:Endnote"],
|
||||||
|
["Glosse", "Custom:Glosse"],
|
||||||
|
["PresentationMode", "Custom:PresentationMode"],
|
||||||
|
["Tri-Glosse", "Custom:Tri-Glosse"]
|
||||||
|
]
|
||||||
|
|
||||||
|
flex_elements = [
|
||||||
|
["Abbrev", "Element:Abbrev"],
|
||||||
|
["CCC-Code", "Element:CCC-Code"],
|
||||||
|
["Citation-number", "Element:Citation-number"],
|
||||||
|
["City", "Element:City"],
|
||||||
|
["Code", "Element:Code"],
|
||||||
|
["CODEN", "Element:CODEN"],
|
||||||
|
["Country", "Element:Country"],
|
||||||
|
["Day", "Element:Day"],
|
||||||
|
["Directory", "Element:Directory"],
|
||||||
|
["Dscr", "Element:Dscr"],
|
||||||
|
["Email", "Element:Email"],
|
||||||
|
["Emph", "Element:Emph"],
|
||||||
|
["Filename", "Element:Filename"],
|
||||||
|
["Firstname", "Element:Firstname"],
|
||||||
|
["Fname", "Element:Fname"],
|
||||||
|
["GuiButton", "Element:GuiButton"],
|
||||||
|
["GuiMenu", "Element:GuiMenu"],
|
||||||
|
["GuiMenuItem", "Element:GuiMenuItem"],
|
||||||
|
["ISSN", "Element:ISSN"],
|
||||||
|
["Issue-day", "Element:Issue-day"],
|
||||||
|
["Issue-months", "Element:Issue-months"],
|
||||||
|
["Issue-number", "Element:Issue-number"],
|
||||||
|
["KeyCap", "Element:KeyCap"],
|
||||||
|
["KeyCombo", "Element:KeyCombo"],
|
||||||
|
["Keyword", "Element:Keyword"],
|
||||||
|
["Literal", "Element:Literal"],
|
||||||
|
["MenuChoice", "Element:MenuChoice"],
|
||||||
|
["Month", "Element:Month"],
|
||||||
|
["Orgdiv", "Element:Orgdiv"],
|
||||||
|
["Orgname", "Element:Orgname"],
|
||||||
|
["Postcode", "Element:Postcode"],
|
||||||
|
["SS-Code", "Element:SS-Code"],
|
||||||
|
["SS-Title", "Element:SS-Title"],
|
||||||
|
["State", "Element:State"],
|
||||||
|
["Street", "Element:Street"],
|
||||||
|
["Surname", "Element:Surname"],
|
||||||
|
["Volume", "Element:Volume"],
|
||||||
|
["Year", "Element:Year"]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def revert_flexnames(document):
|
||||||
|
if document.backend == "latex":
|
||||||
|
flexlist = flex_insets
|
||||||
|
else:
|
||||||
|
flexlist = flex_elements
|
||||||
|
|
||||||
|
rx = re.compile(r'^\\begin_inset Flex\s+(.+)$')
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
i = find_token(document.body, "\\begin_inset Flex", i)
|
||||||
|
if i == -1:
|
||||||
|
return
|
||||||
|
m = rx.match(document.body[i])
|
||||||
|
if not m:
|
||||||
|
document.warning("Illegal flex inset: " + document.body[i])
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
style = m.group(1)
|
||||||
|
for f in flexlist:
|
||||||
|
if f[0] == style:
|
||||||
|
document.body[i] = "\\begin_inset Flex " + f[1]
|
||||||
|
break
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
def convert_mathdots(document):
|
def convert_mathdots(document):
|
||||||
" Load mathdots automatically "
|
" Load mathdots automatically "
|
||||||
while True:
|
while True:
|
||||||
@ -2293,10 +2397,12 @@ convert = [[346, []],
|
|||||||
[399, [convert_mathdots]],
|
[399, [convert_mathdots]],
|
||||||
[400, [convert_rule]],
|
[400, [convert_rule]],
|
||||||
[401, []],
|
[401, []],
|
||||||
[402, [convert_bibtexClearpage]]
|
[402, [convert_bibtexClearpage]],
|
||||||
]
|
[403, [convert_flexnames]]
|
||||||
|
]
|
||||||
|
|
||||||
revert = [[401, []],
|
revert = [[402, [revert_flexnames]],
|
||||||
|
[401, []],
|
||||||
[400, [revert_diagram]],
|
[400, [revert_diagram]],
|
||||||
[399, [revert_rule]],
|
[399, [revert_rule]],
|
||||||
[398, [revert_mathdots]],
|
[398, [revert_mathdots]],
|
||||||
|
@ -100,6 +100,10 @@ import os, re, string, sys
|
|||||||
# Incremented to format 28, 6 August 2010 by lasgouttes
|
# Incremented to format 28, 6 August 2010 by lasgouttes
|
||||||
# Added ParbreakIsNewline tag for Layout and InsetLayout.
|
# Added ParbreakIsNewline tag for Layout and InsetLayout.
|
||||||
|
|
||||||
|
# Incremented to format 29, 10 August 2010 by rgh
|
||||||
|
# Changed Custom:Style, CharStyle:Style, and Element:Style
|
||||||
|
# uniformly to Flex:Style.
|
||||||
|
|
||||||
# Do not forget to document format change in Customization
|
# Do not forget to document format change in Customization
|
||||||
# Manual (section "Declaring a new text class").
|
# Manual (section "Declaring a new text class").
|
||||||
|
|
||||||
@ -107,7 +111,7 @@ import os, re, string, sys
|
|||||||
# development/tools/updatelayouts.sh script to update all
|
# development/tools/updatelayouts.sh script to update all
|
||||||
# layout files to the new format.
|
# layout files to the new format.
|
||||||
|
|
||||||
currentFormat = 28
|
currentFormat = 29
|
||||||
|
|
||||||
|
|
||||||
def usage(prog_name):
|
def usage(prog_name):
|
||||||
@ -191,6 +195,9 @@ def convert(lines):
|
|||||||
re_Type = re.compile(r'\s*Type\s+(\w+)', re.IGNORECASE)
|
re_Type = re.compile(r'\s*Type\s+(\w+)', re.IGNORECASE)
|
||||||
re_Builtin = re.compile(r'^(\s*)LaTeXBuiltin\s+(\w*)', re.IGNORECASE)
|
re_Builtin = re.compile(r'^(\s*)LaTeXBuiltin\s+(\w*)', re.IGNORECASE)
|
||||||
re_True = re.compile(r'^\s*(?:true|1)\s*$', re.IGNORECASE)
|
re_True = re.compile(r'^\s*(?:true|1)\s*$', re.IGNORECASE)
|
||||||
|
re_InsetLayout = re.compile(r'^\s*InsetLayout\s+(?:Custom|CharStyle|Element):(\S+)\s*$')
|
||||||
|
# with quotes
|
||||||
|
re_QInsetLayout = re.compile(r'^\s*InsetLayout\s+"(?:Custom|CharStyle|Element):([^"]+)"\s*$')
|
||||||
|
|
||||||
# counters for sectioning styles (hardcoded in 1.3)
|
# counters for sectioning styles (hardcoded in 1.3)
|
||||||
counters = {"part" : "\\Roman{part}",
|
counters = {"part" : "\\Roman{part}",
|
||||||
@ -279,6 +286,17 @@ def convert(lines):
|
|||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if format == 28:
|
||||||
|
match = re_InsetLayout.match(lines[i])
|
||||||
|
if match:
|
||||||
|
lines[i] = "InsetLayout Flex:" + match.group(1)
|
||||||
|
else:
|
||||||
|
match = re_QInsetLayout.match(lines[i])
|
||||||
|
if match:
|
||||||
|
lines[i] = "InsetLayout \"Flex:" + match.group(1) + "\""
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
# Only new features
|
# Only new features
|
||||||
if format >= 24 and format <= 27:
|
if format >= 24 and format <= 27:
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -84,7 +84,8 @@ def layouts_l10n(input_files, output, base):
|
|||||||
ListName = re.compile(r'\s*ListName\s+(.*)')
|
ListName = re.compile(r'\s*ListName\s+(.*)')
|
||||||
CategoryName = re.compile(r'\s*Category\s+(.*)')
|
CategoryName = re.compile(r'\s*Category\s+(.*)')
|
||||||
NameRE = re.compile(r'DeclareLyXModule.*{(.*)}')
|
NameRE = re.compile(r'DeclareLyXModule.*{(.*)}')
|
||||||
InsetLayout = re.compile(r'^InsetLayout\s+(.*)')
|
InsetLayout = re.compile(r'^InsetLayout\s+\"?(.*)\"?')
|
||||||
|
FlexCheck = re.compile(r'^Flex:(.*)')
|
||||||
DescBegin = re.compile(r'#+\s*DescriptionBegin\s*$')
|
DescBegin = re.compile(r'#+\s*DescriptionBegin\s*$')
|
||||||
DescEnd = re.compile(r'#+\s*DescriptionEnd\s*$')
|
DescEnd = re.compile(r'#+\s*DescriptionEnd\s*$')
|
||||||
Category = re.compile(r'#Category: (.*)$')
|
Category = re.compile(r'#Category: (.*)$')
|
||||||
@ -172,6 +173,9 @@ def layouts_l10n(input_files, output, base):
|
|||||||
string = res.group(1)
|
string = res.group(1)
|
||||||
string = string.replace('_', ' ')
|
string = string.replace('_', ' ')
|
||||||
writeString(out, src, base, lineno, string)
|
writeString(out, src, base, lineno, string)
|
||||||
|
m = FlexCheck.search(string)
|
||||||
|
if m:
|
||||||
|
writeString(out, src, base, lineno, m.group(1))
|
||||||
continue
|
continue
|
||||||
res = Category.search(line)
|
res = Category.search(line)
|
||||||
if res != None:
|
if res != None:
|
||||||
|
@ -127,7 +127,7 @@ namespace {
|
|||||||
|
|
||||||
// Do not remove the comment below, so we get merge conflict in
|
// Do not remove the comment below, so we get merge conflict in
|
||||||
// independent branches. Instead add your own.
|
// independent branches. Instead add your own.
|
||||||
int const LYX_FORMAT = 402; // uwestoehr: fix for bug 1881
|
int const LYX_FORMAT = 403; // rgh: Dummy format for InsetFlex name conversion
|
||||||
|
|
||||||
typedef map<string, bool> DepClean;
|
typedef map<string, bool> DepClean;
|
||||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||||
|
@ -60,7 +60,7 @@ namespace lyx {
|
|||||||
// development/updatelayouts.sh script, to update the format of
|
// development/updatelayouts.sh script, to update the format of
|
||||||
// all of our layout files.
|
// all of our layout files.
|
||||||
//
|
//
|
||||||
int const LAYOUT_FORMAT = 28;
|
int const LAYOUT_FORMAT = 29;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -1090,7 +1090,10 @@ void MenuDefinition::expandFlexInsert(
|
|||||||
TextClass::InsetLayouts::const_iterator end = insetLayouts.end();
|
TextClass::InsetLayouts::const_iterator end = insetLayouts.end();
|
||||||
for (; cit != end; ++cit) {
|
for (; cit != end; ++cit) {
|
||||||
if (cit->second.lyxtype() == type) {
|
if (cit->second.lyxtype() == type) {
|
||||||
docstring const label = cit->first;
|
docstring label = cit->first;
|
||||||
|
// we remove the "Flex:" prefix, if it is present
|
||||||
|
if (prefixIs(label, from_utf8("Flex:")))
|
||||||
|
label = label.substr(5);
|
||||||
addWithStatusCheck(MenuItem(MenuItem::Command,
|
addWithStatusCheck(MenuItem(MenuItem::Command,
|
||||||
toqstr(translateIfPossible(label)),
|
toqstr(translateIfPossible(label)),
|
||||||
FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(label))));
|
FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(label))));
|
||||||
|
@ -42,6 +42,12 @@ InsetFlex::InsetFlex(InsetFlex const & in)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
docstring InsetFlex::name() const
|
||||||
|
{
|
||||||
|
return from_utf8("Flex:" + name_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetLayout::InsetDecoration InsetFlex::decoration() const
|
InsetLayout::InsetDecoration InsetFlex::decoration() const
|
||||||
{
|
{
|
||||||
InsetLayout::InsetDecoration const dec = getLayout().decoration();
|
InsetLayout::InsetDecoration const dec = getLayout().decoration();
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
///
|
///
|
||||||
InsetFlex(Buffer *, std::string const & layoutName);
|
InsetFlex(Buffer *, std::string const & layoutName);
|
||||||
///
|
///
|
||||||
docstring name() const { return from_utf8(name_); }
|
docstring name() const;
|
||||||
///
|
///
|
||||||
InsetCode lyxCode() const { return FLEX_CODE; }
|
InsetCode lyxCode() const { return FLEX_CODE; }
|
||||||
/// Default looks
|
/// Default looks
|
||||||
|
Loading…
Reference in New Issue
Block a user