[BUG_FIXED] (Author: Andreas Jonsson) Now statusbar reports the number of selected characters instead of number of bytes.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1098 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-08-05 00:38:01 +00:00
parent 082253c37f
commit 785459bf8e
2 changed files with 25 additions and 2 deletions

View File

@ -2736,8 +2736,11 @@ void Notepad_plus::updateStatusBar()
int selByte = 0; int selByte = 0;
int selLine = 0; int selLine = 0;
if (_pEditView->getSelectedCount(selByte, selLine)) _pEditView->getSelectedCount(selByte, selLine);
wsprintf(strSel, TEXT("Sel : %d | %d"), selByte, selLine);
long selected_length = _pEditView->getSelectedLength();
if (selected_length != -1)
wsprintf(strSel, TEXT("Sel : %d | %d"), selected_length, selLine);
else else
wsprintf(strSel, TEXT("Sel : %s"), TEXT("N/A")); wsprintf(strSel, TEXT("Sel : %s"), TEXT("N/A"));

View File

@ -470,6 +470,26 @@ public:
return true; return true;
}; };
long getSelectedLength() const {
// return -1 if it's multi-selection or rectangle selection
if ((execute(SCI_GETSELECTIONS) > 1) || execute(SCI_SELECTIONISRECTANGLE))
return -1;
long size_selected = execute(SCI_GETSELTEXT);
char *selected = new char[size_selected + 1];
execute(SCI_GETSELTEXT, (WPARAM)0, (LPARAM)selected);
char *c = selected;
long length = 0;
while(*c != '\0')
{
if( (*c & 0xC0) != 0x80)
++length;
++c;
}
delete [] selected;
return length;
};
long getLineLength(int line) const { long getLineLength(int line) const {
return long(execute(SCI_GETLINEENDPOSITION, line) - execute(SCI_POSITIONFROMLINE, line)); return long(execute(SCI_GETLINEENDPOSITION, line) - execute(SCI_POSITIONFROMLINE, line));
}; };