bool BufferView::fitCursor()
{
- if (bv_funcs::status(this, cursor_) == bv_funcs::CUR_INSIDE) {
+ if (cursorStatus(cursor_) == CUR_INSIDE) {
frontend::FontMetrics const & fm =
theFontMetrics(cursor_.getFont());
int const asc = fm.maxAscent();
int const last = height_ - height;
Cursor & cur = cursor_;
- bv_funcs::CurStatus st = bv_funcs::status(this, cur);
-
- switch (st) {
- case bv_funcs::CUR_ABOVE:
- // We reset the cursor because bv_funcs::status() does not
+ switch (cursorStatus(cur)) {
+ case CUR_ABOVE:
+ // We reset the cursor because cursorStatus() does not
// work when the cursor is within mathed.
cur.reset(buffer_.inset());
tm.setCursorFromCoordinates(cur, 0, first);
cur.clearSelection();
break;
- case bv_funcs::CUR_BELOW:
- // We reset the cursor because bv_funcs::status() does not
+ case CUR_BELOW:
+ // We reset the cursor because cursorStatus() does not
// work when the cursor is within mathed.
cur.reset(buffer_.inset());
tm.setCursorFromCoordinates(cur, 0, last);
cur.clearSelection();
break;
- case bv_funcs::CUR_INSIDE:
+ case CUR_INSIDE:
int const y = bv_funcs::getPos(*this, cur, cur.boundary()).y_;
int const newy = min(last, max(y, first));
if (y != newy) {
}
+// this could be used elsewhere as well?
+// FIXME: This does not work within mathed!
+CursorStatus BufferView::cursorStatus(DocIterator const & dit) const
+{
+ Point const p = bv_funcs::getPos(*this, dit, dit.boundary());
+ if (p.y_ < 0)
+ return CUR_ABOVE;
+ if (p.y_ > workHeight())
+ return CUR_BELOW;
+ return CUR_INSIDE;
+}
+
+
void BufferView::saveBookmark(unsigned int idx)
{
// tenatively save bookmark, id and pos will be used to
class ParIterator;
class ParagraphMetrics;
class ViewMetricsInfo;
+
+enum CursorStatus {
+ CUR_INSIDE,
+ CUR_ABOVE,
+ CUR_BELOW
+};
/// Scrollbar Parameters.
struct ScrollbarParameters
/// access to anchor.
pit_type anchor_ref() const;
+ ///
+ CursorStatus cursorStatus(DocIterator const & dit) const;
/// access to full cursor.
Cursor & cursor();
/// access to full cursor.
ParagraphMetrics const & parMetrics(Text const *, pit_type) const;
///
- CoordCache & coordCache() {
- return coord_cache_;
- }
+ CoordCache & coordCache() { return coord_cache_; }
///
- CoordCache const & coordCache() const {
- return coord_cache_;
- }
+ CoordCache const & coordCache() const { return coord_cache_; }
///
void draw(frontend::Painter & pain);
for ( ; it != et; it.forwardPos()) {
// avoid invalid nesting when selecting
- if (bv_funcs::status(&bv, it) == bv_funcs::CUR_INSIDE
+ if (bv.cursorStatus(it) == CUR_INSIDE
&& (!cur.selection() || positionable(it, cur.anchor_))) {
Point p = bv_funcs::getPos(bv, it, false);
int xo = p.x_;
{
pair<pit_type, ParagraphMetrics> const & last = *par_metrics_.rbegin();
pit_type const pit = last.first + 1;
- if (pit == text_->paragraphs().size())
+ if (pit == int(text_->paragraphs().size()))
return;
// do it and update its position.
// clip above
int middleTop;
- bool const clipAbove =
- (bv_funcs::status(bv_, beg) == bv_funcs::CUR_ABOVE);
+ bool const clipAbove = (bv_->cursorStatus(beg) == CUR_ABOVE);
if (clipAbove)
middleTop = 0;
else
// clip below
int middleBottom;
- bool const clipBelow =
- (bv_funcs::status(bv_, end) == bv_funcs::CUR_BELOW);
+ bool const clipBelow = (bv_->cursorStatus(end) == CUR_BELOW);
if (clipBelow)
middleBottom = bv_->workHeight();
else
middleBottom = bv_funcs::getPos(*bv_, end, end.boundary()).y_ - row2.ascent();
// start and end in the same line?
- if (!(clipAbove || clipBelow) && &row1 == &row2)
+ if (!clipAbove && !clipBelow && &row1 == &row2)
// then only draw this row's selection
drawRowSelection(pi, x, row1, beg, end, false, false);
else {
return p;
}
-
-// this could be used elsewhere as well?
-// FIXME: This does not work within mathed!
-CurStatus status(BufferView const * bv, DocIterator const & dit)
-{
- Point const p = bv_funcs::getPos(*bv, dit, dit.boundary());
- if (p.y_ < 0)
- return CUR_ABOVE;
- if (p.y_ > bv->workHeight())
- return CUR_BELOW;
-
- return CUR_INSIDE;
-}
-
-
} // namespace bv_funcs
#define BUFFERVIEW_FUNCS_H
#include <string>
-#include <vector>
namespace lyx {
Point getPos(BufferView const & bv, DocIterator const & dit, bool boundary);
-enum CurStatus {
- CUR_INSIDE,
- CUR_ABOVE,
- CUR_BELOW
-};
-
-
-CurStatus status(BufferView const * bv, DocIterator const & dit);
-
-
Point coordOffset(BufferView const & bv, DocIterator const & dit, bool boundary);
} // namespace bv_funcs