]> git.lyx.org Git - features.git/commitdiff
Dekels arabic patch, + some small things by me
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 10 Mar 2000 13:22:20 +0000 (13:22 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 10 Mar 2000 13:22:20 +0000 (13:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@599 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
ChangeLog
acinclude.m4
lib/layouts/amsdefs.inc
lib/layouts/heb-article.layout
lib/lyxrc.example
src/BufferView2.C
src/Makefile.am
src/buffer.C
src/bufferparams.C
src/insets/inseturl.C
src/intl.C
src/layout.C
src/layout.h
src/lyx_gui.C
src/lyxparagraph.h
src/lyxrc.C
src/lyxrc.h
src/lyxscreen.h
src/lyxtext.h
src/paragraph.C
src/screen.C
src/tex-strings.C
src/tex-strings.h
src/text.C
src/text2.C

index a2df1a434a1ab2ce129674d11379567a918260ba..5cf0b63d46c6d47ba9384d0d430971ef81ecc66d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,60 @@
+2000-03-10  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/bufferparams.C (readLanguage): use the new language map
+
+       * src/intl.C (InitKeyMapper): use the new language map
+
+       * src/lyx_gui.C (create_forms): use the new language map
+
+       * src/language.[Ch]: New files. Used for holding the information
+       about each language. Now! Use this new language map enhance it and
+       make it really usable for our needs. 
+
+2000-03-09 Dekel Tsur <dekel@math.tau.ac.il>
+       
+       * screen.C (ShowCursor): Removed duplicate code.
+       (ShowManualCursor): Support for 3 cursor shapes: Bar (default),
+       L (LTR text in RTL document), and reversed-L (RTL text in LTR document)
+       
+       * src/text.C (NextBreakPoint,Fill): Moved declaration of left_margin
+
+       * src/lyxtext.h
+       * src/text.C  Added TransformChar method. Used for rendering Arabic
+       text correctly (change the glyphs of the letter according to the
+       position in the word)
+
+       * src/buffer.C
+       * src/paragraph.C
+       * src/lyxrc.h
+       * src/lyxrc.C  Added lyxrc command {language_command_begin,
+       language_command_end,language_command_ltr,language_command_rtl,
+       language_package} which allows the use of either arabtex or Omega
+       for Arabic
+
+       * src/lyx_gui.C (init)
+       * src/lyxrc.h
+       * src/lyxrc.C Added lyxrc command screen_font_encoding_menu. Allows
+       to use encoding for menu fonts which is different than the encoding
+       for screen fonts
+
+       * src/buffer.C (makeLaTeXFile): If params.language = "default",
+       do not load the babel package.
+       To write an English document with Hebrew/Arabic, change the document
+       language to "english".
+
+       * src/text2.C (SetCounter): Fixed appendix labels for Hebrew document
+       (alphaCounter): changed to return char
+       (loweralphaCounter, hebrewCounter, romanCounter): New functions
+
+       * lib/lyxrc.example  Added examples for Hebrew/Arabic
+
+       * src/layout.h
+       * src/layout.C  Added layout command endlabeltype
+
+       * src/paragraph.C Added GetEndLabel(),LastPhysicalPar() const
+
+       * src/text.C (GetVisibleRow): Draw a box at the end of proof layout
+
 2000-03-10  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/mathed/math_delim.C (search_deco): return a
index d245e526cfe8b44eecd5111b70b83bbda92b82c1..7c317dbd2385bbcd33c7564b024d0040cd1e9f8e 100644 (file)
@@ -184,7 +184,7 @@ dnl Check the version of g++
   elif test $ac_cv_prog_cxx_g = yes; then
     case $gxx_version in
       2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
-      2.95.*)  CXXFLAGS="-g $lyx_opt";;
+      2.95.*)  CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
       2.96*)   CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
       *2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
       *)       CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
index 4a3ec9fa2c1fae9d52e6040b2fcdde15068c1ea0..9016a21138d3b1980b1be782eca50bec43a89590 100644 (file)
@@ -40,6 +40,7 @@ Style Proof
   AlignPossible                Block, Left
   LabelType            Static
   LabelString          "Proof."
+  EndLabelType         Box
   
   # standard font definition
   Font
index cf167affcd791baaa5cd9e990368584b033356a5..15f378f10d2c77146b90417336d5530ee1cf667b 100644 (file)
@@ -30,6 +30,7 @@ Style Proof
   AlignPossible         Block, Left
   LabelType             Static
   LabelString           ":äçëåä"
+  EndLabelType         Filled_Box
   # standard font definition
   Font
     Shape               Up
index 15f4016fa176bbf783dbf1dcade728fb7b7996e7..6e7c7d714d9cd9c278bd01a97f965656e798582d 100644 (file)
 # details of the format.
 #
 #\date_insert_format "%A, %e. %B %Y"
+
+#
+# HEBREW SUPPORT SECTION ####################################################
+#
+
+# To enable the Hebrew support, uncommnet the following lines:
+#\rtl true
+#\kbmap true
+#\kbmap_primary null
+#\kbmap_secondary hebrew
+#\latex_command elatex
+#\font_encoding default
+
+# You also need to bind a key for switching between Hebrew and English.
+# For example,
+#\bind "F12" "font-rtl"
+
+# Finally, you need to select iso8859-8 font encoding, and select screen fonts
+# (below are the default fonts. You need to replace them by Hebrew fonts)
+#\screen_font_encoding iso8859-8
+#\screen_font_roman "-*-times"
+#\screen_font_sans "-*-helvetica"
+#\screen_font_typewriter "-*-courier"
+#\screen_font_popup "-*-helvetica-medium-r"
+#\screen_font_menu "-*-helvetica-bold-r"
+
+#
+# ARABIC SUPPORT SECTION ####################################################
+#
+
+# To enable the Arabic support, uncommnet the following lines:
+#\rtl true
+#\kbmap true
+#\kbmap_primary null
+#\kbmap_secondary arabic
+
+# You also need to bind a key for switching between Arabic and English.
+# For example,
+#\bind "F12" "font-rtl"
+
+# If you use arabtex, uncomment the following lines
+#\language_command_begin true
+#\language_command_end true
+#\language_command_rtl "\begin{arabtext}"
+#\language_command_ltr "\end{arabtext}"
+#\language_package "\usepackage{arabtex,iso88596}\setcode{iso8859-6}"
+
+
+# Finally, you need to select iso8859-6.8x font encoding,
+# and select screen fonts.
+# iso8859-6.8x fonts can be found at
+#   http://www.langbox.com/AraMosaic/mozilla/fontXFE/
+#\screen_font_encoding iso8859-6.8x
+#\screen_font_encoding_menu iso8859-1
+#\screen_font_roman "-*-naskhi"
index 817da110667dadce1890e007ec25beaf5d943b1f..f615a2ae1038d93be6992e7287e9bae0a29e1140 100644 (file)
@@ -719,8 +719,8 @@ void BufferView::showLockedInsetCursor(long x, long y, int asc, int desc)
 {
        if (the_locking_inset && available()) {
                y += text->cursor.y;
-               screen->ShowManualCursor(x, y,
-                                             asc, desc);
+               screen->ShowManualCursor(x, y, asc, desc,
+                                        LyXScreen::BAR_SHAPE);
        }
 }
 
