three patches from Dekel

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@870 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-07-10 10:31:34 +00:00
parent 38d06c587e
commit 146b245e5c
4 changed files with 58 additions and 32 deletions

View File

@ -1,3 +1,23 @@
2000-07-08 Dekel Tsur <dekel@math.tau.ac.il>
* 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 <dekel@math.tau.ac.il>
* src/WorkArea.C (request_clipboard_cb): Set clipboard_read to
true when clipboard is empty.
2000-07-08 Dekel Tsur <dekel@math.tau.ac.il>
* 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 <jug@sad.it> 2000-07-07 Juergen Vigna <jug@sad.it>
* src/screen.C (ToggleSelection): added y_offset and x_offset * src/screen.C (ToggleSelection): added y_offset and x_offset

View File

@ -384,12 +384,11 @@ int request_clipboard_cb(FL_OBJECT * /*ob*/, long /*type*/,
void const * data, long size) void const * data, long size)
{ {
clipboard_selection.erase(); clipboard_selection.erase();
if (size == 0) return 0; // no selection
if (size > 0)
clipboard_selection.reserve(size); clipboard_selection.reserve(size);
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i)
clipboard_selection += static_cast<char const *>(data)[i]; clipboard_selection += static_cast<char const *>(data)[i];
}
clipboard_read = true; clipboard_read = true;
return 0; return 0;
} }

View File

@ -1647,7 +1647,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
height += row_ptr->height(); height += row_ptr->height();
float x, dummy; 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); row_ptr->width(maxwidth+x);
if (inset_owner) { if (inset_owner) {
Row * r = firstrow; Row * r = firstrow;
@ -3688,18 +3688,15 @@ void LyXText::Backspace(BufferView * bview)
} }
// break the cursor row again // break the cursor row again
z = NextBreakPoint(bview, row, workWidth(bview)); if (row->next() && row->next()->par() == row->par() &&
(RowLast(row) == row->par()->Last() - 1 ||
if (z != RowLast(row) || NextBreakPoint(bview, row, workWidth(bview)) != RowLast(row))) {
(row->next() && row->next()->par() == row->par() &&
RowLast(row) == row->par()->Last() - 1)){
/* it can happen that a paragraph loses one row /* it can happen that a paragraph loses one row
* without a real breakup. This is when a word * without a real breakup. This is when a word
* is to long to be broken. Well, I don t care this * is to long to be broken. Well, I don t care this
* hack ;-) */ * hack ;-) */
if (row->next() && row->next()->par() == row->par() && if (RowLast(row) == row->par()->Last() - 1)
RowLast(row) == row->par()->Last() - 1)
RemoveRow(row->next()); RemoveRow(row->next());
refresh_y = y; refresh_y = y;
@ -3710,10 +3707,7 @@ void LyXText::Backspace(BufferView * bview)
SetCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary()); SetCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
// cursor MUST be in row now // cursor MUST be in row now
if (row->next() && row->next()->par() == row->par()) need_break_row = row->next();
need_break_row = row->next();
else
need_break_row = 0;
} else { } else {
// set the dimensions of the row // set the dimensions of the row
row->fill(Fill(bview, row, workWidth(bview))); row->fill(Fill(bview, row, workWidth(bview)));
@ -3734,9 +3728,9 @@ void LyXText::Backspace(BufferView * bview)
lastpos = cursor.par()->Last(); lastpos = cursor.par()->Last();
if (cursor.pos() == lastpos) { if (cursor.pos() == lastpos) {
SetCurrentFont(bview);
if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) != cursor.boundary()) if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) != cursor.boundary())
SetCursor(bview, cursor.par(), cursor.pos(), false, !cursor.boundary()); SetCursor(bview, cursor.par(), cursor.pos(), false, !cursor.boundary());
SetCurrentFont(bview);
} }
// check, wether the last characters font has changed. // check, wether the last characters font has changed.
@ -4764,14 +4758,21 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x,
} }
#endif #endif
if (vc > last + 1) // This shouldn't happen. if (vc > last + 1) // This shouldn't happen.
vc = last + 1; vc = last + 1;
boundary = false; 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? if (row->pos() > last) // Row is empty?
c = row->pos(); 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() || else if (vc == row->pos() ||
(row->par()->table (row->par()->table
&& vc <= last && row->par()->IsNewline(vc-1)) ) { && vc <= last && row->par()->IsNewline(vc-1)) ) {

View File

@ -40,6 +40,7 @@
#include "Painter.h" #include "Painter.h"
#include "font.h" #include "font.h"
#include "debug.h" #include "debug.h"
#include "lyxrc.h"
//#define USE_OLD_CUT_AND_PASTE 1 //#define USE_OLD_CUT_AND_PASTE 1
@ -2867,6 +2868,15 @@ void LyXText::SetCurrentFont(BufferView * bview) const
current_font = current_font =
cursor.par()->GetFontSettings(bview->buffer()->params, pos); cursor.par()->GetFontSettings(bview->buffer()->params, pos);
real_current_font = GetFont(bview->buffer(), cursor.par(), 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); SetCursor(bview, cursor.par(), cursor.pos() + 1, true, true);
} else if (cursor.par()->Previous()) { // steps into the above paragraph. } else if (cursor.par()->Previous()) { // steps into the above paragraph.
LyXParagraph * par = cursor.par()->Previous(); LyXParagraph * par = cursor.par()->Previous();
LyXParagraph::size_type pos = par->Last(); SetCursor(bview, par, par->Last());
SetCursor(bview, par, pos);
if (IsBoundary(bview->buffer(), par, pos))
SetCursor(bview, par, pos, false, true);
} }
} }
@ -2959,15 +2966,14 @@ void LyXText::CursorRight(BufferView * bview, bool internal) const
void LyXText::CursorRightIntern(BufferView * bview, bool internal) const void LyXText::CursorRightIntern(BufferView * bview, bool internal) const
{ {
if (cursor.pos() < cursor.par()->Last()) { if (!internal && cursor.boundary() &&
if (!internal && cursor.boundary() && (!cursor.par()->table || !cursor.par()->IsNewline(cursor.pos())))
(!cursor.par()->table || !cursor.par()->IsNewline(cursor.pos()))) SetCursor(bview, cursor.par(), cursor.pos(), true, false);
SetCursor(bview, cursor.par(), cursor.pos(), true, false); else if (cursor.pos() < cursor.par()->Last()) {
else { SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false);
SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false); if (!internal &&
if (!internal && IsBoundary(bview->buffer(), cursor.par(), cursor.pos())) IsBoundary(bview->buffer(), cursor.par(), cursor.pos()))
SetCursor(bview, cursor.par(), cursor.pos(), true, true); SetCursor(bview, cursor.par(), cursor.pos(), true, true);
}
} else if (cursor.par()->Next()) } else if (cursor.par()->Next())
SetCursor(bview, cursor.par()->Next(), 0); SetCursor(bview, cursor.par()->Next(), 0);
} }