#include "FloatList.h"
using std::copy;
+using std::find;
using std::endl;
+using std::find;
using std::pair;
void LyXText::init()
{
+ the_locking_inset = 0;
firstrow = 0;
lastrow = 0;
number_of_rows = 0;
false);
UpdateCounters(bview, cursor.row());
ClearSelection();
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
}
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row());
ClearSelection();
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row());
ClearSelection();
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
layoutfont = GetFont(bview->buffer(), cursor.par(),-1);
// Update current font
real_current_font.update(font,
- bview->buffer()->params.language_info,
+ bview->buffer()->params.language,
toggleall);
// Reduce to implicit settings
LyXFont newfont = GetFont(bview->buffer(),
cursor.par(), cursor.pos());
newfont.update(font,
- bview->buffer()->params.language_info,
+ bview->buffer()->params.language,
toggleall);
SetCharFont(bview->buffer(),
cursor.par(), cursor.pos(), newfont);
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
ClearSelection();
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
tmpcursor.boundary());
}
* They also delete the corresponding row */
// need the selection cursor:
-void LyXText::SetSelection()
+void LyXText::SetSelection(BufferView * bview)
{
+ const bool lsel = selection;
+
if (!selection) {
last_sel_cursor = sel_cursor;
sel_start_cursor = sel_cursor;
if (sel_start_cursor.par() == sel_end_cursor.par() &&
sel_start_cursor.pos() == sel_end_cursor.pos())
selection = false;
+
+ if (inset_owner && (selection || lsel))
+ inset_owner->SetUpdateStatus(bview, InsetText::SELECTION);
}
void LyXText::ClearSelection() const
{
+ if (selection)
+ status = LyXText::NEED_MORE_REFRESH;
selection = false;
mark_set = false;
}
// If there is a change in the language the implicit word selection
// is disabled.
LyXCursor resetCursor = cursor;
- bool implicitSelection = (font.language() == ignore_language)
+ bool implicitSelection = (font.language() == ignore_language
+ && font.number() == LyXFont::IGNORE)
? SelectWordWhenUnderCursor(bview) : false;
// Set font
SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor;
}
+ if (inset_owner)
+ inset_owner->SetUpdateStatus(bview, InsetText::CURSOR_PAR);
}
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
if (inset_owner)
bview->updateInset(inset_owner, true);
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
- SetSelection();
+ SetSelection(bview);
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
// entry in the marginnote and the enclosing
// environment is an enum/item then correct for the
// LaTeX behaviour (ARRae)
- if(par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
+ if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::MARGIN
&& par->Previous()
&& par->Previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
Floating const & fl
= floatList.getType(tmp->type());
// We should get the correct number here too.
- s = fl.name + " #:";
+ s = fl.name() + " #:";
} else {
/* par->SetLayout(0);
s = layout->labelstring; */
* The character will not be inserted a
* second time */
#if 1
- // if we enter a text-inset the cursor should be to the left side
- // of it! This couldn't happen before as Undo was not handled inside
+ // 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
// does not return the inset!
- if (inset->IsTextInset()) {
- if (cursor.par()->isRightToLeftPar(bview->buffer()->params))
- CursorRight(bview);
- else
- CursorLeft(bview);
+ if (inset->Editable() == Inset::HIGHLY_EDITABLE) {
+ CursorLeft(bview, true);
}
#endif
}
return;
// OK, we have a selection. This is always between sel_start_cursor
- // and sel_end cursor
+ // and sel_end_cursor
#ifndef NEW_INSETS
// Check whether there are half footnotes in the selection
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
sel_cursor = cursor;
SetCursor(bview, actpar, pos);
- SetSelection();
+ SetSelection(bview);
UpdateCounters(bview, cursor.row());
}
LyXParagraph::size_type pos,
string const & str) const
{
- if (par) {
- LyXParagraph::size_type i = 0;
- while (pos + i < par->Last()
- && string::size_type(i) < str.length()
- && str[i] == par->GetChar(pos + i)) {
- ++i;
- }
- if (str.length() == string::size_type(i))
- return true;
+ if (!par)
+ return false;
+
+ LyXParagraph::size_type i = 0;
+ while (pos + i < par->Last()
+ && string::size_type(i) < str.length()
+ && str[i] == par->GetChar(pos + i)) {
+ ++i;
}
+ if (str.length() == string::size_type(i))
+ return true;
return false;
}
sel_cursor = cursor;
for (int i = 0; str[i]; ++i)
CursorRight(bview);
- SetSelection();
+ SetSelection(bview);
}
SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor;
SetCursor(bview, par, pos);
- SetSelection();
+ SetSelection(bview);
}
}
-bool LyXText::GotoNextError(BufferView * bview) const
+bool LyXText::GotoNextInset(BufferView * bview,
+ std::vector<Inset::Code> const & codes,
+ string const & contents) const
{
LyXCursor res = cursor;
+ Inset * inset;
do {
if (res.pos() < res.par()->Last() - 1) {
res.pos(res.pos() + 1);
} while (res.par() &&
!(res.par()->GetChar(res.pos()) == LyXParagraph::META_INSET
- && res.par()->GetInset(res.pos())->AutoDelete()));
-
- if (res.par()) {
- SetCursor(bview, res.par(), res.pos());
- return true;
- }
- return false;
-}
-
+ && (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)));
-bool LyXText::GotoNextNote(BufferView * bview) const
-{
- LyXCursor res = cursor;
- do {
- if (res.pos() < res.par()->Last() - 1) {
- res.pos(res.pos() + 1);
- } else {
- res.par(res.par()->Next());
- res.pos(0);
- }
-
- } while (res.par() &&
- !(res.par()->GetChar(res.pos()) == LyXParagraph::META_INSET
- && res.par()->GetInset(res.pos())->LyxCode() == Inset::IGNORE_CODE));
-
if (res.par()) {
SetCursor(bview, res.par(), res.pos());
return true;
// is there a break one row above
if (row->previous() && row->previous()->par() == row->par()) {
z = NextBreakPoint(bview, row->previous(), workWidth(bview));
- if ( z >= row->pos()) {
+ if (z >= row->pos()) {
// set the dimensions of the row above
y -= row->previous()->height();
refresh_y = y;
// set the cursor again. Otherwise
// dangling pointers are possible
- SetCursor(bview, cursor.par(), cursor.pos());
+ SetCursor(bview, cursor.par(), cursor.pos(),
+ false, cursor.boundary());
sel_cursor = cursor;
return;
}
if (selection) {
tmpcursor = cursor;
- SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos());
+ SetCursorIntern(bview, sel_cursor.par(), sel_cursor.pos(),
+ false, sel_cursor.boundary());
sel_cursor = cursor;
SetCursorIntern(bview, sel_start_cursor.par(),
- sel_start_cursor.pos());
+ sel_start_cursor.pos(),
+ false, sel_start_cursor.boundary());
sel_start_cursor = cursor;
SetCursorIntern(bview, sel_end_cursor.par(),
- sel_end_cursor.pos());
+ sel_end_cursor.pos(),
+ false, sel_end_cursor.boundary());
sel_end_cursor = cursor;
SetCursorIntern(bview, last_sel_cursor.par(),
- last_sel_cursor.pos());
+ last_sel_cursor.pos(),
+ false, last_sel_cursor.boundary());
last_sel_cursor = cursor;
cursor = tmpcursor;
}
- SetCursorIntern(bview, cursor.par(), cursor.pos());
+ SetCursorIntern(bview, cursor.par(), cursor.pos(),
+ false, cursor.boundary());
}
LyXCursor tmpcursor;
if (old_cursor.par() != cursor.par()) {
- if ( (old_cursor.par()->Last() == 0
+ if ((old_cursor.par()->Last() == 0
|| (old_cursor.par()->Last() == 1
&& old_cursor.par()->IsLineSeparator(0)))
#ifndef NEW_INSETS
end = end->next;
}
- if (start && end
- && start != end->next
- && (before != behind || (!before && !behind))) {
+ if (start && end && (start != end->next) &&
+ ((before != behind) || (!before && !behind)))
+ {
tmppar = start;
tmppar2 = tmppar->Clone();
tmppar2->id(tmppar->id());