mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
cosmetics
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20577 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bd03eaa571
commit
f1687373b1
@ -252,7 +252,7 @@ Buffer const & BufferView::buffer() const
|
||||
|
||||
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();
|
||||
@ -446,24 +446,22 @@ void BufferView::setCursorFromScrollbar()
|
||||
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) {
|
||||
@ -484,6 +482,19 @@ Change const BufferView::getCurrentChange() const
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
@ -48,6 +48,12 @@ class Text;
|
||||
class ParIterator;
|
||||
class ParagraphMetrics;
|
||||
class ViewMetricsInfo;
|
||||
|
||||
enum CursorStatus {
|
||||
CUR_INSIDE,
|
||||
CUR_ABOVE,
|
||||
CUR_BELOW
|
||||
};
|
||||
|
||||
/// Scrollbar Parameters.
|
||||
struct ScrollbarParameters
|
||||
@ -171,6 +177,8 @@ public:
|
||||
/// access to anchor.
|
||||
pit_type anchor_ref() const;
|
||||
|
||||
///
|
||||
CursorStatus cursorStatus(DocIterator const & dit) const;
|
||||
/// access to full cursor.
|
||||
Cursor & cursor();
|
||||
/// access to full cursor.
|
||||
@ -210,13 +218,9 @@ public:
|
||||
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);
|
||||
|
@ -218,7 +218,7 @@ namespace {
|
||||
|
||||
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_;
|
||||
|
@ -1177,7 +1177,7 @@ void TextMetrics::newParMetricsDown()
|
||||
{
|
||||
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.
|
||||
@ -1995,8 +1995,7 @@ void TextMetrics::drawSelection(PainterInfo & pi,
|
||||
|
||||
// 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
|
||||
@ -2004,15 +2003,14 @@ void TextMetrics::drawSelection(PainterInfo & pi,
|
||||
|
||||
// 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 {
|
||||
|
@ -253,21 +253,6 @@ Point getPos(BufferView const & bv, DocIterator const & dit, bool boundary)
|
||||
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
|
||||
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#define BUFFERVIEW_FUNCS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
@ -40,16 +39,6 @@ std::string const freefont2string();
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user