[prev in list] [next in list] [prev in thread] [next in thread]
List: jedit-cvs
Subject: [ jEdit-commits ] SF.net SVN: jedit: [12020] jEditLauncher/trunk/src
From: eyebex () users ! sourceforge ! net
Date: 2008-02-26 12:13:21
Message-ID: E1JTygT-0005bO-Tm () sc8-pr-svn4 ! sourceforge ! net
[Download RAW message or body]
Revision: 12020
http://jedit.svn.sourceforge.net/jedit/?rev=12020&view=rev
Author: eyebex
Date: 2008-02-26 04:13:21 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
Replace tabs with spaces. In a shared project, where every developer might have a \
different tab setting, it's a bad idea to use tabs. Indenting might get messed up too \
easily, even if there are comments in the source code what the tab setting should be \
(and not all text editors support reading those settings comments from the source \
code automatically).
Modified Paths:
--------------
jEditLauncher/trunk/src/cfgdialog.cpp
jEditLauncher/trunk/src/cfgdialog.h
jEditLauncher/trunk/src/jdiff.cpp
jEditLauncher/trunk/src/jecfg.cpp
jEditLauncher/trunk/src/jedit.cpp
jEditLauncher/trunk/src/jeditext.cpp
jEditLauncher/trunk/src/jeditext.h
jEditLauncher/trunk/src/jeditlib.cpp
jEditLauncher/trunk/src/jeditlib.h
jEditLauncher/trunk/src/stdafx.cpp
jEditLauncher/trunk/src/stdafx.h
Modified: jEditLauncher/trunk/src/cfgdialog.cpp
===================================================================
--- jEditLauncher/trunk/src/cfgdialog.cpp 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/cfgdialog.cpp 2008-02-26 12:13:21 UTC (rev 12020)
@@ -12,148 +12,147 @@
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, \
BOOL& /*bHandled*/) {
- // center the dialog on the screen
- CenterWindow();
+ // center the dialog on the screen
+ CenterWindow();
- // set icons
- HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), \
MAKEINTRESOURCE(IDR_MAINFRAME),
- IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), \
LR_DEFAULTCOLOR);
- SetIcon(hIcon, TRUE);
- HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), \
MAKEINTRESOURCE(IDR_MAINFRAME),
- IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), \
LR_DEFAULTCOLOR);
- SetIcon(hIconSmall, FALSE);
+ // set icons
+ HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), \
MAKEINTRESOURCE(IDR_MAINFRAME), + IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), \
::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR); + SetIcon(hIcon, TRUE);
+ HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), \
MAKEINTRESOURCE(IDR_MAINFRAME), + IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), \
::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); + SetIcon(hIconSmall, FALSE);
- // fetch settings
- get_java_path(m_szJavaPath);
- get_java_opts(m_szJavaOpts);
- get_jedit_jar(m_szJeditPath);
- get_jedit_opts(m_szJeditOpts);
- get_working_dir(m_szWorkingDir);
- // strip quotes
- strip_quotes(m_szJavaPath);
- strip_quotes(m_szJeditPath);
- strip_quotes(m_szWorkingDir);
- // display settings
- SetDlgItemText(IDC_JAVA_PATH,m_szJavaPath);
- SetDlgItemText(IDC_JAVA_OPTS,m_szJavaOpts);
- SetDlgItemText(IDC_JEDIT_PATH,m_szJeditPath);
- SetDlgItemText(IDC_JEDIT_OPTS,m_szJeditOpts);
- SetDlgItemText(IDC_WORKING_DIR,m_szWorkingDir);
+ // fetch settings
+ get_java_path(m_szJavaPath);
+ get_java_opts(m_szJavaOpts);
+ get_jedit_jar(m_szJeditPath);
+ get_jedit_opts(m_szJeditOpts);
+ get_working_dir(m_szWorkingDir);
+ // strip quotes
+ strip_quotes(m_szJavaPath);
+ strip_quotes(m_szJeditPath);
+ strip_quotes(m_szWorkingDir);
+ // display settings
+ SetDlgItemText(IDC_JAVA_PATH,m_szJavaPath);
+ SetDlgItemText(IDC_JAVA_OPTS,m_szJavaOpts);
+ SetDlgItemText(IDC_JEDIT_PATH,m_szJeditPath);
+ SetDlgItemText(IDC_JEDIT_OPTS,m_szJeditOpts);
+ SetDlgItemText(IDC_WORKING_DIR,m_szWorkingDir);
- return TRUE;
+ return TRUE;
}
LRESULT CMainDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& \
/*bHandled*/) {
- // XXX validate
- int r = 0;
- char err_msg[100] = {0};
+ // XXX validate
+ int r = 0;
+ char err_msg[100] = {0};
- // copy settings
- GetDlgItemText(IDC_JAVA_PATH,m_szJavaPath,MAX_PATH);
- GetDlgItemText(IDC_JAVA_OPTS,m_szJavaOpts,MAX_PATH);
- GetDlgItemText(IDC_JEDIT_PATH,m_szJeditPath,MAX_PATH);
- GetDlgItemText(IDC_JEDIT_OPTS,m_szJeditOpts,MAX_PATH);
- GetDlgItemText(IDC_WORKING_DIR,m_szWorkingDir,MAX_PATH);
- // strip quotes
- strip_quotes(m_szJavaPath);
- strip_quotes(m_szJeditPath);
- strip_quotes(m_szWorkingDir);
- // save settings
- r = set_java_path(m_szJavaPath);
- if(!r) r = set_java_opts(m_szJavaOpts);
- if(!r) r = set_jedit_jar(m_szJeditPath);
- if(!r) r = set_jedit_opts(m_szJeditOpts);
- if(!r) r = set_working_dir(m_szWorkingDir);
- if(r)
- {
- sprintf(err_msg,"Error saving settings: %d", r);
- MessageBox(err_msg, "Error", MB_OK | MB_ICONERROR);
- }
+ // copy settings
+ GetDlgItemText(IDC_JAVA_PATH,m_szJavaPath,MAX_PATH);
+ GetDlgItemText(IDC_JAVA_OPTS,m_szJavaOpts,MAX_PATH);
+ GetDlgItemText(IDC_JEDIT_PATH,m_szJeditPath,MAX_PATH);
+ GetDlgItemText(IDC_JEDIT_OPTS,m_szJeditOpts,MAX_PATH);
+ GetDlgItemText(IDC_WORKING_DIR,m_szWorkingDir,MAX_PATH);
+ // strip quotes
+ strip_quotes(m_szJavaPath);
+ strip_quotes(m_szJeditPath);
+ strip_quotes(m_szWorkingDir);
+ // save settings
+ r = set_java_path(m_szJavaPath);
+ if(!r) r = set_java_opts(m_szJavaOpts);
+ if(!r) r = set_jedit_jar(m_szJeditPath);
+ if(!r) r = set_jedit_opts(m_szJeditOpts);
+ if(!r) r = set_working_dir(m_szWorkingDir);
+ if(r)
+ {
+ sprintf(err_msg,"Error saving settings: %d", r);
+ MessageBox(err_msg, "Error", MB_OK | MB_ICONERROR);
+ }
- if(!r)
- EndDialog(wID);
- return r;
+ if(!r)
+ EndDialog(wID);
+ return r;
}
LRESULT CMainDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& \
/*bHandled*/) {
- EndDialog(wID);
- return 0;
+ EndDialog(wID);
+ return 0;
}
LRESULT CMainDlg::OnBnClickedBrowseJava(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/) {
- CFileDialog dlg(TRUE, _T("exe"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, \
_T("Executable Files (*.exe)\0*.exe\0"), m_hWnd);
- if(dlg.DoModal() == IDOK)
- {
- lstrcpy(m_szJavaPath,dlg.m_szFileName);
- SetDlgItemText(IDC_JAVA_PATH,m_szJavaPath);
- }
+ CFileDialog dlg(TRUE, _T("exe"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, \
_T("Executable Files (*.exe)\0*.exe\0"), m_hWnd); + if(dlg.DoModal() == IDOK)
+ {
+ lstrcpy(m_szJavaPath,dlg.m_szFileName);
+ SetDlgItemText(IDC_JAVA_PATH,m_szJavaPath);
+ }
- return 0;
+ return 0;
}
LRESULT CMainDlg::OnBnClickedBrowseJedit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/) {
- CFileDialog dlg(TRUE, _T("jar"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, \
_T("Jar Files (*.jar)\0*.jar\0\0All Files (*.*)\0*.*\0"), m_hWnd);
- if(dlg.DoModal() == IDOK)
- {
- // XXX set working directory
- lstrcpy(m_szJeditPath,dlg.m_szFileName);
- SetDlgItemText(IDC_JEDIT_PATH,m_szJeditPath);
- }
+ CFileDialog dlg(TRUE, _T("jar"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, \
_T("Jar Files (*.jar)\0*.jar\0\0All Files (*.*)\0*.*\0"), m_hWnd); + \
if(dlg.DoModal() == IDOK) + {
+ // XXX set working directory
+ lstrcpy(m_szJeditPath,dlg.m_szFileName);
+ SetDlgItemText(IDC_JEDIT_PATH,m_szJeditPath);
+ }
- return 0;
+ return 0;
}
LRESULT CMainDlg::OnBnClickedBrowseWorkingDir(WORD /*wNotifyCode*/, WORD /*wID*/, \
HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
- CFolderDialog dlg(m_hWnd,"Working Directory",BIF_RETURNONLYFSDIRS);
- if(dlg.DoModal() == IDOK)
- {
- lstrcpy(m_szWorkingDir,dlg.m_szFolderPath);
- SetDlgItemText(IDC_WORKING_DIR,m_szWorkingDir);
- }
+ CFolderDialog dlg(m_hWnd,"Working Directory",BIF_RETURNONLYFSDIRS);
+ if(dlg.DoModal() == IDOK)
+ {
+ lstrcpy(m_szWorkingDir,dlg.m_szFolderPath);
+ SetDlgItemText(IDC_WORKING_DIR,m_szWorkingDir);
+ }
- return 0;
+ return 0;
}
void CMainDlg::UpdateCommandLine(void)
{
- char szCmd[MAX_PATH*10] = {0};
- create_launch_command(m_szJavaPath,m_szJavaOpts,
- m_szJeditPath,m_szJeditOpts,
- m_szWorkingDir,
- NULL, // OptList
- NULL, // filename
- 0, // nfiles
- szCmd,
- MAX_PATH*10);
- SetDlgItemText(IDC_CMD_LINE,szCmd);
+ char szCmd[MAX_PATH*10] = {0};
+ create_launch_command(m_szJavaPath,m_szJavaOpts,
+ m_szJeditPath,m_szJeditOpts,
+ m_szWorkingDir,
+ NULL, // OptList
+ NULL, // filename
+ 0, // nfiles
+ szCmd,
+ MAX_PATH*10);
+ SetDlgItemText(IDC_CMD_LINE,szCmd);
}
LRESULT CMainDlg::OnEnChangeJeditOpts(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/) {
- UpdateCommandLine();
- return 0;
+ UpdateCommandLine();
+ return 0;
}
LRESULT CMainDlg::OnEnChangeJeditPath(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/) {
- UpdateCommandLine();
- return 0;
+ UpdateCommandLine();
+ return 0;
}
LRESULT CMainDlg::OnEnChangeJavaOpts(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/) {
- UpdateCommandLine();
- return 0;
+ UpdateCommandLine();
+ return 0;
}
LRESULT CMainDlg::OnEnChangeJavaPath(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/) {
- UpdateCommandLine();
- return 0;
+ UpdateCommandLine();
+ return 0;
}
-
Modified: jEditLauncher/trunk/src/cfgdialog.h
===================================================================
--- jEditLauncher/trunk/src/cfgdialog.h 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/cfgdialog.h 2008-02-26 12:13:21 UTC (rev 12020)
@@ -11,52 +11,52 @@
class CMainDlg : public CDialogImpl<CMainDlg>
{
public:
- enum { IDD = IDD_MAINDLG };
+ enum { IDD = IDD_MAINDLG };
- char m_szJavaPath[MAX_PATH];
- char m_szJavaOpts[MAX_PATH];
- char m_szJeditPath[MAX_PATH];
- char m_szJeditOpts[MAX_PATH];
- char m_szWorkingDir[MAX_PATH];
+ char m_szJavaPath[MAX_PATH];
+ char m_szJavaOpts[MAX_PATH];
+ char m_szJeditPath[MAX_PATH];
+ char m_szJeditOpts[MAX_PATH];
+ char m_szWorkingDir[MAX_PATH];
- BEGIN_MSG_MAP(CMainDlg)
- MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
- COMMAND_ID_HANDLER(IDOK, OnOK)
- COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
- COMMAND_HANDLER(IDC_BROWSE_JAVA, BN_CLICKED, OnBnClickedBrowseJava)
- COMMAND_HANDLER(IDC_BROWSE_JEDIT, BN_CLICKED, OnBnClickedBrowseJedit)
- COMMAND_HANDLER(IDC_BROWSE_WORKING_DIR, BN_CLICKED, OnBnClickedBrowseWorkingDir)
- COMMAND_HANDLER(IDC_JEDIT_OPTS, EN_CHANGE, OnEnChangeJeditOpts)
- COMMAND_HANDLER(IDC_JEDIT_PATH, EN_CHANGE, OnEnChangeJeditPath)
- COMMAND_HANDLER(IDC_JAVA_OPTS, EN_CHANGE, OnEnChangeJavaOpts)
- COMMAND_HANDLER(IDC_JAVA_PATH, EN_CHANGE, OnEnChangeJavaPath)
- END_MSG_MAP()
+ BEGIN_MSG_MAP(CMainDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_ID_HANDLER(IDOK, OnOK)
+ COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
+ COMMAND_HANDLER(IDC_BROWSE_JAVA, BN_CLICKED, OnBnClickedBrowseJava)
+ COMMAND_HANDLER(IDC_BROWSE_JEDIT, BN_CLICKED, OnBnClickedBrowseJedit)
+ COMMAND_HANDLER(IDC_BROWSE_WORKING_DIR, BN_CLICKED, \
OnBnClickedBrowseWorkingDir) + COMMAND_HANDLER(IDC_JEDIT_OPTS, EN_CHANGE, \
OnEnChangeJeditOpts) + COMMAND_HANDLER(IDC_JEDIT_PATH, EN_CHANGE, \
OnEnChangeJeditPath) + COMMAND_HANDLER(IDC_JAVA_OPTS, EN_CHANGE, \
OnEnChangeJavaOpts) + COMMAND_HANDLER(IDC_JAVA_PATH, EN_CHANGE, \
OnEnChangeJavaPath) + END_MSG_MAP()
-// Handler prototypes (uncomment arguments if needed):
-// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& \
/*bHandled*/)
-// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/)
-// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
+ // Handler prototypes (uncomment arguments if needed):
+ //LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, \
BOOL& /*bHandled*/) + //LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, \
HWND /*hWndCtl*/, BOOL& /*bHandled*/) + //LRESULT NotifyHandler(int /*idCtrl*/, \
LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
- LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& \
/*bHandled*/);
- LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
- LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& \
/*bHandled*/);
- LRESULT OnBnClickedBrowseJava(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/);
- LRESULT OnBnClickedBrowseJedit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/);
- LRESULT OnBnClickedBrowseWorkingDir(WORD /*wNotifyCode*/, WORD /*wID*/, HWND \
/*hWndCtl*/, BOOL& /*bHandled*/);
- LRESULT OnEnChangeWorkingDir(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/);
- LRESULT OnEnChangeJeditOpts(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/);
- LRESULT OnEnChangeJeditPath(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/);
- LRESULT OnEnChangeJavaOpts(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/);
- LRESULT OnEnChangeJavaPath(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/); + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, \
LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnOK(WORD /*wNotifyCode*/, WORD \
wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnCancel(WORD \
/*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT \
OnBnClickedBrowseJava(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& \
/*bHandled*/); + LRESULT OnBnClickedBrowseJedit(WORD /*wNotifyCode*/, WORD \
/*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT \
OnBnClickedBrowseWorkingDir(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, \
BOOL& /*bHandled*/); + LRESULT OnEnChangeWorkingDir(WORD /*wNotifyCode*/, WORD \
/*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnEnChangeJeditOpts(WORD \
/*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT \
OnEnChangeJeditPath(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& \
/*bHandled*/); + LRESULT OnEnChangeJavaOpts(WORD /*wNotifyCode*/, WORD /*wID*/, \
HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnEnChangeJavaPath(WORD \
/*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
- void UpdateCommandLine(void);
+ void UpdateCommandLine(void);
- CMainDlg()
- {
- m_szJavaPath[0] = 0;
- m_szJavaOpts[0] = 0;
- m_szJeditPath[0] = 0;
- m_szJeditOpts[0] = 0;
- m_szWorkingDir[0] = 0;
- }
+ CMainDlg()
+ {
+ m_szJavaPath[0] = 0;
+ m_szJavaOpts[0] = 0;
+ m_szJeditPath[0] = 0;
+ m_szJeditOpts[0] = 0;
+ m_szWorkingDir[0] = 0;
+ }
};
Modified: jEditLauncher/trunk/src/jdiff.cpp
===================================================================
--- jEditLauncher/trunk/src/jdiff.cpp 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/jdiff.cpp 2008-02-26 12:13:21 UTC (rev 12020)
@@ -17,75 +17,72 @@
// as a console app.
#define BUILD_WIN32_APP
-const char* USAGE =
+const char* USAGE =
"Usage: jdiff.exe [-h] file1 file2\n";
-
#ifdef BUILD_WIN32_APP
-int
+int
WINAPI WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
#else
int
main(int argc,
- char** argv)
+ char** argv)
#endif
{
- #ifdef BUILD_WIN32_APP
- // avoid having to parse lpCmdLine if
- // compiling as windows app
- int argc = __argc;
- char** argv = __argv;
- #endif
- LaunchConfig config;
- char file1[MAX_PATH] = {'\0'};
- char file2[MAX_PATH] = {'\0'};
+ #ifdef BUILD_WIN32_APP
+ // avoid having to parse lpCmdLine if
+ // compiling as windows app
+ int argc = __argc;
+ char** argv = __argv;
+ #endif
+ LaunchConfig config;
+ char file1[MAX_PATH] = {'\0'};
+ char file2[MAX_PATH] = {'\0'};
- for(int i=1; i < argc; i++)
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "argv[%d]: %s\n", i, argv[i]);
+ for(int i=1; i < argc; i++)
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "argv[%d]: %s\n", i, argv[i]);
- // XXX a wait option would be nice
- if(argc > 1 && (strcmp(argv[1], "/h") == 0 ||
- strcmp(argv[1], "-h") == 0 ||
- strcmp(argv[1], "/?") == 0 ||
- strcmp(argv[1], "--help") == 0))
- {
+ // XXX a wait option would be nice
+ if(argc > 1 && (strcmp(argv[1], "/h") == 0 ||
+ strcmp(argv[1], "-h") == 0 ||
+ strcmp(argv[1], "/?") == 0 ||
+ strcmp(argv[1], "--help") == 0))
+ {
#ifdef BUILD_WIN32_APP
- MessageBox(NULL, USAGE, "jDiff Usage", MB_OK);
+ MessageBox(NULL, USAGE, "jDiff Usage", MB_OK);
#else
- printf(USAGE);
+ printf(USAGE);
#endif
- exit(0);
- }
- else if(argc != 3)
- {
+ exit(0);
+ }
+ else if(argc != 3)
+ {
#ifdef BUILD_WIN32_APP
- MessageBox(NULL, USAGE, "jDiff Usage", MB_OK);
+ MessageBox(NULL, USAGE, "jDiff Usage", MB_OK);
#else
- printf(USAGE);
+ printf(USAGE);
#endif
- exit(2);
- }
+ exit(2);
+ }
- if(get_launch_config(&config))
- {
- printf(FAILED_TO_GET_SETTINGS);
- return 1;
- }
+ if(get_launch_config(&config))
+ {
+ printf(FAILED_TO_GET_SETTINGS);
+ return 1;
+ }
- _fullpath(file1,argv[1],MAX_PATH);
- _fullpath(file2,argv[2],MAX_PATH);
+ _fullpath(file1,argv[1],MAX_PATH);
+ _fullpath(file2,argv[2],MAX_PATH);
- return diff_files_in_jedit(config.java,
- config.java_opts,
- config.jedit_jar,
- config.jedit_opts,
- config.working_dir,
- file1,
- file2);
+ return diff_files_in_jedit(config.java,
+ config.java_opts,
+ config.jedit_jar,
+ config.jedit_opts,
+ config.working_dir,
+ file1,
+ file2);
}
-
-// :deepIndent=true:folding=indent:tabSize=4:
Modified: jEditLauncher/trunk/src/jecfg.cpp
===================================================================
--- jEditLauncher/trunk/src/jecfg.cpp 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/jecfg.cpp 2008-02-26 12:13:21 UTC (rev 12020)
@@ -6,29 +6,29 @@
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR \
lpstrCmdLine, int nCmdShow) {
- HRESULT hRes = ::CoInitialize(NULL);
-// If you are running on NT 4.0 or higher you can use the following call instead to
+ HRESULT hRes = ::CoInitialize(NULL);
+// If you are running on NT 4.0 or higher you can use the following call instead to
// make the EXE free threaded. This means that calls come in on a random RPC thread.
-// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
- ATLASSERT(SUCCEEDED(hRes));
+// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
+ ATLASSERT(SUCCEEDED(hRes));
- // this resolves ATL window thunking problem when Microsoft Layer for Unicode \
(MSLU) is used
- ::DefWindowProc(NULL, 0, 0, 0L);
+ // this resolves ATL window thunking problem when Microsoft Layer for Unicode \
(MSLU) is used + ::DefWindowProc(NULL, 0, 0, 0L);
- AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
+ AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
- hRes = _Module.Init(NULL, hInstance);
- ATLASSERT(SUCCEEDED(hRes));
+ hRes = _Module.Init(NULL, hInstance);
+ ATLASSERT(SUCCEEDED(hRes));
- int nRet = 0;
- // BLOCK: Run application
- {
- CMainDlg dlgMain;
- nRet = dlgMain.DoModal();
- }
+ int nRet = 0;
+ // BLOCK: Run application
+ {
+ CMainDlg dlgMain;
+ nRet = dlgMain.DoModal();
+ }
- _Module.Term();
- ::CoUninitialize();
+ _Module.Term();
+ ::CoUninitialize();
- return nRet;
+ return nRet;
}
Modified: jEditLauncher/trunk/src/jedit.cpp
===================================================================
--- jEditLauncher/trunk/src/jedit.cpp 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/jedit.cpp 2008-02-26 12:13:21 UTC (rev 12020)
@@ -8,7 +8,6 @@
* $Id: jedit.cpp 71 2005-01-10 20:26:43Z orutherfurd $
*/
-
#include "jeditlib.h"
// jedit.exe can be build as either a "windows app"
@@ -18,7 +17,7 @@
#define J_LOG_SOURCE "jedit.exe"
-const char* USAGE =
+const char* USAGE =
"Usage: jedit.exe [<options>] [<files>]\n"
" -newplainview: Client instance opens a new plain view\n"
" -newview: Client instance opens a new view (default)\n"
@@ -30,84 +29,80 @@
" instance. Does nothing if passed to the initial jEdit instance.\n";
#ifdef BUILD_WIN32_APP
-int
+int
WINAPI WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
#else
int
main(int argc,
- char** argv)
+ char** argv)
#endif
{
- #ifdef BUILD_WIN32_APP
- // avoid having to parse lpCmdLine if
- // compiling as windows app
- int argc = __argc;
- char** argv = __argv;
- #endif
- char** files = 0;
- int nfiles = 0;
+ #ifdef BUILD_WIN32_APP
+ // avoid having to parse lpCmdLine if
+ // compiling as windows app
+ int argc = __argc;
+ char** argv = __argv;
+ #endif
+ char** files = 0;
+ int nfiles = 0;
- // log arguments
- for(int i=1; i < argc; i++)
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "argv[%d]: %s\n", i, argv[i]);
+ // log arguments
+ for(int i=1; i < argc; i++)
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "argv[%d]: %s\n", i, argv[i]);
- if(argc > 1 && (strcmp(argv[1], "/h") == 0 ||
- strcmp(argv[1], "-h") == 0 ||
- strcmp(argv[1], "/?") == 0 ||
- strcmp(argv[1], "--help") == 0))
- {
+ if(argc > 1 && (strcmp(argv[1], "/h") == 0 ||
+ strcmp(argv[1], "-h") == 0 ||
+ strcmp(argv[1], "/?") == 0 ||
+ strcmp(argv[1], "--help") == 0))
+ {
#ifdef BUILD_WIN32_APP
- MessageBox(NULL, USAGE, "jEdit Usage", MB_OK);
+ MessageBox(NULL, USAGE, "jEdit Usage", MB_OK);
#else
- printf(USAGE);
+ printf(USAGE);
#endif
- return 0;
- }
+ return 0;
+ }
- // get Java and jEdit settings
- LaunchConfig config;
- OptList* opts = parse_args(argc,(const char**)argv);
+ // get Java and jEdit settings
+ LaunchConfig config;
+ OptList* opts = parse_args(argc,(const char**)argv);
- // expand any globs given, if any filenames given
- if(argc > 1) {
- // find out how many files match
- nfiles = -1 * expand_globs((const char**)&argv[opts->len+1],
- argc-(opts->len+1),
- files,
- nfiles);
- if(nfiles) {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "nfiles: %d\n", nfiles);
- int sz = (nfiles) * sizeof(char*);
- files = (char**)malloc(sz);
- if(!files) {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "out of memory\n");
- // display a MsgBox if winapp?
- printf("ERROR: out of memory\n");
- return 1;
- }
- expand_globs((const char**)&argv[opts->len+1], argc-(opts->len+1), files, \
nfiles);
- }
- }
+ // expand any globs given, if any filenames given
+ if(argc > 1) {
+ // find out how many files match
+ nfiles = -1 * expand_globs((const char**)&argv[opts->len+1],
+ argc-(opts->len+1),
+ files,
+ nfiles);
+ if(nfiles) {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "nfiles: %d\n", nfiles);
+ int sz = (nfiles) * sizeof(char*);
+ files = (char**)malloc(sz);
+ if(!files) {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "out of memory\n");
+ // display a MsgBox if winapp?
+ printf("ERROR: out of memory\n");
+ return 1;
+ }
+ expand_globs((const char**)&argv[opts->len+1], argc-(opts->len+1), \
files, nfiles); + }
+ }
- // get java path, jedit path, etc...
- if(get_launch_config(&config)) {
- printf(FAILED_TO_GET_SETTINGS);
- return 1;
- }
+ // get java path, jedit path, etc...
+ if(get_launch_config(&config)) {
+ printf(FAILED_TO_GET_SETTINGS);
+ return 1;
+ }
- return open_files_in_jedit(config.java,
- config.java_opts,
- config.jedit_jar,
- config.jedit_opts,
- config.working_dir,
- opts,
- (const char**)files,
- nfiles);
-
+ return open_files_in_jedit(config.java,
+ config.java_opts,
+ config.jedit_jar,
+ config.jedit_opts,
+ config.working_dir,
+ opts,
+ (const char**)files,
+ nfiles);
}
-
-
-// :deepIndent=true:folding=indent:tabSize=4:
Modified: jEditLauncher/trunk/src/jeditext.cpp
===================================================================
--- jEditLauncher/trunk/src/jeditext.cpp 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/jeditext.cpp 2008-02-26 12:13:21 UTC (rev 12020)
@@ -8,52 +8,52 @@
*
* $Id: jeditext.cpp 70 2005-01-10 20:25:50Z orutherfurd $
*/
-#include "jeditext.h"
+ #include "jeditext.h"
+
// Always get an error while putting the following stuff to the
// jeditext.h file as class protected variables, give up and
// declare them as global stuff
FORMATETC fmte = {CF_HDROP,
- (DVTARGETDEVICE FAR *)NULL,
- DVASPECT_CONTENT,
- -1,
- TYMED_HGLOBAL
- };
+ (DVTARGETDEVICE FAR *)NULL,
+ DVASPECT_CONTENT,
+ -1,
+ TYMED_HGLOBAL
+ };
STGMEDIUM medium;
HRESULT hres = 0;
UINT cbFiles = 0;
+UINT g_cRefThisDll = 0; // Reference count of this DLL
+HINSTANCE g_hmodThisDll = NULL; // Handle to this DLL itself
-UINT g_cRefThisDll = 0; // Reference count of this DLL
-HINSTANCE g_hmodThisDll = NULL; // Handle to this DLL itself
-
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance,
- DWORD dwReason,
- LPVOID lpReserved)
+ DWORD dwReason,
+ LPVOID lpReserved)
{
- switch(dwReason)
- {
- case DLL_PROCESS_ATTACH:
- // Extension DLL one-time initialization
- g_hmodThisDll = hInstance;
- break;
- case DLL_PROCESS_DETACH:
- break;
- }
- return 1; // return TRUE on success
+ switch(dwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ // Extension DLL one-time initialization
+ g_hmodThisDll = hInstance;
+ break;
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return 1; // return TRUE on success
}
static void
inc_cRefThisDLL()
{
- InterlockedIncrement((LPLONG)&g_cRefThisDll);
+ InterlockedIncrement((LPLONG)&g_cRefThisDll);
}
static void
dec_cRefThisDLL()
{
- InterlockedDecrement((LPLONG)&g_cRefThisDll);
+ InterlockedDecrement((LPLONG)&g_cRefThisDll);
}
@@ -61,360 +61,360 @@
// DllCanUnloadNow
//---------------------------------------------------------------------------
-STDAPI
+STDAPI
DllCanUnloadNow(void)
{
- return (g_cRefThisDll == 0 ? S_OK : S_FALSE);
+ return (g_cRefThisDll == 0 ? S_OK : S_FALSE);
}
-STDAPI
+STDAPI
DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
{
- *ppvOut = NULL;
+ *ppvOut = NULL;
- if (IsEqualIID(rclsid, CLSID_ShellExtension))
- {
- CShellExtClassFactory *pcf = new CShellExtClassFactory;
- return pcf->QueryInterface(riid, ppvOut);
- }
+ if (IsEqualIID(rclsid, CLSID_ShellExtension))
+ {
+ CShellExtClassFactory *pcf = new CShellExtClassFactory;
+ return pcf->QueryInterface(riid, ppvOut);
+ }
- return CLASS_E_CLASSNOTAVAILABLE;
+ return CLASS_E_CLASSNOTAVAILABLE;
}
//---------------------------------------------------------------------------
// Register/Unregister Server
//---------------------------------------------------------------------------
-STDAPI
+STDAPI
DllRegisterServer(void)
{
- DWORD dwDisp;
- HKEY hKey;
- LONG result = 0;
- OSVERSIONINFO osvi;
- char path[MAX_PATH] = {'\0'};
- char value[MAX_PATH] = {'\0'};
+ DWORD dwDisp;
+ HKEY hKey;
+ LONG result = 0;
+ OSVERSIONINFO osvi;
+ char path[MAX_PATH] = {'\0'};
+ char value[MAX_PATH] = {'\0'};
- if(!GetModuleFileName(g_hmodThisDll, path, MAX_PATH))
- return E_FAIL;
+ if(!GetModuleFileName(g_hmodThisDll, path, MAX_PATH))
+ return E_FAIL;
- // [HKEY_CLASSES_ROOT\CLSID\{F1763C8F-4F26-4a15-943F-2CA281BD3385}]
- // @="jEdit Shell Extension"
- result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
- "CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKey,
- &dwDisp);
- if(result == ERROR_SUCCESS)
- {
- // @="jEdit Shell Extension"
- strcpy(value,"jEdit Shell Extension");
- RegSetValueEx(hKey,
- NULL,
- 0,
- REG_SZ,
- (LPBYTE)value,
- strlen(value) + 1);
- RegCloseKey(hKey);
- }
- else
- return E_FAIL;
+ // [HKEY_CLASSES_ROOT\CLSID\{F1763C8F-4F26-4a15-943F-2CA281BD3385}]
+ // @="jEdit Shell Extension"
+ result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
+ "CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ NULL,
+ &hKey,
+ &dwDisp);
+ if(result == ERROR_SUCCESS)
+ {
+ // @="jEdit Shell Extension"
+ strcpy(value,"jEdit Shell Extension");
+ RegSetValueEx(hKey,
+ NULL,
+ 0,
+ REG_SZ,
+ (LPBYTE)value,
+ strlen(value) + 1);
+ RegCloseKey(hKey);
+ }
+ else
+ return E_FAIL;
- // [HKEY_CLASSES_ROOT\CLSID\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\InProcServer32]
- // @="C:\\Sandbox\\jedit.exe\\jeditext.dll"
- // "ThreadingModel"="Apartment"
- result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
- "CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\\InProcServer32",
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKey,
- &dwDisp);
- if(result == ERROR_SUCCESS)
- {
- // @="C:\\Sandbox\\jedit.exe\\jeditext.dll"
- strcpy(value,path);
- RegSetValueEx(hKey,
- NULL,
- 0,
- REG_SZ,
- (LPBYTE)value,
- strlen(value) + 1);
- // "ThreadingModel"="Apartment"
- strcpy(value,"Apartment");
- RegSetValueEx(hKey,
- "ThreadingModel",
- 0,
- REG_SZ,
- (LPBYTE)value,
- strlen(value) + 1);
- RegCloseKey(hKey);
- }
- else
- return E_FAIL;
+ // [HKEY_CLASSES_ROOT\CLSID\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\InProcServer32]
+ // @="C:\\Sandbox\\jedit.exe\\jeditext.dll"
+ // "ThreadingModel"="Apartment"
+ result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
+ \
"CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\\InProcServer32", + \
0, + NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ NULL,
+ &hKey,
+ &dwDisp);
+ if(result == ERROR_SUCCESS)
+ {
+ // @="C:\\Sandbox\\jedit.exe\\jeditext.dll"
+ strcpy(value,path);
+ RegSetValueEx(hKey,
+ NULL,
+ 0,
+ REG_SZ,
+ (LPBYTE)value,
+ strlen(value) + 1);
+ // "ThreadingModel"="Apartment"
+ strcpy(value,"Apartment");
+ RegSetValueEx(hKey,
+ "ThreadingModel",
+ 0,
+ REG_SZ,
+ (LPBYTE)value,
+ strlen(value) + 1);
+ RegCloseKey(hKey);
+ }
+ else
+ return E_FAIL;
- // [HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\jedit]
- // @="{F1763C8F-4F26-4a15-943F-2CA281BD3385}"
- result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
- "*\\shellex\\ContextMenuHandlers\\jedit",
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKey,
- &dwDisp);
- if(result == ERROR_SUCCESS)
- {
- // @="{F1763C8F-4F26-4a15-943F-2CA281BD3385}"
- strcpy(value,"{F1763C8F-4F26-4a15-943F-2CA281BD3385}");
- RegSetValueEx(hKey,
- NULL,
- 0,
- REG_SZ,
- (LPBYTE)value,
- strlen(value) + 1);
- RegCloseKey(hKey);
- }
- else
- return E_FAIL;
+ // [HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\jedit]
+ // @="{F1763C8F-4F26-4a15-943F-2CA281BD3385}"
+ result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
+ "*\\shellex\\ContextMenuHandlers\\jedit",
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ NULL,
+ &hKey,
+ &dwDisp);
+ if(result == ERROR_SUCCESS)
+ {
+ // @="{F1763C8F-4F26-4a15-943F-2CA281BD3385}"
+ strcpy(value,"{F1763C8F-4F26-4a15-943F-2CA281BD3385}");
+ RegSetValueEx(hKey,
+ NULL,
+ 0,
+ REG_SZ,
+ (LPBYTE)value,
+ strlen(value) + 1);
+ RegCloseKey(hKey);
+ }
+ else
+ return E_FAIL;
- // [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell \
Extensions\Approved]
- // "{F1763C8F-4F26-4a15-943F-2CA281BD3385}"="jEdit Shell Extension"
- // (only on NT)
- osvi.dwOSVersionInfoSize = sizeof(osvi);
- GetVersionEx(&osvi);
- if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
- {
- result = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
- "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKey,
- &dwDisp);
- if(result == ERROR_SUCCESS)
- {
- // "{F1763C8F-4F26-4a15-943F-2CA281BD3385}"="jEdit Shell Extension"
- strcpy(value,"jEdit Shell Extension");
- RegSetValueEx(hKey,
- "{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
- 0,
- REG_SZ,
- (LPBYTE)value,
- strlen(value) + 1);
- RegCloseKey(hKey);
- }
- }
- else
- return E_FAIL;
+ // [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell \
Extensions\Approved] + // "{F1763C8F-4F26-4a15-943F-2CA281BD3385}"="jEdit Shell \
Extension" + // (only on NT)
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+ if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
+ {
+ result = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
+ "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell \
Extensions\\Approved", + 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_WRITE,
+ NULL,
+ &hKey,
+ &dwDisp);
+ if(result == ERROR_SUCCESS)
+ {
+ // "{F1763C8F-4F26-4a15-943F-2CA281BD3385}"="jEdit Shell Extension"
+ strcpy(value,"jEdit Shell Extension");
+ RegSetValueEx(hKey,
+ "{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
+ 0,
+ REG_SZ,
+ (LPBYTE)value,
+ strlen(value) + 1);
+ RegCloseKey(hKey);
+ }
+ }
+ else
+ return E_FAIL;
- return NOERROR;
+ return NOERROR;
}
-STDAPI
+STDAPI
DllUnregisterServer(void)
{
- char msg[1024] = {'\0'};
- char error[255] = {'\0'};
- const HKEY roots[] = {
- HKEY_CLASSES_ROOT,
- HKEY_LOCAL_MACHINE,
- HKEY_CLASSES_ROOT,
- HKEY_CLASSES_ROOT,
- };
- const char* keys[] = {
- "*\\shellex\\ContextMenuHandlers\\jedit",
- "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
- "CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\\InProcServer32",
- "CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
- };
- LONG results[] = {0,0,0,0};
+ char msg[1024] = {'\0'};
+ char error[255] = {'\0'};
+ const HKEY roots[] = {
+ HKEY_CLASSES_ROOT,
+ HKEY_LOCAL_MACHINE,
+ HKEY_CLASSES_ROOT,
+ HKEY_CLASSES_ROOT,
+ };
+ const char* keys[] = {
+ "*\\shellex\\ContextMenuHandlers\\jedit",
+ "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
+ "CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\\InProcServer32",
+ "CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
+ };
+ LONG results[] = {0,0,0,0};
- for(int i=0; i < 4; i++)
- {
- results[i] = RegDeleteKey(roots[i], keys[i]);
- if(results[i] != ERROR_SUCCESS && results[i] != ERROR_FILE_NOT_FOUND)
- {
- error[0] = 0;
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- results[i],
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
- error,
- 255,
- NULL);
- sprintf(msg, "Error removing: %s\n%s", keys[i], error);
- MessageBox(NULL, msg, "Problem Deleting Registry Key", MB_OK);
- }
- }
+ for(int i=0; i < 4; i++)
+ {
+ results[i] = RegDeleteKey(roots[i], keys[i]);
+ if(results[i] != ERROR_SUCCESS && results[i] != ERROR_FILE_NOT_FOUND)
+ {
+ error[0] = 0;
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ results[i],
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default \
language + error,
+ 255,
+ NULL);
+ sprintf(msg, "Error removing: %s\n%s", keys[i], error);
+ MessageBox(NULL, msg, "Problem Deleting Registry Key", MB_OK);
+ }
+ }
- for(i=0; i < 4; i++)
- if(results[i] != ERROR_SUCCESS && results[i] != ERROR_FILE_NOT_FOUND)
- return E_FAIL;
- return NOERROR;
+ for(i=0; i < 4; i++)
+ if(results[i] != ERROR_SUCCESS && results[i] != ERROR_FILE_NOT_FOUND)
+ return E_FAIL;
+ return NOERROR;
}
CShellExtClassFactory::CShellExtClassFactory()
{
- m_cRef = 0L;
+ m_cRef = 0L;
- inc_cRefThisDLL();
+ inc_cRefThisDLL();
}
CShellExtClassFactory::~CShellExtClassFactory()
{
- dec_cRefThisDLL();
+ dec_cRefThisDLL();
}
-STDMETHODIMP
+STDMETHODIMP
CShellExtClassFactory::QueryInterface(REFIID riid,
- LPVOID FAR *ppv)
+ LPVOID FAR *ppv)
{
- *ppv = NULL;
+ *ppv = NULL;
- // Any interface on this object is the object pointer
+ // Any interface on this object is the object pointer
- if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
- {
- *ppv = (LPCLASSFACTORY)this;
+ if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
+ {
+ *ppv = (LPCLASSFACTORY)this;
- AddRef();
+ AddRef();
- return NOERROR;
- }
+ return NOERROR;
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
-STDMETHODIMP_(ULONG)
+STDMETHODIMP_(ULONG)
CShellExtClassFactory::AddRef()
{
- return InterlockedIncrement((LPLONG)&m_cRef);
+ return InterlockedIncrement((LPLONG)&m_cRef);
}
-STDMETHODIMP_(ULONG)
+STDMETHODIMP_(ULONG)
CShellExtClassFactory::Release()
{
- if (InterlockedDecrement((LPLONG)&m_cRef))
- return m_cRef;
+ if (InterlockedDecrement((LPLONG)&m_cRef))
+ return m_cRef;
- delete this;
+ delete this;
- return 0L;
+ return 0L;
}
-STDMETHODIMP
+STDMETHODIMP
CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
- REFIID riid,
- LPVOID *ppvObj)
+ REFIID riid,
+ LPVOID *ppvObj)
{
- *ppvObj = NULL;
+ *ppvObj = NULL;
- // Shell extensions typically don't support aggregation (inheritance)
+ // Shell extensions typically don't support aggregation (inheritance)
- if (pUnkOuter)
- return CLASS_E_NOAGGREGATION;
+ if (pUnkOuter)
+ return CLASS_E_NOAGGREGATION;
- // Create the main shell extension object. The shell will then call
- // QueryInterface with IID_IShellExtInit--this is how shell extensions are
- // initialized.
+ // Create the main shell extension object. The shell will then call
+ // QueryInterface with IID_IShellExtInit--this is how shell extensions are
+ // initialized.
- LPCSHELLEXT pShellExt = new CShellExt(); //Create the CShellExt object
+ LPCSHELLEXT pShellExt = new CShellExt(); //Create the CShellExt object
- if (NULL == pShellExt)
- return E_OUTOFMEMORY;
+ if (NULL == pShellExt)
+ return E_OUTOFMEMORY;
- return pShellExt->QueryInterface(riid, ppvObj);
+ return pShellExt->QueryInterface(riid, ppvObj);
}
-STDMETHODIMP
+STDMETHODIMP
CShellExtClassFactory::LockServer(BOOL fLock)
{
- return NOERROR;
+ return NOERROR;
}
CShellExt::CShellExt()
{
- /*
- hImage = LoadImage(g_hmodThisDll,
- MAKEINTRESOURCE(101),
- IMAGE_BITMAP,
- 0,
- 0,
- LR_LOADTRANSPARENT);
- */
- m_cRef = 0L;
- m_pDataObj = NULL;
+ /*
+ hImage = LoadImage(g_hmodThisDll,
+ MAKEINTRESOURCE(101),
+ IMAGE_BITMAP,
+ 0,
+ 0,
+ LR_LOADTRANSPARENT);
+ */
+ m_cRef = 0L;
+ m_pDataObj = NULL;
- inc_cRefThisDLL();
+ inc_cRefThisDLL();
}
CShellExt::~CShellExt()
{
- if (m_pDataObj)
- m_pDataObj->Release();
+ if (m_pDataObj)
+ m_pDataObj->Release();
- /*
- if(hImage)
- DeleteObject(hImage);
- */
- dec_cRefThisDLL();
+ /*
+ if(hImage)
+ DeleteObject(hImage);
+ */
+ dec_cRefThisDLL();
}
-STDMETHODIMP
+STDMETHODIMP
CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv)
{
- *ppv = NULL;
+ *ppv = NULL;
- if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown))
- {
- *ppv = (LPSHELLEXTINIT)this;
- }
- else if (IsEqualIID(riid, IID_IContextMenu))
- {
- *ppv = (LPCONTEXTMENU)this;
- }
+ if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown))
+ {
+ *ppv = (LPSHELLEXTINIT)this;
+ }
+ else if (IsEqualIID(riid, IID_IContextMenu))
+ {
+ *ppv = (LPCONTEXTMENU)this;
+ }
- if (*ppv)
- {
- AddRef();
- return NOERROR;
- }
+ if (*ppv)
+ {
+ AddRef();
+ return NOERROR;
+ }
- return E_NOINTERFACE;
+ return E_NOINTERFACE;
}
-STDMETHODIMP_(ULONG)
+STDMETHODIMP_(ULONG)
CShellExt::AddRef()
{
- return InterlockedIncrement((LPLONG)&m_cRef);
+ return InterlockedIncrement((LPLONG)&m_cRef);
}
-STDMETHODIMP_(ULONG)
+STDMETHODIMP_(ULONG)
CShellExt::Release()
{
- if (InterlockedDecrement((LPLONG)&m_cRef))
- return m_cRef;
+ if (InterlockedDecrement((LPLONG)&m_cRef))
+ return m_cRef;
- delete this;
+ delete this;
- return 0L;
+ return 0L;
}
@@ -422,7 +422,7 @@
// FUNCTION: CShellExt::Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY)
//
// PURPOSE: Called by the shell when initializing a context menu or property
-// sheet extension.
+// sheet extension.
//
// PARAMETERS:
// pIDFolder - Specifies the parent folder
@@ -434,28 +434,28 @@
// NOERROR in all cases.
//
// COMMENTS: Note that at the time this function is called, we don't know
-// (or care) what type of shell extension is being initialized.
-// It could be a context menu or a property sheet.
+// (or care) what type of shell extension is being initialized.
+// It could be a context menu or a property sheet.
//
-STDMETHODIMP
+STDMETHODIMP
CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
- LPDATAOBJECT pDataObj,
- HKEY hRegKey)
+ LPDATAOBJECT pDataObj,
+ HKEY hRegKey)
{
- // Initialize can be called more than once
- if (m_pDataObj)
- m_pDataObj->Release();
+ // Initialize can be called more than once
+ if (m_pDataObj)
+ m_pDataObj->Release();
- // duplicate the object pointer and registry handle
+ // duplicate the object pointer and registry handle
- if (pDataObj)
- {
- m_pDataObj = pDataObj;
- pDataObj->AddRef();
- }
+ if (pDataObj)
+ {
+ m_pDataObj = pDataObj;
+ pDataObj->AddRef();
+ }
- return NOERROR;
+ return NOERROR;
}
@@ -464,7 +464,7 @@
// FUNCTION: CShellExt::QueryContextMenu(HMENU, UINT, UINT, UINT, UINT)
//
// PURPOSE: Called by the shell just before the context menu is displayed.
-// This is where you add your specific menu items.
+// This is where you add your specific menu items.
//
// PARAMETERS:
// hMenu - Handle to the context menu
@@ -474,97 +474,97 @@
// uFlags - Specifies the context of the menu event
//
-STDMETHODIMP
+STDMETHODIMP
CShellExt::QueryContextMenu(HMENU hMenu,
- UINT indexMenu,
- UINT idCmdFirst,
- UINT idCmdLast,
- UINT uFlags)
+ UINT indexMenu,
+ UINT idCmdFirst,
+ UINT idCmdLast,
+ UINT uFlags)
{
- UINT idCmd = idCmdFirst;
- char label[MAX_PATH] = {'\0'};
- char ext[MAX_PATH] = {'\0'};
- char path[MAX_PATH] = {'\0'};
- char filename[MAX_PATH] = {'\0'};
- char drive[MAX_PATH] = {'\0'};
- char directory[MAX_PATH] = {'\0'};
-
+ UINT idCmd = idCmdFirst;
+ char label[MAX_PATH] = {'\0'};
+ char ext[MAX_PATH] = {'\0'};
+ char path[MAX_PATH] = {'\0'};
+ char filename[MAX_PATH] = {'\0'};
+ char drive[MAX_PATH] = {'\0'};
+ char directory[MAX_PATH] = {'\0'};
- hres = m_pDataObj->GetData(&fmte, &medium);
- // get number of files selected
- if (medium.hGlobal)
- cbFiles = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, 0, 0);
- InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
+ hres = m_pDataObj->GetData(&fmte, &medium);
+ // get number of files selected
+ if (medium.hGlobal)
+ cbFiles = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, 0, 0);
- InsertMenu(hMenu,
- indexMenu++,
- MF_STRING|MF_BYPOSITION,
- idCmd++,
- "Open with &jEdit");
- /*
- SetMenuItemBitmaps(hMenu,
- indexMenu-1,
- MF_BYPOSITION,
- (HBITMAP)hImage,
- (HBITMAP)hImage);
- */
- if(cbFiles == 2)
- {
- // Can edit up to 4 files in diff mode
- InsertMenu(hMenu,
- indexMenu++,
- MF_STRING|MF_BYPOSITION,
- idCmd++,
- "&Diff with jEdit");
- }
- else if(cbFiles == 1)
- {
- DragQueryFile((HDROP)medium.hGlobal,
- 0,
- path,
- MAX_PATH);
- _splitpath(path,drive,directory,filename,ext);
- if(ext && strlen(ext))
- {
- sprintf(label, "Open &*%s with jEdit", ext);
- InsertMenu(hMenu,
- indexMenu++,
- MF_STRING|MF_BYPOSITION,
- idCmd++,
- label);
- }
- }
+ InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
- InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
+ InsertMenu(hMenu,
+ indexMenu++,
+ MF_STRING|MF_BYPOSITION,
+ idCmd++,
+ "Open with &jEdit");
+ /*
+ SetMenuItemBitmaps(hMenu,
+ indexMenu-1,
+ MF_BYPOSITION,
+ (HBITMAP)hImage,
+ (HBITMAP)hImage);
+ */
+ if(cbFiles == 2)
+ {
+ // Can edit up to 4 files in diff mode
+ InsertMenu(hMenu,
+ indexMenu++,
+ MF_STRING|MF_BYPOSITION,
+ idCmd++,
+ "&Diff with jEdit");
+ }
+ else if(cbFiles == 1)
+ {
+ DragQueryFile((HDROP)medium.hGlobal,
+ 0,
+ path,
+ MAX_PATH);
+ _splitpath(path,drive,directory,filename,ext);
+ if(ext && strlen(ext))
+ {
+ sprintf(label, "Open &*%s with jEdit", ext);
+ InsertMenu(hMenu,
+ indexMenu++,
+ MF_STRING|MF_BYPOSITION,
+ idCmd++,
+ label);
+ }
+ }
- // Must return number of menu items we added.
- return ResultFromShort(idCmd-idCmdFirst);
+ InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
+
+ // Must return number of menu items we added.
+ return ResultFromShort(idCmd-idCmdFirst);
}
-STDMETHODIMP
+STDMETHODIMP
CShellExt::GetCommandString(UINT idCmd,
- UINT uFlags,
- UINT FAR *reserved,
- LPSTR pszName,
- UINT cchMax)
+ UINT uFlags,
+ UINT FAR *reserved,
+ LPSTR pszName,
+ UINT cchMax)
{
- if (uFlags == GCS_HELPTEXT && cchMax > 35)
- {
- if(idCmd == 0)
- lstrcpy(pszName, "Open the selected file(s) with jEdit");
- else if(cbFiles == 2)
- {
- lstrcpy(pszName, "Diff the selected files with jEdit");
- }
- else
- {
- lstrcpy(pszName, "Open matching files with jEdit");
- }
- }
+ if (uFlags == GCS_HELPTEXT && cchMax > 35)
+ {
+ if(idCmd == 0)
+ lstrcpy(pszName, "Open the selected file(s) with jEdit");
+ else if(cbFiles == 2)
+ {
+ lstrcpy(pszName, "Diff the selected files with jEdit");
+ }
+ else
+ {
+ lstrcpy(pszName, "Open matching files with jEdit");
+ }
+ }
- return NOERROR;
+ return NOERROR;
}
@@ -572,233 +572,229 @@
// FUNCTION: CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO)
//
// PURPOSE: Called by the shell after the user has selected on of the
-// menu items that was added in QueryContextMenu().
+// menu items that was added in QueryContextMenu().
//
// PARAMETERS:
// lpcmi - Pointer to an CMINVOKECOMMANDINFO structure
//
-STDMETHODIMP
+STDMETHODIMP
CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{
- HRESULT hr = E_INVALIDARG;
+ HRESULT hr = E_INVALIDARG;
- // If HIWORD(lpcmi->lpVerb) then we have been called programmatically
- // and lpVerb is a command that should be invoked. Otherwise, the shell
- // has called us, and LOWORD(lpcmi->lpVerb) is the menu ID the user has
- // selected. Actually, it's (menu ID - idCmdFirst) from QueryContextMenu().
- if (!HIWORD(lpcmi->lpVerb))
- {
- UINT idCmd = LOWORD(lpcmi->lpVerb);
-
- switch (idCmd)
- {
- case 0:
- hr = OpenInJEdit(lpcmi->hwnd,
- lpcmi->lpDirectory,
- lpcmi->lpVerb,
- lpcmi->lpParameters,
- lpcmi->nShow);
- break;
- case 1:
- if(cbFiles == 2)
- {
- hr = DiffWithJEdit(lpcmi->hwnd,
- lpcmi->lpDirectory,
- lpcmi->lpVerb,
- lpcmi->lpParameters,
- lpcmi->nShow);
- }
- else
- {
- hr = OpenByExtInJEdit(lpcmi->hwnd,
- lpcmi->lpDirectory,
- lpcmi->lpVerb,
- lpcmi->lpParameters,
- lpcmi->nShow);
- }
- break;
- }
- }
- return hr;
+ // If HIWORD(lpcmi->lpVerb) then we have been called programmatically
+ // and lpVerb is a command that should be invoked. Otherwise, the shell
+ // has called us, and LOWORD(lpcmi->lpVerb) is the menu ID the user has
+ // selected. Actually, it's (menu ID - idCmdFirst) from QueryContextMenu().
+ if (!HIWORD(lpcmi->lpVerb))
+ {
+ UINT idCmd = LOWORD(lpcmi->lpVerb);
+
+ switch (idCmd)
+ {
+ case 0:
+ hr = OpenInJEdit(lpcmi->hwnd,
+ lpcmi->lpDirectory,
+ lpcmi->lpVerb,
+ lpcmi->lpParameters,
+ lpcmi->nShow);
+ break;
+ case 1:
+ if(cbFiles == 2)
+ {
+ hr = DiffWithJEdit(lpcmi->hwnd,
+ lpcmi->lpDirectory,
+ lpcmi->lpVerb,
+ lpcmi->lpParameters,
+ lpcmi->nShow);
+ }
+ else
+ {
+ hr = OpenByExtInJEdit(lpcmi->hwnd,
+ lpcmi->lpDirectory,
+ lpcmi->lpVerb,
+ lpcmi->lpParameters,
+ lpcmi->nShow);
+ }
+ break;
+ }
+ }
+ return hr;
}
-STDMETHODIMP
+STDMETHODIMP
CShellExt::DiffWithJEdit(HWND hParent,
- LPCSTR pszWorkingDir,
- LPCSTR pszCmd,
- LPCSTR pszParam,
- int iShowCmd)
+ LPCSTR pszWorkingDir,
+ LPCSTR pszCmd,
+ LPCSTR pszParam,
+ int iShowCmd)
{
- LaunchConfig config;
- char file1[MAX_PATH] = {'\0'};
- char file2[MAX_PATH] = {'\0'};
+ LaunchConfig config;
+ char file1[MAX_PATH] = {'\0'};
+ char file2[MAX_PATH] = {'\0'};
- if(cbFiles != 2)
- return E_FAIL; // expecting 2 args
+ if(cbFiles != 2)
+ return E_FAIL; // expecting 2 args
- DragQueryFile((HDROP)medium.hGlobal,
- 0,
- file1,
- MAX_PATH);
- DragQueryFile((HDROP)medium.hGlobal,
- 1,
- file2,
- MAX_PATH);
+ DragQueryFile((HDROP)medium.hGlobal,
+ 0,
+ file1,
+ MAX_PATH);
+ DragQueryFile((HDROP)medium.hGlobal,
+ 1,
+ file2,
+ MAX_PATH);
- if(get_launch_config(&config))
- {
- MessageBox(hParent,
- "Failed to get jEdit & Java configuration from registry.\n"
- "\n"
- "See 'jeditlauncher.log' in your HOME directory for details.",
- "Can't open jEdit",
- MB_OK);
- return E_FAIL;
- }
+ if(get_launch_config(&config))
+ {
+ MessageBox(hParent,
+ "Failed to get jEdit & Java configuration from registry.\n"
+ "\n"
+ "See 'jeditlauncher.log' in your HOME directory for details.",
+ "Can't open jEdit",
+ MB_OK);
+ return E_FAIL;
+ }
- if(!diff_files_in_jedit(config.java,
- config.java_opts,
- config.jedit_jar,
- config.jedit_opts,
- config.working_dir,
- file1,
- file2))
- return NOERROR;
- return E_FAIL;
+ if(!diff_files_in_jedit(config.java,
+ config.java_opts,
+ config.jedit_jar,
+ config.jedit_opts,
+ config.working_dir,
+ file1,
+ file2))
+ return NOERROR;
+ return E_FAIL;
}
-STDMETHODIMP
+STDMETHODIMP
CShellExt::OpenByExtInJEdit(HWND hParent,
- LPCSTR pszWorkingDir,
- LPCSTR pszCmd,
- LPCSTR pszParam,
- int iShowCmd)
+ LPCSTR pszWorkingDir,
+ LPCSTR pszCmd,
+ LPCSTR pszParam,
+ int iShowCmd)
{
- LaunchConfig config;
- char** files = 0;
- int nfiles = 0;
- char* globs[] = {'\0'};
- char glob[MAX_PATH] = {'\0'};
+ LaunchConfig config;
+ char** files = 0;
+ int nfiles = 0;
+ char* globs[] = {'\0'};
+ char glob[MAX_PATH] = {'\0'};
- char directory[MAX_PATH] = {'\0'};
- char drive[MAX_PATH] = {'\0'};
- char ext[MAX_PATH] = {'\0'};
- char filename[MAX_PATH] = {'\0'};
- char path[MAX_PATH] = {'\0'};
+ char directory[MAX_PATH] = {'\0'};
+ char drive[MAX_PATH] = {'\0'};
+ char ext[MAX_PATH] = {'\0'};
+ char filename[MAX_PATH] = {'\0'};
+ char path[MAX_PATH] = {'\0'};
- DragQueryFile((HDROP)medium.hGlobal,
- 0,
- path,
- MAX_PATH);
+ DragQueryFile((HDROP)medium.hGlobal,
+ 0,
+ path,
+ MAX_PATH);
- // split path into chunks, so we can find
- // all matching files in the directory
- _splitpath(path,drive,directory,filename,ext);
- // <drive>\<dir>\*<ext>
- sprintf(glob,"%s%s*%s", drive, directory, ext);
+ // split path into chunks, so we can find
+ // all matching files in the directory
+ _splitpath(path,drive,directory,filename,ext);
+ // <drive>\<dir>\*<ext>
+ sprintf(glob,"%s%s*%s", drive, directory, ext);
- // find number of files
- globs[0] = glob;
- nfiles = -1 * expand_globs((const char**)globs,
- 1,
- files,
- 0);
+ // find number of files
+ globs[0] = glob;
+ nfiles = -1 * expand_globs((const char**)globs,
+ 1,
+ files,
+ 0);
- // allocate file list
- int nalloc = (nfiles) * sizeof(char*);
+ // allocate file list
+ int nalloc = (nfiles) * sizeof(char*);
- files = (char**)malloc(nalloc);
- if(!files)
- return E_OUTOFMEMORY;
+ files = (char**)malloc(nalloc);
+ if(!files)
+ return E_OUTOFMEMORY;
- // fill the file list
- nfiles = expand_globs((const char**)&globs,
- 1,
- files,
- nfiles);
+ // fill the file list
+ nfiles = expand_globs((const char**)&globs,
+ 1,
+ files,
+ nfiles);
- if(get_launch_config(&config))
- {
- MessageBox(hParent,
- "Failed to get jEdit & Java configuration from registry.\n"
- "\n"
- "See 'jeditlauncher.log' in your HOME directory for details.",
- "Can't open jEdit",
- MB_OK);
- return E_FAIL;
- }
+ if(get_launch_config(&config))
+ {
+ MessageBox(hParent,
+ "Failed to get jEdit & Java configuration from registry.\n"
+ "\n"
+ "See 'jeditlauncher.log' in your HOME directory for details.",
+ "Can't open jEdit",
+ MB_OK);
+ return E_FAIL;
+ }
- // XXX handle error
- open_files_in_jedit(config.java,
- config.java_opts,
- config.jedit_jar,
- config.jedit_opts,
- config.working_dir,
- NULL, // no command-line options
- (const char**)files,
- nfiles);
+ // XXX handle error
+ open_files_in_jedit(config.java,
+ config.java_opts,
+ config.jedit_jar,
+ config.jedit_opts,
+ config.working_dir,
+ NULL, // no command-line options
+ (const char**)files,
+ nfiles);
- return NOERROR;
+ return NOERROR;
}
-STDMETHODIMP
+STDMETHODIMP
CShellExt::OpenInJEdit(HWND hParent,
- LPCSTR pszWorkingDir,
- LPCSTR pszCmd,
- LPCSTR pszParam,
- int iShowCmd)
+ LPCSTR pszWorkingDir,
+ LPCSTR pszCmd,
+ LPCSTR pszParam,
+ int iShowCmd)
{
- int r = 0;
- LaunchConfig config;
- char** files = 0;
+ int r = 0;
+ LaunchConfig config;
+ char** files = 0;
- files = (char**)malloc(sizeof(char*) * cbFiles);
- if(!files)
- return E_OUTOFMEMORY;
+ files = (char**)malloc(sizeof(char*) * cbFiles);
+ if(!files)
+ return E_OUTOFMEMORY;
- for(int i=0; i < cbFiles; i++)
- {
- files[i] = (char*)malloc(sizeof(char) * MAX_PATH);
- if(!files[i])
- return E_OUTOFMEMORY;
- DragQueryFile((HDROP)medium.hGlobal,
- i,
- files[i],
- MAX_PATH);
- }
+ for(int i=0; i < cbFiles; i++)
+ {
+ files[i] = (char*)malloc(sizeof(char) * MAX_PATH);
+ if(!files[i])
+ return E_OUTOFMEMORY;
+ DragQueryFile((HDROP)medium.hGlobal,
+ i,
+ files[i],
+ MAX_PATH);
+ }
- if(get_launch_config(&config))
- {
- MessageBox(hParent,
- "Failed to get jEdit & Java configuration from registry.\n"
- "\n"
- "See 'jeditlauncher.log' in your HOME directory for details.",
- "Can't open jEdit",
- MB_OK);
- return E_FAIL;
- }
+ if(get_launch_config(&config))
+ {
+ MessageBox(hParent,
+ "Failed to get jEdit & Java configuration from registry.\n"
+ "\n"
+ "See 'jeditlauncher.log' in your HOME directory for details.",
+ "Can't open jEdit",
+ MB_OK);
+ return E_FAIL;
+ }
- r = open_files_in_jedit(config.java,
- config.java_opts,
- config.jedit_jar,
- config.jedit_opts,
- config.working_dir,
- NULL, // no command-line options
- (const char**)files,
- cbFiles);
+ r = open_files_in_jedit(config.java,
+ config.java_opts,
+ config.jedit_jar,
+ config.jedit_opts,
+ config.working_dir,
+ NULL, // no command-line options
+ (const char**)files,
+ cbFiles);
- // free files and file list
- for(i=0; i < cbFiles; i++)
- free(files[i]);
- free(files);
+ // free files and file list
+ for(i=0; i < cbFiles; i++)
+ free(files[i]);
+ free(files);
- if(r)
- return E_FAIL;
- return NOERROR;
+ if(r)
+ return E_FAIL;
+ return NOERROR;
}
-
-
-// :deepIndent=true:tabSize=4:
-
Modified: jEditLauncher/trunk/src/jeditext.h
===================================================================
--- jEditLauncher/trunk/src/jeditext.h 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/jeditext.h 2008-02-26 12:13:21 UTC (rev 12020)
@@ -8,7 +8,8 @@
*
* $Id: jeditext.h 72 2005-01-10 20:36:02Z orutherfurd $
*/
-#if !defined __JEDITEXT_H__
+
+ #if !defined __JEDITEXT_H__
#define __JEDITEXT_H__
#if _MSC_VER > 1000
@@ -19,7 +20,7 @@
#define STRICT
#endif
-#define INC_OLE2 // WIN32, get ole2 from windows.h
+#define INC_OLE2 // WIN32, get ole2 from windows.h
#include <windows.h>
#include <windowsx.h>
@@ -41,86 +42,83 @@
class CShellExtClassFactory : public IClassFactory
{
protected:
- ULONG m_cRef;
+ ULONG m_cRef;
public:
- CShellExtClassFactory();
- ~CShellExtClassFactory();
+ CShellExtClassFactory();
+ ~CShellExtClassFactory();
- // IUnknown
- STDMETHODIMP QueryInterface(REFIID, LPVOID FAR*);
- STDMETHODIMP_(ULONG) AddRef();
- STDMETHODIMP_(ULONG) Release();
+ // IUnknown
+ STDMETHODIMP QueryInterface(REFIID, LPVOID FAR*);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
- // IClassFactory
- STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR*);
- STDMETHODIMP LockServer(BOOL);
+ // IClassFactory
+ STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR*);
+ STDMETHODIMP LockServer(BOOL);
};
typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
-class CShellExt : public IContextMenu,
- IShellExtInit
+class CShellExt : public IContextMenu,
+ IShellExtInit
{
protected:
- ULONG m_cRef;
- LPDATAOBJECT m_pDataObj;
- //HANDLE hImage; // bitmap for menu
- STDMETHODIMP OpenFiles(void);
- STDMETHODIMP DiffFiles(void);
+ ULONG m_cRef;
+ LPDATAOBJECT m_pDataObj;
+ //HANDLE hImage; // bitmap for menu
+ STDMETHODIMP OpenFiles(void);
+ STDMETHODIMP DiffFiles(void);
public:
- CShellExt();
- ~CShellExt();
+ CShellExt();
+ ~CShellExt();
- //IUnknown members
- STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
- STDMETHODIMP_(ULONG) AddRef();
- STDMETHODIMP_(ULONG) Release();
+ //IUnknown members
+ STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
- //IShell members
- STDMETHODIMP QueryContextMenu(HMENU hMenu,
- UINT indexMenu,
- UINT idCmdFirst,
- UINT idCmdLast,
- UINT uFlags);
+ //IShell members
+ STDMETHODIMP QueryContextMenu(HMENU hMenu,
+ UINT indexMenu,
+ UINT idCmdFirst,
+ UINT idCmdLast,
+ UINT uFlags);
- STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
+ STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
- STDMETHODIMP GetCommandString(UINT idCmd,
- UINT uFlags,
- UINT FAR *reserved,
- LPSTR pszName,
- UINT cchMax);
+ STDMETHODIMP GetCommandString(UINT idCmd,
+ UINT uFlags,
+ UINT FAR *reserved,
+ LPSTR pszName,
+ UINT cchMax);
- //IShellExtInit methods
- STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder,
- LPDATAOBJECT pDataObj,
- HKEY hKeyID);
+ //IShellExtInit methods
+ STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder,
+ LPDATAOBJECT pDataObj,
+ HKEY hKeyID);
- STDMETHODIMP DiffWithJEdit(HWND hParent,
- LPCSTR pszWorkingDir,
- LPCSTR pszCmd,
- LPCSTR pszParam,
- int iShowCmd);
+ STDMETHODIMP DiffWithJEdit(HWND hParent,
+ LPCSTR pszWorkingDir,
+ LPCSTR pszCmd,
+ LPCSTR pszParam,
+ int iShowCmd);
- STDMETHODIMP OpenByExtInJEdit(HWND hParent,
- LPCSTR pszWorkingDir,
- LPCSTR pszCmd,
- LPCSTR pszParam,
- int iShowCmd);
+ STDMETHODIMP OpenByExtInJEdit(HWND hParent,
+ LPCSTR pszWorkingDir,
+ LPCSTR pszCmd,
+ LPCSTR pszParam,
+ int iShowCmd);
- STDMETHODIMP OpenInJEdit(HWND hParent,
- LPCSTR pszWorkingDir,
- LPCSTR pszCmd,
- LPCSTR pszParam,
- int iShowCmd);
+ STDMETHODIMP OpenInJEdit(HWND hParent,
+ LPCSTR pszWorkingDir,
+ LPCSTR pszCmd,
+ LPCSTR pszParam,
+ int iShowCmd);
};
typedef CShellExt *LPCSHELLEXT;
#pragma data_seg()
-#endif // __JEDITEXT_H__
-
-// :deepIndent=true:tabSize=4:
-
+#endif // __JEDITEXT_H__
Modified: jEditLauncher/trunk/src/jeditlib.cpp
===================================================================
--- jEditLauncher/trunk/src/jeditlib.cpp 2008-02-26 09:10:40 UTC (rev 12019)
+++ jEditLauncher/trunk/src/jeditlib.cpp 2008-02-26 12:13:21 UTC (rev 12020)
@@ -26,29 +26,29 @@
int
has_opt(const OptList* opts,
- const char* name);
+ const char* name);
const char*
get_opt_value(const OptList* opts,
- const char* name);
+ const char* name);
char*
create_server_script(const int wait,
- const int restore,
- const int new_view,
- const int new_plain_view,
- const char * script_file,
- const char * working_dir,
- const char ** filenames,
- unsigned int nfiles);
+ const int restore,
+ const int new_view,
+ const int new_plain_view,
+ const char * script_file,
+ const char * working_dir,
+ const char ** filenames,
+ unsigned int nfiles);
// use same locations as jEditLauncher for easier transition
-static const char* REG_SETTINGS_PATH = \
"Software\\www.jedit.org\\jEditLauncher\\4.0";
-static const char* SETTING_JAVA = "Java Executable";
-static const char* SETTING_JAVA_OPTS = "Java Options";
-static const char* SETTING_JEDIT_OPTS = "jEdit Options";
-static const char* SETTING_JEDIT_JAR = "jEdit Target";
-static const char* SETTING_WORKING_DIR = "jEdit Working Directory";
+static const char* REG_SETTINGS_PATH = \
"Software\\www.jedit.org\\jEditLauncher\\4.0"; +static const char* SETTING_JAVA \
= "Java Executable"; +static const char* SETTING_JAVA_OPTS = "Java Options";
+static const char* SETTING_JEDIT_OPTS = "jEdit Options";
+static const char* SETTING_JEDIT_JAR = "jEdit Target";
+static const char* SETTING_WORKING_DIR = "jEdit Working Directory";
static const char* DIFF_SCRIPT = ""
"// get current view, or open a new one\n"
@@ -57,30 +57,30 @@
"if(v == null) v = jEdit.newView(v);\n"
"// check that JDiff is installed\n"
"if(jEdit.getPlugin(\"jdiff.JDiffPlugin\") == null){\n"
-" Macros.error(v, \"You must have the JDiff plugin installed to use this \
feature.\");\n"
-" return;\n"
+" Macros.error(v, \"You must have the JDiff plugin installed to use this \
feature.\");\n" +" return;\n"
"}\n"
"// disable, if enabled\n"
"if(jdiff.DualDiff.isEnabledFor(v))\n"
-" jdiff.DualDiff.toggleFor(v);\n"
+" jdiff.DualDiff.toggleFor(v);\n"
"// unsplit all edit panes, then split vertically\n"
"while(v.getEditPanes().length > 1)\n"
-" v.unsplit();\n"
+" v.unsplit();\n"
"v.splitVertically();\n"
"// enable diff\n"
"jdiff.DualDiff.toggleFor(v);\n"
"// open buffers and set 1 and 2 in the vertical splits\n"
"openDiffFiles(vw){\n"
-" v = vw;\n"
-" run(){\n"
-" b1 = jEdit.openFile(v, \"%s\");\n"
-" b2 = jEdit.openFile(v, \"%s\");\n"
-" VFSManager.waitForRequests();\n"
-" editPanes = v.getEditPanes();\n"
-" editPanes[0].setBuffer(b1); \n"
-" editPanes[1].setBuffer(b2);\n"
-" }\n"
-" return this;\n"
+" v = vw;\n"
+" run(){\n"
+" b1 = jEdit.openFile(v, \"%s\");\n"
+" b2 = jEdit.openFile(v, \"%s\");\n"
+" VFSManager.waitForRequests();\n"
+" editPanes = v.getEditPanes();\n"
+" editPanes[0].setBuffer(b1); \n"
+" editPanes[1].setBuffer(b2);\n"
+" }\n"
+" return this;\n"
"}\n"
"// open and display the files\n"
"SwingUtilities.invokeLater(openDiffFiles(v));\n";
@@ -105,1125 +105,1125 @@
* @param count number of files in "files".
*
* @return ADDFILE_OK if filename appened to files, ADDFILE_OOM if unable
- * to copy file (out of memory), and ADDFILE_OVERFLOW if files
- * isn't long enough to fit filename.
+ * to copy file (out of memory), and ADDFILE_OVERFLOW if files
+ * isn't long enough to fit filename.
*/
int
-add_file_to_list(const char* filename,
- char** files,
- const int nfiles,
- const int count);
+add_file_to_list(const char* filename,
+ char** files,
+ const int nfiles,
+ const int count);
/**
- * Private constants for private
+ * Private constants for private
* helper function "add_file_to_list".
*/
-#define ADDFILE_OK 1
-#define ADDFILE_OOM 0
-#define ADDFILE_OVERFLOW -1
+#define ADDFILE_OK 1
+#define ADDFILE_OOM 0
+#define ADDFILE_OVERFLOW -1
int
get_home(char* dest, int ndest)
{
- const char* path;
- if((path = getenv("USERPROFILE")) != 0)
- {
- if(strlen(path) > ndest)
- return strlen(path);
- strncpy(dest,path,ndest);
- return 0;
- }
+ const char* path;
+ if((path = getenv("USERPROFILE")) != 0)
+ {
+ if(strlen(path) > ndest)
+ return strlen(path);
+ strncpy(dest,path,ndest);
+ return 0;
+ }
- if(0 != getenv("HOMEDRIVE") && 0 != getenv("HOMEPATH"))
- {
- if(strlen(getenv("HOMEDRIVE")) + strlen(getenv("HOMEPATH")) > ndest)
- return strlen(getenv("HOMEDRIVE")) + strlen(getenv("HOMEPATH"));
- strncpy(dest,getenv("HOMEDRIVE"),3);
- strncat(dest,getenv("HOMEPATH"),ndest-3);
- return 0;
- }
+ if(0 != getenv("HOMEDRIVE") && 0 != getenv("HOMEPATH"))
+ {
+ if(strlen(getenv("HOMEDRIVE")) + strlen(getenv("HOMEPATH")) > ndest)
+ return strlen(getenv("HOMEDRIVE")) + strlen(getenv("HOMEPATH"));
+ strncpy(dest,getenv("HOMEDRIVE"),3);
+ strncat(dest,getenv("HOMEPATH"),ndest-3);
+ return 0;
+ }
- if((path = getenv("HOME")) != 0)
- {
- if(strlen(path) > ndest)
- return strlen(path);
- strncpy(dest,path,ndest);
- return 0;
- }
+ if((path = getenv("HOME")) != 0)
+ {
+ if(strlen(path) > ndest)
+ return strlen(path);
+ strncpy(dest,path,ndest);
+ return 0;
+ }
- return -1;
+ return -1;
}
int
get_launch_config(LaunchConfig* config)
{
- int error = 0;
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "getting launch config...\n");
- if(get_java_path(config->java))
- error = 1;
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "java: '%s'\n", config->java, error);
- get_java_opts(config->java_opts);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "java_opts: '%s'\n", config->java_opts);
- if(get_jedit_jar(config->jedit_jar))
- error = 1;
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "jedit_jar: '%s'\n", config->jedit_jar);
- get_jedit_opts(config->jedit_opts);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "jedit_opts: '%s'\n", config->jedit_opts);
- get_working_dir(config->working_dir);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "working_dir: '%s'\n", config->working_dir);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "errors getting config: %d\n", error);
- return error;
+ int error = 0;
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "getting launch config...\n");
+ if(get_java_path(config->java))
+ error = 1;
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "java: '%s'\n", config->java, error);
+ get_java_opts(config->java_opts);
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "java_opts: '%s'\n", config->java_opts);
+ if(get_jedit_jar(config->jedit_jar))
+ error = 1;
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "jedit_jar: '%s'\n", config->jedit_jar);
+ get_jedit_opts(config->jedit_opts);
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "jedit_opts: '%s'\n", config->jedit_opts);
+ get_working_dir(config->working_dir);
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "working_dir: '%s'\n", \
config->working_dir); + log_to_file(J_LOG_FILE, J_LOG_SOURCE, "errors getting \
config: %d\n", error); + return error;
}
// XXX add an "ndest" param for the size of output buffer
int
get_server_file(char* dest,
- const char* settings_dir,
- const char* filename)
+ const char* settings_dir,
+ const char* filename)
{
- dest[0] = 0;
- char tmp[MAX_PATH] = {'\0'};
- char home[MAX_PATH] = {'\0'};
+ dest[0] = 0;
+ char tmp[MAX_PATH] = {'\0'};
+ char home[MAX_PATH] = {'\0'};
- // XXX need a path_concat function
- if(settings_dir)
- {
- strncpy(dest,settings_dir,MAX_PATH);
- }
- else
- {
- if(get_home(home,MAX_PATH))
- // XXX print an error
- return 1;
- strncpy(dest,home,MAX_PATH);
- strcat(dest,"\\.jedit");
- }
+ // XXX need a path_concat function
+ if(settings_dir)
+ {
+ strncpy(dest,settings_dir,MAX_PATH);
+ }
+ else
+ {
+ if(get_home(home,MAX_PATH))
+ // XXX print an error
+ return 1;
+ strncpy(dest,home,MAX_PATH);
+ strcat(dest,"\\.jedit");
+ }
- strcat(dest,"\\");
- if(filename)
- strcat(dest,filename);
- else
- strcat(dest,"server");
+ strcat(dest,"\\");
+ if(filename)
+ strcat(dest,filename);
+ else
+ strcat(dest,"server");
- return 0;
+ return 0;
}
int
-get_edit_server_info(const char* server_file,
- EditServerInfo * edit_server)
+get_edit_server_info(const char* server_file,
+ EditServerInfo * edit_server)
{
- if(!server_file)
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE,"server_file is NULL\n");
- return 1;
- }
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "getting server info from '%s'\n",
- server_file);
- char* first_line[64] = {'\0'};
- FILE* f;
- f = fopen(server_file, "r");
- if(0 == f)
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "failed to open server file\n");
- return 1;
- }
- fscanf(f, "%s", &first_line);
- fscanf(f, "%u", &edit_server->port);
- fscanf(f, "%u", &edit_server->key);
- fclose(f);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "edit server port: %d, key: %d\n",
- edit_server->port, edit_server->key);
- return 0;
+ if(!server_file)
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE,"server_file is NULL\n");
+ return 1;
+ }
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "getting server info from '%s'\n",
+ server_file);
+ char* first_line[64] = {'\0'};
+ FILE* f;
+ f = fopen(server_file, "r");
+ if(0 == f)
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "failed to open server file\n");
+ return 1;
+ }
+ fscanf(f, "%s", &first_line);
+ fscanf(f, "%u", &edit_server->port);
+ fscanf(f, "%u", &edit_server->key);
+ fclose(f);
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "edit server port: %d, key: %d\n",
+ edit_server->port, edit_server->key);
+ return 0;
}
int
diff_files_in_jedit(const char* java,
- const char* java_opts,
- const char* jedit_jar,
- const char* jedit_opts,
- const char* working_dir,
- const char* file1,
- const char* file2)
+ const char* java_opts,
+ const char* jedit_jar,
+ const char* jedit_opts,
+ const char* working_dir,
+ const char* file1,
+ const char* file2)
{
- char escaped1[MAX_PATH] = {'\0'};
- char escaped2[MAX_PATH] = {'\0'};
- char script[DIFF_SCRIPT_LEN] = {'\0'};
- char server_file[MAX_PATH] = {'\0'};
- char* files[] = {0,0};
- EditServerInfo edit_server;
+ char escaped1[MAX_PATH] = {'\0'};
+ char escaped2[MAX_PATH] = {'\0'};
+ char script[DIFF_SCRIPT_LEN] = {'\0'};
+ char server_file[MAX_PATH] = {'\0'};
+ char* files[] = {0,0};
+ EditServerInfo edit_server;
- escape_filename(file1, escaped1);
- escape_filename(file2, escaped2);
+ escape_filename(file1, escaped1);
+ escape_filename(file2, escaped2);
- sprintf(script, DIFF_SCRIPT, escaped1, escaped2);
+ sprintf(script, DIFF_SCRIPT, escaped1, escaped2);
- // XXX handle errors!
- // XXX pass additional args
- get_server_file(server_file,NULL,NULL);
- get_edit_server_info(server_file,&edit_server);
+ // XXX handle errors!
+ // XXX pass additional args
+ get_server_file(server_file,NULL,NULL);
+ get_edit_server_info(server_file,&edit_server);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script...\n");
- if(send_script(edit_server.port, edit_server.key, script, 0)) /* XXX */
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script failed.\n");
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script...\n");
+ if(send_script(edit_server.port, edit_server.key, script, 0)) /* XXX */
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script failed.\n");
- files[0] = (char*)file1;
- files[1] = (char*)file2;
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "attempting to launch jEdit...\n");
- if(open_files_in_jedit(java,
- java_opts,
- jedit_jar,
- jedit_opts,
- working_dir,
- NULL, // XXX pass options
- (const char**)files,
- 2))
- return 1; // failed
+ files[0] = (char*)file1;
+ files[1] = (char*)file2;
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "attempting to launch jEdit...\n");
+ if(open_files_in_jedit(java,
+ java_opts,
+ jedit_jar,
+ jedit_opts,
+ working_dir,
+ NULL, // XXX pass options
+ (const char**)files,
+ 2))
+ return 1; // failed
- // make 10 attempts to find the server file
- // and send the diff script to the server
- //
- // XXX THIS IS PRETTY CRAPPY.
- // MIGHT BE BETTER TO GENERATE A TEMP.bsh FILE
- // AND USE -run=TEMP.bsh INSTEAD.
- for(int i=0; i < 10; i++)
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "waiting (%d) for server file...\n", i);
- Sleep(1500); // XXX win32 specific
- if(!get_edit_server_info(server_file,&edit_server))
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script...\n");
- if(send_script(edit_server.port, edit_server.key, script, 0)) /* XXX */
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script failed.\n");
- return 1;
- }
- if(send_script(edit_server.port, edit_server.key, FOCUS_SCRIPT, 0)) /* XXX */
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending focus script faile.\n");
- return 1;
- }
- return 0;
- }
- }
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "never found server file.\n");
- return 1;
- }
- else
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending focus script...\n");
- return send_script(edit_server.port, edit_server.key, FOCUS_SCRIPT, 0); /* XXX */
- }
+ // make 10 attempts to find the server file
+ // and send the diff script to the server
+ //
+ // XXX THIS IS PRETTY CRAPPY.
+ // MIGHT BE BETTER TO GENERATE A TEMP.bsh FILE
+ // AND USE -run=TEMP.bsh INSTEAD.
+ for(int i=0; i < 10; i++)
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "waiting (%d) for server \
file...\n", i); + Sleep(1500); // XXX win32 specific
+ if(!get_edit_server_info(server_file,&edit_server))
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script...\n");
+ if(send_script(edit_server.port, edit_server.key, script, 0)) /* XXX \
*/ + {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending diff script \
failed.\n"); + return 1;
+ }
+ if(send_script(edit_server.port, edit_server.key, FOCUS_SCRIPT, 0)) \
/* XXX */ + {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending focus script \
faile.\n"); + return 1;
+ }
+ return 0;
+ }
+ }
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "never found server file.\n");
+ return 1;
+ }
+ else
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending focus script...\n");
+ return send_script(edit_server.port, edit_server.key, FOCUS_SCRIPT, 0); /* \
XXX */ + }
}
int
open_files_in_jedit(const char* java,
- const char* java_opts,
- const char* jedit_jar,
- const char* jedit_opts,
- const char* working_dir,
- const OptList* opts,
- const char** files,
- const int nfiles)
+ const char* java_opts,
+ const char* jedit_jar,
+ const char* jedit_opts,
+ const char* working_dir,
+ const OptList* opts,
+ const char** files,
+ const int nfiles)
{
- // XXX check for "server"
- char server_file[MAX_PATH] = {'\0'};
- int started = 0;
- EditServerInfo edit_server;
- int wait = has_opt(opts,"wait"); // XXX const
- int new_plain_view = has_opt(opts,"newplainview"); // XXX const
- int new_view = has_opt(opts,"newview"); // XXX const
- int restore = has_opt(opts,"reuseview"); // XXX const
- const char* script_file = get_opt_value(opts,"run"); // XXX const
- const char* settings = get_opt_value(opts,"settings");
- const char* server = get_opt_value(opts,"server");
- char tmp[MAX_PATH] = {'\0'};
- if(script_file)
- {
- _fullpath(tmp, script_file, MAX_PATH);
- printf("tmp=%s\n", tmp); // XXX
- script_file = tmp;
- }
+ // XXX check for "server"
+ char server_file[MAX_PATH] = {'\0'};
+ int started = 0;
+ EditServerInfo edit_server;
+ int wait = has_opt(opts,"wait"); // XXX const
+ int new_plain_view = has_opt(opts,"newplainview"); // XXX const
+ int new_view = has_opt(opts,"newview"); // XXX const
+ int restore = has_opt(opts,"reuseview"); // XXX const
+ const char* script_file = get_opt_value(opts,"run"); // XXX const
+ const char* settings = get_opt_value(opts,"settings");
+ const char* server = get_opt_value(opts,"server");
+ char tmp[MAX_PATH] = {'\0'};
+ if(script_file)
+ {
+ _fullpath(tmp, script_file, MAX_PATH);
+ printf("tmp=%s\n", tmp); // XXX
+ script_file = tmp;
+ }
- // XXX handle errors
- get_server_file(server_file,settings,server);
+ // XXX handle errors
+ get_server_file(server_file,settings,server);
- if(!get_edit_server_info(server_file, &edit_server))
- {
-
- char* script = create_server_script(wait,
- restore,
- new_view,
- new_plain_view,
- script_file,
- working_dir,
- files,
- nfiles);
- // XXX handle NULL script
+ if(!get_edit_server_info(server_file, &edit_server))
+ {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending open script...\n");
- int error = send_script(edit_server.port, edit_server.key, script, wait); /* XXX \
*/
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "send_script returned: %d\n", error);
- if(!error)
- started = 1;
+ char* script = create_server_script(wait,
+ restore,
+ new_view,
+ new_plain_view,
+ script_file,
+ working_dir,
+ files,
+ nfiles);
+ // XXX handle NULL script
- }
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "sending open script...\n");
+ int error = send_script(edit_server.port, edit_server.key, script, wait); /* \
XXX */ + log_to_file(J_LOG_FILE, J_LOG_SOURCE, "send_script returned: %d\n", \
error); + if(!error)
+ started = 1;
- // Either didn't find server file, or found server file
- // but wasn't able to connect to EditServer.
- if(0 == started)
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "attempting to launch\n");
- return launch_jedit(java,
- java_opts,
- jedit_jar,
- jedit_opts,
- working_dir,
- opts,
- files,
- nfiles);
- }
+ }
- return (started != 1);
+ // Either didn't find server file, or found server file
+ // but wasn't able to connect to EditServer.
+ if(0 == started)
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "attempting to launch\n");
+ return launch_jedit(java,
+ java_opts,
+ jedit_jar,
+ jedit_opts,
+ working_dir,
+ opts,
+ files,
+ nfiles);
+ }
+
+ return (started != 1);
}
int
-expand_globs(const char** globs,
- const int nglobs,
- char** files,
- int nfiles)
+expand_globs(const char** globs,
+ const int nglobs,
+ char** files,
+ int nfiles)
{
- WIN32_FIND_DATA ffd;
- HANDLE hFind;
+ WIN32_FIND_DATA ffd;
+ HANDLE hFind;
- int overflow = 0;
- int count = 0;
- char filename[MAX_PATH] = {'\0'};
- char directory[MAX_PATH] = {'\0'};
- int slash = -1;
- char cwd[MAX_PATH] = {'\0'};
- char path[MAX_PATH] = {'\0'};
+ int overflow = 0;
+ int count = 0;
+ char filename[MAX_PATH] = {'\0'};
+ char directory[MAX_PATH] = {'\0'};
+ int slash = -1;
+ char cwd[MAX_PATH] = {'\0'};
+ char path[MAX_PATH] = {'\0'};
- getcwd(cwd,MAX_PATH);
- if(cwd[strlen(cwd)-1] != '\\')
- strcat(cwd,"\\");
+ getcwd(cwd,MAX_PATH);
+ if(cwd[strlen(cwd)-1] != '\\')
+ strcat(cwd,"\\");
- for(int i=0; i < nglobs; i++)
- {
- slash = -1;
- ZeroMemory(directory,MAX_PATH);
+ for(int i=0; i < nglobs; i++)
+ {
+ slash = -1;
+ ZeroMemory(directory,MAX_PATH);
- // XXX use _splitpath
- // extract directory portion of path, forward- or backslash found
- for(int j=strlen(globs[i])-1; j >= 0; j--)
- {
- if(globs[i][j] == '\\' || globs[i][j] == '/')
- {
- slash = j;
- strncpy(directory, globs[i], j+1);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "directory for %s is %s\n",
- globs[i], directory);
- break;
- }
- }
+ // XXX use _splitpath
+ // extract directory portion of path, forward- or backslash found
+ for(int j=strlen(globs[i])-1; j >= 0; j--)
+ {
+ if(globs[i][j] == '\\' || globs[i][j] == '/')
+ {
+ slash = j;
+ strncpy(directory, globs[i], j+1);
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "directory for %s is %s\n",
+ globs[i], directory);
+ break;
+ }
+ }
- hFind = FindFirstFile(globs[i], &ffd);
- if (hFind == INVALID_HANDLE_VALUE)
- {
- // assume the problem is that the file doesn't
- // exist, so just add to the list
+ hFind = FindFirstFile(globs[i], &ffd);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ // assume the problem is that the file doesn't
+ // exist, so just add to the list
- // XXX refactor this into a function
- if(strlen(directory))
- strcat(filename,directory);
- else
- strcat(filename,cwd);
- strcat(filename,globs[i]);
- _fullpath(path,filename,MAX_PATH);
+ // XXX refactor this into a function
+ if(strlen(directory))
+ strcat(filename,directory);
+ else
+ strcat(filename,cwd);
+ strcat(filename,globs[i]);
+ _fullpath(path,filename,MAX_PATH);
- switch(add_file_to_list(path, files, nfiles, count))
- {
- case ADDFILE_OK: // added
- count++;
- files++;
- break;
- case ADDFILE_OOM: // out of memory
- // Not doing anything special to signal malloc failure.
- // As long as we're not overwriting RAM that's not ours,
- // since it means bad stuff's already going on.
- goto DONE;
- case ADDFILE_OVERFLOW: // list full
- overflow++;
- break;
- }
+ switch(add_file_to_list(path, files, nfiles, count))
+ {
+ case ADDFILE_OK: // added
+ count++;
+ files++;
+ break;
+ case ADDFILE_OOM: // out of memory
+ // Not doing anything special to signal malloc failure.
+ // As long as we're not overwriting RAM that's not ours,
+ // since it means bad stuff's already going on.
+ goto DONE;
+ case ADDFILE_OVERFLOW: // list full
+ overflow++;
+ break;
+ }
- continue;
- }
- else
- {
- if((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
- goto FIND_FILES;
+ continue;
+ }
+ else
+ {
+ if((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == \
FILE_ATTRIBUTE_DIRECTORY) + goto FIND_FILES;
- ZeroMemory(filename,MAX_PATH);
- // add either given directory or current working directory
- if(strlen(directory))
- strcat(filename,directory);
- else
- strcat(filename,cwd);
- // concat directory and filename
- strcat(filename,ffd.cFileName);
- // absolute path
- _fullpath(path,filename,MAX_PATH);
- switch(add_file_to_list(path, files, nfiles, count))
- {
- case ADDFILE_OK: // added
- count++;
- files++;
- break;
- case ADDFILE_OOM: // out of memory
- // Not doing anything special to signal malloc failure.
- // As long as we're not overwriting RAM that's not ours,
- // since it means bad stuff's already going on.
- goto DONE;
- case ADDFILE_OVERFLOW: // list full
- overflow++;
- break;
- }
+ ZeroMemory(filename,MAX_PATH);
+ // add either given directory or current working directory
+ if(strlen(directory))
+ strcat(filename,directory);
+ else
+ strcat(filename,cwd);
+ // concat directory and filename
+ strcat(filename,ffd.cFileName);
+ // absolute path
+ _fullpath(path,filename,MAX_PATH);
+ switch(add_file_to_list(path, files, nfiles, count))
+ {
+ case ADDFILE_OK: // added
+ count++;
+ files++;
+ break;
+ case ADDFILE_OOM: // out of memory
+ // Not doing anything special to signal malloc failure.
+ // As long as we're not overwriting RAM that's not ours,
+ // since it means bad stuff's already going on.
+ goto DONE;
+ case ADDFILE_OVERFLOW: // list full
+ overflow++;
+ break;
+ }
FIND_FILES:
- while(FindNextFile(hFind, &ffd))
- {
- if((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == \
FILE_ATTRIBUTE_DIRECTORY)
- continue;
+ while(FindNextFile(hFind, &ffd))
+ {
+ if((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == \
FILE_ATTRIBUTE_DIRECTORY) + continue;
- // clear out filename -- for previous
- ZeroMemory(filename,MAX_PATH);
- // add either given directory or current working directory
- if(strlen(directory))
- strcat(filename,directory);
- else
- strcat(filename,cwd);
- // concat directory and filename
- strcat(filename,ffd.cFileName);
- // absolute path
- _fullpath(path,filename,MAX_PATH);
- // add to list
- switch(add_file_to_list(path, files, nfiles, count))
- {
- case ADDFILE_OK: // added
- count++;
- files++;
- break;
- case ADDFILE_OOM: // out of memory
- // Not doing anything special to signal malloc failure.
- // As long as we're not overwriting RAM that's not ours,
- // since it means bad stuff's already going on.
- goto DONE;
- case ADDFILE_OVERFLOW: // list full
- overflow++;
- break;
- }
- }
- FindClose(hFind);
- }
- }
+ // clear out filename -- for previous
+ ZeroMemory(filename,MAX_PATH);
+ // add either given directory or current working directory
+ if(strlen(directory))
+ strcat(filename,directory);
+ else
+ strcat(filename,cwd);
+ // concat directory and filename
+ strcat(filename,ffd.cFileName);
+ // absolute path
+ _fullpath(path,filename,MAX_PATH);
+ // add to list
+ switch(add_file_to_list(path, files, nfiles, count))
+ {
+ case ADDFILE_OK: // added
+ count++;
+ files++;
+ break;
+ case ADDFILE_OOM: // out of memory
+ // Not doing anything special to signal malloc failure.
+ // As long as we're not overwriting RAM that's not ours,
+ // since it means bad stuff's already going on.
+ goto DONE;
+ case ADDFILE_OVERFLOW: // list full
+ overflow++;
+ break;
+ }
+ }
+ FindClose(hFind);
+ }
+ }
DONE:
- if(overflow)
- return -(overflow + count);
- return count;
+ if(overflow)
+ return -(overflow + count);
+ return count;
}
int
-add_file_to_list(const char* filename,
- char** files,
- const int nfiles,
- const int count)
+add_file_to_list(const char* filename,
+ char** files,
+ const int nfiles,
+ const int count)
{
- char* tmp = NULL;
+ char* tmp = NULL;
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "found: %s\n", filename);
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "found: %s\n", filename);
- // if we've overflowed the list,
- // don't even bother copying
- if(count >= nfiles)
- {
- return ADDFILE_OVERFLOW; // overflow
- }
+ // if we've overflowed the list,
+ // don't even bother copying
+ if(count >= nfiles)
+ {
+ return ADDFILE_OVERFLOW; // overflow
+ }
- tmp = (char*)malloc(strlen(filename)+1);
- if(!filename)
- {
- return ADDFILE_OOM;
- }
- *files = strcpy(tmp, filename);
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "added: %s\n", tmp);
- return ADDFILE_OK;
+ tmp = (char*)malloc(strlen(filename)+1);
+ if(!filename)
+ {
+ return ADDFILE_OOM;
+ }
+ *files = strcpy(tmp, filename);
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "added: %s\n", tmp);
+ return ADDFILE_OK;
}
char*
create_server_script(const int wait,
- const int restore,
- const int new_view,
- const int new_plain_view,
- const char * script_file,
- const char * working_dir,
- const char ** filenames,
- unsigned int nfiles)
+ const int restore,
+ const int new_view,
+ const int new_plain_view,
+ const char * script_file,
+ const char * working_dir,
+ const char ** filenames,
+ unsigned int nfiles)
{
- char* script = (char*)malloc((1024*2) + MAX_PATH * 2 * nfiles);
- char escaped_name[MAX_PATH*2] = {'\0'};
- char buffer[250] = {'\0'};
- // XXX log an error
- if(!script)
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE, "unable to allocate script in \
'create_server_script\n");
- return script;
- }
- else
- script[0] = '\0';
- strcat(script, "parent = \"");
- if(working_dir)
- {
- escape_filename(working_dir, escaped_name);
- strncat(script, escaped_name, MAX_PATH*2);
- }
- strcat(script, "\";\n");
+ char* script = (char*)malloc((1024*2) + MAX_PATH * 2 * nfiles);
+ char escaped_name[MAX_PATH*2] = {'\0'};
+ char buffer[250] = {'\0'};
+ // XXX log an error
+ if(!script)
+ {
+ log_to_file(J_LOG_FILE, J_LOG_SOURCE, "unable to allocate script in \
'create_server_script\n"); + return script;
+ }
+ else
+ script[0] = '\0';
+ strcat(script, "parent = \"");
+ if(working_dir)
+ {
+ escape_filename(working_dir, escaped_name);
+ strncat(script, escaped_name, MAX_PATH*2);
+ }
+ strcat(script, "\";\n");
- sprintf(buffer, "args = new String[%d];\n", nfiles);
- strcat(script, buffer);
- for(int i=0; i < nfiles; i++)
- {
- sprintf(buffer, "args[%d] = \"", i);
- strcat(script, buffer);
- escape_filename(filenames[i], escaped_name);
- strncat(script, escaped_name, MAX_PATH*2);
- strcat(script, "\";\n");
- }
+ sprintf(buffer, "args = new String[%d];\n", nfiles);
+ strcat(script, buffer);
+ for(int i=0; i < nfiles; i++)
+ {
+ sprintf(buffer, "args[%d] = \"", i);
+ strcat(script, buffer);
+ escape_filename(filenames[i], escaped_name);
+ strncat(script, escaped_name, MAX_PATH*2);
+ strcat(script, "\";\n");
+ }
- strcat(script, "view = jEdit.getLastView();\n");
- sprintf(buffer, "buffer = EditServer.handleClient(%s, %s, %s, parent, args);\n",
- int2bool(restore),
- int2bool(new_view),
- int2bool(new_plain_view));
- strcat(script, buffer);
- sprintf(buffer, "if(buffer != null && %s){\n", int2bool(wait));
- strcat(script, buffer);
- strcat(script, " buffer.setWaitSocket(socket);\n");
- strcat(script, " doNotCloseSocket = true;\n");
- strcat(script, "}\n");
- sprintf(buffer, "if(view != jEdit.getLastView() && %s){\n", int2bool(wait));
- strcat(script, buffer);
- strcat(script, " jEdit.getLastView().setWaitSocket(socket);\n");
- strcat(script, " doNotCloseSocket = true;\n");
- strcat(script, "}\n");
- strcat(script, "if(doNotCloseSocket == void)\n");
- strcat(script, " socket.close();\n");
+ strcat(script, "view = jEdit.getLastView();\n");
+ sprintf(buffer, "buffer = EditServer.handleClient(%s, %s, %s, parent, args);\n",
+ int2bool(restore),
+ int2bool(new_view),
+ int2bool(new_plain_view));
+ strcat(script, buffer);
+ sprintf(buffer, "if(buffer != null && %s){\n", int2bool(wait));
+ strcat(script, buffer);
+ strcat(script, " buffer.setWaitSocket(socket);\n");
+ strcat(script, " doNotCloseSocket = true;\n");
+ strcat(script, "}\n");
+ sprintf(buffer, "if(view != jEdit.getLastView() && %s){\n", int2bool(wait));
+ strcat(script, buffer);
+ strcat(script, " jEdit.getLastView().setWaitSocket(socket);\n");
+ strcat(script, " doNotCloseSocket = true;\n");
+ strcat(script, "}\n");
+ strcat(script, "if(doNotCloseSocket == void)\n");
+ strcat(script, " socket.close();\n");
- // XXX need to make script_file an absolute path
- if(script_file)
- {
- printf("adding script: %s\n", script_file); // XXX
- escape_filename(script_file, escaped_name);
- printf("escaped_name: %s\n", escaped_name); // XXX
- strcat(script, "BeanShell.runScript(view,\"");
- strcat(script, escaped_name);
- strcat(script, "\", null, this.namespace);\n");
- }
+ // XXX need to make script_file an absolute path
+ if(script_file)
+ {
+ printf("adding script: %s\n", script_file); // XXX
+ escape_filename(script_file, escaped_name);
+ printf("escaped_name: %s\n", escaped_name); // XXX
+ strcat(script, "BeanShell.runScript(view,\"");
+ strcat(script, escaped_name);
+ strcat(script, "\", null, this.namespace);\n");
+ }
- strcat(script, "int state = view.getExtendedState();\n");
- strcat(script, "if((state & view.ICONIFIED) == view.ICONIFIED){ state ^= \
view.ICONIFIED; view.setExtendedState(state); }\n");
- strcat(script, "view.setVisible(true);\n");
- strcat(script, "view.getTextArea().requestFocus();\n");
+ strcat(script, "int state = view.getExtendedState();\n");
+ strcat(script, "if((state & view.ICONIFIED) == view.ICONIFIED){ state ^= \
view.ICONIFIED; view.setExtendedState(state); }\n"); + strcat(script, \
"view.setVisible(true);\n"); + strcat(script, \
"view.getTextArea().requestFocus();\n");
- return script;
+ return script;
}
const char*
int2bool(const int value)
{
- return (value ? "true" : "false");
+ return (value ? "true" : "false");
}
// XXX error handling
// XXX no buffer overrun
int
create_launch_command(const char * java,
- const char * java_opts,
- const char * jedit_jar,
- const char * jedit_opts,
- const char * working_dir,
- const OptList * options,
- const char ** filenames,
- unsigned int nfiles,
- char* cmd,
- unsigned int ncmd)
+ const char * java_opts,
+ const char * jedit_jar,
+ const char * jedit_opts,
+ const char * working_dir,
+ const OptList * options,
+ const char ** filenames,
+ unsigned int nfiles,
+ char* cmd,
+ unsigned int ncmd)
{
- int error = 0;
+ int error = 0;
- // quote java path if containing spaces, but don't double-quote
- if(strchr(java,' ') && java[0] != '"' && java[strlen(java)-1] != '"')
- {
- if(file_exists(java) != ERROR_SUCCESS)
- {
- log_to_file(J_LOG_FILE, J_LOG_SOURCE,
- "java '%s' doesn't exist.\n", java);
- error = 2;
- }
- strcat(cmd, "\"");
- strcat(cmd, java);
- strcat(cmd, "\"");
- }
- else
- strcat(cmd, java);
- strcat(cmd, " ");
+ // quote java path if containing spaces, but don't double-quote
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic