From c7a08d57cefbc2f19a867121a7c03cb9db3143e5 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 16 Mar 2009 13:33:27 +0000 Subject: [PATCH] implement new lfuns inset-begin/end and their -select versions git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28814 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/bind/cua.bind | 4 ++++ src/FuncCode.h | 6 ++++++ src/LyXAction.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ src/Text3.cpp | 26 +++++++++++++++++++++++++- 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index e87b96ab81..5bf17c4042 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -128,6 +128,8 @@ \bind "C-Down" "paragraph-down" \bind "C-Home" "buffer-begin" \bind "C-End" "buffer-end" +\bind "M-C-Home" "inset-begin" +\bind "M-C-End" "inset-end" \bind "C-~S-greater" "label-goto" \bind "C-~S-less" "bookmark-goto 0" @@ -151,6 +153,8 @@ \bind "S-Next" "screen-down-select" \bind "S-C-Home" "buffer-begin-select" \bind "S-C-End" "buffer-end-select" +\bind "S-M-C-Home" "inset-begin-select" +\bind "S-M-C-End" "inset-end-select" \bind "C-Insert" "copy" \bind "S-Insert" "paste" \bind "S-Delete" "cut" diff --git a/src/FuncCode.h b/src/FuncCode.h index 503f30f5a4..1d6428a331 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -418,6 +418,12 @@ enum FuncCode LFUN_VC_COMMAND, LFUN_MATH_FONT_STYLE, LFUN_PHANTOM_INSERT, // uwestoehr, 20090130 + LFUN_INSET_BEGIN, // JMarc, 20090316 + // 325 + LFUN_INSET_END, // JMarc, 20090316 + LFUN_INSET_BEGIN_SELECT, // JMarc, 20090316 + LFUN_INSET_END_SELECT, // JMarc, 20090316 + LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index ffbf8dc75b..1edf499ea9 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1009,6 +1009,49 @@ void LyXAction::init() */ { LFUN_BUFFER_END_SELECT, "buffer-end-select", ReadOnly, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_INSET_BEGIN + * \li Action: Move the cursor to the beginning of the current inset + if it is not already there, or at the beginning of the + enclosing inset otherwise + * \li Syntax: inset-begin + * \li Origin: JMarc, 2009/03/16 + * \endvar + */ + { LFUN_INSET_BEGIN, "inset-begin", ReadOnly, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_INSET_BEGIN_SELECT + * \li Action: Move the cursor to the beginning of the current inset + if it is not already there, or at the beginning of the + enclosing inset otherwise (adding the + traversed text to the selection). + * \li Syntax: inset-begin-select + * \li Origin: JMarc, 2009/03/16 + * \endvar + */ + { LFUN_INSET_BEGIN_SELECT, "inset-begin-select", ReadOnly, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_INSET_END + * \li Action: Move the cursor to the end of the current inset + if it is not already there, or at the end of the + enclosing inset otherwise + * \li Syntax: inset-end + * \li Origin: JMarc, 2009/03/16 + * \endvar + */ + { LFUN_INSET_END, "inset-end", ReadOnly, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_INSET_END_SELECT + * \li Action: Move the cursor to the end of the current inset + if it is not already there, or at the end of the + enclosing inset otherwise (adding the + traversed text to the selection). + * \li Syntax: inset-end-select + * \li Origin: JMarc, 2009/03/16 + * \endvar + */ + { LFUN_INSET_END_SELECT, "inset-end-select", ReadOnly, Edit }, + /*! * \var lyx::FuncCode lyx::LFUN_LINE_BEGIN * \li Action: Move the cursor to the begining of the (screen) line. diff --git a/src/Text3.cpp b/src/Text3.cpp index c212f156f1..50dcf34f7c 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -561,6 +561,26 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.updateFlags(Update::FitCursor); break; + case LFUN_INSET_BEGIN: + case LFUN_INSET_BEGIN_SELECT: + needsUpdate |= cur.selHandle(cmd.action == LFUN_INSET_BEGIN_SELECT); + if (cur.depth() == 1 || cur.pos() > 0) + needsUpdate |= cursorTop(cur); + else + cur.undispatched(); + cur.updateFlags(Update::FitCursor); + break; + + case LFUN_INSET_END: + case LFUN_INSET_END_SELECT: + needsUpdate |= cur.selHandle(cmd.action == LFUN_INSET_END_SELECT); + if (cur.depth() == 1 || cur.pos() < cur.lastpos()) + needsUpdate |= cursorBottom(cur); + else + cur.undispatched(); + cur.updateFlags(Update::FitCursor); + break; + case LFUN_CHAR_FORWARD: case LFUN_CHAR_FORWARD_SELECT: //LYXERR0(" LFUN_CHAR_FORWARD[SEL]:\n" << cur); @@ -2378,10 +2398,14 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_PARAGRAPH_PARAMS_APPLY: case LFUN_PARAGRAPH_PARAMS: case LFUN_ESCAPE: - case LFUN_BUFFER_END: case LFUN_BUFFER_BEGIN: + case LFUN_BUFFER_END: case LFUN_BUFFER_BEGIN_SELECT: case LFUN_BUFFER_END_SELECT: + case LFUN_INSET_BEGIN: + case LFUN_INSET_END: + case LFUN_INSET_BEGIN_SELECT: + case LFUN_INSET_END_SELECT: case LFUN_UNICODE_INSERT: // these are handled in our dispatch() enable = true; -- 2.39.2