22 #include <kstandarddirs.h>
24 #include <kcmdlineargs.h>
25 #include <kaboutdata.h>
28 #include <kinstance.h>
29 #include <kstartupinfo.h>
30 #include <dcopclient.h>
34 #include <tqtextcodec.h>
38 static KCmdLineOptions options[] =
41 {
"start <name>", I18N_NOOP(
"Start Kate with a given session"), 0 },
43 {
"use", I18N_NOOP(
"Use a already running kate instance (if possible)"), 0 },
45 {
"pid <pid>", I18N_NOOP(
"Only try to reuse kate instance with this pid"), 0 },
47 {
"encoding <name>", I18N_NOOP(
"Set encoding for the file to open"), 0 },
49 {
"line <line>", I18N_NOOP(
"Navigate to this line"), 0 },
51 {
"column <column>", I18N_NOOP(
"Navigate to this column"), 0 },
53 {
"stdin", I18N_NOOP(
"Read the contents of stdin"), 0 },
54 {
"+[URL]", I18N_NOOP(
"Document to open"), 0 },
58 extern "C" KDE_EXPORT
int kdemain(
int argc,
char **argv )
63 KAboutData aboutData (
"kate", I18N_NOOP(
"Kate"), kateVersion.latin1(),
64 I18N_NOOP(
"Kate - Advanced Text Editor" ), KAboutData::License_LGPL_V2,
65 I18N_NOOP(
"(c) 2000-2005 The Kate Authors" ), 0,
"http://kate.kde.org");
67 aboutData.addAuthor (
"Christoph Cullmann", I18N_NOOP(
"Maintainer"),
"cullmann@kde.org",
"http://www.babylon2k.de");
68 aboutData.addAuthor (
"Anders Lund", I18N_NOOP(
"Core Developer"),
"anders@alweb.dk",
"http://www.alweb.dk");
69 aboutData.addAuthor (
"Joseph Wenninger", I18N_NOOP(
"Core Developer"),
"jowenn@kde.org",
"http://stud3.tuwien.ac.at/~e9925371");
70 aboutData.addAuthor (
"Hamish Rodda",I18N_NOOP(
"Core Developer"),
"rodda@kde.org");
71 aboutData.addAuthor (
"Waldo Bastian", I18N_NOOP(
"The cool buffersystem" ),
"bastian@kde.org" );
72 aboutData.addAuthor (
"Charles Samuels", I18N_NOOP(
"The Editing Commands"),
"charles@kde.org");
73 aboutData.addAuthor (
"Matt Newell", I18N_NOOP(
"Testing, ..."),
"newellm@proaxis.com");
74 aboutData.addAuthor (
"Michael Bartl", I18N_NOOP(
"Former Core Developer"),
"michael.bartl1@chello.at");
75 aboutData.addAuthor (
"Michael McCallum", I18N_NOOP(
"Core Developer"),
"gholam@xtra.co.nz");
76 aboutData.addAuthor (
"Jochen Wilhemly", I18N_NOOP(
"KWrite Author" ),
"digisnap@cs.tu-berlin.de" );
77 aboutData.addAuthor (
"Michael Koch",I18N_NOOP(
"KWrite port to KParts"),
"koch@kde.org");
78 aboutData.addAuthor (
"Christian Gebauer", 0,
"gebauer@kde.org" );
79 aboutData.addAuthor (
"Simon Hausmann", 0,
"hausmann@kde.org" );
80 aboutData.addAuthor (
"Glen Parker",I18N_NOOP(
"KWrite Undo History, Kspell integration"),
"glenebob@nwlink.com");
81 aboutData.addAuthor (
"Scott Manson",I18N_NOOP(
"KWrite XML Syntax highlighting support"),
"sdmanson@alltel.net");
82 aboutData.addAuthor (
"John Firebaugh",I18N_NOOP(
"Patches and more"),
"jfirebaugh@kde.org");
83 aboutData.addAuthor (
"Dominik Haumann", I18N_NOOP(
"Developer & Highlight wizard"),
"dhdev@gmx.de");
85 aboutData.addCredit (
"Matteo Merli",I18N_NOOP(
"Highlighting for RPM Spec-Files, Perl, Diff and more"),
"merlim@libero.it");
86 aboutData.addCredit (
"Rocky Scaletta",I18N_NOOP(
"Highlighting for VHDL"),
"rocky@purdue.edu");
87 aboutData.addCredit (
"Yury Lebedev",I18N_NOOP(
"Highlighting for SQL"),
"");
88 aboutData.addCredit (
"Chris Ross",I18N_NOOP(
"Highlighting for Ferite"),
"");
89 aboutData.addCredit (
"Nick Roux",I18N_NOOP(
"Highlighting for ILERPG"),
"");
90 aboutData.addCredit (
"Carsten Niehaus", I18N_NOOP(
"Highlighting for LaTeX"),
"");
91 aboutData.addCredit (
"Per Wigren", I18N_NOOP(
"Highlighting for Makefiles, Python"),
"");
92 aboutData.addCredit (
"Jan Fritz", I18N_NOOP(
"Highlighting for Python"),
"");
93 aboutData.addCredit (
"Daniel Naber",
"",
"");
94 aboutData.addCredit (
"Roland Pabel",I18N_NOOP(
"Highlighting for Scheme"),
"");
95 aboutData.addCredit (
"Cristi Dumitrescu",I18N_NOOP(
"PHP Keyword/Datatype list"),
"");
96 aboutData.addCredit (
"Carsten Pfeiffer", I18N_NOOP(
"Very nice help"),
"");
97 aboutData.addCredit (I18N_NOOP(
"All people who have contributed and I have forgotten to mention"),
"",
"");
99 aboutData.setTranslator(I18N_NOOP2(
"NAME OF TRANSLATORS",
"Your names"), I18N_NOOP2(
"EMAIL OF TRANSLATORS",
"Your emails"));
102 KCmdLineArgs::init (argc, argv, &aboutData);
103 KCmdLineArgs::addCmdLineOptions (options);
104 KCmdLineArgs::addTempFileOption();
105 KateApp::addCmdLineOptions ();
108 KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
111 if ( args->isSet(
"use") || (::getenv(
"KATE_PID")!=0) )
117 QCStringList allClients = client.registeredApplications();
122 if ( args->isSet(
"start") )
124 for (
unsigned int i=0; i < allClients.count(); i++)
126 if (allClients[i] ==
"kate" || allClients[i].left(5) ==
"kate-")
128 DCOPRef ref( allClients[i],
"KateApplication" );
129 TQString s = ref.call(
"session" );
130 if ( TQString(args->getOption(
"start")) == s )
132 kateApp = allClients[i];
138 else if ( (args->isSet(
"pid")) || (::getenv(
"KATE_PID") !=0 ) )
141 if ( args->isSet(
"pid") )
142 tryApp = args->getOption(
"pid");
144 tryApp = ::getenv(
"KATE_PID");
146 if ( client.isApplicationRegistered( tryApp.prepend(
"kate-") ) )
151 for (
unsigned int i=0; i < allClients.count(); ++i)
153 if (allClients[i] ==
"kate" || allClients[i].left(5) ==
"kate-")
155 kateApp = allClients[i];
162 if (!kateApp.isEmpty())
164 kdDebug () <<
"kate app: " << kateApp << endl;
166 client.registerAs(
"kate" );
168 DCOPRef kRef (kateApp,
"KateApplication");
170 if (args->isSet (
"start"))
171 kRef.call(
"activateSession", TQString (args->getOption(
"start")) );
173 TQString enc = args->isSet(
"encoding") ? args->getOption(
"encoding") : TQCString(
"");
175 bool tempfileSet = KCmdLineArgs::isTempFileSet();
177 for (
int z=0; z<args->count(); z++)
178 kRef.call(
"openURL", args->url(z), enc, tempfileSet );
180 if( args->isSet(
"stdin" ) )
182 TQTextIStream input(stdin);
185 TQTextCodec *codec = args->isSet(
"encoding") ? TQTextCodec::codecForName(args->getOption(
"encoding")) : 0;
188 input.setCodec (codec);
195 line = input.readLine();
196 text.append( line +
"\n" );
197 }
while( !line.isNull() );
199 kRef.call(
"openInput", text );
206 if (args->isSet (
"line"))
208 line = args->getOption (
"line").toInt();
212 if (args->isSet (
"column"))
214 column = args->getOption (
"column").toInt();
219 kRef.call(
"setCursor", line, column );
224 uint mwn = kRef.call(
"activeMainWindowNumber");
226 DCOPRef wRef( kateApp, TQCString(
"__KateMainWindow#") + smwn.setNum(mwn) );
227 if ( wRef.call(
"minimized") )
229 if ( wRef.call(
"maximized" ) )
230 wRef.call(
"maximize" );
232 wRef.call(
"restore");
250 wRef.call(
"raise" );
254 KStartupInfo::appStarted( );
264 if (app.shouldExit())