index 6a9afa79c65cec6a59418f1d365add15124925c8..8d46c26fd7f829bc90687e34a030484702e5f336 100644 (file)
@@ -98,6 +98,8 @@ lyx_SOURCES = \
        kbmap.h \
        kbsequence.C \
        kbsequence.h \
+       language.C \
+       language.h \
        lastfiles.C \
        lastfiles.h \
        latexoptions.C \
index eef1554e9b9dd8aa2d772d19d47b45641a6c3738..f6e09f16c4e88da33d068b5adbfda674c1bda467 100644 (file)
@@ -429,12 +429,14 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
        } else if (token == "\\defskip") {
                lex.nextToken();
                params.defskip = VSpace(lex.GetString());
+#if 0
        } else if (token == "\\no_isolatin1") { // obsolete
                lex.nextToken();
        } else if (token == "\\no_babel") { // obsolete
                lex.nextToken();
        } else if (token == "\\no_epsfig") { // obsolete
                lex.nextToken();
+#endif
        } else if (token == "\\epsfig") { // obsolete
                // Indeed it is obsolete, but we HAVE to be backwards
                // compatible until 0.14, because otherwise all figures
@@ -1708,8 +1710,7 @@ void Buffer::makeLaTeXFile(string const & fname,
                        else if (lyxrc->rtl_support)
                                options += "hebrew,";
                        options += params.language + ',';
-               } else if (lyxrc->rtl_support)
-                       options += "hebrew,english,";
+               }
 
                // the user-defined options
                if (!params.options.empty()) {
@@ -1864,8 +1865,8 @@ void Buffer::makeLaTeXFile(string const & fname,
 
                // We try to load babel late, in case it interferes
                // with other packages.
-               if (params.language != "default" || lyxrc->rtl_support ) {
-                       ofs << "\\usepackage{babel}\n";
+               if (params.language != "default") {
+                       ofs << lyxrc->language_package;
                        texrow.newline();
                }
 
@@ -1990,6 +1991,9 @@ void Buffer::makeLaTeXFile(string const & fname,
                texrow.newline();
        } // only_body
        lyxerr.debug() << "preamble finished, now the body." << endl;
+       if (lyxrc->language_command_begin &&
+           params.getDocumentDirection() == LYX_DIR_RIGHT_TO_LEFT)
+               ofs << lyxrc->language_command_rtl;
        
        bool was_title = false;
        bool already_title = false;
@@ -2081,6 +2085,10 @@ void Buffer::makeLaTeXFile(string const & fname,
                texrow.newline();
        }
 
+       if (lyxrc->language_command_end &&
+           params.getDocumentDirection() == LYX_DIR_RIGHT_TO_LEFT)
+               ofs << lyxrc->language_command_ltr;
+
        if (!only_body) {
                ofs << "\\end{document}\n";
                texrow.newline();
@@ -2695,6 +2703,10 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
                font1 = font2;
        }
 
+       if (lyxrc->language_command_end &&
+           params.getDocumentDirection() == LYX_DIR_RIGHT_TO_LEFT)
+               os << lyxrc->language_command_ltr;
+
        /* needed if there is an optional argument but no contents */
        if (main_body > 0 && main_body == par->size()) {
                font1 = style.font;
index 8dc2e25e37488e2c0f46a4d35ac6dbe213fff0c2..7c1a56f32736d78c0c5fee2d707608ce9b42ee77 100644 (file)
@@ -23,6 +23,7 @@
 #include "support/lyxlib.h"
 #include "support/lstrings.h"
 #include "lyxrc.h"
+#include "language.h"
 
 extern LyXRC * lyxrc;
 
@@ -198,9 +199,25 @@ void BufferParams::readLanguage(LyXLex & lex)
        if (!lex.next()) return;
        
        string tmptok = lex.GetString();
+#if 0
        string test;
        int n = 0;
+#endif
        // check if tmptok is part of tex_babel in tex-defs.h
+       Languages::iterator lit = languages.find(tmptok);
+       if (lit != languages.end()) {
+               // found it
+               language = tmptok;
+               return;
+       }
+       // not found
+       lyxerr << "Warning: language `"
+              << tmptok << "' not recognized!\n"
+              << "         Setting language to `default'."
+              << endl;
+       language = "default";
+       
+#if 0  
        while (true) {
                test = tex_babel[n++];
                
@@ -217,6 +234,7 @@ void BufferParams::readLanguage(LyXLex & lex)
                        break;   
                }      
        }
+#endif
 }
 
 
@@ -251,6 +269,7 @@ void BufferParams::readGraphicsDriver(LyXLex & lex)
 
 LyXDirection BufferParams::getDocumentDirection() const
 {
-       return (lyxrc->rtl_support && language == "hebrew")
+       return (lyxrc->rtl_support &&
+               (language == "hebrew" || language == "arabic"))
                ? LYX_DIR_RIGHT_TO_LEFT : LYX_DIR_LEFT_TO_RIGHT;
 }
index bec7fc1ca7c176e2b0f004f32cda4ba5157f00e2..c20b8ea3ca709bb85c3a8f12d9b367467fabf9cd 100644 (file)
@@ -166,7 +166,7 @@ string InsetUrl::getScreenLabel() const
 }
 
 
-int InsetUrl::Latex(ostream & os, signed char fragile, bool free_spc) const
+int InsetUrl::Latex(ostream & os, signed char fragile, bool /*free_spc*/) const
 {
        if (!getOptions().empty())
                os << getOptions() + ' ';
index 806808eac29803020010b81cd7fd17b8065aa779..d88362747bca9b7c211984c58ebed2c130f5c27e 100644 (file)
@@ -28,6 +28,7 @@
 #include "lyxrc.h"
 #include "trans_mgr.h"
 #include "support/lstrings.h"
+#include "language.h"
 
 extern LyXRC * lyxrc;
 
@@ -130,10 +131,11 @@ void Intl::KeyMapPrim()
 
        /* read text from choice */
        int i = Language->get();
-       
+
+#if 0
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "Table: " << tex_babel[i-1] << endl;
-
+#endif
        string p;
        if (i == otherkeymap)
                p = fl_get_input(fd_form_keymap->OtherKeymap);
@@ -164,10 +166,11 @@ void Intl::KeyMapSec()
 
        /* read text from choice */
        int i = Language2->get();
-       
+
+#if 0
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "Table: " << tex_babel[i-1] << endl;
-
+#endif
        string p;
        if (i == otherkeymap)
                p = fl_get_input(fd_form_keymap->OtherKeymap2);
@@ -280,8 +283,8 @@ void Intl::InitKeyMapper(bool on)
        Language2->add(120, 110, 160, 30, 300); // Secondary
        fl_end_form();
 
+#if 0
        int n = 0;
-
        while (true)
                if (!strlen(tex_babel[n]))
                        break;
@@ -290,7 +293,18 @@ void Intl::InitKeyMapper(bool on)
                        Language2->addto(tex_babel[n]);
                        ++n;
                }
-       
+#else
+       int n = 1;
+       // Default is not in the language map
+       Language->addto("default");
+       Language2->addto("default");
+       for (Languages::const_iterator cit = languages.begin();
+            cit != languages.end(); ++cit) {
+               Language->addto((*cit).second.lang.c_str());
+               Language2->addto((*cit).second.lang.c_str());
+               ++n;
+       }
+#endif
        Language->addto(_("other..."));
        Language2->addto(_("other..."));
        otherkeymap = n + 1;
index b0bcc63810fd00542eea56d1a0897d5debb51db5..b36c1c47e84d43116b8d370e5fbe003d34f38be5 100644 (file)
@@ -74,7 +74,8 @@ enum LayoutTags {
        LT_LABELSEP, 
        LT_LABELSTRING, 
        LT_LABELSTRING_APPENDIX, 
-       LT_LABELTYPE, 
+       LT_LABELTYPE,
+       LT_ENDLABELTYPE,
        LT_LATEXNAME, 
        LT_LATEXPARAM, 
        LT_LATEXTYPE, 
@@ -102,6 +103,7 @@ static keyword_item layoutTags[] = {
        { "bottomsep",                  LT_BOTTOMSEP },
        { "copystyle",                  LT_COPYSTYLE },
        { "end",                        LT_END },
+       { "endlabeltype",               LT_ENDLABELTYPE },
        { "fill_bottom",                LT_FILL_BOTTOM },
        { "fill_top",                   LT_FILL_TOP },
        { "font",                       LT_FONT },
@@ -161,6 +163,7 @@ LyXLayout::LyXLayout ()
        align = LYX_ALIGN_BLOCK;
        alignpossible = LYX_ALIGN_BLOCK;
        labeltype = LABEL_NO_LABEL;
+       endlabeltype = END_LABEL_NO_LABEL;
        // Should or should not. That is the question.
        // spacing.set(Spacing::OneHalf);
        fill_top = false;
@@ -181,6 +184,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                { "bottomsep",                  LT_BOTTOMSEP },
                { "copystyle",                  LT_COPYSTYLE },
                { "end",                        LT_END },
+               { "endlabeltype",               LT_ENDLABELTYPE },
                { "fill_bottom",                LT_FILL_BOTTOM },
                { "fill_top",                   LT_FILL_TOP },
                { "font",                       LT_FONT },
@@ -322,6 +326,10 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                case LT_LABELTYPE:
                        readLabelType(lexrc);
                        break;
+
+               case LT_ENDLABELTYPE:
+                       readEndLabelType(lexrc);
+                       break;
                        
                case LT_LEFTMARGIN:     // left margin type
                        if (lexrc.next())
@@ -658,6 +666,32 @@ void LyXLayout::readLabelType(LyXLex & lexrc)
        }
 }
 
+static keyword_item endlabelTypeTags[] = {
+       { "box",        END_LABEL_BOX },
+       { "filled_box", END_LABEL_FILLED_BOX },
+       { "no_label",   END_LABEL_NO_LABEL }
+};
+
+void LyXLayout::readEndLabelType(LyXLex & lexrc)
+{
+       pushpophelper pph(lexrc, endlabelTypeTags,
+                         END_LABEL_ENUM_LAST-END_LABEL_ENUM_FIRST+1);
+       int le = lexrc.lex();
+       switch(le) {
+       case LyXLex::LEX_UNDEF:
+               lexrc.printError("Unknown labeltype tag `$$Token'");
+               break;
+       case END_LABEL_BOX:
+       case END_LABEL_FILLED_BOX:
+       case END_LABEL_NO_LABEL:
+               endlabeltype = static_cast<LYX_END_LABEL_TYPES>(le);
+               break;
+       default:
+               lyxerr << "Unhandled value " << le
+                      << " in LyXLayout::readEndLabelType." << endl;
+               break;
+       }
+}
 
 #if 0
 static keyword_item marginTags[] = {
index da29bc5d5ea8f7033996f55629723ee022e118e2..530943defe6ca13fd1005cbb7d257e59062f8d2d 100644 (file)
@@ -146,7 +146,19 @@ enum LYX_LABEL_TYPES {
        LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
 };
 
-
+enum LYX_END_LABEL_TYPES {
+       ///
+       END_LABEL_NO_LABEL,
+       ///
+       END_LABEL_BOX,
+       ///
+       END_LABEL_FILLED_BOX,
+       ///
+       END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
+       ///
+       END_LABEL_ENUM_LAST = END_LABEL_FILLED_BOX
+};
+               
 /* Fix labels are printed flushright, manual labels flushleft. 
  * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
  * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL. 
@@ -181,6 +193,7 @@ public:
        void readAlign(LyXLex &);
        void readAlignPossible(LyXLex &);
        void readLabelType(LyXLex &);
+       void readEndLabelType(LyXLex &);
        void readMargin(LyXLex &);
        void readLatexType(LyXLex &);
        void readSpacing(LyXLex &);
@@ -268,6 +281,9 @@ public:
        ///
        char labeltype; // add approp. type
 
+       ///
+       char endlabeltype;
+
        ///
        LYX_MARGIN_TYPE margintype;
 
index e9bd2c685d70a12016d1c021d0829a555ef6bc1b..8fdfc9778f7b127dad6336e06159d1fe37b3c2b8 100644 (file)
@@ -36,6 +36,7 @@
 #include "lyx_gui_misc.h"
 #include "lyxlookup.h"
 #include "bufferlist.h"
+#include "language.h"
 
 #ifdef TWO_COLOR_ICONS
 #include "banner_bw.xbm"
@@ -226,15 +227,17 @@ void LyXGUI::init()
                return;
 
        create_forms();
-       
+
+       if (lyxrc->font_norm_menu.empty())
+               lyxrc->font_norm_menu = lyxrc->font_norm;
        // Set the font name for popups and menus
         string menufontname = lyxrc->menu_font_name 
                               + "-*-*-*-?-*-*-*-*-"  
-                              + lyxrc->font_norm
+                              + lyxrc->font_norm_menu;
                // "?" means "scale that font"
         string popupfontname = lyxrc->popup_font_name 
                               + "-*-*-*-?-*-*-*-*-"  
-                              + lyxrc->font_norm
+                              + lyxrc->font_norm_menu;
 
         if (fl_set_font_name(FL_BOLD_STYLE, menufontname.c_str()) < 0)
                 lyxerr << "Could not set menu font to "
@@ -405,15 +408,24 @@ void LyXGUI::create_forms()
        combo_language->add(ob->x, ob->y, ob->w, ob->h, 250);
        combo_language->shortcut("#G", 1);
        fl_end_form();
+#if 0
        int n; // declared here because DEC cxx does not like multiple
               // declarations of variables in for() loops (JMarc)
         for (n = 0; tex_babel[n][0]; ++n) {
            combo_language->addto(tex_babel[n]);
        }
+#else
+       // "default" is not part of the languages array any more.
+       combo_language->addto("default");
+       for(Languages::const_iterator cit = languages.begin();
+           cit != languages.end(); ++cit) {
+               combo_language->addto((*cit).second.lang.c_str());
+       }
+#endif
 
        // not really necessary, but we can do it anyway.
        fl_addto_choice(fd_form_document->choice_fontsize, "default|10|11|12");
-       
+       int n;
         for (n = 0; tex_fonts[n][0]; ++n) {
            fl_addto_choice(fd_form_document->choice_fonts, tex_fonts[n]);
        }
index 8835859650077be348e0d18931b1d4bc95ba6f0a..9c72dae44dcd38d4f9b1caa3d670ce0a539a0151 100644 (file)
@@ -178,6 +178,9 @@ public:
                        || dhook->GetDepth() != GetDepth());
        }
 
+       /// Check if the current paragraph is the last paragraph in a
+       /// proof environment
+       int GetEndLabel() const;
 
        ///
        TextContainer text;
@@ -299,6 +302,8 @@ public:
        LyXParagraph * PreviousBeforeFootnote();
        ///
        LyXParagraph * LastPhysicalPar();
+       ///
+       LyXParagraph const * LastPhysicalPar() const;
        
        ///
        LyXParagraph * FirstPhysicalPar();
index 18dbfb0bf70e3562514f0f966c5e9f724a59c8f1..6424f382dbd1594857f8b76c47c1984bcc049de7 100644 (file)
@@ -81,6 +81,7 @@ enum LyXRCTags {
        RC_SCREEN_FONT_MENU,
        RC_SCREEN_FONT_POPUP,
        RC_SCREEN_FONT_ENCODING,
+       RC_SCREEN_FONT_ENCODING_MENU,
        RC_AUTOSAVE,
        RC_SGML_EXTRA_OPTIONS,
        RC_DOCUMENTPATH,
@@ -129,6 +130,11 @@ enum LyXRCTags {
        RC_HTML_COMMAND,
        RC_MAKE_BACKUP,
        RC_RTL_SUPPORT,
+       RC_LANGUAGE_PACKAGE,
+       RC_LANGUAGE_COMMAND_BEGIN,
+       RC_LANGUAGE_COMMAND_END,
+       RC_LANGUAGE_COMMAND_RTL,
+       RC_LANGUAGE_COMMAND_LTR,
        RC_PDFLATEX_COMMAND,
        RC_PDF_MODE,
        RC_VIEWPDF_COMMAND,
@@ -174,6 +180,11 @@ keyword_item lyxrcTags[] = {
        { "\\kbmap", RC_KBMAP },
        { "\\kbmap_primary", RC_KBMAP_PRIMARY },
        { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
+       { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
+       { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
+       { "\\language_command_ltr", RC_LANGUAGE_COMMAND_LTR },
+       { "\\language_command_rtl", RC_LANGUAGE_COMMAND_RTL },
+       { "\\language_package", RC_LANGUAGE_PACKAGE },
        { "\\lastfiles", RC_LASTFILES },
        { "\\latex_command", RC_LATEX_COMMAND },
         { "\\literate_command", RC_LITERATE_COMMAND },
@@ -209,6 +220,7 @@ keyword_item lyxrcTags[] = {
        { "\\rtl", RC_RTL_SUPPORT },
        { "\\screen_dpi", RC_SCREEN_DPI },
        { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
+       { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
        { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
        { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
        { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
@@ -312,6 +324,7 @@ LyXRC::LyXRC()
        menu_font_name = "-*-helvetica-bold-r";
        popup_font_name = "-*-helvetica-medium-r";
        font_norm = "iso8859-1";
+       font_norm_menu = "";
        autosave = 300;
        auto_region_delete = true;
        ascii_linelen = 75;
@@ -330,6 +343,13 @@ LyXRC::LyXRC()
        use_kbmap = false;
        hasBindFile = false;
        rtl_support = false;
+       language_package = "\\usepackage{babel}";
+       language_command_begin = false;
+       language_command_end = false;
+       language_command_rtl = "\\sethebrew";
+       language_command_ltr = "\\unsethebrew";
+       defaultKeyBindings();
+       ///
        date_insert_format = "%A, %e %B %Y";
        show_banner = true;
        //
@@ -780,7 +800,12 @@ int LyXRC::read(string const & filename)
                        if (lexrc.next())
                                font_norm = lexrc.GetString();
                        break;
-                       
+
+               case RC_SCREEN_FONT_ENCODING_MENU:
+                       if (lexrc.next())
+                               font_norm_menu = lexrc.GetString();
+                       break;
+
                case RC_AUTOREGIONDELETE:
                        // Auto region delete defaults to true
                        if (lexrc.next())
@@ -921,6 +946,26 @@ int LyXRC::read(string const & filename)
                        if (lexrc.next())
                                date_insert_format = lexrc.GetString();
                        break;
+               case RC_LANGUAGE_PACKAGE:
+                       if (lexrc.next())
+                               language_package = lexrc.GetString();
+                       break;
+               case RC_LANGUAGE_COMMAND_BEGIN:
+                       if (lexrc.next())
+                               language_command_begin = lexrc.GetBool();
+                       break;
+               case RC_LANGUAGE_COMMAND_END:
+                       if (lexrc.next())
+                               language_command_end = lexrc.GetBool();
+                       break;
+               case RC_LANGUAGE_COMMAND_RTL:
+                       if (lexrc.next())
+                               language_command_rtl = lexrc.GetString();
+                       break;
+               case RC_LANGUAGE_COMMAND_LTR:
+                       if (lexrc.next())
+                               language_command_ltr = lexrc.GetString();
+                       break;
                case RC_RTL_SUPPORT:
                        if (lexrc.next())
                                rtl_support = lexrc.GetBool();
@@ -1173,6 +1218,9 @@ void LyXRC::output(ostream & os) const
                os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
        case RC_SCREEN_FONT_ENCODING:
                os << "\\screen_font_encoding \"" << font_norm << "\"\n";
+       case RC_SCREEN_FONT_ENCODING_MENU:
+               os << "\\screen_font_encoding_menu \"" << font_norm_menu
+                  << "\"\n";
        case RC_SCREEN_FONT_SCALABLE:
                os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
                   << "\n";
@@ -1218,6 +1266,20 @@ void LyXRC::output(ostream & os) const
                os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
        case RC_RTL_SUPPORT:
                os << "\\rtl " << tostr(rtl_support) << "\n";
+       case RC_LANGUAGE_COMMAND_BEGIN:
+               os << "\\language_command_begin " 
+                  << tostr(language_command_begin) << "\n";
+       case RC_LANGUAGE_COMMAND_END:
+               os << "\\language_command_end " 
+                  << tostr(language_command_end) << "\n";
+       case RC_LANGUAGE_PACKAGE:
+               os << "\\language_package \"" << language_package << "\"\n";
+       case RC_LANGUAGE_COMMAND_LTR:
+               os << "\\language_command_ltr \"" << language_command_ltr
+                  << "\"\n";
+       case RC_LANGUAGE_COMMAND_RTL:
+               os << "\\language_command_rtl \"" << language_command_rtl
+                  << "\"\n";
        case RC_MAKE_BACKUP:
                os << "\\make_backup " << tostr(make_backup) << "\n";
        case RC_DATE_INSERT_FORMAT:
index c9c757b9029f6dbb3dffc9db246f255c73cfefad..77b1454a182ef08b0adfc5ee92464b126d66c23b 100644 (file)
@@ -158,6 +158,8 @@ public:
        ///
        string font_norm;
        ///
+       string font_norm_menu;
+       ///
        unsigned int autosave;
        ///
        string fax_command;
@@ -201,6 +203,17 @@ public:
        string lyxpipes;
        ///
        string date_insert_format;
+       ///
+       string language_package;
+       ///
+       bool language_command_begin;
+       ///
+       bool language_command_end;
+       ///
+       string language_command_rtl;
+       ///
+       string language_command_ltr;
+
        ///
        bool rtl_support;
        ///
index e30921b7606b2ada331bdb5a1bbca89605ac22eb..1aa54c02ebd182772fc278f8ab336fd0ee1e382c 100644 (file)
@@ -32,6 +32,16 @@ class WorkArea;
  */
 class LyXScreen {
 public:
+
+       enum Cursor_Shape {
+               ///
+               BAR_SHAPE,
+               ///
+               L_SHAPE,
+               ///
+               REVERSED_L_SHAPE
+       };
+
        ///
        LyXScreen(WorkArea &, LyXText * text_ptr);
 
@@ -53,7 +63,8 @@ public:
        ///
        void CursorToggle();
        ///
-       void ShowManualCursor(long x, long y, int asc, int desc);
+       void ShowManualCursor(long x, long y, int asc, int desc,
+                             Cursor_Shape shape);
        /// returns 1 if first has changed, otherwise 0
        int  FitManualCursor(long, long, int, int);
        ///
index f6995e25322cd92e8efc2586b5c2faea2675ae6f..352828694305ee15721fce089b85974b0b99b7f8 100644 (file)
@@ -44,6 +44,13 @@ public:
                NEED_VERY_LITTLE_REFRESH
        };
 
+       enum Letter_Form {
+               FORM_ISOLATED,
+               FORM_INITIAL,
+               FORM_MEDIAL,
+               FORM_FINAL
+       };
+
        /// points to Buffer.params
        BufferParams * parameters;
        /// points to Buffer
@@ -636,6 +643,13 @@ private:
                        return vis2log_list[pos-bidi_start];
        }
 
+       ///
+       unsigned char TransformChar(unsigned char c, Letter_Form form) const;
+
+       ///
+       unsigned char TransformChar(unsigned char c, LyXParagraph * par,
+                               LyXParagraph::size_type pos) const;
+
        /** returns the paragraph position of the last character in the 
          specified row
          */
index 2cc1a95b67abbe0d44b0ebc03bc5aa83cef11372..99ab8c67ba08ad16de4af89ac340225356646cfd 100644 (file)
@@ -1202,9 +1202,20 @@ LyXParagraph * LyXParagraph::LastPhysicalPar()
                tmp = tmp->NextAfterFootnote();
    
        return tmp;
-   
 }
 
