From 2d84c9d3ad0aaea0620658024537d54e6a7939f4 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 26 Jan 2013 13:17:00 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- kjsembed/Makefile.am | 2 +- kjsembed/builtins/Makefile.am | 2 +- kjsembed/customobject_imp.cpp | 14 +- kjsembed/customobject_imp.h | 6 +- kjsembed/docs/ChangeLog | 2 +- kjsembed/docs/embedding/simple-embed/Makefile.am | 2 +- kjsembed/docs/embedding/simple-embed/README | 2 +- kjsembed/jsfactory.cpp | 6 +- kjsembed/kjsembedpart.h | 2 +- kjsembed/kscript/Makefile.am | 17 --- kjsembed/kscript/javascript.cpp | 111 --------------- kjsembed/kscript/javascript.desktop | 7 - kjsembed/kscript/javascript.h | 60 -------- kjsembed/kscript/swaptabs.desktop | 5 - kjsembed/kscript/swaptabs.js | 75 ---------- kjsembed/kscript/swaptabs.ui | 172 ----------------------- kjsembed/plugin/jsconsoleplugin.cpp | 2 +- kjsembed/plugin/jsconsoleplugin.h | 2 +- kjsembed/tdescript/Makefile.am | 17 +++ kjsembed/tdescript/javascript.cpp | 111 +++++++++++++++ kjsembed/tdescript/javascript.desktop | 7 + kjsembed/tdescript/javascript.h | 60 ++++++++ kjsembed/tdescript/swaptabs.desktop | 5 + kjsembed/tdescript/swaptabs.js | 75 ++++++++++ kjsembed/tdescript/swaptabs.ui | 172 +++++++++++++++++++++++ kjsembed/tests/test_kparts_args.js | 16 --- kjsembed/tests/test_tdeparts_args.js | 16 +++ 27 files changed, 484 insertions(+), 484 deletions(-) delete mode 100644 kjsembed/kscript/Makefile.am delete mode 100644 kjsembed/kscript/javascript.cpp delete mode 100644 kjsembed/kscript/javascript.desktop delete mode 100644 kjsembed/kscript/javascript.h delete mode 100644 kjsembed/kscript/swaptabs.desktop delete mode 100644 kjsembed/kscript/swaptabs.js delete mode 100644 kjsembed/kscript/swaptabs.ui create mode 100644 kjsembed/tdescript/Makefile.am create mode 100644 kjsembed/tdescript/javascript.cpp create mode 100644 kjsembed/tdescript/javascript.desktop create mode 100644 kjsembed/tdescript/javascript.h create mode 100644 kjsembed/tdescript/swaptabs.desktop create mode 100644 kjsembed/tdescript/swaptabs.js create mode 100644 kjsembed/tdescript/swaptabs.ui delete mode 100644 kjsembed/tests/test_kparts_args.js create mode 100644 kjsembed/tests/test_tdeparts_args.js (limited to 'kjsembed') diff --git a/kjsembed/Makefile.am b/kjsembed/Makefile.am index 3399ffb6..ad4b48f4 100644 --- a/kjsembed/Makefile.am +++ b/kjsembed/Makefile.am @@ -6,7 +6,7 @@ INCLUDES = -I$(QTDIR)/tools/designer/uilib -I$(srcdir)/.. $(all_includes) INCLUDES += -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -SUBDIRS = bindings builtins qtbindings . plugin plugins kscript stdlib cpptests docs +SUBDIRS = bindings builtins qtbindings . plugin plugins tdescript stdlib cpptests docs lib_LTLIBRARIES = libkjsembed.la bin_PROGRAMS = kjscmd diff --git a/kjsembed/builtins/Makefile.am b/kjsembed/builtins/Makefile.am index bf12fcf8..5be761af 100644 --- a/kjsembed/builtins/Makefile.am +++ b/kjsembed/builtins/Makefile.am @@ -11,7 +11,7 @@ libkjsembedbuiltins_la_SOURCES = stdaction_imp.cpp \ qdir_imp.cpp \ qfile_imp.cpp -libkjsembedbuiltins_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +libkjsembedbuiltins_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor libkjsembedbuiltins_la_LIBADD = $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_KPARTS) \ $(LIB_KFILE) -lkjs $(LIBSOCKET) diff --git a/kjsembed/customobject_imp.cpp b/kjsembed/customobject_imp.cpp index 04b20c68..ab006c77 100644 --- a/kjsembed/customobject_imp.cpp +++ b/kjsembed/customobject_imp.cpp @@ -45,7 +45,7 @@ #ifndef QT_ONLY -#include +#include #include #include @@ -435,14 +435,14 @@ KJS::Value CustomObjectImp::call( KJS::ExecState *exec, KJS::Object &self, const return KJS::Value(); break; case KHTMLPartSelectAll: - khtmlPartSelectAll( exec, self, args ); + tdehtmlPartSelectAll( exec, self, args ); return KJS::Value(); break; case KHTMLPartHasSelection: - return khtmlPartHasSelection( exec, self, args ); + return tdehtmlPartHasSelection( exec, self, args ); break; case KHTMLPartSelectedText: - return khtmlPartSelectedText( exec, self, args ); + return tdehtmlPartSelectedText( exec, self, args ); break; case KSystemTrayContextMenu: return ksystemtrayContextMenu( exec, self, args ); @@ -1094,7 +1094,7 @@ void CustomObjectImp::hboxSpacing( KJS::ExecState *exec, KJS::Object &, const KJ box->setSpacing( extractInt( exec, args, 0 ) ); } -void CustomObjectImp::khtmlPartSelectAll( KJS::ExecState *, KJS::Object &, const KJS::List & ) +void CustomObjectImp::tdehtmlPartSelectAll( KJS::ExecState *, KJS::Object &, const KJS::List & ) { #ifndef QT_ONLY @@ -1105,7 +1105,7 @@ void CustomObjectImp::khtmlPartSelectAll( KJS::ExecState *, KJS::Object &, const #endif // QT_ONLY } -KJS::Value CustomObjectImp::khtmlPartHasSelection( KJS::ExecState *, KJS::Object &, const KJS::List & ) +KJS::Value CustomObjectImp::tdehtmlPartHasSelection( KJS::ExecState *, KJS::Object &, const KJS::List & ) { #ifndef QT_ONLY @@ -1118,7 +1118,7 @@ KJS::Value CustomObjectImp::khtmlPartHasSelection( KJS::ExecState *, KJS::Object return KJS::Null(); } -KJS::Value CustomObjectImp::khtmlPartSelectedText( KJS::ExecState *, KJS::Object &, const KJS::List & ) +KJS::Value CustomObjectImp::tdehtmlPartSelectedText( KJS::ExecState *, KJS::Object &, const KJS::List & ) { #ifndef QT_ONLY diff --git a/kjsembed/customobject_imp.h b/kjsembed/customobject_imp.h index 600d7a15..2b11686c 100644 --- a/kjsembed/customobject_imp.h +++ b/kjsembed/customobject_imp.h @@ -172,9 +172,9 @@ public: void hboxSpacing( KJS::ExecState *exec, KJS::Object &, const KJS::List &args ); - void khtmlPartSelectAll( KJS::ExecState *, KJS::Object &, const KJS::List & ); - KJS::Value khtmlPartHasSelection( KJS::ExecState *, KJS::Object &, const KJS::List & ); - KJS::Value khtmlPartSelectedText( KJS::ExecState *, KJS::Object &, const KJS::List &args ); + void tdehtmlPartSelectAll( KJS::ExecState *, KJS::Object &, const KJS::List & ); + KJS::Value tdehtmlPartHasSelection( KJS::ExecState *, KJS::Object &, const KJS::List & ); + KJS::Value tdehtmlPartSelectedText( KJS::ExecState *, KJS::Object &, const KJS::List &args ); KJS::Value ksystemtrayContextMenu( KJS::ExecState *exec, KJS::Object&, const KJS::List &args ); KJS::Value ksystemtrayActionCollection( KJS::ExecState *exec, KJS::Object&, const KJS::List &args ); diff --git a/kjsembed/docs/ChangeLog b/kjsembed/docs/ChangeLog index 0c19114f..4b14af71 100644 --- a/kjsembed/docs/ChangeLog +++ b/kjsembed/docs/ChangeLog @@ -1351,7 +1351,7 @@ 2004-04-09 Friday 21:26 rich Added support for streaming data to a KPart, and an example of doing so. This - means you no longer need to have a temporary file to display stuff in khtml. + means you no longer need to have a temporary file to display stuff in tdehtml. 2004-04-09 Friday 20:22 rich diff --git a/kjsembed/docs/embedding/simple-embed/Makefile.am b/kjsembed/docs/embedding/simple-embed/Makefile.am index 2c9243a3..93d68f76 100644 --- a/kjsembed/docs/embedding/simple-embed/Makefile.am +++ b/kjsembed/docs/embedding/simple-embed/Makefile.am @@ -8,7 +8,7 @@ bin_PROGRAMS = embedjs INCLUDES = -I$(top_srcdir) $(all_includes) # the library search path. -embedjs_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor +embedjs_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor # the libraries to link against. embedjs_LDADD = $(LIB_KFILE) $(LIB_TDEPRINT) -lkjs $(top_builddir)/kjsembed/libkjsembed.la diff --git a/kjsembed/docs/embedding/simple-embed/README b/kjsembed/docs/embedding/simple-embed/README index 9c048f35..12f9642b 100644 --- a/kjsembed/docs/embedding/simple-embed/README +++ b/kjsembed/docs/embedding/simple-embed/README @@ -53,7 +53,7 @@ embeddable in other apps. For example, the kmplayer kpart can be called to play in your app. For more details, consult : -http://www-106.ibm.com/developerworks/library/l-kparts/ +http://www-106.ibm.com/developerworks/library/l-tdeparts/ http://developer.kde.org/documentation/tutorials/dot/writing-plugins.html http://developer.kde.org/documentation/tutorials/developing-a-plugin-structure/index.html diff --git a/kjsembed/jsfactory.cpp b/kjsembed/jsfactory.cpp index 5e6a22a7..d5be63a9 100644 --- a/kjsembed/jsfactory.cpp +++ b/kjsembed/jsfactory.cpp @@ -54,9 +54,9 @@ #include #include -#include -#include -#include +#include +#include +#include #endif // QT_ONLY diff --git a/kjsembed/kjsembedpart.h b/kjsembed/kjsembedpart.h index 84080138..3e4b3afb 100644 --- a/kjsembed/kjsembedpart.h +++ b/kjsembed/kjsembedpart.h @@ -25,7 +25,7 @@ #include #ifndef QT_ONLY -#include +#include #endif #include diff --git a/kjsembed/kscript/Makefile.am b/kjsembed/kscript/Makefile.am deleted file mode 100644 index 2efe1a79..00000000 --- a/kjsembed/kscript/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -INCLUDES = -I$(srcdir) -I$(top_srcdir) $(all_includes) - -kde_module_LTLIBRARIES = libjavascript.la - -libjavascript_la_SOURCES = javascript.cpp -libjavascript_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -lDCOP -ltdecore -ltdeui $(LIB_QT) -lkjs -ltdefx -no-undefined -avoid-version -libjavascript_la_LIBADD = -lkscript ../libkjsembed.la - - -METASOURCES = AUTO - -servicetypedir = $(kde_servicesdir) -servicetype_DATA = javascript.desktop - -katescriptsdir = $(kde_datadir)/kate/scripts -katescripts_DATA = swaptabs.desktop swaptabs.ui -katescripts_SCRIPTS = swaptabs.js diff --git a/kjsembed/kscript/javascript.cpp b/kjsembed/kscript/javascript.cpp deleted file mode 100644 index 22de1aef..00000000 --- a/kjsembed/kscript/javascript.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Ian Reinhart Geiser (geiseri@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "javascript.h" -#include -#include -#include -#include -#include -#include - -#include -#include -//using namespace KScriptInterface; -typedef KGenericFactory JavaScriptFactory; -K_EXPORT_COMPONENT_FACTORY( libjavascript, JavaScriptFactory( "JavaScript" ) ) - -JavaScript::JavaScript(KScriptClientInterface *parent, const char *name, const TQStringList &args ) -{ - ScriptClientInterface = parent; - m_jsembed = new KJSEmbed::KJSEmbedPart(this, "kjsembed_part"); - m_scriptLoc = ""; // arg1? - m_method = ""; // arg2? - m_jsembed->addObject( this, "KScriptInterface"); - m_jsembed->addObject( m_jsembed->view(), "console" ); -} - -JavaScript::~JavaScript() -{ -} - -TQString JavaScript::script() const -{ - return m_scriptLoc; -} - -void JavaScript::setScript( const TQString &scriptFile ) -{ - m_scriptLoc = scriptFile; -} - -void JavaScript::setScript( const TQString &scriptFile, const TQString &method ) -{ - m_scriptLoc = scriptFile; - m_method = method; -} - -void JavaScript::run(TQObject *context, const TQVariant &arg) -{ - TQVariant retVal; - if( context ) m_jsembed->addObject(context); - - m_jsembed->runFile(m_scriptLoc, m_jsembed->globalObject() ); - - if( !m_method.isEmpty() ) - { - KJS::List args; - args.append( KJSEmbed::convertToValue(m_jsembed->globalExec(), arg) ); - KJS::Value val = m_jsembed->callMethod(m_method, args); - retVal = KJSEmbed::convertToVariant(m_jsembed->globalExec(),val); - } - ScriptClientInterface->done(KScriptClientInterface::ResultSuccess, retVal); -} - -void JavaScript::writeLine( const TQString &msg ) -{ - ScriptClientInterface->output(msg); -} - -void JavaScript::writeWarning( const TQString &msg ) -{ - ScriptClientInterface->warning(msg); -} - -void JavaScript::writeError( const TQString &msg ) -{ - ScriptClientInterface->error(msg); -} - -void JavaScript::setProgress( int percent ) -{ - ScriptClientInterface->progress(percent); -} - -TQString JavaScript::appID() const -{ - return kapp->dcopClient()->appId(); -} - -void JavaScript::kill() -{ - // not sure what to do here.... -} - -#include "javascript.moc" diff --git a/kjsembed/kscript/javascript.desktop b/kjsembed/kscript/javascript.desktop deleted file mode 100644 index 1d612975..00000000 --- a/kjsembed/kscript/javascript.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Name=KJSEmbed Script Runner -Type=Service -X-TDE-Library=libjavascript -X-TDE-Script-Runner=JavaScript/kjs -ServiceTypes=KScriptRunner/KScriptRunner -Comment=Javascript scripts from inside the application. diff --git a/kjsembed/kscript/javascript.h b/kjsembed/kscript/javascript.h deleted file mode 100644 index 9ca87f24..00000000 --- a/kjsembed/kscript/javascript.h +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2003 Ian Reinhart Geiser (geiseri@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef __javascript_h__ -#define __javascript_h__ - -#include -#include -#include - -namespace KJSEmbed { - class KJSEmbedPart; -} - -//using namespace KScriptInterface; -class JavaScript : public KScriptInterface -{ - Q_OBJECT - TQ_PROPERTY( TQString appID READ appID ) - -public: - JavaScript(KScriptClientInterface *parent, const char *name, const TQStringList &args); - virtual ~JavaScript(); - TQString script() const; - void setScript( const TQString &scriptFile ); - void setScript( const TQString &scriptLibFile, const TQString &method ); - void run(TQObject *context = 0, const TQVariant &arg = 0); - void kill(); - - TQString appID() const; - -public slots: - void writeLine( const TQString &msg ); - void writeWarning( const TQString &msg ); - void writeError( const TQString &msg ); - void setProgress( int percent ); - -private: - KScriptClientInterface *ScriptClientInterface; - KJSEmbed::KJSEmbedPart *m_jsembed; - TQString m_method; - TQString m_scriptLoc; -}; - -#endif diff --git a/kjsembed/kscript/swaptabs.desktop b/kjsembed/kscript/swaptabs.desktop deleted file mode 100644 index ebe80ab9..00000000 --- a/kjsembed/kscript/swaptabs.desktop +++ /dev/null @@ -1,5 +0,0 @@ -[Desktop Entry] -Name=Swap tabs and spaces. -Comment=Swap tabs and space indentation in text. -Type=JavaScript/kjs -X-TDE-ScriptName=swaptabs.js diff --git a/kjsembed/kscript/swaptabs.js b/kjsembed/kscript/swaptabs.js deleted file mode 100644 index 20d19248..00000000 --- a/kjsembed/kscript/swaptabs.js +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env kjscmd -var appID = "kate"; -StdDirs.addResourceType("swaptabs", StdDirs.kde_default("data") + "/kate/scripts"); - -var client = new DCOPClient(); -var config = new Config( this, "swaptabsrc" ); -var documentIndex = client.call(appID, "KateDocumentManager", "activeDocumentNumber()"); -var ui = StdDirs.findResource("swaptabs","swaptabs.ui"); -var dlg = Factory.loadui(ui); - -// Load prefs -dlg.count.value = config.readNumEntry("Spaces", 8 ); -dlg.swap.selectedId = config.readNumEntry("Mode", 0 ); - -if( dlg.exec() == 1 ) -{ - var spaces = dlg.count.value; - - var sourceText; - var destText; - if( dlg.selection.checked ) - sourceText = client.call(appID, "SelectionInterface#" + documentIndex, "selection()"); - else - sourceText = client.call(appID, "EditInterface#" + documentIndex, "text()"); - - if( dlg.swap.selectedId == 0 ) - destText = replaceSpaces( spaces, sourceText ); - else - destText = replaceTabs( spaces, sourceText ); - - if( dlg.selection.checked ) - { - if( client.call(appID, "SelectionInterface#" + documentIndex, "hasSelection()") ) - { - var startLine = client.call(appID, "SelectionInterfaceExt#" + documentIndex, "selStartLine()"); - var startCol = client.call(appID, "SelectionInterfaceExt#" + documentIndex, "selStartCol()"); - client.call(appID, "SelectionInterface#" + documentIndex, "removeSelectedText()"); - client.call(appID, "SelectionInterface#" + documentIndex, "clearSelection()"); - client.call(appID, "EditInterface#" + documentIndex, "insertText(uint,uint,TQString)", startLine, startCol, destText); - } - else - { - alert("You must first select text."); - return false; - } - } - else - client.call(appID, "EditInterface#" + documentIndex, "setText(TQString)", destText ); - - // save prefs - config.writeNumEntry("Spaces", dlg.count.value ); - config.writeNumEntry("Mode", dlg.swap.selectedId ); -} - -function replaceSpaces( count, text ) -{ - var regExp = new RegExp("[ ]{"+count+","+count+"}", "g"); - regExp.mulitline = true; - - returnText = text.replace( regExp, "\t"); - return returnText; -} - -function replaceTabs( count, text ) -{ - - var regExp = new RegExp("[\t]","g"); - regExp.mulitline = true; - - var spaces = ""; - for( var idx = 0; idx < count; ++idx) - spaces += " "; - returnText = text.replace( regExp, spaces); - return returnText; -} diff --git a/kjsembed/kscript/swaptabs.ui b/kjsembed/kscript/swaptabs.ui deleted file mode 100644 index f7f5e973..00000000 --- a/kjsembed/kscript/swaptabs.ui +++ /dev/null @@ -1,172 +0,0 @@ - -MyDialog - - - MyDialog - - - - 0 - 0 - 219 - 176 - - - - Swap Tabs & Spaces - - - true - - - - unnamed - - - - layout2 - - - - unnamed - - - - textLabel1 - - - Number of spaces for a tab: - - - - - count - - - 4 - - - - - - - swap - - - Swap - - - 0 - - - - unnamed - - - - radioButton1 - - - Tabs for spaces - - - - - radioButton2 - - - Spaces for tabs - - - - - - - selection - - - Substitute only in current selection - - - - - Layout1 - - - - unnamed - - - 0 - - - 6 - - - - Horizontal Spacing2 - - - Horizontal - - - Expanding - - - - 20 - 20 - - - - - - buttonOk - - - &OK - - - - - - true - - - true - - - - - buttonCancel - - - &Cancel - - - - - - true - - - - - - - - - buttonOk - clicked() - MyDialog - accept() - - - buttonCancel - clicked() - MyDialog - reject() - - - - diff --git a/kjsembed/plugin/jsconsoleplugin.cpp b/kjsembed/plugin/jsconsoleplugin.cpp index 15e67506..c1e4026c 100644 --- a/kjsembed/plugin/jsconsoleplugin.cpp +++ b/kjsembed/plugin/jsconsoleplugin.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/kjsembed/plugin/jsconsoleplugin.h b/kjsembed/plugin/jsconsoleplugin.h index 18a17ed9..c8ea7aef 100644 --- a/kjsembed/plugin/jsconsoleplugin.h +++ b/kjsembed/plugin/jsconsoleplugin.h @@ -22,7 +22,7 @@ #ifndef KJSEMBEDJSCONSOLEPLUGIN_H #define KJSEMBEDJSCONSOLEPLUGIN_H -#include +#include class KJSEmbedPart; diff --git a/kjsembed/tdescript/Makefile.am b/kjsembed/tdescript/Makefile.am new file mode 100644 index 00000000..adcf52d4 --- /dev/null +++ b/kjsembed/tdescript/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = -I$(srcdir) -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libjavascript.la + +libjavascript_la_SOURCES = javascript.cpp +libjavascript_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -lDCOP -ltdecore -ltdeui $(LIB_QT) -lkjs -ltdefx -no-undefined -avoid-version +libjavascript_la_LIBADD = -ltdescript ../libkjsembed.la + + +METASOURCES = AUTO + +servicetypedir = $(kde_servicesdir) +servicetype_DATA = javascript.desktop + +katescriptsdir = $(kde_datadir)/kate/scripts +katescripts_DATA = swaptabs.desktop swaptabs.ui +katescripts_SCRIPTS = swaptabs.js diff --git a/kjsembed/tdescript/javascript.cpp b/kjsembed/tdescript/javascript.cpp new file mode 100644 index 00000000..22de1aef --- /dev/null +++ b/kjsembed/tdescript/javascript.cpp @@ -0,0 +1,111 @@ +/* This file is part of the KDE project + Copyright (C) 2003 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "javascript.h" +#include +#include +#include +#include +#include +#include + +#include +#include +//using namespace KScriptInterface; +typedef KGenericFactory JavaScriptFactory; +K_EXPORT_COMPONENT_FACTORY( libjavascript, JavaScriptFactory( "JavaScript" ) ) + +JavaScript::JavaScript(KScriptClientInterface *parent, const char *name, const TQStringList &args ) +{ + ScriptClientInterface = parent; + m_jsembed = new KJSEmbed::KJSEmbedPart(this, "kjsembed_part"); + m_scriptLoc = ""; // arg1? + m_method = ""; // arg2? + m_jsembed->addObject( this, "KScriptInterface"); + m_jsembed->addObject( m_jsembed->view(), "console" ); +} + +JavaScript::~JavaScript() +{ +} + +TQString JavaScript::script() const +{ + return m_scriptLoc; +} + +void JavaScript::setScript( const TQString &scriptFile ) +{ + m_scriptLoc = scriptFile; +} + +void JavaScript::setScript( const TQString &scriptFile, const TQString &method ) +{ + m_scriptLoc = scriptFile; + m_method = method; +} + +void JavaScript::run(TQObject *context, const TQVariant &arg) +{ + TQVariant retVal; + if( context ) m_jsembed->addObject(context); + + m_jsembed->runFile(m_scriptLoc, m_jsembed->globalObject() ); + + if( !m_method.isEmpty() ) + { + KJS::List args; + args.append( KJSEmbed::convertToValue(m_jsembed->globalExec(), arg) ); + KJS::Value val = m_jsembed->callMethod(m_method, args); + retVal = KJSEmbed::convertToVariant(m_jsembed->globalExec(),val); + } + ScriptClientInterface->done(KScriptClientInterface::ResultSuccess, retVal); +} + +void JavaScript::writeLine( const TQString &msg ) +{ + ScriptClientInterface->output(msg); +} + +void JavaScript::writeWarning( const TQString &msg ) +{ + ScriptClientInterface->warning(msg); +} + +void JavaScript::writeError( const TQString &msg ) +{ + ScriptClientInterface->error(msg); +} + +void JavaScript::setProgress( int percent ) +{ + ScriptClientInterface->progress(percent); +} + +TQString JavaScript::appID() const +{ + return kapp->dcopClient()->appId(); +} + +void JavaScript::kill() +{ + // not sure what to do here.... +} + +#include "javascript.moc" diff --git a/kjsembed/tdescript/javascript.desktop b/kjsembed/tdescript/javascript.desktop new file mode 100644 index 00000000..1d612975 --- /dev/null +++ b/kjsembed/tdescript/javascript.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=KJSEmbed Script Runner +Type=Service +X-TDE-Library=libjavascript +X-TDE-Script-Runner=JavaScript/kjs +ServiceTypes=KScriptRunner/KScriptRunner +Comment=Javascript scripts from inside the application. diff --git a/kjsembed/tdescript/javascript.h b/kjsembed/tdescript/javascript.h new file mode 100644 index 00000000..9ca87f24 --- /dev/null +++ b/kjsembed/tdescript/javascript.h @@ -0,0 +1,60 @@ +/* This file is part of the KDE project + Copyright (C) 2003 Ian Reinhart Geiser (geiseri@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef __javascript_h__ +#define __javascript_h__ + +#include +#include +#include + +namespace KJSEmbed { + class KJSEmbedPart; +} + +//using namespace KScriptInterface; +class JavaScript : public KScriptInterface +{ + Q_OBJECT + TQ_PROPERTY( TQString appID READ appID ) + +public: + JavaScript(KScriptClientInterface *parent, const char *name, const TQStringList &args); + virtual ~JavaScript(); + TQString script() const; + void setScript( const TQString &scriptFile ); + void setScript( const TQString &scriptLibFile, const TQString &method ); + void run(TQObject *context = 0, const TQVariant &arg = 0); + void kill(); + + TQString appID() const; + +public slots: + void writeLine( const TQString &msg ); + void writeWarning( const TQString &msg ); + void writeError( const TQString &msg ); + void setProgress( int percent ); + +private: + KScriptClientInterface *ScriptClientInterface; + KJSEmbed::KJSEmbedPart *m_jsembed; + TQString m_method; + TQString m_scriptLoc; +}; + +#endif diff --git a/kjsembed/tdescript/swaptabs.desktop b/kjsembed/tdescript/swaptabs.desktop new file mode 100644 index 00000000..ebe80ab9 --- /dev/null +++ b/kjsembed/tdescript/swaptabs.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Name=Swap tabs and spaces. +Comment=Swap tabs and space indentation in text. +Type=JavaScript/kjs +X-TDE-ScriptName=swaptabs.js diff --git a/kjsembed/tdescript/swaptabs.js b/kjsembed/tdescript/swaptabs.js new file mode 100644 index 00000000..20d19248 --- /dev/null +++ b/kjsembed/tdescript/swaptabs.js @@ -0,0 +1,75 @@ +#!/usr/bin/env kjscmd +var appID = "kate"; +StdDirs.addResourceType("swaptabs", StdDirs.kde_default("data") + "/kate/scripts"); + +var client = new DCOPClient(); +var config = new Config( this, "swaptabsrc" ); +var documentIndex = client.call(appID, "KateDocumentManager", "activeDocumentNumber()"); +var ui = StdDirs.findResource("swaptabs","swaptabs.ui"); +var dlg = Factory.loadui(ui); + +// Load prefs +dlg.count.value = config.readNumEntry("Spaces", 8 ); +dlg.swap.selectedId = config.readNumEntry("Mode", 0 ); + +if( dlg.exec() == 1 ) +{ + var spaces = dlg.count.value; + + var sourceText; + var destText; + if( dlg.selection.checked ) + sourceText = client.call(appID, "SelectionInterface#" + documentIndex, "selection()"); + else + sourceText = client.call(appID, "EditInterface#" + documentIndex, "text()"); + + if( dlg.swap.selectedId == 0 ) + destText = replaceSpaces( spaces, sourceText ); + else + destText = replaceTabs( spaces, sourceText ); + + if( dlg.selection.checked ) + { + if( client.call(appID, "SelectionInterface#" + documentIndex, "hasSelection()") ) + { + var startLine = client.call(appID, "SelectionInterfaceExt#" + documentIndex, "selStartLine()"); + var startCol = client.call(appID, "SelectionInterfaceExt#" + documentIndex, "selStartCol()"); + client.call(appID, "SelectionInterface#" + documentIndex, "removeSelectedText()"); + client.call(appID, "SelectionInterface#" + documentIndex, "clearSelection()"); + client.call(appID, "EditInterface#" + documentIndex, "insertText(uint,uint,TQString)", startLine, startCol, destText); + } + else + { + alert("You must first select text."); + return false; + } + } + else + client.call(appID, "EditInterface#" + documentIndex, "setText(TQString)", destText ); + + // save prefs + config.writeNumEntry("Spaces", dlg.count.value ); + config.writeNumEntry("Mode", dlg.swap.selectedId ); +} + +function replaceSpaces( count, text ) +{ + var regExp = new RegExp("[ ]{"+count+","+count+"}", "g"); + regExp.mulitline = true; + + returnText = text.replace( regExp, "\t"); + return returnText; +} + +function replaceTabs( count, text ) +{ + + var regExp = new RegExp("[\t]","g"); + regExp.mulitline = true; + + var spaces = ""; + for( var idx = 0; idx < count; ++idx) + spaces += " "; + returnText = text.replace( regExp, spaces); + return returnText; +} diff --git a/kjsembed/tdescript/swaptabs.ui b/kjsembed/tdescript/swaptabs.ui new file mode 100644 index 00000000..f7f5e973 --- /dev/null +++ b/kjsembed/tdescript/swaptabs.ui @@ -0,0 +1,172 @@ + +MyDialog + + + MyDialog + + + + 0 + 0 + 219 + 176 + + + + Swap Tabs & Spaces + + + true + + + + unnamed + + + + layout2 + + + + unnamed + + + + textLabel1 + + + Number of spaces for a tab: + + + + + count + + + 4 + + + + + + + swap + + + Swap + + + 0 + + + + unnamed + + + + radioButton1 + + + Tabs for spaces + + + + + radioButton2 + + + Spaces for tabs + + + + + + + selection + + + Substitute only in current selection + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonOk + + + &OK + + + + + + true + + + true + + + + + buttonCancel + + + &Cancel + + + + + + true + + + + + + + + + buttonOk + clicked() + MyDialog + accept() + + + buttonCancel + clicked() + MyDialog + reject() + + + + diff --git a/kjsembed/tests/test_kparts_args.js b/kjsembed/tests/test_kparts_args.js deleted file mode 100644 index a719590a..00000000 --- a/kjsembed/tests/test_kparts_args.js +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env kjscmd - -var mw = new KMainWindow(); -var box = new TQVBox( mw ); -mw.setCentralWidget( box ); - -var args = [ "WIDTH=300", "HEIGHT=250", "CODE=TestApplet.class", "CLASSPATH=.", "TEXT=Foobar" ] -var part = Factory.createROPart( "application/x-java-applet", - "'KParts/ReadOnlyPart' in ServiceTypes", - box, "foobar", - args ); - -part.openURL( "./TestApplet.class" ); - -mw.show(); -application.exec(); diff --git a/kjsembed/tests/test_tdeparts_args.js b/kjsembed/tests/test_tdeparts_args.js new file mode 100644 index 00000000..a719590a --- /dev/null +++ b/kjsembed/tests/test_tdeparts_args.js @@ -0,0 +1,16 @@ +#!/usr/bin/env kjscmd + +var mw = new KMainWindow(); +var box = new TQVBox( mw ); +mw.setCentralWidget( box ); + +var args = [ "WIDTH=300", "HEIGHT=250", "CODE=TestApplet.class", "CLASSPATH=.", "TEXT=Foobar" ] +var part = Factory.createROPart( "application/x-java-applet", + "'KParts/ReadOnlyPart' in ServiceTypes", + box, "foobar", + args ); + +part.openURL( "./TestApplet.class" ); + +mw.show(); +application.exec(); -- cgit v1.2.3