+ enh: configurable statusbar

This commit is contained in:
Rainer Kottenhoff 2018-04-24 12:43:19 +02:00
parent 17b5ecf112
commit 06bf2e63ee
8 changed files with 274 additions and 222 deletions

Binary file not shown.

View File

@ -682,7 +682,7 @@ void RunDlg(HWND hwnd,LPCWSTR lpstrDefault)
//
// OpenWithDlgProc()
//
extern WCHAR tchOpenWithDir[MAX_PATH];
extern WCHAR g_tchOpenWithDir[MAX_PATH];
extern int flagNoFadeHidden;
extern int cxOpenWithDlg;
@ -706,7 +706,7 @@ INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam
ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_OPENWITHDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
ListView_InsertColumn(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,&lvc);
DirList_Init(GetDlgItem(hwnd,IDC_OPENWITHDIR),NULL);
DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),g_tchOpenWithDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR));
ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
@ -791,9 +791,9 @@ INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam
case IDC_GETOPENWITHDIR:
{
if (GetDirectory(hwnd,IDS_OPENWITH,tchOpenWithDir,tchOpenWithDir,true))
if (GetDirectory(hwnd,IDS_OPENWITH,g_tchOpenWithDir,g_tchOpenWithDir,true))
{
DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),tchOpenWithDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),g_tchOpenWithDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR));
ListView_EnsureVisible(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,false);
ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
@ -882,7 +882,7 @@ bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile)
//
// FavoritesDlgProc()
//
extern WCHAR tchFavoritesDir[MAX_PATH];
extern WCHAR g_tchFavoritesDir[MAX_PATH];
extern int cxFavoritesDlg;
extern int cyFavoritesDlg;
@ -904,7 +904,7 @@ INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara
ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FAVORITESDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
ListView_InsertColumn(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,&lvc);
DirList_Init(GetDlgItem(hwnd,IDC_FAVORITESDIR),NULL);
DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),g_tchFavoritesDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR));
ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
@ -988,9 +988,9 @@ INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara
case IDC_GETFAVORITESDIR:
{
if (GetDirectory(hwnd,IDS_FAVORITES,tchFavoritesDir,tchFavoritesDir,true))
if (GetDirectory(hwnd,IDS_FAVORITES,g_tchFavoritesDir,g_tchFavoritesDir,true))
{
DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),tchFavoritesDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),g_tchFavoritesDir,DL_ALLOBJECTS,NULL,false,flagNoFadeHidden,DS_NAME,false);
DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR));
ListView_EnsureVisible(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,false);
ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED);
@ -1128,7 +1128,7 @@ bool AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget)
if (iResult == IDOK)
{
if (!PathCreateFavLnk(pszName,lpszTarget,tchFavoritesDir)) {
if (!PathCreateFavLnk(pszName,lpszTarget,g_tchFavoritesDir)) {
MsgBox(MBWARN,IDS_FAV_FAILURE);
return false;
}

View File

@ -1007,7 +1007,7 @@ LONG StatusCalcPaneWidth(HWND hwnd,LPCWSTR lpsz)
SelectObject(hdc,hfold);
ReleaseDC(hwnd,hdc);
return (size.cx + 16L);
return (size.cx + 12L);
}
@ -1038,7 +1038,7 @@ int Toolbar_GetButtons(HWND hwnd,int cmdBase,LPWSTR lpszButtons,int cchButtons)
int Toolbar_SetButtons(HWND hwnd,int cmdBase,LPCWSTR lpszButtons,LPCTBBUTTON ptbb,int ctbb)
{
WCHAR tchButtons[LARGE_BUFFER];
WCHAR tchButtons[MIDSZ_BUFFER];
int i,c;
int iCmd;

View File

@ -114,25 +114,30 @@ TBBUTTON tbbMainWnd[] = { { 0,IDT_FILE_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0
#define TBBUTTON_DEFAULT_IDS L"1 2 4 3 0 5 6 0 7 8 9 0 10 11 0 12 0 24 26 0 22 23 0 13 14 0 15 0 25 0 17"
WCHAR g_wchIniFile[MAX_PATH] = { L'\0' };
WCHAR g_wchIniFile2[MAX_PATH] = { L'\0' };
WCHAR szBufferFile[MAX_PATH] = { L'\0' };
bool bSaveSettings;
bool bEnableSaveSettings;
bool bSaveRecentFiles;
bool bPreserveCaretPos;
bool bSaveFindReplace;
bool bFindReplCopySelOrClip = true;
WCHAR tchLastSaveCopyDir[MAX_PATH] = { L'\0' };
WCHAR tchOpenWithDir[MAX_PATH] = { L'\0' };
WCHAR tchFavoritesDir[MAX_PATH] = { L'\0' };
WCHAR tchDefaultDir[MAX_PATH] = { L'\0' };
WCHAR tchDefaultExtension[64] = { L'\0' };
WCHAR tchFileDlgFilters[5*1024] = { L'\0' };
WCHAR tchToolbarButtons[512] = { L'\0' };
WCHAR tchToolbarBitmap[MAX_PATH] = { L'\0' };
WCHAR tchToolbarBitmapHot[MAX_PATH] = { L'\0' };
WCHAR tchToolbarBitmapDisabled[MAX_PATH] = { L'\0' };
WCHAR g_wchIniFile[MAX_PATH] = { L'\0' };
WCHAR g_wchIniFile2[MAX_PATH] = { L'\0' };
static WCHAR g_szTmpFilePath[MAX_PATH] = { L'\0' };
bool bSaveSettings;
bool bEnableSaveSettings;
bool bSaveRecentFiles;
bool bPreserveCaretPos;
bool bSaveFindReplace;
bool bFindReplCopySelOrClip = true;
WCHAR g_tchFileDlgFilters[XXXL_BUFFER] = { L'\0' };
WCHAR g_tchLastSaveCopyDir[MAX_PATH] = { L'\0' };
WCHAR g_tchOpenWithDir[MAX_PATH] = { L'\0' };
WCHAR g_tchFavoritesDir[MAX_PATH] = { L'\0' };
static WCHAR g_tchDefaultExtension[64] = { L'\0' };
static WCHAR g_tchDefaultDir[MAX_PATH] = { L'\0' };
static WCHAR g_tchToolbarButtons[MIDSZ_BUFFER] = { L'\0' };
static WCHAR g_tchStatusbarSections[SMALL_BUFFER] = { L'\0' };
static WCHAR g_tchToolbarBitmap[MAX_PATH] = { L'\0' };
static WCHAR g_tchToolbarBitmapHot[MAX_PATH] = { L'\0' };
static WCHAR g_tchToolbarBitmapDisabled[MAX_PATH] = { L'\0' };
int iPathNameFormat;
bool bWordWrap;
@ -212,6 +217,7 @@ int iUpdateDelayHyperlinkStyling;
int iUpdateDelayMarkAllCoccurrences;
int iCurrentLineHorizontalSlop = 0;
int iCurrentLineVerticalSlop = 0;
bool bStatusBarOptimizedSpace = false;
const int DirectWriteTechnology[4] = {
SC_TECHNOLOGY_DEFAULT
@ -725,7 +731,7 @@ bool InitApplication(HINSTANCE hInstance)
//=============================================================================
//
// InitInstance()
// _InitWindowPosition()
//
//
static void __fastcall _InitWindowPosition(HWND hwnd)
@ -825,6 +831,65 @@ static void __fastcall _InitWindowPosition(HWND hwnd)
}
//=============================================================================
//
// _StatusbarSetSections()
//
//
static int g_aStatusbarSectionWidth[STATUS_SECTOR_COUNT];
static void __fastcall _StatusbarSetSections(int cx)
{
static int lastCX = -1;
if (!bShowStatusbar || (cx == lastCX)) { return; } // static calculation
// prepare sector array
for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) {
g_aStatusbarSectionWidth[i] = -1;
}
static WCHAR tchSectors[SMALL_BUFFER];
StringCchCopy(tchSectors, COUNTOF(tchSectors), g_tchStatusbarSections);
TrimString(tchSectors);
// ensure single spaces only
WCHAR *p = StrStr(tchSectors, L" ");
while (p) {
MoveMemory((WCHAR*)p, (WCHAR*)p + 1, (lstrlen(p) + 1) * sizeof(WCHAR));
p = StrStr(tchSectors, L" "); // next
}
// separate IDs
for (int i = 0; i < COUNTOF(tchSectors); ++i) {
if (tchSectors[i] == L' ') { tchSectors[i] = L'\0'; }
}
int const weight[STATUS_SECTOR_COUNT] = STATUSBAR_SECTOR_WEIGHTS;
// fill width
int totalWeight = 1;
p = tchSectors;
while (*p) {
int iID;
if (swscanf_s(p, L"%i", &iID) == 1) {
if ((iID >= 0) && (iID < STATUS_SECTOR_COUNT)) {
g_aStatusbarSectionWidth[iID] = (bStatusBarOptimizedSpace ? 0 : (cx * weight[iID]));
totalWeight += weight[iID];
}
}
p = StrEnd(p) + 1;
}
// normalize
if (!bStatusBarOptimizedSpace) {
for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) {
if (g_aStatusbarSectionWidth[i] > 0) {
g_aStatusbarSectionWidth[i] /= totalWeight;
}
}
}
lastCX = cx;
}
//=============================================================================
//
@ -888,7 +953,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
bOpened = FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchFile);
}
else {
LPCWSTR lpFileToOpen = flagBufferFile ? szBufferFile : lpFileArg;
LPCWSTR lpFileToOpen = flagBufferFile ? g_szTmpFilePath : lpFileArg;
bOpened = FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, lpFileToOpen);
if (bOpened) {
if (flagBufferFile) {
@ -907,8 +972,8 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
UpdateLineNumberWidth();
// check for temp file and delete
if (flagIsElevated && PathFileExists(szBufferFile)) {
DeleteFile(szBufferFile);
if (flagIsElevated && PathFileExists(g_szTmpFilePath)) {
DeleteFile(g_szTmpFilePath);
}
}
if (flagJumpTo) { // Jump to position
@ -1049,6 +1114,9 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
iReplacedOccurrences = 0;
g_iMarkOccurrencesCount = (g_iMarkOccurrences > 0) ? 0 : -1;
_StatusbarSetSections(g_WinInfo.cx);
UpdateToolbar();
UpdateStatusbar();
UpdateLineNumberWidth();
@ -1578,10 +1646,10 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
// Add normal Toolbar Bitmap
hbmp = NULL;
if (StringCchLenW(tchToolbarBitmap,COUNTOF(tchToolbarBitmap)))
if (StringCchLenW(g_tchToolbarBitmap,COUNTOF(g_tchToolbarBitmap)))
{
if (!SearchPath(NULL,tchToolbarBitmap,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),tchToolbarBitmap);
if (!SearchPath(NULL,g_tchToolbarBitmap,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmap);
hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
}
@ -1602,10 +1670,10 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
// Optionally add hot Toolbar Bitmap
hbmp = NULL;
if (StringCchLenW(tchToolbarBitmapHot,COUNTOF(tchToolbarBitmapHot)))
if (StringCchLenW(g_tchToolbarBitmapHot,COUNTOF(g_tchToolbarBitmapHot)))
{
if (!SearchPath(NULL,tchToolbarBitmapHot,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),tchToolbarBitmapHot);
if (!SearchPath(NULL,g_tchToolbarBitmapHot,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmapHot);
hbmp = LoadImage(NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
if (hbmp)
@ -1620,10 +1688,10 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
// Optionally add disabled Toolbar Bitmap
hbmp = NULL;
if (StringCchLenW(tchToolbarBitmapDisabled,COUNTOF(tchToolbarBitmapDisabled)))
if (StringCchLenW(g_tchToolbarBitmapDisabled,COUNTOF(g_tchToolbarBitmapDisabled)))
{
if (!SearchPath(NULL,tchToolbarBitmapDisabled,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),tchToolbarBitmapDisabled);
if (!SearchPath(NULL,g_tchToolbarBitmapDisabled,NULL,COUNTOF(szTmp),szTmp,NULL))
StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmapDisabled);
hbmp = LoadImage(NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
if (hbmp)
@ -1681,7 +1749,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
SendMessage(g_hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd);
if (Toolbar_SetButtons(g_hwndToolbar, IDT_FILE_NEW, tchToolbarButtons, tbbMainWnd, COUNTOF(tbbMainWnd)) == 0) {
if (Toolbar_SetButtons(g_hwndToolbar, IDT_FILE_NEW, g_tchToolbarButtons, tbbMainWnd, COUNTOF(tbbMainWnd)) == 0) {
SendMessage(g_hwndToolbar, TB_ADDBUTTONS, NUMINITIALTOOLS, (LPARAM)tbbMainWnd);
}
SendMessage(g_hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc);
@ -1843,7 +1911,7 @@ void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam)
}
// recreate toolbar and statusbar
Toolbar_GetButtons(g_hwndToolbar,IDT_FILE_NEW,tchToolbarButtons,COUNTOF(tchToolbarButtons));
Toolbar_GetButtons(g_hwndToolbar,IDT_FILE_NEW,g_tchToolbarButtons,COUNTOF(g_tchToolbarButtons));
DestroyWindow(g_hwndToolbar);
DestroyWindow(hwndReBar);
@ -1872,28 +1940,21 @@ void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam)
// MsgSize() - Handles WM_SIZE
//
//
static int g_aStatusSectorWidth[STATUS_SECTOR_COUNT] = { -1 };
void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
RECT rc;
int x,y,cx,cy;
HDWP hdwp;
if (wParam == SIZE_MINIMIZED)
return;
x = 0;
y = 0;
int x = 0;
int y = 0;
cx = LOWORD(lParam);
cy = HIWORD(lParam);
int cx = LOWORD(lParam);
int cy = HIWORD(lParam);
if (bShowToolbar)
{
/* SendMessage(g_hwndToolbar,WM_SIZE,0,0);
RECT rc;
GetWindowRect(g_hwndToolbar,&rc);
y = (rc.bottom - rc.top);
cy -= (rc.bottom - rc.top);*/
@ -1912,12 +1973,13 @@ void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
if (bShowStatusbar)
{
RECT rc;
SendMessage(g_hwndStatus,WM_SIZE,0,0);
GetWindowRect(g_hwndStatus,&rc);
cy -= (rc.bottom - rc.top);
}
hdwp = BeginDeferWindowPos(2);
HDWP hdwp = BeginDeferWindowPos(2);
DeferWindowPos(hdwp,hwndEditFrame,NULL,x,y,cx,cy,
SWP_NOZORDER | SWP_NOACTIVATE);
@ -1929,30 +1991,8 @@ void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
EndDeferWindowPos(hdwp);
// calculate average space for statusbar sectors
//g_aStatusSectorWidth[STATUS_DOCLINE] = StatusCalcPaneWidth(g_hwndStatus, L"Ln 9'999'/9'999");
//g_aStatusSectorWidth[STATUS_DOCCOLUMN] = StatusCalcPaneWidth(g_hwndStatus, L"Col 999/999");
//g_aStatusSectorWidth[STATUS_SELECTION] = StatusCalcPaneWidth(g_hwndStatus, L"Sel 9'999 (9999 Bytes)/999[ln]");
//g_aStatusSectorWidth[STATUS_OCCURRENCE] = StatusCalcPaneWidth(g_hwndStatus, L"Occ 9'999");
//g_aStatusSectorWidth[STATUS_DOCSIZE] = StatusCalcPaneWidth(g_hwndStatus, L"9'999 (Bytes)");
//g_aStatusSectorWidth[STATUS_CODEPAGE] = StatusCalcPaneWidth(g_hwndStatus, L"Unicode (UTF-8)");
//g_aStatusSectorWidth[STATUS_EOLMODE] = StatusCalcPaneWidth(g_hwndStatus, L"LF");
//g_aStatusSectorWidth[STATUS_OVRMODE] = StatusCalcPaneWidth(g_hwndStatus, L"OVR");
//g_aStatusSectorWidth[STATUS_2ND_DEF] = StatusCalcPaneWidth(g_hwndStatus, L"2ND");
//g_aStatusSectorWidth[STATUS_LEXER] = StatusCalcPaneWidth(g_hwndStatus, L"Standard Lexer");
int const weight[STATUS_SECTOR_COUNT+1] = { 3, 3, 5, 3, 2, 2, 1, 1, 1, 3, 24 };
g_aStatusSectorWidth[STATUS_DOCLINE] = (cx * weight[STATUS_DOCLINE]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_DOCCOLUMN] = (cx * weight[STATUS_DOCCOLUMN]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_SELECTION] = (cx * weight[STATUS_SELECTION]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_OCCURRENCE] = (cx * weight[STATUS_OCCURRENCE]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_DOCSIZE] = (cx * weight[STATUS_DOCSIZE]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_CODEPAGE] = (cx * weight[STATUS_CODEPAGE]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_EOLMODE] = (cx * weight[STATUS_EOLMODE]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_OVRMODE] = (cx * weight[STATUS_OVRMODE]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_2ND_DEF] = (cx * weight[STATUS_2ND_DEF]) / weight[STATUS_SECTOR_COUNT];
g_aStatusSectorWidth[STATUS_LEXER] = -1; //(cx * weight[STATUS_LEXER]) / weight[STATUS_SECTOR_COUNT];
_StatusbarSetSections(cx);
UpdateToolbar();
UpdateStatusbar();
UpdateLineNumberWidth();
@ -2887,7 +2927,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
sei.fMask = 0;
sei.hwnd = hwnd;
sei.lpVerb = NULL;
sei.lpFile = tchFavoritesDir;
sei.lpFile = g_tchFavoritesDir;
sei.lpParameters = NULL;
sei.lpDirectory = NULL;
sei.nShow = SW_SHOWNORMAL;
@ -6015,7 +6055,9 @@ void LoadSettings()
WCHAR *pIniSection = LocalAlloc(LPTR, sizeof(WCHAR) * INISECTIONBUFCNT * HUGE_BUFFER);
int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR);
LoadIniSection(L"Settings",pIniSection,cchIniSection);
// --------------------------------------------------------------------------
LoadIniSection(L"Settings", pIniSection, cchIniSection);
// --------------------------------------------------------------------------
bEnableSaveSettings = true;
bSaveSettings = IniSectionGetBool(pIniSection,L"SaveSettings",true);
@ -6033,19 +6075,19 @@ void LoadSettings()
g_efrData.bDotMatchAll = IniSectionGetBool(pIniSection, L"RegexDotMatchesAll", false);
g_efrData.fuFlags = IniSectionGetUInt(pIniSection, L"efrData_fuFlags", 0);
if (!IniSectionGetString(pIniSection, L"OpenWithDir", L"", tchOpenWithDir, COUNTOF(tchOpenWithDir))) {
//SHGetSpecialFolderPath(NULL, tchOpenWithDir, CSIDL_DESKTOPDIRECTORY, true);
GetKnownFolderPath(&FOLDERID_Desktop, tchOpenWithDir, COUNTOF(tchOpenWithDir));
if (!IniSectionGetString(pIniSection, L"OpenWithDir", L"", g_tchOpenWithDir, COUNTOF(g_tchOpenWithDir))) {
//SHGetSpecialFolderPath(NULL, g_tchOpenWithDir, CSIDL_DESKTOPDIRECTORY, true);
GetKnownFolderPath(&FOLDERID_Desktop, g_tchOpenWithDir, COUNTOF(g_tchOpenWithDir));
}
else {
PathAbsoluteFromApp(tchOpenWithDir, NULL, COUNTOF(tchOpenWithDir), true);
PathAbsoluteFromApp(g_tchOpenWithDir, NULL, COUNTOF(g_tchOpenWithDir), true);
}
if (!IniSectionGetString(pIniSection, L"Favorites", L"", tchFavoritesDir, COUNTOF(tchFavoritesDir))) {
//SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,tchFavoritesDir);
GetKnownFolderPath(&FOLDERID_Favorites, tchFavoritesDir, COUNTOF(tchFavoritesDir));
if (!IniSectionGetString(pIniSection, L"Favorites", L"", g_tchFavoritesDir, COUNTOF(g_tchFavoritesDir))) {
//SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,g_tchFavoritesDir);
GetKnownFolderPath(&FOLDERID_Favorites, g_tchFavoritesDir, COUNTOF(g_tchFavoritesDir));
}
else {
PathAbsoluteFromApp(tchFavoritesDir, NULL, COUNTOF(tchFavoritesDir), true);
PathAbsoluteFromApp(g_tchFavoritesDir, NULL, COUNTOF(g_tchFavoritesDir), true);
}
iPathNameFormat = IniSectionGetInt(pIniSection,L"PathNameFormat",0);
@ -6195,7 +6237,7 @@ void LoadSettings()
bTransparentModeAvailable = (bTransparentModeAvailable) ? true : false;
// see TBBUTTON tbbMainWnd[] for initial/reset set of buttons
IniSectionGetString(pIniSection,L"ToolbarButtons", L"", tchToolbarButtons, COUNTOF(tchToolbarButtons));
IniSectionGetString(pIniSection,L"ToolbarButtons", L"", g_tchToolbarButtons, COUNTOF(g_tchToolbarButtons));
bShowToolbar = IniSectionGetBool(pIniSection,L"ShowToolbar",true);
@ -6237,21 +6279,23 @@ void LoadSettings()
xCustomSchemesDlg = IniSectionGetInt(pIniSection, L"CustomSchemesDlgPosX", 0);
yCustomSchemesDlg = IniSectionGetInt(pIniSection, L"CustomSchemesDlgPosY", 0);
// --------------------------------------------------------------------------
LoadIniSection(L"Settings2",pIniSection,cchIniSection);
// --------------------------------------------------------------------------
bStickyWinPos = IniSectionGetInt(pIniSection,L"StickyWindowPosition",0);
if (bStickyWinPos) bStickyWinPos = 1;
IniSectionGetString(pIniSection,L"DefaultExtension",L"txt",
tchDefaultExtension,COUNTOF(tchDefaultExtension));
StrTrim(tchDefaultExtension,L" \t.\"");
g_tchDefaultExtension,COUNTOF(g_tchDefaultExtension));
StrTrim(g_tchDefaultExtension,L" \t.\"");
IniSectionGetString(pIniSection,L"DefaultDirectory",L"",
tchDefaultDir,COUNTOF(tchDefaultDir));
g_tchDefaultDir,COUNTOF(g_tchDefaultDir));
ZeroMemory(tchFileDlgFilters,sizeof(WCHAR)*COUNTOF(tchFileDlgFilters));
ZeroMemory(g_tchFileDlgFilters,sizeof(WCHAR)*COUNTOF(g_tchFileDlgFilters));
IniSectionGetString(pIniSection,L"FileDlgFilters",L"",
tchFileDlgFilters,COUNTOF(tchFileDlgFilters)-2);
g_tchFileDlgFilters,COUNTOF(g_tchFileDlgFilters)-2);
dwFileCheckInverval = IniSectionGetInt(pIniSection,L"FileCheckInverval",2000);
dwAutoReloadTimeout = IniSectionGetInt(pIniSection,L"AutoReloadTimeout",2000);
@ -6280,19 +6324,26 @@ void LoadSettings()
iCurrentLineVerticalSlop = IniSectionGetInt(pIniSection, L"CurrentLineVerticalSlop", 5);
iCurrentLineVerticalSlop = max(min(iCurrentLineVerticalSlop, 200), 0);
bStatusBarOptimizedSpace = IniSectionGetBool(pIniSection, L"StatusBarOptimizedSpace", false);
IniSectionGetString(pIniSection, L"StatusbarVisibleSections", STATUSBAR_DEFAULT_IDS, g_tchStatusbarSections, COUNTOF(g_tchStatusbarSections));
// --------------------------------------------------------------------------
LoadIniSection(L"Toolbar Images",pIniSection,cchIniSection);
// --------------------------------------------------------------------------
IniSectionGetString(pIniSection,L"BitmapDefault",L"",
tchToolbarBitmap,COUNTOF(tchToolbarBitmap));
g_tchToolbarBitmap,COUNTOF(g_tchToolbarBitmap));
IniSectionGetString(pIniSection,L"BitmapHot",L"",
tchToolbarBitmapHot,COUNTOF(tchToolbarBitmap));
g_tchToolbarBitmapHot,COUNTOF(g_tchToolbarBitmap));
IniSectionGetString(pIniSection,L"BitmapDisabled",L"",
tchToolbarBitmapDisabled,COUNTOF(tchToolbarBitmap));
g_tchToolbarBitmapDisabled,COUNTOF(g_tchToolbarBitmap));
int ResX = GetSystemMetrics(SM_CXSCREEN);
int ResY = GetSystemMetrics(SM_CYSCREEN);
// --------------------------------------------------------------------------
LoadIniSection(L"Window", pIniSection, cchIniSection);
// --------------------------------------------------------------------------
WCHAR tchHighDpiToolBar[32] = { L'\0' };
StringCchPrintf(tchHighDpiToolBar,COUNTOF(tchHighDpiToolBar),L"%ix%i HighDpiToolBar", ResX, ResY);
@ -6404,9 +6455,9 @@ void SaveSettings(bool bSaveSettingsNow) {
IniSectionSetBool(pIniSection, L"HideNonMatchedLines", g_efrData.bHideNonMatchedLines);
IniSectionSetBool(pIniSection, L"RegexDotMatchesAll", g_efrData.bDotMatchAll);
IniSectionSetInt(pIniSection, L"efrData_fuFlags", g_efrData.fuFlags);
PathRelativeToApp(tchOpenWithDir, wchTmp, COUNTOF(wchTmp), false, true, flagPortableMyDocs);
PathRelativeToApp(g_tchOpenWithDir, wchTmp, COUNTOF(wchTmp), false, true, flagPortableMyDocs);
IniSectionSetString(pIniSection, L"OpenWithDir", wchTmp);
PathRelativeToApp(tchFavoritesDir, wchTmp, COUNTOF(wchTmp), false, true, flagPortableMyDocs);
PathRelativeToApp(g_tchFavoritesDir, wchTmp, COUNTOF(wchTmp), false, true, flagPortableMyDocs);
IniSectionSetString(pIniSection, L"Favorites", wchTmp);
IniSectionSetInt(pIniSection, L"PathNameFormat", iPathNameFormat);
IniSectionSetBool(pIniSection, L"WordWrap", bWordWrapG);
@ -6483,9 +6534,9 @@ void SaveSettings(bool bSaveSettingsNow) {
IniSectionSetInt(pIniSection, L"CustomSchemesDlgPosX", xCustomSchemesDlg);
IniSectionSetInt(pIniSection, L"CustomSchemesDlgPosY", yCustomSchemesDlg);
Toolbar_GetButtons(g_hwndToolbar, IDT_FILE_NEW, tchToolbarButtons, COUNTOF(tchToolbarButtons));
if (StringCchCompareX(tchToolbarButtons, TBBUTTON_DEFAULT_IDS) == 0) { tchToolbarButtons[0] = L'\0'; }
IniSectionSetString(pIniSection, L"ToolbarButtons", tchToolbarButtons);
Toolbar_GetButtons(g_hwndToolbar, IDT_FILE_NEW, g_tchToolbarButtons, COUNTOF(g_tchToolbarButtons));
if (StringCchCompareX(g_tchToolbarButtons, TBBUTTON_DEFAULT_IDS) == 0) { g_tchToolbarButtons[0] = L'\0'; }
IniSectionSetString(pIniSection, L"ToolbarButtons", g_tchToolbarButtons);
SaveIniSection(L"Settings", pIniSection);
LocalFree(pIniSection);
@ -6626,11 +6677,11 @@ void ParseCommandLine()
// Relaunch elevated
else if (StrCmpNI(lp1,L"tmpfbuf=",CSTRLEN(L"tmpfbuf=")) == 0) {
StringCchCopyN(szBufferFile,COUNTOF(szBufferFile),
StringCchCopyN(g_szTmpFilePath,COUNTOF(g_szTmpFilePath),
lp1 + CSTRLEN(L"tmpfbuf="),len - CSTRLEN(L"tmpfbuf="));
TrimString(szBufferFile);
PathUnquoteSpaces(szBufferFile);
NormalizePathEx(szBufferFile,COUNTOF(szBufferFile));
TrimString(g_szTmpFilePath);
PathUnquoteSpaces(g_szTmpFilePath);
NormalizePathEx(g_szTmpFilePath,COUNTOF(g_szTmpFilePath));
flagBufferFile = 1;
}
@ -7278,31 +7329,13 @@ const static WCHAR* FR_Status[] = { L"[>--<]", L"[>>--]", L"[>>-+]", L"[+->]>",
FR_STATES g_FindReplaceMatchFoundState = FND_NOP;
#define txtWidth 80
void UpdateStatusbar()
{
static WCHAR tchLn[32] = { L'\0' };
static WCHAR tchLines[32] = { L'\0' };
static WCHAR tchCol[32] = { L'\0' };
static WCHAR tchCols[32] = { L'\0' };
static WCHAR tchSel[32] = { L'\0' };
static WCHAR tchSelB[32] = { L'\0' };
static WCHAR tchOcc[32] = { L'\0' };
static WCHAR tchReplOccs[32] = { L'\0' };
static WCHAR tchDocLine[64] = { L'\0' };
static WCHAR tchDocColumn[64] = { L'\0' };
static WCHAR tchDocSelection[64] = { L'\0' };
static WCHAR tchDocOccurrence[64] = { L'\0' };
static WCHAR tchFRStatus[128] = { L'\0' };
static WCHAR tchBytes[64] = { L'\0' };
static WCHAR tchDocSize[64] = { L'\0' };
static WCHAR tchEncoding[64] = { L'\0' };
static WCHAR tchStatusBar[STATUS_SECTOR_COUNT][txtWidth];
static WCHAR tchEOLMode[32] = { L'\0' };
static WCHAR tchOvrMode[32] = { L'\0' };
static WCHAR tch2ndDef[32] = { L'\0' };
static WCHAR tchLexerName[128] = { L'\0' };
static WCHAR tchLinesSelected[32] = { L'\0' };
static WCHAR tchFRStatus[128] = { L'\0' };
static WCHAR tchTmp[32] = { L'\0' };
if (!bShowStatusbar) { return; }
@ -7311,27 +7344,35 @@ void UpdateStatusbar()
const DocPos iTextLength = SciCall_GetTextLength();
const int iEncoding = Encoding_Current(CPI_GET);
static WCHAR tchLn[32] = { L'\0' };
StringCchPrintf(tchLn, COUNTOF(tchLn), L"%td", SciCall_LineFromPosition(iPos) + 1);
FormatNumberStr(tchLn);
static WCHAR tchLines[32] = { L'\0' };
StringCchPrintf(tchLines, COUNTOF(tchLines), L"%td", SciCall_GetLineCount());
FormatNumberStr(tchLines);
DocPos iCol = SciCall_GetColumn(iPos) + 1;
iCol += (DocPos)SendMessage(g_hwndEdit, SCI_GETSELECTIONNCARETVIRTUALSPACE, 0, 0);
static WCHAR tchCol[32] = { L'\0' };
StringCchPrintf(tchCol, COUNTOF(tchCol), L"%td", iCol);
FormatNumberStr(tchCol);
static WCHAR tchCols[32] = { L'\0' };
if (bMarkLongLines) {
StringCchPrintf(tchCols, COUNTOF(tchCols), L"%td", iLongLinesLimit);
FormatNumberStr(tchCols);
}
else {
tchCols[0] = L'\0';
}
// Print number of selected chars in statusbar
// number of selected chars in statusbar
const bool bIsSelEmpty = SciCall_IsSelectionEmpty();
const DocPos iSelStart = (bIsSelEmpty ? 0 : SciCall_GetSelectionStart());
const DocPos iSelEnd = (bIsSelEmpty ? 0 : SciCall_GetSelectionEnd());
static WCHAR tchSel[32] = { L'\0' };
static WCHAR tchSelB[32] = { L'\0' };
if (!bIsSelEmpty && !SciCall_IsSelectionRectangle())
{
const DocPos iSel = (DocPos)SendMessage(g_hwndEdit, SCI_COUNTCHARACTERS, iSelStart, iSelEnd);
@ -7344,8 +7385,26 @@ void UpdateStatusbar()
tchSelB[0] = L'0'; tchSelB[1] = L'\0';
}
// Print number of occurrence marks found
if ((g_iMarkOccurrencesCount >= 0) && !g_bMarkOccurrencesMatchVisible)
// number of selected lines in statusbar
static WCHAR tchLinesSelected[32] = { L'\0' };
if (bIsSelEmpty) {
tchLinesSelected[0] = L'-';
tchLinesSelected[1] = L'-';
tchLinesSelected[2] = L'\0';
}
else {
const DocLn iLineStart = SciCall_LineFromPosition(iSelStart);
const DocLn iLineEnd = SciCall_LineFromPosition(iSelEnd);
const DocPos iStartOfLinePos = SciCall_PositionFromLine(iLineEnd);
DocLn iLinesSelected = (iLineEnd - iLineStart);
if ((iSelStart != iSelEnd) && (iStartOfLinePos != iSelEnd)) { iLinesSelected += 1; }
StringCchPrintf(tchLinesSelected, COUNTOF(tchLinesSelected), L"%i", iLinesSelected);
FormatNumberStr(tchLinesSelected);
}
// number of occurrence marks found
static WCHAR tchOcc[32] = { L'\0' };
if ((g_iMarkOccurrencesCount >= 0) && !g_bMarkOccurrencesMatchVisible)
{
if ((g_iMarkOccurrencesMaxCount < 0) || (g_iMarkOccurrencesCount < g_iMarkOccurrencesMaxCount))
{
@ -7362,97 +7421,83 @@ void UpdateStatusbar()
StringCchCopy(tchOcc, COUNTOF(tchOcc), L"--");
}
// Print number of selected lines in statusbar
if (bIsSelEmpty) {
tchLinesSelected[0] = L'-';
tchLinesSelected[1] = L'-';
tchLinesSelected[2] = L'\0';
}
else {
const DocLn iLineStart = SciCall_LineFromPosition(iSelStart);
const DocLn iLineEnd = SciCall_LineFromPosition(iSelEnd);
const DocPos iStartOfLinePos = SciCall_PositionFromLine(iLineEnd);
DocLn iLinesSelected = (iLineEnd - iLineStart);
if ((iSelStart != iSelEnd) && (iStartOfLinePos != iSelEnd)) { iLinesSelected += 1; }
StringCchPrintf(tchLinesSelected, COUNTOF(tchLinesSelected), L"%i", iLinesSelected);
FormatNumberStr(tchLinesSelected);
}
// --------------------------------------------------------------------------
FormatString(tchDocLine, COUNTOF(tchDocLine), IDS_STATUS_DOCLINE, tchLn, tchLines);
FormatString(tchStatusBar[STATUS_DOCLINE], txtWidth, IDS_STATUS_DOCLINE, tchLn, tchLines);
if (bMarkLongLines)
FormatString(tchDocColumn, COUNTOF(tchDocColumn), IDS_STATUS_DOCCOLUMN2, tchCol, tchCols);
FormatString(tchStatusBar[STATUS_DOCCOLUMN], txtWidth, IDS_STATUS_DOCCOLUMN2, tchCol, tchCols);
else
FormatString(tchDocColumn, COUNTOF(tchDocColumn), IDS_STATUS_DOCCOLUMN, tchCol);
FormatString(tchStatusBar[STATUS_DOCCOLUMN], txtWidth, IDS_STATUS_DOCCOLUMN, tchCol);
FormatString(tchDocSelection, COUNTOF(tchDocSelection), IDS_STATUS_SELECTION, tchSel, tchSelB, tchLinesSelected);
FormatString(tchStatusBar[STATUS_SELECTION], txtWidth, IDS_STATUS_SELECTION, tchSel, tchSelB);
FormatString(tchStatusBar[STATUS_SELCTLINES], txtWidth, IDS_STATUS_SELCTLINES, tchLinesSelected);
FormatString(tchDocOccurrence, COUNTOF(tchDocOccurrence), IDS_STATUS_OCCURRENCE, tchOcc);
FormatString(tchStatusBar[STATUS_OCCURRENCE], txtWidth, IDS_STATUS_OCCURRENCE, tchOcc);
// get number of bytes in current encoding
static WCHAR tchBytes[32] = { L'\0' };
StrFormatByteSize(iTextLength, tchBytes, COUNTOF(tchBytes));
FormatString(tchDocSize, COUNTOF(tchDocSize), IDS_STATUS_DOCSIZE, tchBytes);
FormatString(tchStatusBar[STATUS_DOCSIZE], txtWidth, IDS_STATUS_DOCSIZE, tchBytes);
Encoding_SetLabel(iEncoding);
StringCchPrintf(tchEncoding, COUNTOF(tchEncoding), L"%s", Encoding_GetLabel(iEncoding));
StringCchPrintf(tchStatusBar[STATUS_CODEPAGE], txtWidth, L"%s", Encoding_GetLabel(iEncoding));
if (g_iEOLMode == SC_EOL_CR)
{
StringCchCopy(tchEOLMode, COUNTOF(tchEOLMode), L"CR");
StringCchCopy(tchStatusBar[STATUS_EOLMODE], txtWidth, L"CR");
}
else if (g_iEOLMode == SC_EOL_LF)
{
StringCchCopy(tchEOLMode, COUNTOF(tchEOLMode), L"LF");
StringCchCopy(tchStatusBar[STATUS_EOLMODE], txtWidth, L"LF");
}
else {
StringCchCopy(tchEOLMode, COUNTOF(tchEOLMode), L"CR+LF");
StringCchCopy(tchStatusBar[STATUS_EOLMODE], txtWidth, L"CR+LF");
}
if (SendMessage(g_hwndEdit, SCI_GETOVERTYPE, 0, 0))
{
StringCchCopy(tchOvrMode, COUNTOF(tchOvrMode), L"OVR");
StringCchCopy(tchStatusBar[STATUS_OVRMODE], txtWidth, L"OVR");
}
else {
StringCchCopy(tchOvrMode, COUNTOF(tchOvrMode), L"INS");
StringCchCopy(tchStatusBar[STATUS_OVRMODE], txtWidth, L"INS");
}
if (Style_GetUse2ndDefault())
{
StringCchCopy(tch2ndDef, COUNTOF(tch2ndDef), L"2ND");
StringCchCopy(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"2ND");
}
else {
StringCchCopy(tch2ndDef, COUNTOF(tch2ndDef), L"STD");
StringCchCopy(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"STD");
}
Style_GetCurrentLexerName(tchLexerName, COUNTOF(tchLexerName));
Style_GetCurrentLexerName(tchStatusBar[STATUS_LEXER], txtWidth);
// Statusbar width
int aWidth[STATUS_SECTOR_COUNT];
aWidth[STATUS_DOCLINE] = max(g_aStatusSectorWidth[STATUS_DOCLINE], StatusCalcPaneWidth(g_hwndStatus, tchDocLine));
aWidth[STATUS_DOCCOLUMN] = aWidth[STATUS_DOCLINE] + max(g_aStatusSectorWidth[STATUS_DOCCOLUMN], StatusCalcPaneWidth(g_hwndStatus, tchDocColumn));
aWidth[STATUS_SELECTION] = aWidth[STATUS_DOCCOLUMN] + max(g_aStatusSectorWidth[STATUS_SELECTION], StatusCalcPaneWidth(g_hwndStatus, tchDocSelection));
aWidth[STATUS_OCCURRENCE] = aWidth[STATUS_SELECTION] + max(g_aStatusSectorWidth[STATUS_OCCURRENCE], StatusCalcPaneWidth(g_hwndStatus, tchDocOccurrence));
aWidth[STATUS_DOCSIZE] = aWidth[STATUS_OCCURRENCE] + max(g_aStatusSectorWidth[STATUS_DOCSIZE], StatusCalcPaneWidth(g_hwndStatus, tchDocSize));
aWidth[STATUS_CODEPAGE] = aWidth[STATUS_DOCSIZE] + max(g_aStatusSectorWidth[STATUS_CODEPAGE], StatusCalcPaneWidth(g_hwndStatus, tchEncoding));
aWidth[STATUS_EOLMODE] = aWidth[STATUS_CODEPAGE] + max(g_aStatusSectorWidth[STATUS_EOLMODE], StatusCalcPaneWidth(g_hwndStatus, tchEOLMode));
aWidth[STATUS_OVRMODE] = g_aStatusSectorWidth[STATUS_OVRMODE];
aWidth[STATUS_2ND_DEF] = g_aStatusSectorWidth[STATUS_2ND_DEF];
aWidth[STATUS_LEXER] = g_aStatusSectorWidth[STATUS_LEXER];
int aStatusbarSections[STATUS_SECTOR_COUNT];
int cnt = 0;
int totalWidth = 0;
for (int id = 0; id < STATUS_SECTOR_COUNT; ++id) {
if (g_aStatusbarSectionWidth[id] >= 0) {
totalWidth += max(g_aStatusbarSectionWidth[id], StatusCalcPaneWidth(g_hwndStatus, tchStatusBar[id]));
aStatusbarSections[cnt++] = totalWidth;
}
}
SendMessage(g_hwndStatus, SB_SETPARTS, COUNTOF(aWidth), (LPARAM)aWidth);
if (cnt > 0) { aStatusbarSections[cnt - 1] = -1; }
else { aStatusbarSections[0] = -1; bShowStatusbar = false; }
StatusSetText(g_hwndStatus, STATUS_DOCLINE, tchDocLine);
StatusSetText(g_hwndStatus, STATUS_DOCCOLUMN, tchDocColumn);
StatusSetText(g_hwndStatus, STATUS_SELECTION, tchDocSelection);
StatusSetText(g_hwndStatus, STATUS_OCCURRENCE, tchDocOccurrence);
StatusSetText(g_hwndStatus, STATUS_DOCSIZE, tchDocSize);
StatusSetText(g_hwndStatus, STATUS_CODEPAGE, tchEncoding);
StatusSetText(g_hwndStatus, STATUS_EOLMODE, tchEOLMode);
StatusSetText(g_hwndStatus, STATUS_OVRMODE, tchOvrMode);
StatusSetText(g_hwndStatus, STATUS_2ND_DEF, tch2ndDef);
StatusSetText(g_hwndStatus, STATUS_LEXER, tchLexerName);
SendMessage(g_hwndStatus, SB_SETPARTS, (WPARAM)cnt, (LPARAM)aStatusbarSections);
cnt = 0;
for (int id = 0; id < STATUS_SECTOR_COUNT; ++id) {
if (g_aStatusbarSectionWidth[id] >= 0) {
StatusSetText(g_hwndStatus, cnt++, tchStatusBar[id]);
}
}
//InvalidateRect(g_hwndStatus,NULL,true);
// --------------------------------------------------------------------------
// update Find/Replace dialog (if any)
static WCHAR tchReplOccs[32] = { L'\0' };
if (g_hwndDlgFindReplace) {
if (iReplacedOccurrences > 0)
StringCchPrintf(tchReplOccs, COUNTOF(tchReplOccs), L"%i", iReplacedOccurrences);
@ -8133,9 +8178,9 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy)
if (bSaveAs || bSaveCopy || StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile)) == 0)
{
WCHAR tchInitialDir[MAX_PATH] = { L'\0' };
if (bSaveCopy && StringCchLenW(tchLastSaveCopyDir,COUNTOF(tchLastSaveCopyDir))) {
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),tchLastSaveCopyDir);
StringCchCopy(tchFile,COUNTOF(tchFile),tchLastSaveCopyDir);
if (bSaveCopy && StringCchLenW(g_tchLastSaveCopyDir,COUNTOF(g_tchLastSaveCopyDir))) {
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_tchLastSaveCopyDir);
StringCchCopy(tchFile,COUNTOF(tchFile),g_tchLastSaveCopyDir);
PathCchAppend(tchFile,COUNTOF(tchFile),PathFindFileName(g_wchCurFile));
}
else
@ -8161,8 +8206,8 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy)
UpdateLineNumberWidth();
}
else {
StringCchCopy(tchLastSaveCopyDir,COUNTOF(tchLastSaveCopyDir),tchFile);
PathRemoveFileSpec(tchLastSaveCopyDir);
StringCchCopy(g_tchLastSaveCopyDir,COUNTOF(g_tchLastSaveCopyDir),tchFile);
PathRemoveFileSpec(g_tchLastSaveCopyDir);
}
}
}
@ -8277,8 +8322,8 @@ bool OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_wchCurFile);
PathRemoveFileSpec(tchInitialDir);
}
else if (StringCchLenW(tchDefaultDir,COUNTOF(tchDefaultDir))) {
ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
else if (StringCchLenW(g_tchDefaultDir,COUNTOF(g_tchDefaultDir))) {
ExpandEnvironmentStrings(g_tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
if (PathIsRelative(tchInitialDir)) {
WCHAR tchModule[MAX_PATH] = { L'\0' };
GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
@ -8301,7 +8346,7 @@ bool OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | /* OFN_NOCHANGEDIR |*/
OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST |
OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/;
ofn.lpstrDefExt = (StringCchLenW(tchDefaultExtension,COUNTOF(tchDefaultExtension))) ? tchDefaultExtension : NULL;
ofn.lpstrDefExt = (StringCchLenW(g_tchDefaultExtension,COUNTOF(g_tchDefaultExtension))) ? g_tchDefaultExtension : NULL;
if (GetOpenFileName(&ofn)) {
StringCchCopyN(lpstrFile,cchFile,szFile,COUNTOF(szFile));
@ -8334,8 +8379,8 @@ bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_wchCurFile);
PathRemoveFileSpec(tchInitialDir);
}
else if (StringCchLenW(tchDefaultDir,COUNTOF(tchDefaultDir))) {
ExpandEnvironmentStrings(tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
else if (StringCchLenW(g_tchDefaultDir,COUNTOF(g_tchDefaultDir))) {
ExpandEnvironmentStrings(g_tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir));
if (PathIsRelative(tchInitialDir)) {
WCHAR tchModule[MAX_PATH] = { L'\0' };
GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
@ -8357,7 +8402,7 @@ bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
ofn.Flags = OFN_HIDEREADONLY /*| OFN_NOCHANGEDIR*/ |
/*OFN_NODEREFERENCELINKS |*/ OFN_OVERWRITEPROMPT |
OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST;
ofn.lpstrDefExt = (StringCchLenW(tchDefaultExtension,COUNTOF(tchDefaultExtension))) ? tchDefaultExtension : NULL;
ofn.lpstrDefExt = (StringCchLenW(g_tchDefaultExtension,COUNTOF(g_tchDefaultExtension))) ? g_tchDefaultExtension : NULL;
if (GetSaveFileName(&ofn)) {
StringCchCopyN(lpstrFile,cchFile,szNewFile,COUNTOF(szNewFile));

View File

@ -1469,7 +1469,8 @@ BEGIN
IDS_STATUS_DOCLINE "Ln %s / %s"
IDS_STATUS_DOCCOLUMN "Col %s"
IDS_STATUS_DOCCOLUMN2 "Col %s / %s"
IDS_STATUS_SELECTION "Sel %s (%s) / %s [ln]"
IDS_STATUS_SELECTION "Sel %s (%s)"
IDS_STATUS_SELCTLINES "SelLn %s"
IDS_STATUS_OCCURRENCE "Occ %s"
IDS_STATUS_DOCSIZE "%s [UTF-8]"
IDS_LOADFILE "Loading ""%s""..."

View File

@ -4598,14 +4598,15 @@ void Style_SetIndentGuides(HWND hwnd,bool bShow)
//
// Style_GetFileOpenDlgFilter()
//
extern WCHAR tchFileDlgFilters[5*1024];
extern WCHAR g_tchFileDlgFilters[XXXL_BUFFER];
bool Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter)
{
if (StringCchLenW(tchFileDlgFilters,COUNTOF(tchFileDlgFilters)) == 0)
GetString(IDS_FILTER_ALL,lpszFilter,cchFilter);
if (StringCchLenW(g_tchFileDlgFilters, COUNTOF(g_tchFileDlgFilters)) == 0) {
GetString(IDS_FILTER_ALL, lpszFilter, cchFilter);
}
else {
StringCchCopyN(lpszFilter,cchFilter,tchFileDlgFilters,cchFilter - 2);
StringCchCopyN(lpszFilter,cchFilter,g_tchFileDlgFilters,cchFilter - 2);
StringCchCat(lpszFilter,cchFilter,L"||");
}
PrepareFilterStr(lpszFilter);

View File

@ -65,6 +65,7 @@ typedef enum BufferSizes
LARGE_BUFFER = 512,
HUGE_BUFFER = 1024,
XHUGE_BUFFER = 2048,
XXXL_BUFFER = 4096,
FILE_ARG_BUF = MAX_PATH + 2,
FNDRPL_BUFFER = 1024,
@ -80,12 +81,15 @@ typedef enum { MBINFO = 0, MBWARN, MBYESNO, MBYESNOWARN, MBYESNOCANCEL, MBOKCANC
//==== Statusbar ==============================================================
typedef enum {
STATUS_DOCLINE = 0, STATUS_DOCCOLUMN, STATUS_SELECTION, STATUS_OCCURRENCE, STATUS_DOCSIZE,
STATUS_CODEPAGE, STATUS_EOLMODE, STATUS_OVRMODE, STATUS_2ND_DEF, STATUS_LEXER,
STATUS_DOCLINE = 0, STATUS_DOCCOLUMN, STATUS_SELECTION, STATUS_SELCTLINES, STATUS_OCCURRENCE,
STATUS_DOCSIZE, STATUS_CODEPAGE, STATUS_EOLMODE, STATUS_OVRMODE, STATUS_2ND_DEF, STATUS_LEXER,
STATUS_SECTOR_COUNT,
STATUS_HELP = 255
} STATUS_SECTOR_T;
#define STATUSBAR_DEFAULT_IDS L"0 1 2 3 4 5 6 7 8 9 10"
#define STATUSBAR_SECTOR_WEIGHTS { 2, 2, 3, 2, 2, 2, 2, 1, 1, 1, 3 }
// --------------------------------------------------------------------------
typedef struct _editfindreplace

View File

@ -184,22 +184,23 @@
#define IDS_STATUS_DOCCOLUMN 10007
#define IDS_STATUS_DOCCOLUMN2 10008
#define IDS_STATUS_SELECTION 10009
#define IDS_STATUS_OCCURRENCE 10010
#define IDS_STATUS_DOCSIZE 10011
#define IDS_LOADFILE 10012
#define IDS_SAVEFILE 10013
#define IDS_PRINTFILE 10014
#define IDS_SAVINGSETTINGS 10015
#define IDS_LINKDESCRIPTION 10016
#define IDS_FILTER_ALL 10017
#define IDS_FILTER_EXE 10018
#define IDS_FILTER_INI 10019
#define IDS_OPENWITH 10020
#define IDS_FAVORITES 10021
#define IDS_BACKSLASHHELP 10022
#define IDS_REGEXPHELP 10023
#define IDS_WILDCARDHELP 10024
#define IDS_FR_STATUS_FMT 10025
#define IDS_STATUS_SELCTLINES 10010
#define IDS_STATUS_OCCURRENCE 10011
#define IDS_STATUS_DOCSIZE 10012
#define IDS_LOADFILE 10013
#define IDS_SAVEFILE 10014
#define IDS_PRINTFILE 10015
#define IDS_SAVINGSETTINGS 10016
#define IDS_LINKDESCRIPTION 10017
#define IDS_FILTER_ALL 10018
#define IDS_FILTER_EXE 10019
#define IDS_FILTER_INI 10020
#define IDS_OPENWITH 10021
#define IDS_FAVORITES 10022
#define IDS_BACKSLASHHELP 10023
#define IDS_REGEXPHELP 10024
#define IDS_WILDCARDHELP 10025
#define IDS_FR_STATUS_FMT 10026
#define CMD_ESCAPE 20000
#define CMD_SHIFTESC 20001
#define CMD_SHIFTCTRLENTER 20002