Introduce new LFUN_SECTION_SELECT. When this lfun is called and the cursor is in a section heading, the whole section is selected.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29518 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-05-03 18:58:00 +00:00
parent 5ed63945f7
commit 0da78f8bbd
3 changed files with 51 additions and 4 deletions

View 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

View 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
};

View 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: