mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+ StatusBar information enhancements
This commit is contained in:
parent
7a118f186b
commit
eea77201fc
38
src/Edit.c
38
src/Edit.c
@ -114,9 +114,8 @@ enum SortOrderMask {
|
||||
int g_DOSEncoding;
|
||||
|
||||
// Supported Encodings
|
||||
WCHAR wchANSI[8] = { L'\0'};
|
||||
WCHAR wchSYS[8] = { L'\0' };
|
||||
WCHAR wchOEM[8] = { L'\0' };
|
||||
WCHAR wchANSI[16] = { L'\0'};
|
||||
WCHAR wchOEM[16] = { L'\0' };
|
||||
|
||||
NP2ENCODING mEncoding[] = {
|
||||
{ NCP_ANSI | NCP_RECODE, CP_ACP, "ansi,system,ascii,", 61000, L"" },
|
||||
@ -907,18 +906,18 @@ BOOL Encoding_HasChanged(int iOriginalEncoding)
|
||||
|
||||
void Encoding_InitDefaults()
|
||||
{
|
||||
mEncoding[CPI_ANSI_DEFAULT].uCodePage = GetACP();
|
||||
StringCchPrintf(wchANSI,COUNTOF(wchANSI),L" (%u)",mEncoding[CPI_ANSI_DEFAULT].uCodePage);
|
||||
mEncoding[CPI_ANSI_DEFAULT].uCodePage = GetACP(); // set ANSI system CP
|
||||
StringCchPrintf(wchANSI,COUNTOF(wchANSI),L" (CP-%u)",mEncoding[CPI_ANSI_DEFAULT].uCodePage);
|
||||
|
||||
mEncoding[CPI_OEM].uCodePage = GetOEMCP();
|
||||
StringCchPrintf(wchOEM,COUNTOF(wchOEM),L" (%u)",mEncoding[CPI_OEM].uCodePage);
|
||||
StringCchPrintf(wchOEM,COUNTOF(wchOEM),L" (CP-%u)",mEncoding[CPI_OEM].uCodePage);
|
||||
|
||||
g_DOSEncoding = CPI_OEM;
|
||||
// Try to set the DOS encoding to DOS-437 if the default OEMCP is not DOS-437
|
||||
if (mEncoding[g_DOSEncoding].uCodePage != 437)
|
||||
{
|
||||
for (int i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); ++i) {
|
||||
if (mEncoding[i].uCodePage == 437 && Encoding_IsValid(i)) {
|
||||
if (Encoding_IsValid(i) && (mEncoding[i].uCodePage == 437)) {
|
||||
g_DOSEncoding = i;
|
||||
break;
|
||||
}
|
||||
@ -972,11 +971,14 @@ int Encoding_MapIniSetting(BOOL bLoad,int iSetting) {
|
||||
}
|
||||
|
||||
|
||||
void Encoding_GetLabel(int iEncoding) {
|
||||
if (mEncoding[iEncoding].wchLabel[0] == 0) {
|
||||
WCHAR wch[256] = { L'\0' };
|
||||
GetString(mEncoding[iEncoding].idsName,wch,COUNTOF(wch));
|
||||
WCHAR *pwsz = StrChr(wch, L';');
|
||||
void Encoding_GetLabel(int iEncoding)
|
||||
{
|
||||
if (mEncoding[iEncoding].wchLabel[0] == L'\0')
|
||||
{
|
||||
WCHAR wch1[128] = { L'\0' };
|
||||
WCHAR wch2[128] = { L'\0' };
|
||||
GetString(mEncoding[iEncoding].idsName,wch1,COUNTOF(wch1));
|
||||
WCHAR *pwsz = StrChr(wch1, L';');
|
||||
if (pwsz) {
|
||||
pwsz = StrChr(CharNext(pwsz), L';');
|
||||
if (pwsz) {
|
||||
@ -984,9 +986,17 @@ void Encoding_GetLabel(int iEncoding) {
|
||||
}
|
||||
}
|
||||
if (!pwsz)
|
||||
pwsz = wch;
|
||||
pwsz = wch1;
|
||||
|
||||
StringCchCopyN(wch2, COUNTOF(wch2), pwsz, COUNTOF(wch1));
|
||||
|
||||
if (Encoding_IsANSI(iEncoding))
|
||||
StringCchCatN(wch2, COUNTOF(wch2), wchANSI, COUNTOF(wchANSI));
|
||||
else if (iEncoding == CPI_OEM)
|
||||
StringCchCatN(wch2, COUNTOF(wch2), wchOEM, COUNTOF(wchOEM));
|
||||
|
||||
StringCchCopyN(mEncoding[iEncoding].wchLabel,COUNTOF(mEncoding[iEncoding].wchLabel),
|
||||
pwsz,COUNTOF(mEncoding[iEncoding].wchLabel));
|
||||
wch2,COUNTOF(mEncoding[iEncoding].wchLabel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ typedef struct _np2encoding {
|
||||
UINT uCodePage;
|
||||
char* pszParseNames;
|
||||
int idsName;
|
||||
WCHAR wchLabel[32];
|
||||
WCHAR wchLabel[64];
|
||||
} NP2ENCODING;
|
||||
|
||||
int Encoding_Current(int); // getter/setter
|
||||
|
||||
@ -1869,11 +1869,11 @@ void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
EndDeferWindowPos(hdwp);
|
||||
|
||||
// Statusbar width
|
||||
aWidth[0] = max(120,min(cx/3,StatusCalcPaneWidth(hwndStatus,L"Ln 9'999'999 : 9'999'999 Col 9'999'999 : 999 Sel 9'999'999")));
|
||||
aWidth[1] = aWidth[0] + StatusCalcPaneWidth(hwndStatus,L"9'999'999 Bytes");
|
||||
aWidth[2] = aWidth[1] + StatusCalcPaneWidth(hwndStatus,L"Unicode BE BOM");
|
||||
aWidth[3] = aWidth[2] + StatusCalcPaneWidth(hwndStatus,L"CR+LF");
|
||||
aWidth[4] = aWidth[3] + StatusCalcPaneWidth(hwndStatus,L"OVR");
|
||||
aWidth[0] = max(120,min(cx/3,StatusCalcPaneWidth(hwndStatus,L" Ln 9'999'999 : 9'999'999 Col 9'999'999 : 999 Sel 9'999'999 SelLn 9'999'999 Occ 9'999'999 ")));
|
||||
aWidth[1] = aWidth[0] + StatusCalcPaneWidth(hwndStatus,L" 9'999'999 Bytes [UTF-8] ");
|
||||
aWidth[2] = aWidth[1] + StatusCalcPaneWidth(hwndStatus,L" Unicode (UTF-16) LE BOM ");
|
||||
aWidth[3] = aWidth[2] + StatusCalcPaneWidth(hwndStatus,L" CR+LF ");
|
||||
aWidth[4] = aWidth[3] + StatusCalcPaneWidth(hwndStatus,L" OVR ");
|
||||
aWidth[5] = -1;
|
||||
|
||||
SendMessage(hwndStatus,SB_SETPARTS,COUNTOF(aWidth),(LPARAM)aWidth);
|
||||
@ -7160,7 +7160,7 @@ void UpdateStatusbar()
|
||||
int iLineEnd = (int)SendMessage( hwndEdit , SCI_LINEFROMPOSITION , iSelEnd , 0 );
|
||||
int iStartOfLinePos = (int)SendMessage( hwndEdit , SCI_POSITIONFROMLINE , iLineEnd , 0 );
|
||||
int iLinesSelected = iLineEnd - iLineStart;
|
||||
if( iSelStart != iSelEnd && iStartOfLinePos != iSelEnd ) iLinesSelected += 1;
|
||||
if ((iSelStart != iSelEnd) && (iStartOfLinePos != iSelEnd)) iLinesSelected += 1;
|
||||
StringCchPrintf(tchLinesSelected,COUNTOF(tchLinesSelected),L"%i",iLinesSelected);
|
||||
FormatNumberStr(tchLinesSelected);
|
||||
|
||||
@ -7177,16 +7177,16 @@ void UpdateStatusbar()
|
||||
Encoding_GetLabel(Encoding_Current(CPI_GET));
|
||||
|
||||
if (iEOLMode == SC_EOL_CR)
|
||||
StringCchCopy(tchEOLMode,COUNTOF(tchEOLMode),L"CR");
|
||||
StringCchCopy(tchEOLMode,COUNTOF(tchEOLMode),L" CR");
|
||||
else if (iEOLMode == SC_EOL_LF)
|
||||
StringCchCopy(tchEOLMode,COUNTOF(tchEOLMode),L"LF");
|
||||
StringCchCopy(tchEOLMode,COUNTOF(tchEOLMode),L" LF");
|
||||
else
|
||||
StringCchCopy(tchEOLMode,COUNTOF(tchEOLMode),L"CR+LF");
|
||||
StringCchCopy(tchEOLMode,COUNTOF(tchEOLMode),L" CR+LF");
|
||||
|
||||
if (SendMessage(hwndEdit,SCI_GETOVERTYPE,0,0))
|
||||
StringCchCopy(tchOvrMode,COUNTOF(tchOvrMode),L"OVR");
|
||||
StringCchCopy(tchOvrMode,COUNTOF(tchOvrMode),L" OVR");
|
||||
else
|
||||
StringCchCopy(tchOvrMode,COUNTOF(tchOvrMode),L"INS");
|
||||
StringCchCopy(tchOvrMode,COUNTOF(tchOvrMode),L" INS");
|
||||
|
||||
Style_GetCurrentLexerName(tchLexerName,COUNTOF(tchLexerName));
|
||||
|
||||
|
||||
BIN
src/Notepad3.rc
BIN
src/Notepad3.rc
Binary file not shown.
Loading…
Reference in New Issue
Block a user