#include "BufferView.h"
#include "language.h"
#include "ParagraphParameters.h"
+#include "undo_funcs.h"
using std::max;
using std::min;
tmpinset->draw(bview, font, offset+row->baseline(), x,
cleared);
#ifdef SEEMS_TO_BE_NOT_NEEDED
- if (status == CHANGED_IN_DRAW) {
+ if (status_ == CHANGED_IN_DRAW) {
UpdateInset(bview, tmpinset);
- status = CHANGED_IN_DRAW;
+ status(bview, CHANGED_IN_DRAW);
}
#endif
}
&& layout.labeltype!= LABEL_SENSITIVE)
return;
- setUndo(bview->buffer(), Undo::INSERT,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::INSERT,cursor.par(),cursor.par()->next());
// Always break behind a space
//
cursorLeft(bview);
}
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
* same Paragraph one to the right and make a rebreak */
void LyXText::insertChar(BufferView * bview, char c)
{
- setUndo(bview->buffer(), Undo::INSERT,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::INSERT,
+ cursor.par(), cursor.par()->next());
// When the free-spacing option is set for the current layout,
// disable the double-space checking
y -= row->previous()->height();
refresh_y = y;
refresh_row = row->previous();
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row);
refresh_row = row;
refresh_x = cursor.x();
refresh_pos = cursor.pos();
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row);
// will the cursor be in another row now?
if (rowLast(row) <= cursor.pos() + 1 && row->next()) {
int const tmpheight = row->height();
setHeightOfRow(bview, row);
if (tmpheight == row->height())
- status = LyXText::NEED_VERY_LITTLE_REFRESH;
+ status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
else
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
current_font = rawtmpfont;
real_current_font = realtmpfont;
if (row->par()->getChar(row->pos()) == Paragraph::META_INSET
&& (inset=row->par()->getInset(row->pos()))
&& (inset->display())) // || (inset->scroll() < 0)))
- align = (inset->LyxCode() == Inset::MATHMACRO_CODE)
+ align = (inset->lyxCode() == Inset::MATHMACRO_CODE)
? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER;
switch (align) {
// Start the selection from here
selection.cursor = cursor;
- std::ostringstream latex;
+ ostringstream latex;
// and find the end of the word
// (optional hyphens are part of a word)
&& (cursor.par()->isLetter(cursor.pos()))
|| (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
&& cursor.par()->getInset(cursor.pos()) != 0
- && cursor.par()->getInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
+ && cursor.par()->getInset(cursor.pos())->latex(bview->buffer(), latex, false, false) == 0
&& latex.str() == "\\-"
))
cursor.pos(cursor.pos() + 1);
// set the sel cursor
selection.cursor = cursor;
- std::ostringstream latex;
+ ostringstream latex;
// now find the end of the word
while (cursor.pos() < cursor.par()->size()
&& (cursor.par()->isLetter(cursor.pos())
|| (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET
&& cursor.par()->getInset(cursor.pos()) != 0
- && cursor.par()->getInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
+ && cursor.par()->getInset(cursor.pos())->latex(bview->buffer(), latex, false, false) == 0
&& latex.str() == "\\-"
)))
cursor.pos(cursor.pos() + 1);
LyXCursor to;
if (selection.set()) {
- from = selection.cursor;
- to = cursor;
+ from = selection.start;
+ to = selection.end;
} else {
getWord(from, to, PARTIAL_WORD);
- setCursor(bview, to.par(), to.pos()+1);
+ setCursor(bview, to.par(), to.pos() + 1);
}
- setUndo(bview->buffer(), Undo::FINISH,
- from.par()->previous(), to.par()->next());
-
-#if 1
- changeRegionCase(bview, to, from, action);
-#else
- while(from != to) {
- unsigned char c = from.par()->getChar(from.pos());
- if (!IsInsetChar(c) && !IsHfillChar(c)) {
- switch (action) {
- case text_lowercase:
- c = tolower(c);
- break;
- case text_capitalization:
- c = toupper(c);
- action = text_lowercase;
- break;
- case text_uppercase:
- c = toupper(c);
- break;
- }
- }
- from.par()->setChar(from.pos(), c);
- checkParagraph(bview, from.par(), from.pos());
- from.pos(from.pos() + 1);
- if (from.pos() >= from.par()->size()) {
- from.par(from.par()->next());
- from.pos(0);
- }
- }
- if (to.row() != from.row()) {
- refresh_y = from.y() - from.row()->baseline();
- refresh_row = from.row();
- status = LyXText::NEED_MORE_REFRESH;
- }
-#endif
+ changeRegionCase(bview, from, to, action);
}
LyXCursor const & to,
LyXText::TextCase action)
{
- setUndo(bview->buffer(), Undo::FINISH,
- from.par()->previous(), to.par()->next());
-
- LyXCursor tmp(from);
+ lyx::Assert(from <= to);
- while(tmp != to) {
- unsigned char c = tmp.par()->getChar(tmp.pos());
+ setUndo(bview, Undo::FINISH,
+ from.par(), to.par()->next());
+
+ Paragraph::size_type pos = from.pos();
+ Paragraph * par = from.par();
+
+ while (par && (pos != to.pos() || par != to.par())) {
+ unsigned char c = par->getChar(pos);
if (!IsInsetChar(c) && !IsHfillChar(c)) {
switch (action) {
case text_lowercase:
break;
}
}
- tmp.par()->setChar(tmp.pos(), c);
- checkParagraph(bview, tmp.par(), tmp.pos());
- tmp.pos(tmp.pos() + 1);
- if (tmp.pos() >= tmp.par()->size()) {
- tmp.par(tmp.par()->next());
- tmp.pos(0);
+ par->setChar(pos, c);
+ checkParagraph(bview, par, pos);
+
+ ++pos;
+ if (pos == par->size()) {
+ par = par->next();
+ pos = 0;
}
}
- if (to.row() != tmp.row()) {
- refresh_y = tmp.y() - tmp.row()->baseline();
- refresh_row = tmp.row();
- status = LyXText::NEED_MORE_REFRESH;
+ if (to.row() != from.row()) {
+ refresh_y = from.y() - from.row()->baseline();
+ refresh_row = from.row();
+ status(bview, LyXText::NEED_MORE_REFRESH);
}
}
-void LyXText::transposeChars(BufferView const & bview)
+void LyXText::transposeChars(BufferView & bview)
{
Paragraph * tmppar = cursor.par();
- setUndo(bview.buffer(), Undo::FINISH,
- tmppar->previous(), tmppar->next());
+ setUndo(&bview, Undo::FINISH,
+ tmppar, tmppar->next());
Paragraph::size_type tmppos = cursor.pos();
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
LyXCursor tmpcursor = cursor;
cursor = old_cursor; // to make sure undo gets the right cursor position
- setUndo(bview->buffer(), Undo::DELETE,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::DELETE,
+ cursor.par(), cursor.par()->next());
cursor = tmpcursor;
backspace(bview);
}
if (cursor.row()->height() != tmpheight) {
refresh_y = cursor.y() - cursor.row()->baseline();
refresh_row = cursor.row();
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
}
return;
}
}
if (cursor.par()->previous()) {
- setUndo(bview->buffer(), Undo::DELETE,
- cursor.par()->previous()->previous(),
+ setUndo(bview, Undo::DELETE,
+ cursor.par()->previous(),
cursor.par()->next());
}
if (cursor.pos())
cursor.pos(cursor.pos() - 1);
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
} else {
/* this is the code for a normal backspace, not pasting
* any paragraphs */
- setUndo(bview->buffer(), Undo::DELETE,
- cursor.par()->previous(),
- cursor.par()->next());
+ setUndo(bview, Undo::DELETE,
+ cursor.par(), cursor.par()->next());
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
// some insets are undeletable here
if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
- if (!cursor.par()->getInset(cursor.pos())->Deletable())
+ if (!cursor.par()->getInset(cursor.pos())->deletable())
return;
// force complete redo when erasing display insets
// this is a cruel method but safe..... Matthias
refresh_y = y;
refresh_row = tmprow;
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
setCursor(bview, cursor.par(), cursor.pos(),
false, cursor.boundary());
//current_font = rawtmpfont;
refresh_y = y;
refresh_row = row;
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row);
// will the cursor be in another row now?
int const tmpheight = row->height();
setHeightOfRow(bview, row);
if (tmpheight == row->height())
- status = LyXText::NEED_VERY_LITTLE_REFRESH;
+ status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
else
- status = LyXText::NEED_MORE_REFRESH;
+ status(bview, LyXText::NEED_MORE_REFRESH);
refresh_y = y;
refresh_row = row;
setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());