]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/prefs2prefs_lfuns.py
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / lib / scripts / prefs2prefs_lfuns.py
index 3061d3bc238ec91ad255184a204a10f090b125cf..1295a7dc308576d99249a38d9072181d6a8a23bc 100644 (file)
 
 import sys, re
 
-current_format = 1
-
 ###########################################################
 #
 # Actual converter functions
 #
 # These accept a line as argument and should return a list:
 #  (bool, newline)
-# where the bool indicates whether we changed anything. I
-# that case, one normally returns: (False, []).
+# where the bool indicates whether we changed anything. If not,
+# one normally returns: (False, []).
 
 no_match = (False, [])
 
@@ -49,7 +47,7 @@ def next_inset_toggle(line):
 
 
 def optional_insert(line):
-       return simple_renaming(line, "argument-insert", "optional-insert")
+       return simple_renaming(line, "optional-insert", "argument-insert")
 
 
 re_nm = re.compile(r'^(.*)notes-mutate\s+(\w+)\s+(\w+)(.*)$')
@@ -112,6 +110,42 @@ def toc_insert(line):
        return simple_renaming(line, "toc-insert", "inset-insert toc")
 
 
+re_ps = re.compile(r'^(.*)paragraph-spacing\s+(default|single|onehalf|double)\b(.*)$')
+re_psother = re.compile(r'^(.*)paragraph-spacing\s+other\s+(\d+\.\d?|\d?\.\d+|\d+)(.*)$')
+def paragraph_spacing(line):
+       # possible args: default, single, onehalf, double, other FLOAT
+       m = re_ps.search(line)
+       if m:
+               arg = m.group(2)
+               newline = m.group(1) + "paragraph-params \\paragraph-spacing " + arg + \
+                       m.group(3)
+               return (True, newline)
+
+       m = re_psother.search(line)
+       if not m:
+               return no_match
+
+       arg = m.group(2)
+       newline = m.group(1) + "paragraph-params \\paragraph-spacing other " + \
+               arg + m.group(3)
+       return (True, newline)
+
+
+def tabular_feature(line):
+       return simple_renaming(line, "tabular-feature", "inset-modify tabular")
+
+re_Bar2bar = re.compile(r'^(\\(?:bind|unbind))\s+"([^"]*)Bar"(\s+"[^"]+")')
+def Bar2bar(line):
+       m = re_Bar2bar.search(line)
+       if not m:
+               return no_match
+
+       btype = m.group(1)
+       mod = m.group(2)
+       rest = m.group(3)
+       newline = btype + " \"" + mod + "bar\"" + rest
+       return (True, newline)
+
 #
 #
 ###########################################################
@@ -120,14 +154,17 @@ def toc_insert(line):
 # Conversion chain
 
 conversions = [
-       [ # this will be a long list of conversions for format 0
+       [  1, [ # this will be a long list of conversions to format 1
                next_inset_toggle,
                next_inset_modify,
                optional_insert,
                notes_mutate,
                all_insets_toggle,
                line_insert,
-               toc_insert
-       ] # end conversions for format 0
+               toc_insert,
+               paragraph_spacing,
+               tabular_feature,
+               Bar2bar
+       ]],
 ]