weekend stuff less the chunk John "*strongly* disagrees with"

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7527 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-11 09:09:01 +00:00
parent 87d49485e9
commit 566e084f63
30 changed files with 215 additions and 645 deletions

View File

@ -29,7 +29,6 @@
#include "lyxfunc.h" #include "lyxfunc.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "lyxrow.h"
#include "lastfiles.h" #include "lastfiles.h"
#include "paragraph.h" #include "paragraph.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
@ -349,7 +348,7 @@ bool BufferView::Pimpl::fitCursor()
ret = screen().fitCursor(bv_->text, bv_); ret = screen().fitCursor(bv_->text, bv_);
} }
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); //dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
// We need to always update, in case we did a // We need to always update, in case we did a
// paste and we stayed anchored to a row, but // paste and we stayed anchored to a row, but
@ -371,7 +370,7 @@ void BufferView::Pimpl::redoCurrentBuffer()
} }
int BufferView::Pimpl::resizeCurrentBuffer() void BufferView::Pimpl::resizeCurrentBuffer()
{ {
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl; lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
@ -400,7 +399,6 @@ int BufferView::Pimpl::resizeCurrentBuffer()
selection = bv_->text->selection.set(); selection = bv_->text->selection.set();
mark_set = bv_->text->selection.mark(); mark_set = bv_->text->selection.mark();
the_locking_inset = bv_->theLockingInset(); the_locking_inset = bv_->theLockingInset();
resizeInsets(bv_);
bv_->text->fullRebreak(); bv_->text->fullRebreak();
update(); update();
} else { } else {
@ -418,12 +416,9 @@ int BufferView::Pimpl::resizeCurrentBuffer()
// bv_->text->owner(bv_); // bv_->text->owner(bv_);
if (lyxerr.debugging()) if (lyxerr.debugging())
textcache.show(lyxerr, "resizeCurrentBuffer"); textcache.show(lyxerr, "resizeCurrentBuffer");
resizeInsets(bv_);
} else { } else {
lyxerr << "no text in cache!" << endl; lyxerr << "no text in cache!" << endl;
bv_->text = new LyXText(bv_); bv_->text = new LyXText(bv_);
resizeInsets(bv_);
bv_->text->init(bv_); bv_->text->init(bv_);
} }
@ -461,8 +456,6 @@ int BufferView::Pimpl::resizeCurrentBuffer()
owner_->clearMessage(); owner_->clearMessage();
updateScrollbar(); updateScrollbar();
return 0;
} }
@ -617,13 +610,6 @@ void BufferView::Pimpl::workAreaResize()
if (lyxerr.debugging()) if (lyxerr.debugging())
textcache.show(lyxerr, "Expose delete all"); textcache.show(lyxerr, "Expose delete all");
textcache.clear(); textcache.clear();
// FIXME: this is already done in resizeCurrentBuffer() ??
resizeInsets(bv_);
} else if (heightChange) {
// fitCursor() ensures we don't jump back
// to the start of the document on vertical
// resize
fitCursor();
} }
} }
@ -633,13 +619,18 @@ void BufferView::Pimpl::workAreaResize()
// always make sure that the scrollbar is sane. // always make sure that the scrollbar is sane.
updateScrollbar(); updateScrollbar();
owner_->updateLayoutChoice(); owner_->updateLayoutChoice();
return;
} }
void BufferView::Pimpl::update() void BufferView::Pimpl::update()
{ {
lyxerr << "BufferView::update()" << endl; lyxerr << "BufferView::update()" << endl;
// fix cursor coordinate cache in case something went wrong
if (bv_->getLyXText()) {
// check needed to survive LyX startup
bv_->getLyXText()->redoCursor();
fitCursor();
}
screen().redraw(*bv_); screen().redraw(*bv_);
} }
@ -1229,15 +1220,13 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
case LFUN_PARAGRAPH_UPDATE: { case LFUN_PARAGRAPH_UPDATE: {
if (!bv_->owner()->getDialogs().visible("paragraph")) if (!bv_->owner()->getDialogs().visible("paragraph"))
break; break;
Paragraph const * par = &*bv_->getLyXText()->cursor.par(); Paragraph const & par = *bv_->getLyXText()->cursor.par();
if (!par)
break;
string data; string data;
params2string(*par, data); params2string(par, data);
// Will the paragraph accept changes from the dialog? // Will the paragraph accept changes from the dialog?
InsetOld * const inset = par->inInset(); InsetOld * const inset = par.inInset();
bool const accept = bool const accept =
!(inset && inset->forceDefaultParagraphs(inset)); !(inset && inset->forceDefaultParagraphs(inset));
@ -1389,6 +1378,7 @@ void BufferView::Pimpl::updateInset()
// this should not be needed, but it is... // this should not be needed, but it is...
bv_->text->redoParagraph(bv_->text->cursor.par()); bv_->text->redoParagraph(bv_->text->cursor.par());
update(); update();
updateScrollbar(); updateScrollbar();
} }

View File

@ -43,7 +43,7 @@ struct BufferView::Pimpl : public boost::signals::trackable {
/// ///
void redoCurrentBuffer(); void redoCurrentBuffer();
/// ///
int resizeCurrentBuffer(); void resizeCurrentBuffer();
/// ///
void update(); void update();
/** /**

View File

@ -1,4 +1,21 @@
2003-08-11 André Pönitz <poenitz@gmx.net>
* InsetList.[Ch]: remove resizeInsetsLyXText()
* lyxtext.h:
* text.C:
* text2.C:
* text3.C: merge insertParagraphs() and appendParagraph()
remove breakAgain(), update()
* BufferView_pimpl.[Ch]:
* bufferview_funcs.[Ch]:
* lyxfunc.C:
* paragraph.[Ch]:
* rowpainter.C:
* tabular.C: adjust after text & InsetList changes.
2003-08-08 André Pönitz <poenitz@gmx.net> 2003-08-08 André Pönitz <poenitz@gmx.net>
* text.C (insertChar, backspace): replace rowlist fiddling * text.C (insertChar, backspace): replace rowlist fiddling

View File

@ -176,18 +176,3 @@ void InsetList::deleteInsetsLyXText(BufferView * bv)
} }
} }
} }
void InsetList::resizeInsetsLyXText(BufferView * bv)
{
List::iterator it = list.begin();
List::iterator end = list.end();
for (; it != end; ++it) {
if (it->inset) {
if (it->inset->isTextInset()) {
static_cast<UpdatableInset*>
(it->inset)->resizeLyXText(bv, true);
}
}
}
}

View File

@ -54,8 +54,6 @@ public:
void decreasePosAfterPos(lyx::pos_type pos); void decreasePosAfterPos(lyx::pos_type pos);
/// ///
void deleteInsetsLyXText(BufferView * bv); void deleteInsetsLyXText(BufferView * bv);
///
void resizeInsetsLyXText(BufferView * bv);
private: private:
/// ///
List list; List list;

View File

@ -24,14 +24,13 @@ Box::Box(int x1_, int x2_, int y1_, int y2_) :
bool Box::contained(int x, int y) bool Box::contained(int x, int y)
{ {
return (x1 < x && x2 > x && return (x1 < x && x2 > x && y1 < y && y2 > y);
y1 < y && y2 > y);
} }
ostream & operator<<(ostream & o, Box const & b) ostream & operator<<(ostream & os, Box const & b)
{ {
return o << "x1,y1: " << b.x1 << ',' << b.y1 return os << "x1,y1: " << b.x1 << ',' << b.y1
<< " x2,y2: " << b.x2 << ',' << b.y2 << " x2,y2: " << b.x2 << ',' << b.y2
<< std::endl; << std::endl;
} }

View File

@ -50,16 +50,6 @@ bool toggleall(false);
namespace bv_funcs { namespace bv_funcs {
void resizeInsets(BufferView * bv)
{
ParagraphList & paragraphs = bv->buffer()->paragraphs;
/// then remove all LyXText in text-insets
std::for_each(paragraphs.begin(), paragraphs.end(),
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
}
// Set data using font and toggle // Set data using font and toggle
// If successful, returns true // If successful, returns true
bool font2string(LyXFont const & font, bool toggle, string & data) bool font2string(LyXFont const & font, bool toggle, string & data)
@ -219,6 +209,7 @@ void number(BufferView * bv)
toggleAndShow(bv, font); toggleAndShow(bv, font);
} }
void lang(BufferView * bv, string const & l) void lang(BufferView * bv, string const & l)
{ {
Language const * lang = languages.getLanguage(l); Language const * lang = languages.getLanguage(l);
@ -393,10 +384,6 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
} }
LyXText * text = bv->getLyXText(); LyXText * text = bv->getLyXText();
// FIXME: can this happen ??
if (!text)
return;
text->toggleFree(font, toggleall); text->toggleFree(font, toggleall);
bv->update(); bv->update();
@ -417,9 +404,8 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
void replaceSelection(LyXText * lt) void replaceSelection(LyXText * lt)
{ {
if (lt->selection.set()) { if (lt->selection.set()) {
lt->update();
lt->cutSelection(true, false); lt->cutSelection(true, false);
lt->update(); lt->bv()->update();
} }
} }

View File

@ -22,8 +22,6 @@ class LyXText;
namespace bv_funcs { namespace bv_funcs {
///
void resizeInsets(BufferView * bv);
/** Set \param data using \param font and \param toggle. /** Set \param data using \param font and \param toggle.
* If successful, returns true. * If successful, returns true.
*/ */

View File

@ -128,8 +128,7 @@ InsetOld * createInset(FuncRequest const & cmd)
if (icp.getContents().empty()) { if (icp.getContents().empty()) {
lv->getDialogs().show("index", data, 0); lv->getDialogs().show("index", data, 0);
} else { } else {
FuncRequest fr(bv, LFUN_INSET_APPLY, data); lv->dispatch(FuncRequest(bv, LFUN_INSET_APPLY, data));
lv->dispatch(fr);
} }
return 0; return 0;
} }
@ -151,8 +150,8 @@ InsetOld * createInset(FuncRequest const & cmd)
InsetCaption * inset = new InsetCaption(params); InsetCaption * inset = new InsetCaption(params);
inset->setOwner(bv->theLockingInset()); inset->setOwner(bv->theLockingInset());
inset->setAutoBreakRows(true); inset->setAutoBreakRows(true);
inset->setDrawFrame(0, InsetText::LOCKED); inset->setDrawFrame(InsetText::LOCKED);
inset->setFrameColor(0, LColor::captionframe); inset->setFrameColor(LColor::captionframe);
return inset; return inset;
} }
return 0; return 0;

