00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kateapp.h"
00021
00022 #include <kstandarddirs.h>
00023 #include <klocale.h>
00024 #include <kcmdlineargs.h>
00025 #include <kaboutdata.h>
00026 #include <kglobal.h>
00027 #include <kconfig.h>
00028 #include <kinstance.h>
00029 #include <kstartupinfo.h>
00030 #include <dcopclient.h>
00031 #include <dcopref.h>
00032 #include <kdebug.h>
00033
00034 #include <qtextcodec.h>
00035
00036 static KCmdLineOptions options[] =
00037 {
00038 { "s", 0 , 0 },
00039 { "start <name>", I18N_NOOP("Start Kate with a given session"), 0 },
00040 { "u", 0, 0 },
00041 { "use", I18N_NOOP("Use a already running kate instance (if possible)"), 0 },
00042 { "p", 0, 0 },
00043 { "pid <pid>", I18N_NOOP("Only try to reuse kate instance with this pid"), 0 },
00044 { "e", 0, 0 },
00045 { "encoding <name>", I18N_NOOP("Set encoding for the file to open"), 0 },
00046 { "l", 0, 0 },
00047 { "line <line>", I18N_NOOP("Navigate to this line"), 0 },
00048 { "c", 0, 0 },
00049 { "column <column>", I18N_NOOP("Navigate to this column"), 0 },
00050 { "i", 0, 0 },
00051 { "stdin", I18N_NOOP("Read the contents of stdin"), 0 },
00052 { "+[URL]", I18N_NOOP("Document to open"), 0 },
00053 KCmdLineLastOption
00054 };
00055
00056 extern "C" KDE_EXPORT int kdemain( int argc, char **argv )
00057 {
00058
00059 QString kateVersion = KateApp::kateVersion();
00060
00061 KAboutData aboutData ("kate", I18N_NOOP("Kate"), kateVersion.latin1(),
00062 I18N_NOOP( "Kate - Advanced Text Editor" ), KAboutData::License_LGPL_V2,
00063 I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0, "http://kate.kde.org");
00064
00065 aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "cullmann@kde.org", "http://www.babylon2k.de");
00066 aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "anders@alweb.dk", "http://www.alweb.dk");
00067 aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "jowenn@kde.org","http://stud3.tuwien.ac.at/~e9925371");
00068 aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "rodda@kde.org");
00069 aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "bastian@kde.org" );
00070 aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "charles@kde.org");
00071 aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "newellm@proaxis.com");
00072 aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "michael.bartl1@chello.at");
00073 aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "gholam@xtra.co.nz");
00074 aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "digisnap@cs.tu-berlin.de" );
00075 aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "koch@kde.org");
00076 aboutData.addAuthor ("Christian Gebauer", 0, "gebauer@kde.org" );
00077 aboutData.addAuthor ("Simon Hausmann", 0, "hausmann@kde.org" );
00078 aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "glenebob@nwlink.com");
00079 aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "sdmanson@alltel.net");
00080 aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "jfirebaugh@kde.org");
00081 aboutData.addAuthor ("Dominik Haumann", I18N_NOOP("Developer & Highlight wizard"), "dhdev@gmx.de");
00082
00083 aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "merlim@libero.it");
00084 aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "rocky@purdue.edu");
00085 aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),"");
00086 aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),"");
00087 aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),"");
00088 aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),"");
00089 aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),"");
00090 aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),"");
00091 aboutData.addCredit ("Daniel Naber","","");
00092 aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),"");
00093 aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),"");
00094 aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), "");
00095 aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"","");
00096
00097 aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));
00098
00099
00100 KCmdLineArgs::init (argc, argv, &aboutData);
00101 KCmdLineArgs::addCmdLineOptions (options);
00102 KateApp::addCmdLineOptions ();
00103
00104
00105 KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
00106
00107
00108 if (args->isSet("use"))
00109 {
00110 DCOPClient client;
00111 client.attach ();
00112
00113
00114 QCStringList allClients = client.registeredApplications();
00115
00116
00117 QCString kateApp;
00118
00119 if (args->isSet("pid"))
00120 {
00121 QCString tryApp = QCString ("kate-") + args->getOption("pid");
00122 if (client.isApplicationRegistered(tryApp))
00123 kateApp = tryApp;
00124 }
00125 else
00126 {
00127 for (unsigned int i=0; i < allClients.count(); ++i)
00128 {
00129 if (allClients[i] == "kate" || allClients[i].left(5) == "kate-")
00130 {
00131 kateApp = allClients[i];
00132 break;
00133 }
00134 }
00135 }
00136
00137
00138 if (!kateApp.isEmpty())
00139 {
00140 kdDebug () << "kate app: " << kateApp << endl;
00141
00142 client.registerAs( "kate" );
00143
00144 DCOPRef kRef (kateApp, "KateApplication");
00145
00146 if (args->isSet ("start"))
00147 kRef.call( "activateSession", QString (args->getOption("start")) );
00148
00149 QString enc = args->isSet("encoding") ? args->getOption("encoding") : QCString("");
00150
00151 for (int z=0; z<args->count(); z++)
00152 kRef.call( "openURL", args->url(z), enc );
00153
00154 if( args->isSet( "stdin" ) )
00155 {
00156 QTextIStream input(stdin);
00157
00158
00159 QTextCodec *codec = args->isSet("encoding") ? QTextCodec::codecForName(args->getOption("encoding")) : 0;
00160
00161 if (codec)
00162 input.setCodec (codec);
00163
00164 QString line;
00165 QString text;
00166
00167 do
00168 {
00169 line = input.readLine();
00170 text.append( line + "\n" );
00171 } while( !line.isNull() );
00172
00173 kRef.call( "openInput", text );
00174 }
00175
00176 int line = 0;
00177 int column = 0;
00178 bool nav = false;
00179
00180 if (args->isSet ("line"))
00181 {
00182 line = args->getOption ("line").toInt();
00183 nav = true;
00184 }
00185
00186 if (args->isSet ("column"))
00187 {
00188 column = args->getOption ("column").toInt();
00189 nav = true;
00190 }
00191
00192 if (nav)
00193 kRef.call( "setCursor", line, column );
00194
00195
00196
00197
00198 uint mwn = kRef.call("activeMainWindowNumber");
00199 QCString smwn;
00200 DCOPRef wRef( kateApp, QCString( "__KateMainWindow#") + smwn.setNum(mwn) );
00201 if ( wRef.call("minimized") )
00202 {
00203 if ( wRef.call( "maximized" ) )
00204 wRef.call( "maximize" );
00205 else
00206 wRef.call("restore");
00207 }
00208 wRef.call( "raise" );
00209
00210
00211 KStartupInfo::appStarted( );
00212
00213 return 0;
00214 }
00215 }
00216
00217
00218 KateApp app (args);
00219
00220
00221 if (app.shouldExit())
00222 {
00223 return 0;
00224 }
00225
00226
00227 return app.exec();
00228 }
00229
00230