#include "lyxrow.h"
#include "paragraph.h"
#include "ParagraphParameters.h"
-#include "PosIterator.h"
#include "iterators.h"
#include "frontends/Alert.h"
#include "insets/insettext.h"
-#include "mathed/math_cursor.h"
-
#include "support/tostr.h"
-
#include "support/std_sstream.h"
using lyx::support::bformat;
bool changeDepthAllowed(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
{
- if (!bv->available() || !text)
- return false;
-
- return text->changeDepthAllowed(type);
+ return bv->available() && text && text->changeDepthAllowed(type);
}
void changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
{
- if (!bv->available() || !text)
- return;
- text->changeDepth(type);
+ if (bv->available() && text)
+ text->changeDepth(type);
}
// Returns the current font and depth as a message.
string const currentState(BufferView * bv)
{
+ ostringstream state;
+
if (!bv->available())
return string();
- if (mathcursor)
- return mathcursor->info();
-
- ostringstream state;
+ if (bv->cursor().inMathed()) {
+ bv->cursor().info(state);
+ return state.str();
+ }
LyXText * text = bv->getLyXText();
Buffer * buffer = bv->buffer();
}
-
// deletes a selection during an insertion
void replaceSelection(LyXText * text)
{
- if (text->selection.set()) {
+ if (text->bv()->cursor().selection()) {
text->cutSelection(true, false);
text->bv()->update();
}
}
-
-/*
-if the fitCursor call refers to some point in never-explored-land, then we
-don't have y information in insets there, then we cannot even do an update
-to get it (because we need the y infomation for setting top_y first). So
-this is solved in put_selection_at with:
-
-- setting top_y to the y of the outerPar (that has good info)
-- calling update
-- calling cursor().updatePos()
-- then call fitCursor()
-
-Ab.
-*/
-
-void put_selection_at(BufferView * bv, PosIterator const & cur,
- int length, bool backwards)
-{
- ParIterator par(cur);
-
- bv->getLyXText()->clearSelection();
-
- LyXText * text = par.text(*bv->buffer());
- par.lockPath(bv);
- // hack for the chicken and egg problem
- if (par.inset())
- bv->top_y(par.outerPar()->y);
- bv->update();
- text->setCursor(cur.pit(), cur.pos());
- bv->cursor().updatePos();
-
- if (length) {
- text->setSelectionRange(length);
- text->setSelection();
- if (backwards)
- std::swap(text->cursor(), text->anchor());
- }
-
- bv->fitCursor();
- bv->update();
-}
-
-
} // namespace bv_funcs