View File

@ -20,7 +20,6 @@ using std::queue;
using std::vector; using std::vector;
int Graph::bfs_init(int s, bool clear_visited) int Graph::bfs_init(int s, bool clear_visited)
{ {
if (s < 0) if (s < 0)

View File

@ -1,4 +1,16 @@
2003-08-11 André Pönitz <poenitz@gmx.net>
* inset.h: remove resizeLyXText
* insetcaption.C:
* insetcollapsable.[Ch]:
* insetminipage.C:
* insettabular.[Ch]: adjust
* insettext.[Ch]: remove saveLyXTextState,
restoreLyXTextStat, sstate, reinitLyXText
2003-08-07 André Pönitz <poenitz@gmx.net> 2003-08-07 André Pönitz <poenitz@gmx.net>
* inset.[Ch]: move non-crucial functions out-of-line * inset.[Ch]: move non-crucial functions out-of-line

View File

@ -232,8 +232,6 @@ public:
bool recursive = false) const; bool recursive = false) const;
/// ///
virtual void deleteLyXText(BufferView *, bool = true) const {} virtual void deleteLyXText(BufferView *, bool = true) const {}
///
virtual void resizeLyXText(BufferView *, bool /*force*/= false) const {}
/// returns the actuall scroll-value /// returns the actuall scroll-value
virtual int scroll(bool recursive=true) const { virtual int scroll(bool recursive=true) const {
if (!recursive || !owner_) if (!recursive || !owner_)

View File

@ -36,8 +36,8 @@ InsetCaption::InsetCaption(BufferParams const & bp)
: InsetText(bp) : InsetText(bp)
{ {
setAutoBreakRows(true); setAutoBreakRows(true);
setDrawFrame(0, InsetText::LOCKED); setDrawFrame(InsetText::LOCKED);
setFrameColor(0, LColor::captionframe); setFrameColor(LColor::captionframe);
} }

View File

@ -49,12 +49,12 @@ InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
#if 0 #if 0
autocollapse(false), autocollapse(false),
#endif #endif
oldWidth(0), in_update(false), first_after_edit(false) in_update(false), first_after_edit(false)
{ {
inset.setOwner(this); inset.setOwner(this);
inset.setAutoBreakRows(true); inset.setAutoBreakRows(true);
inset.setDrawFrame(0, InsetText::ALWAYS); inset.setDrawFrame(InsetText::ALWAYS);
inset.setFrameColor(0, LColor::collapsableframe); inset.setFrameColor(LColor::collapsableframe);
setInsetName("Collapsable"); setInsetName("Collapsable");
} }
@ -66,7 +66,7 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
#if 0 #if 0
autocollapse(in.autocollapse), autocollapse(in.autocollapse),
#endif #endif
oldWidth(0), in_update(false), first_after_edit(false) in_update(false), first_after_edit(false)
{ {
inset.init(&(in.inset)); inset.init(&(in.inset));
inset.setOwner(this); inset.setOwner(this);
@ -243,6 +243,7 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
} }
bv->updateInset(); bv->updateInset();
bv->buffer()->markDirty(); bv->buffer()->markDirty();
lyxerr << "InsetCollapsable::lfunMouseRelease\n";
} else if (!collapsed_ && cmd.y > button_dim.y2) { } else if (!collapsed_ && cmd.y > button_dim.y2) {
ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED; ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED;
} }
@ -444,13 +445,6 @@ void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
} }
void InsetCollapsable::resizeLyXText(BufferView * bv, bool force) const
{
inset.resizeLyXText(bv, force);
oldWidth = width();
}
void InsetCollapsable::getLabelList(std::vector<string> & list) const void InsetCollapsable::getLabelList(std::vector<string> & list) const
{ {
inset.getLabelList(list); inset.getLabelList(list);

View File

@ -114,8 +114,6 @@ public:
/// ///
void deleteLyXText(BufferView *, bool recursive=true) const; void deleteLyXText(BufferView *, bool recursive=true) const;
/// ///
void resizeLyXText(BufferView *, bool force = false) const;
///
void getLabelList(std::vector<string> &) const; void getLabelList(std::vector<string> &) const;
/// ///
int scroll(bool recursive=true) const; int scroll(bool recursive=true) const;
@ -205,8 +203,6 @@ private:
/// ///
bool autocollapse; bool autocollapse;
#endif #endif
///
mutable int oldWidth;
/// ///
bool in_update; bool in_update;
/// ///

View File

@ -76,16 +76,7 @@ InsetMinipage::InsetMinipage(BufferParams const & bp)
#if 0 #if 0
setAutoCollapse(false); setAutoCollapse(false);
#endif #endif
inset.setFrameColor(LColor::blue);
#if 0
#ifdef WITH_WARNINGS
#warning Remove this color definitions before 1.2.0 final!
#endif
// just for experimentation :)
setBackgroundColor(LColor::green);
#endif
inset.setFrameColor(0, LColor::blue);
setInsetName("Minipage"); setInsetName("Minipage");
} }

View File

@ -45,7 +45,6 @@
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
#include <cstdlib> #include <cstdlib>
#include <map>
using namespace lyx::support; using namespace lyx::support;
@ -1650,10 +1649,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
// the insettext of the active cell (if any) // the insettext of the active cell (if any)
// until later (see InsetText::do_resize) // until later (see InsetText::do_resize)
unlockInsetInInset(bv, the_locking_inset); unlockInsetInInset(bv, the_locking_inset);
bv->update();
for (int i = 0; i < tabular.rows(); ++i)
tabular.getCellInset(i, column).resizeLyXText(bv);
updateLocal(bv);
} }
if (vallen.zero() if (vallen.zero()
@ -1677,10 +1673,6 @@ void InsetTabular::tabularFeatures(BufferView * bv,
// the insettext of the active cell (if any) // the insettext of the active cell (if any)
// until later (see InsetText::do_resize) // until later (see InsetText::do_resize)
unlockInsetInInset(bv, the_locking_inset); unlockInsetInInset(bv, the_locking_inset);
for (int i = 0; i < tabular.rows(); ++i)
tabular.getCellInset(i, column).resizeLyXText(bv);
updateLocal(bv); updateLocal(bv);
} }
} }
@ -1989,16 +1981,7 @@ bool InsetTabular::insetHit(BufferView *, int x, int) const
void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
{ {
resizeLyXText(bv, recursive); //resizeLyXText(bv, recursive);
}
void InsetTabular::resizeLyXText(BufferView * bv, bool force) const
{
if (force)
for (int i = 0; i < tabular.rows(); ++i)
for (int j = 0; j < tabular.columns(); ++j)
tabular.getCellInset(i, j).resizeLyXText(bv, true);
} }

View File

@ -140,8 +140,6 @@ public:
/// ///
void deleteLyXText(BufferView *, bool recursive = true) const; void deleteLyXText(BufferView *, bool recursive = true) const;
/// ///
void resizeLyXText(BufferView *, bool force = false) const;
///
void openLayoutDialog(BufferView *) const; void openLayoutDialog(BufferView *) const;
/// ///
bool showInsetDialog(BufferView *) const; bool showInsetDialog(BufferView *) const;

View File

@ -42,6 +42,7 @@
#include "rowpainter.h" #include "rowpainter.h"
#include "insetnewline.h" #include "insetnewline.h"
#include "metricsinfo.h" #include "metricsinfo.h"
#include "textcursor.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
@ -80,50 +81,6 @@ using lyx::pos_type;
using lyx::textclass_type; using lyx::textclass_type;
// we should get rid of these (Andre')
void InsetText::saveLyXTextState() const
{
// check if my paragraphs are still valid
ParagraphList::iterator it = const_cast<ParagraphList&>(paragraphs).begin();
ParagraphList::iterator end = const_cast<ParagraphList&>(paragraphs).end();
for (; it != end; ++it)
if (it == text_.cursor.par())
break;
if (it != end && text_.cursor.pos() <= it->size())
sstate = text_; // slicing intended
else
sstate.cursor.par(end);
}
void InsetText::restoreLyXTextState() const
{
if (sstate.cursor.par() == const_cast<ParagraphList&>(paragraphs).end())
return;
text_.selection.set(true);
// at this point just to avoid the DEPM when setting the cursor
text_.selection.mark(sstate.selection.mark());
if (sstate.selection.set()) {
text_.setCursor(sstate.selection.start.par(),
sstate.selection.start.pos(),
true, sstate.selection.start.boundary());
text_.selection.cursor = text_.cursor;
text_.setCursor(sstate.selection.end.par(), sstate.selection.end.pos(),
true, sstate.selection.end.boundary());
text_.setSelection();
text_.setCursor(sstate.cursor.par(), sstate.cursor.pos());
} else {
text_.setCursor(sstate.cursor.par(), sstate.cursor.pos(),
true, sstate.cursor.boundary());
text_.selection.cursor = text_.cursor;
text_.selection.set(false);
}
}
InsetText::InsetText(BufferParams const & bp) InsetText::InsetText(BufferParams const & bp)
: UpdatableInset(), text_(0, this) : UpdatableInset(), text_(0, this)
{ {
@ -162,8 +119,6 @@ void InsetText::init(InsetText const * ins)
for (; pit != end; ++pit) for (; pit != end; ++pit)
pit->setInsetOwner(this); pit->setInsetOwner(this);
reinitLyXText();
autoBreakRows = ins->autoBreakRows; autoBreakRows = ins->autoBreakRows;
drawFrame_ = ins->drawFrame_; drawFrame_ = ins->drawFrame_;
frame_color = ins->frame_color; frame_color = ins->frame_color;
@ -182,7 +137,6 @@ void InsetText::init(InsetText const * ins)
drawTextYOffset = 0; drawTextYOffset = 0;
locked = false; locked = false;
old_par = paragraphs.end(); old_par = paragraphs.end();
sstate.cursor.par(paragraphs.end());
in_insetAllowed = false; in_insetAllowed = false;
} }
@ -192,9 +146,8 @@ void InsetText::clear(bool just_mark_erased)
if (just_mark_erased) { if (just_mark_erased) {
ParagraphList::iterator it = paragraphs.begin(); ParagraphList::iterator it = paragraphs.begin();
ParagraphList::iterator end = paragraphs.end(); ParagraphList::iterator end = paragraphs.end();
for (; it != end; ++it) { for (; it != end; ++it)
it->markErased(); it->markErased();
}
return; return;
} }
@ -205,8 +158,6 @@ void InsetText::clear(bool just_mark_erased)
paragraphs.push_back(Paragraph()); paragraphs.push_back(Paragraph());
paragraphs.begin()->setInsetOwner(this); paragraphs.begin()->setInsetOwner(this);
paragraphs.begin()->layout(old_layout); paragraphs.begin()->layout(old_layout);
reinitLyXText();
} }
@ -385,7 +336,6 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
if (!autoBreakRows && paragraphs.size() > 1) if (!autoBreakRows && paragraphs.size() > 1)
collapseParagraphs(bv); collapseParagraphs(bv);
text_.partialRebreak();
if (!text_.selection.set()) if (!text_.selection.set())
text_.selection.cursor = text_.cursor; text_.selection.cursor = text_.cursor;
@ -1470,6 +1420,8 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
bool InsetText::checkAndActivateInset(BufferView * bv, bool front) bool InsetText::checkAndActivateInset(BufferView * bv, bool front)
{ {
if (cpos() == cpar()->size())
return false;
InsetOld * inset = cpar()->getInset(cpos()); InsetOld * inset = cpar()->getInset(cpos());
if (!isHighlyEditableInset(inset)) if (!isHighlyEditableInset(inset))
return false; return false;
@ -1534,7 +1486,6 @@ void InsetText::setText(string const & data, LyXFont const & font)
clear(false); clear(false);
for (unsigned int i = 0; i < data.length(); ++i) for (unsigned int i = 0; i < data.length(); ++i)
paragraphs.begin()->insertChar(i, data[i], font); paragraphs.begin()->insertChar(i, data[i], font);
reinitLyXText();
} }
@ -1548,21 +1499,15 @@ void InsetText::setAutoBreakRows(bool flag)
} }
void InsetText::setDrawFrame(BufferView * bv, DrawFrame how) void InsetText::setDrawFrame(DrawFrame how)
{ {
if (how != drawFrame_) {
drawFrame_ = how; drawFrame_ = how;
updateLocal(bv, false);
}
} }
void InsetText::setFrameColor(BufferView * bv, LColor::color col) void InsetText::setFrameColor(LColor::color col)
{ {
if (frame_color != col) {
frame_color = col; frame_color = col;
updateLocal(bv, false);
}
} }
@ -1638,9 +1583,15 @@ LyXText * InsetText::getLyXText(BufferView const * bv,
void InsetText::setViewCache(BufferView const * bv) const void InsetText::setViewCache(BufferView const * bv) const
{ {
if (bv) if (bv) {
if (bv != text_.bv_owner) {
lyxerr << "setting view cache from "
<< text_.bv_owner << " to " << bv << "\n";
text_.init(const_cast<BufferView *>(bv));
}
text_.bv_owner = const_cast<BufferView *>(bv); text_.bv_owner = const_cast<BufferView *>(bv);
} }
}
void InsetText::deleteLyXText(BufferView * bv, bool recursive) const void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
@ -1654,88 +1605,15 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
} }
void InsetText::resizeLyXText(BufferView * bv, bool /*force*/) const
{
if (paragraphs.size() == 1 && paragraphs.begin()->empty())
return;
if (!bv)
return;
Assert(bv);
setViewCache(bv);
for_each(const_cast<ParagraphList&>(paragraphs).begin(),
const_cast<ParagraphList&>(paragraphs).end(),
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
saveLyXTextState();
text_.init(bv);
restoreLyXTextState();
// seems to be unneeded
#if 1
if (the_locking_inset) {
inset_x = cix() - top_x + drawTextXOffset;
inset_y = ciy() + drawTextYOffset;
}
#endif
#if 0
text_.top_y(bv->screen().topCursorVisible(&text_));
if (!owner()) {
const_cast<InsetText*>(this)->updateLocal(bv, false);
// this will scroll the screen such that the cursor becomes visible
bv->updateScrollbar();
}
#endif
}
void InsetText::reinitLyXText() const
{
BufferView * bv = text_.bv_owner;
if (!bv)
return;
saveLyXTextState();
for_each(const_cast<ParagraphList&>(paragraphs).begin(),
const_cast<ParagraphList&>(paragraphs).end(),
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
text_.init(bv);
restoreLyXTextState();
if (the_locking_inset) {
inset_x = cix() - top_x + drawTextXOffset;
inset_y = ciy() + drawTextYOffset;
}
text_.top_y(bv->screen().topCursorVisible(&text_));
if (!owner()) {
// this will scroll the screen such that the cursor becomes visible
bv->updateScrollbar();
}
}
void InsetText::removeNewlines() void InsetText::removeNewlines()
{ {
bool changed = false;
ParagraphList::iterator it = paragraphs.begin(); ParagraphList::iterator it = paragraphs.begin();
ParagraphList::iterator end = paragraphs.end(); ParagraphList::iterator end = paragraphs.end();
for (; it != end; ++it) { for (; it != end; ++it)
for (int i = 0; i < it->size(); ++i) { for (int i = 0; i < it->size(); ++i)
if (it->isNewline(i)) { if (it->isNewline(i))
changed = true;
it->erase(i); it->erase(i);
} }
}
}
if (changed)
reinitLyXText();
}
int InsetText::scroll(bool recursive) const int InsetText::scroll(bool recursive) const
@ -1956,7 +1834,6 @@ void InsetText::collapseParagraphs(BufferView * bv)
mergeParagraph(bv->buffer()->params, paragraphs, first_par); mergeParagraph(bv->buffer()->params, paragraphs, first_par);
} }
reinitLyXText();
} }
@ -1981,8 +1858,6 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
ParagraphList::iterator pend = plist.end(); ParagraphList::iterator pend = plist.end();
for (; pit != pend; ++pit) for (; pit != pend; ++pit)
paragraphs.push_back(*pit); paragraphs.push_back(*pit);
reinitLyXText();
} }

View File

