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 "lyxtext.h"
#include "lyxrc.h"
#include "lyxrow.h"
#include "lastfiles.h"
#include "paragraph.h"
#include "ParagraphParameters.h"
@ -349,7 +348,7 @@ bool BufferView::Pimpl::fitCursor()
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
// 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;
@ -400,7 +399,6 @@ int BufferView::Pimpl::resizeCurrentBuffer()
selection = bv_->text->selection.set();
mark_set = bv_->text->selection.mark();
the_locking_inset = bv_->theLockingInset();
resizeInsets(bv_);
bv_->text->fullRebreak();
update();
} else {
@ -418,12 +416,9 @@ int BufferView::Pimpl::resizeCurrentBuffer()
// bv_->text->owner(bv_);
if (lyxerr.debugging())
textcache.show(lyxerr, "resizeCurrentBuffer");
resizeInsets(bv_);
} else {
lyxerr << "no text in cache!" << endl;
bv_->text = new LyXText(bv_);
resizeInsets(bv_);
bv_->text->init(bv_);
}
@ -461,8 +456,6 @@ int BufferView::Pimpl::resizeCurrentBuffer()
owner_->clearMessage();
updateScrollbar();
return 0;
}
@ -617,13 +610,6 @@ void BufferView::Pimpl::workAreaResize()
if (lyxerr.debugging())
textcache.show(lyxerr, "Expose delete all");
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.
updateScrollbar();
owner_->updateLayoutChoice();
return;
}
void BufferView::Pimpl::update()
{
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_);
}
@ -1229,15 +1220,13 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
case LFUN_PARAGRAPH_UPDATE: {
if (!bv_->owner()->getDialogs().visible("paragraph"))
break;
Paragraph const * par = &*bv_->getLyXText()->cursor.par();
if (!par)
break;
Paragraph const & par = *bv_->getLyXText()->cursor.par();
string data;
params2string(*par, data);
params2string(par, data);
// Will the paragraph accept changes from the dialog?
InsetOld * const inset = par->inInset();
InsetOld * const inset = par.inInset();
bool const accept =
!(inset && inset->forceDefaultParagraphs(inset));
@ -1389,6 +1378,7 @@ void BufferView::Pimpl::updateInset()
// this should not be needed, but it is...
bv_->text->redoParagraph(bv_->text->cursor.par());
update();
updateScrollbar();
}

View File

@ -43,7 +43,7 @@ struct BufferView::Pimpl : public boost::signals::trackable {
///
void redoCurrentBuffer();
///
int resizeCurrentBuffer();
void resizeCurrentBuffer();
///
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>
* 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 deleteInsetsLyXText(BufferView * bv);
///
void resizeInsetsLyXText(BufferView * bv);
private:
///
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)
{
return (x1 < x && x2 > x &&
y1 < y && y2 > y);
return (x1 < x && x2 > x && 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
<< std::endl;
}

View File

@ -50,16 +50,6 @@ bool toggleall(false);
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
// If successful, returns true
bool font2string(LyXFont const & font, bool toggle, string & data)
@ -219,6 +209,7 @@ void number(BufferView * bv)
toggleAndShow(bv, font);
}
void lang(BufferView * bv, string const & l)
{
Language const * lang = languages.getLanguage(l);
@ -393,10 +384,6 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
}
LyXText * text = bv->getLyXText();
// FIXME: can this happen ??
if (!text)
return;
text->toggleFree(font, toggleall);
bv->update();
@ -417,9 +404,8 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
void replaceSelection(LyXText * lt)
{
if (lt->selection.set()) {
lt->update();
lt->cutSelection(true, false);
lt->update();
lt->bv()->update();
}
}

View File

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

View File

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

View File

