mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Get rid of BufferView::scrollUp/Down
LFUN_SCROLL was the last user, change it to use only scroll(). Take this opportunity to improve a bit this dispatch code. Also improve somewhat the methods documentation.
This commit is contained in:
parent
f52842d289
commit
439b7bb9c9
@ -2168,18 +2168,24 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
scroll_step = d->scrollbarParameters_.single_step;
|
||||
else if (scroll_type == "page")
|
||||
scroll_step = d->scrollbarParameters_.page_step;
|
||||
else
|
||||
return;
|
||||
string const scroll_quantity = cmd.getArg(1);
|
||||
if (scroll_quantity == "up")
|
||||
scrollUp(scroll_step);
|
||||
else if (scroll_quantity == "down")
|
||||
scrollDown(scroll_step);
|
||||
else {
|
||||
int const scroll_value = convert<int>(scroll_quantity);
|
||||
if (scroll_value)
|
||||
scroll(scroll_step * scroll_value);
|
||||
dispatched = false;
|
||||
return;
|
||||
}
|
||||
|
||||
string const scroll_quantity = cmd.getArg(1);
|
||||
|
||||
if (scroll_quantity == "up")
|
||||
scroll(-scroll_step);
|
||||
else if (scroll_quantity == "down")
|
||||
scroll(scroll_step);
|
||||
else if (isStrInt(scroll_quantity))
|
||||
scroll(scroll_step * convert<int>(scroll_quantity));
|
||||
else {
|
||||
dispatched = false;
|
||||
return;
|
||||
}
|
||||
|
||||
dr.screenUpdate(Update::ForceDraw);
|
||||
dr.forceBufferUpdate();
|
||||
break;
|
||||
@ -2859,20 +2865,6 @@ int BufferView::scroll(int pixels)
|
||||
}
|
||||
|
||||
|
||||
int BufferView::scrollDown(int pixels)
|
||||
{
|
||||
d->anchor_ypos_ -= pixels;
|
||||
return -pixels;
|
||||
}
|
||||
|
||||
|
||||
int BufferView::scrollUp(int pixels)
|
||||
{
|
||||
d->anchor_ypos_ += pixels;
|
||||
return pixels;
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::setCursorFromRow(int row)
|
||||
{
|
||||
TexRow::TextEntry start, end;
|
||||
|
@ -218,17 +218,17 @@ public:
|
||||
/// Ensure the passed cursor \p dit is visible.
|
||||
/// This method will automatically scroll and update the BufferView
|
||||
/// (metrics+drawing) if needed.
|
||||
/// \param how Use this scroll strategy
|
||||
/// \param how: where the cursor should appear (visible/top/center)
|
||||
void showCursor(DocIterator const & dit, ScrollType how);
|
||||
/// Scroll to the cursor.
|
||||
/// \param how Use this scroll strategy
|
||||
/// This only updates the anchor vertical position, but does not
|
||||
/// recompute metrics nor trigger a screen refresh.
|
||||
/// \param how: where the cursor should appear (visible/top/center)
|
||||
/// \return true if screen was scrolled
|
||||
bool scrollToCursor(DocIterator const & dit, ScrollType how);
|
||||
/// scroll down document by the given number of pixels.
|
||||
int scrollDown(int pixels);
|
||||
/// scroll up document by the given number of pixels.
|
||||
int scrollUp(int pixels);
|
||||
/// scroll document by the given number of pixels.
|
||||
/// scroll the view by the given number of pixels. This only
|
||||
/// updates the anchor vertical position, but does not recompute
|
||||
/// metrics nor trigger a screen refresh.
|
||||
int scroll(int pixels);
|
||||
/// Scroll the view by a number of pixels.
|
||||
void scrollDocView(int pixels);
|
||||
|
Loading…
Reference in New Issue
Block a user