[NEW_FEATURE] (Author: Ivan Radić, aka Loreia) Add selected line count display on the status bar.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@986 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2012-11-16 00:10:30 +00:00
parent 1e9690998d
commit f22c49c7f4
2 changed files with 17 additions and 8 deletions

View File

@ -337,7 +337,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
bool willBeShown = nppGUI._statusBarShow;
_statusBar.init(_pPublicInterface->getHinst(), hwnd, 6);
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, 200);
_statusBar.setPartWidth(STATUSBAR_CUR_POS, 230);
_statusBar.setPartWidth(STATUSBAR_CUR_POS, 260);
_statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, 110);
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, 120);
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, 30);
@ -2650,10 +2650,11 @@ void Notepad_plus::updateStatusBar()
{
TCHAR strLnCol[128];
TCHAR strSel[64];
int selByte = 0;
int selLine = 0;
long nbByte = _pEditView->getSelectedByteNumber();
if (nbByte != -1)
wsprintf(strSel, TEXT("Sel : %d"), nbByte);
if (_pEditView->getSelectedCount(selByte, selLine))
wsprintf(strSel, TEXT("Sel : %d | %d"), selByte, selLine);
else
wsprintf(strSel, TEXT("Sel : %s"), TEXT("N/A"));

View File

@ -448,13 +448,21 @@ public:
return long(execute(SCI_GETCOLUMN, execute(SCI_GETCURRENTPOS)));
};
long getSelectedByteNumber() const {
// return -1 if it's multi-selection or rectangle selection
bool getSelectedCount(int & selByte, int & selLine) const {
// return false if it's multi-selection or rectangle selection
if ((execute(SCI_GETSELECTIONS) > 1) || execute(SCI_SELECTIONISRECTANGLE))
return -1;
return false;
long start = long(execute(SCI_GETSELECTIONSTART));
long end = long(execute(SCI_GETSELECTIONEND));
return (start < end)?end-start:start-end;
selByte = (start < end)?end-start:start-end;
start = long(execute(SCI_LINEFROMPOSITION, start));
end = long(execute(SCI_LINEFROMPOSITION, end));
selLine = (start < end)?end-start:start-end;
if (selLine)
++selLine;
return true;
};
long getLineLength(int line) const {