@ -20,7 +20,6 @@ using std::queue;
using std::vector;
int Graph::bfs_init(int s, bool clear_visited)
{
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>
* inset.[Ch]: move non-crucial functions out-of-line

View File

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

View File

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

View File

@ -49,12 +49,12 @@ InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
#if 0
autocollapse(false),
#endif
oldWidth(0), in_update(false), first_after_edit(false)
in_update(false), first_after_edit(false)
{
inset.setOwner(this);
inset.setAutoBreakRows(true);
inset.setDrawFrame(0, InsetText::ALWAYS);
inset.setFrameColor(0, LColor::collapsableframe);
inset.setDrawFrame(InsetText::ALWAYS);
inset.setFrameColor(LColor::collapsableframe);
setInsetName("Collapsable");
}
@ -66,7 +66,7 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
#if 0
autocollapse(in.autocollapse),
#endif
oldWidth(0), in_update(false), first_after_edit(false)
in_update(false), first_after_edit(false)
{
inset.init(&(in.inset));
inset.setOwner(this);
@ -243,6 +243,7 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
}
bv->updateInset();
bv->buffer()->markDirty();
lyxerr << "InsetCollapsable::lfunMouseRelease\n";
} else if (!collapsed_ && cmd.y > button_dim.y2) {
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
{
inset.getLabelList(list);

View File

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

View File

@ -76,16 +76,7 @@ InsetMinipage::InsetMinipage(BufferParams const & bp)
#if 0
setAutoCollapse(false);
#endif
#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);
inset.setFrameColor(LColor::blue);
setInsetName("Minipage");
}

View File

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

View File

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

View File

@ -42,6 +42,7 @@
#include "rowpainter.h"
#include "insetnewline.h"
#include "metricsinfo.h"
#include "textcursor.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
@ -80,50 +81,6 @@ using lyx::pos_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)
: UpdatableInset(), text_(0, this)
{
@ -162,8 +119,6 @@ void InsetText::init(InsetText const * ins)
for (; pit != end; ++pit)
pit->setInsetOwner(this);
reinitLyXText();
autoBreakRows = ins->autoBreakRows;
drawFrame_ = ins->drawFrame_;
frame_color = ins->frame_color;
@ -182,7 +137,6 @@ void InsetText::init(InsetText const * ins)
drawTextYOffset = 0;
locked = false;
old_par = paragraphs.end();
sstate.cursor.par(paragraphs.end());
in_insetAllowed = false;
}
@ -192,9 +146,8 @@ void InsetText::clear(bool just_mark_erased)
if (just_mark_erased) {
ParagraphList::iterator it = paragraphs.begin();
ParagraphList::iterator end = paragraphs.end();
for (; it != end; ++it) {
for (; it != end; ++it)
it->markErased();
}
return;
}
@ -205,8 +158,6 @@ void InsetText::clear(bool just_mark_erased)
paragraphs.push_back(Paragraph());
paragraphs.begin()->setInsetOwner(this);
paragraphs.begin()->layout(old_layout);
reinitLyXText();
}
@ -385,7 +336,6 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
if (!autoBreakRows && paragraphs.size() > 1)
collapseParagraphs(bv);
text_.partialRebreak();
if (!text_.selection.set())
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)
{
if (cpos() == cpar()->size())
return false;
InsetOld * inset = cpar()->getInset(cpos());
if (!isHighlyEditableInset(inset))
return false;
@ -1534,7 +1486,6 @@ void InsetText::setText(string const & data, LyXFont const & font)
clear(false);
for (unsigned int i = 0; i < data.length(); ++i)
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;
updateLocal(bv, false);
}
drawFrame_ = how;
}
void InsetText::setFrameColor(BufferView * bv, LColor::color col)
void InsetText::setFrameColor(LColor::color col)
{
if (frame_color != col) {
frame_color = col;
updateLocal(bv, false);
}
frame_color = col;
}
@ -1638,8 +1583,14 @@ LyXText * InsetText::getLyXText(BufferView const * bv,
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);
}
}
@ -1654,87 +1605,14 @@ 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()
{
bool changed = false;
ParagraphList::iterator it = paragraphs.begin();
ParagraphList::iterator end = paragraphs.end();
for (; it != end; ++it) {
for (int i = 0; i < it->size(); ++i) {
if (it->isNewline(i)) {
changed = true;
for (; it != end; ++it)
for (int i = 0; i < it->size(); ++i)
if (it->isNewline(i))
it->erase(i);
}
}
}
if (changed)
reinitLyXText();
}
@ -1956,7 +1834,6 @@ void InsetText::collapseParagraphs(BufferView * bv)
mergeParagraph(bv->buffer()->params, paragraphs, first_par);
}
reinitLyXText();
}
@ -1981,8 +1858,6 @@ void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
ParagraphList::iterator pend = plist.end();
for (; pit != pend; ++pit)
paragraphs.push_back(*pit);
reinitLyXText();
}

