mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
New LFUN tabular-feature: convert "inset-modify tabular" in LyX files
* Increase LyX format * New function convert_info_insets in lyx2lyx_tools.py Use this function in the future for future updates of info insets * Convert "inset-modify tabular" to "tabular-feature" in info insets * Remove icon naming hack regarding "inset-modify tabular"
This commit is contained in:
parent
647b4efb1e
commit
f58638c704
@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
||||
|
||||
-----------------------
|
||||
|
||||
2016-01-26 Guillaume Munch <gm@lyx.org>
|
||||
* Format incremented to 506
|
||||
No new parameters.
|
||||
Convert "inset-modify tabular" to "tabular-feature" in Info insets.
|
||||
|
||||
2016-01-26 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 505
|
||||
No new parameters.
|
||||
|
@ -86,7 +86,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
|
||||
("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
|
||||
("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
|
||||
("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
|
||||
("2_2", list(range(475,506)), minor_versions("2.2" , 0))
|
||||
("2_2", list(range(475,507)), minor_versions("2.2" , 0))
|
||||
]
|
||||
|
||||
####################################################################
|
||||
|
@ -69,6 +69,11 @@ latex_length(slen):
|
||||
(bool, length), where the bool tells us if it was a percentage, and
|
||||
the length is the LaTeX representation.
|
||||
|
||||
convert_info_insets(document, type, func):
|
||||
Applies func to the argument of all info insets matching certain types
|
||||
type : the type to match. This can be a regular expression.
|
||||
func : function from string to string to apply to the "arg" field of
|
||||
the info insets.
|
||||
'''
|
||||
|
||||
import re
|
||||
@ -503,3 +508,21 @@ def str2bool(s):
|
||||
"'true' goes to True, case-insensitively, and we strip whitespace."
|
||||
s = s.strip().lower()
|
||||
return s == "true"
|
||||
|
||||
|
||||
def convert_info_insets(document, type, func):
|
||||
"Convert info insets matching type using func."
|
||||
i = 0
|
||||
type_re = re.compile(r'^type\s+"(%s)"$' % type)
|
||||
arg_re = re.compile(r'^arg\s+"(.*)"$')
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Info", i)
|
||||
if i == -1:
|
||||
return
|
||||
t = type_re.match(document.body[i + 1])
|
||||
if t:
|
||||
arg = arg_re.match(document.body[i + 2])
|
||||
if arg:
|
||||
new_arg = func(arg.group(1))
|
||||
document.body[i + 2] = 'arg "%s"' % new_arg
|
||||
i += 3
|
||||
|
@ -31,7 +31,7 @@ import sys, os
|
||||
# del_token, check_token, get_option_value
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert, lyx2latex, \
|
||||
lyx2verbatim, length_in_bp
|
||||
lyx2verbatim, length_in_bp, convert_info_insets
|
||||
# insert_to_preamble, latex_length, revert_flex_inset, \
|
||||
# revert_font_attrs, hex2ratio, str2bool
|
||||
|
||||
@ -2305,6 +2305,18 @@ def convert_ACM_siggraph(document):
|
||||
document.body[1:1] = note
|
||||
|
||||
|
||||
def convert_info_tabular_feature(document):
|
||||
def f(arg):
|
||||
return arg.replace("inset-modify tabular", "tabular-feature")
|
||||
convert_info_insets(document, "shortcut(s)?|icon", f)
|
||||
|
||||
|
||||
def revert_info_tabular_feature(document):
|
||||
def f(arg):
|
||||
return arg.replace("tabular-feature", "inset-modify tabular")
|
||||
convert_info_insets(document, "shortcut(s)?|icon", f)
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -2344,10 +2356,12 @@ convert = [
|
||||
[502, []],
|
||||
[503, []],
|
||||
[504, [convert_save_props]],
|
||||
[505, [convert_ACM_siggraph]]
|
||||
[505, [convert_ACM_siggraph]],
|
||||
[506, [convert_info_tabular_feature]]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[505, [revert_info_tabular_feature]],
|
||||
[504, [revert_save_props]],
|
||||
[503, [revert_save_props]],
|
||||
[502, [revert_verbatim_star]],
|
||||
|
@ -486,23 +486,9 @@ QString iconName(FuncRequest const & f, bool unknown)
|
||||
docstring firstcom;
|
||||
docstring dummy = split(f.argument(), firstcom, ';');
|
||||
name1 = toqstr(firstcom);
|
||||
// FIXME: we should remove all references to "inset-modify tabular"
|
||||
// icons and shortcuts in all manuals
|
||||
name1.replace("inset-modify tabular", "tabular-feature");
|
||||
name1.replace(' ', '_');
|
||||
break;
|
||||
}
|
||||
case LFUN_INSET_MODIFY: {
|
||||
// FIXME: we should remove all references to "inset-modify tabular"
|
||||
// icons and shortcuts in all manuals
|
||||
string inset_name;
|
||||
string const command = split(to_utf8(f.argument()), inset_name, ' ');
|
||||
if (inset_name == "tabular") {
|
||||
name1 = "tabular-feature "+ toqstr(command);
|
||||
name1.replace(' ', '_');
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
name2 = toqstr(lyxaction.getActionName(f.action()));
|
||||
name1 = name2;
|
||||
|
@ -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 505 // uwestoehr: new format for ACM siggraaph
|
||||
#define LYX_FORMAT_TEX2LYX 505
|
||||
#define LYX_FORMAT_LYX 506 // guillaume munch: convert "inset-modify tabular"
|
||||
#define LYX_FORMAT_TEX2LYX 506
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user