[BUG_FIXED] Fix the file status auto-detection bug : a unwanted selection after a popup dialog.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@10 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2007-08-22 16:53:19 +00:00
parent 1f83e269f4
commit e062a94cc5
3 changed files with 35 additions and 15 deletions

View File

@ -1923,12 +1923,12 @@ BOOL Notepad_plus::notify(SCNotification *notification)
} }
void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite) void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite)
{ {
int caretPos = int(_pEditView->execute(SCI_GETCURRENTPOS, 0, 0)); int caretPos = int(_pEditView->execute(SCI_GETCURRENTPOS));
braceAtCaret = -1; braceAtCaret = -1;
braceOpposite = -1; braceOpposite = -1;
char charBefore = '\0'; char charBefore = '\0';
//char styleBefore = '\0'; //char styleBefore = '\0';
int lengthDoc = int(_pEditView->execute(SCI_GETLENGTH, 0, 0)); int lengthDoc = int(_pEditView->execute(SCI_GETLENGTH));
if ((lengthDoc > 0) && (caretPos > 0)) if ((lengthDoc > 0) && (caretPos > 0))
{ {
@ -3898,6 +3898,8 @@ void Notepad_plus::checkModifiedDocument()
const NppGUI & nppGUI = pNppParam->getNppGUI(); const NppGUI & nppGUI = pNppParam->getNppGUI();
bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate); bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate);
for (int j = 0 ; j < NB_VIEW ; j++) for (int j = 0 ; j < NB_VIEW ; j++)
{ {
for (int i = (pScintillaArray[j]->getNbDoc()-1) ; i >= 0 ; i--) for (int i = (pScintillaArray[j]->getNbDoc()-1) ; i >= 0 ; i--)
@ -3913,8 +3915,10 @@ void Notepad_plus::checkModifiedDocument()
if (::IsIconic(_hSelf)) if (::IsIconic(_hSelf))
::ShowWindow(_hSelf, SW_SHOWNORMAL); ::ShowWindow(_hSelf, SW_SHOWNORMAL);
//int caretPos = int(_pEditView->execute(SCI_GETCURRENTPOS));
if (update || doReloadOrNot(docBuf.getFileName()) == IDYES) if (update || doReloadOrNot(docBuf.getFileName()) == IDYES)
{ {
pDocTabArray[j]->activate(i); pDocTabArray[j]->activate(i);
// if it's a non current view, make it as the current view // if it's a non current view, make it as the current view
if (j == 1) if (j == 1)
@ -3927,6 +3931,14 @@ void Notepad_plus::checkModifiedDocument()
if (pScintillaArray[j]->isCurrentBufReadOnly()) if (pScintillaArray[j]->isCurrentBufReadOnly())
pScintillaArray[j]->execute(SCI_SETREADONLY, TRUE); pScintillaArray[j]->execute(SCI_SETREADONLY, TRUE);
if (_activeAppInf._isActivated)
{
int curPos = _pEditView->execute(SCI_GETCURRENTPOS);
::PostMessage(_pEditView->getHSelf(), WM_LBUTTONUP, 0, 0);
::PostMessage(_pEditView->getHSelf(), SCI_SETSEL, curPos, curPos);
_activeAppInf._isActivated = false;
}
} }
docBuf.updatTimeStamp(); docBuf.updatTimeStamp();
} }
@ -6589,23 +6601,20 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return notify(reinterpret_cast<SCNotification *>(lParam)); return notify(reinterpret_cast<SCNotification *>(lParam));
} }
//case WM_CHECKTORENEW :
//printStr("bourges ton cul !!!");
//checkModifiedDocument();
//return TRUE;
case WM_ACTIVATEAPP : case WM_ACTIVATEAPP :
{ {
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); if (wParam == TRUE) // if npp is about to be activated
if (LOWORD(wParam) && (nppgui._fileAutoDetection != cdDisabled))
{ {
checkModifiedDocument(); NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI());
return FALSE; if (LOWORD(wParam) && (nppgui._fileAutoDetection != cdDisabled))
{
_activeAppInf._isActivated = true;
checkModifiedDocument();
return FALSE;
}
} }
//return ::DefWindowProc(hwnd, Message, wParam, lParam);
break; break;
} }
case WM_ACTIVATE : case WM_ACTIVATE :
_pEditView->getFocus(); _pEditView->getFocus();

View File

@ -431,6 +431,13 @@ private:
bool _isDocModifing; bool _isDocModifing;
bool _isHotspotDblClicked; bool _isHotspotDblClicked;
struct ActivateAppInfo {
bool _isActivated;
int _x;
int _y;
ActivateAppInfo() : _isActivated(false), _x(0), _y(0){};
} _activeAppInf;
//Synchronized Scolling //Synchronized Scolling
struct SyncInfo { struct SyncInfo {

View File

@ -404,9 +404,13 @@ public:
void scroll(int column, int line){ void scroll(int column, int line){
execute(SCI_LINESCROLL, column, line); execute(SCI_LINESCROLL, column, line);
}; };
long getCurrentPointX()const{
return long (execute(SCI_POINTXFROMPOSITION, 0, execute(SCI_GETCURRENTPOS)));
};
long getCurrentPointY()const{ long getCurrentPointY()const{
return long (execute(SCI_POINTYFROMPOSITION,0,execute(SCI_GETCURRENTPOS))); return long (execute(SCI_POINTYFROMPOSITION, 0, execute(SCI_GETCURRENTPOS)));
}; };
long getTextHeight()const{ long getTextHeight()const{