From 722ce1efbac31c61b1d4b13f7e075c9f311e3e73 Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Sun, 2 Mar 2014 20:05:33 +0100 Subject: Finish renaming tdevelop components --- lib/util/CMakeLists.txt | 8 +-- lib/util/Makefile.am | 18 +++--- lib/util/configwidgetproxy.cpp | 4 +- lib/util/configwidgetproxy.h | 8 +-- lib/util/filetemplate.cpp | 18 +++--- lib/util/filetemplate.h | 12 ++-- lib/util/kdeveditorutil.cpp | 89 ----------------------------- lib/util/kdeveditorutil.h | 67 ---------------------- lib/util/kdevjobtimer.cpp | 39 ------------- lib/util/kdevjobtimer.h | 40 ------------- lib/util/kdevshellwidget.cpp | 125 ----------------------------------------- lib/util/kdevshellwidget.h | 101 --------------------------------- lib/util/tdeveditorutil.cpp | 89 +++++++++++++++++++++++++++++ lib/util/tdeveditorutil.h | 67 ++++++++++++++++++++++ lib/util/tdevjobtimer.cpp | 39 +++++++++++++ lib/util/tdevjobtimer.h | 40 +++++++++++++ lib/util/tdevshellwidget.cpp | 125 +++++++++++++++++++++++++++++++++++++++++ lib/util/tdevshellwidget.h | 101 +++++++++++++++++++++++++++++++++ 18 files changed, 495 insertions(+), 495 deletions(-) delete mode 100644 lib/util/kdeveditorutil.cpp delete mode 100644 lib/util/kdeveditorutil.h delete mode 100644 lib/util/kdevjobtimer.cpp delete mode 100644 lib/util/kdevjobtimer.h delete mode 100644 lib/util/kdevshellwidget.cpp delete mode 100644 lib/util/kdevshellwidget.h create mode 100644 lib/util/tdeveditorutil.cpp create mode 100644 lib/util/tdeveditorutil.h create mode 100644 lib/util/tdevjobtimer.cpp create mode 100644 lib/util/tdevjobtimer.h create mode 100644 lib/util/tdevshellwidget.cpp create mode 100644 lib/util/tdevshellwidget.h (limited to 'lib/util') diff --git a/lib/util/CMakeLists.txt b/lib/util/CMakeLists.txt index 1eb17f35..0114b5ae 100644 --- a/lib/util/CMakeLists.txt +++ b/lib/util/CMakeLists.txt @@ -26,13 +26,13 @@ install( FILES DESTINATION ${INCLUDE_INSTALL_DIR}/tdevelop/util ) -##### kdevutil (static) ######################### +##### tdevutil (static) ######################### -tde_add_library( kdevutil STATIC_PIC AUTOMOC +tde_add_library( tdevutil STATIC_PIC AUTOMOC SOURCES blockingkprocess.cpp configwidgetproxy.cpp domutil.cpp execcommand.cpp filetemplate.cpp - kdeveditorutil.cpp kdevjobtimer.cpp - kdevshellwidget.cpp tdescriptactionmanager.cpp + tdeveditorutil.cpp tdevjobtimer.cpp + tdevshellwidget.cpp tdescriptactionmanager.cpp rurl.cpp settings.cpp urlutil.cpp ) diff --git a/lib/util/Makefile.am b/lib/util/Makefile.am index 8bf28091..52ededb0 100644 --- a/lib/util/Makefile.am +++ b/lib/util/Makefile.am @@ -1,10 +1,10 @@ INCLUDES = -I$(top_srcdir)/lib/compat -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/sourceinfo $(all_includes) -noinst_LTLIBRARIES = libkdevutil.la +noinst_LTLIBRARIES = libtdevutil.la -libkdevutil_la_SOURCES = blockingkprocess.cpp configwidgetproxy.cpp domutil.cpp \ - execcommand.cpp filetemplate.cpp kdeveditorutil.cpp kdevjobtimer.cpp \ - kdevshellwidget.cpp tdescriptactionmanager.cpp rurl.cpp settings.cpp urlutil.cpp +libtdevutil_la_SOURCES = blockingkprocess.cpp configwidgetproxy.cpp domutil.cpp \ + execcommand.cpp filetemplate.cpp tdeveditorutil.cpp tdevjobtimer.cpp \ + tdevshellwidget.cpp tdescriptactionmanager.cpp rurl.cpp settings.cpp urlutil.cpp METASOURCES = AUTO @@ -12,10 +12,10 @@ tdevelopincludedir = $(includedir)/tdevelop/util tdevelopinclude_HEADERS = domutil.h execcommand.h filetemplate.h urlutil.h \ configwidgetproxy.h rurl.h tdescriptactionmanager.h -DOXYGEN_REFERENCES = dcop interfaces tdecore tdefx tdeui tdehtml tdemdi tdeio kjs tdeparts tdeutils kdevextensions kdevinterfaces -DOXYGEN_PROJECTNAME = KDevelop Utility Library -DOXYGEN_DOCDIRPREFIX = kdev +DOXYGEN_REFERENCES = dcop interfaces tdecore tdefx tdeui tdehtml tdemdi tdeio kjs tdeparts tdeutils tdevextensions tdevinterfaces +DOXYGEN_PROJECTNAME = TDevelop Utility Library +DOXYGEN_DOCDIRPREFIX = tdev include ../../Doxyfile.am -noinst_HEADERS = blockingkprocess.h kdeveditorutil.h kdevjobtimer.h \ - kdevshellwidget.h settings.h +noinst_HEADERS = blockingkprocess.h tdeveditorutil.h tdevjobtimer.h \ + tdevshellwidget.h settings.h diff --git a/lib/util/configwidgetproxy.cpp b/lib/util/configwidgetproxy.cpp index bea1c79a..c2251158 100644 --- a/lib/util/configwidgetproxy.cpp +++ b/lib/util/configwidgetproxy.cpp @@ -26,13 +26,13 @@ #include #include -#include +#include #include "configwidgetproxy.h" -ConfigWidgetProxy::ConfigWidgetProxy( KDevCore * core ) +ConfigWidgetProxy::ConfigWidgetProxy( TDevCore * core ) { connect( core, TQT_SIGNAL(configWidget(KDialogBase*)), this, TQT_SLOT(slotConfigWidget( KDialogBase*)) ); connect( core, TQT_SIGNAL(projectConfigWidget(KDialogBase*)), this, TQT_SLOT(slotProjectConfigWidget( KDialogBase*)) ); diff --git a/lib/util/configwidgetproxy.h b/lib/util/configwidgetproxy.h index 7881f830..f1ced178 100644 --- a/lib/util/configwidgetproxy.h +++ b/lib/util/configwidgetproxy.h @@ -24,7 +24,7 @@ #include #include -class KDevCore; +class TDevCore; class KDialogBase; /** @@ -65,8 +65,8 @@ void MyPart::insertConfigWidget( TQObject const * dlg, TQWidget * page, unsigned } @endcode -Note that this replaces the functionality of typical KDevCore::configWidget() and -KDevCore::projectConfigWidget() slots. +Note that this replaces the functionality of typical TDevCore::configWidget() and +TDevCore::projectConfigWidget() slots. */ class ConfigWidgetProxy : public TQObject { @@ -76,7 +76,7 @@ Q_OBJECT public: /**Constructor. @param core An instance of KDevelop Core.*/ - ConfigWidgetProxy( KDevCore * core ); + ConfigWidgetProxy( TDevCore * core ); virtual ~ConfigWidgetProxy(); /** diff --git a/lib/util/filetemplate.cpp b/lib/util/filetemplate.cpp index c2454580..4d0facdf 100644 --- a/lib/util/filetemplate.cpp +++ b/lib/util/filetemplate.cpp @@ -27,12 +27,12 @@ #include -#include "kdevplugin.h" -#include "kdevproject.h" +#include "tdevplugin.h" +#include "tdevproject.h" #include "domutil.h" -bool FileTemplate::exists(KDevPlugin *part, const TQString &name, Policy p) +bool FileTemplate::exists(TDevPlugin *part, const TQString &name, Policy p) { //TQString fileName = (p == Default) ? // (part->project()->projectDirectory() + "/templates/" + name) : name; @@ -40,17 +40,17 @@ bool FileTemplate::exists(KDevPlugin *part, const TQString &name, Policy p) return TQFile::exists( fullPathForName(part,name,p) ); } -TQString FileTemplate::read(KDevPlugin *part, const TQString &name, Policy p) +TQString FileTemplate::read(TDevPlugin *part, const TQString &name, Policy p) { - //KDevProject *project = part->project(); + //TDevProject *project = part->project(); //TQString fileName = (p == Default) ? (project->projectDirectory() + // "/templates/" + name) : name; return readFile(part, fullPathForName(part, name, p) ); } -TQString FileTemplate::readFile(KDevPlugin *part, const TQString &fileName) +TQString FileTemplate::readFile(TDevPlugin *part, const TQString &fileName) { TQDomDocument &dom = *part->projectDom(); @@ -87,7 +87,7 @@ TQString FileTemplate::makeSubstitutions( TQDomDocument & dom, const TQString & } -bool FileTemplate::copy(KDevPlugin *part, const TQString &name, +bool FileTemplate::copy(TDevPlugin *part, const TQString &name, const TQString &dest, Policy p) { TQString text = read(part, name, p); @@ -109,7 +109,7 @@ bool FileTemplate::copy(KDevPlugin *part, const TQString &name, return true; } -TQString FileTemplate::fullPathForName(KDevPlugin *part, const TQString &name, +TQString FileTemplate::fullPathForName(TDevPlugin *part, const TQString &name, Policy p) { // if Policy is not default, full path is just the name if (p!=Default) return name; @@ -123,6 +123,6 @@ TQString FileTemplate::fullPathForName(KDevPlugin *part, const TQString &name, } // next try global - TQString globalName = ::locate("data", "kdevfilecreate/file-templates/" + name); + TQString globalName = ::locate("data", "tdevfilecreate/file-templates/" + name); return globalName.isNull() ? fileName : globalName; } diff --git a/lib/util/filetemplate.h b/lib/util/filetemplate.h index 8f863535..7802f9b7 100644 --- a/lib/util/filetemplate.h +++ b/lib/util/filetemplate.h @@ -22,7 +22,7 @@ #include -class KDevPlugin; +class TDevPlugin; class TQDomDocument; /** @@ -49,21 +49,21 @@ public: * exists in the current project. File templates * are stored in the "templates" subdirectory of a project or in application shared dirs. */ - static bool exists(KDevPlugin *part, const TQString &name, Policy p = Default); + static bool exists(TDevPlugin *part, const TQString &name, Policy p = Default); /** * Reads a template with the given name (e.g. "cpp") * and makes variable substitutions (like $AUTHOR$ etc.) * in it. The resulting string is returned. */ - static TQString read(KDevPlugin *part, const TQString &name, Policy p = Default); + static TQString read(TDevPlugin *part, const TQString &name, Policy p = Default); /** * Reads a template with the given URL * and makes variable substitutions (like $AUTHOR$ etc.) * in it. The resulting string is returned. */ - static TQString readFile(KDevPlugin *part, const TQString &fileName); + static TQString readFile(TDevPlugin *part, const TQString &fileName); /** * Makes variable substitutions on a text, based on a specified TQDomDocument @@ -76,13 +76,13 @@ public: * file with the name dest and - while copying - * performs variable substitutions. */ - static bool copy(KDevPlugin *part, const TQString &name, + static bool copy(TDevPlugin *part, const TQString &name, const TQString &dest, Policy p = Default); /** * Translates a template name into a full path, or suggests a full path * for the template in the project directory if it doesn't exist. */ - static TQString fullPathForName(KDevPlugin *part, const TQString &name, Policy p = Default); + static TQString fullPathForName(TDevPlugin *part, const TQString &name, Policy p = Default); }; #endif diff --git a/lib/util/kdeveditorutil.cpp b/lib/util/kdeveditorutil.cpp deleted file mode 100644 index 198e9a42..00000000 --- a/lib/util/kdeveditorutil.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Jens Dagerbo * - * jens.dagerbo@swipnet.se * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "kdeveditorutil.h" - -#include -#include -#include -#include -#include - -bool KDevEditorUtil::currentPositionReal( unsigned int * line, unsigned int * col, KTextEditor::Document * doc, KTextEditor::View * view ) -{ - if ( !line || !col ) return false; - - KTextEditor::EditInterface * editIface = dynamic_cast( doc ); - if ( !editIface ) return false; - - view = view ? view : dynamic_cast( doc->widget() ); - - KTextEditor::ViewCursorInterface * cursorIface = dynamic_cast( view ); - if ( !cursorIface ) return false; - - cursorIface->cursorPositionReal( line, col ); - return true; -} - -TQString KDevEditorUtil::currentLine( KTextEditor::Document * doc, KTextEditor::View * view ) -{ - KTextEditor::EditInterface * editIface = dynamic_cast( doc ); - if ( !editIface ) return TQString(); - - view = view ? view : dynamic_cast( doc->widget() ); - - KTextEditor::ViewCursorInterface * cursorIface = dynamic_cast( view ); - if ( !cursorIface ) return TQString(); - - uint line = 0; - uint col = 0; - cursorIface->cursorPositionReal(&line, &col); - - return editIface->textLine(line); -} - -TQString KDevEditorUtil::currentWord( KTextEditor::Document * doc, KTextEditor::View * view ) -{ - KTextEditor::EditInterface * editIface = dynamic_cast( doc ); - if ( !editIface ) return TQString(); - - view = view ? view : dynamic_cast( doc->widget() ); - - KTextEditor::ViewCursorInterface * cursorIface = dynamic_cast( view ); - if ( !cursorIface ) return TQString(); - - uint line = 0; - uint col = 0; - cursorIface->cursorPositionReal(&line, &col); - - TQString linestr = editIface->textLine(line); - - int startPos = TQMAX( TQMIN( (int)col, (int)linestr.length()-1 ), 0 ); - int endPos = startPos; - startPos--; - while (startPos >= 0 && ( linestr[startPos].isLetterOrNumber() || linestr[startPos] == '_' || linestr[startPos] == '~') ) - startPos--; - while (endPos < (int)linestr.length() && ( linestr[endPos].isLetterOrNumber() || linestr[endPos] == '_' ) ) - endPos++; - - return ( ( startPos == endPos ) ? TQString() : linestr.mid( startPos+1, endPos-startPos-1 ) ); -} - - -TQString KDevEditorUtil::currentSelection( KTextEditor::Document * doc ) -{ - KTextEditor::SelectionInterface * selectIface = dynamic_cast( doc ); - return selectIface ? selectIface->selection() : TQString(); -} - - -// kate: space-indent off; indent-width 4; tab-width 4; show-tabs on; - diff --git a/lib/util/kdeveditorutil.h b/lib/util/kdeveditorutil.h deleted file mode 100644 index 79a64fe1..00000000 --- a/lib/util/kdeveditorutil.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Jens Dagerbo * - * jens.dagerbo@swipnet.se * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef KDEVEDITOR_H -#define KDEVEDITOR_H - -namespace KTextEditor -{ -class Document; -class View; -} - -#include - -/** -Class with some common utility operations not currently supported by KTE - - @author Jens Dagerbo -*/ -class KDevEditorUtil -{ - KDevEditorUtil() {} -public: - - /** - * - * @param line - * @param col - * @param doc - * @param view - * @return - */ - static bool currentPositionReal( unsigned int * line, unsigned int * col, KTextEditor::Document * doc, KTextEditor::View * view = 0 ); - - /** - * - * @param doc - * @param view - * @return - */ - static TQString currentLine( KTextEditor::Document * doc, KTextEditor::View * view = 0 ); - - /** - * Call to get the text under the cursor of the currently active view. - * @return the text under the cursor of the currently active view - */ - static TQString currentWord( KTextEditor::Document * doc, KTextEditor::View * view = 0 ); - - /** - * Call to get the selection in the currently active view - * @return the selection in the currently active view - */ - static TQString currentSelection( KTextEditor::Document * doc ); -}; - -#endif - - -// kate: space-indent off; indent-width 4; tab-width 4; show-tabs on; diff --git a/lib/util/kdevjobtimer.cpp b/lib/util/kdevjobtimer.cpp deleted file mode 100644 index b0b78250..00000000 --- a/lib/util/kdevjobtimer.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Jens Dagerbo * - * jens.dagerbo@swipnet.se * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "kdevjobtimer.h" - -KDevJobTimer::KDevJobTimer( void * payload, TQObject *parent, const char *name) - : TQTimer(parent, name) -{ - m_payload = payload; - connect( this, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout()) ); -} - -KDevJobTimer::~KDevJobTimer() -{ -} - -void KDevJobTimer::singleShot(int msec, TQObject * receiver, const char * member, void * payload) -{ - KDevJobTimer * p = new KDevJobTimer( payload ); - p->start( msec, true ); - connect( p, TQT_SIGNAL(timeout(void*)), receiver, member ); -} - -void KDevJobTimer::slotTimeout() -{ - emit timeout( m_payload ); - m_payload = 0; - deleteLater(); -} - -#include "kdevjobtimer.moc" diff --git a/lib/util/kdevjobtimer.h b/lib/util/kdevjobtimer.h deleted file mode 100644 index b0fa829e..00000000 --- a/lib/util/kdevjobtimer.h +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Jens Dagerbo * - * jens.dagerbo@swipnet.se * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef KDEVJOBTIMER_H -#define KDEVJOBTIMER_H - -#include - -class KDevJobTimer : public TQTimer -{ -Q_OBJECT - -public: - static void singleShot( int msec, TQObject * receiver, const char * member, void * payload ); - -signals: - void timeout(void*); - -private: - KDevJobTimer( void * payload, TQObject *parent = 0, const char *name = 0); - ~KDevJobTimer(); - -private slots: - void slotTimeout(); - -private: - void * m_payload; - -}; - - -#endif diff --git a/lib/util/kdevshellwidget.cpp b/lib/util/kdevshellwidget.cpp deleted file mode 100644 index b9220250..00000000 --- a/lib/util/kdevshellwidget.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Jens Dagerbo * - * jens.dagerbo@swipnet.se * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include - -#include "kdevshellwidget.h" - -KDevShellWidget::KDevShellWidget(TQWidget *parent, const char *name) - : TQVBox(parent, name), m_doAutoActivate( false ), m_isRunning( false ) -{ -} - - -KDevShellWidget::~KDevShellWidget() -{ -} - -void KDevShellWidget::setShell( const TQString & shell, const TQStrList & arguments ) -{ - m_shellName = shell; - m_shellArguments = arguments; -} - -void KDevShellWidget::activate( ) -{ - KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart"); - if ( !factory ) return; - - m_konsolePart = (KParts::ReadOnlyPart *) factory->create( TQT_TQOBJECT(this), "libkonsolepart", "KParts::ReadOnlyPart" ); - if ( !m_konsolePart ) return; - - connect( m_konsolePart, TQT_SIGNAL( processExited(TDEProcess *) ), this, TQT_SLOT( processExited(TDEProcess *) ) ); - connect( m_konsolePart, TQT_SIGNAL( receivedData( const TQString& ) ), this, TQT_SIGNAL( receivedData( const TQString& ) ) ); - connect( m_konsolePart, TQT_SIGNAL(destroyed()), this, TQT_SLOT(partDestroyed()) ); - - m_konsolePart->widget()->setFocusPolicy( TQ_WheelFocus ); - setFocusProxy( m_konsolePart->widget() ); - m_konsolePart->widget()->setFocus(); - - if ( m_konsolePart->widget()->inherits(TQFRAME_OBJECT_NAME_STRING) ) - ((TQFrame*)m_konsolePart->widget())->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); - - m_konsolePart->widget()->show(); - - TerminalInterface* ti = static_cast( m_konsolePart->tqt_cast( "TerminalInterface" ) ); - if( !ti ) return; - - if ( !m_shellName.isEmpty() ) - ti->startProgram( m_shellName, m_shellArguments ); - - m_isRunning = true; - -} - -void KDevShellWidget::partDestroyed( ) -{ - if ( m_doAutoActivate ) - { - activate(); - } -} - -void KDevShellWidget::processExited( TDEProcess * proc ) -{ - m_isRunning = false; - - if ( !proc ) return; - - kdDebug(9000) << proc->args() << endl; - - if ( proc->normalExit() ) - emit shellExited( proc->exitStatus() ); - else if ( proc->signalled() ) - emit shellSignalled( proc->exitSignal() ); -} - -void KDevShellWidget::sendInput( const TQString & text ) -{ - if ( !m_konsolePart ) return; - TerminalInterface* ti = static_cast( m_konsolePart->tqt_cast( "TerminalInterface" ) ); - if( !ti ) return; - - ti->sendInput( text ); -} - -bool KDevShellWidget::isRunning( ) -{ - return m_isRunning; -} - -void KDevShellWidget::setAutoReactivateOnClose( bool doAutoActivate ) -{ - // to auto reactivate can be dangerous, do it like this to avoid - // reactivating with a non-working setting (the partDestroyed() - // slot will have ran before m_doAutoActivate is set) - if ( doAutoActivate ) - TQTimer::singleShot( 3000, this, TQT_SLOT(setAutoReactivateOnCloseDelayed()) ); - else - m_doAutoActivate = false; -} - -void KDevShellWidget::setAutoReactivateOnCloseDelayed( ) -{ - m_doAutoActivate = true; -} - - -#include "kdevshellwidget.moc" - -// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off; diff --git a/lib/util/kdevshellwidget.h b/lib/util/kdevshellwidget.h deleted file mode 100644 index 6bb6a8d7..00000000 --- a/lib/util/kdevshellwidget.h +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Jens Dagerbo * - * jens.dagerbo@swipnet.se * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#ifndef KDEVSHELLWIDGET_H -#define KDEVSHELLWIDGET_H - -#include -#include -#include - -class TDEProcess; -namespace KParts -{ - class ReadOnlyPart; -} - -class KDevShellWidget : public TQVBox -{ - -Q_OBJECT - - -public: - KDevShellWidget(TQWidget *parent = 0, const char *name = 0); - virtual ~KDevShellWidget(); - - /** - * Stores the shell name and arguments, that will be used in @ref activate() - * @param shell The shell name, for example 'irb' or '/bin/bash' - * @param arguments Any optional arguments - */ - void setShell( const TQString & shell, const TQStrList & arguments = TQStrList() ); - - /** - * Executes the previously set shell. If @ref setShell wasn't called before - * konsolepart will decide what to use. - */ - void activate(); - - /** - * Should we auto launch the shell again if it was terminated? - * @param doAutoActivate - */ - void setAutoReactivateOnClose( bool doAutoActivate ); - - /** - * Send text to the running shell - * @param text The text to send to the shell - */ - void sendInput( const TQString & text ); - - /** - * Call to check if the shell is currently running - * @return true if the shell is currently running - */ - bool isRunning(); - -signals: - /** - * This signal will be emmitted when the started shell exits normally - * @param exitcode The return code of the process - */ - void shellExited( int exitcode ); - - /** - * This signal will be emitted when the started shell is terminated by a signal - * @param signalcode The signal the process was killed with - */ - void shellSignalled( int signalcode ); - - /** - * This signal will be emitted when the process receives data - * @param text received data - */ - void receivedData( const TQString & ); - -private slots: - void partDestroyed(); - void processExited( TDEProcess * ); - void setAutoReactivateOnCloseDelayed( ); - -private: - TQGuardedPtr m_konsolePart; - TQString m_shellName; - TQStrList m_shellArguments; - bool m_doAutoActivate; - bool m_isRunning; -}; - -#endif - -// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off; diff --git a/lib/util/tdeveditorutil.cpp b/lib/util/tdeveditorutil.cpp new file mode 100644 index 00000000..455909f8 --- /dev/null +++ b/lib/util/tdeveditorutil.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "tdeveditorutil.h" + +#include +#include +#include +#include +#include + +bool TDevEditorUtil::currentPositionReal( unsigned int * line, unsigned int * col, KTextEditor::Document * doc, KTextEditor::View * view ) +{ + if ( !line || !col ) return false; + + KTextEditor::EditInterface * editIface = dynamic_cast( doc ); + if ( !editIface ) return false; + + view = view ? view : dynamic_cast( doc->widget() ); + + KTextEditor::ViewCursorInterface * cursorIface = dynamic_cast( view ); + if ( !cursorIface ) return false; + + cursorIface->cursorPositionReal( line, col ); + return true; +} + +TQString TDevEditorUtil::currentLine( KTextEditor::Document * doc, KTextEditor::View * view ) +{ + KTextEditor::EditInterface * editIface = dynamic_cast( doc ); + if ( !editIface ) return TQString(); + + view = view ? view : dynamic_cast( doc->widget() ); + + KTextEditor::ViewCursorInterface * cursorIface = dynamic_cast( view ); + if ( !cursorIface ) return TQString(); + + uint line = 0; + uint col = 0; + cursorIface->cursorPositionReal(&line, &col); + + return editIface->textLine(line); +} + +TQString TDevEditorUtil::currentWord( KTextEditor::Document * doc, KTextEditor::View * view ) +{ + KTextEditor::EditInterface * editIface = dynamic_cast( doc ); + if ( !editIface ) return TQString(); + + view = view ? view : dynamic_cast( doc->widget() ); + + KTextEditor::ViewCursorInterface * cursorIface = dynamic_cast( view ); + if ( !cursorIface ) return TQString(); + + uint line = 0; + uint col = 0; + cursorIface->cursorPositionReal(&line, &col); + + TQString linestr = editIface->textLine(line); + + int startPos = TQMAX( TQMIN( (int)col, (int)linestr.length()-1 ), 0 ); + int endPos = startPos; + startPos--; + while (startPos >= 0 && ( linestr[startPos].isLetterOrNumber() || linestr[startPos] == '_' || linestr[startPos] == '~') ) + startPos--; + while (endPos < (int)linestr.length() && ( linestr[endPos].isLetterOrNumber() || linestr[endPos] == '_' ) ) + endPos++; + + return ( ( startPos == endPos ) ? TQString() : linestr.mid( startPos+1, endPos-startPos-1 ) ); +} + + +TQString TDevEditorUtil::currentSelection( KTextEditor::Document * doc ) +{ + KTextEditor::SelectionInterface * selectIface = dynamic_cast( doc ); + return selectIface ? selectIface->selection() : TQString(); +} + + +// kate: space-indent off; indent-width 4; tab-width 4; show-tabs on; + diff --git a/lib/util/tdeveditorutil.h b/lib/util/tdeveditorutil.h new file mode 100644 index 00000000..d69e914b --- /dev/null +++ b/lib/util/tdeveditorutil.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TDEVEDITOR_H +#define TDEVEDITOR_H + +namespace KTextEditor +{ +class Document; +class View; +} + +#include + +/** +Class with some common utility operations not currently supported by KTE + + @author Jens Dagerbo +*/ +class TDevEditorUtil +{ + TDevEditorUtil() {} +public: + + /** + * + * @param line + * @param col + * @param doc + * @param view + * @return + */ + static bool currentPositionReal( unsigned int * line, unsigned int * col, KTextEditor::Document * doc, KTextEditor::View * view = 0 ); + + /** + * + * @param doc + * @param view + * @return + */ + static TQString currentLine( KTextEditor::Document * doc, KTextEditor::View * view = 0 ); + + /** + * Call to get the text under the cursor of the currently active view. + * @return the text under the cursor of the currently active view + */ + static TQString currentWord( KTextEditor::Document * doc, KTextEditor::View * view = 0 ); + + /** + * Call to get the selection in the currently active view + * @return the selection in the currently active view + */ + static TQString currentSelection( KTextEditor::Document * doc ); +}; + +#endif + + +// kate: space-indent off; indent-width 4; tab-width 4; show-tabs on; diff --git a/lib/util/tdevjobtimer.cpp b/lib/util/tdevjobtimer.cpp new file mode 100644 index 00000000..0e1465e0 --- /dev/null +++ b/lib/util/tdevjobtimer.cpp @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2006 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "tdevjobtimer.h" + +TDevJobTimer::TDevJobTimer( void * payload, TQObject *parent, const char *name) + : TQTimer(parent, name) +{ + m_payload = payload; + connect( this, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout()) ); +} + +TDevJobTimer::~TDevJobTimer() +{ +} + +void TDevJobTimer::singleShot(int msec, TQObject * receiver, const char * member, void * payload) +{ + TDevJobTimer * p = new TDevJobTimer( payload ); + p->start( msec, true ); + connect( p, TQT_SIGNAL(timeout(void*)), receiver, member ); +} + +void TDevJobTimer::slotTimeout() +{ + emit timeout( m_payload ); + m_payload = 0; + deleteLater(); +} + +#include "tdevjobtimer.moc" diff --git a/lib/util/tdevjobtimer.h b/lib/util/tdevjobtimer.h new file mode 100644 index 00000000..313e56e5 --- /dev/null +++ b/lib/util/tdevjobtimer.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2006 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TDEVJOBTIMER_H +#define TDEVJOBTIMER_H + +#include + +class TDevJobTimer : public TQTimer +{ +Q_OBJECT + +public: + static void singleShot( int msec, TQObject * receiver, const char * member, void * payload ); + +signals: + void timeout(void*); + +private: + TDevJobTimer( void * payload, TQObject *parent = 0, const char *name = 0); + ~TDevJobTimer(); + +private slots: + void slotTimeout(); + +private: + void * m_payload; + +}; + + +#endif diff --git a/lib/util/tdevshellwidget.cpp b/lib/util/tdevshellwidget.cpp new file mode 100644 index 00000000..b5b8d195 --- /dev/null +++ b/lib/util/tdevshellwidget.cpp @@ -0,0 +1,125 @@ +/*************************************************************************** + * Copyright (C) 2006 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "tdevshellwidget.h" + +TDevShellWidget::TDevShellWidget(TQWidget *parent, const char *name) + : TQVBox(parent, name), m_doAutoActivate( false ), m_isRunning( false ) +{ +} + + +TDevShellWidget::~TDevShellWidget() +{ +} + +void TDevShellWidget::setShell( const TQString & shell, const TQStrList & arguments ) +{ + m_shellName = shell; + m_shellArguments = arguments; +} + +void TDevShellWidget::activate( ) +{ + KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart"); + if ( !factory ) return; + + m_konsolePart = (KParts::ReadOnlyPart *) factory->create( TQT_TQOBJECT(this), "libkonsolepart", "KParts::ReadOnlyPart" ); + if ( !m_konsolePart ) return; + + connect( m_konsolePart, TQT_SIGNAL( processExited(TDEProcess *) ), this, TQT_SLOT( processExited(TDEProcess *) ) ); + connect( m_konsolePart, TQT_SIGNAL( receivedData( const TQString& ) ), this, TQT_SIGNAL( receivedData( const TQString& ) ) ); + connect( m_konsolePart, TQT_SIGNAL(destroyed()), this, TQT_SLOT(partDestroyed()) ); + + m_konsolePart->widget()->setFocusPolicy( TQ_WheelFocus ); + setFocusProxy( m_konsolePart->widget() ); + m_konsolePart->widget()->setFocus(); + + if ( m_konsolePart->widget()->inherits(TQFRAME_OBJECT_NAME_STRING) ) + ((TQFrame*)m_konsolePart->widget())->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + m_konsolePart->widget()->show(); + + TerminalInterface* ti = static_cast( m_konsolePart->tqt_cast( "TerminalInterface" ) ); + if( !ti ) return; + + if ( !m_shellName.isEmpty() ) + ti->startProgram( m_shellName, m_shellArguments ); + + m_isRunning = true; + +} + +void TDevShellWidget::partDestroyed( ) +{ + if ( m_doAutoActivate ) + { + activate(); + } +} + +void TDevShellWidget::processExited( TDEProcess * proc ) +{ + m_isRunning = false; + + if ( !proc ) return; + + kdDebug(9000) << proc->args() << endl; + + if ( proc->normalExit() ) + emit shellExited( proc->exitStatus() ); + else if ( proc->signalled() ) + emit shellSignalled( proc->exitSignal() ); +} + +void TDevShellWidget::sendInput( const TQString & text ) +{ + if ( !m_konsolePart ) return; + TerminalInterface* ti = static_cast( m_konsolePart->tqt_cast( "TerminalInterface" ) ); + if( !ti ) return; + + ti->sendInput( text ); +} + +bool TDevShellWidget::isRunning( ) +{ + return m_isRunning; +} + +void TDevShellWidget::setAutoReactivateOnClose( bool doAutoActivate ) +{ + // to auto reactivate can be dangerous, do it like this to avoid + // reactivating with a non-working setting (the partDestroyed() + // slot will have ran before m_doAutoActivate is set) + if ( doAutoActivate ) + TQTimer::singleShot( 3000, this, TQT_SLOT(setAutoReactivateOnCloseDelayed()) ); + else + m_doAutoActivate = false; +} + +void TDevShellWidget::setAutoReactivateOnCloseDelayed( ) +{ + m_doAutoActivate = true; +} + + +#include "tdevshellwidget.moc" + +// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off; diff --git a/lib/util/tdevshellwidget.h b/lib/util/tdevshellwidget.h new file mode 100644 index 00000000..f6476814 --- /dev/null +++ b/lib/util/tdevshellwidget.h @@ -0,0 +1,101 @@ +/*************************************************************************** + * Copyright (C) 2006 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef TDEVSHELLWIDGET_H +#define TDEVSHELLWIDGET_H + +#include +#include +#include + +class TDEProcess; +namespace KParts +{ + class ReadOnlyPart; +} + +class TDevShellWidget : public TQVBox +{ + +Q_OBJECT + + +public: + TDevShellWidget(TQWidget *parent = 0, const char *name = 0); + virtual ~TDevShellWidget(); + + /** + * Stores the shell name and arguments, that will be used in @ref activate() + * @param shell The shell name, for example 'irb' or '/bin/bash' + * @param arguments Any optional arguments + */ + void setShell( const TQString & shell, const TQStrList & arguments = TQStrList() ); + + /** + * Executes the previously set shell. If @ref setShell wasn't called before + * konsolepart will decide what to use. + */ + void activate(); + + /** + * Should we auto launch the shell again if it was terminated? + * @param doAutoActivate + */ + void setAutoReactivateOnClose( bool doAutoActivate ); + + /** + * Send text to the running shell + * @param text The text to send to the shell + */ + void sendInput( const TQString & text ); + + /** + * Call to check if the shell is currently running + * @return true if the shell is currently running + */ + bool isRunning(); + +signals: + /** + * This signal will be emmitted when the started shell exits normally + * @param exitcode The return code of the process + */ + void shellExited( int exitcode ); + + /** + * This signal will be emitted when the started shell is terminated by a signal + * @param signalcode The signal the process was killed with + */ + void shellSignalled( int signalcode ); + + /** + * This signal will be emitted when the process receives data + * @param text received data + */ + void receivedData( const TQString & ); + +private slots: + void partDestroyed(); + void processExited( TDEProcess * ); + void setAutoReactivateOnCloseDelayed( ); + +private: + TQGuardedPtr m_konsolePart; + TQString m_shellName; + TQStrList m_shellArguments; + bool m_doAutoActivate; + bool m_isRunning; +}; + +#endif + +// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off; -- cgit v1.2.3