#include "lyxrc.h"
#include "lastfiles.h"
#include "paragraph.h"
+#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "TextCache.h"
#include "undo_funcs.h"
}
+void BufferView::Pimpl::top_y(int y)
+{
+ top_y_ = y;
+}
+
+
+int BufferView::Pimpl::top_y() const
+{
+ return top_y_;
+}
+
+
void BufferView::Pimpl::buffer(Buffer * b)
{
lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
// set current buffer
buffer_ = b;
+ top_y_ = 0;
+
// if we're quitting lyx, don't bother updating stuff
if (quitting)
return;
resizeCurrentBuffer();
// FIXME: needed when ?
- bv_->text->top_y(screen().topCursorVisible(bv_->text));
+ top_y(screen().topCursorVisible(bv_->text));
// Buffer-dependent dialogs should be updated or
// hidden. This should go here because some dialogs (eg ToC)
bv_->theLockingInset(the_locking_inset);
}
- bv_->text->top_y(screen().topCursorVisible(bv_->text));
+ top_y(screen().topCursorVisible(bv_->text));
switchKeyMap();
owner_->busy(false);
LyXText const & t = *bv_->text;
lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() "
- << t.top_y() << ", default height " << defaultRowHeight() << endl;
+ << top_y() << ", default height " << defaultRowHeight() << endl;
- workarea().setScrollbarParams(t.height, t.top_y(), defaultRowHeight());
+ workarea().setScrollbarParams(t.height, top_y(), defaultRowHeight());
}
screen().hideCursor();
- bv_->text->top_y(value);
+ top_y(value);
screen().redraw(*bv_);
if (!lyxrc.cursor_follows_scrollbar)
return;
int const height = defaultRowHeight();
- int const first = int((bv_->text->top_y() + height));
- int const last = int((bv_->text->top_y() + workarea().workHeight() - height));
+ int const first = top_y() + height;
+ int const last = top_y() + workarea().workHeight() - height;
LyXText * text = bv_->text;
if (text->cursor.y() < first)
int const line_height = defaultRowHeight();
// The new absolute coordinate
- int new_top_y = t->top_y() + lines * line_height;
+ int new_top_y = top_y() + lines * line_height;
// Restrict to a valid value
new_top_y = std::min(t->height - 4 * line_height, new_top_y);
scrollDocView(new_top_y);
// Update the scrollbar.
- workarea().setScrollbarParams(t->height, t->top_y(), defaultRowHeight());
+ workarea().setScrollbarParams(t->height, top_y(), defaultRowHeight());
}
text->selection.end != bv_->text->xsel_cache.end))
{
bv_->text->xsel_cache = text->selection;
- sel = text->selectionAsString(bv_->buffer(), false);
+ sel = text->selectionAsString(*bv_->buffer(), false);
} else if (!text->selection.set()) {
sel = string();
bv_->text->xsel_cache.set(false);
if (bv_->getLyXText()) {
// check needed to survive LyX startup
bv_->getLyXText()->redoCursor();
- fitCursor();
}
screen().redraw(*bv_);
}
beforeChange(text);
int const half_height = workarea().workHeight() / 2;
- int new_y = 0;
-
- if (text->cursor.y() > half_height)
- new_y = text->cursor.y() - half_height;
+ int new_y = std::max(0, text->cursor.y() - half_height);
// FIXME: look at this comment again ...
// and also might have moved top_y() must make sure to call
// updateScrollbar() currently. Never mind that this is a
// pretty obfuscated way of updating t->top_y()
- text->top_y(new_y);
+ top_y(new_y);
//screen().draw();
update();
}
screen().hideCursor();
bool const res = dispatch(ev);
-
+
// see workAreaKeyPress
cursor_timeout.restart();
screen().showCursor(*bv_);
case LFUN_INSET_INSERT: {
InsetOld * inset = createInset(ev);
if (inset && insertInset(inset)) {
- updateInset();
+ updateInset(inset);
string const name = ev.getArg(0);
if (name == "bibitem") {
string arg = ev.argument;
if (arg.empty()) {
- arg = bv_->getLyXText()->selectionAsString(buffer_,
+ arg = bv_->getLyXText()->selectionAsString(*buffer_,
false);
// FIXME
if (arg.size() > 100 || arg.empty()) {
// Get word or selection
bv_->getLyXText()->selectWordWhenUnderCursor(lyx::WHOLE_WORD);
- arg = bv_->getLyXText()->selectionAsString(buffer_, false);
+ arg = bv_->getLyXText()->selectionAsString(*buffer_, false);
// FIXME: where is getLyXText()->unselect(bv_) ?
}
}
}
-void BufferView::Pimpl::updateInset()
+void BufferView::Pimpl::updateInset(InsetOld const * inset)
{
if (!available())
return;
+ bv_->text->redoParagraph(outerPar(*bv_->buffer(), inset));
+
// this should not be needed, but it is...
- //bv_->text->redoParagraph(bv_->text->cursor.par());
- //bv_->text->fullRebreak();
+ // bv_->text->redoParagraph(bv_->text->cursor.par());
+ // bv_->text->fullRebreak();
update();
updateScrollbar();