/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
#include "buffer.h"
#include "lyxcursor.h"
#include "lyxtext.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
#include "bufferlist.h"
-#include "lyxscreen.h"
+#include "frontends/screen.h"
#include "LaTeX.h"
#include "BufferView_pimpl.h"
#include "language.h"
#include "undo_funcs.h"
#include "debug.h"
#include "iterators.h"
+#include "lyxlex.h"
+#include "WordLangTuple.h"
#include "frontends/Alert.h"
+#include "frontends/Dialogs.h"
#include "insets/insetcommand.h" //ChangeRefs
#include "insets/inseterror.h"
// Copyright CHT Software Service GmbH
// Uwe C. Schroeder
//
- // Insert a Lyxformat - file into current buffer
+ // Insert a LyXformat - file into current buffer
//
// Moved from lyx_cb.C (Lgb)
{
- if (filen.empty()) return false;
+ if (filen.empty())
+ return false;
string const fname = MakeAbsPath(filen);
MakeDisplayPath(fname, 50));
return false;
}
-
+
beforeChange(text);
ifstream ifs(fname.c_str());
MakeDisplayPath(fname, 50));
return false;
}
-
+
int const c = ifs.peek();
-
+
LyXLex lex(0, 0);
lex.setStream(ifs);
lyxerr[Debug::INFO] << "Will insert file with header" << endl;
res = buffer()->readFile(lex, text->cursor.par());
} else {
- lyxerr[Debug::INFO] << "Will insert file without header"
+ lyxerr[Debug::INFO] << "Will insert file without header"
<< endl;
res = buffer()->readLyXformat2(lex, text->cursor.par());
}
cursor_par = cursor_par_prev;
cursor_pos = cursor_par_prev->size();
cursor_par_prev = cursor_par->previous();
- // cursor_par_next remains the same
+ // cursor_par_next remains the same
} else if (cursor_par_next) {
// First step below may occur before while{}
// .
}
}
- Paragraph::inset_iterator pit = par->inset_iterator_begin();
- Paragraph::inset_iterator pend = par->inset_iterator_end();
+ InsetList::iterator pit = par->insetlist.begin();
+ InsetList::iterator pend = par->insetlist.end();
+
while (pit != pend) {
- if (pit->autoDelete()) {
+ if (pit.getInset()->autoDelete()) {
removed = true;
pos_type const pos = pit.getPos();
par->erase(pos);
// We just invalidated par's inset iterators so
// we get the next valid iterator position
- pit = par->InsetIterator(pos);
+ pit = par->insetlist.insetIterator(pos);
// and ensure we have a valid end iterator.
- pend = par->inset_iterator_end();
+ pend = par->insetlist.end();
if (cursor_par == par) {
// update the saved cursor position
int const errorrow = cit->error_in_line;
// Insert error string for row number
- int tmpid = -1;
+ int tmpid = -1;
int tmppos = -1;
if (buffer()->texrow.getIdFromRow(errorrow, tmpid, tmppos)) {
buffer()->texrow.increasePos(tmpid, tmppos);
}
-
+
Paragraph * texrowpar = 0;
if (tmpid == -1) {
if (texrowpar == 0)
continue;
+ freezeUndo();
InsetError * new_inset = new InsetError(msgtxt);
text->setCursorIntern(this, texrowpar, tmppos);
text->insertInset(this, new_inset);
text->fullRebreak(this);
+ unFreezeUndo();
}
// Restore the cursor position
text->setCursorIntern(this, cursor.par(), cursor.pos());
void BufferView::setCursorFromRow(int row)
{
- int tmpid = -1;
+ int tmpid = -1;
int tmppos = -1;
buffer()->texrow.getIdFromRow(row, tmpid, tmppos);
}
-/* This is also a buffer property (ale) */
+// This is also a buffer property (ale)
// Not so sure about that. a goto Label function can not be buffer local, just
-// think how this will work in a multiwindo/buffer environment, all the
+// think how this will work in a multiwindow/buffer environment, all the
// cursors in all the views showing this buffer will move. (Lgb)
// OK, then no cursor action should be allowed in buffer. (ale)
bool BufferView::gotoLabel(string const & label)
-
{
for (Buffer::inset_iterator it = buffer()->inset_iterator_begin();
it != buffer()->inset_iterator_end(); ++it) {
- vector<string> labels = (*it)->getLabelList();
+ vector<string> labels = it->getLabelList();
if (find(labels.begin(),labels.end(),label)
!= labels.end()) {
beforeChange(text);
void BufferView::menuUndo()
{
- if (available()) {
- owner()->message(_("Undo"));
- hideCursor();
- beforeChange(text);
- update(text, BufferView::SELECT|BufferView::FITCUR);
- if (!textUndo(this))
- owner()->message(_("No further undo information"));
- else
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- setState();
- }
+ if (!available())
+ return;
+
+ owner()->message(_("Undo"));
+ hideCursor();
+ beforeChange(text);
+ update(text, BufferView::SELECT|BufferView::FITCUR);
+ if (!textUndo(this))
+ owner()->message(_("No further undo information"));
+ else
+ update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ switchKeyMap();
}
void BufferView::menuRedo()
{
-#if 0 // this should not be here (Jug 20011206)
- if (theLockingInset()) {
- owner()->message(_("Redo not yet supported in math mode"));
+ if (!available())
return;
- }
-#endif
-
- if (available()) {
- owner()->message(_("Redo"));
- hideCursor();
- beforeChange(text);
- update(text, BufferView::SELECT|BufferView::FITCUR);
- if (!textRedo(this))
- owner()->message(_("No further redo information"));
- else
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- setState();
- }
+
+ owner()->message(_("Redo"));
+ hideCursor();
+ beforeChange(text);
+ update(text, BufferView::SELECT|BufferView::FITCUR);
+ if (!textRedo(this))
+ owner()->message(_("No further redo information"));
+ else
+ update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ switchKeyMap();
}
}
-void BufferView::copy()
-{
- if (available()) {
- text->copySelection(this);
- owner()->message(_("Copy"));
- }
-}
-
-
-void BufferView::cut(bool realcut)
-{
- if (available()) {
- hideCursor();
- update(text, BufferView::SELECT|BufferView::FITCUR);
- text->cutSelection(this, true, realcut);
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- owner()->message(_("Cut"));
- }
-}
-
-
-void BufferView::paste()
-{
- if (!available()) return;
-
- owner()->message(_("Paste"));
-
- hideCursor();
- // clear the selection
- toggleSelection();
- text->clearSelection();
- update(text, BufferView::SELECT|BufferView::FITCUR);
-
- // paste
- text->pasteSelection(this);
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
- // clear the selection
- toggleSelection();
- text->clearSelection();
- update(text, BufferView::SELECT|BufferView::FITCUR);
-}
-
-
-/* these functions are for the spellchecker */
-string const BufferView::nextWord(float & value)
+// these functions are for the spellchecker
+WordLangTuple const BufferView::nextWord(float & value)
{
if (!available()) {
value = 1;
- return string();
+ return WordLangTuple();
}
return text->selectNextWordToSpellcheck(this, value);
}
-
+
void BufferView::selectLastWord()
{
- if (!available()) return;
-
+ if (!available())
+ return;
+
LyXCursor cur = text->selection.cursor;
hideCursor();
beforeChange(text);
void BufferView::endOfSpellCheck()
{
if (!available()) return;
-
+
hideCursor();
beforeChange(text);
text->selectSelectedWord(this);
void BufferView::replaceWord(string const & replacestring)
{
- if (!available()) return;
+ if (!available())
+ return;
LyXText * tt = getLyXText();
hideCursor();
update(tt, BufferView::SELECT|BufferView::FITCUR);
-
- /* clear the selection (if there is any) */
+
+ // clear the selection (if there is any)
toggleSelection(false);
update(tt, BufferView::SELECT|BufferView::FITCUR);
-
- /* clear the selection (if there is any) */
+
+ // clear the selection (if there is any)
toggleSelection(false);
tt->replaceSelectionWithString(this, replacestring);
-
+
tt->setSelectionOverString(this, replacestring);
// Go back so that replacement string is also spellchecked
}
}
// Then do a deep look of the inset and lock the right one
- Paragraph * par = buffer()->paragraph;
int const id = inset->id();
- while(par) {
- Paragraph::inset_iterator it =
- par->inset_iterator_begin();
- Paragraph::inset_iterator const end =
- par->inset_iterator_end();
+ ParagraphList::iterator pit = buffer()->paragraphs.begin();
+ ParagraphList::iterator pend = buffer()->paragraphs.end();
+ for (; pit != pend; ++pit) {
+ InsetList::iterator it = pit->insetlist.begin();
+ InsetList::iterator end = pit->insetlist.end();
for (; it != end; ++it) {
- if ((*it) == inset) {
- text->setCursorIntern(this, par, it.getPos());
+ if (it.getInset() == inset) {
+ text->setCursorIntern(this, &*pit, it.getPos());
theLockingInset(inset);
return true;
}
- if ((*it)->getInsetFromID(id)) {
- text->setCursorIntern(this, par, it.getPos());
- (*it)->edit(this);
+ if (it.getInset()->getInsetFromID(id)) {
+ text->setCursorIntern(this, &*pit, it.getPos());
+ it.getInset()->edit(this);
return theLockingInset()->lockInsetInInset(this, inset);
}
}
- par = par->next();
}
return false;
}
(cursor.par()->getInset(cursor.pos() - 1) ==
locking_inset))
text->setCursor(this, cursor,
- cursor.par(), cursor.pos() - 1);
+ cursor.par(), cursor.pos() - 1);
LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE;
LyXText * txt = getLyXText();
if (locking_inset->isTextInset() &&
shape = (txt->real_current_font.isVisibleRightToLeft())
? LyXScreen::REVERSED_L_SHAPE
: LyXScreen::L_SHAPE;
- y += cursor.y() + theLockingInset()->insetInInsetY();
- pimpl_->screen_->showManualCursor(text, x, y, asc, desc,
+ y += cursor.iy() + theLockingInset()->insetInInsetY();
+ screen().showManualCursor(text, x, y, asc, desc,
shape);
}
}
void BufferView::hideLockedInsetCursor()
{
if (theLockingInset() && available()) {
- pimpl_->screen_->hideCursor();
+ screen().hideCursor();
}
}
-void BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
+bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
{
if (theLockingInset() && available()) {
- y += text->cursor.y() + theLockingInset()->insetInInsetY();
- if (pimpl_->screen_->fitManualCursor(text, this, x, y, asc, desc))
+ y += text->cursor.iy() + theLockingInset()->insetInInsetY();
+ if (screen().fitManualCursor(this, text, x, y, asc, desc)) {
updateScrollbar();
+ return true;
+ }
}
+ return false;
}
inset->insetUnlock(this);
theLockingInset(0);
// make sure we update the combo !
- owner()->setLayout(getLyXText()->cursor.par()->layout());
+ owner()->setLayout(getLyXText()->cursor.par()->layout()->name());
+ // Tell the paragraph dialog that we changed paragraph
+ owner()->getDialogs().updateParagraph();
finishUndo();
return 0;
} else if (inset && theLockingInset() &&
theLockingInset()->unlockInsetInInset(this, inset)) {
- // owner inset has updated the layout combo
+ // Tell the paragraph dialog that we changed paragraph
+ owner()->getDialogs().updateParagraph();
+ // owner inset has updated the layout combo
finishUndo();
return 0;
}
if (kind == Undo::EDIT) // in this case insets would not be stored!
kind = Undo::FINISH;
setUndo(this, kind,
- text->cursor.par(),
- text->cursor.par()->next());
+ text->cursor.par(),
+ text->cursor.par()->next());
}
it != end; ++it) {
Paragraph * par = *it;
bool changed_inset = false;
- for (Paragraph::inset_iterator it2 = par->inset_iterator_begin();
- it2 != par->inset_iterator_end(); ++it2) {
- if ((*it2)->lyxCode() == code) {
- InsetCommand * inset = static_cast<InsetCommand *>(*it2);
+ for (InsetList::iterator it2 = par->insetlist.begin();
+ it2 != par->insetlist.end(); ++it2) {
+ if (it2.getInset()->lyxCode() == code) {
+ InsetCommand * inset = static_cast<InsetCommand *>(it2.getInset());
if (inset->getContents() == from) {
inset->setContents(to);
changed_inset = true;
}
if (changed_inset) {
need_update = true;
-#ifdef WITH_WARNINGS
-#warning FIXME
-#endif
+
+ // FIXME
+
// The test it.size()==1 was needed to prevent crashes.
// How to set the cursor corretly when it.size()>1 ??
if (it.size() == 1) {
string const & to)
{
typedef pair<string, string> StringPair;
-
- vector<StringPair> keys = buffer()->getBibkeyList();
- if (count_if(keys.begin(), keys.end(),
- lyx::equal_1st_in_pair<StringPair>(from))
+
+ vector<StringPair> keys = buffer()->getBibkeyList();
+ if (count_if(keys.begin(), keys.end(),
+ lyx::equal_1st_in_pair<StringPair>(from))
> 1)
return false;