22 #include <kstandarddirs.h>
23 #include <tdelocale.h>
24 #include <tdecmdlineargs.h>
25 #include <tdeaboutdata.h>
26 #include <tdeglobal.h>
27 #include <tdeconfig.h>
28 #include <kinstance.h>
29 #include <tdestartupinfo.h>
30 #include <dcopclient.h>
34 #include <tqtextcodec.h>
38 static TDECmdLineOptions 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 {
"force-sdi", I18N_NOOP(
"Force single document mode if the MDI setting is enabled."), 0 },
47 {
"pid <pid>", I18N_NOOP(
"Only try to reuse kate instance with this pid"), 0 },
49 {
"encoding <name>", I18N_NOOP(
"Set encoding for the file to open"), 0 },
51 {
"line <line>", I18N_NOOP(
"Navigate to this line"), 0 },
53 {
"column <column>", I18N_NOOP(
"Navigate to this column"), 0 },
55 {
"stdin", I18N_NOOP(
"Read the contents of stdin"), 0 },
56 {
"+[URL]", I18N_NOOP(
"Document to open"), 0 },
60 extern "C" TDE_EXPORT
int kdemain(
int argc,
char **argv )
62 TDEConfig * config = NULL;
63 bool alwaysUseInstance;
67 TDEAboutData aboutData (
"kate", I18N_NOOP(
"Kate"), kateVersion.latin1(),
68 I18N_NOOP(
"Kate - Advanced Text Editor" ), TDEAboutData::License_LGPL_V2,
69 I18N_NOOP(
"(c) 2000-2005 The Kate Authors" ), 0);
71 aboutData.addAuthor (
"Christoph Cullmann", I18N_NOOP(
"Maintainer"),
"cullmann@kde.org",
"http://www.babylon2k.de");
72 aboutData.addAuthor (
"Anders Lund", I18N_NOOP(
"Core Developer"),
"anders@alweb.dk",
"http://www.alweb.dk");
73 aboutData.addAuthor (
"Joseph Wenninger", I18N_NOOP(
"Core Developer"),
"jowenn@kde.org",
"http://stud3.tuwien.ac.at/~e9925371");
74 aboutData.addAuthor (
"Hamish Rodda",I18N_NOOP(
"Core Developer"),
"rodda@kde.org");
75 aboutData.addAuthor (
"Waldo Bastian", I18N_NOOP(
"The cool buffersystem" ),
"bastian@kde.org" );
76 aboutData.addAuthor (
"Charles Samuels", I18N_NOOP(
"The Editing Commands"),
"charles@kde.org");
77 aboutData.addAuthor (
"Matt Newell", I18N_NOOP(
"Testing, ..."),
"newellm@proaxis.com");
78 aboutData.addAuthor (
"Michael Bartl", I18N_NOOP(
"Former Core Developer"),
"michael.bartl1@chello.at");
79 aboutData.addAuthor (
"Michael McCallum", I18N_NOOP(
"Core Developer"),
"gholam@xtra.co.nz");
80 aboutData.addAuthor (
"Jochen Wilhemly", I18N_NOOP(
"KWrite Author" ),
"digisnap@cs.tu-berlin.de" );
81 aboutData.addAuthor (
"Michael Koch",I18N_NOOP(
"KWrite port to KParts"),
"koch@kde.org");
82 aboutData.addAuthor (
"Christian Gebauer", 0,
"gebauer@kde.org" );
83 aboutData.addAuthor (
"Simon Hausmann", 0,
"hausmann@kde.org" );
84 aboutData.addAuthor (
"Glen Parker",I18N_NOOP(
"KWrite Undo History, Kspell integration"),
"glenebob@nwlink.com");
85 aboutData.addAuthor (
"Scott Manson",I18N_NOOP(
"KWrite XML Syntax highlighting support"),
"sdmanson@alltel.net");
86 aboutData.addAuthor (
"John Firebaugh",I18N_NOOP(
"Patches and more"),
"jfirebaugh@kde.org");
87 aboutData.addAuthor (
"Dominik Haumann", I18N_NOOP(
"Developer & Highlight wizard"),
"dhdev@gmx.de");
89 aboutData.addCredit (
"Matteo Merli",I18N_NOOP(
"Highlighting for RPM Spec-Files, Perl, Diff and more"),
"merlim@libero.it");
90 aboutData.addCredit (
"Rocky Scaletta",I18N_NOOP(
"Highlighting for VHDL"),
"rocky@purdue.edu");
91 aboutData.addCredit (
"Yury Lebedev",I18N_NOOP(
"Highlighting for SQL"),
"");
92 aboutData.addCredit (
"Chris Ross",I18N_NOOP(
"Highlighting for Ferite"),
"");
93 aboutData.addCredit (
"Nick Roux",I18N_NOOP(
"Highlighting for ILERPG"),
"");
94 aboutData.addCredit (
"Carsten Niehaus", I18N_NOOP(
"Highlighting for LaTeX"),
"");
95 aboutData.addCredit (
"Per Wigren", I18N_NOOP(
"Highlighting for Makefiles, Python"),
"");
96 aboutData.addCredit (
"Jan Fritz", I18N_NOOP(
"Highlighting for Python"),
"");
97 aboutData.addCredit (
"Daniel Naber",
"",
"");
98 aboutData.addCredit (
"Roland Pabel",I18N_NOOP(
"Highlighting for Scheme"),
"");
99 aboutData.addCredit (
"Cristi Dumitrescu",I18N_NOOP(
"PHP Keyword/Datatype list"),
"");
100 aboutData.addCredit (
"Carsten Pfeiffer", I18N_NOOP(
"Very nice help"),
"");
101 aboutData.addCredit (I18N_NOOP(
"All people who have contributed and I have forgotten to mention"),
"",
"");
103 aboutData.setTranslator(I18N_NOOP2(
"NAME OF TRANSLATORS",
"Your names"), I18N_NOOP2(
"EMAIL OF TRANSLATORS",
"Your emails"));
105 TDEInstance instance( &aboutData );
108 TDECmdLineArgs::init (argc, argv, &aboutData);
109 TDECmdLineArgs::addCmdLineOptions (options);
110 TDECmdLineArgs::addTempFileOption();
111 KateApp::addCmdLineOptions ();
114 TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs();
116 config = TDEGlobal::config();
117 config->setGroup(
"General");
118 alwaysUseInstance = config->readBoolEntry(
"UseInstance");
121 if ( ((args->isSet(
"use") || alwaysUseInstance) &&
122 !(args->isSet(
"force-sdi"))) || (::getenv(
"KATE_PID")!=0) )
128 QCStringList allClients = client.registeredApplications();
133 if ( args->isSet(
"start") )
135 for (
unsigned int i=0; i < allClients.count(); i++)
137 if (allClients[i] ==
"kate" || allClients[i].left(5) ==
"kate-")
139 DCOPRef ref( allClients[i],
"KateApplication" );
140 TQString s = ref.call(
"session" );
141 if ( TQString(args->getOption(
"start")) == s )
143 kateApp = allClients[i];
149 else if ( (args->isSet(
"pid")) || (::getenv(
"KATE_PID") !=0 ) )
152 if ( args->isSet(
"pid") )
153 tryApp = args->getOption(
"pid");
155 tryApp = ::getenv(
"KATE_PID");
157 if ( client.isApplicationRegistered( tryApp.prepend(
"kate-") ) )
162 for (
unsigned int i=0; i < allClients.count(); ++i)
164 if (allClients[i] ==
"kate" || allClients[i].left(5) ==
"kate-")
166 kateApp = allClients[i];
173 if (!kateApp.isEmpty())
175 kdDebug () <<
"kate app: " << kateApp << endl;
177 client.registerAs(
"kate" );
179 DCOPRef kRef (kateApp,
"KateApplication");
181 if (args->isSet (
"start"))
182 kRef.call(
"activateSession", TQString (args->getOption(
"start")) );
184 TQString enc = args->isSet(
"encoding") ? args->getOption(
"encoding") : TQCString(
"");
186 bool tempfileSet = TDECmdLineArgs::isTempFileSet();
188 for (
int z=0; z<args->count(); z++)
189 kRef.call(
"openURL", args->url(z), enc, tempfileSet );
191 if( args->isSet(
"stdin" ) )
193 TQTextIStream input(stdin);
196 TQTextCodec *codec = args->isSet(
"encoding") ? TQTextCodec::codecForName(args->getOption(
"encoding")) : 0;
199 input.setCodec (codec);
206 line = input.readLine();
207 text.append( line +
"\n" );
208 }
while( !line.isNull() );
210 kRef.call(
"openInput", text );
217 if (args->isSet (
"line"))
219 line = args->getOption (
"line").toInt();
223 if (args->isSet (
"column"))
225 column = args->getOption (
"column").toInt();
230 kRef.call(
"setCursor", line, column );
235 uint mwn = kRef.call(
"activeMainWindowNumber");
237 DCOPRef wRef( kateApp, TQCString(
"__KateMainWindow#") + smwn.setNum(mwn) );
238 if ( wRef.call(
"minimized") )
240 if ( wRef.call(
"maximized" ) )
241 wRef.call(
"maximize" );
243 wRef.call(
"restore");
245 wRef.call(
"setActiveWindowFocused" );
248 TDEStartupInfo::appStarted( );
258 if (app.shouldExit())
Kate Application This class represents the core kate application object.
static TQString kateVersion(bool fullVersion=true)
Returns the current Kate version (X.Y) or (X.Y.Z)