mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 15:54:17 +02:00
[NEW_FEATURE] Add new pluin notification NPPN_LANGCHANGED.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@319 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
11b624062f
commit
5ef6a4a5b4
@ -336,4 +336,9 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
|||||||
//scnNotification->nmhdr.hwndFrom = hwndNpp;
|
//scnNotification->nmhdr.hwndFrom = hwndNpp;
|
||||||
//scnNotification->nmhdr.idFrom = newBufferID;
|
//scnNotification->nmhdr.idFrom = newBufferID;
|
||||||
|
|
||||||
|
#define NPPN_LANGCHANGED (NPPN_FIRST + 12) // To notify plugins that the language in the current doc is just changed.
|
||||||
|
//scnNotification->nmhdr.code = NPPN_LANGCHANGED;
|
||||||
|
//scnNotification->nmhdr.hwndFrom = hwndNpp;
|
||||||
|
//scnNotification->nmhdr.idFrom = currentBufferID;
|
||||||
|
|
||||||
#endif //NOTEPAD_PLUS_MSGS_H
|
#endif //NOTEPAD_PLUS_MSGS_H
|
||||||
|
@ -4075,7 +4075,9 @@ void Notepad_plus::command(int id)
|
|||||||
case IDM_LANG_CMAKE :
|
case IDM_LANG_CMAKE :
|
||||||
case IDM_LANG_YAML :
|
case IDM_LANG_YAML :
|
||||||
case IDM_LANG_USER :
|
case IDM_LANG_USER :
|
||||||
|
{
|
||||||
setLanguage(id, menuID2LangType(id));
|
setLanguage(id, menuID2LangType(id));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_PREV_DOC :
|
case IDC_PREV_DOC :
|
||||||
@ -8440,6 +8442,7 @@ void Notepad_plus::drawTabbarColoursFromStylerArray()
|
|||||||
if (stInact && stInact->_bgColor != -1)
|
if (stInact && stInact->_bgColor != -1)
|
||||||
TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg);
|
TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) {
|
void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) {
|
||||||
NppParameters *pNppParam = NppParameters::getInstance();
|
NppParameters *pNppParam = NppParameters::getInstance();
|
||||||
const NppGUI & nppGUI = pNppParam->getNppGUI();
|
const NppGUI & nppGUI = pNppParam->getNppGUI();
|
||||||
@ -8456,50 +8459,64 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) {
|
|||||||
if (mask & BufferChangeStatus) { //reload etc
|
if (mask & BufferChangeStatus) { //reload etc
|
||||||
bool didDialog = false;
|
bool didDialog = false;
|
||||||
switch(buffer->getStatus()) {
|
switch(buffer->getStatus()) {
|
||||||
case DOC_UNNAMED: { //nothing todo
|
case DOC_UNNAMED: //nothing todo
|
||||||
break; }
|
{
|
||||||
case DOC_REGULAR: { //nothing todo
|
break;
|
||||||
break; }
|
}
|
||||||
case DOC_MODIFIED: { //ask for reloading
|
case DOC_REGULAR: //nothing todo
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DOC_MODIFIED: //ask for reloading
|
||||||
|
{
|
||||||
bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate) || (nppGUI._fileAutoDetection == cdAutoUpdateGo2end);
|
bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate) || (nppGUI._fileAutoDetection == cdAutoUpdateGo2end);
|
||||||
if (!autoUpdate) {
|
if (!autoUpdate)
|
||||||
|
{
|
||||||
didDialog = true;
|
didDialog = true;
|
||||||
if (doReloadOrNot(buffer->getFilePath()) != IDYES)
|
if (doReloadOrNot(buffer->getFilePath()) != IDYES)
|
||||||
break; //abort
|
break; //abort
|
||||||
}
|
}
|
||||||
//activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible
|
//activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible
|
||||||
doReload(buffer->getID(), false);
|
doReload(buffer->getID(), false);
|
||||||
if (mainActive || subActive) {
|
if (mainActive || subActive)
|
||||||
|
{
|
||||||
performPostReload(mainActive?MAIN_VIEW:SUB_VIEW);
|
performPostReload(mainActive?MAIN_VIEW:SUB_VIEW);
|
||||||
}
|
}
|
||||||
break; }
|
break;
|
||||||
case DOC_DELETED: { //ask for keep
|
}
|
||||||
|
case DOC_DELETED: //ask for keep
|
||||||
|
{
|
||||||
int index = _pDocTab->getIndexByBuffer(buffer->getID());
|
int index = _pDocTab->getIndexByBuffer(buffer->getID());
|
||||||
int iView = currentView();
|
int iView = currentView();
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
iView = otherView();
|
iView = otherView();
|
||||||
//activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible
|
//activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible
|
||||||
didDialog = true;
|
didDialog = true;
|
||||||
if (doCloseOrNot(buffer->getFilePath()) == IDNO) {
|
if (doCloseOrNot(buffer->getFilePath()) == IDNO)
|
||||||
|
{
|
||||||
//close in both views, doing current view last since that has to remain opened
|
//close in both views, doing current view last since that has to remain opened
|
||||||
doClose(buffer->getID(), otherView());
|
doClose(buffer->getID(), otherView());
|
||||||
doClose(buffer->getID(), currentView());
|
doClose(buffer->getID(), currentView());
|
||||||
}
|
}
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (didDialog) {
|
if (didDialog)
|
||||||
|
{
|
||||||
int curPos = _pEditView->execute(SCI_GETCURRENTPOS);
|
int curPos = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||||
::PostMessage(_pEditView->getHSelf(), WM_LBUTTONUP, 0, 0);
|
::PostMessage(_pEditView->getHSelf(), WM_LBUTTONUP, 0, 0);
|
||||||
::PostMessage(_pEditView->getHSelf(), SCI_SETSEL, curPos, curPos);
|
::PostMessage(_pEditView->getHSelf(), SCI_SETSEL, curPos, curPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mainActive && !subActive) {
|
if (!mainActive && !subActive)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & (BufferChangeLanguage)) {
|
if (mask & (BufferChangeLanguage))
|
||||||
|
{
|
||||||
if (mainActive)
|
if (mainActive)
|
||||||
_autoCompleteMain.setLanguage(buffer->getLangType());
|
_autoCompleteMain.setLanguage(buffer->getLangType());
|
||||||
if (subActive)
|
if (subActive)
|
||||||
@ -8512,7 +8529,8 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) {
|
|||||||
if ((currentView() == SUB_VIEW) && !subActive)
|
if ((currentView() == SUB_VIEW) && !subActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mask & (BufferChangeDirty|BufferChangeFilename)) {
|
if (mask & (BufferChangeDirty|BufferChangeFilename))
|
||||||
|
{
|
||||||
checkDocState();
|
checkDocState();
|
||||||
setTitle();
|
setTitle();
|
||||||
TCHAR dir[MAX_PATH];
|
TCHAR dir[MAX_PATH];
|
||||||
@ -8520,22 +8538,31 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) {
|
|||||||
PathRemoveFileSpec(dir);
|
PathRemoveFileSpec(dir);
|
||||||
setWorkingDir(dir);
|
setWorkingDir(dir);
|
||||||
}
|
}
|
||||||
if (mask & (BufferChangeLanguage)) {
|
|
||||||
|
if (mask & (BufferChangeLanguage))
|
||||||
|
{
|
||||||
checkLangsMenu(-1); //let N++ do search for the item
|
checkLangsMenu(-1); //let N++ do search for the item
|
||||||
setLangStatus(buffer->getLangType());
|
setLangStatus(buffer->getLangType());
|
||||||
if (_mainEditView.getCurrentBuffer() == buffer)
|
if (_mainEditView.getCurrentBuffer() == buffer)
|
||||||
_autoCompleteMain.setLanguage(buffer->getLangType());
|
_autoCompleteMain.setLanguage(buffer->getLangType());
|
||||||
else if (_subEditView.getCurrentBuffer() == buffer)
|
else if (_subEditView.getCurrentBuffer() == buffer)
|
||||||
_autoCompleteSub.setLanguage(buffer->getLangType());
|
_autoCompleteSub.setLanguage(buffer->getLangType());
|
||||||
|
|
||||||
|
SCNotification scnN;
|
||||||
|
scnN.nmhdr.code = NPPN_LANGCHANGED;
|
||||||
|
scnN.nmhdr.hwndFrom = _hSelf;
|
||||||
|
scnN.nmhdr.idFrom = (uptr_t)_pEditView->getCurrentBufferID();
|
||||||
|
_pluginsManager.notify(&scnN);
|
||||||
}
|
}
|
||||||
if (mask & (BufferChangeFormat|BufferChangeLanguage|BufferChangeUnicode)) {
|
|
||||||
|
if (mask & (BufferChangeFormat|BufferChangeLanguage|BufferChangeUnicode))
|
||||||
|
{
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
checkUnicodeMenuItems(buffer->getUnicodeMode());
|
checkUnicodeMenuItems(buffer->getUnicodeMode());
|
||||||
setUniModeText(buffer->getUnicodeMode());
|
setUniModeText(buffer->getUnicodeMode());
|
||||||
setDisplayFormat(buffer->getFormat());
|
setDisplayFormat(buffer->getFormat());
|
||||||
enableConvertMenuItems(buffer->getFormat());
|
enableConvertMenuItems(buffer->getFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) {
|
void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user