• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katefactory.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001-2004 Christoph Cullmann <cullmann@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "config.h"
20 #include "katefactory.h"
21 
22 #include "katedocument.h"
23 #include "kateview.h"
24 #include "katerenderer.h"
25 #include "katecmds.h"
26 #include "katefiletype.h"
27 #include "kateschema.h"
28 #include "katesearch.h"
29 #include "kateconfig.h"
30 #ifndef TQ_WS_WIN //todo
31 #include "katejscript.h"
32 #endif
33 #include "kateluaindentscript.h"
34 #include "../interfaces/katecmd.h"
35 
36 #include <kvmallocator.h>
37 #include <tdelocale.h>
38 #include <kdirwatch.h>
39 #include <kstaticdeleter.h>
40 
41 #include <tqapplication.h>
42 
46 class KateFactoryPublic : public KParts::Factory
47 {
48  public:
59  KParts::Part *createPartObject ( TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const char *classname, const TQStringList &args )
60  {
61  return KateFactory::self()->createPartObject (parentWidget, widgetName, parent, name, classname, args);
62  }
63 };
64 
65 K_EXPORT_COMPONENT_FACTORY( libkatepart, KateFactoryPublic )
66 
67 KateFactory *KateFactory::s_self = 0;
68 
69 KateFactory::KateFactory ()
70  : m_aboutData ("katepart", I18N_NOOP("Kate Part"), KATEPART_VERSION,
71  I18N_NOOP( "Embeddable editor component" ), TDEAboutData::License_LGPL_V2,
72  I18N_NOOP( "(c) 2000-2004 The Kate Authors" ), 0, "http://kate-editor.org/")
73  , m_instance (&m_aboutData)
74  , m_plugins (TDETrader::self()->query("KTextEditor/Plugin"))
75  , m_jscript (0)
76 {
77  // set s_self
78  s_self = this;
79 
80  //
81  // fill about data
82  //
83  m_aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "cullmann@kde.org", "http://www.babylon2k.de");
84  m_aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "anders@alweb.dk", "http://www.alweb.dk");
85  m_aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "jowenn@kde.org","http://stud3.tuwien.ac.at/~e9925371");
86  m_aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "rodda@kde.org");
87  m_aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "bastian@kde.org" );
88  m_aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "charles@kde.org");
89  m_aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "newellm@proaxis.com");
90  m_aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "michael.bartl1@chello.at");
91  m_aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "gholam@xtra.co.nz");
92  m_aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "digisnap@cs.tu-berlin.de" );
93  m_aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "koch@kde.org");
94  m_aboutData.addAuthor ("Christian Gebauer", 0, "gebauer@kde.org" );
95  m_aboutData.addAuthor ("Simon Hausmann", 0, "hausmann@kde.org" );
96  m_aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "glenebob@nwlink.com");
97  m_aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "sdmanson@alltel.net");
98  m_aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "jfirebaugh@kde.org");
99  m_aboutData.addAuthor ("Dominik Haumann", I18N_NOOP("Developer & Highlight wizard"), "dhdev@gmx.de");
100 
101  m_aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "merlim@libero.it");
102  m_aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "rocky@purdue.edu");
103  m_aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),"");
104  m_aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),"");
105  m_aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),"");
106  m_aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),"");
107  m_aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),"");
108  m_aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),"");
109  m_aboutData.addCredit ("Daniel Naber","","");
110  m_aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),"");
111  m_aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),"");
112  m_aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), "");
113  m_aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"","");
114 
115  m_aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));
116 
117  //
118  // dir watch
119  //
120  m_dirWatch = new KDirWatch ();
121 
122  //
123  // filetype man
124  //
125  m_fileTypeManager = new KateFileTypeManager ();
126 
127  //
128  // schema man
129  //
130  m_schemaManager = new KateSchemaManager ();
131 
132  // config objects
133  m_documentConfig = new KateDocumentConfig ();
134  m_viewConfig = new KateViewConfig ();
135  m_rendererConfig = new KateRendererConfig ();
136 
137  // vm allocator
138  m_vm = new KVMAllocator ();
139 
140 #ifndef TQ_WS_WIN //todo
141  // create script man (search scripts) + register commands
142  m_jscriptManager = new KateJScriptManager ();
143  KateCmd::self()->registerCommand (m_jscriptManager);
144  m_indentScriptManagers.append(new KateIndentJScriptManager());
145 #else
146  m_jscriptManager = 0;
147 #endif
148 #ifdef HAVE_LUA
149  m_indentScriptManagers.append(new KateLUAIndentScriptManager());
150 #endif
151  //
152  // init the cmds
153  //
154  m_cmds.push_back (new KateCommands::CoreCommands());
155  m_cmds.push_back (new KateCommands::SedReplace ());
156  m_cmds.push_back (new KateCommands::Character ());
157  m_cmds.push_back (new KateCommands::Date ());
158  m_cmds.push_back (new SearchCommand());
159 
160  for ( TQValueList<Kate::Command *>::iterator it = m_cmds.begin(); it != m_cmds.end(); ++it )
161  KateCmd::self()->registerCommand (*it);
162 }
163 
164 KateFactory::~KateFactory()
165 {
166  /* ?hack? If MainApplication-Interface::quit is called by dcop the factory gets destroyed before all documents are destroyed eg in kwrite.
167  This could happen in other apps too. Since the documents try to unregister a new factory is created (in the ::self call) and registered with a
168  KStaticDeleter which causes a crash. That's why I ensure here that all documents are destroyed before the factory goes down (JOWENN)*/
169  while (KateDocument *doc=m_documents.first()) {
170  s_self=this; /* this is needed because the KStaticDeleter sets the global reference to 0, before it deletes the object it handles.
171  To prevent a crash again restore the factory pointer temporarily. (jowenn)*/
172  delete doc;
173  s_self=0;
174  }
175  /*another solution would be to set a flag in the documents, and inhibit calling of the deregistering methods, but I don't see a problem
176  if all created objects are deleted before their factory. If somebody sees a problem, let me know*/
177 
178  delete m_documentConfig;
179  delete m_viewConfig;
180  delete m_rendererConfig;
181 
182  delete m_fileTypeManager;
183  delete m_schemaManager;
184 
185  delete m_dirWatch;
186 
187  delete m_vm;
188 
189  for ( TQValueList<Kate::Command *>::iterator it = m_cmds.begin(); it != m_cmds.end(); ++it )
190  delete *it;
191 
192  // cu manager
193  delete m_jscriptManager;
194  m_indentScriptManagers.setAutoDelete(true);
195  // cu jscript
196  delete m_jscript;
197 }
198 
199 static KStaticDeleter<KateFactory> sdFactory;
200 
201 KateFactory *KateFactory::self ()
202 {
203  if (!s_self) {
204  sdFactory.setObject(s_self, new KateFactory ());
205  }
206  return s_self;
207 }
208 
209 KParts::Part *KateFactory::createPartObject ( TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const char *_classname, const TQStringList & )
210 {
211  TQCString classname( _classname );
212  bool bWantSingleView = ( classname != "KTextEditor::Document" && classname != "Kate::Document" );
213  bool bWantBrowserView = ( classname == "Browser/View" );
214  bool bWantReadOnly = (bWantBrowserView || ( classname == "KParts::ReadOnlyPart" ));
215 
216  KParts::ReadWritePart *part = new KateDocument (bWantSingleView, bWantBrowserView, bWantReadOnly, parentWidget, widgetName, parent, name);
217  part->setReadWrite( !bWantReadOnly );
218 
219  return part;
220 }
221 
222 void KateFactory::registerDocument ( KateDocument *doc )
223 {
224  m_documents.append( doc );
225 }
226 
227 void KateFactory::deregisterDocument ( KateDocument *doc )
228 {
229  m_documents.removeRef( doc );
230 }
231 
232 void KateFactory::registerView ( KateView *view )
233 {
234  m_views.append( view );
235 }
236 
237 void KateFactory::deregisterView ( KateView *view )
238 {
239  m_views.removeRef( view );
240 }
241 
242 void KateFactory::registerRenderer ( KateRenderer *renderer )
243 {
244  m_renderers.append( renderer );
245 }
246 
247 void KateFactory::deregisterRenderer ( KateRenderer *renderer )
248 {
249  m_renderers.removeRef( renderer );
250 }
251 
252 KateJScript *KateFactory::jscript ()
253 {
254 #ifndef TQ_WS_WIN //todo
255  if (m_jscript)
256  return m_jscript;
257 
258  return m_jscript = new KateJScript ();
259 #else
260  return 0;
261 #endif
262 }
263 
264 
265 KateIndentScript KateFactory::indentScript (const TQString &scriptname)
266 {
267  KateIndentScript result;
268  for(uint i=0;i<m_indentScriptManagers.count();i++)
269  {
270  result=m_indentScriptManagers.at(i)->script(scriptname);
271  if (!result.isNull()) return result;
272  }
273  return result;
274 }
KParts::Factory
KParts::Factory::createPartObject
virtual Part * createPartObject(TQWidget *parentWidget=0, const char *widgetName=0, TQObject *parent=0, const char *name=0, const char *classname="KParts::Part", const TQStringList &args=TQStringList())=0
KParts::Part
KParts::ReadWritePart
KParts::ReadWritePart::setReadWrite
virtual void setReadWrite(bool readwrite=true)
KStaticDeleter
KVMAllocator
KateCommands::Character
insert a unicode or ascii character base 9+1: 1234 hex: 0x1234 or x1234 octal: 01231
Definition: katecmds.h:130
KateCommands::CoreCommands
This Kate::Command provides access to a lot of the core functionality of kate part,...
Definition: katecmds.h:40
KateCommands::Date
insert the current date/time in the given format
Definition: katecmds.h:154
KateCommands::SedReplace
– Charles Samuels charles@kde.org Support vim/sed find and replace s/search/replace/ find search,...
Definition: katecmds.h:76
KateJScript
Whole Kate Part scripting in one classs Allow subclassing to allow specialized scripting engine for i...
Definition: katejscript.h:53
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:43
TDEAboutData
I18N_NOOP
#define I18N_NOOP(x)
tdelocale.h

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.1
This website is maintained by Timothy Pearson.