1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008, 2010-2012 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "TortoiseUDiff.h"
21 #include "MainWindow.h"
22 #include "CmdLineParser.h"
23 #include "TaskbarUUID.h"
26 #pragma comment(lib, "comctl32.lib")
29 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
32 int APIENTRY
_tWinMain(HINSTANCE hInstance
,
33 HINSTANCE hPrevInstance
,
37 UNREFERENCED_PARAMETER(hPrevInstance
);
38 UNREFERENCED_PARAMETER(nCmdShow
);
45 CCmdLineParser
parser(lpCmdLine
);
47 if (parser
.HasKey(_T("?")) || parser
.HasKey(_T("help")))
50 LoadString(hInstance
, IDS_COMMANDLINEHELP
, buf
, sizeof(buf
)/sizeof(TCHAR
));
51 MessageBox(NULL
, buf
, _T("TortoiseUDiff"), MB_ICONINFORMATION
);
55 INITCOMMONCONTROLSEX used
= {
56 sizeof(INITCOMMONCONTROLSEX
),
57 ICC_STANDARD_CLASSES
| ICC_BAR_CLASSES
59 InitCommonControlsEx(&used
);
62 HMODULE hSciLexerDll
= ::LoadLibrary(_T("SciLexer.DLL"));
63 if (hSciLexerDll
== NULL
)
66 CMainWindow
mainWindow(hInstance
);
67 mainWindow
.SetRegistryPath(_T("Software\\TortoiseGit\\UDiffViewerWindowPos"));
68 if (parser
.HasVal(_T("title")))
69 mainWindow
.SetTitle(parser
.GetVal(_T("title")));
70 else if (parser
.HasVal(_T("patchfile")))
71 mainWindow
.SetTitle(parser
.GetVal(_T("patchfile")));
73 mainWindow
.SetTitle(_T("diff from pipe"));
75 if (!mainWindow
.RegisterAndCreateWindow())
77 FreeLibrary(hSciLexerDll
);
81 bool bLoadedSuccessfully
= false;
82 if ( (lpCmdLine
[0] == 0) ||
83 (parser
.HasKey(_T("p"))) )
85 // input from console pipe
86 // set console to raw mode
88 GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE
), &oldMode
);
89 SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE
), oldMode
& ~(ENABLE_LINE_INPUT
| ENABLE_ECHO_INPUT
));
91 bLoadedSuccessfully
= mainWindow
.LoadFile(GetStdHandle(STD_INPUT_HANDLE
));
93 else if (parser
.HasVal(_T("patchfile")))
94 bLoadedSuccessfully
= mainWindow
.LoadFile(parser
.GetVal(_T("patchfile")));
95 else if (lpCmdLine
[0] != 0)
96 bLoadedSuccessfully
= mainWindow
.LoadFile(lpCmdLine
);
99 if (!bLoadedSuccessfully
)
101 FreeLibrary(hSciLexerDll
);
105 ::ShowWindow(mainWindow
.GetHWNDEdit(), SW_SHOW
);
106 ::SetFocus(mainWindow
.GetHWNDEdit());
108 hAccelTable
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDC_TORTOISEUDIFF
));
110 // Main message loop:
111 while (GetMessage(&msg
, NULL
, 0, 0))
113 if (!TranslateAccelerator(mainWindow
, hAccelTable
, &msg
))
115 TranslateMessage(&msg
);
116 DispatchMessage(&msg
);
120 FreeLibrary(hSciLexerDll
);
121 return (int) msg
.wParam
;