Add Debug Info feature

This commit is contained in:
Don Ho 2015-12-06 23:20:14 +01:00
parent 48e9b84bb2
commit 773397d6ea
13 changed files with 209 additions and 20 deletions

View File

@ -541,3 +541,14 @@ bool PluginsManager::allocateMarker(int numberRequired, int *start)
return retVal;
}
generic_string PluginsManager::getLoadedPluginNames() const
{
generic_string pluginPaths;
for (size_t i = 0; i < _loadedDlls.size(); ++i)
{
pluginPaths += _loadedDlls[i];
pluginPaths += TEXT(" ");
}
return pluginPaths;
}

View File

@ -57,9 +57,7 @@ struct PluginCommand
struct PluginInfo
{
PluginInfo() :_hLib(NULL), _pluginMenu(NULL), _pFuncSetInfo(NULL),\
_pFuncGetFuncsArray(NULL), _pFuncGetName(NULL), _funcItems(NULL),\
_nbFuncItem(0){}
PluginInfo() {}
~PluginInfo()
{
if (_pluginMenu)
@ -69,25 +67,25 @@ struct PluginInfo
::FreeLibrary(_hLib);
}
HINSTANCE _hLib;
HMENU _pluginMenu;
HINSTANCE _hLib = NULL;
HMENU _pluginMenu = NULL;
PFUNCSETINFO _pFuncSetInfo;
PFUNCGETNAME _pFuncGetName;
PBENOTIFIED _pBeNotified;
PFUNCGETFUNCSARRAY _pFuncGetFuncsArray;
PMESSAGEPROC _pMessageProc;
PFUNCISUNICODE _pFuncIsUnicode;
PFUNCSETINFO _pFuncSetInfo = NULL;
PFUNCGETNAME _pFuncGetName = NULL;
PBENOTIFIED _pBeNotified = NULL;
PFUNCGETFUNCSARRAY _pFuncGetFuncsArray = NULL;
PMESSAGEPROC _pMessageProc = NULL;
PFUNCISUNICODE _pFuncIsUnicode = NULL;
FuncItem *_funcItems;
int _nbFuncItem;
FuncItem *_funcItems = NULL;
int _nbFuncItem = 0;
generic_string _moduleName;
};
class PluginsManager
{
public:
PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false), _dynamicIDAlloc(ID_PLUGINS_CMD_DYNAMIC, ID_PLUGINS_CMD_DYNAMIC_LIMIT),
PluginsManager() : _dynamicIDAlloc(ID_PLUGINS_CMD_DYNAMIC, ID_PLUGINS_CMD_DYNAMIC_LIMIT),
_markerAlloc(MARKER_PLUGINS, MARKER_PLUGINS_LIMIT) {}
~PluginsManager()
{
@ -128,15 +126,16 @@ public:
bool inDynamicRange(int id) { return _dynamicIDAlloc.isInRange(id); }
bool allocateMarker(int numberRequired, int *start);
generic_string getLoadedPluginNames() const;
private:
NppData _nppData;
HMENU _hPluginsMenu;
HMENU _hPluginsMenu = NULL;
std::vector<PluginInfo *> _pluginInfos;
std::vector<PluginCommand> _pluginsCommands;
std::vector<generic_string> _loadedDlls;
bool _isDisabled;
bool _isDisabled = false;
IDAllocator _dynamicIDAlloc;
IDAllocator _markerAlloc;

View File

@ -616,6 +616,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_findCharsInRangeDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_colEditorDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_aboutDlg.init(_pPublicInterface->getHinst(), hwnd);
_debugInfoDlg.init(_pPublicInterface->getHinst(), hwnd, _isAdministrator, _pluginsManager.getLoadedPluginNames());
_runDlg.init(_pPublicInterface->getHinst(), hwnd);
_runMacroDlg.init(_pPublicInterface->getHinst(), hwnd);

View File

@ -341,6 +341,7 @@ private:
FindReplaceDlg _findReplaceDlg;
FindIncrementDlg _incrementFindDlg;
AboutDlg _aboutDlg;
DebugInfoDlg _debugInfoDlg;
RunDlg _runDlg;
GoToLineDlg _goToLineDlg;
ColumnEditorDlg _colEditorDlg;

View File

@ -855,6 +855,7 @@ BEGIN
MENUITEM "Update Notepad++", IDM_UPDATE_NPP
MENUITEM "Set Updater Proxy...", IDM_CONFUPDATERPROXY
MENUITEM SEPARATOR
MENUITEM "Debug Info", IDM_DEBUGINFO
MENUITEM "About Notepad++", IDM_ABOUT
END
@ -894,6 +895,18 @@ BEGIN
EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
END
IDD_DEBUGINFOBOX DIALOGEX 0, 0, 271, 200
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "Debug Info"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN
EDITTEXT IDC_DEBUGINFO_EDIT,31,20,220,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
LTEXT "Copy debug info into clipboard",IDC_DEBUGINFO_COPYLINK,31,120,126,8
DEFPUSHBUTTON "OK",IDOK,106,160,50,14,BS_FLAT,WS_EX_STATICEDGE
END
IDD_GOLINE DIALOGEX 26, 41, 261, 88
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE

View File

@ -2196,6 +2196,12 @@ void Notepad_plus::command(int id)
break;
}
case IDM_DEBUGINFO:
{
_debugInfoDlg.doDialog();
break;
}
case IDM_ABOUT:
{
bool doAboutDlg = false;

View File

@ -6040,6 +6040,28 @@ int NppParameters::langTypeToCommandID(LangType lt) const
return id;
}
generic_string NppParameters:: getWinVersionStr() const
{
switch (_winVersion)
{
case WV_WIN32S: return TEXT("Windows 3.1");
case WV_95: return TEXT("Windows 95");
case WV_98: return TEXT("Windows 98");
case WV_ME: return TEXT("Windows Millennium Edition");
case WV_NT: return TEXT("Windows NT");
case WV_W2K: return TEXT("Windows 2000");
case WV_XP: return TEXT("Windows XP");
case WV_S2003: return TEXT("Windows Server 2003");
case WV_XPX64: return TEXT("Windows XP 64 bits");
case WV_VISTA: return TEXT("Windows Vista");
case WV_WIN7: return TEXT("Windows 7");
case WV_WIN8: return TEXT("Windows 8");
case WV_WIN81: return TEXT("Windows 8.1");
case WV_WIN10: return TEXT("Windows 10");
default: /*case WV_UNKNOWN:*/ return TEXT("Windows unknown version");
}
}
void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & globalStylers)
{
TiXmlNode *lexersRoot = (_pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("LexerStyles"));

View File

@ -1495,7 +1495,8 @@ public:
bool getContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU pluginsMenu);
bool reloadContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU pluginsMenu);
winVer getWinVersion() { return _winVersion;};
winVer getWinVersion() const {return _winVersion;};
generic_string getWinVersionStr() const;
FindHistory & getFindHistory() {return _findHistory;};
bool _isFindReplacing; // an on the fly variable for find/replace functions
void safeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection);