@ -13,7 +13,6 @@
#define INSETTEXT_H #define INSETTEXT_H
#include "updatableinset.h" #include "updatableinset.h"
#include "textcursor.h"
#include "LString.h" #include "LString.h"
#include "LColor.h" #include "LColor.h"
#include "ParagraphList.h" #include "ParagraphList.h"
@ -129,9 +128,9 @@ public:
/// ///
bool getAutoBreakRows() const { return autoBreakRows; } bool getAutoBreakRows() const { return autoBreakRows; }
/// ///
void setDrawFrame(BufferView *, DrawFrame); void setDrawFrame(DrawFrame);
/// ///
void setFrameColor(BufferView *, LColor::color); void setFrameColor(LColor::color);
/// ///
LyXText * getLyXText(BufferView const *, LyXText * getLyXText(BufferView const *,
bool const recursive = false) const; bool const recursive = false) const;
@ -140,8 +139,6 @@ public:
/// ///
void deleteLyXText(BufferView *, bool recursive = true) const; void deleteLyXText(BufferView *, bool recursive = true) const;
/// ///
void resizeLyXText(BufferView *, bool force = false) const;
///
bool showInsetDialog(BufferView *) const; bool showInsetDialog(BufferView *) const;
/// ///
void getLabelList(std::vector<string> &) const; void getLabelList(std::vector<string> &) const;
@ -279,10 +276,6 @@ private:
/// ///
void clearInset(BufferView *, int start_x, int baseline) const; void clearInset(BufferView *, int start_x, int baseline) const;
/// ///
void saveLyXTextState() const;
///
void restoreLyXTextState() const;
///
void collapseParagraphs(BufferView *); void collapseParagraphs(BufferView *);
/* Private structures and variables */ /* Private structures and variables */
@ -307,9 +300,6 @@ private:
/// ///
mutable ParagraphList::iterator old_par; mutable ParagraphList::iterator old_par;
/// some funny 'temporarily saved state'
mutable TextCursor sstate;
/// ///
// to remember old painted frame dimensions to clear it on the right spot! // to remember old painted frame dimensions to clear it on the right spot!
/// ///
@ -320,8 +310,6 @@ private:
int mouse_x; int mouse_x;
int mouse_y; int mouse_y;
public: public:
///
void reinitLyXText() const;
/// ///
mutable LyXText text_; mutable LyXText text_;
/// ///

View File

@ -13,7 +13,6 @@
#include "lyxfunc.h" #include "lyxfunc.h"
#include "version.h" #include "version.h"
#include "kbmap.h" #include "kbmap.h"
#include "lyxrow.h"
#include "bufferlist.h" #include "bufferlist.h"
#include "buffer.h" #include "buffer.h"
#include "buffer_funcs.h" #include "buffer_funcs.h"

View File

