From 5587709f0e6562e20b3bdb37f10dff9b96c929c0 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 27 Dec 2007 11:37:07 +0000 Subject: [PATCH] Introduce LFUN_SCROLL. Santa-clauss. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22324 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/bind/cua.bind | 4 ++++ src/BufferView.cpp | 26 ++++++++++++++++++++++++++ src/BufferView.h | 2 ++ src/LyXAction.cpp | 1 + src/lfuns.h | 9 +++++++++ 5 files changed, 42 insertions(+) diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index d8dc27084a..ba1ea0048a 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -100,6 +100,10 @@ \bind "C-F4" "buffer-close" \bind "M-F4" "lyx-quit" \bind "F5" "screen-recenter" +\bind "C-M-Up" "scroll line up" +\bind "C-M-Down" "scroll line down" +\bind "C-M-Prior" "scroll page up" +\bind "C-M-Next" "scroll page down" \bind "C-F6" "buffer-next" \bind "C-S-F6" "buffer-previous" \bind "F7" "dialog-show spellchecker" diff --git a/src/BufferView.cpp b/src/BufferView.cpp index b160285c13..7afe959d58 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -830,6 +830,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd) case LFUN_SCREEN_UP: case LFUN_SCREEN_DOWN: + case LFUN_SCROLL: flag.enabled(true); break; @@ -1218,6 +1219,10 @@ bool BufferView::dispatch(FuncRequest const & cmd) break; } + case LFUN_SCROLL: + lfunScroll(cmd); + break; + case LFUN_SCREEN_UP_SELECT: case LFUN_SCREEN_DOWN_SELECT: { // Those two are not ready yet for consumption. @@ -1408,6 +1413,27 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0) } +void BufferView::lfunScroll(FuncRequest const & cmd) +{ + string const scroll_type = cmd.getArg(0); + int const scroll_step = + (scroll_type == "line")? d->scrollbarParameters_.lineScrollHeight + : (scroll_type == "page")? height_ : 0; + if (scroll_step == 0) + 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(scroll_quantity); + if (scroll_value) + scroll(scroll_step * scroll_value); + } +} + + void BufferView::scroll(int y) { if (y > 0) diff --git a/src/BufferView.h b/src/BufferView.h index f1897cb964..765267b421 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -134,6 +134,8 @@ public: /// This method will automatically scroll and update the BufferView and updated /// if needed. void showCursor(); + /// LFUN_SCROLL Helper. + void lfunScroll(FuncRequest const & cmd); /// scroll down document by the given number of pixels. void scrollDown(int pixels); /// scroll up document by the given number of pixels. diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index c1222ff06d..de2d41e7a3 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -276,6 +276,7 @@ void LyXAction::init() { LFUN_SCREEN_DOWN, "screen-down", ReadOnly, Edit }, { LFUN_SCREEN_DOWN_SELECT, "screen-down-select", ReadOnly, Edit }, { LFUN_SCREEN_FONT_UPDATE, "screen-font-update", NoBuffer, Layout }, + { LFUN_SCROLL, "scroll", ReadOnly, Edit }, { LFUN_SCREEN_RECENTER, "screen-recenter", ReadOnly, Edit }, { LFUN_SCREEN_UP, "screen-up", ReadOnly, Edit }, { LFUN_SCREEN_UP_SELECT, "screen-up-select", ReadOnly, Edit }, diff --git a/src/lfuns.h b/src/lfuns.h index add94e5c28..8f9686fdef 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -476,6 +476,15 @@ enum kb_action { // 315 LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM, LFUN_IN_MATHMACROTEMPLATE, +/** LFUN_SCROLL + * \li Action: scroll the buffer view. + * \li Notion: Only about scrolling up or down; do not modify the cursor. + * \li Syntax: scroll [TYPE] [QUANTITY] + * \li Params: TYPE: line|page\n + QUANTITY: up|down|\n + * \li Origin: Abdelrazak Younes, Dec 27 2007 +*/ + LFUN_SCROLL, LFUN_LASTACTION // end of the table }; -- 2.39.2