joachim99@8
|
1 /***************************************************************************
|
joachim99@8
|
2 main.cpp - Where everything starts.
|
joachim99@8
|
3 -------------------
|
joachim99@8
|
4 begin : Don Jul 11 12:31:29 CEST 2002
|
joachim99@58
|
5 copyright : (C) 2002-2004 by Joachim Eibl
|
joachim99@8
|
6 email : joachim.eibl@gmx.de
|
joachim99@8
|
7 ***************************************************************************/
|
joachim99@8
|
8
|
joachim99@8
|
9 /***************************************************************************
|
joachim99@8
|
10 * *
|
joachim99@8
|
11 * This program is free software; you can redistribute it and/or modify *
|
joachim99@8
|
12 * it under the terms of the GNU General Public License as published by *
|
joachim99@8
|
13 * the Free Software Foundation; either version 2 of the License, or *
|
joachim99@8
|
14 * (at your option) any later version. *
|
joachim99@8
|
15 * *
|
joachim99@8
|
16 ***************************************************************************/
|
joachim99@8
|
17
|
joachim99@8
|
18 #include <kcmdlineargs.h>
|
joachim99@8
|
19 #include <kaboutdata.h>
|
joachim99@8
|
20 #include <klocale.h>
|
joachim99@40
|
21 #include "kdiff3_shell.h"
|
friseb123@16
|
22 #include "version.h"
|
joachim99@53
|
23 #include <qtextcodec.h>
|
joachim99@8
|
24
|
joachim99@66
|
25 #ifdef KREPLACEMENTS_H
|
joachim99@66
|
26 #include "optiondialog.h"
|
joachim99@66
|
27 #endif
|
joachim99@8
|
28
|
joachim99@8
|
29 static const char *description =
|
joachim99@8
|
30 I18N_NOOP("Text Diff and Merge Tool");
|
joachim99@8
|
31
|
joachim99@8
|
32 static KCmdLineOptions options[] =
|
joachim99@8
|
33 {
|
joachim99@8
|
34 { "m", 0, 0 },
|
joachim99@8
|
35 { "merge", I18N_NOOP("Merge the input."), 0 },
|
joachim99@8
|
36 { "b", 0, 0 },
|
joachim99@8
|
37 { "base file", I18N_NOOP("Explicit base file. For compatibility with certain tools."), 0 },
|
joachim99@8
|
38 { "o", 0, 0 },
|
joachim99@8
|
39 { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 },
|
joachim99@8
|
40 { "out file", I18N_NOOP("Output file, again. (For compatibility with certain tools.)"), 0 },
|
joachim99@8
|
41 { "auto", I18N_NOOP("No GUI if all conflicts are auto-solvable. (Needs -o file)"), 0 },
|
joachim99@8
|
42 { "qall", I18N_NOOP("Don't solve conflicts automatically. (For compatibility...)"), 0 },
|
joachim99@66
|
43 { "L1 alias1", I18N_NOOP("Visible name replacement for input file 1 (base)."), 0 },
|
joachim99@66
|
44 { "L2 alias2", I18N_NOOP("Visible name replacement for input file 2."), 0 },
|
joachim99@66
|
45 { "L3 alias3", I18N_NOOP("Visible name replacement for input file 3."), 0 },
|
joachim99@66
|
46 { "L", 0, 0 },
|
joachim99@66
|
47 { "fname alias", I18N_NOOP("Alternative visible name replacement. Supply this once for every input."), 0 },
|
joachim99@66
|
48 { "u", I18N_NOOP("Has no effect. For compatibility with certain tools."), 0 },
|
joachim99@8
|
49 #ifdef _WIN32
|
joachim99@8
|
50 { "query", I18N_NOOP("For compatibility with certain tools."), 0 },
|
joachim99@8
|
51 #endif
|
joachim99@8
|
52 { "+[File1]", I18N_NOOP("file1 to open (base, if not specified via --base)"), 0 },
|
joachim99@8
|
53 { "+[File2]", I18N_NOOP("file2 to open"), 0 },
|
joachim99@8
|
54 { "+[File3]", I18N_NOOP("file3 to open"), 0 },
|
joachim99@8
|
55 { 0, 0, 0 }
|
joachim99@8
|
56 };
|
joachim99@8
|
57
|
joachim99@8
|
58
|
joachim99@8
|
59 #ifdef _WIN32
|
joachim99@8
|
60 #include <process.h>
|
joachim99@8
|
61 // This command checks the comm
|
joachim99@8
|
62 static bool isOptionUsed(const QString& s, int argc, char* argv[])
|
joachim99@8
|
63 {
|
joachim99@8
|
64 for(int j=0; j<argc; ++j )
|
joachim99@8
|
65 {
|
joachim99@8
|
66 if( "-"+s == argv[j] || "--"+s==argv[j] )
|
joachim99@8
|
67 {
|
joachim99@8
|
68 return true;
|
joachim99@8
|
69 }
|
joachim99@8
|
70 }
|
joachim99@8
|
71 return false;
|
joachim99@8
|
72 }
|
joachim99@8
|
73 #endif
|
joachim99@8
|
74
|
joachim99@8
|
75 int main(int argc, char *argv[])
|
joachim99@8
|
76 {
|
joachim99@8
|
77 #ifdef _WIN32
|
joachim99@8
|
78 /* KDiff3 can be used as replacement for the text-diff and merge tool provided by
|
joachim99@8
|
79 Clearcase. This is experimental and so far has only been tested under Windows.
|
joachim99@8
|
80
|
joachim99@8
|
81 The installation is very simple:
|
joachim99@8
|
82 1. In the Clearcase "bin"-directory rename "cleardiffmrg.exe" to "cleardiffmrg_orig.exe".
|
joachim99@8
|
83 2. Copy kdiff3.exe into that "bin"-directory and rename it to "cleardiffmrg.exe".
|
joachim99@8
|
84 (Also copy the other files that are needed by KDiff3 there.)
|
joachim99@8
|
85
|
joachim99@8
|
86 Now when a file comparison or merge is done by Clearcase then of course KDiff3 will be
|
joachim99@8
|
87 run instead.
|
joachim99@8
|
88 If the commandline contains the option "-directory" then KDiff3 can't do it but will
|
joachim99@8
|
89 run "cleardiffmrg_orig.exe" instead.
|
joachim99@8
|
90 */
|
joachim99@8
|
91
|
joachim99@8
|
92 /* // Write all args into a temporary file. Uncomment this for debugging purposes.
|
joachim99@8
|
93 FILE* f = fopen("c:\\t.txt","w");
|
joachim99@8
|
94 for(int i=0; i< argc; ++i)
|
joachim99@8
|
95 fprintf(f,"Arg %d: %s\n", i, argv[i]);
|
joachim99@8
|
96 fclose(f);
|
joachim99@8
|
97 */
|
joachim99@8
|
98
|
joachim99@8
|
99 // KDiff3 can replace cleardiffmrg from clearcase. But not all functions.
|
joachim99@8
|
100 if ( isOptionUsed( "directory", argc,argv ) )
|
joachim99@8
|
101 {
|
joachim99@8
|
102 return ::_spawnvp(_P_WAIT , "cleardiffmrg_orig", argv );
|
joachim99@8
|
103 }
|
joachim99@58
|
104
|
joachim99@8
|
105 #endif
|
joachim99@8
|
106 QApplication::setColorSpec( QApplication::ManyColor ); // Grab all 216 colors
|
joachim99@8
|
107
|
joachim99@8
|
108 KAboutData aboutData( "kdiff3", I18N_NOOP("KDiff3"),
|
joachim99@8
|
109 VERSION, description, KAboutData::License_GPL,
|
joachim99@53
|
110 "(c) 2002-2004 Joachim Eibl", 0, "http://kdiff3.sourceforge.net/", "joachim.eibl@gmx.de");
|
joachim99@8
|
111 aboutData.addAuthor("Joachim Eibl",0, "joachim.eibl@gmx.de");
|
joachim99@66
|
112 aboutData.addCredit("Eike Sauer", "Bugfixes, Debian package maintainer" );
|
joachim99@66
|
113 aboutData.addCredit("Sebastien Fricker", "Windows installer" );
|
joachim99@66
|
114 aboutData.addCredit("Stephan Binner", "i18n-help", "binner@kde.org" );
|
joachim99@66
|
115 aboutData.addCredit("Stefan Partheymueller", "Clipboard-patch" );
|
joachim99@66
|
116 aboutData.addCredit("David Faure", "KIO-Help", "faure@kde.org" );
|
joachim99@66
|
117 aboutData.addCredit("Bernd Gehrmann", "Class CvsIgnoreList from Cervisia" );
|
joachim99@66
|
118 aboutData.addCredit("Andre Woebbeking", "Class StringMatcher" );
|
joachim99@66
|
119 aboutData.addCredit("Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, Len Tower", "GNU-Diffutils");
|
joachim99@66
|
120 aboutData.addCredit(I18N_NOOP("+ Many thanks to those who reported bugs and contributed ideas!"));
|
joachim99@66
|
121
|
joachim99@66
|
122
|
joachim99@8
|
123 KCmdLineArgs::init( argc, argv, &aboutData );
|
joachim99@8
|
124 KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
|
joachim99@8
|
125
|
joachim99@53
|
126 KApplication app;
|
joachim99@53
|
127 #ifdef KREPLACEMENTS_H
|
joachim99@66
|
128 QString locale;
|
joachim99@66
|
129
|
joachim99@66
|
130 locale = app.config()->readEntry("Language", "Auto");
|
joachim99@66
|
131 int spacePos = locale.find(' ');
|
joachim99@66
|
132 if (spacePos>0) locale = locale.left(spacePos);
|
joachim99@53
|
133 QTranslator kdiff3Translator( 0 );
|
joachim99@53
|
134 QTranslator qtTranslator( 0 );
|
joachim99@66
|
135 if (locale != "en_orig")
|
joachim99@66
|
136 {
|
joachim99@66
|
137 if ( locale == "Auto" || locale.isEmpty() )
|
joachim99@66
|
138 locale = QTextCodec::locale();
|
joachim99@66
|
139
|
joachim99@66
|
140 QString translationDir = getTranslationDir();
|
joachim99@66
|
141 kdiff3Translator.load( QString("kdiff3_")+locale, translationDir );
|
joachim99@66
|
142 app.installTranslator( &kdiff3Translator );
|
joachim99@66
|
143
|
joachim99@66
|
144 qtTranslator.load( QString("qt_")+locale, translationDir );
|
joachim99@66
|
145 app.installTranslator( &qtTranslator );
|
joachim99@66
|
146 }
|
joachim99@53
|
147 #endif
|
joachim99@8
|
148
|
joachim99@8
|
149 if (app.isRestored())
|
joachim99@8
|
150 {
|
joachim99@8
|
151 RESTORE(KDiff3Shell);
|
joachim99@8
|
152 }
|
joachim99@8
|
153 else
|
joachim99@8
|
154 {
|
joachim99@8
|
155 new KDiff3Shell();
|
joachim99@8
|
156 }
|
joachim99@8
|
157
|
joachim99@8
|
158 return app.exec();
|
joachim99@8
|
159 }
|
joachim99@53
|
160
|
joachim99@53
|
161 // Suppress warning with --enable-final
|
joachim99@53
|
162 #undef VERSION
|