mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 05:45:00 +02:00
[NEW_FEATURE] (Author : Christian Cuvier) characters count is added in status bar.
[NEW] a bigger chameleon picture is displayed in about dialog. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@548 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
b45df0db24
commit
50f39e351d
@ -14,10 +14,11 @@
|
|||||||
//You should have received a copy of the GNU General Public License
|
//You should have received a copy of the GNU General Public License
|
||||||
//along with this program; if not, write to the Free Software
|
//along with this program; if not, write to the Free Software
|
||||||
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
/*
|
||||||
#ifndef _WIN32_IE
|
#ifndef _WIN32_IE
|
||||||
#define _WIN32_IE 0x500
|
#define _WIN32_IE 0x500
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
#include "precompiledHeaders.h"
|
#include "precompiledHeaders.h"
|
||||||
#include "Notepad_plus.h"
|
#include "Notepad_plus.h"
|
||||||
#include "FileDialog.h"
|
#include "FileDialog.h"
|
||||||
@ -5179,18 +5180,137 @@ void Notepad_plus::activateDoc(int pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char utflen[] = {1,1,2,3};
|
||||||
|
|
||||||
|
size_t Notepad_plus::getSelectedCharNumber(UniMode u)
|
||||||
|
{
|
||||||
|
size_t result = 0;
|
||||||
|
if (u == uniUTF8 || u == uniCookie)
|
||||||
|
{
|
||||||
|
int numSel = _pEditView->execute(SCI_GETSELECTIONS);
|
||||||
|
for (int i=0; i < numSel; i++)
|
||||||
|
{
|
||||||
|
size_t line1 = _pEditView->execute(SCI_LINEFROMPOSITION, _pEditView->execute(SCI_GETSELECTIONNSTART, i));
|
||||||
|
size_t line2 = _pEditView->execute(SCI_LINEFROMPOSITION, _pEditView->execute(SCI_GETSELECTIONNEND, i));
|
||||||
|
for (size_t j = line1; j <= line2; j++)
|
||||||
|
{
|
||||||
|
size_t stpos = _pEditView->execute(SCI_GETLINESELSTARTPOSITION, j);
|
||||||
|
if (stpos != INVALID_POSITION)
|
||||||
|
{
|
||||||
|
size_t endpos = _pEditView->execute(SCI_GETLINESELENDPOSITION, j);
|
||||||
|
for (size_t pos = stpos; pos < endpos; pos++)
|
||||||
|
{
|
||||||
|
unsigned char c = 0xf0 & (unsigned char)_pEditView->execute(SCI_GETCHARAT, pos);
|
||||||
|
if (c >= 0xc0)
|
||||||
|
pos += utflen[(c & 0x30) >> 4];
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i=0; i < _numSel; i++)
|
||||||
|
{
|
||||||
|
size_t stpos = _pEditView->execute(SCI_GETSELECTIONNSTART, i);
|
||||||
|
size_t endpos = _pEditView->execute(SCI_GETSELECTIONNEND, i);
|
||||||
|
result += (endpos - stpos);
|
||||||
|
size_t line1 = _pEditView->execute(SCI_LINEFROMPOSITION, stpos);
|
||||||
|
size_t line2 = _pEditView->execute(SCI_LINEFROMPOSITION, endpos);
|
||||||
|
line2 -= line1;
|
||||||
|
if (_pEditView->execute(SCI_GETEOLMODE) == SC_EOL_CRLF) line2 *= 2;
|
||||||
|
result -= line2;
|
||||||
|
}
|
||||||
|
if (u != uni8Bit && u != uni7Bit) result *= 2;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Notepad_plus::getCurrentDocCharCount(size_t numLines, UniMode u)
|
||||||
|
{
|
||||||
|
if (u != uniUTF8 && u != uniCookie)
|
||||||
|
{
|
||||||
|
size_t result = _pEditView->execute(SCI_GETLENGTH);
|
||||||
|
size_t lines = numLines;
|
||||||
|
if (_pEditView->execute(SCI_GETCHARAT, result-1) >= ' ') lines--;
|
||||||
|
if (_pEditView->execute(SCI_GETEOLMODE) == SC_EOL_CRLF) lines *= 2;
|
||||||
|
return result - lines;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t result = 0;
|
||||||
|
for (size_t line=0; line<numLines; line++)
|
||||||
|
{
|
||||||
|
size_t endpos = _pEditView->execute(SCI_GETLINEENDPOSITION, line);
|
||||||
|
for (size_t pos = _pEditView->execute(SCI_POSITIONFROMLINE, line); pos < endpos; pos++)
|
||||||
|
{
|
||||||
|
unsigned char c = 0xf0 & (unsigned char)_pEditView->execute(SCI_GETCHARAT, pos);
|
||||||
|
if (c >= 0xc0) pos += utflen[(c & 0x30) >> 4];
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Notepad_plus::isFormatUnicode(UniMode u)
|
||||||
|
{
|
||||||
|
return (u != uni8Bit && u != uni7Bit && u != uniUTF8 && u != uniCookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Notepad_plus::getBOMSize(UniMode u)
|
||||||
|
{
|
||||||
|
switch(u)
|
||||||
|
{
|
||||||
|
case uni16LE:
|
||||||
|
case uni16BE:
|
||||||
|
return 2;
|
||||||
|
case uniUTF8:
|
||||||
|
return 3;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Notepad_plus::getSelectedAreas()
|
||||||
|
{
|
||||||
|
_numSel = _pEditView->execute(SCI_GETSELECTIONS);
|
||||||
|
if (_numSel == 1) // either 0 or 1 selection
|
||||||
|
return (_pEditView->execute(SCI_GETSELECTIONNSTART, 0) == _pEditView->execute(SCI_GETSELECTIONNEND, 0)) ? 0 : 1;
|
||||||
|
return (_pEditView->execute(SCI_SELECTIONISRECTANGLE)) ? 1 : _numSel;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Notepad_plus::getSelectedBytes()
|
||||||
|
{
|
||||||
|
size_t result = 0;
|
||||||
|
for (int i=0; i<_numSel; i++)
|
||||||
|
result += (_pEditView->execute(SCI_GETSELECTIONNEND, i) - _pEditView->execute(SCI_GETSELECTIONNSTART, i));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Notepad_plus::updateStatusBar()
|
void Notepad_plus::updateStatusBar()
|
||||||
{
|
{
|
||||||
|
UniMode u = _pEditView->getCurrentBuffer()->getUnicodeMode();
|
||||||
TCHAR strLnCol[64];
|
TCHAR strLnCol[64];
|
||||||
wsprintf(strLnCol, TEXT("Ln : %d Col : %d Sel : %d"),\
|
|
||||||
|
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->getCurrentLineNumber() + 1), \
|
||||||
(_pEditView->getCurrentColumnNumber() + 1),\
|
(_pEditView->getCurrentColumnNumber() + 1),\
|
||||||
(_pEditView->getSelectedByteNumber()));
|
getSelectedCharNumber(u), getSelectedBytes() * sizeofChar,\
|
||||||
|
areas);
|
||||||
|
|
||||||
_statusBar.setText(strLnCol, STATUSBAR_CUR_POS);
|
_statusBar.setText(strLnCol, STATUSBAR_CUR_POS);
|
||||||
|
|
||||||
TCHAR strDonLen[64];
|
TCHAR strDonLen[64];
|
||||||
wsprintf(strDonLen, TEXT("nb char : %d nb line : %d"), _pEditView->getCurrentDocLen(), _pEditView->execute(SCI_GETLINECOUNT));
|
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(strDonLen, STATUSBAR_DOC_SIZE);
|
||||||
_statusBar.setText(_pEditView->execute(SCI_GETOVERTYPE) ? TEXT("OVR") : TEXT("INS"), STATUSBAR_TYPING_MODE);
|
_statusBar.setText(_pEditView->execute(SCI_GETOVERTYPE) ? TEXT("OVR") : TEXT("INS"), STATUSBAR_TYPING_MODE);
|
||||||
}
|
}
|
||||||
@ -7508,7 +7628,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
bool willBeShown = nppGUI._statusBarShow;
|
bool willBeShown = nppGUI._statusBarShow;
|
||||||
_statusBar.init(_hInst, hwnd, 6);
|
_statusBar.init(_hInst, hwnd, 6);
|
||||||
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, 250);
|
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, 250);
|
||||||
_statusBar.setPartWidth(STATUSBAR_CUR_POS, 250);
|
_statusBar.setPartWidth(STATUSBAR_CUR_POS, 300);
|
||||||
_statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, 80);
|
_statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, 80);
|
||||||
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, 100);
|
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, 100);
|
||||||
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, 30);
|
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, 30);
|
||||||
|
@ -535,6 +535,13 @@ private:
|
|||||||
void activateDoc(int pos);
|
void activateDoc(int pos);
|
||||||
|
|
||||||
void updateStatusBar();
|
void updateStatusBar();
|
||||||
|
size_t getSelectedCharNumber(UniMode);
|
||||||
|
size_t getCurrentDocCharCount(size_t numLines, UniMode u);
|
||||||
|
int getSelectedAreas();
|
||||||
|
int _numSel;
|
||||||
|
size_t getSelectedBytes();
|
||||||
|
bool isFormatUnicode(UniMode);
|
||||||
|
int getBOMSize(UniMode);
|
||||||
|
|
||||||
void showAutoComp();
|
void showAutoComp();
|
||||||
void autoCompFromCurrentFile(bool autoInsert = true);
|
void autoCompFromCurrentFile(bool autoInsert = true);
|
||||||
|
@ -584,8 +584,8 @@ IDD_ABOUTBOX DIALOGEX 0, 0, 271, 240
|
|||||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_BORDER | WS_SYSMENU
|
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_BORDER | WS_SYSMENU
|
||||||
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
|
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT NOTEPAD_PLUS_VERSION, IDC_STATIC,50,16,65,11
|
LTEXT NOTEPAD_PLUS_VERSION, IDC_STATIC,60,16,65,11
|
||||||
LTEXT UNICODE_ANSI_MODE, IDC_STATIC,120,16,65,11
|
LTEXT UNICODE_ANSI_MODE, IDC_STATIC,130,16,65,11
|
||||||
GROUPBOX "GNU General Public Licence",IDC_STATIC,19,75,231,131,BS_CENTER
|
GROUPBOX "GNU General Public Licence",IDC_STATIC,19,75,231,131,BS_CENTER
|
||||||
DEFPUSHBUTTON "Ok",IDOK,106,215,50,14,BS_FLAT,WS_EX_STATICEDGE
|
DEFPUSHBUTTON "Ok",IDOK,106,215,50,14,BS_FLAT,WS_EX_STATICEDGE
|
||||||
LTEXT "Author :",IDC_STATIC,21,41,31,8
|
LTEXT "Author :",IDC_STATIC,21,41,31,8
|
||||||
@ -594,7 +594,7 @@ BEGIN
|
|||||||
LTEXT "http://notepad-plus.sourceforge.net/",IDC_HOME_ADDR,78,54,126,8
|
LTEXT "http://notepad-plus.sourceforge.net/",IDC_HOME_ADDR,78,54,126,8
|
||||||
EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
|
EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
|
||||||
EDITTEXT IDC_BUILD_DATETIME,150,2,150,10, ES_READONLY | NOT WS_BORDER
|
EDITTEXT IDC_BUILD_DATETIME,150,2,150,10, ES_READONLY | NOT WS_BORDER
|
||||||
CONTROL "",IDI_CHAMELEON,"Static",SS_OWNERDRAW,21,10,48,48
|
CONTROL "",IDI_CHAMELEON,"Static",SS_OWNERDRAW,20,5,64,64
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_GOLINE DIALOGEX 26, 41, 261, 88
|
IDD_GOLINE DIALOGEX 26, 41, 261, 88
|
||||||
|
@ -70,9 +70,9 @@ BOOL CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case WM_DRAWITEM :
|
case WM_DRAWITEM :
|
||||||
{
|
{
|
||||||
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON));
|
HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON), IMAGE_ICON, 48, 48, LR_DEFAULTSIZE);
|
||||||
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
|
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
|
||||||
::DrawIcon(pdis->hDC, 0, 0, hIcon);
|
::DrawIconEx(pdis->hDC, 0, 0, hIcon, 48, 48, 0, NULL, DI_NORMAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 3.7 KiB |
Loading…
x
Reference in New Issue
Block a user