View File

@ -13,7 +13,6 @@
#define INSETTEXT_H
#include "updatableinset.h"
#include "textcursor.h"
#include "LString.h"
#include "LColor.h"
#include "ParagraphList.h"
@ -129,9 +128,9 @@ public:
///
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 *,
bool const recursive = false) const;
@ -140,8 +139,6 @@ public:
///
void deleteLyXText(BufferView *, bool recursive = true) const;
///
void resizeLyXText(BufferView *, bool force = false) const;
///
bool showInsetDialog(BufferView *) const;
///
void getLabelList(std::vector<string> &) const;
@ -279,10 +276,6 @@ private:
///
void clearInset(BufferView *, int start_x, int baseline) const;
///
void saveLyXTextState() const;
///
void restoreLyXTextState() const;
///
void collapseParagraphs(BufferView *);
/* Private structures and variables */
@ -307,9 +300,6 @@ private:
///
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!
///
@ -320,8 +310,6 @@ private:
int mouse_x;
int mouse_y;
public:
///
void reinitLyXText() const;
///
mutable LyXText text_;
///

View File

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

View File

@ -152,8 +152,6 @@ public:
///
void insertInset(InsetOld * inset);
/// Completes the insertion with a rebreak
void partialRebreak();
/// a full rebreak of the whole text
void fullRebreak();
/// compute text metrics
@ -238,6 +236,8 @@ public:
WordLangTuple const selectNextWordToSpellcheck(float & value);
///
void selectSelectedWord();
/// re-computes the cached coordinates in the cursor
void redoCursor();
/// returns true if par was empty and was removed
bool setCursor(ParagraphList::iterator pit,
lyx::pos_type pos,
@ -403,12 +403,6 @@ private:
void insertParagraph(ParagraphList::iterator pit,
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
void setHeightOfRow(RowList::iterator rit);
@ -424,8 +418,6 @@ public:
/** Updates all counters starting BEHIND the row. Changed paragraphs
* with a dynamic left margin will be rebroken. */
void updateCounters();
///
void update();
/**
* Returns an inset if inset was hit, or 0 if not.
* 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);
}
@ -1192,12 +1193,6 @@ void Paragraph::deleteInsetsLyXText(BufferView * bv)
}
void Paragraph::resizeInsetsLyXText(BufferView * bv)
{
insetlist.resizeInsetsLyXText(bv);
}
void Paragraph::setContentsFromPar(Paragraph const & par)
{
pimpl_->setContentsFromPar(par);
@ -1355,7 +1350,7 @@ bool Paragraph::isFreeSpacing() const
return true;
// 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())
return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
return false;

View File

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

View File

@ -28,7 +28,6 @@
#include "language.h"
#include "encoding.h"
#include "lyxtext.h"
#include "lyxrow.h"
#include "rowpainter.h"
#include "lyxrc.h"
#include "lyxrow_funcs.h"
@ -1099,6 +1098,7 @@ int paintRows(BufferView const & bv, LyXText const & text,
{
RowList::iterator end = text.rows().end();
while (rit != end && yf < y2) {
//const_cast<LyXText &>(text).setHeightOfRow(rit);
paintRowsHelper(bv, text, rit, y + yo, xo, y + text.top_y());
y += 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 j = 0; j < columns_; ++j) {
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].back().right_line = true;
@ -400,15 +400,15 @@ void LyXTabular::init(BufferParams const & bp,
row_info.back().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);
}
column_info.back().right_line = true;
calculate_width_of_tabular();
rowofcell = vector<int>();
columnofcell = vector<int>();
rowofcell.clear();
columnofcell.clear();
set_row_column_number_info();
is_long_tabular = 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_,
cellstruct(bp)));
for (int i = 0; i <= row; ++i) {
for (int j = 0; j < columns_; ++j) {
for (int i = 0; i <= row; ++i)
for (int j = 0; j < columns_; ++j)
c_info[i][j] = cell_info[i][j];
}
}
for (int i = row + 1; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
for (int i = row + 1; i < rows_; ++i)
for (int j = 0; j < columns_; ++j)
c_info[i][j] = cell_info[i-1][j];
}
}
cell_info = c_info;
++row;
for (int j = 0; j < columns_; ++j) {
@ -481,22 +479,19 @@ void LyXTabular::appendColumn(BufferParams const & bp, int cell)
column_info[column + 1] = column_info[column];
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];
}
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];
}
// 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;
}
if (column + 2 >= columns_ ||
c_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
{
if (column + 2 >= columns_
|| c_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN)
c_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
}
}
cell_info = c_info;
//++column;
@ -575,6 +570,7 @@ void LyXTabular::set_row_column_number_info(bool oldformat)
} while (column < columns_ &&
cell_info[row][column].multicolumn
== LyXTabular::CELL_PART_OF_MULTICOLUMN);
if (column == columns_) {
column = 0;
++row;

View File

@ -11,7 +11,6 @@
#include <config.h>
#include "lyxtext.h"
#include "lyxrow.h"
#include "paragraph.h"
#include "gettext.h"
#include "bufferparams.h"
@ -487,7 +486,7 @@ int LyXText::leftMargin(Row const & row) const
InsetOld * ins;
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->needFullRow() || ins->display()))
return LEFT_MARGIN;
@ -1213,12 +1212,10 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
}
labeladdon = int(
(font_metrics::maxAscent(labelfont) *
layout->spacing.getValue() *
spacing_val)
+(font_metrics::maxDescent(labelfont) *
(font_metrics::maxAscent(labelfont) +
font_metrics::maxDescent(labelfont)) *
layout->spacing.getValue() *
spacing_val)
spacing_val
+ layout->topsep * 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)
{
// 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
setCursor(cursor.par(), 0);
if (boost::next(cursorRow()) != rows().end())
breakAgain(boost::next(cursorRow()));
redoParagraph(cursor.par());
}
@ -1602,16 +1514,10 @@ void LyXText::insertChar(char c)
// and it should (along with realtmpfont) when we type the space.
// 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
// movements. The moving cursor would refresh the current font
// Get the font that is used to calculate the baselineskip
pos_type const lastpos = cursor.par()->size();
LyXFont rawparfont =
cursor.par()->getFontSettings(bv()->buffer()->params,
lastpos - 1);
LyXFont realtmpfont = real_current_font;
LyXFont rawtmpfont = current_font;
if (!freeSpacing && IsLineSeparatorChar(c)) {
if ((cursor.pos() > 0
@ -2168,8 +2074,7 @@ void LyXText::backspace()
// This is an empty paragraph and we delete it just
// by moving the cursor one step
// left and let the DeleteEmptyParagraphMechanism
// handle the actual deletion
// of the paragraph.
// handle the actual deletion of the paragraph.
if (cursor.par() != ownerParagraphs().begin()) {
ParagraphList::iterator tmppit = boost::prior(cursor.par());
@ -2213,12 +2118,7 @@ void LyXText::backspace()
// Pasting is not allowed, if the paragraphs have different
// layout. I think it is a real bug of all other
// 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 =
bv()->buffer()->params.getLyXTextClass();
@ -2228,30 +2128,14 @@ void LyXText::backspace()
&& cursor.par()->getAlign() == tmppit->getAlign()) {
removeParagraph(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))
; //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);
// 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();
if (cursor.pos() && cursor.par()->isSeparator(cursor.pos() - 1))
cursor.pos(cursor.pos() - 1);
// the row may have changed, block, hfills etc.
updateCounters();
setCursor(cursor.par(), cursor.pos(), false);
}
} else {

View File

@ -28,7 +28,6 @@
#include "frontends/font_metrics.h"
#include "debug.h"
#include "lyxrc.h"
#include "lyxrow.h"
#include "FloatList.h"
#include "language.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
// are allowed to make cosmetic improvements. For instance make footnotes
// 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
{
Assert(pos >= 0);
@ -285,7 +282,31 @@ void LyXText::insertParagraph(ParagraphList::iterator pit,
rit = rowlist_.insert(rit, Row(pit, 0));
// 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 {
pit->applyLayout(lyxlayout);
makeFontEntriesLayoutSpecific(bv()->buffer()->params, *pit);
ParagraphList::iterator fppit = pit;
fppit->params().spaceTop(lyxlayout->fill_top ?
pit->params().spaceTop(lyxlayout->fill_top ?
VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE));
fppit->params().spaceBottom(lyxlayout->fill_bottom ?
pit->params().spaceBottom(lyxlayout->fill_bottom ?
VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE));
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)
{
ParagraphList::iterator pit(cursor.par());
ParagraphList::iterator end(cursor.par());
ParagraphList::iterator pit = cursor.par();
ParagraphList::iterator end = cursor.par();
ParagraphList::iterator start = pit;
if (selection.set()) {
@ -480,10 +500,8 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
if (depth < prev_after_depth
&& pit->layout()->labeltype != LABEL_BIBLIO) {
changed = true;
if (!test_only) {
if (!test_only)
pit->params().depth(depth + 1);
}
}
} else if (depth) {
changed = true;
@ -503,7 +521,6 @@ bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
if (test_only)
return changed;
redoParagraphs(start, pastend);
// We need to actually move the text->cursor. I don't
@ -623,35 +640,9 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
}
// reinsert the paragraph
// insert a new row, starting at position 0
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);
insertParagraph(pit, rit);
// why?
setHeightOfRow(rows().begin());
}
@ -659,7 +650,7 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
void LyXText::fullRebreak()
{
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
setCursorIntern(cursor.par(), cursor.pos());
redoCursor();
selection.cursor = cursor;
}
@ -691,25 +682,9 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & 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);
#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
dim.asc = rows().begin()->ascent_of_text();
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
@ -857,8 +822,8 @@ string LyXText::getStringToIndex()
// the DTP switches for paragraphs. LyX will store them in the first
// physicla paragraph. When a paragraph is broken, the top settings rest,
// the bottom settings are given to the new one. So I can make shure,
// physical paragraph. When a paragraph is broken, the top settings rest,
// 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
// them!
@ -962,13 +927,12 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
pit->itemdepth = 0;
}
/* Maybe we have to increment the enumeration depth.
* BUT, enumeration in a footnote is considered in isolation from its
* surrounding paragraph so don't increment if this is the
* first line of the footnote
* AND, bibliographies can't have their depth changed ie. they
* are always of depth 0
*/
// Maybe we have to increment the enumeration depth.
// BUT, enumeration in a footnote is considered in isolation from its
// surrounding paragraph so don't increment if this is the
// first line of the footnote
// AND, bibliographies can't have their depth changed ie. they
// are always of depth 0
if (pit != ownerParagraphs().begin()
&& boost::prior(pit)->getDepth() < pit->getDepth()
&& 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 (pit->params().labelWidthString().empty()) {
if (pit->params().labelWidthString().empty())
pit->setLabelWidthString(layout->labelstring());
}
} else {
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
void LyXText::updateCounters()
{
RowList::iterator rowit = rows().begin();
ParagraphList::iterator pit = rowit->par();
// CHECK if this is really needed. (Lgb)
// start over
bv()->buffer()->params.getLyXTextClass().counters().reset();
ParagraphList::iterator beg = ownerParagraphs().begin();
ParagraphList::iterator end = ownerParagraphs().end();
for (; pit != end; ++pit) {
while (rowit->par() != pit)
++rowit;
for (ParagraphList::iterator pit = beg; pit != end; ++pit) {
string const oldLabel = pit->params().labelString();
size_t maxdepth = 0;
@ -1171,10 +1128,8 @@ void LyXText::updateCounters()
string const & newLabel = pit->params().labelString();
if (oldLabel.empty() && !newLabel.empty()) {
removeParagraph(rowit);
appendParagraph(rowit);
}
if (oldLabel != newLabel)
redoParagraph(pit);
}
}
@ -1189,14 +1144,12 @@ void LyXText::insertInset(InsetOld * inset)
// Just to rebreak and refresh correctly.
// The character will not be inserted a second time
insertChar(Paragraph::META_INSET);
// If we enter a highly editable inset the cursor should be to before
// the inset. This couldn't happen before as Undo was not handled inside
// inset now after the Undo LyX tries to call inset->Edit(...) again
// and cannot do this as the cursor is behind the inset and GetInset
// If we enter a highly editable inset the cursor should be before
// the inset. After an Undo LyX tries to call inset->edit(...)
// and fails if the cursor is behind the inset and getInset
// does not return the inset!
if (isHighlyEditableInset(inset)) {
if (isHighlyEditableInset(inset))
cursorLeft(true);
}
unFreezeUndo();
}
@ -1238,7 +1191,6 @@ void LyXText::cutSelection(bool doclear, bool realcut)
recordUndo(bv(), Undo::DELETE, selection.start.par(),
boost::prior(undoendpit));
endpit = selection.end.par();
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,
pos_type pos, bool boundary)
{
@ -1538,11 +1497,11 @@ float LyXText::getCursorX(RowList::iterator rit,
cursor_vpos = (rit_par->isRightToLeftPar(bv()->buffer()->params))
? rit_pos : last + 1;
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)
? log2vis(pos - 1) + 1 : log2vis(pos - 1);
else
/// Place cursor before char at (logical) position pos
// Place cursor before char at (logical) position pos
cursor_vpos = (bidi_level(pos) % 2 == 0)
? log2vis(pos) : log2vis(pos) + 1;
@ -1581,32 +1540,6 @@ float LyXText::getCursorX(RowList::iterator rit,
void LyXText::setCursorIntern(ParagraphList::iterator pit,
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);
if (setfont)
setCurrentFont();
@ -1940,8 +1873,7 @@ void LyXText::cursorDownParagraph()
// fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism
void LyXText::fixCursorAfterDelete(LyXCursor & cur,
LyXCursor const & where)
void LyXText::fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where)
{
// if cursor is not in the paragraph where the delete occured,
// do nothing
@ -1970,10 +1902,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
return false;
// We allow all kinds of "mumbo-jumbo" when freespacing.
if (old_cursor.par()->layout()->free_spacing
|| old_cursor.par()->isFreeSpacing()) {
if (old_cursor.par()->isFreeSpacing())
return false;
}
/* Ok I'll put some comments here about what is missing.
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 (old_cursor.par() != cursor.par()
|| old_cursor.pos() != cursor.pos()) {
// Only if the cursor has really moved
// Only if the cursor has really moved
if (old_cursor.pos() > 0
&& old_cursor.pos() < old_cursor.par()->size()
&& old_cursor.par()->isLineSeparator(old_cursor.pos())
@ -2081,7 +2011,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
* there is another layout before */
RowList::iterator tmprit = boost::next(prevrow);
if (tmprit != rows().end()) {
breakAgain(tmprit);
redoParagraph(tmprit->par());
updateCounters();
}
setHeightOfRow(prevrow);
@ -2110,7 +2040,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
The next row can change its height, if
there is another layout before */
if (nextrow != rows().end()) {
breakAgain(nextrow);
redoParagraph(nextrow->par());
updateCounters();
}
}
@ -2146,8 +2076,7 @@ ParagraphList & LyXText::ownerParagraphs() const
bool LyXText::isInInset() const
{
// Sub-level has non-null bv owner and
// non-null inset owner.
// Sub-level has non-null bv owner and non-null inset owner.
return inset_owner != 0 && bv_owner != 0;
}

View File

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

View File

@ -57,7 +57,7 @@ public:
/// Init State
class TransInitState : virtual public TransFSMData, public TransState {
class TransInitState :virtual public TransFSMData, public TransState {
public:
///
TransInitState();