computation. Please test and tell me if there are more problems you see.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@683
a592a061-630c-0410-9148-
cb99ea01b6c8
+2000-04-20 Juergen Vigna <jug@sad.it>
+
+ * src/insets/insettext.C (cutSelection):
+ (copySelection): Fixed with selection from right to left.
+ (draw): now the rows are not recalculated at every draw.
+ (computeTextRows): for now reset the inset-owner here (this is
+ important for an undo or copy where the inset-owner is not set
+ automatically!)
+
+ * src/BufferView_pimpl.C (workAreaMotionNotify): when passing the
+ motion to the_locking_inset screen->first was forgotten, this was
+ not important till we got multiline insets.
+
2000-04-19 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/mathed/formulamacro.C (Latex): remove CHECK comment, since
2000-04-19 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/mathed/formulamacro.C (Latex): remove CHECK comment, since
bv_->the_locking_inset->
InsetMotionNotify(bv_,
x - cursor.x,
bv_->the_locking_inset->
InsetMotionNotify(bv_,
x - cursor.x,
+ y - cursor.y + screen->first,
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
if (move_cursor && (tmpinset != bv_->the_locking_inset))
if (move_cursor && (tmpinset != bv_->the_locking_inset))
bv_->text->SetCursor(cursor.par,cursor.pos,true);
x = x - start_x;
// The origin of an inset is on the baseline
bv_->text->SetCursor(cursor.par,cursor.pos,true);
x = x - start_x;
// The origin of an inset is on the baseline
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
if (move_cursor && (tmpinset != bv_->the_locking_inset))
if (move_cursor && (tmpinset != bv_->the_locking_inset))
- bv_->text->SetCursor(cursor.par,cursor.pos,true);
+#endif
+ bv_->text->SetCursor(cursor.par,cursor.pos-1,true);
x = x - start_x;
// The origin of an inset is on the baseline
y = y_tmp - (bv_->text->cursor.y);
x = x - start_x;
// The origin of an inset is on the baseline
y = y_tmp - (bv_->text->cursor.y);
// in and some method of choosing beween them (based on the first few chars
// in the selection probably.) This would be a nice feature and quite
// easy to implement. (Lgb)
// in and some method of choosing beween them (based on the first few chars
// in the selection probably.) This would be a nice feature and quite
// easy to implement. (Lgb)
+//
+// Sure but I just cleaned up this code for now with the same functionality
+// as before. I also want to add a XClipboard function so that we can copy
+// text from LyX to some other X-application in the form of ASCII or in the
+// form of LaTeX (or Docbook depending on the document-class!). Think how nice
+// it could be to select a math-inset do a "Copy to X-Clipboard as LaTeX" and
+// then do a middle mouse button click in the application you want and have
+// the whole formula there in LaTeX-Code. (Jug)
static LyXParagraph * buf = 0;
static LyXTextClassList::size_type textclass = 0;
static LyXParagraph * buf = 0;
static LyXTextClassList::size_type textclass = 0;
static
void DeleteBuffer()
{
static
void DeleteBuffer()
{
- while (buf) {
- tmppar = buf;
- buf = buf->next;
- delete tmppar;
- }
- buf = 0;
+ while (buf) {
+ tmppar = buf;
+ buf = buf->next;
+ delete tmppar;
+ }
+ buf = 0;
void UpdatableInset::draw(Painter &, LyXFont const &,
void UpdatableInset::draw(Painter &, LyXFont const &,
- int baseline, float & x) const
+ int /* baseline */, float & x) const
{
if (scx) x += float(scx);
{
if (scx) x += float(scx);
- top_x = int(x);
- top_baseline = baseline;
+// ATTENTION: this is not good doing here
+// top_x = int(x);
+// top_baseline = baseline;
xpos = x;
UpdatableInset::draw(pain, f, baseline, x);
xpos = x;
UpdatableInset::draw(pain, f, baseline, x);
- top_x = int(x);
- top_baseline = baseline;
- computeTextRows(pain, x);
- computeBaselines(baseline);
+ if (init_inset || (baseline != top_baseline) || (top_x != int(x))) {
+ top_baseline = baseline;
+ if (init_inset || (top_x != int(x))) {
+ top_x = int(x);
+ computeTextRows(pain, x);
+ init_inset = false;
+ }
+ computeBaselines(baseline);
+ }
if (the_locking_inset && (cursor.pos == inset_pos)) {
resetPos(pain);
inset_x = cursor.x - top_x + drawTextXOffset;
if (the_locking_inset && (cursor.pos == inset_pos)) {
resetPos(pain);
inset_x = cursor.x - top_x + drawTextXOffset;
}
rows.back().asc = wordAscent;
rows.back().desc = wordDescent;
}
rows.back().asc = wordAscent;
rows.back().desc = wordDescent;
rows.push_back(row);
SingleHeight(pain, par, p, oasc, odesc);
insetWidth = max(insetWidth, owidth);
rows.push_back(row);
SingleHeight(pain, par, p, oasc, odesc);
insetWidth = max(insetWidth, owidth);
- Inset const * inset = 0;
if (((p + 1) < par->Last()) &&
(par->GetChar(p + 1)==LyXParagraph::META_INSET))
inset = par->GetInset(p + 1);
if (((p + 1) < par->Last()) &&
(par->GetChar(p + 1)==LyXParagraph::META_INSET))
inset = par->GetInset(p + 1);
- if (inset && inset->display()) {
- if (!is_first_word_in_row && (width >= maxWidth)) {
- // we have to split also the row above
+ if (inset) {
+ inset->setOwner(this);
+ if (inset->display()) {
+ if (!is_first_word_in_row && (width >= maxWidth)) {
+ // we have to split also the row above
+ rows.back().asc = oasc;
+ rows.back().desc = odesc;
+ row.pos = nwp;
+ rows.push_back(row);
+ oasc = wordAscent;
+ odesc = wordDescent;
+ insetWidth = max(insetWidth, owidth);
+ width = lastWordWidth;
+ lastWordWidth = 0;
+ } else {
+ oasc = max(oasc, wordAscent);
+ odesc = max(odesc, wordDescent);
+ }
rows.back().asc = oasc;
rows.back().desc = odesc;
rows.back().asc = oasc;
rows.back().desc = odesc;
- oasc = wordAscent;
- odesc = wordDescent;
- insetWidth = max(insetWidth, owidth);
- width = lastWordWidth;
- lastWordWidth = 0;
- } else {
- oasc = max(oasc, wordAscent);
- odesc = max(odesc, wordDescent);
+ SingleHeight(pain, par, p, asc, desc);
+ rows.back().asc = asc;
+ rows.back().desc = desc;
+ row.pos = nwp = p + 1;
+ rows.push_back(row);
+ oasc = odesc = width = lastWordWidth = 0;
+ is_first_word_in_row = true;
+ wordAscent = wordDescent = 0;
+ continue;
- rows.back().asc = oasc;
- rows.back().desc = odesc;
- row.pos = ++p;
- rows.push_back(row);
- SingleHeight(pain, par, p, asc, desc);
- rows.back().asc = asc;
- rows.back().desc = desc;
- row.pos = nwp = p + 1;
- rows.push_back(row);
- oasc = odesc = width = lastWordWidth = 0;
- is_first_word_in_row = true;
- wordAscent = wordDescent = 0;
- continue;
} else if (par->IsSeparator(p)) {
if (width >= maxWidth) {
if (is_first_word_in_row) {
} else if (par->IsSeparator(p)) {
if (width >= maxWidth) {
if (is_first_word_in_row) {
void InsetText::UpdateLocal(BufferView *bv, bool flag)
{
void InsetText::UpdateLocal(BufferView *bv, bool flag)
{
if (flag) {
computeTextRows(bv->painter(), xpos);
computeBaselines(top_baseline);
if (flag) {
computeTextRows(bv->painter(), xpos);
computeBaselines(top_baseline);
bv->updateInset(this, flag);
if (flag)
resetPos(bv->painter());
bv->updateInset(this, flag);
if (flag)
resetPos(bv->painter());
-#else
- init_inset = flag;
- bv->updateInset(this, flag);
-#endif
}
bool InsetText::cutSelection()
}
bool InsetText::cutSelection()
CutAndPaste cap;
LyXParagraph *endpar = par;
CutAndPaste cap;
LyXParagraph *endpar = par;
+ int start, end;
+ if (selection_start > selection_end) {
+ start = selection_end;
+ end = selection_start;
+ } else {
+ start = selection_start;
+ end = selection_end;
+ }
- return cap.cutSelection(par, &endpar, selection_start, selection_end,
- buffer->params.textclass);
+ return cap.cutSelection(par, &endpar, start, end,buffer->params.textclass);
}
bool InsetText::copySelection()
}
bool InsetText::copySelection()
- return cap.copySelection(par, par, selection_start, selection_end,
- buffer->params.textclass);
+ int start, end;
+ if (selection_start > selection_end) {
+ start = selection_end;
+ end = selection_start;
+ } else {
+ start = selection_start;
+ end = selection_end;
+ }
+ return cap.copySelection(par, par, start, end, buffer->params.textclass);
}
bool InsetText::pasteSelection()
}
bool InsetText::pasteSelection()