View File

@ -2566,7 +2566,7 @@ void Finder::copy()
const generic_string toClipboard = stringJoin(lines, TEXT("\r\n"));
if (!toClipboard.empty())
{
if (!str2Clipboard(toClipboard.c_str(), _hSelf))
if (!str2Clipboard(toClipboard, _hSelf))
{
assert(false);
::MessageBox(NULL, TEXT("Error placing text in clipboard."), TEXT("Notepad++"), MB_ICONINFORMATION);

View File

@ -111,5 +111,106 @@ void AboutDlg::doDialog()
// Adjust the position of AboutBox
goToCenter();
};
}
INT_PTR CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/)
{
switch (message)
{
case WM_INITDIALOG:
{
// Notepad++ version
_debugInfoStr = NOTEPAD_PLUS_VERSION;
_debugInfoStr += TEXT("\r\n");
// Build time
_debugInfoStr += TEXT("Build time : ");
generic_string buildTime;
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
buildTime += wmc->char2wchar(__DATE__, CP_ACP);
buildTime += TEXT(" - ");
buildTime += wmc->char2wchar(__TIME__, CP_ACP);
_debugInfoStr += buildTime;
_debugInfoStr += TEXT("\r\n");
// Binary path
_debugInfoStr += TEXT("Path : ");
TCHAR nppFullPath[MAX_PATH];
::GetModuleFileName(NULL, nppFullPath, MAX_PATH);
_debugInfoStr += nppFullPath;
_debugInfoStr += TEXT("\r\n");
// Administrator mode
_debugInfoStr += TEXT("Admin mode : ");
_debugInfoStr += (_isAdmin ? TEXT("ON") : TEXT("OFF"));
_debugInfoStr += TEXT("\r\n");
// local conf
_debugInfoStr += TEXT("Local Conf mode : ");
bool doLocalConf = (NppParameters::getInstance())->isLocal();
_debugInfoStr += (doLocalConf ? TEXT("ON") : TEXT("OFF"));
_debugInfoStr += TEXT("\r\n");
// OS version
_debugInfoStr += TEXT("OS : ");
_debugInfoStr += (NppParameters::getInstance())->getWinVersionStr();
_debugInfoStr += TEXT("\r\n");
// Plugins
_debugInfoStr += TEXT("Plugins : ");
_debugInfoStr += _loadedPlugins;
_debugInfoStr += TEXT("\r\n");
::SetDlgItemText(_hSelf, IDC_DEBUGINFO_EDIT, _debugInfoStr.c_str());
_copyToClipboardLink.init(_hInst, _hSelf);
_copyToClipboardLink.create(::GetDlgItem(_hSelf, IDC_DEBUGINFO_COPYLINK), IDC_DEBUGINFO_COPYLINK);
getClientRect(_rc);
return TRUE;
}
case WM_COMMAND:
{
switch (wParam)
{
case IDCANCEL:
case IDOK:
display(false);
return TRUE;
case IDC_DEBUGINFO_COPYLINK:
{
if ((GetKeyState(VK_LBUTTON) & 0x100) != 0)
{
// Visual effect
::SendDlgItemMessage(_hSelf, IDC_DEBUGINFO_EDIT, EM_SETSEL, 0, _debugInfoStr.length() - 1);
// Copy to clipboard
str2Clipboard(_debugInfoStr, _hSelf);
}
return TRUE;
}
default:
break;
}
}
case WM_DESTROY:
{
return TRUE;
}
}
return FALSE;
}
void DebugInfoDlg::doDialog()
{
if (!isCreated())
create(IDD_DEBUGINFOBOX);
// Adjust the position of AboutBox
goToCenter();
}

