]> git.lyx.org Git - features.git/commitdiff
Rename and restructure get_containing_inset.
authorRichard Heck <rgheck@comcast.net>
Fri, 5 Nov 2010 15:18:47 +0000 (15:18 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 5 Nov 2010 15:18:47 +0000 (15:18 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36117 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_2_0.py
lib/lyx2lyx/parser_tools.py

index 9ebc31e548eb0efa1c31c87f8e7c844405214103..ff3dc8edeac2aa661bad5eb7d56671b46ec28dd9 100644 (file)
@@ -25,7 +25,7 @@ import sys, os
 
 from parser_tools import find_token, find_end_of, find_tokens, \
   find_end_of_inset, find_end_of_layout, find_token_backwards, \
-  get_containing_inset, get_value, get_quoted_value
+  is_in_inset, get_value, get_quoted_value
   
 from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
   put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
@@ -1619,10 +1619,11 @@ def revert_nameref(document):
       i += 1
       # Make sure it is actually in an inset!
       # A normal line could begin with "LatexCommand nameref"!
-      stins, endins = get_containing_inset(document.body, cmdloc, \
+      val = is_in_inset(document.body, cmdloc, \
           "\\begin_inset CommandInset ref")
-      if stins == -1:
-        continue
+      if not val:
+          continue
+      stins, endins = val
 
       # ok, so it is in an InsetRef
       refline = find_token(document.body, "reference", stins, endins)
@@ -1655,9 +1656,9 @@ def remove_Nameref(document):
     i += 1
     
     # Make sure it is actually in an inset!
-    stins, endins = get_containing_inset(document.body, \
-        cmdloc, "\\begin_inset CommandInset ref")
-    if stins == -1:
+    val = is_in_inset(document.body, cmdloc, \
+        "\\begin_inset CommandInset ref")
+    if not val:
       continue
     document.body[cmdloc] = "LatexCommand nameref"
 
index 19e50542940da04b93687c8f14682e9ae1f595b8..e7cee56ba47e4c02cf5aa203c74bad19494cfcd2 100644 (file)
@@ -245,11 +245,11 @@ def find_end_of_layout(lines, i):
 
 # checks if line i is in the given inset
 # if so, returns starting and ending lines
-# otherwise, returns (-1, -1)
+# otherwise, returns False
 # Example:
-#  get_containing_inset(document.body, i, "\\begin_inset Tabular")
-# returns (-1, -1) unless i is within a table.
-def get_containing_inset(lines, i, inset):
+#  is_in_inset(document.body, i, "\\begin_inset Tabular")
+# returns False unless i is within a table.
+def is_in_inset(lines, i, inset):
     defval = (-1, -1)
     stins = find_token_backwards(lines, inset, i)
     if stins == -1: