[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
remotes/trunk
Don Ho 2010-09-25 17:04:44 +00:00
parent 52a0e7971d
commit bb7cb36df9
3 changed files with 26 additions and 33 deletions

View File

@ -2411,32 +2411,15 @@ size_t Notepad_plus::getSelectedBytes()
return result; return result;
} }
/* int Notepad_plus::wordCount()
void Notepad_plus::updateStatusBar()
{ {
UniMode u = _pEditView->getCurrentBuffer()->getUnicodeMode(); FindOption env;
TCHAR strLnCol[64]; env._str2Search = TEXT("[^ \\\\.,;:!?()+\\-\\*/=\\]\\[{}&~\"'`|@$%§<>\\^]+");
//printStr(env._str2Search.c_str());
int areas = getSelectedAreas(); env._searchType = FindRegex;
int sizeofChar = (isFormatUnicode(u)) ? 2 : 1; return _findReplaceDlg.processAll(ProcessCountAll, &env, true);
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);
} }
*/
void Notepad_plus::updateStatusBar() 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) void Notepad_plus::setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filter)
{ {
generic_string fltr; generic_string fltr;

View File

@ -579,6 +579,7 @@ private:
bool noOpenedDoc() const; bool noOpenedDoc() const;
bool goToPreviousIndicator(int indicID2Search, bool isWrap = true) const; bool goToPreviousIndicator(int indicID2Search, bool isWrap = true) const;
bool goToNextIndicator(int indicID2Search, bool isWrap = true) const; bool goToNextIndicator(int indicID2Search, bool isWrap = true) const;
int wordCount();
}; };

View File

@ -1021,25 +1021,28 @@ void Notepad_plus::command(int id)
characterNumber += TEXT("\r"); characterNumber += TEXT("\r");
} }
TCHAR *nbCharLabel = TEXT("Characters (without blanks): "); TCHAR *nbCharLabel = TEXT("Characters (without blanks): ");
TCHAR *nbWordLabel = TEXT("Words: ");
TCHAR *nbLineLabel = TEXT("Lines: ");
TCHAR *nbByteLabel = TEXT("Current document length: "); TCHAR *nbByteLabel = TEXT("Current document length: ");
TCHAR *nbLineLabel = TEXT("Total lines: ");
TCHAR *nbSelLabel1 = TEXT(" selected characters ("); TCHAR *nbSelLabel1 = TEXT(" selected characters (");
TCHAR *nbSelLabel2 = TEXT(" bytes) in "); TCHAR *nbSelLabel2 = TEXT(" bytes) in ");
TCHAR *nbRangeLabel = TEXT(" ranges"); TCHAR *nbRangeLabel = TEXT(" ranges");
UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode(); UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode();
int nbChar = getCurrentDocCharCount(um); int nbChar = getCurrentDocCharCount(um);
int nbWord = wordCount();
size_t nbLine = _pEditView->execute(SCI_GETLINECOUNT); size_t nbLine = _pEditView->execute(SCI_GETLINECOUNT);
int nbByte = _pEditView->execute(SCI_GETLENGTH); int nbByte = _pEditView->execute(SCI_GETLENGTH);
int nbSel = getSelectedCharNumber(um); int nbSel = getSelectedCharNumber(um);
int nbSelByte = getSelectedBytes(); int nbSelByte = getSelectedBytes();
int nbRange = getSelectedAreas(); int nbRange = getSelectedAreas();
TCHAR nbCharStr[64]; TCHAR nbCharStr[32];
TCHAR nbByteStr[64]; TCHAR nbWordStr[16];
TCHAR nbLineStr[64]; TCHAR nbByteStr[32];
TCHAR nbSelStr[64]; TCHAR nbLineStr[32];
TCHAR nbSelByteStr[64]; TCHAR nbSelStr[32];
TCHAR nbSelByteStr[32];
TCHAR nbRangeStr[8]; TCHAR nbRangeStr[8];
generic_sprintf(nbCharStr, TEXT("%d"), nbChar); generic_sprintf(nbCharStr, TEXT("%d"), nbChar);
@ -1047,9 +1050,9 @@ void Notepad_plus::command(int id)
characterNumber += nbCharStr; characterNumber += nbCharStr;
characterNumber += TEXT("\r"); characterNumber += TEXT("\r");
generic_sprintf(nbByteStr, TEXT("%d"), nbByte); generic_sprintf(nbWordStr, TEXT("%d"), nbWord);
characterNumber += nbByteLabel; characterNumber += nbWordLabel;
characterNumber += nbByteStr; characterNumber += nbWordStr;
characterNumber += TEXT("\r"); characterNumber += TEXT("\r");
generic_sprintf(nbLineStr, TEXT("%d"), nbLine); generic_sprintf(nbLineStr, TEXT("%d"), nbLine);
@ -1057,6 +1060,11 @@ void Notepad_plus::command(int id)
characterNumber += nbLineStr; characterNumber += nbLineStr;
characterNumber += TEXT("\r"); characterNumber += TEXT("\r");
generic_sprintf(nbByteStr, TEXT("%d"), nbByte);
characterNumber += nbByteLabel;
characterNumber += nbByteStr;
characterNumber += TEXT("\r");
generic_sprintf(nbSelStr, TEXT("%d"), nbSel); generic_sprintf(nbSelStr, TEXT("%d"), nbSel);
generic_sprintf(nbSelByteStr, TEXT("%d"), nbSelByte); generic_sprintf(nbSelByteStr, TEXT("%d"), nbSelByte);
generic_sprintf(nbRangeStr, TEXT("%d"), nbRange); generic_sprintf(nbRangeStr, TEXT("%d"), nbRange);