From 574031d6891305725b4d4a1834e7111fc2f51014 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 11 Dec 2001 14:33:52 +0000 Subject: [PATCH] keep selection after font change (John), fix positionning of error insets after environments (Ben), fix drawing of negative lengths and deletion of double spaces in single paragraph (me) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3188 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 20 ++++++++++++++++++++ src/buffer.C | 1 + src/paragraph.C | 1 + src/text.C | 19 +++++++++++-------- src/text2.C | 28 +++++++++++++++------------- 5 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0a46dbf5be..d564c506b7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2001-12-11 Ben Stanley + + * paragraph.C: fixed missing line number count when exporting + Environments to LaTeX file + + * buffer.C: added informational message for checking line numbers. + +2001-12-11 Jean-Marc Lasgouttes + + * text2.C (deleteEmptyParagraphMechanism): if there is only one + paragraph, do the 'double space' part, but not the 'empty + paragraph' one. + + * text.C (workWidth): small optimization + (getLengthMarkerHeight): use minimal size for negative lengths. + 2001-12-11 Dekel Tsur * lyxfont.C (GUIFamilyNames): Fix GUIFamilyNames array @@ -9,6 +25,10 @@ * FontLoader.C: * lyxfont.[Ch]: support for fraktur font used by \mathfrak +2001-12-06 John Levon + + * text2.C: keep selection on a setFont() + 2001-12-06 John Levon * lyx_cb.C: another bv->text misuse, from insert label diff --git a/src/buffer.C b/src/buffer.C index 48b3a755c0..95de936940 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2449,6 +2449,7 @@ void Buffer::makeLaTeXFile(string const & fname, } lyxerr[Debug::INFO] << "Finished making latex file." << endl; + lyxerr[Debug::INFO] << "Row count was " << texrow.rows()-1 << "." << endl; } diff --git a/src/paragraph.C b/src/paragraph.C index 2a414c3134..94662b1424 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1830,6 +1830,7 @@ Paragraph * Paragraph::TeXEnvironment(Buffer const * buf, if (style.isEnvironment()) { os << "\\end{" << style.latexname() << "}\n"; + texrow.newline(); } lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl; diff --git a/src/text.C b/src/text.C index 3ff2676f67..059ed2f8b0 100644 --- a/src/text.C +++ b/src/text.C @@ -72,8 +72,8 @@ int LyXText::workWidth(BufferView * bview, Inset * inset) const pos_type pos = 0; Buffer::inset_iterator it = bview->buffer()->inset_iterator_begin(); - - for (; it != bview->buffer()->inset_iterator_end(); ++it) { + Buffer::inset_iterator end = bview->buffer()->inset_iterator_end(); + for ( ; it != end; ++it) { if (*it == inset) { par = it.getPar(); pos = it.getPos(); @@ -3160,12 +3160,12 @@ void LyXText::paintRowDepthBar(DrawRowParams & p) int LyXText::getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const { - if (vsp.kind() != VSpace::LENGTH) { - return int(vsp.inPixels(bv)); - } - - int const space_size = int(vsp.inPixels(bv)); int const arrow_size = 4; + int const space_size = int(vsp.inPixels(bv)); + + if (vsp.kind() != VSpace::LENGTH) { + return space_size; + } LyXFont font; font.decSize(); @@ -3173,7 +3173,10 @@ int LyXText::getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const lyxfont::maxAscent(font) + lyxfont::maxDescent(font)); - return std::max(min_size, space_size); + if (vsp.length().len().value() < 0.0) + return min_size; + else + return std::max(min_size, space_size); } diff --git a/src/text2.C b/src/text2.C index 4ddf68cae9..4ddfcffa2c 100644 --- a/src/text2.C +++ b/src/text2.C @@ -790,11 +790,11 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall) redoParagraphs(bview, selection.start, selection.end.par()->next()); // we have to reset the selection, because the - // geometry could have changed + // geometry could have changed, but we keep + // it for user convenience setCursor(bview, selection.start.par(), selection.start.pos()); selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); - clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true, tmpcursor.boundary()); @@ -874,7 +874,7 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, y -= tmprow->height(); } } - + // we can set the refreshing parameters now status(bview, LyXText::NEED_MORE_REFRESH); refresh_y = y; @@ -888,11 +888,12 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, tmppar = 0; while (tmppar != endpar) { removeRow(tmprow->next()); - if (tmprow->next()) + if (tmprow->next()) { tmppar = tmprow->next()->par(); - else + } else { tmppar = 0; - } + } + } // remove the first one tmprow2 = tmprow; /* this is because tmprow->previous() @@ -2369,17 +2370,13 @@ void LyXText::fixCursorAfterDelete(BufferView * bview, void LyXText::deleteEmptyParagraphMechanism(BufferView * bview, LyXCursor const & old_cursor) const { - // don't delete anything if this is the ONLY paragraph! - if (!old_cursor.par()->next() && !old_cursor.par()->previous()) - return; - // Would be wrong to delete anything if we have a selection. if (selection.set()) return; // We allow all kinds of "mumbo-jumbo" when freespacing. if (textclasslist.Style(bview->buffer()->params.textclass, - old_cursor.par()->getLayout()).free_spacing || - old_cursor.par()->isFreeSpacing()) + old_cursor.par()->getLayout()).free_spacing + || old_cursor.par()->isFreeSpacing()) { return; } @@ -2410,7 +2407,8 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview, // MISSING // If the pos around the old_cursor were spaces, delete one of them. - if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) { + if (old_cursor.par() != cursor.par() + || old_cursor.pos() != cursor.pos()) { // Only if the cursor has really moved if (old_cursor.pos() > 0 @@ -2442,6 +2440,10 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview, } } + // don't delete anything if this is the ONLY paragraph! + if (!old_cursor.par()->next() && !old_cursor.par()->previous()) + return; + // Do not delete empty paragraphs with keepempty set. if ((textclasslist.Style(bview->buffer()->params.textclass, old_cursor.par()->getLayout())).keepempty)