From ca3b6674beb02f46835c47b38101caab595b01e5 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 16 Oct 2000 13:32:02 +0000 Subject: [PATCH] Patches from Dekel (2) and a bit more git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/lyx-1_1_5@1124 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 22 ++++++++++++++++++++++ README | 10 ++++------ lib/lyxrc.example | 6 ++++++ src/lyx_gui.C | 28 +++++++++++++++++----------- src/lyxfunc.C | 7 +++++++ src/text.C | 30 ++++++++++++++++++++++++++---- src/text2.C | 33 ++++++++++++++++++--------------- 7 files changed, 100 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0336568b7d..8b5496de81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2000-10-14 Dekel Tsur + + * src/text.C (Backspace): Make sure that the row of the cursor is + rebreaked. + + * src/lyxfunc.C (Dispatch): Set CurrentState() in minibuffer after + insertion of a char. + + * src/lyx_gui.C (init): Prevent a crash when only one font from + menu/popup fonts is not found. + + * lib/lyxrc.example: Add an example for binding a key for language + switching. + +2000-10-13 Dekel Tsur + + * src/text.C (GetColumnNearX): Better behavior when a RTL + paragraph is ended by LTR text. + + * src/text2.C (SetCurrentFont,CursorLeftIntern,CursorRightIntern): + ditto. + 2000-10-13 Jean-Marc Lasgouttes * README: add a description of our numbering scheme diff --git a/README b/README index 83088c3019..55c704edfd 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Preamble: LyX versionning scheme +Preamble: LyX version scheme In September of 1999 the LyX Team decided that we could no longer successfully use the two strand development process @@ -17,9 +17,7 @@ Preamble: LyX versionning scheme * Establishing the foundations of GUI/system independence, - * Rearrangement of the directory structure, - - * Use of libtool, automake and autoconf. + * Rearrangement of the directory structure. Once the transition is over the 1.1 series should be very stable and we will then release 1.2.0. This new series will be @@ -28,9 +26,9 @@ Preamble: LyX versionning scheme occurring in branches of CVS and once the feature/modification has proved stable it will be merged into the main releases. - Versionning uses a continuous numbering scheme where odd or + LyX now uses a continuous numbering scheme where odd or even numbering is no longer significant. Prereleases are - labelled with a "pre" suffix and any fixes required between + labeled with a "pre" suffix and any fixes required between stable releases have a "fix" suffix. Thus there are three possible file names: diff --git a/lib/lyxrc.example b/lib/lyxrc.example index db9b6a1d6d..af99e02494 100644 --- a/lib/lyxrc.example +++ b/lib/lyxrc.example @@ -640,6 +640,12 @@ # Default is "true" #\mark_foreign_language false +# It is possible to bind keys for changing the language inside a document. +# For example, the following command will cause F12 to switch between French +# and English in a French document, and in a document of other language it will +# switch between that language and French. +#\bind "F12" "language french" + # # HEBREW SUPPORT SECTION #################################################### # diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 583abed617..a0b9df6e75 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -197,35 +197,41 @@ void LyXGUI::init() 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 + string boldfontname = lyxrc.menu_font_name + "-*-*-*-?-*-*-*-*-" + lyxrc.font_norm_menu; // "?" means "scale that font" - string popupfontname = lyxrc.popup_font_name + string fontname = lyxrc.popup_font_name + "-*-*-*-?-*-*-*-*-" + lyxrc.font_norm_menu; - int bold = fl_set_font_name(FL_BOLD_STYLE, menufontname.c_str()); - int normal = fl_set_font_name(FL_NORMAL_STYLE, popupfontname.c_str()); + int bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str()); + int normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str()); if (bold < 0) lyxerr << "Could not set menu font to " - << menufontname << endl; + << boldfontname << endl; if (normal < 0) lyxerr << "Could not set popup font to " - << popupfontname << endl; + << fontname << endl; if (bold < 0 && normal < 0) { lyxerr << "Using 'helvetica' font for menus" << endl; - bold = fl_set_font_name(FL_BOLD_STYLE, - "-*-helvetica-bold-r-*-*-*-?-*-*-*-*-iso8859-1"); - normal = fl_set_font_name(FL_NORMAL_STYLE, - "-*-helvetica-medium-r-*-*-*-?-*-*-*-*-iso8859-1"); + boldfontname = "-*-helvetica-bold-r-*-*-*-?-*-*-*-*-iso8859-1"; + fontname = "-*-helvetica-medium-r-*-*-*-?-*-*-*-*-iso8859-1"; + bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str()); + normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str()); + if (bold < 0 && normal < 0) { lyxerr << "Could not find helvetica font. Using 'fixed'." << endl; - normal = fl_set_font_name(FL_NORMAL_STYLE, "fixed"); + fl_set_font_name(FL_NORMAL_STYLE, "fixed"); + normal = bold = 0; } } + if (bold < 0) + fl_set_font_name(FL_BOLD_STYLE, fontname.c_str()); + else if (normal < 0) + fl_set_font_name(FL_NORMAL_STYLE, boldfontname.c_str()); // put here (after fl_initialize) to avoid segfault. Cannot be done // in setDefaults() (Matthias 140496) diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 0310cc99f9..cdcfe69ba9 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -2575,6 +2575,10 @@ string LyXFunc::Dispatch(int ac, owner->view()->text->sel_cursor = owner->view()->text->cursor; moveCursorUpdate(false); + + // current_font.number can change so we need to update + // the minibuffer + owner->getMiniBuffer()->Set(CurrentState(owner->view())); } break; @@ -2692,6 +2696,9 @@ string LyXFunc::Dispatch(int ac, owner->view()->text->sel_cursor = owner->view()->text->cursor; moveCursorUpdate(false); + // current_font.number can change so we need to update + // the minibuffer + owner->getMiniBuffer()->Set(CurrentState(owner->view())); return string(); } else { // why is an "Unknown action" with empty diff --git a/src/text.C b/src/text.C index 01dad21665..dd54132478 100644 --- a/src/text.C +++ b/src/text.C @@ -3701,9 +3701,20 @@ void LyXText::Backspace() BreakAgainOneRow(row); SetCursor(cursor.par, cursor.pos, false, cursor.boundary); - // cursor MUST be in row now + // will the cursor be in another row now? + if (row->next && row->next->par == row->par && + RowLast(row) <= cursor.pos) { + row = row->next; + BreakAgainOneRow(row); + } + + SetCursor(cursor.par, cursor.pos, + false, cursor.boundary); - need_break_row = row->next; + if (row->next && row->next->par == row->par) + need_break_row = row->next; + else + need_break_row = 0; } else { // set the dimensions of the row row->fill = Fill(row, paperwidth); @@ -3724,9 +3735,9 @@ void LyXText::Backspace() lastpos = cursor.par->Last(); if (cursor.pos == lastpos) { - SetCurrentFont(); if (IsBoundary(cursor.par, cursor.pos) != cursor.boundary) SetCursor(cursor.par, cursor.pos, false, !cursor.boundary); + SetCurrentFont(); } // check, wether the last characters font has changed. @@ -4666,7 +4677,7 @@ int LyXText::GetColumnNearX(Row * row, int & x, bool & boundary) const ++vc; } - if (vc > row->pos && (tmpx+last_tmpx)/2 > x) { + if ((tmpx+last_tmpx)/2 > x) { tmpx = last_tmpx; left_side = true; } @@ -4677,9 +4688,20 @@ int LyXText::GetColumnNearX(Row * row, int & x, bool & boundary) const vc = last+1; boundary = false; + bool lastrow = lyxrc.rtl_support // This is not needed, but gives + // some speedup if rtl_support=false + && (!row->next || row->next->par != row->par); + bool rtl = (lastrow) + ? row->par->isRightToLeftPar() + : false; // If lastrow is false, we don't need to compute + // the value of rtl. if (row->pos > last) // Row is empty? c = row->pos; + else if (lastrow && + ( ( rtl && left_side && vc == row->pos && x < tmpx - 5) || + (!rtl && !left_side && vc == last + 1 && x > tmpx + 5) )) + c = last + 1; else if (vc == row->pos || (row->par->table && vc <= last && row->par->IsNewline(vc-1)) ) { c = vis2log(vc); diff --git a/src/text2.C b/src/text2.C index b310dc6a3b..fcd617406f 100644 --- a/src/text2.C +++ b/src/text2.C @@ -3416,6 +3416,13 @@ void LyXText::SetCurrentFont() const current_font = cursor.par->GetFontSettings(pos); real_current_font = GetFont(cursor.par, pos); + + if (cursor.pos == cursor.par->Last() && + IsBoundary(cursor.par, cursor.pos) && !cursor.boundary) { + Language const * lang = cursor.par->getParLanguage(); + current_font.setLanguage(lang); + real_current_font.setLanguage(lang); + } } @@ -3475,10 +3482,7 @@ void LyXText::CursorLeftIntern(bool internal) const SetCursor(cursor.par, cursor.pos + 1, true, true); } else if (cursor.par->Previous()) { // steps into the above paragraph. LyXParagraph * par = cursor.par->Previous(); - LyXParagraph::size_type pos = par->Last(); - SetCursor(par, pos); - if (IsBoundary(par, pos)) - SetCursor(par, pos, false, true); + SetCursor(par, par->Last()); } } @@ -3498,17 +3502,16 @@ void LyXText::CursorRight(bool internal) const void LyXText::CursorRightIntern(bool internal) const { - if (cursor.pos < cursor.par->Last()) { - if (!internal && cursor.boundary && - (!cursor.par->table || !cursor.par->IsNewline(cursor.pos))) - SetCursor(cursor.par, cursor.pos, true, false); - else { - SetCursor(cursor.par, cursor.pos + 1, true, false); - if (!internal && IsBoundary(cursor.par, cursor.pos)) - SetCursor(cursor.par, cursor.pos, true, true); - } - } else if (cursor.par->Next()) - SetCursor(cursor.par->Next(), 0); + if (!internal && cursor.boundary && + (!cursor.par->table || !cursor.par->IsNewline(cursor.pos))) + SetCursor(cursor.par, cursor.pos, true, false); + else if (cursor.pos < cursor.par->Last()) { + SetCursor(cursor.par, cursor.pos + 1, true, false); + if (!internal && + IsBoundary(cursor.par, cursor.pos)) + SetCursor(cursor.par, cursor.pos, true, true); + } else if (cursor.par->Next()) + SetCursor(cursor.par->Next(), 0); }