コード例 #1
0
ファイル: BufferTimeList.cpp プロジェクト: triaxia/NppSalt
void BufferTimeList::Monitor()
{
    vector<TCHAR *> messages;
    try
    {
        AutoLock lock(&_sync);
        for (int idx = 0; idx < _files.size(); idx++)
        {
            FILETIME time;
            if (IsChanged(_files[idx]->BufferId, &time))
            {
                TCHAR localTime[256];
                ToLocalTime(time, localTime);
                TCHAR *pbuffer = new TCHAR[1024];
                generic_sprintf(pbuffer, TEXT("\"%s\" has been modified by another program (%s)."), _files[idx]->Path, localTime);
                messages.push_back(pbuffer);
            }
        }
    }
    catch (...)
    {
        // ignore all
    };

    // flash outside of the lock as otherwise it will block messgages which in-turn causes deadlock
    if (messages.size() > 0)
        FlashCaption(messages);
}
コード例 #2
0
ファイル: PluginsManager.cpp プロジェクト: Loreia/UDL2
bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam)
{
	const TCHAR * moduleName = (const TCHAR *)wParam;
	if (!moduleName || !moduleName[0] || !lParam)
		return false;

	for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
	{
        if (_pluginInfos[i]->_moduleName == moduleName)
		{
            if (_pluginInfos[i]->_hLib)
			{
				try {
					_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
				} catch(std::exception e) {
					::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
				} catch (...) {
					TCHAR funcInfo[128];
					generic_sprintf(funcInfo, TEXT("relayPluginMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
					pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
				}
				return true;
            }
		}
	}
	return false;
}
コード例 #3
0
ファイル: BufferTimeList.cpp プロジェクト: triaxia/NppSalt
void BufferTimeList::BeforeSave(unsigned long bufferId)
{
    AutoLock lock(&_sync);
    FILETIME time;
    if (!IsChanged(bufferId, &time))
        return;

    BufferTime *pFile = Find(bufferId);

    SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_SELECTALL, 0);
    SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_COPY, 0);
    SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_DELETE, 0);
    SendMessage(_hwnd, NPPM_RELOADFILE, 0, (LPARAM) pFile->Path); // 0 - no alert
    SendMessage(_hwnd, WM_COMMAND, IDM_FILE_NEW, 0);
    SendMessage(_hwnd, WM_COMMAND, IDM_EDIT_PASTE, 0);

    TCHAR localTime[256];
    ToLocalTime(time, localTime);

    TCHAR newTitle[256];
    SendMessage(_hwnd, NPPM_GETFULLCURRENTPATH, 256, (LPARAM) newTitle);
    TCHAR buffer[1024];
    static const TCHAR * format = TEXT("Your changes have NOT been saved because \"%s\" was modified and saved to disk by another program (%s).\n\nThe file has now been reloaded and your changes have been copied to the \"%s\" tab.");
    generic_sprintf(buffer, format, pFile->Path, localTime, newTitle);
    ErrorBox(_hwnd, buffer);
}
コード例 #4
0
ファイル: BufferTimeList.cpp プロジェクト: triaxia/NppSalt
void BufferTimeList::ToLocalTime(FILETIME fileTime, TCHAR *localTime)
{
    SYSTEMTIME stUTC, stLocal;
    FileTimeToSystemTime(&fileTime, &stUTC);
    SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
    generic_sprintf(localTime, TEXT("at %02d:%02d:%02d on %02d/%02d/%d"), 
        stLocal.wHour, stLocal.wMinute, stLocal.wSecond, stLocal.wDay, stLocal.wMonth, stLocal.wYear);
}
コード例 #5
0
void ListView::setValues(int codepage)
{
	_codepage = codepage;
	
	for (int i = 0 ; i < 256 ; ++i)
	{
		LVITEM item;
		item.mask = LVIF_TEXT;
		TCHAR dec[8];
		TCHAR hex[8];
		generic_sprintf(dec, TEXT("%d"), i);
		generic_sprintf(hex, TEXT("%02X"), i);
		item.pszText = dec;
		item.iItem = i;
		item.iSubItem = 0;
		ListView_InsertItem(_hSelf, &item);

		ListView_SetItemText(_hSelf, i, 1, (LPTSTR)hex);

		generic_string s = getAscii((unsigned char)i);
		ListView_SetItemText(_hSelf, i, 2, (LPTSTR)s.c_str());
	}
}
コード例 #6
0
int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, TCHAR *defaultMessage, TCHAR *defaultTitle, int msgBoxType, int intInfo, TCHAR *strInfo)
{
	generic_string msg, title;
	size_t index;
	TCHAR int2Write[256];
	TCHAR intPlaceHolderSymbol[] = TEXT("$INT_REPLACE$");
	TCHAR strPlaceHolderSymbol[] = TEXT("$STR_REPLACE$");

	size_t intPlaceHolderLen = lstrlen(intPlaceHolderSymbol);
	size_t strPlaceHolderLen = lstrlen(strPlaceHolderSymbol);

	generic_sprintf(int2Write, TEXT("%d"), intInfo);

	if (!getMsgBoxLang(msgBoxTagName, title, msg))
	{
		title = defaultTitle;
		msg = defaultMessage;
	}
	index = title.find(intPlaceHolderSymbol);
	if (index != string::npos)
		title.replace(index, intPlaceHolderLen, int2Write);

	index = msg.find(intPlaceHolderSymbol);
	if (index != string::npos)
		msg.replace(index, intPlaceHolderLen, int2Write);

	if (strInfo)
	{
		index = title.find(strPlaceHolderSymbol);
		if (index != string::npos)
			title.replace(index, strPlaceHolderLen, strInfo);

		index = msg.find(strPlaceHolderSymbol);
		if (index != string::npos)
			msg.replace(index, strPlaceHolderLen, strInfo);
	}
	return ::MessageBox(hWnd, msg.c_str(), title.c_str(), msgBoxType);

	/*
	defaultTitle.replace(index, len, int2Write);
	defaultTitle.replace(index, len, str2Write);
	defaultMessage.replace(index, len, int2Write);
	defaultMessage.replace(index, len, str2Write);
	return ::MessageBox(hWnd, defaultMessage, defaultTitle, msgBoxType);
	*/
}
コード例 #7
0
ファイル: PluginsManager.cpp プロジェクト: Loreia/UDL2
void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam)
{
	for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
	{
        if (_pluginInfos[i]->_hLib)
		{
			try {
				_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
			} catch(std::exception e) {
				::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
			} catch (...) {
				TCHAR funcInfo[128];
				generic_sprintf(funcInfo, TEXT("relayNppMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
				pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT(""));
			}
		}
	}
}
コード例 #8
0
ファイル: PluginsManager.cpp プロジェクト: Loreia/UDL2
void PluginsManager::runPluginCommand(size_t i)
{
	if (i < _pluginsCommands.size())
	{
		if (_pluginsCommands[i]._pFunc != NULL)
		{
			try {
				_pluginsCommands[i]._pFunc();
			} catch(std::exception e) {
				::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK);
			} catch (...) {
				TCHAR funcInfo[128];
				generic_sprintf(funcInfo, TEXT("runPluginCommand(size_t i : %d)"), i);
				pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
			}
		}
	}
}
コード例 #9
0
ファイル: PluginsManager.cpp プロジェクト: Loreia/UDL2
void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
{
	for (size_t i = 0 ; i < _pluginsCommands.size() ; i++)
	{
		if (!generic_stricmp(_pluginsCommands[i]._pluginName.c_str(), pluginName))
		{
			if (_pluginsCommands[i]._funcID == commandID)
			{
				try {
					_pluginsCommands[i]._pFunc();
				} catch(std::exception e) {
					::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
				} catch (...) {
					TCHAR funcInfo[128];
					generic_sprintf(funcInfo, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID);
					pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
				}
			}
		}
	}
}
コード例 #10
0
ファイル: PluginsManager.cpp プロジェクト: Loreia/UDL2
void PluginsManager::notify(SCNotification *notification)
{
	for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
	{
        if (_pluginInfos[i]->_hLib)
        {
			// To avoid the plugin change the data in SCNotification
			// Each notification to pass to a plugin is a copy of SCNotification instance
			SCNotification scNotif = *notification;
			try {
				_pluginInfos[i]->_pBeNotified(&scNotif);
			} catch(std::exception e) {
				::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
			} catch (...) {
				TCHAR funcInfo[128];
				generic_sprintf(funcInfo, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %d\r notification->nmhdr.idFrom == %d"),\
					scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom);
				pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
			}
		}
	}
}