#include "TextMetrics.h"
#include "TexRow.h"
#include "TocBackend.h"
-#include "VSpace.h"
#include "WordLangTuple.h"
#include "insets/InsetBibtex.h"
#include "frontends/Painter.h"
#include "frontends/Selection.h"
-#include "graphics/Previews.h"
-
#include "support/convert.h"
#include "support/debug.h"
#include "support/ExceptionMessage.h"
#include "support/filetools.h"
#include "support/gettext.h"
+#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/Package.h"
#include "support/types.h"
if (recenter)
scrolled = scroll(ypos - height_/2);
+ // We try to visualize the whole row, if the row height is larger than
+ // the screen height, we scroll to a heuristic value of height_ / 4.
+ // FIXME: This heuristic value should be replaced by a recursive search
+ // for a row in the inset that can be visualized completely.
+ else if (row_dim.height() > height_) {
+ if (ypos < defaultRowHeight())
+ scrolled = scroll(ypos - height_ / 4);
+ else if (ypos > height_ - defaultRowHeight())
+ scrolled = scroll(ypos - 3 * height_ / 4);
+ }
+
// If the top part of the row falls of the screen, we scroll
// up to align the top of the row with the top of the screen.
- else if (ypos - row_dim.ascent() < 0)
- scrolled = scrollUp(-ypos + row_dim.ascent());
+ else if (ypos - row_dim.ascent() < 0 && ypos < height_) {
+ int ynew = row_dim.ascent();
+ scrolled = scrollUp(ynew - ypos);
+ }
// If the bottom of the row falls of the screen, we scroll down.
- // However, we have to be careful not to scroll that much that
- // the top falls of the screen.
- else if (ypos + row_dim.descent() > height_) {
+ else if (ypos + row_dim.descent() > height_ && ypos > 0) {
int ynew = height_ - row_dim.descent();
- if (ynew < row_dim.ascent())
- ynew = row_dim.ascent();
- int const scroll = ypos - ynew;
- scrolled = scrollDown(scroll);
+ scrolled = scrollDown(ypos - ynew);
}
// else, nothing to do, the cursor is already visible so we just return.
break;
}
+ // FIXME:
+ // The change of language of buffer belongs to the Buffer class.
+ // We have to do it here because we need a cursor for Undo.
+ // When Undo::recordUndoBufferParams() is implemented someday
+ // LFUN_BUFFER_LANGUAGE should be handled by the Buffer class.
+ case LFUN_BUFFER_LANGUAGE: {
+ Language const * oldL = buffer_.params().language;
+ Language const * newL = languages.getLanguage(argument);
+ if (!newL || oldL == newL)
+ break;
+ if (oldL->rightToLeft() == newL->rightToLeft()) {
+ cur.recordUndoFullDocument();
+ buffer_.changeLanguage(oldL, newL);
+ cur.setCurrentFont();
+ dr.forceBufferUpdate();
+ }
+ break;
+ }
+
default:
// OK, so try the Buffer itself...
buffer_.dispatch(cmd, dr);