@ -152,8 +152,6 @@ public:
/// ///
void insertInset(InsetOld * inset); void insertInset(InsetOld * inset);
/// Completes the insertion with a rebreak
void partialRebreak();
/// a full rebreak of the whole text /// a full rebreak of the whole text
void fullRebreak(); void fullRebreak();
/// compute text metrics /// compute text metrics
@ -238,6 +236,8 @@ public:
WordLangTuple const selectNextWordToSpellcheck(float & value); WordLangTuple const selectNextWordToSpellcheck(float & value);
/// ///
void selectSelectedWord(); void selectSelectedWord();
/// re-computes the cached coordinates in the cursor
void redoCursor();
/// returns true if par was empty and was removed /// returns true if par was empty and was removed
bool setCursor(ParagraphList::iterator pit, bool setCursor(ParagraphList::iterator pit,
lyx::pos_type pos, lyx::pos_type pos,
@ -403,12 +403,6 @@ private:
void insertParagraph(ParagraphList::iterator pit, void insertParagraph(ParagraphList::iterator pit,
RowList::iterator rowit); RowList::iterator rowit);
/** appends the implizit specified paragraph behind the specified row,
* start at the implizit given position */
void appendParagraph(RowList::iterator rowit);
///
void breakAgain(RowList::iterator rit);
/// Calculate and set the height of the row /// Calculate and set the height of the row
void setHeightOfRow(RowList::iterator rit); void setHeightOfRow(RowList::iterator rit);
@ -424,8 +418,6 @@ public:
/** Updates all counters starting BEHIND the row. Changed paragraphs /** Updates all counters starting BEHIND the row. Changed paragraphs
* with a dynamic left margin will be rebroken. */ * with a dynamic left margin will be rebroken. */
void updateCounters(); void updateCounters();
///
void update();
/** /**
* Returns an inset if inset was hit, or 0 if not. * Returns an inset if inset was hit, or 0 if not.
* If hit, the coordinates are changed relative to the inset. * If hit, the coordinates are changed relative to the inset.

View File

@ -287,7 +287,8 @@ void Paragraph::insertInset(pos_type pos, InsetOld * inset)
} }
void Paragraph::insertInset(pos_type pos, InsetOld * inset, LyXFont const & font, Change change) void Paragraph::insertInset(pos_type pos, InsetOld * inset,
LyXFont const & font, Change change)
{ {
pimpl_->insertInset(pos, inset, font, change); pimpl_->insertInset(pos, inset, font, change);
} }
@ -1192,12 +1193,6 @@ void Paragraph::deleteInsetsLyXText(BufferView * bv)
} }
void Paragraph::resizeInsetsLyXText(BufferView * bv)
{
insetlist.resizeInsetsLyXText(bv);
}
void Paragraph::setContentsFromPar(Paragraph const & par) void Paragraph::setContentsFromPar(Paragraph const & par)
{ {
pimpl_->setContentsFromPar(par); pimpl_->setContentsFromPar(par);
@ -1355,7 +1350,7 @@ bool Paragraph::isFreeSpacing() const
return true; return true;
// for now we just need this, later should we need this in some // for now we just need this, later should we need this in some
// other way we can always add a function to InsetOld::() too. // other way we can always add a function to InsetOld too.
if (pimpl_->inset_owner && pimpl_->inset_owner->owner()) if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE; return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
return false; return false;

View File

@ -111,8 +111,6 @@ public:
void setInsetOwner(UpdatableInset * inset); void setInsetOwner(UpdatableInset * inset);
/// ///
void deleteInsetsLyXText(BufferView *); void deleteInsetsLyXText(BufferView *);
///
void resizeInsetsLyXText(BufferView *);
/// ///
lyx::pos_type size() const; lyx::pos_type size() const;

View File

@ -28,7 +28,6 @@
#include "language.h" #include "language.h"
#include "encoding.h" #include "encoding.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxrow.h"
#include "rowpainter.h" #include "rowpainter.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "lyxrow_funcs.h" #include "lyxrow_funcs.h"
@ -1099,6 +1098,7 @@ int paintRows(BufferView const & bv, LyXText const & text,
{ {
RowList::iterator end = text.rows().end(); RowList::iterator end = text.rows().end();
while (rit != end && yf < y2) { while (rit != end && yf < y2) {
//const_cast<LyXText &>(text).setHeightOfRow(rit);
paintRowsHelper(bv, text, rit, y + yo, xo, y + text.top_y()); paintRowsHelper(bv, text, rit, y + yo, xo, y + text.top_y());
y += rit->height(); y += rit->height();
yf += rit->height(); yf += rit->height();

View File

@ -392,7 +392,7 @@ void LyXTabular::init(BufferParams const & bp,
for (int i = 0; i < rows_; ++i) { for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) { for (int j = 0; j < columns_; ++j) {
cell_info[i][j].inset.setOwner(owner_); cell_info[i][j].inset.setOwner(owner_);
cell_info[i][j].inset.setDrawFrame(0, InsetText::LOCKED); cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
cell_info[i][j].cellno = cellno++; cell_info[i][j].cellno = cellno++;
} }
cell_info[i].back().right_line = true; cell_info[i].back().right_line = true;
@ -400,15 +400,15 @@ void LyXTabular::init(BufferParams const & bp,
row_info.back().bottom_line = true; row_info.back().bottom_line = true;
row_info.front().bottom_line = true; row_info.front().bottom_line = true;
for (int i = 0; i < columns_; ++i) { for (int i = 0; i < columns_; ++i)
calculate_width_of_column(i); calculate_width_of_column(i);
}
column_info.back().right_line = true; column_info.back().right_line = true;
calculate_width_of_tabular(); calculate_width_of_tabular();
rowofcell = vector<int>(); rowofcell.clear();
columnofcell = vector<int>(); columnofcell.clear();
set_row_column_number_info(); set_row_column_number_info();
is_long_tabular = false; is_long_tabular = false;
rotate = false; rotate = false;
@ -433,16 +433,14 @@ void LyXTabular::appendRow(BufferParams const & bp, int cell)
cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_, cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
cellstruct(bp))); cellstruct(bp)));
for (int i = 0; i <= row; ++i) { for (int i = 0; i <= row; ++i)
for (int j = 0; j < columns_; ++j) { for (int j = 0; j < columns_; ++j)
c_info[i][j] = cell_info[i][j]; c_info[i][j] = cell_info[i][j];
}
} for (int i = row + 1; i < rows_; ++i)
for (int i = row + 1; i < rows_; ++i) { for (int j = 0; j < columns_; ++j)
for (int j = 0; j < columns_; ++j) {
c_info[i][j] = cell_info[i-1][j]; c_info[i][j] = cell_info[i-1][j];
}
}
cell_info = c_info; cell_info = c_info;
++row; ++row;
for (int j = 0; j < columns_; ++j) { for (int j = 0; j < columns_; ++j) {
@ -481,23 +479,20 @@ void LyXTabular::appendColumn(BufferParams const & bp, int cell)
column_info[column + 1] = column_info[column]; column_info[column + 1] = column_info[column];
for (int i = 0; i < rows_; ++i) { for (int i = 0; i < rows_; ++i) {
for (int j = 0; j <= column; ++j) { for (int j = 0; j <= column; ++j)
c_info[i][j] = cell_info[i][j]; c_info[i][j] = cell_info[i][j];
}
for (int j = column + 1; j < columns_; ++j) { for (int j = column + 1; j < columns_; ++j)
c_info[i][j] = cell_info[i][j - 1]; c_info[i][j] = cell_info[i][j - 1];
}
// care about multicolumns // care about multicolumns
if (c_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) if (c_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
{
c_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN; c_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
}
if (column + 2 >= columns_ || if (column + 2 >= columns_
c_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN) || c_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
{
c_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL; c_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
} }
}
cell_info = c_info; cell_info = c_info;
//++column; //++column;
for (int i = 0; i < rows_; ++i) { for (int i = 0; i < rows_; ++i) {
@ -575,6 +570,7 @@ void LyXTabular::set_row_column_number_info(bool oldformat)
} while (column < columns_ && } while (column < columns_ &&
cell_info[row][column].multicolumn cell_info[row][column].multicolumn
== LyXTabular::CELL_PART_OF_MULTICOLUMN); == LyXTabular::CELL_PART_OF_MULTICOLUMN);
if (column == columns_) { if (column == columns_) {
column = 0; column = 0;
++row; ++row;

View File

@ -11,7 +11,6 @@
#include <config.h> #include <config.h>
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxrow.h"
#include "paragraph.h" #include "paragraph.h"
#include "gettext.h" #include "gettext.h"
#include "bufferparams.h" #include "bufferparams.h"
@ -487,7 +486,7 @@ int LyXText::leftMargin(Row const & row) const
InsetOld * ins; InsetOld * ins;
if (row.pos() < row.par()->size()) if (row.pos() < row.par()->size())
if ((row.par()->getChar(row.pos()) == Paragraph::META_INSET) && if (row.par()->getChar(row.pos()) == Paragraph::META_INSET &&
(ins = row.par()->getInset(row.pos())) && (ins = row.par()->getInset(row.pos())) &&
(ins->needFullRow() || ins->display())) (ins->needFullRow() || ins->display()))
return LEFT_MARGIN; return LEFT_MARGIN;
@ -1213,12 +1212,10 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
} }
labeladdon = int( labeladdon = int(
(font_metrics::maxAscent(labelfont) * (font_metrics::maxAscent(labelfont) +
font_metrics::maxDescent(labelfont)) *
layout->spacing.getValue() * layout->spacing.getValue() *
spacing_val) spacing_val
+(font_metrics::maxDescent(labelfont) *
layout->spacing.getValue() *
spacing_val)
+ layout->topsep * defaultRowHeight() + layout->topsep * defaultRowHeight()
+ layout->labelbottomsep * defaultRowHeight()); + layout->labelbottomsep * defaultRowHeight());
} }
@ -1351,90 +1348,6 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
} }
// Appends the implicit specified paragraph before the specified row,
// start at the implicit given position
void LyXText::appendParagraph(RowList::iterator rowit)
{
Assert(rowit != rowlist_.end());
pos_type const last = rowit->par()->size();
bool done = false;
do {
pos_type z = rowBreakPoint(*rowit);
RowList::iterator tmprow = rowit;
if (z < last) {
++z;
Row newrow(rowit->par(), z);
rowit = rowlist_.insert(boost::next(rowit), newrow);
} else {
done = true;
}
// Set the dimensions of the row
// fixed fill setting now by calling inset->update() in
// SingleWidth when needed!
tmprow->fill(fill(tmprow, workWidth()));
setHeightOfRow(tmprow);
} while (!done);
}
void LyXText::breakAgain(RowList::iterator rit)
{
Assert(rit != rows().end());
bool not_ready = true;
do {
pos_type z = rowBreakPoint(*rit);
RowList::iterator tmprit = rit;
RowList::iterator end = rows().end();
if (z < rit->par()->size()) {
RowList::iterator next_rit = boost::next(rit);
if (next_rit == end ||
(next_rit != end &&
next_rit->par() != rit->par())) {
// insert a new row
++z;
Row newrow(rit->par(), z);
rit = rowlist_.insert(next_rit, newrow);
} else {
++rit;
++z;
if (rit->pos() == z)
not_ready = false; // the rest will not change
else {
rit->pos(z);
}
}
} else {
// if there are some rows too much, delete them
// only if you broke the whole paragraph!
RowList::iterator tmprit2 = rit;
while (boost::next(tmprit2) != end
&& boost::next(tmprit2)->par() == rit->par()) {
++tmprit2;
}
while (tmprit2 != rit) {
--tmprit2;
removeRow(boost::next(tmprit2));
}
not_ready = false;
}
// set the dimensions of the row
tmprit->fill(fill(tmprit, workWidth()));
setHeightOfRow(tmprit);
} while (not_ready);
}
void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout) void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
{ {
// allow only if at start or end, or all previous is new text // allow only if at start or end, or all previous is new text
@ -1521,8 +1434,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
else else
setCursor(cursor.par(), 0); setCursor(cursor.par(), 0);
if (boost::next(cursorRow()) != rows().end()) redoParagraph(cursor.par());
breakAgain(boost::next(cursorRow()));
} }
@ -1602,16 +1514,10 @@ void LyXText::insertChar(char c)
// and it should (along with realtmpfont) when we type the space. // and it should (along with realtmpfont) when we type the space.
// CHECK There is a bug here! (Asger) // CHECK There is a bug here! (Asger)
LyXFont realtmpfont = real_current_font;
LyXFont rawtmpfont = current_font;
// store the current font. This is because of the use of cursor // store the current font. This is because of the use of cursor
// movements. The moving cursor would refresh the current font // movements. The moving cursor would refresh the current font
LyXFont realtmpfont = real_current_font;
// Get the font that is used to calculate the baselineskip LyXFont rawtmpfont = current_font;
pos_type const lastpos = cursor.par()->size();
LyXFont rawparfont =
cursor.par()->getFontSettings(bv()->buffer()->params,
lastpos - 1);
if (!freeSpacing && IsLineSeparatorChar(c)) { if (!freeSpacing && IsLineSeparatorChar(c)) {
if ((cursor.pos() > 0 if ((cursor.pos() > 0
@ -2168,8 +2074,7 @@ void LyXText::backspace()
// This is an empty paragraph and we delete it just // This is an empty paragraph and we delete it just
// by moving the cursor one step // by moving the cursor one step
// left and let the DeleteEmptyParagraphMechanism // left and let the DeleteEmptyParagraphMechanism
// handle the actual deletion // handle the actual deletion of the paragraph.
// of the paragraph.
if (cursor.par() != ownerParagraphs().begin()) { if (cursor.par() != ownerParagraphs().begin()) {
ParagraphList::iterator tmppit = boost::prior(cursor.par()); ParagraphList::iterator tmppit = boost::prior(cursor.par());
@ -2213,11 +2118,6 @@ void LyXText::backspace()
// Pasting is not allowed, if the paragraphs have different // Pasting is not allowed, if the paragraphs have different
// layout. I think it is a real bug of all other // layout. I think it is a real bug of all other
// word processors to allow it. It confuses the user. // word processors to allow it. It confuses the user.
// Even so with a footnote paragraph and a non-footnote
// paragraph. I will not allow pasting in this case,
// because the user would be confused if the footnote behaves
// different wether it is open or closed.
//Correction: Pasting is always allowed with standard-layout //Correction: Pasting is always allowed with standard-layout
LyXTextClass const & tclass = LyXTextClass const & tclass =
bv()->buffer()->params.getLyXTextClass(); bv()->buffer()->params.getLyXTextClass();
@ -2228,30 +2128,14 @@ void LyXText::backspace()
&& cursor.par()->getAlign() == tmppit->getAlign()) { && cursor.par()->getAlign() == tmppit->getAlign()) {
removeParagraph(tmprow); removeParagraph(tmprow);
removeRow(tmprow); removeRow(tmprow);
mergeParagraph(bv()->buffer()->params, bv()->buffer()->paragraphs, cursor.par()); mergeParagraph(bv()->buffer()->params,
bv()->buffer()->paragraphs, cursor.par());
if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1)) if (cursor.pos() && cursor.par()->isSeparator(cursor.pos() - 1))
; //cursor.par()->insertChar(cursor.pos(), ' ');
// strangely enough it seems that commenting out the line above removes
// most or all of the segfaults. I will however also try to move the
// two Remove... lines in front of the PasteParagraph too.
else
if (cursor.pos())
cursor.pos(cursor.pos() - 1); cursor.pos(cursor.pos() - 1);
// remove the lost paragraph
// This one is not safe, since the paragraph that the tmprow and the
// following rows belong to has been deleted by the PasteParagraph
// above. The question is... could this be moved in front of the
// PasteParagraph?
//RemoveParagraph(tmprow);
//RemoveRow(tmprow);
// This rebuilds the rows.
appendParagraph(cursorRow());
updateCounters();
// the row may have changed, block, hfills etc. // the row may have changed, block, hfills etc.
updateCounters();
setCursor(cursor.par(), cursor.pos(), false); setCursor(cursor.par(), cursor.pos(), false);
} }
} else { } else {

View File

@ -28,7 +28,6 @@
#include "frontends/font_metrics.h" #include "frontends/font_metrics.h"
#include "debug.h" #include "debug.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "lyxrow.h"
#include "FloatList.h" #include "FloatList.h"
#include "language.h" #include "language.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
@ -103,8 +102,6 @@ void LyXText::init(BufferView * bview)
// The difference is that this one is used for displaying, and thus we // The difference is that this one is used for displaying, and thus we
// are allowed to make cosmetic improvements. For instance make footnotes // are allowed to make cosmetic improvements. For instance make footnotes
// smaller. (Asger) // smaller. (Asger)
// If position is -1, we get the layout font of the paragraph.
// If position is -2, we get the font of the manual label of the paragraph.
LyXFont LyXText::getFont(ParagraphList::iterator pit, pos_type pos) const LyXFont LyXText::getFont(ParagraphList::iterator pit, pos_type pos) const
{ {
Assert(pos >= 0); Assert(pos >= 0);
@ -285,7 +282,31 @@ void LyXText::insertParagraph(ParagraphList::iterator pit,
rit = rowlist_.insert(rit, Row(pit, 0)); rit = rowlist_.insert(rit, Row(pit, 0));
// and now append the whole paragraph before the new row // and now append the whole paragraph before the new row
appendParagraph(rit); Assert(rit != rowlist_.end());
pos_type const last = rit->par()->size();
bool done = false;
do {
pos_type z = rowBreakPoint(*rit);
RowList::iterator tmprow = rit;
if (z < last) {
++z;
Row newrow(rit->par(), z);
rit = rowlist_.insert(boost::next(rit), newrow);
} else {
done = true;
}
// Set the dimensions of the row
// fixed fill setting now by calling inset->update() in
// SingleWidth when needed!
tmprow->fill(fill(tmprow, workWidth()));
setHeightOfRow(tmprow);
} while (!done);
} }
@ -385,11 +406,10 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
do { do {
pit->applyLayout(lyxlayout); pit->applyLayout(lyxlayout);
makeFontEntriesLayoutSpecific(bv()->buffer()->params, *pit); makeFontEntriesLayoutSpecific(bv()->buffer()->params, *pit);
ParagraphList::iterator fppit = pit; pit->params().spaceTop(lyxlayout->fill_top ?
fppit->params().spaceTop(lyxlayout->fill_top ?
VSpace(VSpace::VFILL) VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE)); : VSpace(VSpace::NONE));
fppit->params().spaceBottom(lyxlayout->fill_bottom ? pit->params().spaceBottom(lyxlayout->fill_bottom ?
VSpace(VSpace::VFILL) VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE)); : VSpace(VSpace::NONE));
if (lyxlayout->margintype == MARGIN_MANUAL) if (lyxlayout->margintype == MARGIN_MANUAL)
@ -451,8 +471,8 @@ void LyXText::setLayout(string const & layout)
bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only) bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
{ {
ParagraphList::iterator pit(cursor.par()); ParagraphList::iterator pit = cursor.par();
ParagraphList::iterator end(cursor.par()); ParagraphList::iterator end = cursor.par();
ParagraphList::iterator start = pit; ParagraphList::iterator start = pit;
if (selection.set()) { if (selection.set()) {
@ -480,11 +500,9 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
if (depth < prev_after_depth if (depth < prev_after_depth
&& pit->layout()->labeltype != LABEL_BIBLIO) { && pit->layout()->labeltype != LABEL_BIBLIO) {
changed = true; changed = true;
if (!test_only) { if (!test_only)
pit->params().depth(depth + 1); pit->params().depth(depth + 1);
} }
}
} else if (depth) { } else if (depth) {
changed = true; changed = true;
if (!test_only) if (!test_only)
@ -503,7 +521,6 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
if (test_only) if (test_only)
return changed; return changed;
redoParagraphs(start, pastend); redoParagraphs(start, pastend);
// We need to actually move the text->cursor. I don't // We need to actually move the text->cursor. I don't
@ -623,35 +640,9 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
} }
// reinsert the paragraph // reinsert the paragraph
// insert a new row, starting at position 0 insertParagraph(pit, rit);
Row newrow(pit, 0);
rit = rowlist_.insert(rit, newrow);
// and now append the whole paragraph before the new row
pos_type const last = rit->par()->size();
bool done = false;
do {
pos_type z = rowBreakPoint(*rit);
RowList::iterator tmprow = rit;
if (z < last) {
++z;
Row newrow(rit->par(), z);
rit = rowlist_.insert(boost::next(rit), newrow);
} else {
done = true;
}
// Set the dimensions of the row
// fixed fill setting now by calling inset->update() in
// SingleWidth when needed!
tmprow->fill(fill(tmprow, workWidth()));
setHeightOfRow(tmprow);
} while (!done);
// why?
setHeightOfRow(rows().begin()); setHeightOfRow(rows().begin());
} }
@ -659,7 +650,7 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
void LyXText::fullRebreak() void LyXText::fullRebreak()
{ {
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end()); redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
setCursorIntern(cursor.par(), cursor.pos()); redoCursor();
selection.cursor = cursor; selection.cursor = cursor;
} }
@ -691,25 +682,9 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
ii->inset->metrics(m, dim); ii->inset->metrics(m, dim);
} }
#if 1
// insert a new row, starting at position 0
Row newrow(pit, 0);
RowList::iterator rit = rowlist_.insert(rowlist_.end(), newrow);
// and now append the whole paragraph before the new row
appendParagraph(rit);
#else
redoParagraph(pit); redoParagraph(pit);
#endif
} }
// compute height
//lyxerr << "height 0: " << height << endl;
//for (RowList::iterator rit = rows().begin(); rit != rows().end(); ++rit) {
// height += rit->height();
//}
//lyxerr << "height 1: " << height << endl;
// final dimension // final dimension
dim.asc = rows().begin()->ascent_of_text(); dim.asc = rows().begin()->ascent_of_text();
dim.des = height - dim.asc; dim.des = height - dim.asc;
@ -717,16 +692,6 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
} }
void LyXText::partialRebreak()
{
if (rows().empty()) {
init(bv());
return;
}
breakAgain(rows().begin());
}
// important for the screen // important for the screen
@ -857,8 +822,8 @@ string LyXText::getStringToIndex()
// the DTP switches for paragraphs. LyX will store them in the first // the DTP switches for paragraphs. LyX will store them in the first
// physicla paragraph. When a paragraph is broken, the top settings rest, // physical paragraph. When a paragraph is broken, the top settings rest,
// the bottom settings are given to the new one. So I can make shure, // the bottom settings are given to the new one. So I can make sure,
// they do not duplicate themself and you cannnot make dirty things with // they do not duplicate themself and you cannnot make dirty things with
// them! // them!
@ -962,13 +927,12 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
pit->itemdepth = 0; pit->itemdepth = 0;
} }
/* Maybe we have to increment the enumeration depth. // Maybe we have to increment the enumeration depth.
* BUT, enumeration in a footnote is considered in isolation from its // BUT, enumeration in a footnote is considered in isolation from its
* surrounding paragraph so don't increment if this is the // surrounding paragraph so don't increment if this is the
* first line of the footnote // first line of the footnote
* AND, bibliographies can't have their depth changed ie. they // AND, bibliographies can't have their depth changed ie. they
* are always of depth 0 // are always of depth 0
*/
if (pit != ownerParagraphs().begin() if (pit != ownerParagraphs().begin()
&& boost::prior(pit)->getDepth() < pit->getDepth() && boost::prior(pit)->getDepth() < pit->getDepth()
&& boost::prior(pit)->layout()->labeltype == LABEL_COUNTER_ENUMI && boost::prior(pit)->layout()->labeltype == LABEL_COUNTER_ENUMI
@ -990,9 +954,8 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
} }
if (layout->margintype == MARGIN_MANUAL) { if (layout->margintype == MARGIN_MANUAL) {
if (pit->params().labelWidthString().empty()) { if (pit->params().labelWidthString().empty())
pit->setLabelWidthString(layout->labelstring()); pit->setLabelWidthString(layout->labelstring());
}
} else { } else {
pit->setLabelWidthString(string()); pit->setLabelWidthString(string());
} }
@ -1145,18 +1108,12 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
// Updates all counters. Paragraphs with changed label string will be rebroken // Updates all counters. Paragraphs with changed label string will be rebroken
void LyXText::updateCounters() void LyXText::updateCounters()
{ {
RowList::iterator rowit = rows().begin(); // start over
ParagraphList::iterator pit = rowit->par();
// CHECK if this is really needed. (Lgb)
bv()->buffer()->params.getLyXTextClass().counters().reset(); bv()->buffer()->params.getLyXTextClass().counters().reset();
ParagraphList::iterator beg = ownerParagraphs().begin(); ParagraphList::iterator beg = ownerParagraphs().begin();
ParagraphList::iterator end = ownerParagraphs().end(); ParagraphList::iterator end = ownerParagraphs().end();
for (; pit != end; ++pit) { for (ParagraphList::iterator pit = beg; pit != end; ++pit) {
while (rowit->par() != pit)
++rowit;
string const oldLabel = pit->params().labelString(); string const oldLabel = pit->params().labelString();
size_t maxdepth = 0; size_t maxdepth = 0;
@ -1171,10 +1128,8 @@ void LyXText::updateCounters()
string const & newLabel = pit->params().labelString(); string const & newLabel = pit->params().labelString();
if (oldLabel.empty() && !newLabel.empty()) { if (oldLabel != newLabel)
removeParagraph(rowit); redoParagraph(pit);
appendParagraph(rowit);
}
} }
} }
@ -1189,14 +1144,12 @@ void LyXText::insertInset(InsetOld * inset)
// Just to rebreak and refresh correctly. // Just to rebreak and refresh correctly.
// The character will not be inserted a second time // The character will not be inserted a second time
insertChar(Paragraph::META_INSET); insertChar(Paragraph::META_INSET);
// If we enter a highly editable inset the cursor should be to before // If we enter a highly editable inset the cursor should be before
// the inset. This couldn't happen before as Undo was not handled inside // the inset. After an Undo LyX tries to call inset->edit(...)
// inset now after the Undo LyX tries to call inset->Edit(...) again // and fails if the cursor is behind the inset and getInset
// and cannot do this as the cursor is behind the inset and GetInset
// does not return the inset! // does not return the inset!
if (isHighlyEditableInset(inset)) { if (isHighlyEditableInset(inset))
cursorLeft(true); cursorLeft(true);
}
unFreezeUndo(); unFreezeUndo();
} }
@ -1238,7 +1191,6 @@ void LyXText::cutSelection(bool doclear, bool realcut)
recordUndo(bv(), Undo::DELETE, selection.start.par(), recordUndo(bv(), Undo::DELETE, selection.start.par(),
boost::prior(undoendpit)); boost::prior(undoendpit));
endpit = selection.end.par(); endpit = selection.end.par();
int endpos = selection.end.pos(); int endpos = selection.end.pos();
@ -1438,6 +1390,13 @@ bool LyXText::setCursor(ParagraphList::iterator pit,
} }
void LyXText::redoCursor()
{
#warning maybe the same for selections?
setCursor(cursor, cursor.par(), cursor.pos(), cursor.boundary());
}
void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit, void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
pos_type pos, bool boundary) pos_type pos, bool boundary)
{ {
@ -1538,11 +1497,11 @@ float LyXText::getCursorX(RowList::iterator rit,
cursor_vpos = (rit_par->isRightToLeftPar(bv()->buffer()->params)) cursor_vpos = (rit_par->isRightToLeftPar(bv()->buffer()->params))
? rit_pos : last + 1; ? rit_pos : last + 1;
else if (pos > rit_pos && (pos > last || boundary)) else if (pos > rit_pos && (pos > last || boundary))
/// Place cursor after char at (logical) position pos - 1 // Place cursor after char at (logical) position pos - 1
cursor_vpos = (bidi_level(pos - 1) % 2 == 0) cursor_vpos = (bidi_level(pos - 1) % 2 == 0)
? log2vis(pos - 1) + 1 : log2vis(pos - 1); ? log2vis(pos - 1) + 1 : log2vis(pos - 1);
else else
/// Place cursor before char at (logical) position pos // Place cursor before char at (logical) position pos
cursor_vpos = (bidi_level(pos) % 2 == 0) cursor_vpos = (bidi_level(pos) % 2 == 0)
? log2vis(pos) : log2vis(pos) + 1; ? log2vis(pos) : log2vis(pos) + 1;
@ -1581,32 +1540,6 @@ float LyXText::getCursorX(RowList::iterator rit,
void LyXText::setCursorIntern(ParagraphList::iterator pit, void LyXText::setCursorIntern(ParagraphList::iterator pit,
pos_type pos, bool setfont, bool boundary) pos_type pos, bool setfont, bool boundary)
{ {
UpdatableInset * it = pit->inInset();
if (it) {
if (it != inset_owner) {
lyxerr[Debug::INSETS] << "InsetText is " << it
<< endl
<< "inset_owner is "
<< inset_owner << endl;
#ifdef WITH_WARNINGS
#warning I believe this code is wrong. (Lgb)
#warning Jürgen, have a look at this. (Lgb)
#warning Hmmm, I guess you are right but we
#warning should verify when this is needed
#endif
// Jürgen, would you like to have a look?
// I guess we need to move the outer cursor
// and open and lock the inset (bla bla bla)
// stuff I don't know... so can you have a look?
// (Lgb)
// I moved the lyxerr stuff in here so we can see if
// this is actually really needed and where!
// (Jug)
// it->getLyXText(bv())->setCursorIntern(bv(), par, pos, setfont, boundary);
return;
}
}
setCursor(cursor, pit, pos, boundary); setCursor(cursor, pit, pos, boundary);
if (setfont) if (setfont)
setCurrentFont(); setCurrentFont();
@ -1940,8 +1873,7 @@ void LyXText::cursorDownParagraph()
// fix the cursor `cur' after a characters has been deleted at `where' // fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism // position. Called by deleteEmptyParagraphMechanism
void LyXText::fixCursorAfterDelete(LyXCursor & cur, void LyXText::fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where)
LyXCursor const & where)
{ {
// if cursor is not in the paragraph where the delete occured, // if cursor is not in the paragraph where the delete occured,
// do nothing // do nothing
@ -1970,10 +1902,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
return false; return false;
// We allow all kinds of "mumbo-jumbo" when freespacing. // We allow all kinds of "mumbo-jumbo" when freespacing.
if (old_cursor.par()->layout()->free_spacing if (old_cursor.par()->isFreeSpacing())
|| old_cursor.par()->isFreeSpacing()) {
return false; return false;
}
/* Ok I'll put some comments here about what is missing. /* Ok I'll put some comments here about what is missing.
I have fixed BackSpace (and thus Delete) to not delete I have fixed BackSpace (and thus Delete) to not delete
@ -2001,8 +1931,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
// If the pos around the old_cursor were spaces, delete one of them. // If the pos around the old_cursor were spaces, delete one of them.
if (old_cursor.par() != cursor.par() if (old_cursor.par() != cursor.par()
|| old_cursor.pos() != cursor.pos()) { || old_cursor.pos() != cursor.pos()) {
// Only if the cursor has really moved
// Only if the cursor has really moved
if (old_cursor.pos() > 0 if (old_cursor.pos() > 0
&& old_cursor.pos() < old_cursor.par()->size() && old_cursor.pos() < old_cursor.par()->size()
&& old_cursor.par()->isLineSeparator(old_cursor.pos()) && old_cursor.par()->isLineSeparator(old_cursor.pos())
@ -2081,7 +2011,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
* there is another layout before */ * there is another layout before */
RowList::iterator tmprit = boost::next(prevrow); RowList::iterator tmprit = boost::next(prevrow);
if (tmprit != rows().end()) { if (tmprit != rows().end()) {
breakAgain(tmprit); redoParagraph(tmprit->par());
updateCounters(); updateCounters();
} }
setHeightOfRow(prevrow); setHeightOfRow(prevrow);
@ -2110,7 +2040,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
The next row can change its height, if The next row can change its height, if
there is another layout before */ there is another layout before */
if (nextrow != rows().end()) { if (nextrow != rows().end()) {
breakAgain(nextrow); redoParagraph(nextrow->par());
updateCounters(); updateCounters();
} }
} }
@ -2146,8 +2076,7 @@ ParagraphList & LyXText::ownerParagraphs() const
bool LyXText::isInInset() const bool LyXText::isInInset() const
{ {
// Sub-level has non-null bv owner and // Sub-level has non-null bv owner and non-null inset owner.
// non-null inset owner.
return inset_owner != 0 && bv_owner != 0; return inset_owner != 0 && bv_owner != 0;
} }

View File

@ -11,7 +11,6 @@
#include <config.h> #include <config.h>
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxrow.h"
#include "paragraph.h" #include "paragraph.h"
#include "BufferView.h" #include "BufferView.h"
#include "funcrequest.h" #include "funcrequest.h"
@ -226,7 +225,7 @@ void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
bv()->owner()->message(_("No more insets")); bv()->owner()->message(_("No more insets"));
} }
} }
update(); bv()->update();
selection.cursor = cursor; selection.cursor = cursor;
} }
@ -348,16 +347,11 @@ void LyXText::cursorNext()
} }
void LyXText::update()
{
bv()->update();
}
namespace { namespace {
void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind) void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
{ {
lt->update(); bv->update();
InsetSpecialChar * new_inset = new InsetSpecialChar(kind); InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
replaceSelection(lt); replaceSelection(lt);
if (!bv->insertInset(new_inset)) if (!bv->insertInset(new_inset))
@ -415,8 +409,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (tmp->params().startOfAppendix()) { if (tmp->params().startOfAppendix()) {
recordUndo(bv, Undo::ATOMIC, tmp); recordUndo(bv, Undo::ATOMIC, tmp);
tmp->params().startOfAppendix(false); tmp->params().startOfAppendix(false);
int tmpy; setHeightOfRow(getRow(tmp, 0));
setHeightOfRow(getRow(tmp, 0, tmpy));
break; break;
} }
} }
@ -428,28 +421,25 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
updateCounters(); updateCounters();
redoParagraph(cursor.par()); redoParagraph(cursor.par());
setCursor(cursor.par(), cursor.pos()); setCursor(cursor.par(), cursor.pos());
update(); bv->update();
break; break;
} }
case LFUN_DELETE_WORD_FORWARD: case LFUN_DELETE_WORD_FORWARD:
bv->beforeChange(this); bv->beforeChange(this);
deleteWordForward(); deleteWordForward();
update();
finishChange(bv); finishChange(bv);
break; break;
case LFUN_DELETE_WORD_BACKWARD: case LFUN_DELETE_WORD_BACKWARD:
bv->beforeChange(this); bv->beforeChange(this);
deleteWordBackward(); deleteWordBackward();
update();
finishChange(bv); finishChange(bv);
break; break;
case LFUN_DELETE_LINE_FORWARD: case LFUN_DELETE_LINE_FORWARD:
bv->beforeChange(this); bv->beforeChange(this);
deleteLineForward(); deleteLineForward();
update();
finishChange(bv); finishChange(bv);
break; break;
@ -461,7 +451,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
cursorRightOneWord(); cursorRightOneWord();
finishChange(bv); finishChange(bv);
update();
break; break;
case LFUN_WORDLEFT: case LFUN_WORDLEFT:
@ -718,7 +707,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
} }
moveCursorUpdate(bv, false); moveCursorUpdate(bv, false);
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
bv->switchKeyMap();
break; break;
case LFUN_DELETE_SKIP: case LFUN_DELETE_SKIP:
@ -754,7 +742,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
} else { } else {
cutSelection(true, false); cutSelection(true, false);
} }
update(); bv->update();
break; break;
@ -771,7 +759,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
} }
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
bv->switchKeyMap(); bv->switchKeyMap();
update(); bv->update();
break; break;
case LFUN_BACKSPACE_SKIP: case LFUN_BACKSPACE_SKIP:
@ -795,16 +783,15 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
selection.cursor = cur; selection.cursor = cur;
} }
} else { } else {
update();
cutSelection(true, false); cutSelection(true, false);
} }
update(); bv->update();
break; break;
case LFUN_BREAKPARAGRAPH: case LFUN_BREAKPARAGRAPH:
replaceSelection(bv->getLyXText()); replaceSelection(bv->getLyXText());
breakParagraph(bv->buffer()->paragraphs, 0); breakParagraph(bv->buffer()->paragraphs, 0);
update(); bv->update();
selection.cursor = cursor; selection.cursor = cursor;
bv->switchKeyMap(); bv->switchKeyMap();
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
@ -813,7 +800,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BREAKPARAGRAPHKEEPLAYOUT: case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
replaceSelection(bv->getLyXText()); replaceSelection(bv->getLyXText());
breakParagraph(bv->buffer()->paragraphs, 1); breakParagraph(bv->buffer()->paragraphs, 1);
update(); bv->update();
selection.cursor = cursor; selection.cursor = cursor;
bv->switchKeyMap(); bv->switchKeyMap();
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
@ -841,7 +828,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
else { else {
breakParagraph(bv->buffer()->paragraphs, 0); breakParagraph(bv->buffer()->paragraphs, 0);
} }
update(); bv->update();
selection.cursor = cur; selection.cursor = cur;
bv->switchKeyMap(); bv->switchKeyMap();
bv->owner()->view_state_changed(); bv->owner()->view_state_changed();
@ -885,7 +872,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (cur_spacing != new_spacing || cur_value != new_value) { if (cur_spacing != new_spacing || cur_value != new_value) {
pit->params().spacing(Spacing(new_spacing, new_value)); pit->params().spacing(Spacing(new_spacing, new_value));
redoParagraph(); redoParagraph();
update(); bv->update();
} }
break; break;
} }
@ -897,19 +884,16 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
bv->beforeChange(this); bv->beforeChange(this);
update();
toggleInset(); toggleInset();
update(); bv->update();
bv->switchKeyMap(); bv->switchKeyMap();
break; break;
case LFUN_SPACE_INSERT: case LFUN_SPACE_INSERT:
if (cursor.par()->layout()->free_spacing) { if (cursor.par()->layout()->free_spacing)
insertChar(' '); insertChar(' ');
update(); else
} else {
doInsertInset(this, cmd, false, false); doInsertInset(this, cmd, false, false);
}
moveCursorUpdate(bv, false); moveCursorUpdate(bv, false);
break; break;
@ -935,7 +919,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_MARK_OFF: case LFUN_MARK_OFF:
bv->beforeChange(this); bv->beforeChange(this);
update(); bv->update();
selection.cursor = cursor; selection.cursor = cursor;
cmd.message(N_("Mark off")); cmd.message(N_("Mark off"));
break; break;
@ -943,7 +927,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_MARK_ON: case LFUN_MARK_ON:
bv->beforeChange(this); bv->beforeChange(this);
selection.mark(true); selection.mark(true);
update(); bv->update();
selection.cursor = cursor; selection.cursor = cursor;
cmd.message(N_("Mark on")); cmd.message(N_("Mark on"));
break; break;
@ -957,37 +941,28 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
cmd.message(N_("Mark set")); cmd.message(N_("Mark set"));
} }
selection.cursor = cursor; selection.cursor = cursor;
update(); bv->update();
break; break;
case LFUN_UPCASE_WORD: case LFUN_UPCASE_WORD:
update();
changeCase(LyXText::text_uppercase); changeCase(LyXText::text_uppercase);
if (inset_owner) bv->update();
bv->updateInset();
update();
break; break;
case LFUN_LOWCASE_WORD: case LFUN_LOWCASE_WORD:
changeCase(LyXText::text_lowercase); changeCase(LyXText::text_lowercase);
if (inset_owner) bv->update();
bv->updateInset();
update();
break; break;
case LFUN_CAPITALIZE_WORD: case LFUN_CAPITALIZE_WORD:
changeCase(LyXText::text_capitalization); changeCase(LyXText::text_capitalization);
if (inset_owner) bv->update();
bv->updateInset();
update();
break; break;
case LFUN_TRANSPOSE_CHARS: case LFUN_TRANSPOSE_CHARS:
recordUndo(bv, Undo::ATOMIC, cursor.par()); recordUndo(bv, Undo::ATOMIC, cursor.par());
if (inset_owner)
bv->updateInset();
redoParagraph(); redoParagraph();
update(); bv->update();
break; break;
case LFUN_PASTE: { case LFUN_PASTE: {
@ -1002,7 +977,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
} }
pasteSelection(sel_index); pasteSelection(sel_index);
clearSelection(); // bug 393 clearSelection(); // bug 393
update(); bv->update();
bv->switchKeyMap(); bv->switchKeyMap();
break; break;
} }
@ -1010,7 +985,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_CUT: case LFUN_CUT:
cutSelection(true, true); cutSelection(true, true);
cmd.message(_("Cut")); cmd.message(_("Cut"));
update(); bv->update();
break; break;
case LFUN_COPY: case LFUN_COPY:
@ -1023,7 +998,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
return UNDISPATCHED; return UNDISPATCHED;
cursorTop(); cursorTop();
finishChange(bv, true); finishChange(bv, true);
update();
break; break;
case LFUN_ENDBUFSEL: case LFUN_ENDBUFSEL:
@ -1031,7 +1005,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
return UNDISPATCHED; return UNDISPATCHED;
cursorBottom(); cursorBottom();
finishChange(bv, true); finishChange(bv, true);
update();
break; break;
case LFUN_GETXY: case LFUN_GETXY:
@ -1117,7 +1090,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
current_layout = layout; current_layout = layout;
setLayout(layout); setLayout(layout);
bv->owner()->setLayout(layout); bv->owner()->setLayout(layout);
update(); bv->update();
bv->switchKeyMap(); bv->switchKeyMap();
} }
break; break;
@ -1134,7 +1107,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
else else
insertStringAsLines(clip); insertStringAsLines(clip);
clearSelection(); clearSelection();
update(); bv->update();
} }
break; break;
} }
@ -1192,10 +1165,9 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
int const datetmp_len = int const datetmp_len =
::strftime(datetmp, 32, arg.c_str(), now_tm); ::strftime(datetmp, 32, arg.c_str(), now_tm);
for (int i = 0; i < datetmp_len; i++) { for (int i = 0; i < datetmp_len; i++)
insertChar(datetmp[i]); insertChar(datetmp[i]);
update();
}
selection.cursor = cursor; selection.cursor = cursor;
moveCursorUpdate(bv, false); moveCursorUpdate(bv, false);
break; break;
@ -1215,7 +1187,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
setSelection(); setSelection();
if (!isInInset()) if (!isInInset())
bv->screen().toggleSelection(this, bv, false); bv->screen().toggleSelection(this, bv, false);
update(); bv->update();
bv->haveSelection(selection.set()); bv->haveSelection(selection.set());
} }
break; break;
@ -1233,7 +1205,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
} else { } else {
selectWord(lyx::WHOLE_WORD_STRICT); selectWord(lyx::WHOLE_WORD_STRICT);
} }
update(); bv->update();
bv->haveSelection(selection.set()); bv->haveSelection(selection.set());
} }
break; break;
@ -1509,7 +1481,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
bv->owner()->getIntl().getTransManager(). bv->owner()->getIntl().getTransManager().
TranslateAndInsert(*cit, this); TranslateAndInsert(*cit, this);
update();
selection.cursor = cursor; selection.cursor = cursor;
moveCursorUpdate(bv, false); moveCursorUpdate(bv, false);