+LyXParagraph const * LyXParagraph::LastPhysicalPar() const
+{
+       if (footnoteflag != LyXParagraph::NO_FOOTNOTE)
+               return this;
+   
+       LyXParagraph const * tmp = this;
+       while (tmp->next
+              && tmp->next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+               tmp = tmp->NextAfterFootnote();
+   
+       return tmp;  
+}
 
 LyXParagraph * LyXParagraph::FirstPhysicalPar()
 {
@@ -1567,6 +1578,34 @@ void LyXParagraph::CloseFootnote(LyXParagraph::size_type pos)
        }
 }
 
+int LyXParagraph::GetEndLabel() const
+{
+       LyXParagraph const * par = this;
+       int par_depth = GetDepth();
+       while (par) {
+               LyXTextClass::LayoutList::size_type layout = par->GetLayout();
+               int endlabeltype =
+                       textclasslist.Style(current_view->buffer()->params.textclass,
+                                           layout).endlabeltype;
+               if (endlabeltype != END_LABEL_NO_LABEL) {
+                       LyXParagraph const * last = LastPhysicalPar();
+                       if (!last || !last->next)
+                               return endlabeltype;
+
+                       int next_depth = last->next->GetDepth();
+                       if (par_depth > next_depth ||
+                           (par_depth == next_depth && layout != last->next->GetLayout() ))
+                               return endlabeltype;
+                       break;
+               }
+               if (par_depth == 0)
+                       break;
+               par = par->DepthHook(par_depth - 1);
+               if (par)
+                       par_depth = par->GetDepth();
+       }
+       return END_LABEL_NO_LABEL;
+}
 
 LyXTextClass::size_type LyXParagraph::GetLayout() const
 {
@@ -1916,9 +1955,9 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
                current_view->buffer()->params.getDocumentDirection();
        if (direction != global_direction) {
                if (direction == LYX_DIR_LEFT_TO_RIGHT)
-                       os << "\\unsethebrew\n";
+                       os << lyxrc->language_command_ltr << '\n';
                else
-                       os << "\\sethebrew\n";
+                       os << lyxrc->language_command_rtl << '\n';
                texrow.newline();
        }
        
@@ -1981,9 +2020,9 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
 
        if (direction != global_direction)
                if (direction == LYX_DIR_LEFT_TO_RIGHT)
-                       os << "\\sethebrew";
+                       os << '\n' << lyxrc->language_command_rtl;
                else
-                       os << "\\unsethebrew";
+                       os << '\n' << lyxrc->language_command_ltr;
        
        switch (style.latextype) {
        case LATEX_ITEM_ENVIRONMENT:
@@ -3755,9 +3794,9 @@ LyXParagraph * LyXParagraph::TeXFootnote(ostream & os, TexRow & texrow,
        LyXDirection direction = getParDirection();
        if (direction != par_direction) {
                if (direction == LYX_DIR_LEFT_TO_RIGHT)
-                       os << "\\unsethebrew\n";
+                       os << lyxrc->language_command_ltr << '\n';
                else
-                       os << "\\sethebrew\n";
+                       os << lyxrc->language_command_rtl << '\n';
                texrow.newline();
        }
 
index cc379034d94c5db37e667f7693a82f55e05fc4bd..2fe0eb0705a609971f1ef03510a430f10fc9a66d 100644 (file)
@@ -21,6 +21,7 @@
 #include "lyxrow.h"
 #include "Painter.h"
 #include "WorkArea.h"
+#include "bufferparams.h"
 
 using std::max;
 using std::min;
@@ -185,52 +186,19 @@ void LyXScreen::Draw(long  y)
 
 void LyXScreen::ShowCursor()
 {
-       if (cursor_visible) return;
-   
-       long x = text->cursor.x;
-       
-       long y1 = max(text->cursor.y -
-                     text->real_current_font.maxAscent() - first, 0L);
-       
-       long y2 = min(text->cursor.y +
-                     text->real_current_font.maxDescent() - first,
-                     long(owner.height()));
-
-       // Secure against very strange situations
-       if (y2 < y1) y2 = y1;
-
-       if (cursor_pixmap){
-               XFreePixmap(fl_display, cursor_pixmap);
-               cursor_pixmap = 0;
-       }
-   
-       if (y2 > 0 && y1 < owner.height()) {
-               cursor_pixmap_w = 1;
-               cursor_pixmap_h = y2 - y1 + 1;
-               cursor_pixmap_x = x;
-               cursor_pixmap_y = y1;
-               cursor_pixmap = 
-                       XCreatePixmap(fl_display,
-                                     fl_root,
-                                     cursor_pixmap_w,
-                                     cursor_pixmap_h,
-                                     fl_get_visual_depth());
-               XCopyArea(fl_display,
-                         owner.getWin(),
-                         cursor_pixmap,
-                         gc_copy,
-                         owner.xpos() + cursor_pixmap_x,
-                         owner.ypos() + cursor_pixmap_y,
-                         cursor_pixmap_w, cursor_pixmap_h,
-                         0, 0);
-               XDrawLine(fl_display,
-                         owner.getWin(),
-                         gc_copy,
-                         x + owner.xpos(),
-                         y1 + owner.ypos(),
-                         x + owner.xpos(),
-                         y2 + owner.ypos());
-               cursor_visible = true;
+       if (!cursor_visible) {
+               Cursor_Shape shape = BAR_SHAPE;
+               if (text->real_current_font.getFontDirection()
+                   != text->parameters->getDocumentDirection())
+                       if (text->real_current_font.getFontDirection()
+                           == LYX_DIR_LEFT_TO_RIGHT)
+                               shape = L_SHAPE;
+                       else
+                               shape = REVERSED_L_SHAPE;
+               ShowManualCursor(text->cursor.x, text->cursor.y,
+                                text->real_current_font.maxAscent(),
+                                text->real_current_font.maxDescent(),
+                                shape);
        }
 }
 
@@ -258,22 +226,40 @@ int LyXScreen::FitManualCursor(long /*x*/, long y, int asc, int desc)
 }
 
 
-void  LyXScreen::ShowManualCursor(long x, long y, int asc, int desc)
+void  LyXScreen::ShowManualCursor(long x, long y, int asc, int desc,
+                                 Cursor_Shape shape)
 {
        long y1 = max(y - first - asc, 0L);
        long y2 = min(y - first + desc, long(owner.height()));
 
+       // Secure against very strange situations
+       if (y2 < y1) y2 = y1;
+
        if (cursor_pixmap){
                XFreePixmap(fl_display, cursor_pixmap);
                cursor_pixmap = 0;
        }
-               
+
        if (y2 > 0 && y1 <
            owner.height()) {
-               cursor_pixmap_w = 1;
                cursor_pixmap_h = y2 - y1 + 1;
-               cursor_pixmap_x = x,
-                       cursor_pixmap_y = y1;
+               cursor_pixmap_y = y1;
+
+               switch(shape) {
+               case BAR_SHAPE:
+                       cursor_pixmap_w = 1;
+                       cursor_pixmap_x = x;
+                       break;
+               case L_SHAPE:
+                       cursor_pixmap_w = cursor_pixmap_h/3;
+                       cursor_pixmap_x = x;
+                       break;
+               case REVERSED_L_SHAPE:
+                       cursor_pixmap_w = cursor_pixmap_h/3;
+                       cursor_pixmap_x = x - cursor_pixmap_w + 1;
+                       break;
+               }
+
                cursor_pixmap = 
                        XCreatePixmap (fl_display,
                                       fl_root,
@@ -296,6 +282,21 @@ void  LyXScreen::ShowManualCursor(long x, long y, int asc, int desc)
                          y1 + owner.ypos(),
                          x + owner.xpos(),
                          y2 + owner.ypos());
+               switch(shape) {
+               case BAR_SHAPE:
+                       break;
+               case L_SHAPE:
+               case REVERSED_L_SHAPE:
+                       int rectangle_h = (cursor_pixmap_h+10)/20;
+                       XFillRectangle(fl_display,
+                                      owner.getWin(),
+                                      gc_copy,
+                                      cursor_pixmap_x + owner.xpos(),
+                                      y2 - rectangle_h + 1 + owner.ypos(),
+                                      cursor_pixmap_w - 1, rectangle_h);
+                       break;
+               }
+
        }
        cursor_visible = true;
 }
index cefa39a9ccbbba82288c840b5fbd8fc84300a75a..d194b5bc2f5b33472a9ba2209f187d5c8af10ee0 100644 (file)
@@ -43,20 +43,23 @@ char const * string_align[5] = {
 // used all over. As it happens, that meant that these strings were included 
 // 27 times in the object file. (Asger)
 
+#if 0
 ///
-char const * tex_babel[] = {"default", "afrikaans", "american",
-                          "austrian", "bahasa", "brazil", "breton",
-                          "catalan", "croatian", "czech", "danish", "dutch", 
-                          "english", "esperanto", "estonian",
-                          "finnish", "francais", "french", "frenchb",
-                          "galician",
-                          "german", "greek", "hebrew", "hungarian", "irish",
-                          "italian", "lsorbian", "magyar", "norsk",
-                          "polish", "portuges", "romanian",
-                          "russian", "scottish",
-                          "spanish", "slovak", "slovene", "swedish",
-                          "turkish", "usorbian", "welsh",
-                          ""};
+char const * tex_babel[] = {
+       "default", "afrikaans", "american", "arabic",
+       "austrian", "bahasa", "brazil", "breton",
+       "catalan", "croatian", "czech", "danish", "dutch", 
+       "english", "esperanto", "estonian",
+       "finnish", "francais", "french", "frenchb",
+       "galician",
+       "german", "greek", "hebrew", "hungarian", "irish",
+       "italian", "lsorbian", "magyar", "norsk",
+       "polish", "portuges", "romanian",
+       "russian", "scottish",
+       "spanish", "slovak", "slovene", "swedish",
+       "turkish", "usorbian", "welsh",
+       ""};
+#endif
 
 
 char const * tex_graphics[] = {"default", "dvips", "dvitops", "emtex",
index f06391b7be4a5306dd28c0520b71d564a6ab51e6..2ca62772fecac256ca5c4ad123a87a275953464c 100644 (file)
@@ -25,7 +25,7 @@ extern char const * string_align[];
 // 27 times in the object file. (Asger)
 
 ///
-extern char const * tex_babel[];
+//extern char const * tex_babel[];
 
 ///
 extern char const * tex_graphics[];
index c7da87d66ed28e324d0cbcda313901312cd321ed..454592e3ea565fd8e691b82899327e8427e295f5 100644 (file)
@@ -44,6 +44,94 @@ extern int bibitemMaxWidth(Painter &, LyXFont const &);
 
 #define FIX_DOUBLE_SPACE 1
 
+static int iso885968x[] = {
+       0xbc,   // 0xa8 = fathatan
+       0xbd,   // 0xa9 = dammatan
+       0xbe,   // 0xaa = kasratan
+       0xdb,   // 0xab = fatha
+       0xdc,   // 0xac = damma
+       0xdd,   // 0xad = kasra
+       0xde,   // 0xae = shadda
+       0xdf,   // 0xaf = sukun
+
+       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xb0-0xbf
+
+       0,      // 0xc0 
+       0xc1,   // 0xc1 = hamza
+       0xc2,   // 0xc2 = ligature madda
+       0xc3,   // 0xc3 = ligature hamza on alef
+       0xc4,   // 0xc4 = ligature hamza on waw
+       0xc5,   // 0xc5 = ligature hamza under alef
+       0xc0,   // 0xc6 = ligature hamza on ya 
+       0xc7,   // 0xc7 = alef
+       0xeb,   // 0xc8 = baa 
+       0xc9,   // 0xc9 = taa marbuta
+       0xec,   // 0xca = taa
+       0xed,   // 0xcb = thaa
+       0xee,   // 0xcc = jeem
+       0xef,   // 0xcd = haa
+       0xf0,   // 0xce = khaa
+       0xcf,   // 0xcf = dal
+
+       0xd0,   // 0xd0 = thal
+       0xd1,   // 0xd1 = ra
+       0xd2,   // 0xd2 = zain
+       0xf1,   // 0xd3 = seen
+       0xf2,   // 0xd4 = sheen
+       0xf3,   // 0xd5 = sad
+       0xf4,   // 0xd6 = dad
+       0xd7,   // 0xd7 = tah
+       0xd8,   // 0xd8 = zah
+       0xf5,   // 0xd9 = ain
+       0xf6,   // 0xda = ghain
+       0,0,0,0,0, // 0xdb- 0xdf
+
+       0,      // 0xe0
+       0xf7,   // 0xe1 = fa
+       0xf8,   // 0xe2 = qaf
+       0xf9,   // 0xe3 = kaf
+       0xfa,   // 0xe4 = lam
+       0xfb,   // 0xe5 = meem
+       0xfc,   // 0xe6 = noon
+       0xfd,   // 0xe7 = ha
+       0xe8,   // 0xe8 = waw
+       0xe9,   // 0xe9 = alef maksura
+       0xfe    // 0xea = ya
+};
+
+bool is_arabic(unsigned char c)
+{
+       return 0xa8 <= c && c <= 0xea && iso885968x[c-0xa8];
+}
+
+unsigned char LyXText::TransformChar(unsigned char c, Letter_Form form) const
+{
+       if (is_arabic(c) && 
+           (form == FORM_INITIAL || form == FORM_MEDIAL) )
+               return iso885968x[c-0xa8];
+       else
+               return c;
+}
+
+unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par,
+                       LyXParagraph::size_type pos) const
+{
+       if (!is_arabic(c))
+               return c;
+
+       bool not_first = (pos > 0 && is_arabic(par->GetChar(pos-1)));
+       if (pos < par->Last()-1 && is_arabic(par->GetChar(pos+1)))
+               if (not_first)
+                       return TransformChar(c,FORM_MEDIAL);
+               else
+                       return TransformChar(c,FORM_INITIAL);
+       else
+               if (not_first)
+                       return TransformChar(c,FORM_FINAL);
+               else
+                       return TransformChar(c,FORM_ISOLATED);
+}
+
 // This is the comments that some of the warnings below refers to.
 // There are some issues in this file and I don't think they are
 // really related to the FIX_DOUBLE_SPACE patch. I'd rather think that
@@ -84,6 +172,8 @@ int LyXText::SingleWidth(LyXParagraph * par,
 
        // The most common case is handled first (Asger)
        if (IsPrintable(c)) {
+               if (lyxrc->rtl_support && lyxrc->font_norm == "iso8859-6.8x")
+                       c = TransformChar(c, par, pos);
                return font.width(c);
 
        } else if (IsHfillChar(c)) {
@@ -416,6 +506,9 @@ void LyXText::draw(Row const * row,
        // So IMHO we should go with the easier and clearer implementation.
        // And even if 1024 is a large number here it might overflow, string
        // will only overflow if the machine is out of memory...
+       bool do_transform = (lyxrc->rtl_support && lyxrc->font_norm == "iso8859-6.8x");
+       if (do_transform)
+               c = TransformChar(c, row->par, pos);
        static string textstring;
        textstring = c;
        ++vpos;
@@ -426,6 +519,8 @@ void LyXText::draw(Row const * row,
               (pos = vis2log(vpos)) >= 0
               && static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
               && font2 == GetFont(row->par, pos)) {
+               if (do_transform)
+                       c = TransformChar(c, row->par, pos);
                textstring += c;
                ++vpos;
        }
@@ -816,7 +911,6 @@ LyXText::NextBreakPoint(Row const * row, int width) const
        // position of the last possible breakpoint 
        // -1 isn't a suitable value, but a flag
        LyXParagraph::size_type last_separator = -1;
-       int left_margin = LabelEnd(row);
        width -= RightMargin(row);
        
        LyXParagraph::size_type main_body = BeginningOfMainBody(par);
@@ -882,6 +976,7 @@ LyXText::NextBreakPoint(Row const * row, int width) const
                                x += GetFont(par, -2).stringWidth(layout.labelsep);
                                if (par->IsLineSeparator(i - 1))
                                        x-= SingleWidth(par, i - 1);
+                               int left_margin = LabelEnd(row);
                                if (x < left_margin)
                                        x = left_margin;
                        }
@@ -935,9 +1030,7 @@ int LyXText::Fill(Row const * row, int paper_width) const
                           * this point. */ 
        }
        /* table stuff -- end*/ 
-       
-       int left_margin = LabelEnd(row);
-       
+               
        // if the row ends with newline, this newline will not be relevant
        //if (last >= 0 && row->par->IsNewline(last))
        //      --last;
@@ -969,6 +1062,7 @@ int LyXText::Fill(Row const * row, int paper_width) const
                                stringWidth(layout.labelsep);
                        if (row->par->IsLineSeparator(i - 1))
                                w -= SingleWidth(row->par, i - 1);
+                       int left_margin = LabelEnd(row);
                        if (w < left_margin)
                                w = left_margin;
                }
@@ -979,6 +1073,7 @@ int LyXText::Fill(Row const * row, int paper_width) const
                w += GetFont(row->par, -2).stringWidth(layout.labelsep);
                if (last >= 0 && row->par->IsLineSeparator(last))
                        w -= SingleWidth(row->par, last);
+               int left_margin = LabelEnd(row);
                if (w < left_margin)
                        w = left_margin;
        }
@@ -3949,6 +4044,40 @@ void LyXText::GetVisibleRow(int offset,
                                  Painter::line_thick);
                        y_bottom -= GetFont(par, par->Last() - 1).ascent('x');
                }
+
+               // draw an endlabel
+               int endlabel = row_ptr->par->GetEndLabel();
+               if (endlabel == END_LABEL_BOX ||
+                   endlabel == END_LABEL_FILLED_BOX) {
+                       LyXFont font = GetFont(row_ptr->par, RowLast(row_ptr));
+                       int size = int(0.75*font.maxAscent());
+                       int y = (offset + row_ptr->baseline) - size;
+                       int x = (direction == LYX_DIR_LEFT_TO_RIGHT)
+                               ? paperwidth - LYX_PAPER_MARGIN - size
+                               : LYX_PAPER_MARGIN;
+                       if (row_ptr->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
+                               if (direction == LYX_DIR_LEFT_TO_RIGHT)
+                                       x -= LYX_PAPER_MARGIN/2;
+                               else {
+                                       LyXFont font(LyXFont::ALL_SANE);
+                                       font.setSize(LyXFont::SIZE_SMALL);
+                                       x += font.textWidth("Mwide-figM", 10);
+                               }
+                       if (row_ptr->fill <= size)
+                               x += (size - row_ptr->fill + 1) * direction;
+                       if (endlabel == END_LABEL_BOX) {
+                               pain.line(x, y, x, y + size,
+                                         LColor::eolmarker);
+                               pain.line(x + size, y, x + size , y + size,
+                                         LColor::eolmarker);
+                               pain.line(x, y, x + size, y,
+                                         LColor::eolmarker);
+                               pain.line(x, y + size, x + size, y + size,
+                                         LColor::eolmarker);
+                       } else
+                               pain.fillRectangle(x, y, size, size,
+                                                  LColor::eolmarker);
+               }
        }
        
        /* draw the text in the pixmap */  
index 55e8221ec7580790ff7a6c9e4e07c92c31b1bbf9..d2c60ee3a9363d997d6d27b9a092d88a97e088f2 100644 (file)
@@ -1347,17 +1347,48 @@ void LyXText::SetParagraphExtraOpt(int type,
 }
 
 
-static
-string alphaCounter(int n) {
-       if (n != 0) {
-               if (n > 'Z')
-                       return "??";
-               char result[2] = { 'A' + n - 1, 0 };
-               return result;
-       }
-       return "";
+char loweralphaCounter(int n)
+{
+       if (n < 1 || n > 26)
+               return '?';
+       else
+               return 'a' + n - 1;
+}
+
+char alphaCounter(int n)
+{
+       if (n < 1 || n > 26)
+               return '?';
+       else
+               return 'A' + n - 1;
+}
+
+char hebrewCounter(int n)
+{
+       static const char hebrew[22] = {
+               'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è',
+               'é', 'ë', 'ì', 'î', 'ð', 'ñ', 'ò', 'ô', 'ö', 
+               '÷', 'ø', 'ù', 'ú'
+       };
+       if (n < 1 || n > 22)
+               return '?';
+       else
+               return hebrew[n-1];
 }
 
+static char const * romanCounter(int n)
+{
+       static char const * roman[20] = {
+               "i",   "ii",  "iii", "iv", "v",
+               "vi",  "vii", "viii", "ix", "x",
+               "xi",  "xii", "xiii", "xiv", "xv",
+               "xvi", "xvii", "xviii", "xix", "xx"
+       };
+       if (n < 1 || n > 20)
+               return "??";
+       else
+               return roman[n-1];
+}
 
 // set the counter of a paragraph. This includes the labels
 void LyXText::SetCounter(LyXParagraph * par) const
@@ -1544,28 +1575,51 @@ void LyXText::SetCounter(LyXParagraph * par) const
                        } else { // appendix
                                switch (2 * LABEL_FIRST_COUNTER - textclass.maxcounter() + i) {
                                case LABEL_COUNTER_CHAPTER:
-                                       s << alphaCounter(par->getCounter(i));
+                                       if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
+                                               s << alphaCounter(par->getCounter(i));
+                                       else
+                                               s << hebrewCounter(par->getCounter(i));
                                        break;
                                case LABEL_COUNTER_SECTION:
-                                       s << alphaCounter(par->getCounter(i - 1)) << '.'
+                                       if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
+                                               s << alphaCounter(par->getCounter(i - 1));
+                                       else
+                                               s << hebrewCounter(par->getCounter(i - 1));
+
+                                       s << '.'
                                          << par->getCounter(i);
 
                                        break;
                                case LABEL_COUNTER_SUBSECTION:
-                                       s << alphaCounter(par->getCounter(i - 2)) << '.'
+                                       if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
+                                               s << alphaCounter(par->getCounter(i - 2));
+                                       else
+                                               s << hebrewCounter(par->getCounter(i - 2));
+
+                                       s << '.'
                                          << par->getCounter(i-1) << '.'
                                          << par->getCounter(i);
 
                                        break;
                                case LABEL_COUNTER_SUBSUBSECTION:
-                                       s << alphaCounter(par->getCounter(i-3)) << '.'
+                                       if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
+                                               s << alphaCounter(par->getCounter(i-3));
+                                       else
+                                               s << hebrewCounter(par->getCounter(i-3));
+
+                                       s << '.'
                                          << par->getCounter(i-2) << '.'
                                          << par->getCounter(i-1) << '.'
                                          << par->getCounter(i);
 
                                        break;
                                case LABEL_COUNTER_PARAGRAPH:
-                                       s << alphaCounter(par->getCounter(i-4)) << '.'
+                                       if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
+                                               s << alphaCounter(par->getCounter(i-4));
+                                       else
+                                               s << hebrewCounter(par->getCounter(i-4));
+
+                                       s << '.'
                                          << par->getCounter(i-3) << '.'
                                          << par->getCounter(i-2) << '.'
                                          << par->getCounter(i-1) << '.'
@@ -1573,7 +1627,12 @@ void LyXText::SetCounter(LyXParagraph * par) const
 
                                        break;
                                case LABEL_COUNTER_SUBPARAGRAPH:
-                                       s << alphaCounter(par->getCounter(i-5)) << '.'
+                                       if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
+                                               s << alphaCounter(par->getCounter(i-5));
+                                       else
+                                               s << hebrewCounter(par->getCounter(i-5));
+
+                                       s << '.'
                                          << par->getCounter(i-4) << '.'
                                          << par->getCounter(i-3) << '.'
                                          << par->getCounter(i-2) << '.'
@@ -1614,17 +1673,6 @@ void LyXText::SetCounter(LyXParagraph * par) const
                        par->incCounter(i + par->enumdepth);
                        int number = par->getCounter(i + par->enumdepth);
 
-                       static const char *roman[20] = {
-                               "i",   "ii",  "iii", "iv", "v",
-                               "vi",  "vii", "viii", "ix", "x",
-                               "xi",  "xii", "xiii", "xiv", "xv",
-                               "xvi", "xvii", "xviii", "xix", "xx"
-                       };
-                       static const char hebrew[22] = {
-                               'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è',
-                               'é', 'ë', 'ì', 'î', 'ð', 'ñ', 'ò', 'ô', 'ö', 
-                               '÷', 'ø', 'ù', 'ú'
-                       };
 #ifdef HAVE_SSTREAM
                        ostringstream s;
 #else
@@ -1634,31 +1682,26 @@ void LyXText::SetCounter(LyXParagraph * par) const
                        case 1:
                                if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
                                        s << '('
-                                         << static_cast<unsigned char>
-                                               (((number - 1) % 26) + 'a')
+                                         << loweralphaCounter(number)
                                          << ')';
-                               
                                else
                                        s << '('
-                                         << static_cast<unsigned char>
-                                               (hebrew[(number - 1) % 22])
+                                         << hebrewCounter(number)
                                          << ')';
                                break;
                        case 2:
                                if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
-                                       s << roman[(number - 1) % 20] << '.';
+                                       s << romanCounter(number) << '.';
                                else
-                                       s << '.' << roman[(number - 1) % 20];
+                                       s << '.' << romanCounter(number);
                                break;
                        case 3:
                                if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
-                                       s << static_cast<unsigned char>
-                                               (((number - 1) % 26) + 'A')
+                                       s << alphaCounter(number)
                                          << '.';
                                else
                                        s << '.'
-                                         << static_cast<unsigned char>
-                                               (((number - 1) % 26) + 'A');
+                                         << alphaCounter(number);
                                break;
                        default:
                                if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
@@ -3005,7 +3048,7 @@ void LyXText::SetCursorIntern(LyXParagraph * par,
                        current_font = cursor.par->GetFontSettings(cursor.pos);
                        real_current_font = GetFont(cursor.par, cursor.pos);
                        if (pos == 0 && par->size() == 0 
-                           && owner_->buffer()->params.getDocumentDirection() == LYX_DIR_RIGHT_TO_LEFT) {
+                           && parameters->getDocumentDirection() == LYX_DIR_RIGHT_TO_LEFT) {
                                current_font.setDirection(LyXFont::RTL_DIR);
                                real_current_font.setDirection(LyXFont::RTL_DIR);
                        }