View File

@ -55,7 +55,6 @@ along with this program; if not, write to the Free Software \
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.")
class AboutDlg : public StaticDialog
{
public :
@ -76,4 +75,33 @@ private :
URLCtrl _pageLink;
};
class DebugInfoDlg : public StaticDialog
{
public:
DebugInfoDlg() : StaticDialog() {};
void init(HINSTANCE hInst, HWND parent, bool isAdmin, generic_string loadedPlugins) {
_isAdmin = isAdmin;
_loadedPlugins = loadedPlugins;
Window::init(hInst, parent);
};
void doDialog();
virtual void destroy() {
_copyToClipboardLink.destroy();
};
protected:
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
private:
generic_string _debugInfoStr;
bool _isAdmin = false;
generic_string _loadedPlugins;
URLCtrl _copyToClipboardLink;
};
#endif //ABOUT_DLG_H

View File

@ -487,6 +487,7 @@
#define IDM_CONFUPDATERPROXY (IDM_ABOUT + 9)
#define IDM_CMDLINEARGUMENTS (IDM_ABOUT + 10)
#define IDM_ONLINESUPPORT (IDM_ABOUT + 11)
#define IDM_DEBUGINFO (IDM_ABOUT + 12)
#define IDM_SETTING (IDM + 8000)

View File

@ -277,6 +277,11 @@
#define IDC_ONLINEHELP_ADDR 1704
#define IDC_AUTHOR_NAME 1705
#define IDC_BUILD_DATETIME 1706 //LS: CompileDateInAboutDialog: Automatically insert compile date as additional version info in About-dialog!
#define IDD_DEBUGINFOBOX 1750
#define IDC_DEBUGINFO_EDIT 1751
#define IDC_DEBUGINFO_COPYLINK 1752
//#define IDD_USER_DEFINE_BOX 1800
//#define IDD_RUN_DLG 1900