+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
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";;
AlignPossible Block, Left
LabelType Static
LabelString "Proof."
+ EndLabelType Box
# standard font definition
Font
AlignPossible Block, Left
LabelType Static
LabelString ":äçëåä"
+ EndLabelType Filled_Box
# standard font definition
Font
Shape Up
# 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"
{
if (the_locking_inset && available()) {
y += text->cursor.y;
- screen->ShowManualCursor(x, y,
- asc, desc);
+ screen->ShowManualCursor(x, y, asc, desc,
+ LyXScreen::BAR_SHAPE);
}
}
kbmap.h \
kbsequence.C \
kbsequence.h \
+ language.C \
+ language.h \
lastfiles.C \
lastfiles.h \
latexoptions.C \
} 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
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()) {
// 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();
}
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;
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();
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;
#include "support/lyxlib.h"
#include "support/lstrings.h"
#include "lyxrc.h"
+#include "language.h"
extern LyXRC * lyxrc;
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++];
break;
}
}
+#endif
}
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;
}
}
-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() + ' ';
#include "lyxrc.h"
#include "trans_mgr.h"
#include "support/lstrings.h"
+#include "language.h"
extern LyXRC * lyxrc;
/* 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);
/* 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);
Language2->add(120, 110, 160, 30, 300); // Secondary
fl_end_form();
+#if 0
int n = 0;
-
while (true)
if (!strlen(tex_babel[n]))
break;
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;
LT_LABELSEP,
LT_LABELSTRING,
LT_LABELSTRING_APPENDIX,
- LT_LABELTYPE,
+ LT_LABELTYPE,
+ LT_ENDLABELTYPE,
LT_LATEXNAME,
LT_LATEXPARAM,
LT_LATEXTYPE,
{ "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 },
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;
{ "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 },
case LT_LABELTYPE:
readLabelType(lexrc);
break;
+
+ case LT_ENDLABELTYPE:
+ readEndLabelType(lexrc);
+ break;
case LT_LEFTMARGIN: // left margin type
if (lexrc.next())
}
}
+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[] = {
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.
void readAlign(LyXLex &);
void readAlignPossible(LyXLex &);
void readLabelType(LyXLex &);
+ void readEndLabelType(LyXLex &);
void readMargin(LyXLex &);
void readLatexType(LyXLex &);
void readSpacing(LyXLex &);
///
char labeltype; // add approp. type
+ ///
+ char endlabeltype;
+
///
LYX_MARGIN_TYPE margintype;
#include "lyx_gui_misc.h"
#include "lyxlookup.h"
#include "bufferlist.h"
+#include "language.h"
#ifdef TWO_COLOR_ICONS
#include "banner_bw.xbm"
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 "
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]);
}
|| dhook->GetDepth() != GetDepth());
}
+ /// Check if the current paragraph is the last paragraph in a
+ /// proof environment
+ int GetEndLabel() const;
///
TextContainer text;
LyXParagraph * PreviousBeforeFootnote();
///
LyXParagraph * LastPhysicalPar();
+ ///
+ LyXParagraph const * LastPhysicalPar() const;
///
LyXParagraph * FirstPhysicalPar();
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,
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,
{ "\\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 },
{ "\\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 },
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;
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;
//
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())
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();
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";
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:
///
string font_norm;
///
+ string font_norm_menu;
+ ///
unsigned int autosave;
///
string fax_command;
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;
///
*/
class LyXScreen {
public:
+
+ enum Cursor_Shape {
+ ///
+ BAR_SHAPE,
+ ///
+ L_SHAPE,
+ ///
+ REVERSED_L_SHAPE
+ };
+
///
LyXScreen(WorkArea &, LyXText * text_ptr);
///
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);
///
NEED_VERY_LITTLE_REFRESH
};
+ enum Letter_Form {
+ FORM_ISOLATED,
+ FORM_INITIAL,
+ FORM_MEDIAL,
+ FORM_FINAL
+ };
+
/// points to Buffer.params
BufferParams * parameters;
/// points to Buffer
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
*/
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()
{
}
}
+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
{
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();
}
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:
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();
}
#include "lyxrow.h"
#include "Painter.h"
#include "WorkArea.h"
+#include "bufferparams.h"
using std::max;
using std::min;
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);
}
}
}
-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,
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;
}
// 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",
// 27 times in the object file. (Asger)
///
-extern char const * tex_babel[];
+//extern char const * tex_babel[];
///
extern char const * tex_graphics[];
#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
// 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)) {
// 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;
(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;
}
// 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);
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;
}
* 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;
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;
}
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;
}
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 */
}
-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
} 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) << '.'
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) << '.'
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
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)
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);
}