]> git.lyx.org Git - features.git/commitdiff
Introduce new LFUN_SECTION_SELECT. When this lfun is called and the cursor is in...
authorVincent van Ravesteijn <vfr@lyx.org>
Sun, 3 May 2009 18:58:00 +0000 (18:58 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 3 May 2009 18:58:00 +0000 (18:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29518 a592a061-630c-0410-9148-cb99ea01b6c8

src/FuncCode.h
src/LyXAction.cpp
src/Text3.cpp

index 33cca3a56c661a69b6458e666666d96512a1b979..d2257a4e3718d535a35ca7b65e13a7fc62a46110 100644 (file)
@@ -428,6 +428,7 @@ enum FuncCode
        // 330
        LFUN_MATH_BIGDELIM,
        LFUN_MATH_FONT_STYLE,
+       LFUN_SECTION_SELECT,            // vfr, 20090503
 
 
        LFUN_LASTACTION                 // end of the table
index dc8121a0bb7a712dea23e016d5e61117bd657cba..d6d540d723089021ce7d7f129afe7a19d8353454 100644 (file)
@@ -3273,6 +3273,17 @@ void LyXAction::init()
  */
                { LFUN_BUFFER_ZOOM_OUT, "buffer-zoom-out", ReadOnly, Buffer },
 
+/*!
+ * \var lyx::FuncCode lyx::LFUN_SECTION_SELECT
+ * \li Action: Selects the whole section.
+ * \li Notion: The cursor should be in a section heading 
+               before calling this lfun.
+ * \li Syntax: section-select
+ * \li Origin: vfr, 05 May 2009
+ * \endvar
+ */
+               { LFUN_SECTION_SELECT, "section-select", ReadOnly, Edit },
+
                { LFUN_NOACTION, "", Noop, Hidden }
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
        };
index f306a6d2de1eb862c69e8ef2ba4f09d2174b7522..c4c4524a96cc9d4606d260f8ce6cebfd1d8ccc58 100644 (file)
@@ -329,9 +329,8 @@ static void outline(OutlineOp mode, Cursor & cur)
        // Seek the one (on same level) below
        for (; finish != end; ++finish) {
                toclevel = finish->layout().toclevel;
-               if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel) {
+               if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
                        break;
-               }
        }
 
        switch (mode) {
@@ -373,9 +372,8 @@ static void outline(OutlineOp mode, Cursor & cur)
                        for (; dest != end; ++dest) {
                                toclevel = dest->layout().toclevel;
                                if (toclevel != Layout::NOT_IN_TOC
-                                   && toclevel <= thistoclevel) {
+                                     && toclevel <= thistoclevel)
                                        break;
-                               }
                        }
                        // One such was found:
                        pit_type newpit = distance(bgn, dest);
@@ -709,6 +707,42 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                needsUpdate |= tm.cursorEnd(cur);
                break;
 
+       case LFUN_SECTION_SELECT: {
+               Buffer & buf = *cur.buffer();
+               pit_type & pit = cur.pit();
+               ParagraphList & pars = buf.text().paragraphs();
+               ParagraphList::iterator bgn = pars.begin();
+               // The first paragraph of the area to be selected:
+               ParagraphList::iterator start = boost::next(bgn, pit);
+               // The final paragraph of area to be selected:
+               ParagraphList::iterator finish = start;
+               ParagraphList::iterator end = pars.end();
+
+               setCursor(cur, cur.pit(), 0);
+               Cursor old_cur = cur;
+               needsUpdate |= cur.selHandle(true);
+               
+               int const thistoclevel = start->layout().toclevel;
+               if (thistoclevel == Layout::NOT_IN_TOC)
+                       break;
+
+               // Move out (down) from this section header
+               if (finish != end)
+                       ++finish;
+
+               int toclevel;
+               // Seek the one (on same level) below
+               for (; finish != end; ++finish, cur.forwardPar()) {
+                       toclevel = finish->layout().toclevel;
+                       if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
+                               break;
+               }
+               setCursor(cur, cur.pit(), cur.lastpos());
+               
+               needsUpdate |= cur != old_cur;
+               break;
+       }
+
        case LFUN_WORD_RIGHT:
        case LFUN_WORD_RIGHT_SELECT:
                if (lyxrc.visual_cursor) {
@@ -2363,6 +2397,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_WORD_RIGHT_SELECT:
        case LFUN_WORD_LEFT_SELECT:
        case LFUN_WORD_SELECT:
+       case LFUN_SECTION_SELECT:
        case LFUN_PARAGRAPH_UP:
        case LFUN_PARAGRAPH_DOWN:
        case LFUN_LINE_BEGIN: