+ add: character count for statusbar

This commit is contained in:
Rainer Kottenhoff 2018-08-07 02:17:03 +02:00
parent 30765311f7
commit fee9770396
6 changed files with 56 additions and 18 deletions

Binary file not shown.

View File

@ -3033,7 +3033,12 @@ int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, i
WCHAR* q = StrStrW(p, L",");
if (q > p) { *q = L'\0'; }
if (n < iCount) {
if (*p != L',') { StringCchCopyW(sMatrix[n], (size_t)iLen, p); }
if (*p != L',') {
StringCchCopyW(sMatrix[n], (size_t)iLen, p);
}
else {
sMatrix[n][0] = L'\0';
}
}
p = (q > p) ? (q + 1) : (p + 1);
++n;

View File

@ -6722,10 +6722,10 @@ void LoadSettings()
WCHAR tchStatusBar[MIDSZ_BUFFER] = { L'\0' };
IniSectionGetString(pIniSection, L"SectionPrefixes", STATUSBAR_SECTION_PREFIXES, tchStatusBar, COUNTOF(tchStatusBar));
ReadStrgsFromCSV(tchStatusBar, g_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"");
ReadStrgsFromCSV(tchStatusBar, g_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_PRFX_");
IniSectionGetString(pIniSection, L"SectionPostfixes", STATUSBAR_SECTION_POSTFIXES, tchStatusBar, COUNTOF(tchStatusBar));
ReadStrgsFromCSV(tchStatusBar, g_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"");
ReadStrgsFromCSV(tchStatusBar, g_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_POFX_");
IniSectionGetString(pIniSection, L"VisibleSections", STATUSBAR_DEFAULT_IDS, tchStatusBar, COUNTOF(tchStatusBar));
ReadVectorFromString(tchStatusBar, g_iStatusbarSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1);
@ -7978,9 +7978,9 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw)
static WCHAR tchLn[32] = { L'\0' };
static DocLn s_iLnFromPos = -1;
DocLn const iLnFromPos = SciCall_LineFromPosition(iPos) + 1;
DocLn const iLnFromPos = SciCall_LineFromPosition(iPos);
if (s_iLnFromPos != iLnFromPos) {
StringCchPrintf(tchLn, COUNTOF(tchLn), L"%td", iLnFromPos);
StringCchPrintf(tchLn, COUNTOF(tchLn), L"%td", iLnFromPos + 1);
FormatNumberStr(tchLn);
}
@ -8007,16 +8007,16 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw)
static WCHAR tchCols[32] = { L'\0' };
static DocPos s_iCol = -1;
DocPos const iCol = SciCall_GetColumn(iPos) + SciCall_GetSelectionNCaretVirtualSpace(0) + 1;
DocPos const iCol = SciCall_GetColumn(iPos) + SciCall_GetSelectionNCaretVirtualSpace(0);
if (s_iCol != iCol) {
StringCchPrintf(tchCol, COUNTOF(tchCol), L"%td", iCol);
StringCchPrintf(tchCol, COUNTOF(tchCol), L"%td", iCol + 1);
FormatNumberStr(tchCol);
}
static DocPos s_iLineLen = -1;
DocPos const iLineLen = Sci_GetNetLineLength(Sci_GetCurrentLineNumber()) + 1;
DocPos const iLineLen = Sci_GetNetLineLength(Sci_GetCurrentLineNumber());
if (s_iLineLen != iLineLen) {
StringCchPrintf(tchCols, COUNTOF(tchCols), L"%td", iLineLen);
StringCchPrintf(tchCols, COUNTOF(tchCols), L"%td", iLineLen + 1);
FormatNumberStr(tchCols);
}
@ -8032,6 +8032,37 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw)
// ------------------------------------------------------
static WCHAR tchChr[32] = { L'\0' };
static WCHAR tchChrs[32] = { L'\0' };
static DocPos s_iChr = -1;
DocPos const iLineBegin = SciCall_PositionFromLine(iLnFromPos);
DocPos const iChr = SciCall_CountCharacters(iLineBegin, iPos);
if (s_iChr != iChr) {
StringCchPrintf(tchChr, COUNTOF(tchChr), L"%td", iChr);
FormatNumberStr(tchChr);
}
static DocPos s_iChrs = -1;
DocPos const iLineBack = SciCall_GetLineEndPosition(iLnFromPos);
DocPos const iChrs = SciCall_CountCharacters(iLineBegin, iLineBack);
if (s_iChrs != iChrs) {
StringCchPrintf(tchChrs, COUNTOF(tchChrs), L"%td", iChrs);
FormatNumberStr(tchChrs);
}
if ((s_iChr != iChr) || (s_iChrs != iChrs)) {
StringCchPrintf(tchStatusBar[STATUS_DOCCHAR], txtWidth, L"%s%s / %s%s",
g_mxSBPrefix[STATUS_DOCCHAR], tchChr, tchChrs, g_mxSBPostfix[STATUS_DOCCHAR]);
s_iChr = iChr;
s_iChrs = iChrs;
bIsUpdateNeeded = true;
}
// ------------------------------------------------------
// number of selected chars in statusbar
static WCHAR tchSel[32] = { L'\0' };
static WCHAR tchSelB[64] = { L'\0' };

View File

@ -222,6 +222,7 @@ DeclareSciCallR1(PositionAfter, POSITIONAFTER, DocPos, DocPos, position)
DeclareSciCallR1(GetCharAt, GETCHARAT, char, DocPos, position)
DeclareSciCallR0(GetEOLMode, GETEOLMODE, int)
DeclareSciCallR2(CountCharacters, COUNTCHARACTERS, DocPos, DocPos, startpos, DocPos, endpos)
DeclareSciCallR0(GetLineCount, GETLINECOUNT, DocLn)
DeclareSciCallR0(GetTextLength, GETTEXTLENGTH, DocPos)
DeclareSciCallR1(LineLength, LINELENGTH, DocPos, DocLn, line)

View File

@ -86,20 +86,21 @@ typedef enum { MBINFO = 0, MBWARN, MBYESNO, MBYESNOWARN, MBYESNOCANCEL, MBOKCANC
typedef WCHAR prefix_t[MICRO_BUFFER];
typedef enum {
STATUS_DOCLINE = 0, STATUS_DOCCOLUMN, STATUS_SELECTION, STATUS_SELCTBYTES, STATUS_SELCTLINES, STATUS_OCCURRENCE,
STATUS_DOCSIZE, STATUS_CODEPAGE, STATUS_EOLMODE, STATUS_OVRMODE, STATUS_2ND_DEF, STATUS_LEXER, STATUS_OCCREPLACE,
STATUS_DOCLINE = 0, STATUS_DOCCOLUMN, STATUS_SELECTION, STATUS_SELCTBYTES, STATUS_SELCTLINES,
STATUS_OCCURRENCE, STATUS_DOCSIZE, STATUS_CODEPAGE, STATUS_EOLMODE, STATUS_OVRMODE, STATUS_2ND_DEF,
STATUS_LEXER, STATUS_DOCCHAR, STATUS_OCCREPLACE,
STATUS_SECTOR_COUNT,
STATUS_HELP = 255
} STATUS_SECTOR_T;
#define SBS_INIT_ZERO { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
#define SBS_INIT_MINUS { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }
#define SBS_INIT_ORDER { 0, 1, 2, 3, 4, 5, 6, 7. 8. 9, 10, 11, 12 }
#define SBS_INIT_ZERO { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
#define SBS_INIT_MINUS { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }
#define SBS_INIT_ORDER { 0, 1, 2, 3, 4, 5, 6, 7. 8. 9, 10, 11, 12, 13 }
#define STATUSBAR_SECTION_PREFIXES L"Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,,Repl ,"
#define STATUSBAR_SECTION_POSTFIXES L",,, [UTF-8],,, [UTF-8],,,,,,,"
#define STATUSBAR_DEFAULT_IDS L"0 1 2 4 5 6 7 8 9 10 11 12"
#define STATUSBAR_SECTION_WIDTH_SPECS L"30 20 20 20 20 20 0 0 0 0 0 0 0"
#define STATUSBAR_SECTION_PREFIXES L"Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,,Ch ,Repl ,"
#define STATUSBAR_SECTION_POSTFIXES L",,, [UTF-8],,, [UTF-8],,,,,,,,"
#define STATUSBAR_DEFAULT_IDS L"0 1 12 2 4 5 6 7 8 9 10 11"
#define STATUSBAR_SECTION_WIDTH_SPECS L"30 20 20 20 20 20 0 0 0 0 0 0 20 0"
#define STAUSBAR_RIGHT_MARGIN 20
// --------------------------------------------------------------------------