Introduce LFUN_SCROLL.

Santa-clauss.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22324 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-27 11:37:07 +00:00
parent 88942bcae4
commit 5587709f0e
5 changed files with 42 additions and 0 deletions

View File

@ -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"

View File

@ -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<int>(scroll_quantity);
if (scroll_value)
scroll(scroll_step * scroll_value);
}
}
void BufferView::scroll(int y)
{
if (y > 0)

View File

@ -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.

View File

@ -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 },

View File

@ -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|<number>\n
* \li Origin: Abdelrazak Younes, Dec 27 2007
*/
LFUN_SCROLL,
LFUN_LASTACTION // end of the table
};