I committed the following patch which implements inset-begin/end which
do not exactly do what you think they do ;) For example, for
buffer-begin
- if cursor is in the middle go to the beginning of the inset
- if it is already at the beginning, go at the beginning of the
enclosing inset

This is intended to be a quick way to move in nested insets (which
happen a lot for me with branches and minipages).

I am open to comments about the behaviour and possible bindings for
emacs and mac. For cua, I chose C-M-Home/End.

This is something that could go to branch after some polish.

JMarc

svndiff

Index: src/LyXAction.cpp
===================================================================
--- src/LyXAction.cpp	(révision 28813)
+++ src/LyXAction.cpp	(copie de travail)
@@ -1010,6 +1010,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.
  * \li Syntax: line-begin
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp	(révision 28813)
+++ src/Text3.cpp	(copie de travail)
@@ -561,6 +561,26 @@ void Text::dispatch(Cursor & cur, FuncRe
 		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, FuncR
 	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;
Index: src/FuncCode.h
===================================================================
--- src/FuncCode.h	(révision 28813)
+++ src/FuncCode.h	(copie de travail)
@@ -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
 };
Index: lib/bind/cua.bind
===================================================================
--- lib/bind/cua.bind	(révision 28813)
+++ lib/bind/cua.bind	(copie de travail)
@@ -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"

Reply via email to