Did you test your function? It segfaults my program when I use it like
that, that is, without doing anything except of calliing cur.isRTL():
Index: src/mathed/InsetMathNest.cpp
===================================================================
--- src/mathed/InsetMathNest.cpp        (revision 18081)
+++ src/mathed/InsetMathNest.cpp        (working copy)
@@ -494,6 +494,10 @@
               cur.autocorrect() = false;
               cur.clearTargetX();
               cur.macroModeClose();
+               if (cur.isRTL() )
+                       puts("RTL");//goto goto_char_backwards;
+
+               goto_char_forwards:
               if (cur.pos() != cur.lastpos() &&
cur.openable(cur.nextAtom())) {
                       cur.pushLeft(*cur.nextAtom().nucleus());
                       cur.inset().idxFirst(cur);
@@ -513,6 +517,10 @@
               cur.autocorrect() = false;
               cur.clearTargetX();
               cur.macroModeClose();
+               if (cur.isRTL())
+                       puts("RTL");//goto goto_char_forwards;
+
+               goto_char_backwards:
               if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
                       cur.posLeft();
                       cur.push(*cur.nextAtom().nucleus());


On 4/29/07, Abdelrazak Younes <[EMAIL PROTECTED]> wrote:
Elazar Leibovich wrote:
> When trying to determine the directionality of a mathed inset the
> cursor is currently located in, I'm having the following troubles.
> I cannot get the paragraph directly from the cursor (I don't know why,
> but someone explicitly disallowed that, having a
> "BOOST_ASSERT(inTexted());" when calling cur.paragraph).

Maybe we should remove this assertion in the const access method...
But anyway, I've just committed a new method that will give you this
information: bool Cursor::isRTL().

This methods only give the RTL state of the current paragraph so it will
not work for mixed language paragraph.

Please send a patch when you are done.

Abdel.


Author: younes
Date: Sun Apr 29 10:29:16 2007
New Revision: 18080

URL: http://www.lyx.org/trac/changeset/18080
Log:
* Cursor::isRTL(): new method that gives the RTL state of the paragraph.

Modified:
     lyx-devel/trunk/src/Cursor.cpp
     lyx-devel/trunk/src/Cursor.h

Modified: lyx-devel/trunk/src/Cursor.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Cursor.cpp?rev=18080
==============================================================================
--- lyx-devel/trunk/src/Cursor.cpp (original)
+++ lyx-devel/trunk/src/Cursor.cpp Sun Apr 29 10:29:16 2007
@@ -1327,4 +1327,10 @@
  }


+bool Cursor::isRTL() const
+{
+       return top().paragraph().isRightToLeftPar(bv().buffer()->params());
+}
+
+
  } // namespace lyx

Modified: lyx-devel/trunk/src/Cursor.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Cursor.h?rev=18080
==============================================================================
--- lyx-devel/trunk/src/Cursor.h (original)
+++ lyx-devel/trunk/src/Cursor.h Sun Apr 29 10:29:16 2007
@@ -307,6 +307,8 @@
        Encoding const * getEncoding() const;
        /// font at cursor position
        LyXFont getFont() const;
+       ///
+       bool isRTL() const;
  };




Reply via email to