From bb7cb36df932363e9323635af2831c992d8d52b4 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 25 Sep 2010 17:04:44 +0000 Subject: [PATCH] [NEW_FEATURE] Add Word count feature in Summary command. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@670 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 32 ++++++++------------------------ PowerEditor/src/Notepad_plus.h | 1 + PowerEditor/src/NppCommands.cpp | 26 +++++++++++++++++--------- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 18c6e0a6f..e7c7e05cc 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2411,32 +2411,15 @@ size_t Notepad_plus::getSelectedBytes() return result; } -/* -void Notepad_plus::updateStatusBar() +int Notepad_plus::wordCount() { - UniMode u = _pEditView->getCurrentBuffer()->getUnicodeMode(); - TCHAR strLnCol[64]; - - int areas = getSelectedAreas(); - int sizeofChar = (isFormatUnicode(u)) ? 2 : 1; - wsprintf(strLnCol, TEXT("Ln : %d Col : %d Sel : %d (%d bytes) in %d ranges"),\ - (_pEditView->getCurrentLineNumber() + 1), \ - (_pEditView->getCurrentColumnNumber() + 1),\ - getSelectedCharNumber(u), getSelectedBytes() * sizeofChar,\ - areas); - - _statusBar.setText(strLnCol, STATUSBAR_CUR_POS); - - TCHAR strDonLen[64]; - size_t numLines = _pEditView->execute(SCI_GETLINECOUNT); - wsprintf(strDonLen, TEXT("%d chars %d bytes %d lines"),\ - getCurrentDocCharCount(numLines, u),\ - _pEditView->execute(SCI_GETLENGTH) * sizeofChar + getBOMSize(u),\ - numLines); - _statusBar.setText(strDonLen, STATUSBAR_DOC_SIZE); - _statusBar.setText(_pEditView->execute(SCI_GETOVERTYPE) ? TEXT("OVR") : TEXT("INS"), STATUSBAR_TYPING_MODE); + FindOption env; + env._str2Search = TEXT("[^ \\\\.,;:!?()+\\-\\*/=\\]\\[{}&~\"'`|@$%§<>\\^]+"); + //printStr(env._str2Search.c_str()); + env._searchType = FindRegex; + return _findReplaceDlg.processAll(ProcessCountAll, &env, true); } -*/ + void Notepad_plus::updateStatusBar() { @@ -4204,6 +4187,7 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam } } + void Notepad_plus::setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filter) { generic_string fltr; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index d75cdb9e4..93b3e8c77 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -579,6 +579,7 @@ private: bool noOpenedDoc() const; bool goToPreviousIndicator(int indicID2Search, bool isWrap = true) const; bool goToNextIndicator(int indicID2Search, bool isWrap = true) const; + int wordCount(); }; diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 42eb3125b..224a11206 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -1021,25 +1021,28 @@ void Notepad_plus::command(int id) characterNumber += TEXT("\r"); } TCHAR *nbCharLabel = TEXT("Characters (without blanks): "); + TCHAR *nbWordLabel = TEXT("Words: "); + TCHAR *nbLineLabel = TEXT("Lines: "); TCHAR *nbByteLabel = TEXT("Current document length: "); - TCHAR *nbLineLabel = TEXT("Total lines: "); TCHAR *nbSelLabel1 = TEXT(" selected characters ("); TCHAR *nbSelLabel2 = TEXT(" bytes) in "); TCHAR *nbRangeLabel = TEXT(" ranges"); UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode(); int nbChar = getCurrentDocCharCount(um); + int nbWord = wordCount(); size_t nbLine = _pEditView->execute(SCI_GETLINECOUNT); int nbByte = _pEditView->execute(SCI_GETLENGTH); int nbSel = getSelectedCharNumber(um); int nbSelByte = getSelectedBytes(); int nbRange = getSelectedAreas(); - TCHAR nbCharStr[64]; - TCHAR nbByteStr[64]; - TCHAR nbLineStr[64]; - TCHAR nbSelStr[64]; - TCHAR nbSelByteStr[64]; + TCHAR nbCharStr[32]; + TCHAR nbWordStr[16]; + TCHAR nbByteStr[32]; + TCHAR nbLineStr[32]; + TCHAR nbSelStr[32]; + TCHAR nbSelByteStr[32]; TCHAR nbRangeStr[8]; generic_sprintf(nbCharStr, TEXT("%d"), nbChar); @@ -1047,9 +1050,9 @@ void Notepad_plus::command(int id) characterNumber += nbCharStr; characterNumber += TEXT("\r"); - generic_sprintf(nbByteStr, TEXT("%d"), nbByte); - characterNumber += nbByteLabel; - characterNumber += nbByteStr; + generic_sprintf(nbWordStr, TEXT("%d"), nbWord); + characterNumber += nbWordLabel; + characterNumber += nbWordStr; characterNumber += TEXT("\r"); generic_sprintf(nbLineStr, TEXT("%d"), nbLine); @@ -1057,6 +1060,11 @@ void Notepad_plus::command(int id) characterNumber += nbLineStr; characterNumber += TEXT("\r"); + generic_sprintf(nbByteStr, TEXT("%d"), nbByte); + characterNumber += nbByteLabel; + characterNumber += nbByteStr; + characterNumber += TEXT("\r"); + generic_sprintf(nbSelStr, TEXT("%d"), nbSel); generic_sprintf(nbSelByteStr, TEXT("%d"), nbSelByte); generic_sprintf(nbRangeStr, TEXT("%d"), nbRange);