[ENHANCE] Enhance the auto-add extension feature.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@54 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
86855be790
commit
ead33bc5d4
@ -575,11 +575,6 @@ void Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg)
|
||||
if (filters[0])
|
||||
{
|
||||
int nbExt = fDlg.setExtsFilter(getLangDesc(lid, true).c_str(), filters);
|
||||
|
||||
if (curl == lid)
|
||||
{
|
||||
fDlg.setInitIndex(nbExt - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
l = (NppParameters::getInstance())->getLangFromIndex(i++);
|
||||
@ -598,8 +593,6 @@ void Notepad_plus::fileOpen()
|
||||
int sz = int(pfns->size());
|
||||
for (int i = 0 ; i < sz ; i++)
|
||||
doOpen((pfns->at(i)).c_str(), fDlg.isReadOnly());
|
||||
|
||||
//setLangStatus(_pEditView->getCurrentDocType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -5523,8 +5516,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
//--Status Bar Section--//
|
||||
bool willBeShown = nppGUI._statusBarShow;
|
||||
_statusBar.init(_hInst, hwnd, 6);
|
||||
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, 100);
|
||||
_statusBar.setPartWidth(STATUSBAR_CUR_POS, 180);
|
||||
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, 180);
|
||||
_statusBar.setPartWidth(STATUSBAR_CUR_POS, 250);
|
||||
_statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, 80);
|
||||
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, 100);
|
||||
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, 30);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -502,20 +502,20 @@ BEGIN
|
||||
CONTROL "",IDI_M30ICON,"Static",SS_OWNERDRAW,21,10,20,20
|
||||
END
|
||||
|
||||
IDD_GOLINE DIALOGEX 26, 41, 223, 67
|
||||
IDD_GOLINE DIALOGEX 26, 41, 233, 67
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
|
||||
CAPTION "Go To Line #"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "You are here :", ID_URHERE_STATIC,5,8,95,8,NOT WS_GROUP
|
||||
LTEXT "0123456789",ID_CURRLINE,100,8,40,8,NOT WS_GROUP
|
||||
LTEXT "0123456789",ID_CURRLINE,100,8,45,8,NOT WS_GROUP
|
||||
LTEXT "You want to go :", ID_UGO_STATIC,5,21,95,8
|
||||
EDITTEXT ID_GOLINE_EDIT,100,20,35,12,ES_NUMBER
|
||||
EDITTEXT ID_GOLINE_EDIT,100,20,45,12,ES_NUMBER
|
||||
LTEXT "You can't go further than :", ID_NOMORETHAN_STATIC,5,49,92,8,NOT WS_GROUP
|
||||
LTEXT "0123456789",ID_LASTLINE,99,49,40,8,NOT WS_GROUP
|
||||
DEFPUSHBUTTON "&Go !",IDOK,145,21,70,14,BS_NOTIFY
|
||||
PUSHBUTTON "I'm going nowhere",IDCANCEL,145,43,70,14,BS_NOTIFY
|
||||
LTEXT "0123456789",ID_LASTLINE,99,49,45,8,NOT WS_GROUP
|
||||
DEFPUSHBUTTON "&Go !",IDOK,155,21,70,14,BS_NOTIFY
|
||||
PUSHBUTTON "I'm going nowhere",IDCANCEL,155,43,70,14,BS_NOTIFY
|
||||
END
|
||||
|
||||
IDD_VALUE_DLG DIALOGEX 0, 0, 74, 17
|
||||
|
@ -20,7 +20,7 @@
|
||||
FileDialog *FileDialog::staticThis = NULL;
|
||||
|
||||
FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst)
|
||||
: _nbCharFileExt(0), _nbExt(0), _initIndex(-1)
|
||||
: _nbCharFileExt(0), _nbExt(0)
|
||||
{staticThis = this;
|
||||
for (int i = 0 ; i < nbExtMax ; i++)
|
||||
_extArray[i][0] = '\0';
|
||||
@ -221,8 +221,11 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||
if (*fn == '\0')
|
||||
return oldProc(hwnd, message, wParam, lParam);
|
||||
|
||||
string fnExt = changeExt(fn, currentExt);
|
||||
::SetWindowText(fnControl, fnExt.c_str());
|
||||
if (currentExt != "")
|
||||
{
|
||||
string fnExt = changeExt(fn, currentExt);
|
||||
::SetWindowText(fnControl, fnExt.c_str());
|
||||
}
|
||||
return oldProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
@ -234,6 +237,34 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||
return oldProc(hwnd, message, wParam, lParam);
|
||||
};
|
||||
|
||||
static char * get1stExt(char *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt)
|
||||
char *begin = ext;
|
||||
for ( ; *begin != '.' ; begin++);
|
||||
char *end = ++begin;
|
||||
for ( ; *end != ';' && *end != ')' ; end++);
|
||||
*end = '\0';
|
||||
if (*begin == '*')
|
||||
*begin = '\0';
|
||||
return begin;
|
||||
};
|
||||
|
||||
static string addExt(HWND textCtrl, HWND typeCtrl) {
|
||||
char fn[256];
|
||||
::GetWindowText(textCtrl, fn, sizeof(fn));
|
||||
|
||||
int i = ::SendMessage(typeCtrl, CB_GETCURSEL, 0, 0);
|
||||
char ext[256];
|
||||
::SendMessage(typeCtrl, CB_GETLBTEXT, i, (LPARAM)ext);
|
||||
char *pExt = get1stExt(ext);
|
||||
if (*fn != '\0')
|
||||
{
|
||||
string fnExt = changeExt(fn, pExt);
|
||||
::SetWindowText(textCtrl, fnExt.c_str());
|
||||
}
|
||||
return pExt;
|
||||
};
|
||||
|
||||
|
||||
UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(uMsg)
|
||||
@ -243,18 +274,13 @@ UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
|
||||
::SetWindowLong(hWnd, GWL_USERDATA, (long)staticThis);
|
||||
hFileDlg = ::GetParent(hWnd);
|
||||
goToCenter(hFileDlg);
|
||||
if (staticThis->_initIndex != -1)
|
||||
/*if (staticThis->_initIndex != -1)
|
||||
{
|
||||
HWND typeControl = ::GetDlgItem(hFileDlg, cmb1);
|
||||
::SendMessage(typeControl, CB_SETCURSEL, staticThis->_initIndex, 0);
|
||||
char ext[256];
|
||||
::SendMessage(typeControl, CB_GETLBTEXT, staticThis->_initIndex, (LPARAM)ext);
|
||||
char *pExt = staticThis->get1stExt(ext);
|
||||
if (*pExt == '\0')
|
||||
return TRUE;
|
||||
|
||||
currentExt = pExt;
|
||||
}
|
||||
HWND fnControl = ::GetDlgItem(hFileDlg, edt1);
|
||||
currentExt = addExt(fnControl, typeControl);
|
||||
}*/
|
||||
oldProc = (WNDPROC)::SetWindowLong(hFileDlg, GWL_WNDPROC, (LONG)fileDlgProc);
|
||||
return FALSE;
|
||||
}
|
||||
@ -269,7 +295,6 @@ UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
@ -282,24 +307,9 @@ BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
case CDN_TYPECHANGE :
|
||||
{
|
||||
HWND fnControl = ::GetDlgItem(::GetParent(hWnd), edt1);
|
||||
char fn[256];
|
||||
::GetWindowText(fnControl, fn, sizeof(fn));
|
||||
if (*fn == '\0')
|
||||
return TRUE;
|
||||
|
||||
HWND typeControl = ::GetDlgItem(::GetParent(hWnd), cmb1);
|
||||
int i = ::SendMessage(typeControl, CB_GETCURSEL, 0, 0);
|
||||
char ext[256];
|
||||
::SendMessage(typeControl, CB_GETLBTEXT, i, (LPARAM)ext);
|
||||
currentExt = addExt(fnControl, typeControl);
|
||||
|
||||
char *pExt = get1stExt(ext);
|
||||
if (*pExt == '\0')
|
||||
return TRUE;
|
||||
|
||||
currentExt = pExt;
|
||||
string fnExt = changeExt(fn, pExt);
|
||||
|
||||
::SetWindowText(fnControl, fnExt.c_str());
|
||||
break;
|
||||
}
|
||||
default :
|
||||
|
@ -40,7 +40,7 @@ static string changeExt(string fn, string ext)
|
||||
{
|
||||
string fnExt = fn;
|
||||
int index = fnExt.find_last_of(".");
|
||||
string extension = ".";
|
||||
string extension = ext == ""?"":".";
|
||||
extension += ext;
|
||||
if (index == string::npos)
|
||||
{
|
||||
@ -85,9 +85,6 @@ public:
|
||||
stringVector * doOpenMultiFilesDlg();
|
||||
char * doOpenSingleFileDlg();
|
||||
bool isReadOnly() {return _ofn.Flags & OFN_READONLY;};
|
||||
void setInitIndex(int i) {
|
||||
_initIndex = i;
|
||||
};
|
||||
|
||||
protected :
|
||||
static UINT APIENTRY OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
@ -104,19 +101,8 @@ private:
|
||||
|
||||
char _extArray[nbExtMax][extLenMax];
|
||||
int _nbExt;
|
||||
int _initIndex;
|
||||
//int _initIndex;
|
||||
|
||||
|
||||
char * get1stExt(char *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt)
|
||||
char *begin = ext;
|
||||
for ( ; *begin != '.' ; begin++);
|
||||
char *end = ++begin;
|
||||
for ( ; *end != ';' && *end != ')' ; end++);
|
||||
*end = '\0';
|
||||
if (*begin == '*')
|
||||
*begin = '\0';
|
||||
return begin;
|
||||
};
|
||||
static FileDialog *staticThis;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user