#include <boost/current_function.hpp>
#include <sstream>
+#include <limits>
using lyx::pit_type;
int x, int y, int xlow, int xhigh, int ylow, int yhigh)
{
BOOST_ASSERT(!cursor.empty());
- pit_type beg, end;
CursorSlice bottom = cursor[0];
LyXText * text = bottom.text();
BOOST_ASSERT(text);
-
+
DocIterator it = doc_iterator_begin(bottom.inset());
DocIterator const et = doc_iterator_end(bottom.inset());
return false;
}
-
} // namespace anon
-// be careful: this is called from the bv's constructor, too, so
+// be careful: this is called from the bv's constructor, too, so
// bv functions are not yet available!
LCursor::LCursor(BufferView & bv)
: DocIterator(), bv_(&bv), anchor_(), x_target_(-1),
void LCursor::dispatch(FuncRequest const & cmd0)
{
- lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
+ lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: "
+ << cmd0 << endl << *this << endl;
if (empty())
return;
LCursor safe = *this;
for (; size(); pop()) {
- lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
+ lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: "
+ << cmd0 << endl << *this << endl;
BOOST_ASSERT(pos() <= lastpos());
BOOST_ASSERT(idx() <= lastidx());
BOOST_ASSERT(pit() <= lastpit());
}
-bool LCursor::getStatus(FuncRequest const & cmd, FuncStatus & status)
-{
- // This is, of course, a mess. Better create a new doc iterator and use
- // this in Inset::getStatus. This might require an additional
- // BufferView * arg, though (which should be avoided)
- LCursor safe = *this;
- bool res = false;
- for ( ; size(); pop()) {
- //lyxerr << "\nLCursor::getStatus: cmd: " << cmd << endl << *this << endl;
- if (idx() > lastidx()) {
- lyxerr << "wrong idx " << idx() << ", max is " << lastidx()
- << ". Trying to correct this." << endl;
- idx() = lastidx();
- }
- if (pit() > lastpit()) {
- lyxerr << "wrong par " << pit() << ", max is " << lastpit()
- << ". Trying to correct this." << endl;
- pit() = lastpit();
- }
- if (pos() > lastpos()) {
- lyxerr << "wrong pos " << pos() << ", max is " << lastpos()
- << ". Trying to correct this." << endl;
- pos() = lastpos();
- }
-
- // The inset's getStatus() will return 'true' if it made
- // a definitive decision on whether it want to handle the
- // request or not. The result of this decision is put into
- // the 'status' parameter.
- if (inset().getStatus(*this, cmd, status)) {
- res = true;
- break;
- }
- }
- operator=(safe);
- return res;
-}
-
-
BufferView & LCursor::bv() const
{
BOOST_ASSERT(bv_);
}
-void LCursor::getDim(int & asc, int & des) const
-{
- if (inMathed()) {
- BOOST_ASSERT(inset().asMathInset());
- //inset().asMathInset()->getCursorDim(asc, des);
- asc = 10;
- des = 2;
- } else if (inTexted()) {
- LyXFont const & realfont = text()->real_current_font;
- asc = font_metrics::maxAscent(realfont);
- des = font_metrics::maxDescent(realfont);
- } else {
- lyxerr << "should this happen?" << endl;
- asc = 10;
- des = 10;
- }
-}
-
-
void LCursor::getPos(int & x, int & y) const
{
Point p = bv_funcs::getPos(*this);
}
}
- // try current cell for e.g. text insets
- if (inset().idxUpDown2(*this, up))
- return true;
-
//xarray().boundingBox(xlow, xhigh, ylow, yhigh);
//if (up)
// yhigh = yo - 4;
if (operator[](s).text())
break;
CursorSlice const & sl = operator[](s);
- LyXText & text = *sl.text();
+ LyXText const & text = *sl.text();
LyXFont font = text.getPar(sl.pit()).getFont(
bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
return font.language()->encoding();
{
disp_.update(false);
}
+
+
+LyXFont LCursor::getFont() const
+{
+ // HACK. far from being perfect...
+ int s = 0;
+ // go up until first non-0 text is hit
+ // (innermost text is 0 in mathed)
+ for (s = size() - 1; s >= 0; --s)
+ if (operator[](s).text())
+ break;
+ CursorSlice const & sl = operator[](s);
+ LyXText const & text = *sl.text();
+ LyXFont font = text.getPar(sl.pit()).getFont(
+ bv().buffer()->params(),
+ sl.pos(),
+ outerFont(sl.pit(), text.paragraphs()));
+ for (; s < size(); ++s)
+ ;
+ return font;
+}