summaryrefslogtreecommitdiffstats
path: root/kate/plugins/wordcompletion
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kate/plugins/wordcompletion
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/plugins/wordcompletion')
-rw-r--r--kate/plugins/wordcompletion/Makefile.am17
-rw-r--r--kate/plugins/wordcompletion/docwordcompletion.cpp554
-rw-r--r--kate/plugins/wordcompletion/docwordcompletion.h133
-rw-r--r--kate/plugins/wordcompletion/docwordcompletionui.rc16
-rw-r--r--kate/plugins/wordcompletion/ktexteditor_docwordcompletion.desktop139
5 files changed, 859 insertions, 0 deletions
diff --git a/kate/plugins/wordcompletion/Makefile.am b/kate/plugins/wordcompletion/Makefile.am
new file mode 100644
index 000000000..5bddb895e
--- /dev/null
+++ b/kate/plugins/wordcompletion/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = -I$(top_srcdir)/interfaces $(all_includes)
+METASOURCES = AUTO
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = ktexteditor_docwordcompletion.la
+
+ktexteditor_docwordcompletion_la_SOURCES = docwordcompletion.cpp
+ktexteditor_docwordcompletion_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la
+ktexteditor_docwordcompletion_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+docwordcompletiondatadir = $(kde_datadir)/ktexteditor_docwordcompletion
+docwordcompletiondata_DATA = docwordcompletionui.rc
+
+kde_services_DATA = ktexteditor_docwordcompletion.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/ktexteditor_docwordcompletion.pot
diff --git a/kate/plugins/wordcompletion/docwordcompletion.cpp b/kate/plugins/wordcompletion/docwordcompletion.cpp
new file mode 100644
index 000000000..9fb7f4844
--- /dev/null
+++ b/kate/plugins/wordcompletion/docwordcompletion.cpp
@@ -0,0 +1,554 @@
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ 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.
+
+ ---
+ file: docwordcompletion.cpp
+
+ KTextEditor plugin to autocompletion with document words.
+ Copyright Anders Lund <anders.lund@lund.tdcadsl.dk>, 2003
+
+ The following completion methods are supported:
+ * Completion with bigger matching words in
+ either direction (backward/forward).
+ * NOT YET Pop up a list of all bigger matching words in document
+
+*/
+//BEGIN includes
+#include "docwordcompletion.h"
+
+#include <ktexteditor/document.h>
+#include <ktexteditor/viewcursorinterface.h>
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/variableinterface.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdialog.h>
+#include <kgenericfactory.h>
+#include <klocale.h>
+#include <kaction.h>
+#include <knotifyclient.h>
+#include <kparts/part.h>
+#include <kiconloader.h>
+
+#include <qregexp.h>
+#include <qstring.h>
+#include <qdict.h>
+#include <qspinbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qhbox.h>
+#include <qwhatsthis.h>
+#include <qcheckbox.h>
+
+// #include <kdebug.h>
+//END
+
+//BEGIN DocWordCompletionPlugin
+K_EXPORT_COMPONENT_FACTORY( ktexteditor_docwordcompletion, KGenericFactory<DocWordCompletionPlugin>( "ktexteditor_docwordcompletion" ) )
+DocWordCompletionPlugin::DocWordCompletionPlugin( QObject *parent,
+ const char* name,
+ const QStringList& /*args*/ )
+ : KTextEditor::Plugin ( (KTextEditor::Document*) parent, name )
+{
+ readConfig();
+}
+
+void DocWordCompletionPlugin::readConfig()
+{
+ KConfig *config = kapp->config();
+ config->setGroup( "DocWordCompletion Plugin" );
+ m_treshold = config->readNumEntry( "treshold", 3 );
+ m_autopopup = config->readBoolEntry( "autopopup", true );
+}
+
+void DocWordCompletionPlugin::writeConfig()
+{
+ KConfig *config = kapp->config();
+ config->setGroup("DocWordCompletion Plugin");
+ config->writeEntry("autopopup", m_autopopup );
+ config->writeEntry("treshold", m_treshold );
+}
+
+void DocWordCompletionPlugin::addView(KTextEditor::View *view)
+{
+ DocWordCompletionPluginView *nview = new DocWordCompletionPluginView (m_treshold, m_autopopup, view, "Document word completion");
+ m_views.append (nview);
+}
+
+void DocWordCompletionPlugin::removeView(KTextEditor::View *view)
+{
+ for (uint z=0; z < m_views.count(); z++)
+ if (m_views.at(z)->parentClient() == view)
+ {
+ DocWordCompletionPluginView *nview = m_views.at(z);
+ m_views.remove (nview);
+ delete nview;
+ }
+}
+
+KTextEditor::ConfigPage* DocWordCompletionPlugin::configPage( uint, QWidget *parent, const char *name )
+{
+ return new DocWordCompletionConfigPage( this, parent, name );
+}
+
+QString DocWordCompletionPlugin::configPageName( uint ) const
+{
+ return i18n("Word Completion Plugin");
+}
+
+QString DocWordCompletionPlugin::configPageFullName( uint ) const
+{
+ return i18n("Configure the Word Completion Plugin");
+}
+
+// FIXME provide sucn a icon
+ QPixmap DocWordCompletionPlugin::configPagePixmap( uint, int size ) const
+{
+ return UserIcon( "kte_wordcompletion", size );
+}
+//END
+
+//BEGIN DocWordCompletionPluginView
+struct DocWordCompletionPluginViewPrivate
+{
+ uint line, col; // start position of last match (where to search from)
+ uint cline, ccol; // cursor position
+ uint lilen; // length of last insertion
+ QString last; // last word we were trying to match
+ QString lastIns; // latest applied completion
+ QRegExp re; // hrm
+ KToggleAction *autopopup; // for accessing state
+ uint treshold; // the required length of a word before popping up the completion list automatically
+ int directionalPos; // be able to insert "" at the correct time
+};
+
+DocWordCompletionPluginView::DocWordCompletionPluginView( uint treshold, bool autopopup, KTextEditor::View *view, const char *name )
+ : QObject( view, name ),
+ KXMLGUIClient( view ),
+ m_view( view ),
+ d( new DocWordCompletionPluginViewPrivate )
+{
+ d->treshold = treshold;
+ view->insertChildClient( this );
+ setInstance( KGenericFactory<DocWordCompletionPlugin>::instance() );
+
+ (void) new KAction( i18n("Reuse Word Above"), CTRL+Key_8, this,
+ SLOT(completeBackwards()), actionCollection(), "doccomplete_bw" );
+ (void) new KAction( i18n("Reuse Word Below"), CTRL+Key_9, this,
+ SLOT(completeForwards()), actionCollection(), "doccomplete_fw" );
+ (void) new KAction( i18n("Pop Up Completion List"), 0, this,
+ SLOT(popupCompletionList()), actionCollection(), "doccomplete_pu" );
+ (void) new KAction( i18n("Shell Completion"), 0, this,
+ SLOT(shellComplete()), actionCollection(), "doccomplete_sh" );
+ d->autopopup = new KToggleAction( i18n("Automatic Completion Popup"), 0, this,
+ SLOT(toggleAutoPopup()), actionCollection(), "enable_autopopup" );
+
+ d->autopopup->setChecked( autopopup );
+ toggleAutoPopup();
+
+ setXMLFile("docwordcompletionui.rc");
+
+ KTextEditor::VariableInterface *vi = KTextEditor::variableInterface( view->document() );
+ if ( vi )
+ {
+ QString e = vi->variable("wordcompletion-autopopup");
+ if ( ! e.isEmpty() )
+ d->autopopup->setEnabled( e == "true" );
+
+ connect( view->document(), SIGNAL(variableChanged(const QString &, const QString &)),
+ this, SLOT(slotVariableChanged(const QString &, const QString &)) );
+ }
+}
+
+void DocWordCompletionPluginView::settreshold( uint t )
+{
+ d->treshold = t;
+}
+
+void DocWordCompletionPluginView::completeBackwards()
+{
+ complete( false );
+}
+
+void DocWordCompletionPluginView::completeForwards()
+{
+ complete();
+}
+
+// Pop up the editors completion list if applicable
+void DocWordCompletionPluginView::popupCompletionList( QString w )
+{
+ if ( w.isEmpty() )
+ w = word();
+ if ( w.isEmpty() )
+ return;
+
+ KTextEditor::CodeCompletionInterface *cci = codeCompletionInterface( m_view );
+ cci->showCompletionBox( allMatches( w ), w.length() );
+}
+
+void DocWordCompletionPluginView::toggleAutoPopup()
+{
+ if ( d->autopopup->isChecked() ) {
+ if ( ! connect( m_view->document(), SIGNAL(charactersInteractivelyInserted(int ,int ,const QString&)),
+ this, SLOT(autoPopupCompletionList()) ))
+ {
+ connect( m_view->document(), SIGNAL(textChanged()), this, SLOT(autoPopupCompletionList()) );
+ }
+ } else {
+ disconnect( m_view->document(), SIGNAL(textChanged()), this, SLOT(autoPopupCompletionList()) );
+ disconnect( m_view->document(), SIGNAL(charactersInteractivelyInserted(int ,int ,const QString&)),
+ this, SLOT(autoPopupCompletionList()) );
+
+ }
+}
+
+// for autopopup FIXME - don't pop up if reuse word is inserting
+void DocWordCompletionPluginView::autoPopupCompletionList()
+{
+ if ( ! m_view->hasFocus() ) return;
+ QString w = word();
+ if ( w.length() >= d->treshold )
+ {
+ popupCompletionList( w );
+ }
+}
+
+// Contributed by <brain@hdsnet.hu>
+void DocWordCompletionPluginView::shellComplete()
+{
+ // setup
+ KTextEditor::EditInterface * ei = KTextEditor::editInterface(m_view->document());
+ // find the word we are typing
+ uint cline, ccol;
+ viewCursorInterface(m_view)->cursorPositionReal(&cline, &ccol);
+ QString wrd = word();
+ if (wrd.isEmpty())
+ return;
+
+ QValueList < KTextEditor::CompletionEntry > matches = allMatches(wrd);
+ if (matches.size() == 0)
+ return;
+ QString partial = findLongestUnique(matches);
+ if (partial.length() == wrd.length())
+ {
+ KTextEditor::CodeCompletionInterface * cci = codeCompletionInterface(m_view);
+ cci->showCompletionBox(matches, wrd.length());
+ }
+ else
+ {
+ partial.remove(0, wrd.length());
+ ei->insertText(cline, ccol, partial);
+ }
+}
+
+// Do one completion, searching in the desired direction,
+// if possible
+void DocWordCompletionPluginView::complete( bool fw )
+{
+ // setup
+ KTextEditor::EditInterface *ei = KTextEditor::editInterface( m_view->document() );
+ // find the word we are typing
+ uint cline, ccol;
+ viewCursorInterface( m_view )->cursorPositionReal( &cline, &ccol );
+ QString wrd = word();
+ if ( wrd.isEmpty() )
+ return;
+
+ int inc = fw ? 1 : -1;
+
+ /* IF the current line is equal to the previous line
+ AND the position - the length of the last inserted string
+ is equal to the old position
+ AND the lastinsertedlength last characters of the word is
+ equal to the last inserted string
+ */
+ if ( cline == d-> cline &&
+ ccol - d->lilen == d->ccol &&
+ wrd.endsWith( d->lastIns ) )
+ {
+ // this is a repeted activation
+
+ // if we are back to where we started, reset.
+ if ( ( fw && d->directionalPos == -1 ) ||
+ ( !fw && d->directionalPos == 1 ) )
+ {
+ if ( d->lilen )
+ ei->removeText( d->cline, d->ccol, d->cline, d->ccol + d->lilen );
+
+ d->lastIns = "";
+ d->lilen = 0;
+ d->line = d->cline;
+ d->col = d->ccol;
+ d->directionalPos = 0;
+
+ return;
+ }
+
+ if ( fw )
+ d->col += d->lilen;
+
+ ccol = d->ccol;
+ wrd = d->last;
+
+ d->directionalPos += inc;
+ }
+ else
+ {
+ d->cline = cline;
+ d->ccol = ccol;
+ d->last = wrd;
+ d->lastIns = "";
+ d->line = cline;
+ d->col = ccol - wrd.length();
+ d->lilen = 0;
+ d->directionalPos = inc;
+ }
+
+ d->re.setPattern( "\\b" + wrd + "(\\w+)" );
+ int pos ( 0 );
+ QString ln = ei->textLine( d->line );
+
+ while ( true )
+ {
+ pos = fw ?
+ d->re.search( ln, d->col ) :
+ d->re.searchRev( ln, d->col );
+
+ if ( pos > -1 ) // we matched a word
+ {
+ QString m = d->re.cap( 1 );
+ if ( m != d->lastIns )
+ {
+ // we got good a match! replace text and return.
+ if ( d->lilen )
+ ei->removeText( d->cline, d->ccol, d->cline, d->ccol + d->lilen );
+ ei->insertText( d->cline, d->ccol, m );
+
+ d->lastIns = m;
+ d->lilen = m.length();
+ d->col = pos; // for next try
+
+ return;
+ }
+
+ // equal to last one, continue
+ else
+ {
+ d->col = pos; // for next try
+
+ if ( fw )
+ d->col += d->re.matchedLength();
+
+ else
+ {
+ if ( pos == 0 )
+ {
+ if ( d->line > 0 )
+ {
+ d->line += inc;
+ ln = ei->textLine( d->line );
+ d->col = ln.length();
+ }
+ else
+ {
+ KNotifyClient::beep();
+ return;
+ }
+ }
+
+ else
+ d->col--;
+ }
+ }
+ }
+
+ else // no match
+ {
+ if ( (! fw && d->line == 0 ) || ( fw && d->line >= (uint)ei->numLines() ) )
+ {
+ KNotifyClient::beep();
+ return;
+ }
+
+ d->line += inc;
+
+ ln = ei->textLine( d->line );
+ d->col = fw ? 0 : ln.length();
+ }
+ } // while true
+}
+
+// Contributed by <brain@hdsnet.hu>
+QString DocWordCompletionPluginView::findLongestUnique(const QValueList < KTextEditor::CompletionEntry > &matches)
+{
+ QString partial = matches.front().text;
+ QValueList < KTextEditor::CompletionEntry >::const_iterator i = matches.begin();
+ for (++i; i != matches.end(); ++i)
+ {
+ if (!(*i).text.startsWith(partial))
+ {
+ while(partial.length() > 0)
+ {
+ partial.remove(partial.length() - 1, 1);
+ if ((*i).text.startsWith(partial))
+ {
+ break;
+ }
+ }
+ if (partial.length() == 0)
+ return QString();
+ }
+ }
+
+ return partial;
+}
+
+// Return the string to complete (the letters behind the cursor)
+QString DocWordCompletionPluginView::word()
+{
+ uint cline, ccol;
+ viewCursorInterface( m_view )->cursorPositionReal( &cline, &ccol );
+ if ( ! ccol ) return QString::null; // no word
+ KTextEditor::EditInterface *ei = KTextEditor::editInterface( m_view->document() );
+ d->re.setPattern( "\\b(\\w+)$" );
+ if ( d->re.searchRev(
+ ei->text( cline, 0, cline, ccol )
+ ) < 0 )
+ return QString::null; // no word
+ return d->re.cap( 1 );
+}
+
+// Scan throught the entire document for possible completions,
+// ignoring any dublets
+QValueList<KTextEditor::CompletionEntry> DocWordCompletionPluginView::allMatches( const QString &word )
+{
+ QValueList<KTextEditor::CompletionEntry> l;
+ uint i( 0 );
+ int pos( 0 );
+ d->re.setPattern( "\\b("+word+"\\w+)" );
+ QString s, m;
+ KTextEditor::EditInterface *ei = KTextEditor::editInterface( m_view->document() );
+ QDict<int> seen; // maybe slow with > 17 matches
+ int sawit(1); // to ref for the dict
+ uint cline, ccol;// needed to avoid constructing a word at cursor position
+ viewCursorInterface( m_view )->cursorPositionReal( &cline, &ccol );
+
+ while( i < ei->numLines() )
+ {
+ s = ei->textLine( i );
+ pos = 0;
+ while ( pos >= 0 )
+ {
+ pos = d->re.search( s, pos );
+ if ( pos >= 0 )
+ {
+ // do not construct a new word!
+ if ( i == cline && pos + word.length() == ccol )
+ {
+ pos += word.length();
+ continue;
+ }
+
+ m = d->re.cap( 1 );
+ if ( ! seen[ m ] ) {
+ seen.insert( m, &sawit );
+ KTextEditor::CompletionEntry e;
+ e.text = m;
+ l.append( e );
+ }
+ pos += d->re.matchedLength();
+ }
+ }
+ i++;
+ }
+ return l;
+}
+
+void DocWordCompletionPluginView::slotVariableChanged( const QString &var, const QString &val )
+{
+ if ( var == "wordcompletion-autopopup" )
+ d->autopopup->setEnabled( val == "true" );
+ else if ( var == "wordcompletion-treshold" )
+ d->treshold = val.toInt();
+}
+//END
+
+//BEGIN DocWordCompletionConfigPage
+DocWordCompletionConfigPage::DocWordCompletionConfigPage( DocWordCompletionPlugin *completion, QWidget *parent, const char *name )
+ : KTextEditor::ConfigPage( parent, name )
+ , m_completion( completion )
+{
+ QVBoxLayout *lo = new QVBoxLayout( this );
+ lo->setSpacing( KDialog::spacingHint() );
+
+ cbAutoPopup = new QCheckBox( i18n("Automatically &show completion list"), this );
+ lo->addWidget( cbAutoPopup );
+
+ QHBox *hb = new QHBox( this );
+ hb->setSpacing( KDialog::spacingHint() );
+ lo->addWidget( hb );
+ QLabel *l = new QLabel( i18n(
+ "Translators: This is the first part of two strings wich will comprise the "
+ "sentence 'Show completions when a word is at least N characters'. The first "
+ "part is on the right side of the N, which is represented by a spinbox "
+ "widget, followed by the second part: 'characters long'. Characters is a "
+ "ingeger number between and including 1 and 30. Feel free to leave the "
+ "second part of the sentence blank if it suits your language better. ",
+ "Show completions &when a word is at least"), hb );
+ sbAutoPopup = new QSpinBox( 1, 30, 1, hb );
+ l->setBuddy( sbAutoPopup );
+ lSbRight = new QLabel( i18n(
+ "This is the second part of two strings that will comprise teh sentence "
+ "'Show completions when a word is at least N characters'",
+ "characters long."), hb );
+
+ QWhatsThis::add( cbAutoPopup, i18n(
+ "Enable the automatic completion list popup as default. The popup can "
+ "be disabled on a view basis from the 'Tools' menu.") );
+ QWhatsThis::add( sbAutoPopup, i18n(
+ "Define the length a word should have before the completion list "
+ "is displayed.") );
+
+ cbAutoPopup->setChecked( m_completion->autoPopupEnabled() );
+ sbAutoPopup->setValue( m_completion->treshold() );
+
+ lo->addStretch();
+}
+
+void DocWordCompletionConfigPage::apply()
+{
+ m_completion->setAutoPopupEnabled( cbAutoPopup->isChecked() );
+ m_completion->setTreshold( sbAutoPopup->value() );
+ m_completion->writeConfig();
+}
+
+void DocWordCompletionConfigPage::reset()
+{
+ cbAutoPopup->setChecked( m_completion->autoPopupEnabled() );
+ sbAutoPopup->setValue( m_completion->treshold() );
+}
+
+void DocWordCompletionConfigPage::defaults()
+{
+ cbAutoPopup->setChecked( true );
+ sbAutoPopup->setValue( 3 );
+}
+
+//END DocWordCompletionConfigPage
+
+#include "docwordcompletion.moc"
+// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
diff --git a/kate/plugins/wordcompletion/docwordcompletion.h b/kate/plugins/wordcompletion/docwordcompletion.h
new file mode 100644
index 000000000..b42560fca
--- /dev/null
+++ b/kate/plugins/wordcompletion/docwordcompletion.h
@@ -0,0 +1,133 @@
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ 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.
+
+ ---
+ file: docwordcompletion.h
+
+ KTextEditor plugin to autocompletion with document words.
+ Copyright Anders Lund <anders.lund@lund.tdcadsl.dk>, 2003
+
+ The following completion methods are supported:
+ * Completion with bigger matching words in
+ either direction (backward/forward).
+ * NOT YET Pop up a list of all bigger matching words in document
+
+*/
+
+#ifndef _DocWordCompletionPlugin_h_
+#define _DocWordCompletionPlugin_h_
+
+#include <ktexteditor/plugin.h>
+#include <ktexteditor/view.h>
+#include <ktexteditor/codecompletioninterface.h>
+#include <ktexteditor/configinterfaceextension.h>
+#include <kxmlguiclient.h>
+
+#include <qevent.h>
+#include <qobject.h>
+#include <qvaluelist.h>
+
+class DocWordCompletionPlugin
+ : public KTextEditor::Plugin
+ , public KTextEditor::PluginViewInterface
+ , public KTextEditor::ConfigInterfaceExtension
+{
+ Q_OBJECT
+
+ public:
+ DocWordCompletionPlugin( QObject *parent = 0,
+ const char* name = 0,
+ const QStringList &args = QStringList() );
+ virtual ~DocWordCompletionPlugin() {};
+
+ void addView (KTextEditor::View *view);
+ void removeView (KTextEditor::View *view);
+
+ void readConfig();
+ void writeConfig();
+
+ // ConfigInterfaceExtention
+ uint configPages() const { return 1; };
+ KTextEditor::ConfigPage * configPage( uint number, QWidget *parent, const char *name );
+ QString configPageName( uint ) const;
+ QString configPageFullName( uint ) const;
+ QPixmap configPagePixmap( uint, int ) const;
+
+ uint treshold() const { return m_treshold; };
+ void setTreshold( uint t ) { m_treshold = t; };
+ bool autoPopupEnabled() const { return m_autopopup; };
+ void setAutoPopupEnabled( bool enable ) { m_autopopup = enable; };
+
+
+ private:
+ QPtrList<class DocWordCompletionPluginView> m_views;
+ uint m_treshold;
+ bool m_autopopup;
+
+};
+
+class DocWordCompletionPluginView
+ : public QObject, public KXMLGUIClient
+{
+ Q_OBJECT
+
+ public:
+ DocWordCompletionPluginView( uint treshold=3, bool autopopup=true, KTextEditor::View *view=0,
+ const char *name=0 );
+ ~DocWordCompletionPluginView() {};
+
+ void settreshold( uint treshold );
+
+ private slots:
+ void completeBackwards();
+ void completeForwards();
+ void shellComplete();
+
+ void popupCompletionList( QString word=QString::null );
+ void autoPopupCompletionList();
+ void toggleAutoPopup();
+
+ void slotVariableChanged( const QString &, const QString & );
+
+ private:
+ void complete( bool fw=true );
+
+ QString word();
+ QValueList<KTextEditor::CompletionEntry> allMatches( const QString &word );
+ QString findLongestUnique(const QValueList < KTextEditor::CompletionEntry > &matches);
+ KTextEditor::View *m_view;
+ struct DocWordCompletionPluginViewPrivate *d;
+};
+
+class DocWordCompletionConfigPage : public KTextEditor::ConfigPage
+{
+ Q_OBJECT
+ public:
+ DocWordCompletionConfigPage( DocWordCompletionPlugin *completion, QWidget *parent, const char *name );
+ virtual ~DocWordCompletionConfigPage() {};
+
+ virtual void apply();
+ virtual void reset();
+ virtual void defaults();
+
+ private:
+ DocWordCompletionPlugin *m_completion;
+ class QCheckBox *cbAutoPopup;
+ class QSpinBox *sbAutoPopup;
+ class QLabel *lSbRight;
+};
+
+#endif // _DocWordCompletionPlugin_h_
+// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
diff --git a/kate/plugins/wordcompletion/docwordcompletionui.rc b/kate/plugins/wordcompletion/docwordcompletionui.rc
new file mode 100644
index 000000000..f8095e128
--- /dev/null
+++ b/kate/plugins/wordcompletion/docwordcompletionui.rc
@@ -0,0 +1,16 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="ktexteditor_docwordcompletion" library="ktexteditor_docwordcompletion" version="4">
+<MenuBar>
+ <Menu name="tools"><Text>&amp;Tools</Text>
+ <separator group="tools_operations" />
+ <menu name="wordcompletion" group="tools_operations"><text>Word Completion</text>
+ <Action name="doccomplete_fw" />
+ <Action name="doccomplete_bw" />
+ <Action name="doccomplete_pu" />
+ <Action name="doccomplete_sh" />
+ <separator />
+ <action name="enable_autopopup" />
+ </menu>
+ </Menu>
+</MenuBar>
+</kpartplugin>
diff --git a/kate/plugins/wordcompletion/ktexteditor_docwordcompletion.desktop b/kate/plugins/wordcompletion/ktexteditor_docwordcompletion.desktop
new file mode 100644
index 000000000..dd2a5e8dc
--- /dev/null
+++ b/kate/plugins/wordcompletion/ktexteditor_docwordcompletion.desktop
@@ -0,0 +1,139 @@
+[Desktop Entry]
+Name=KTextEditor Word Completion Plugin
+Name[af]=KTextEditor Woord Voltooiïng Inprop Module
+Name[be]=Модуль заканчэння словаў
+Name[bn]=কে-টেক্সট-এডিটর শব্দ পরিপূরণ প্লাগ-ইন
+Name[bs]=KTextEditor dodatak za dovršavanje riječi
+Name[ca]=Endollable de completar paraules del KTextEditor
+Name[cs]=Modul pro doplňování slov
+Name[csb]=Plugins editorë do dofùlowaniô słowów
+Name[da]=KTextEditor 'ord-kompletterings'-plugin
+Name[de]=KTextEditor-Erweiterung für Wortergänzungen
+Name[el]=Πρόσθετο συμπλήρωσης λέξεων του KTextEditor
+Name[eo]=KTextEditor Vortkompletiga kromaĵo
+Name[es]=Plugin de completado de palabras de KTextEditor
+Name[et]=KTextEditori sõna lõpetamise plugin
+Name[eu]=KTextEditor-en hitzen osaketarako plugin-a
+Name[fa]=وصلۀ تکمیل واژۀ KTextEditor
+Name[fi]=KTextEditorin sanojen täydennyslaajennus
+Name[fr]=Module externe de complètement des mots de KTextEditor
+Name[fy]=KTextEditor plugin foar it kompleet meitje fan wurden
+Name[ga]=Breiseán Comhlánaithe Focal KTextEditor
+Name[gl]=Plugin de Completado de Palabras de KTextEditor
+Name[he]=תוסף השלמה אוטומטית של מילים עבור KTextEditor
+Name[hi]=के-टेक्स्ट-एडिटर वर्ड कम्प्लीशन प्लगिन
+Name[hr]=KTextEditor dodatak za dopunjavanje riječi
+Name[hsb]=KTextEditor Plugin za wudospołnjenje słowow
+Name[hu]=KTextEditor szókiegészítő bővítőmodul
+Name[id]=Plugin Pelengkapan Kata KTextEditor
+Name[is]=KTextEditor íforrit til að klára orð
+Name[it]=Plugin completamento parole di KTextEditor
+Name[ja]=KTextEditor 単語補完プラグイン
+Name[ka]=სიტყვების თვითშევსების KTextEditor-ის მოდული
+Name[kk]=KTextEditor сөздерді аяқтау модулі
+Name[km]=កម្មវិធី​ជំនួយ​បំពេញ​ពាក្យ​របស់ KTextEditor
+Name[ko]=K글월편집기 낱말 완성 플러그인
+Name[lb]=KTextEditor-Wuert-Vervollstännegungs-Plugin
+Name[lt]=KTextEditor žodžio užbaigimo priedas
+Name[lv]=KTextEditor vārdu pabeigšanas spraudnis
+Name[mk]=KTextEditor приклучок за довршување на зборови
+Name[ms]=Plug masuk Penyudah Kata Fail KTextEditor
+Name[nb]=Programtillegg for ordfullføring i KTextEditor
+Name[nds]=KTextEditor-Plugin för Woort-Kompletteren
+Name[ne]=KTextEditor शब्द समाप्ति प्लगइन
+Name[nl]=KTextEditor-plugin voor het aanvullen van woorden
+Name[nn]=Programtillegg for ordfullføring i KTextEditor
+Name[pa]=KTextEditor ਪਾਠ ਪੂਰਨ ਪਲੱਗਿੰਨ
+Name[pl]=Wtyczka edytora do dopełniania słów
+Name[pt]='Plugin' de Completação de Palavras do KTextEditor
+Name[pt_BR]=Plug-in de Complementação de Palavras para Editor de textos
+Name[ro]=Modul completare cuvinte pentru KTextEditor
+Name[ru]=Модуль автодополнения слов KTextEditor
+Name[rw]=Icomeka ry'Iyuzuza Jambo rya KMuhinduziUmwandiko
+Name[se]=KTextEditor:a sátneollašuhttinlassemoduvla
+Name[sk]=Modul pre doplnenie slov pre KTextEditor
+Name[sl]=Vstavek KTextEditor za dopolnjevanje besed
+Name[sr]=KTextEditor прикључак за довршавање речи
+Name[sr@Latn]=KTextEditor priključak za dovršavanje reči
+Name[sv]=Ktexteditor-insticksprogram för att komplettera ord
+Name[ta]=கேஉரைதொகுப்பாளர் கோப்பு உள்ளீட்டுச் சொருகுப்பொருள்
+Name[te]=కెటెక్స్ట్ ఎడిటర్ పద పూరణ ప్లగిన్
+Name[tg]=Модули худиловакунандаи калимаҳои KTextEditor
+Name[th]=ปลักอินการเติมคำให้สมบูรณ์ของ KTextEditor
+Name[tr]=KTextEditor Kelime Tamamlama Eklentisi
+Name[tt]=KTextEditor'nıñ Süz Tulılandıru Östämäse
+Name[uk]=Втулок KTextEditor для завершення слів
+Name[vi]=Bộ cầm phít Nhập xong Từ KTextEditor
+Name[zh_CN]=KTextEditor 单词补全插件
+Name[zh_HK]=KTextEditor 文字自動補齊外掛程式
+Name[zh_TW]=KTextEditor 單字補完外掛程式
+Comment=Directional or popup-based completion from words in the document
+Comment[af]=Direksionele of opspring gebaseerde woord voltooiïng van woorde in die dokument
+Comment[be]=Простае заканчэнне словаў ці выплыўнае вакно з варыянтамі заканчэння
+Comment[bg]=Автоматично завършване на думи, базирано на използваните вече думи в документа
+Comment[bn]=ডকুমেন্ট-এর অন্যান্য শব্দের উপর ভিত্তি করে পরিপূরণ
+Comment[bs]=Direkcionalno ili popup-bazirano dovršavanje za riječi u dokumentu
+Comment[ca]=Compleció de paraules del document dirigida o basada en emergents
+Comment[cs]=Přímé nebo vyskakovací doplňování slov v dokumentu
+Comment[csb]=Dofùlowanié na spòdlëm lëstë słowów w dokùmence
+Comment[da]=Retnings- eller popop-baseret fuldstændiggørelse ud fra ord i dokumentet
+Comment[de]=Richtungs- oder über Aufklappfenstergesteuerte automatische Vervollständigung von Wörtern in Dokumenten
+Comment[el]=Κατευθυντική ή μέσω αναδυόμενων μενού συμπλήρωση από λέξεις μέσα στο έγγραφο
+Comment[eo]=Regula aŭ ŝprucbazita kompletigo de vortoj en la dokumento
+Comment[es]=Completado de palabras direccional o de menú emergente en el documento.
+Comment[et]=Lõpetamine vastavalt suunale või hüpikvariantide alusel dokumendi sõnade põhjal
+Comment[eu]=Dokumentuko hitzen osaketarako plugin-a
+Comment[fa]=تکمیل جهت‌دار یا مبنی بر بالاپر از کلمات موجود در سند
+Comment[fi]=Asiakirjasta löytyvillä sanoilla täydentäminen
+Comment[fr]=Complètement utilisant la direction ou un menu à partir des mots du document
+Comment[fy]=kompleet meitsje fan wurden yn it dokumint op Direktsjeneel of popup-basearje
+Comment[gl]=Completado direccional ou baseada en popup a partir de palabras no documento
+Comment[he]=השלמת מילים כיווניות או מבוססת תיבת מוקפצות של מילים מהמסמך
+Comment[hi]=डायरेक्शनल या पॉपअप-आधारित दस्तावेज़ में शब्द से कम्पलीशन.
+Comment[hr]=Usmjereno ili pop-up zasnovano dovršavanje iz riječi u dokumentu
+Comment[hsb]=Direktionalne abo na pop-up bazowace wudospołnjowanje za słowa w dokumenće
+Comment[hu]=Irány szerinti vagy felbukkanó kiegészítés dokumentum szavai alapján
+Comment[id]=Pelengkapan arahan atau popup dari kata di dalam dokumen
+Comment[is]=Áttvíst forrit sem getur líka opnað glugga með orðatillögum
+Comment[it]=Completamento direzionale o con finestre a comparsa di parole nel documento
+Comment[ja]=ポップアップまたはユーザの指示によってドキュメントの単語から補完します
+Comment[ka]=დოკუმენტში სიტყვების პირდაპირი მეთოდით ან ჩამოშლადი მენიუთი თვითშევსება
+Comment[kk]=Құжаттағы сөздерді аяқтау модулі
+Comment[km]=ការបំពេញ​ពាក្យ​ដោយ​ផ្ទាល់ ឬ តាម​រយៈ​ការលេចឡើង​នៃ​ពាក្យ​ដែល​មាន​ក្នុង​ឯកសារ
+Comment[lb]=Direktional oder Opklapp-Fënster-baséiert Vervollstännegung vu Wierder am Dokument
+Comment[lt]=Žodžių pabaigimas rašant dokumente pasiūlymus teikiant eilutėje arba iššokančiame meniu
+Comment[lv]=Vārdu automātiska pabeigšana izmantojot dokumentā jau esošos vārdus
+Comment[mk]=Насочено или скок-базирано довршување од зборови во документот
+Comment[ms]=Penyelesaian berarah atau berasaskan popup daripada perkataan dalam dokumen
+Comment[nb]=Retningsbestemt eller sprettopp-basert fullføring av ord i dokumentet
+Comment[nds]=Richten- oder Opdukbaseert Kompletteren vun Wöör binnen dat Dokment
+Comment[ne]=कागजातमा शब्दहरूबाट दिशानिर्देशित वा पपअपमा आधारित समाप्ति
+Comment[nl]=Voor het aanvullen van woorden in het document door middel van onder meer pop-ups
+Comment[nn]=Retningsbestemt eller sprettopp-basert fullføring av ord i dokumentet
+Comment[pa]=ਦਸਤਾਵੇਜ਼ ਵਿੱਚ ਦਿਸ਼ਾਵੀ ਜਾਂ ਪੋਪਅੱਪ ਆਧਾਰਿਤ ਸ਼ਬਦ ਪੂਰਨ
+Comment[pl]=Dopełnianie na podstawie listy słów w dokumencie
+Comment[pt]=Completação direccional ou por lista de palavras no documento
+Comment[pt_BR]=Complementação direcional, ou baseada em popup, de palavras do documento
+Comment[ro]=Propune completarea cuvintelor din document dintr-o listă popup sau direcţională
+Comment[ru]=Автодополнение слов в документе
+Comment[rw]=Irangiza mfatacyerekezo cyangwa rishingiye-kwirambura biva ku magambo yo mu nyandiko
+Comment[sk]=Dopĺňanie slov v dokumente priame alebo pomocou dialógu
+Comment[sl]=Neposredno ali pojavno dopolnjevanje iz besed v dokumentu
+Comment[sr]=Директна или искачућа допуна од речи у документу
+Comment[sr@Latn]=Direktna ili iskačuća dopuna od reči u dokumentu
+Comment[sv]=Komplettering av ord i dokumentet baserad på ordlista eller dialogruta
+Comment[ta]=ஆவணத்திலுள்ள வார்த்தைகளிலிருந்து திசைகள் அல்லது மேல்விரி-சார்ந்த நிறைவு
+Comment[te]=పత్రం లోని పదాలు వాడె, దిశా లేక పాప్ అప్ ఆధారిత పద పూరణ
+Comment[tg]=Худиловакунандаи калима дар ҳуҷҷат
+Comment[th]=การเติมคำให้สมบูรณ์โดยการชี้นำหรือ popup ขึ้นมา จากคำต่างๆ ในเอกสาร
+Comment[tr]=Doğrusal veya açılır-kuttu abanlı kelime tamamlama
+Comment[tt]=İstälek süzlärenä azaqlarnı yözep çığarıp kürsätä torğan närsä
+Comment[uk]=Завершення слів у документі. Пряме або на основі вигулькного меню
+Comment[vi]=Khả năng nhập xong từ trong tài liệu, đựa vào chiều hoặc vào bộ bật lên.
+Comment[zh_CN]=在文档中基于方向或弹出补全单词
+Comment[zh_TW]=在編輯文件時的單字補完功能
+X-KDE-Library=ktexteditor_docwordcompletion
+ServiceTypes=KTextEditor/Plugin
+Type=Service
+InitialPreference=8
+MimeType=text/plain