I guess this might qualify as "elementary support for 'word count'".
No recursion into insets, but I could do that as well.

Idea ok?

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)
Index: LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.139
diff -u -p -r1.139 LyXAction.C
--- LyXAction.C 12 Sep 2002 14:58:05 -0000      1.139
+++ LyXAction.C 17 Oct 2002 18:05:42 -0000
@@ -399,6 +399,7 @@ void LyXAction::init()
                { LFUN_WORDRIGHTSEL, "word-forward-select", "", ReadOnly },
                { LFUN_LOWCASE_WORD, "word-lowcase", "", Noop },
                { LFUN_WORDSEL, "word-select", "", ReadOnly },
+               { LFUN_WORDCOUNT, "word-count", "", ReadOnly },
                { LFUN_UPCASE_WORD, "word-upcase", "", Noop },
                { LFUN_MESSAGE, "message",
                  N_("Show message in minibuffer"), NoBuffer },
Index: commandtags.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/commandtags.h,v
retrieving revision 1.103
diff -u -p -r1.103 commandtags.h
--- commandtags.h       11 Sep 2002 14:48:16 -0000      1.103
+++ commandtags.h       17 Oct 2002 18:05:42 -0000
@@ -283,14 +283,15 @@ enum kb_action {
        LFUN_FORKS_SHOW,                // Angus 16 Feb 2002
        LFUN_FORKS_KILL,                // Angus 16 Feb 2002
        LFUN_TOOLTIPS_TOGGLE,           // Angus 8 Mar 2002
-       LFUN_INSET_OPTARG,                              // Martin 12 Aug 2002
+       LFUN_INSET_OPTARG,              // Martin 12 Aug 2002
        LFUN_MOUSE_PRESS,               // André 9 Aug 2002
        LFUN_MOUSE_MOTION,              // André 9 Aug 2002
        LFUN_MOUSE_RELEASE,             // André 9 Aug 2002
-       LFUN_MOUSE_DOUBLE,             // André 9 Aug 2002
-       LFUN_MOUSE_TRIPLE,             // André 9 Aug 2002
+       LFUN_MOUSE_DOUBLE,              // André 9 Aug 2002
+       LFUN_MOUSE_TRIPLE,              // André 9 Aug 2002
        LFUN_EDIT,                      // André 16 Aug 2002
        LFUN_INSET_WRAP,                // Dekel 7 Apr 2002
+       LFUN_WORDCOUNT,                 // André 17 Oct 2002
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.24
diff -u -p -r1.24 text3.C
--- text3.C     9 Oct 2002 13:07:29 -0000       1.24
+++ text3.C     17 Oct 2002 18:05:42 -0000
@@ -398,6 +398,21 @@ Inset::RESULT LyXText::dispatch(FuncRequ
                break;
        }
 
+       case LFUN_WORDCOUNT: {
+               LyXCursor saved = cursor;
+               cursorBottom(bv);
+               LyXCursor end = cursor;
+               cursorTop(bv);
+               unsigned count;
+               for (count = 0; cursor != end; ++count) 
+                       cursorRightOneWord(bv);
+               std::ostringstream os;
+               os << _("word count: ") << count;
+               cmd.message(os.str().c_str());
+               cursor = saved;
+               break;
+       }
+
        case LFUN_DELETE_WORD_FORWARD:
                bv->beforeChange(this);
                update(bv, false);

Reply via email to