#include "insets/insetcommand.h"
#include "insets/insetnewline.h"
#include "undo_funcs.h"
+#include "text_funcs.h"
#include <ctime>
#include <clocale>
using std::endl;
using std::find;
using std::vector;
+using lyx::pos_type;
extern string current_layout;
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
}
if (!lt->isInInset()) {
bv->update(lt, BufferView::SELECT);
- bv->showCursor();
} else if (bv->text->refreshStatus() != LyXText::REFRESH_NONE) {
- bv->theLockingInset()->hideInsetCursor(bv);
bv->update(BufferView::SELECT);
- bv->showCursor();
}
if (!lt->selection.set())
bool LyXText::gotoNextInset(vector<Inset::Code> const & codes,
string const & contents)
{
- LyXCursor res = cursor;
+ ParagraphList::iterator end = ownerParagraphs().end();
+ ParagraphList::iterator pit = cursor.par();
+ pos_type pos = cursor.pos();
+
Inset * inset;
do {
- if (res.pos() < res.par()->size() - 1) {
- res.pos(res.pos() + 1);
+ if (pos + 1 < pit->size()) {
+ ++pos;
} else {
- res.par(res.par()->next());
- res.pos(0);
+ ++pit;
+ pos = 0;
}
- } while (res.par() &&
- !(res.par()->isInset(res.pos())
- && (inset = res.par()->getInset(res.pos())) != 0
- && find(codes.begin(), codes.end(), inset->lyxCode())
- != codes.end()
- && (contents.empty() ||
- static_cast<InsetCommand *>(
- res.par()->getInset(res.pos()))->getContents()
- == contents)));
-
- if (res.par()) {
- setCursor(res.par(), res.pos(), false);
+ } while (pit != end &&
+ !(pit->isInset(pos) &&
+ (inset = pit->getInset(pos)) != 0 &&
+ find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() &&
+ (contents.empty() ||
+ static_cast<InsetCommand *>(pit->getInset(pos))->getContents()
+ == contents)));
+
+ if (pit != end) {
+ setCursor(pit, pos, false);
return true;
}
return false;
void LyXText::gotoInset(vector<Inset::Code> const & codes,
- bool same_content)
+ bool same_content)
{
- bv()->hideCursor();
bv()->beforeChange(this);
update();
string contents;
- if (same_content && cursor.par()->isInset(cursor.pos())) {
+ if (same_content && cursor.pos() < cursor.par()->size()
+ && cursor.par()->isInset(cursor.pos())) {
Inset const * inset = cursor.par()->getInset(cursor.pos());
if (find(codes.begin(), codes.end(), inset->lyxCode())
!= codes.end())
}
if (!gotoNextInset(codes, contents)) {
- if (cursor.pos() || cursor.par() != ownerParagraph()) {
+ if (cursor.pos() || cursor.par() != ownerParagraphs().begin()) {
LyXCursor tmp = cursor;
- cursor.par(ownerParagraph());
+ cursor.par(ownerParagraphs().begin());
cursor.pos(0);
if (!gotoNextInset(codes, contents)) {
cursor = tmp;
void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
{
- bv->hideCursor();
lt->update();
InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
if (!bv->insertInset(new_inset))
switch (cmd.action) {
case LFUN_APPENDIX: {
- Paragraph * par = cursor.par();
- bool start = !par->params().startOfAppendix();
+ ParagraphList::iterator pit = cursor.par();
+ bool start = !pit->params().startOfAppendix();
// ensure that we have only one start_of_appendix in this document
- Paragraph * tmp = ownerParagraph();
- for (; tmp; tmp = tmp->next()) {
+ ParagraphList::iterator tmp = ownerParagraphs().begin();
+ ParagraphList::iterator end = ownerParagraphs().end();
+
+ for (; tmp != end; ++tmp) {
if (tmp->params().startOfAppendix()) {
- setUndo(bv, Undo::EDIT, tmp, tmp->next());
+ setUndo(bv, Undo::EDIT, tmp, boost::next(tmp));
tmp->params().startOfAppendix(false);
int tmpy;
setHeightOfRow(getRow(tmp, 0, tmpy));
}
}
- setUndo(bv, Undo::EDIT, par, par->next());
- par->params().startOfAppendix(start);
+ setUndo(bv, Undo::EDIT, pit, boost::next(pit));
+ pit->params().startOfAppendix(start);
// we can set the refreshing parameters now
updateCounters();
finishChange(bv);
break;
- case LFUN_SHIFT_TAB:
- case LFUN_TAB:
- if (!selection.mark())
- bv->beforeChange(this);
- update();
- cursorTab();
- finishChange(bv);
- break;
-
case LFUN_WORDRIGHT:
if (!selection.mark())
bv->beforeChange(this);
update();
// It is possible to make it a lot faster still
// just comment out the line below...
- bv->showCursor();
} else {
update();
cutSelection(bv, true);
update();
// It is possible to make it a lot faster still
// just comment out the line below...
- bv->showCursor();
}
} else {
update();
}
case LFUN_PARAGRAPH_SPACING: {
- Paragraph * par = cursor.par();
- Spacing::Space cur_spacing = par->params().spacing().getSpace();
+ ParagraphList::iterator pit = cursor.par();
+ Spacing::Space cur_spacing = pit->params().spacing().getSpace();
float cur_value = 1.0;
if (cur_spacing == Spacing::Other)
- cur_value = par->params().spacing().getValue();
+ cur_value = pit->params().spacing().getValue();
istringstream is(cmd.argument.c_str());
string tmp;
<< cmd.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
- par->params().spacing(Spacing(new_spacing, new_value));
+ pit->params().spacing(Spacing(new_spacing, new_value));
redoParagraph();
update();
}
break;
}
+ case LFUN_INSET_SETTINGS:
+ lyx::Assert(bv->theLockingInset());
+ bv->theLockingInset()->getLockingInset()->showInsetDialog(bv);
+ break;
+
case LFUN_INSET_TOGGLE:
- bv->hideCursor();
bv->beforeChange(this);
update();
toggleInset();
case LFUN_TRANSPOSE_CHARS:
update();
- transposeChars();
+ transposeChars(*this, cursor);
if (inset_owner)
bv->updateInset(inset_owner);
update();
case LFUN_PASTE:
cmd.message(_("Paste"));
- bv->hideCursor();
// clear the selection
bv->toggleSelection();
clearSelection();
break;
case LFUN_CUT:
- bv->hideCursor();
update();
cutSelection(bv, true);
update();
if (!change_layout && selection.set() &&
selection.start.par() != selection.end.par())
{
- Paragraph * spar = selection.start.par();
- Paragraph * epar = selection.end.par()->next();
- while (spar != epar) {
- if (spar->layout()->name() != current_layout) {
+ ParagraphList::iterator spit = selection.start.par();
+ ParagraphList::iterator epit = boost::next(selection.end.par());
+ while (spit != epit) {
+ if (spit->layout()->name() != current_layout) {
change_layout = true;
break;
}
- spar = spar->next();
+ ++spit;
}
}
if (change_layout) {
- bv->hideCursor();
current_layout = layout;
update();
setLayout(layout);
case LFUN_PASTESELECTION: {
if (!bv->buffer())
break;
- bv->hideCursor();
// this was originally a beforeChange(bv->text), i.e
// the outermost LyXText!
bv->beforeChange(this);
}
case LFUN_QUOTE: {
- Paragraph const * par = cursor.par();
+ ParagraphList::iterator pit = cursor.par();
lyx::pos_type pos = cursor.pos();
char c;
if (!pos)
c = ' ';
- else if (par->isInset(pos - 1) && par->getInset(pos - 1)->isSpace())
+ else if (pit->isInset(pos - 1) && pit->getInset(pos - 1)->isSpace())
c = ' ';
else
- c = par->getChar(pos - 1);
+ c = pit->getChar(pos - 1);
- bv->hideCursor();
- LyXLayout_ptr const & style = par->layout();
+ LyXLayout_ptr const & style = pit->layout();
if (style->pass_thru ||
- par->getFontSettings(bv->buffer()->params,
+ pit->getFontSettings(bv->buffer()->params,
pos).language()->lang() == "hebrew" ||
(!bv->insertInset(new InsetQuotes(c, bv->buffer()->params))))
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
break;
if (cmd.button() == mouse_button::button1) {
if (!isInInset()) {
- bv->screen().hideCursor();
bv->screen().toggleSelection(this, bv);
}
cursorHome();
break;
if (cmd.button() == mouse_button::button1) {
if (!isInInset()) {
- bv->screen().hideCursor();
bv->screen().toggleSelection(this, bv);
selectWord(LyXText::WHOLE_WORD_STRICT);
bv->screen().toggleSelection(this, bv, false);
Inset * tli = bv->theLockingInset();
LyXCursor cursor = bv->text->cursor;
LyXFont font = bv->text->getFont(bv->buffer(),
- cursor.par(), cursor.pos());
+ cursor.par(), cursor.pos());
int width = tli->width(bv, font);
int inset_x = font.isVisibleRightToLeft()
? cursor.ix() - width : cursor.ix();
break;
}
- bv->screen().hideCursor();
-
RowList::iterator cursorrow = bv->text->cursor.row();
bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->text->top_y());
#if 0
bv->text->setSelection();
bv->screen().toggleToggle(bv->text, bv);
bv->fitCursor();
- bv->showCursor();
break;
}
if (!inset_hit)
selection_possible = true;
- bv->screen().hideCursor();
// Clear the selection
bv->screen().toggleSelection(bv->text, bv);
UpdatableInset * inset = static_cast<UpdatableInset *>(inset_hit);
selection_possible = false;
bv->owner()->message(inset->editMessage());
- //inset->edit(bv, x, y, cmd.button());
// We just have to lock the inset before calling a PressEvent on it!
- // we don't need the edit() call here! (Jug20020329)
if (!bv->lockInset(inset))
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
FuncRequest cmd1(bv, LFUN_MOUSE_PRESS, x, y, cmd.button());