Re: Statistiques
Stéphane Mourey <[email protected]>
| Newsgroups | gmane.editors.lyx.french |
|---|---|
| Message-ID | <[email protected]> |
Le 13/10/2014 22:49, Jean-Marc Lasgouttes a écrit : > Je vois plein de changements d'espaces. Mon éditeur de code est configuré pour supprimer les espaces surnuméraires... faudra peut-être que je change ça. > J'ai fait la même chose dans master, est-ce que tu pourrais rebaser > ton patch sur le nouveau master? Cela fera un patch plus clair. Le voilà donc. Bonne nuit. -- Blog: Impossible Exil <http://impossible-exil.info>
0001-Add-LFUN_SERVER_GET_STATISTICS-command-which-make-po.patch
(text/x-patch, 3.2 KB)
From 2de97193a8eba9b9f5d7798e5e9115f36141da08 Mon Sep 17 00:00:00 2001 From: brokenclock <[email protected]> Date: Mon, 13 Oct 2014 21:46:47 +0200 Subject: [PATCH] Add LFUN_SERVER_GET_STATISTICS command, which make possible to get the LyX statistics on .lyxpipe.out --- src/FuncCode.h | 1 + src/LyXAction.cpp | 12 ++++++++++++ src/Text3.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/src/FuncCode.h b/src/FuncCode.h index 2ae820a..3bd0cd0 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -458,6 +458,7 @@ enum FuncCode // 355 LFUN_SPELLING_CONTINUOUSLY, // vfr, 20130324 LFUN_SEPARATOR_INSERT, // ef 20140502 + LFUN_SERVER_GET_STATISTICS, // brokenclock 20141010 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 175f68e..bdc4198 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -3526,6 +3526,18 @@ void LyXAction::init() */ { LFUN_STATISTICS, "statistics", ReadOnly, System }, /*! + * \var lyx::FuncCode lyx::LFUN_SERVER_GET_STATISTICS + * \li Action: Count the statistics (number of words and characters) + in the document. + * \li Notion: Note that this function gives the number of words/chars written, + not the number of characters which will be typeset. + * \li Syntax: server-get-statistics <words|chars|chars-space> + * \li Params: <words|chars|chars-space> indicate the statistic to get, none for all space separated + * \li Origin: brokenclock, Oct 10 2014 + * \endvar + */ + { LFUN_SERVER_GET_STATISTICS, "server-get-statistics", ReadOnly | Argument, System }, +/*! * \var lyx::FuncCode lyx::LFUN_COMPLETION_INLINE * \li Action: Show the inline completion at the cursor position. * \li Syntax: completion-inline diff --git a/src/Text3.cpp b/src/Text3.cpp index 79711f4..11260b4 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2391,6 +2391,31 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) needsUpdate = true; break; + case LFUN_SERVER_GET_STATISTICS: + { + DocIterator from, to; + if (cur.selection()) { + from = cur.selectionBegin(); + to = cur.selectionEnd(); + } else { + from = doc_iterator_begin(cur.buffer()); + to = doc_iterator_end(cur.buffer()); + } + + cur.buffer()->updateStatistics(from, to); + const string arg0 = cmd.getArg(0); + if (arg0 == "words") { + cur.message(convert<docstring>(cur.buffer()->wordCount())); + } else if (arg0 == "chars") { + cur.message(convert<docstring>(cur.buffer()->charCount(false))); + } else if (arg0 == "chars-space") { + cur.message(convert<docstring>(cur.buffer()->charCount(true))); + } else { + cur.message(convert<docstring>(cur.buffer()->wordCount()) + " " + convert<docstring>(cur.buffer()->charCount(false)) + " " + convert<docstring>(cur.buffer()->charCount(true))); + } + } + break; + default: LYXERR(Debug::ACTION, "Command " << cmd << " not DISPATCHED by Text"); cur.undispatched(); @@ -3109,6 +3134,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_UNICODE_INSERT: case LFUN_THESAURUS_ENTRY: case LFUN_ESCAPE: + case LFUN_SERVER_GET_STATISTICS: // these are handled in our dispatch() enable = true; break; -- 1.9.1