mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-08 10:11:21 +00:00
Bugfix patch from Dekel
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/lyx-1_1_5@1270 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
13394206d1
commit
fa4bef2dd2
34
ChangeLog
34
ChangeLog
@ -1,3 +1,37 @@
|
|||||||
|
2000-12-02 Dekel Tsur <dekelts@tau.ac.il>
|
||||||
|
|
||||||
|
* src/BufferView_pimpl.C (workAreaMotionNotify): Fixed mouse
|
||||||
|
movement in inset in RTL text.
|
||||||
|
(checkInsetHit): Fixed mouse movement in scrolled inset in RTL text.
|
||||||
|
(workAreaButtonRelease): Do not open a float when there is a selection.
|
||||||
|
|
||||||
|
* src/spellchecker.C (RunSpellChecker): Open all floats before
|
||||||
|
spellchecking.
|
||||||
|
|
||||||
|
* src/text.C (InsertChar): Consider "," as a part of a number
|
||||||
|
(for LTR numbers in RTL text code).
|
||||||
|
(IsBoundary): Fixed (and simplified).
|
||||||
|
(InsertChar): Recalculate cursor boundary.
|
||||||
|
(Backspace): Ditto.
|
||||||
|
|
||||||
|
2000-11-23 Dekel Tsur <dekelts@tau.ac.il>
|
||||||
|
|
||||||
|
* mathed/formula.C (LocalDispatch): Preserve the label when
|
||||||
|
changing from display math to eqnarray (however, the label
|
||||||
|
do not appear at the first line, as one might expects, but at the
|
||||||
|
second line).
|
||||||
|
(LocalDispatch): When inserting a label to a formula which already
|
||||||
|
have a label, the old label is used as default value.
|
||||||
|
Also, if the label is changed, then all references to the label
|
||||||
|
are changed.
|
||||||
|
|
||||||
|
* src/mathed/math_iter.C (setLabel): Allow to set the label
|
||||||
|
even if it is empty. This is needed to allow deletion of a label
|
||||||
|
in an eqnarray.
|
||||||
|
|
||||||
|
* src/BufferView2.C (ChangeRefsIfUnique): New method. Changes the
|
||||||
|
refernces only if the old label appears once in the document.
|
||||||
|
|
||||||
2000-12-06 Lars Gullik Bjønnes <larsbj@lyx.org>
|
2000-12-06 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||||
|
|
||||||
* src/lyx_cb.C (InsertAsciiFile): use a vector to temporary store
|
* src/lyx_cb.C (InsertAsciiFile): use a vector to temporary store
|
||||||
|
@ -226,6 +226,8 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
///
|
///
|
||||||
bool ChangeRefs(string const & from, string const & to);
|
bool ChangeRefs(string const & from, string const & to);
|
||||||
|
///
|
||||||
|
bool ChangeRefsIfUnique(string const & from, string const & to);
|
||||||
#ifdef XFORMS_CLIPBOARD
|
#ifdef XFORMS_CLIPBOARD
|
||||||
///
|
///
|
||||||
void pasteClipboard(bool asPara);
|
void pasteClipboard(bool asPara);
|
||||||
|
@ -39,6 +39,7 @@ using std::endl;
|
|||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::find;
|
using std::find;
|
||||||
|
using std::count;
|
||||||
|
|
||||||
// Inserts a file into current document
|
// Inserts a file into current document
|
||||||
bool BufferView::insertLyXFile(string const & filen)
|
bool BufferView::insertLyXFile(string const & filen)
|
||||||
@ -795,6 +796,16 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
|
||||||
|
{
|
||||||
|
// Check if the label 'from' appears more than once
|
||||||
|
vector<string> labels = buffer()->getLabelList();
|
||||||
|
if (count(labels.begin(), labels.end(), from) > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ChangeRefs(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
void BufferView::updateInset(Inset * inset, bool mark_dirty)
|
void BufferView::updateInset(Inset * inset, bool mark_dirty)
|
||||||
{
|
{
|
||||||
if (!inset)
|
if (!inset)
|
||||||
|
@ -505,9 +505,13 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
|
|||||||
// Check for inset locking
|
// Check for inset locking
|
||||||
if (bv_->the_locking_inset) {
|
if (bv_->the_locking_inset) {
|
||||||
LyXCursor cursor = bv_->text->cursor;
|
LyXCursor cursor = bv_->text->cursor;
|
||||||
|
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos);
|
||||||
|
int width = bv_->the_locking_inset->width(bv_->painter(), font);
|
||||||
|
int start_x = font.isVisibleRightToLeft()
|
||||||
|
? cursor.x - width : cursor.x;
|
||||||
bv_->the_locking_inset->
|
bv_->the_locking_inset->
|
||||||
InsetMotionNotify(bv_,
|
InsetMotionNotify(bv_,
|
||||||
x - cursor.x,
|
x - start_x,
|
||||||
y - cursor.y + screen->first,
|
y - cursor.y + screen->first,
|
||||||
state);
|
state);
|
||||||
return;
|
return;
|
||||||
@ -810,6 +814,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
|
|||||||
c = bv_->text->cursor.par->
|
c = bv_->text->cursor.par->
|
||||||
GetChar(bv_->text->cursor.pos);
|
GetChar(bv_->text->cursor.pos);
|
||||||
}
|
}
|
||||||
|
if(!bv_->text->selection)
|
||||||
if (c == LyXParagraph::META_FOOTNOTE
|
if (c == LyXParagraph::META_FOOTNOTE
|
||||||
|| c == LyXParagraph::META_MARGIN
|
|| c == LyXParagraph::META_MARGIN
|
||||||
|| c == LyXParagraph::META_FIG
|
|| c == LyXParagraph::META_FIG
|
||||||
@ -906,16 +911,10 @@ Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y,
|
|||||||
// Check whether the inset really was hit
|
// Check whether the inset really was hit
|
||||||
Inset * tmpinset = cursor.par->GetInset(cursor.pos);
|
Inset * tmpinset = cursor.par->GetInset(cursor.pos);
|
||||||
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos);
|
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos);
|
||||||
bool is_rtl = font.isVisibleRightToLeft();
|
int width = tmpinset->width(bv_->painter(), font);
|
||||||
int start_x, end_x;
|
int start_x = font.isVisibleRightToLeft()
|
||||||
|
? cursor.x - width : cursor.x;
|
||||||
if (is_rtl) {
|
int end_x = start_x + width;
|
||||||
start_x = cursor.x - tmpinset->width(bv_->painter(), font);
|
|
||||||
end_x = cursor.x;
|
|
||||||
} else {
|
|
||||||
start_x = cursor.x;
|
|
||||||
end_x = cursor.x + tmpinset->width(bv_->painter(), font);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x > start_x && x < end_x
|
if (x > start_x && x < end_x
|
||||||
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
|
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
|
||||||
@ -937,16 +936,12 @@ Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y,
|
|||||||
(cursor.par->GetInset(cursor.pos - 1)->Editable())) {
|
(cursor.par->GetInset(cursor.pos - 1)->Editable())) {
|
||||||
Inset * tmpinset = cursor.par->GetInset(cursor.pos-1);
|
Inset * tmpinset = cursor.par->GetInset(cursor.pos-1);
|
||||||
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos-1);
|
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos-1);
|
||||||
bool is_rtl = font.isVisibleRightToLeft();
|
|
||||||
int start_x, end_x;
|
|
||||||
|
|
||||||
if (!is_rtl) {
|
int width = tmpinset->width(bv_->painter(), font);
|
||||||
start_x = cursor.x - tmpinset->width(bv_->painter(), font);
|
int start_x = font.isVisibleRightToLeft()
|
||||||
end_x = cursor.x;
|
? cursor.x : cursor.x - width;
|
||||||
} else {
|
int end_x = start_x + width;
|
||||||
start_x = cursor.x;
|
|
||||||
end_x = cursor.x + tmpinset->width(bv_->painter(), font);
|
|
||||||
}
|
|
||||||
if (x > start_x && x < end_x
|
if (x > start_x && x < end_x
|
||||||
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
|
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
|
||||||
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
|
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
|
||||||
|
@ -60,7 +60,8 @@ void InsetLabel::Edit(BufferView * bv, int, int, unsigned int)
|
|||||||
if (!new_contents.empty() &&
|
if (!new_contents.empty() &&
|
||||||
contents != new_contents) {
|
contents != new_contents) {
|
||||||
bv->buffer()->markDirty();
|
bv->buffer()->markDirty();
|
||||||
bool flag = bv->ChangeRefs(contents,new_contents);
|
bool flag = bv->ChangeRefsIfUnique(contents,
|
||||||
|
new_contents);
|
||||||
contents = new_contents;
|
contents = new_contents;
|
||||||
bv->text->RedoParagraph();
|
bv->text->RedoParagraph();
|
||||||
if (flag) {
|
if (flag) {
|
||||||
|
@ -765,6 +765,10 @@ InsetFormula::LocalDispatch(BufferView * bv,
|
|||||||
case LFUN_BREAKLINE:
|
case LFUN_BREAKLINE:
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||||
mathcursor->Insert(' ', LM_TC_CR);
|
mathcursor->Insert(' ', LM_TC_CR);
|
||||||
|
if (!label.empty()) {
|
||||||
|
mathcursor->setLabel(label.c_str());
|
||||||
|
label.erase();
|
||||||
|
}
|
||||||
par = mathcursor->GetPar();
|
par = mathcursor->GetPar();
|
||||||
UpdateLocal(bv);
|
UpdateLocal(bv);
|
||||||
break;
|
break;
|
||||||
@ -1020,28 +1024,37 @@ InsetFormula::LocalDispatch(BufferView * bv,
|
|||||||
case LFUN_INSERT_LABEL:
|
case LFUN_INSERT_LABEL:
|
||||||
{
|
{
|
||||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||||
if (par->GetType() < LM_OT_PAR) break;
|
if (par->GetType() < LM_OT_PAR)
|
||||||
string lb = arg;
|
break;
|
||||||
if (lb.empty()) {
|
|
||||||
pair<bool, string>
|
string old_label = (par->GetType() == LM_OT_MPARN)
|
||||||
res = askForText(_("Enter new label to insert:"));
|
? mathcursor->getLabel() : label;
|
||||||
if (res.first) {
|
string new_label = arg;
|
||||||
lb = res.second;
|
if (new_label.empty()) {
|
||||||
}
|
pair<bool, string> res = old_label.empty()
|
||||||
|
? askForText(_("Enter new label to insert:"))
|
||||||
|
: askForText(_("Enter label:"), old_label);
|
||||||
|
if (!res.first)
|
||||||
|
break;
|
||||||
|
new_label = frontStrip(strip(res.second));
|
||||||
}
|
}
|
||||||
if (!lb.empty() && lb[0] > ' ') {
|
|
||||||
|
if (new_label == old_label)
|
||||||
|
break; // Nothing to do
|
||||||
|
|
||||||
|
if (!new_label.empty())
|
||||||
SetNumber(true);
|
SetNumber(true);
|
||||||
if (par->GetType() == LM_OT_MPARN) {
|
|
||||||
mathcursor->setLabel(lb.c_str());
|
if (!new_label.empty() && bv->ChangeRefsIfUnique(old_label, new_label))
|
||||||
// MathMatrixInset *mt = (MathMatrixInset*)par;
|
bv->redraw();
|
||||||
// mt->SetLabel(lb);
|
|
||||||
} else {
|
if (par->GetType() == LM_OT_MPARN)
|
||||||
//if (label.notEmpty()) delete label;
|
mathcursor->setLabel(new_label.c_str());
|
||||||
label = lb;
|
// MathMatrixInset *mt = (MathMatrixInset*)par;
|
||||||
}
|
// mt->SetLabel(new_label);
|
||||||
UpdateLocal(bv);
|
else
|
||||||
} else
|
label = new_label;
|
||||||
label.erase();
|
UpdateLocal(bv);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,10 @@ class MathedCursor {
|
|||||||
void setNumbered();
|
void setNumbered();
|
||||||
void setLabel(char const *);
|
void setLabel(char const *);
|
||||||
///
|
///
|
||||||
|
char const * getLabel() const {
|
||||||
|
return cursor->getLabel();
|
||||||
|
}
|
||||||
|
///
|
||||||
bool Limits();
|
bool Limits();
|
||||||
/// Set accent: if argument = 0 it's considered consumed
|
/// Set accent: if argument = 0 it's considered consumed
|
||||||
void setAccent(int ac = 0);
|
void setAccent(int ac = 0);
|
||||||
|
@ -219,6 +219,10 @@ class MathedXIter: public MathedIter {
|
|||||||
//@{
|
//@{
|
||||||
///
|
///
|
||||||
bool setLabel(char* label);
|
bool setLabel(char* label);
|
||||||
|
///
|
||||||
|
char const * getLabel() const {
|
||||||
|
return crow->getLabel();
|
||||||
|
}
|
||||||
///
|
///
|
||||||
bool setNumbered(bool);
|
bool setNumbered(bool);
|
||||||
//@}
|
//@}
|
||||||
|
@ -651,6 +651,12 @@ bool RunSpellChecker(BufferView * bv)
|
|||||||
int i, newvalue;
|
int i, newvalue;
|
||||||
FL_OBJECT * obj;
|
FL_OBJECT * obj;
|
||||||
|
|
||||||
|
#ifndef NEW_INSETS
|
||||||
|
// Open all floats
|
||||||
|
bv->allFloats(1, 0);
|
||||||
|
bv->allFloats(1, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
string tmp = (lyxrc.isp_use_alt_lang) ? lyxrc.isp_alt_lang : bv->buffer()->GetLanguage();
|
string tmp = (lyxrc.isp_use_alt_lang) ? lyxrc.isp_alt_lang : bv->buffer()->GetLanguage();
|
||||||
bool rtl = tmp == "hebrew" || tmp == "arabic";
|
bool rtl = tmp == "hebrew" || tmp == "arabic";
|
||||||
|
|
||||||
|
34
src/text.C
34
src/text.C
@ -434,12 +434,9 @@ bool LyXText::IsBoundary(LyXParagraph * par, LyXParagraph::size_type pos) const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool rtl = bidi_level(pos - 1) % 2;
|
bool rtl = bidi_level(pos - 1) % 2;
|
||||||
bool rtl2 = rtl;
|
bool rtl2 = bidi_InRange(pos)
|
||||||
if (pos == par->Last() ||
|
? bidi_level(pos) % 2
|
||||||
(par->table && par->IsNewline(pos)))
|
: par->isRightToLeftPar();
|
||||||
rtl2 = par->isRightToLeftPar();
|
|
||||||
else if (bidi_InRange(pos))
|
|
||||||
rtl2 = bidi_level(pos) % 2;
|
|
||||||
return rtl != rtl2;
|
return rtl != rtl2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,12 +447,9 @@ bool LyXText::IsBoundary(LyXParagraph * par, LyXParagraph::size_type pos,
|
|||||||
return false; // This is just for speedup
|
return false; // This is just for speedup
|
||||||
|
|
||||||
bool rtl = font.isVisibleRightToLeft();
|
bool rtl = font.isVisibleRightToLeft();
|
||||||
bool rtl2 = rtl;
|
bool rtl2 = bidi_InRange(pos)
|
||||||
if (pos == par->Last() ||
|
? bidi_level(pos) % 2
|
||||||
(par->table && par->IsNewline(pos)))
|
: par->isRightToLeftPar();
|
||||||
rtl2 = par->isRightToLeftPar();
|
|
||||||
else if (bidi_InRange(pos))
|
|
||||||
rtl2 = bidi_level(pos) % 2;
|
|
||||||
return rtl != rtl2;
|
return rtl != rtl2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2666,7 +2660,7 @@ void LyXText::InsertChar(char c)
|
|||||||
if (lyxrc.auto_number) {
|
if (lyxrc.auto_number) {
|
||||||
if (current_font.number() == LyXFont::ON) {
|
if (current_font.number() == LyXFont::ON) {
|
||||||
if (!isdigit(c) && !strchr("+-/*", c) &&
|
if (!isdigit(c) && !strchr("+-/*", c) &&
|
||||||
!(strchr(".",c) &&
|
!(strchr(".,",c) &&
|
||||||
cursor.pos >= 1 && cursor.pos < cursor.par->size() &&
|
cursor.pos >= 1 && cursor.pos < cursor.par->size() &&
|
||||||
GetFont(cursor.par, cursor.pos).number() == LyXFont::ON &&
|
GetFont(cursor.par, cursor.pos).number() == LyXFont::ON &&
|
||||||
GetFont(cursor.par, cursor.pos-1).number() == LyXFont::ON)
|
GetFont(cursor.par, cursor.pos-1).number() == LyXFont::ON)
|
||||||
@ -2685,7 +2679,7 @@ void LyXText::InsertChar(char c)
|
|||||||
) {
|
) {
|
||||||
SetCharFont(cursor.par, cursor.pos - 1,
|
SetCharFont(cursor.par, cursor.pos - 1,
|
||||||
current_font);
|
current_font);
|
||||||
} else if (strchr(".", c) &&
|
} else if (strchr(".,", c) &&
|
||||||
cursor.pos >= 2 &&
|
cursor.pos >= 2 &&
|
||||||
GetFont(cursor.par, cursor.pos-2).number() == LyXFont::ON) {
|
GetFont(cursor.par, cursor.pos-2).number() == LyXFont::ON) {
|
||||||
SetCharFont(cursor.par, cursor.pos - 1,
|
SetCharFont(cursor.par, cursor.pos - 1,
|
||||||
@ -2847,6 +2841,10 @@ void LyXText::InsertChar(char c)
|
|||||||
current_font = rawtmpfont;
|
current_font = rawtmpfont;
|
||||||
real_current_font = realtmpfont;
|
real_current_font = realtmpfont;
|
||||||
SetCursor(cursor.par, cursor.pos + 1, false, cursor.boundary);
|
SetCursor(cursor.par, cursor.pos + 1, false, cursor.boundary);
|
||||||
|
if (IsBoundary(cursor.par, cursor.pos) != cursor.boundary)
|
||||||
|
SetCursor(cursor.par, cursor.pos, false,
|
||||||
|
!cursor.boundary);
|
||||||
|
|
||||||
if (row->next && row->next->par == row->par)
|
if (row->next && row->next->par == row->par)
|
||||||
need_break_row = row->next;
|
need_break_row = row->next;
|
||||||
else
|
else
|
||||||
@ -3734,12 +3732,12 @@ void LyXText::Backspace()
|
|||||||
// current_font = rawtmpfont;
|
// current_font = rawtmpfont;
|
||||||
// real_current_font = realtmpfont;
|
// real_current_font = realtmpfont;
|
||||||
|
|
||||||
|
if (IsBoundary(cursor.par, cursor.pos) != cursor.boundary)
|
||||||
|
SetCursor(cursor.par, cursor.pos, false, !cursor.boundary);
|
||||||
|
|
||||||
lastpos = cursor.par->Last();
|
lastpos = cursor.par->Last();
|
||||||
if (cursor.pos == lastpos) {
|
if (cursor.pos == lastpos)
|
||||||
if (IsBoundary(cursor.par, cursor.pos) != cursor.boundary)
|
|
||||||
SetCursor(cursor.par, cursor.pos, false, !cursor.boundary);
|
|
||||||
SetCurrentFont();
|
SetCurrentFont();
|
||||||
}
|
|
||||||
|
|
||||||
// check, wether the last characters font has changed.
|
// check, wether the last characters font has changed.
|
||||||
if (rawparfont !=
|
if (rawparfont !=
|
||||||
|
Loading…
Reference in New Issue
Block a user