+2003-03-18 Alfredo Braunstein <abraunst@libero.it>
+
+ * lyxtext.h:
+ * text.C:
+ * text2.C: anchor row on setCursor
+
2003-03-18 Alfredo Braunstein <abraunst@libero.it>
* lyxtext.h: remove almost all mutable keywords
2003-03-18 Alfredo Braunstein <abraunst@libero.it>
* lyxtext.h: remove almost all mutable keywords
/// the current font
LyXFont real_current_font;
private:
/// the current font
LyXFont real_current_font;
private:
- /** the first visible row on screen
+ /** the 'anchor' row: the position of this row remains constant
+ * with respect to the top of the screen
/** the pixel offset with respect to this row of top_y
*/
/** the pixel offset with respect to this row of top_y
*/
+ int anchor_row_offset_;
public:
/// get the y coord. of the top of the screen (relative to doc start)
int top_y() const;
public:
/// get the y coord. of the top of the screen (relative to doc start)
int top_y() const;
+ /// set the y coord. of the top of the screen (relative to doc start)
+ /// set the anchoring row. top_y will be computed relative to this
+ void anchor_row(Row * row);
///
InsetText * inset_owner;
///
///
InsetText * inset_owner;
///
int LyXText::top_y() const
{
int LyXText::top_y() const
{
- for (Row * row = firstrow; row && row != top_row_; row = row->next()) {
+ for (Row * row = firstrow;
+ row && row != anchor_row_; row = row->next()) {
- return y + top_row_offset_;
+ return y + anchor_row_offset_;
lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
int y = newy;
lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
int y = newy;
- top_row_ = getRowNearY(y);
- top_row_offset_ = newy - y;
- lyxerr[Debug::GUI] << "changing reference to row: " << top_row_
- << " offset: " << top_row_offset_ << endl;
+ anchor_row_ = getRowNearY(y);
+ anchor_row_offset_ = newy - y;
+ lyxerr[Debug::GUI] << "changing reference to row: " << anchor_row_
+ << " offset: " << anchor_row_offset_ << endl;
+}
+
+
+void LyXText::anchor_row(Row * row)
+{
+ int old_y = top_y();
+ anchor_row_offset_ = 0;
+ anchor_row_ = row;
+ anchor_row_offset_ = old_y - top_y();
+ lyxerr[Debug::GUI] << "anchor_row(): changing reference to row: "
+ << anchor_row_ << " offset: " << anchor_row_offset_
+ << endl;
LyXText::LyXText(BufferView * bv)
LyXText::LyXText(BufferView * bv)
- : height(0), width(0), top_row_(0), top_row_offset_(0),
+ : height(0), width(0), anchor_row_(0), anchor_row_offset_(0),
inset_owner(0), the_locking_inset(0), need_break_row(0),
bv_owner(bv), firstrow(0), lastrow(0)
{
inset_owner(0), the_locking_inset(0), need_break_row(0),
bv_owner(bv), firstrow(0), lastrow(0)
{
LyXText::LyXText(BufferView * bv, InsetText * inset)
LyXText::LyXText(BufferView * bv, InsetText * inset)
- : height(0), width(0), top_row_(0), top_row_offset_(0),
+ : height(0), width(0), anchor_row_(0), anchor_row_offset_(0),
inset_owner(inset), the_locking_inset(0), need_break_row(0),
bv_owner(bv), firstrow(0), lastrow(0)
{
inset_owner(inset), the_locking_inset(0), need_break_row(0),
bv_owner(bv), firstrow(0), lastrow(0)
{
// what about refresh_y
}
// what about refresh_y
}
- if (top_row_ == row) {
- if (row->next()) {
- top_row_ = row->next();
- top_row_offset_ -= row->height();
+ if (anchor_row_ == row) {
+ if (row_prev) {
+ anchor_row_ = row_prev;
+ anchor_row_offset_ = 0;
- top_row_ = row_prev;
- top_row_offset_ = 0;
+ anchor_row_ = row->next();
+ anchor_row_offset_ -= row->height();
cur.ix(int(x));
} else
cur.ix(cur.x());
cur.ix(int(x));
} else
cur.ix(cur.x());
+ //if the cursor is in a visible row, anchor to it
+ int topy = top_y();
+ if (topy < y && y < topy + bv()->workHeight())
+ anchor_row(row);