From 146b245e5cad0f430b753249bbd2dc092c2147f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 10 Jul 2000 10:31:34 +0000 Subject: [PATCH] three patches from Dekel git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@870 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 20 ++++++++++++++++++++ src/WorkArea.C | 9 ++++----- src/text.C | 29 +++++++++++++++-------------- src/text2.C | 32 +++++++++++++++++++------------- 4 files changed, 58 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e1465a6cd..749cd80960 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2000-07-08 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-07-08 Dekel Tsur + + * src/WorkArea.C (request_clipboard_cb): Set clipboard_read to + true when clipboard is empty. + +2000-07-08 Dekel Tsur + + * text.C (Backspace): Prevent rebreaking of a row if it is the last + row of the paragraph. + (SetHeightOfRow): Call to PrepareToPrint with 7th argument = false + to prevent calculation of bidi tables + 2000-07-07 Juergen Vigna * src/screen.C (ToggleSelection): added y_offset and x_offset diff --git a/src/WorkArea.C b/src/WorkArea.C index d261fed540..0be0fc9f18 100644 --- a/src/WorkArea.C +++ b/src/WorkArea.C @@ -384,12 +384,11 @@ int request_clipboard_cb(FL_OBJECT * /*ob*/, long /*type*/, void const * data, long size) { clipboard_selection.erase(); - if (size == 0) return 0; // no selection - - clipboard_selection.reserve(size); - for (int i = 0; i < size; ++i) { + + if (size > 0) + clipboard_selection.reserve(size); + for (int i = 0; i < size; ++i) clipboard_selection += static_cast(data)[i]; - } clipboard_read = true; return 0; } diff --git a/src/text.C b/src/text.C index ae8594686e..92bae9605a 100644 --- a/src/text.C +++ b/src/text.C @@ -1647,7 +1647,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const height += row_ptr->height(); float x, dummy; - PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy); + PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false); row_ptr->width(maxwidth+x); if (inset_owner) { Row * r = firstrow; @@ -3688,18 +3688,15 @@ void LyXText::Backspace(BufferView * bview) } // break the cursor row again - z = NextBreakPoint(bview, row, workWidth(bview)); - - if (z != RowLast(row) || - (row->next() && row->next()->par() == row->par() && - RowLast(row) == row->par()->Last() - 1)){ + if (row->next() && row->next()->par() == row->par() && + (RowLast(row) == row->par()->Last() - 1 || + NextBreakPoint(bview, row, workWidth(bview)) != RowLast(row))) { /* it can happen that a paragraph loses one row * without a real breakup. This is when a word * is to long to be broken. Well, I don t care this * hack ;-) */ - if (row->next() && row->next()->par() == row->par() && - RowLast(row) == row->par()->Last() - 1) + if (RowLast(row) == row->par()->Last() - 1) RemoveRow(row->next()); refresh_y = y; @@ -3710,10 +3707,7 @@ void LyXText::Backspace(BufferView * bview) SetCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary()); // cursor MUST be in row now - if (row->next() && row->next()->par() == row->par()) - need_break_row = row->next(); - else - need_break_row = 0; + need_break_row = row->next(); } else { // set the dimensions of the row row->fill(Fill(bview, row, workWidth(bview))); @@ -3734,9 +3728,9 @@ void LyXText::Backspace(BufferView * bview) lastpos = cursor.par()->Last(); if (cursor.pos() == lastpos) { - SetCurrentFont(bview); if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) != cursor.boundary()) SetCursor(bview, cursor.par(), cursor.pos(), false, !cursor.boundary()); + SetCurrentFont(bview); } // check, wether the last characters font has changed. @@ -4764,14 +4758,21 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x, } #endif - if (vc > last + 1) // This shouldn't happen. vc = last + 1; boundary = false; + bool lastrow = (!row->next() || row->next()->par() != row->par()); + bool rtl = (lastrow) + ? row->par()->isRightToLeftPar(bview->buffer()->params) + : false; if (row->pos() > last) // Row is empty? c = row->pos(); + else if (lastrow && + ( (rtl && vc == row->pos()&& x < tmpx - 5) || + (!rtl && vc == last + 1 && x > tmpx + 5) )) + c = last + 1; else if (vc == row->pos() || (row->par()->table && vc <= last && row->par()->IsNewline(vc-1)) ) { diff --git a/src/text2.C b/src/text2.C index 0503f5f2b3..8fb50ea6e8 100644 --- a/src/text2.C +++ b/src/text2.C @@ -40,6 +40,7 @@ #include "Painter.h" #include "font.h" #include "debug.h" +#include "lyxrc.h" //#define USE_OLD_CUT_AND_PASTE 1 @@ -2867,6 +2868,15 @@ void LyXText::SetCurrentFont(BufferView * bview) const current_font = cursor.par()->GetFontSettings(bview->buffer()->params, pos); real_current_font = GetFont(bview->buffer(), cursor.par(), pos); + + if (cursor.pos() == cursor.par()->Last() && + IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) && + !cursor.boundary()) { + Language const * lang = + cursor.par()->getParLanguage(bview->buffer()->params); + current_font.setLanguage(lang); + real_current_font.setLanguage(lang); + } } @@ -2934,10 +2944,7 @@ void LyXText::CursorLeftIntern(BufferView * bview, bool internal) const SetCursor(bview, 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(bview, par, pos); - if (IsBoundary(bview->buffer(), par, pos)) - SetCursor(bview, par, pos, false, true); + SetCursor(bview, par, par->Last()); } } @@ -2959,15 +2966,14 @@ void LyXText::CursorRight(BufferView * bview, bool internal) const void LyXText::CursorRightIntern(BufferView * bview, bool internal) const { - if (cursor.pos() < cursor.par()->Last()) { - if (!internal && cursor.boundary() && - (!cursor.par()->table || !cursor.par()->IsNewline(cursor.pos()))) - SetCursor(bview, cursor.par(), cursor.pos(), true, false); - else { - SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false); - if (!internal && IsBoundary(bview->buffer(), cursor.par(), cursor.pos())) - SetCursor(bview, cursor.par(), cursor.pos(), true, true); - } + if (!internal && cursor.boundary() && + (!cursor.par()->table || !cursor.par()->IsNewline(cursor.pos()))) + SetCursor(bview, cursor.par(), cursor.pos(), true, false); + else if (cursor.pos() < cursor.par()->Last()) { + SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false); + if (!internal && + IsBoundary(bview->buffer(), cursor.par(), cursor.pos())) + SetCursor(bview, cursor.par(), cursor.pos(), true, true); } else if (cursor.par()->Next()) SetCursor(bview, cursor.par()->Next(), 0); } -- 2.39.2