summaryrefslogtreecommitdiffstats
path: root/kate/modeline
diff options
context:
space:
mode:
Diffstat (limited to 'kate/modeline')
-rw-r--r--kate/modeline/Makefile.am21
-rw-r--r--kate/modeline/ModelinePlugin.cpp125
-rw-r--r--kate/modeline/ModelinePlugin.h40
-rw-r--r--kate/modeline/katemodeline.desktop119
-rw-r--r--kate/modeline/ui.rc8
5 files changed, 313 insertions, 0 deletions
diff --git a/kate/modeline/Makefile.am b/kate/modeline/Makefile.am
new file mode 100644
index 0000000..3afccbc
--- /dev/null
+++ b/kate/modeline/Makefile.am
@@ -0,0 +1,21 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = katemodelineplugin.la
+
+# This is all standard. Remove the LIB_KHTML reference if you are not
+# using the KHTML Part
+katemodelineplugin_la_SOURCES = ModelinePlugin.cpp
+katemodelineplugin_la_LIBADD = -lkateinterfaces
+katemodelineplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+# Install the .rc file in the Part's directory (in this case, the part
+# is KHTMLPart)
+pluginsdir = $(kde_datadir)/kate/plugins/katemodeline
+plugins_DATA = ui.rc
+
+kde_services_DATA = katemodeline.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/katemodeline.pot
diff --git a/kate/modeline/ModelinePlugin.cpp b/kate/modeline/ModelinePlugin.cpp
new file mode 100644
index 0000000..b288856
--- /dev/null
+++ b/kate/modeline/ModelinePlugin.cpp
@@ -0,0 +1,125 @@
+ /***************************************************************************
+ ModelinePlugin.cpp - description
+ -------------------
+ begin : Mon Apr 1 2002
+ copyright : (C) 2002 by John Firebaugh
+ email : jfirebaugh@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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 <qregexp.h>
+#include <kgenericfactory.h>
+#include <klocale.h>
+#include <kaction.h>
+#include <kdebug.h>
+
+#include <kate/application.h>
+#include <kate/documentmanager.h>
+#include <kate/viewmanager.h>
+#include <kate/mainwindow.h>
+#include <kate/document.h>
+#include <kate/view.h>
+
+#include "ModelinePlugin.h"
+#include "ModelinePlugin.moc"
+
+class PluginView : public KXMLGUIClient
+{
+ friend class ModelinePlugin;
+
+ public:
+ Kate::MainWindow *win;
+};
+
+K_EXPORT_COMPONENT_FACTORY( katemodelineplugin, KGenericFactory<ModelinePlugin>( "katemodeline" ) )
+
+ModelinePlugin::ModelinePlugin( QObject* parent, const char* name, const QStringList &args )
+ : Kate::Plugin ( (Kate::Application *) parent, name )
+{
+}
+
+ModelinePlugin::~ModelinePlugin()
+{
+}
+
+void ModelinePlugin::addView(Kate::MainWindow *win)
+{
+ // TODO: doesn't this have to be deleted?
+ PluginView *view = new PluginView ();
+
+ new KAction( i18n("Apply Modeline"), 0,
+ this, SLOT(applyModeline()),
+ view->actionCollection(), "edit_apply_modeline" );
+
+ view->setInstance (new KInstance("kate"));
+ view->setXMLFile( "plugins/katemodeline/ui.rc" );
+ win->guiFactory()->addClient (view);
+ view->win = win;
+
+ m_views.append (view);
+}
+
+void ModelinePlugin::removeView(Kate::MainWindow *win)
+{
+ for (uint z=0; z < m_views.count(); z++)
+ if (m_views.at(z)->win == win)
+ {
+ PluginView *view = m_views.at(z);
+ m_views.remove (view);
+ win->guiFactory()->removeClient (view);
+ delete view;
+ }
+}
+
+void ModelinePlugin::applyModeline()
+{
+ if (!application()->activeMainWindow())
+ return;
+
+ Kate::Document* doc = application()->documentManager()->activeDocument();
+ Kate::View* view = application()->activeMainWindow()->viewManager()->activeView();
+ if( !doc || !view ) return;
+ static QRegExp vim1( "\\b(?:vi:|vim:|ex:)[ \\t](.*)" );
+ static QRegExp vim2( "\\b(?:vi:|vim:|ex:)[ \\t]set (.*):" );
+ uint foundAtLine;
+ uint foundAtCol;
+ uint matchLen;
+ QString options;
+ if( doc->searchText( 0, 0, vim2, &foundAtLine, &foundAtCol, &matchLen ) ) {
+ options = vim2.cap(1);
+ } else if( doc->searchText( 0, 0, vim1, &foundAtLine, &foundAtCol, &matchLen ) ) {
+ options = vim1.cap(1);
+ options.replace( QRegExp( ":" ), " " );
+ }
+ uint configFlags = doc->configFlags();
+ kdDebug() << "Found modeline: " << options << endl;
+ if( options.find( QRegExp( "\\bnoet\\b" ) ) >= 0 ) {
+ kdDebug() << "Clearing replace tabs" << endl;
+ configFlags &= ~Kate::Document::cfReplaceTabs;
+ } else if( options.find( QRegExp( "\\bet\\b" ) ) >= 0 ) {
+ kdDebug() << "Setting replace tabs" << endl;
+ configFlags |= Kate::Document::cfReplaceTabs;
+ }
+ QRegExp ts( "ts=(\\d+)" );
+ if( options.find( ts ) >= 0 ) {
+ uint tabWidth = ts.cap(1).toUInt();
+ kdDebug() << "Setting tab width " << tabWidth << endl;
+ view->setTabWidth( tabWidth );
+ }
+ QRegExp tw( "tw=(\\d+)" );
+ if( options.find( tw ) >= 0 ) {
+ uint textWidth = tw.cap(1).toUInt();
+ kdDebug() << "Setting text width " << textWidth << endl;
+ doc->setWordWrap( true );
+ doc->setWordWrapAt( textWidth );
+ }
+ doc->setConfigFlags( configFlags );
+}
diff --git a/kate/modeline/ModelinePlugin.h b/kate/modeline/ModelinePlugin.h
new file mode 100644
index 0000000..3f4b818
--- /dev/null
+++ b/kate/modeline/ModelinePlugin.h
@@ -0,0 +1,40 @@
+ /***************************************************************************
+ ModelinePlugin.h - description
+ -------------------
+ begin : Mon Apr 1 2002
+ copyright : (C) 2002 by John Firebaugh
+ email : jfirebaugh@kde.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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 _ModelinePlugin_H_
+#define _ModelinePlugin_H_
+
+#include <kate/plugin.h>
+
+class ModelinePlugin : public Kate::Plugin, Kate::PluginViewInterface
+{
+ Q_OBJECT
+
+public:
+ ModelinePlugin( QObject* parent = 0, const char* name = 0, const QStringList &args = QStringList() );
+ virtual ~ModelinePlugin();
+
+ void addView (Kate::MainWindow *win);
+ void removeView (Kate::MainWindow *win);
+private slots:
+ void applyModeline();
+
+private:
+ QPtrList<class PluginView> m_views;
+};
+
+#endif // _ModelinePlugin_H_
diff --git a/kate/modeline/katemodeline.desktop b/kate/modeline/katemodeline.desktop
new file mode 100644
index 0000000..4d31ae6
--- /dev/null
+++ b/kate/modeline/katemodeline.desktop
@@ -0,0 +1,119 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=Kate/Plugin
+X-KDE-Library=katemodelineplugin
+X-Kate-Version=2.5
+Name=Kate Modeline Plugin
+Name[af]=Kate Moduslyn Inplak
+Name[ar]=ملحق Kate Modeline
+Name[az]=Kate Modeline ƏLavəsi
+Name[br]=Lugent Kate Modeline
+Name[ca]=Connector Modeline per a Kate
+Name[cy]=Ategyn Modd-linell Kate
+Name[da]=Kate Tilstandslinje-plugin
+Name[de]=Kate Modeline-Modul
+Name[el]=Πρόσθετο Modeline του Kate
+Name[eo]=Modolinia kromaĵo por Kodredaktilo
+Name[es]=Complemento Modeline de Kate
+Name[et]=Kate teaterea plugin
+Name[eu]=Kateren Modeline plugina
+Name[fa]=وصلۀ Kate Modeline
+Name[fi]=Kate Modeline -sovelma
+Name[fr]=Module externe Modeline pour Kate
+Name[fy]=Kate Modeline-plugin
+Name[gl]=Plugin de Liña de Modo para Kate
+Name[he]=תוסף Modeline ל־Kate
+Name[hi]=के-एटीई मॉडलाइन प्लगइन
+Name[hr]=Kate Modeline dodatak
+Name[hu]=Kate módsor-bővítőmodul
+Name[is]=Kate 'Modeline' viðbót
+Name[it]=Plugin Modeline di Kate
+Name[ja]=Kate Modeline プラグイン
+Name[ka]=Kate Modeline მოდული
+Name[kk]=Kate Modeline плагин модулі
+Name[km]=កម្មវិធី​ជំនួយ​​របៀប​បន្ទាត់ Kate
+Name[lt]=Kate Modeline priedas
+Name[mk]=Modeline-приклучок за Кате
+Name[ms]=Plug masuk Kate Modeline
+Name[nb]=Programtillegg for Kate moduslinje
+Name[nds]=Modeline-Moduul för Kate
+Name[ne]=केट मोडलाइन प्लगइन
+Name[nl]=Kate Modeline-plugin
+Name[nn]=Kate nivålinje-tillegg
+Name[pa]=ਕੇਟ ਢੰਗ-ਸਤਰ ਪਲੱਗਇਨ
+Name[pl]=Wtyczka ustawień linii do Kate
+Name[pt]='Plugin' de Linha de Modo do Kate
+Name[pt_BR]=Plugin Modeline do Kate
+Name[ro]=Modul "modeline" pentru Kate
+Name[ru]=Модуль строки состояния буфера для Kate
+Name[sk]=Kate Modeline modul
+Name[sl]=Vstavek za Modeline v Kate
+Name[sr]=Прикључак режимске линије за Kate
+Name[sr@Latn]=Priključak režimske linije za Kate
+Name[sv]=Kates lägesradsinsticksprogram
+Name[ta]=கேட் வரிவகை சொருகுப்பொருள்
+Name[tg]=Модули хатҳои ҳолати буфер барои Kate
+Name[th]=ปลั๊กอินโหมดไลน์ของ Kate
+Name[tr]=Kate Modeline Eklentisi
+Name[uk]=Втулок Modeline для Kate
+Name[vi]=Bổ sung dòng chế độ Kate
+Name[xh]=Ulayini wendlela yokwenza yeplagi yangaphakathi ye Kate
+Name[zh_CN]=Kate 状态行插件
+Name[zh_TW]=Kate Modeline 外掛程式
+Comment=Set document settings based on vim or emacs modelines
+Comment[ar]=عيّن اعدادات المستندات على أساس ملفات modelines الخاص بـvim أو emacs
+Comment[az]=Sənəd qurğularını vim ya da emacs əsaslarına görə tə'yin et
+Comment[bg]=Установяване на режим базиран на редакторите vim или emacs
+Comment[bs]=Podešava postavke dokumenta na osnovu vim ili emacs modeline-ova
+Comment[ca]=Estableix les preferències dels documents basant-se en mode de línies de vim o emacs
+Comment[cs]=Nastaví vlastnosti dokumentu v závislosti na "modeline" z Emacs nebo vi
+Comment[cy]=Gosod gosodiadau dogfen wedi eu seilio ar fodd-linellau vim neu emacs
+Comment[da]=Sæt dokumentindstillinger baseret på vim- eller emacs-tilstandslinjer
+Comment[de]=Dokumenteinstellungen aus vim- oder emacs-Modelines lesen
+Comment[el]=Καθορισμός των ρυθμίσεων του εγγράφου βασισμένες στις modelines του vim ή του emacs
+Comment[eo]=Metas dokumentan agordon laŭ vim aŭ emacs modolinioj
+Comment[es]=Configura las preferencias del documento basado en los modelos de vim o emacs
+Comment[et]=Rakendab dokumendi puhul vim'ile või emacs'ile sarnast teaterida
+Comment[eu]=Ezarri vim edo emacs-en lerro moduetan oinarritutako dokumentu ezarpenak
+Comment[fa]=تنظیمات سند را براساس modeline vim یا emacs تنظیم می‌کند.
+Comment[fi]=Aseta asiakirjan asetukset perustuen vim tai emacs modelineihin
+Comment[fo]=Nýt ásetingar fyri skjal grundað á vim ella emacs *modelines*
+Comment[fr]=Définir les réglages de document basés sur les modules de vim ou d'emacs
+Comment[fy]=Dokumintynstellingen basearre op vim- of emacs-modelines ynstelle
+Comment[gl]=Alterar as configuracións do documento con base nas liñas de modo de emacs ou de vim
+Comment[he]=קביעת הגדרות המסמך בהתבסס על modelines של vim או emacs
+Comment[hi]=वीआईएम या ईमैक्स मॉडलाइन्स आधारित दस्तावेज़ विन्यास नियत करता है
+Comment[hr]=Zadavanje postavki dokumenta na osnovu modelines iz vim-a ili emacs-a
+Comment[hu]=Dokumentumbeállítások VIM/emacs módleíró sorok alapján
+Comment[is]=Setur stillingar skjals byggt á vim eða emacs 'modeline'
+Comment[it]=Seleziona le impostazioni dei documenti basandosi sui "modeline" di emacs o vim
+Comment[ja]=vim や emacs のモード行によるドキュメント設定
+Comment[ka]=vim-ზე ან emacs-ის modeline-ზე დაფუძნებულ პარამეტრებს ანიჭებს დოკუმენტს
+Comment[kk]=vim не emacs modeline негіздеп, құжаттың параметрлерін орнатады
+Comment[km]=កំណត់​ការ​កំណត់​​ឯកសារ​ដោយ​​ផ្អែក​លើ​របៀប​បន្ទាត់របស់ vim ឬemacs
+Comment[lt]=Sukuria dokumento nustatymus pagal vim ar emacs dokumento komandas
+Comment[mk]=Ги мести поставувањата на документот базирани врз линии на режим за vim или emacs
+Comment[ms]=Tetapkan tetapan dokumen
+Comment[nb]=Tilpass dokumentinnstillinger basert på moduslinjer for vim eller emacs
+Comment[nds]=Dokmenteninstellen vun vim- oder emacs-Modelines lesen
+Comment[ne]=भिम वा इमाकस मोडलाइनमा आधारित कागजात सेटिङ सेट गर्नुहोस्
+Comment[nl]=Documentinstellingen gebaseerd op vim- of emacs-modelines instellen
+Comment[nn]=Vel dokumentinnstillingar basert på nivålinjer for vim eller emacs
+Comment[pl]=Zmienia ustawienia dokumentu zgodnie z ustawieniami linii vim lub emacs-a zapisanymi w pliku
+Comment[pt]=Alterar as configurações do documento com base nas linhas de modo do emacs ou do vim
+Comment[pt_BR]=Ajusta as configurações baseado no vim ou no emacs
+Comment[ro]=Configurează setările documentului în funcţie de "modeline"-urile Vim sau Emacs
+Comment[ru]=Показывает строку состояния буфера как в vim или emacs
+Comment[sk]=Nastaví nastavenia dokumentu založené na vim alebo emacs modely
+Comment[sl]=Uredi nastavitve dokumenta na podlagi določil v vim ali emacs
+Comment[sr]=Поставите подешавања документа на основу Vim-ових или Emacs-ових режимских линија
+Comment[sr@Latn]=Postavite podešavanja dokumenta na osnovu Vim-ovih ili Emacs-ovih režimskih linija
+Comment[sv]=Ställ in dokumentalternativ baserat på Vim- eller Emacs-lägesrader
+Comment[ta]=விம் அல்லது எமாக்ஸ் வரிவகை அடிப்படையிலான ஆவண அமைப்புகளை அமை
+Comment[tg]=Хати ҳолати буферо мисли vim ё emacs нишон медиҳад
+Comment[tr]=Belge ayarlarını vim veya emacs kipsatırına(modeline) göre yap
+Comment[uk]=Встановлює параметри документа на основі рядків режимів vim або emacs
+Comment[vi]=Thiết lập tài liệu dựa vào các dòng chế độ kiểu emacs hoặc vim
+Comment[xh]=Cwangcisa izicwangciso zoxwebhu olusekelwe kwi vim okanye kwi ndlela yeelayini ze emacs
+Comment[zh_CN]=根据 VIM 或 EMACS 状态行来设置文档
+Comment[zh_TW]=依 vim 或 emacs modelines 設定文件
diff --git a/kate/modeline/ui.rc b/kate/modeline/ui.rc
new file mode 100644
index 0000000..ef8fc22
--- /dev/null
+++ b/kate/modeline/ui.rc
@@ -0,0 +1,8 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="katemodeline" library="libkatemodelineplugin" version="2">
+<MenuBar>
+ <Menu name="tools"><text>&amp;Tools</text>
+ <Action name="edit_apply_modeline" />
+ </Menu>
+</MenuBar>
+</kpartplugin>