Commit 6b272c40 authored by Christoph Cullmann's avatar Christoph Cullmann

we shall use sanebrace plugin for KF5

parent 55821d99
kate: indent-width 4; space-indent on;
\ No newline at end of file
project(ktexteditor_autobrace)
add_subdirectory( icons )
########### next target ###############
set(ktexteditor_autobrace_PART_SRCS autobrace.cpp autobrace_config.cpp)
kde4_add_plugin(ktexteditor_autobrace ${ktexteditor_autobrace_PART_SRCS} )
target_link_libraries(ktexteditor_autobrace ${KDE4_KDECORE_LIBS} ktexteditor )
install(TARGETS ktexteditor_autobrace DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install(FILES ktexteditor_autobrace.desktop ktexteditor_autobrace_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
This diff is collapsed.
/**
* This file is part of the KDE libraries
* Copyright (C) 2008 Jakob Petsovits <jpetso@gmx.at>
*
* 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.
*/
#ifndef AUTOBRACE_H
#define AUTOBRACE_H
#include <ktexteditor/plugin.h>
#include <ktexteditor/view.h>
#include <ktexteditor/document.h>
#include <kpluginfactory.h>
#include <QtCore/QEvent>
#include <QtCore/QObject>
#include <QtCore/QHash>
#include <QtCore/QVariantList>
class AutoBracePlugin
: public KTextEditor::Plugin
{
Q_OBJECT
public:
explicit AutoBracePlugin(QObject *parent = 0, const QVariantList &args = QVariantList());
virtual ~AutoBracePlugin();
static AutoBracePlugin *self() { return plugin; }
void addView (KTextEditor::View *view);
void removeView (KTextEditor::View *view);
void readConfig();
void writeConfig();
virtual void readConfig (KConfig *) {}
virtual void writeConfig (KConfig *) {}
/// Inline Option Get/Setters
bool autoBrackets() const { return m_autoBrackets; }
void setAutoBrackets(bool y) { m_autoBrackets = y; }
bool autoQuotations() const { return m_autoQuotations; }
void setAutoQuotations(bool y) { m_autoQuotations = y; }
private:
static AutoBracePlugin *plugin;
QHash<class KTextEditor::View*, class KTextEditor::Document*> m_documents;
QHash<class KTextEditor::Document*, class AutoBracePluginDocument*> m_docplugins;
bool m_autoBrackets;
bool m_autoQuotations;
};
class AutoBracePluginDocument
: public QObject, public KXMLGUIClient
{
Q_OBJECT
public:
explicit AutoBracePluginDocument(KTextEditor::Document *document, const bool& autoBrackets, const bool& autoQuotations);
~AutoBracePluginDocument();
private Q_SLOTS:
void slotTextChanged(KTextEditor::Document *document);
void slotTextInserted(KTextEditor::Document *document, const KTextEditor::Range& range);
void slotTextRemoved(KTextEditor::Document *document, const KTextEditor::Range& range);
void connectSlots(KTextEditor::Document* document);
void disconnectSlots(KTextEditor::Document* document);
private:
bool isInsertionCandidate(KTextEditor::Document *document, int openingBraceLine);
Q_SIGNALS:
void indent();
private:
void insertAutoBracket(KTextEditor::Document *document,const KTextEditor::Range& range,
const QString& brace);
const QString previousToken(KTextEditor::Document *document,const KTextEditor::Range& range);
const QString nextToken(KTextEditor::Document *document,const KTextEditor::Range& range);
int m_insertionLine;
QString m_indentation;
bool m_withSemicolon;
KTextEditor::Range m_lastRange;
const bool& m_autoBrackets;
const bool& m_autoQuotations;
};
K_PLUGIN_FACTORY_DECLARATION(AutoBracePluginFactory)
#endif // AUTOBRACE_H
/**
* This file is part of the KDE libraries
* Copyright (C) 2010 André Stein <andre.stein@rwth-aachen.de>
*
* 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.
*/
#include "autobrace_config.h"
#include "autobrace.h"
#include <QtGui/QBoxLayout>
#include <QtGui/QCheckBox>
#include <klocale.h>
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <klineedit.h>
#include <kconfiggroup.h>
AutoBraceConfig::AutoBraceConfig(QWidget *parent, const QVariantList &args)
: KCModule(AutoBracePluginFactory::componentData(), parent, args)
{
QVBoxLayout *layout = new QVBoxLayout(this);
m_autoBrackets = new QCheckBox(i18n("Automatically add closing brackets ) and ] (and } for e.g. LaTeX)"), this);
m_autoQuotations = new QCheckBox(i18n("Automatically add closing quotation marks"), this);
layout->addWidget(m_autoBrackets);
layout->addWidget(m_autoQuotations);
setLayout(layout);
load();
// Changed slots
connect(m_autoBrackets, SIGNAL(toggled(bool)), this, SLOT(slotChanged(bool)));
connect(m_autoQuotations, SIGNAL(toggled(bool)), this, SLOT(slotChanged(bool)));
}
AutoBraceConfig::~AutoBraceConfig()
{
}
void AutoBraceConfig::save()
{
if (AutoBracePlugin::self())
{
AutoBracePlugin::self()->setAutoBrackets(m_autoBrackets->isChecked());
AutoBracePlugin::self()->setAutoQuotations(m_autoQuotations->isChecked());
AutoBracePlugin::self()->writeConfig();
}
else
{
KConfigGroup cg(KGlobal::config(), "AutoBrace Plugin");
cg.writeEntry("autobrackets", m_autoBrackets->isChecked());
cg.writeEntry("autoquotations", m_autoQuotations->isChecked());
}
emit changed(false);
}
void AutoBraceConfig::load()
{
if (AutoBracePlugin::self())
{
AutoBracePlugin::self()->readConfig();
m_autoBrackets->setChecked(AutoBracePlugin::self()->autoBrackets());
m_autoQuotations->setChecked(AutoBracePlugin::self()->autoQuotations());
}
else
{
KConfigGroup cg(KGlobal::config(), "AutoBrace Plugin" );
m_autoBrackets->setChecked(cg.readEntry("autobrackets", QVariant(true)).toBool());
m_autoQuotations->setChecked(cg.readEntry("autoquotations", QVariant(true)).toBool());
}
emit changed(false);
}
void AutoBraceConfig::defaults()
{
m_autoBrackets->setChecked(true);
m_autoQuotations->setChecked(true);
emit changed(true);
}
void AutoBraceConfig::slotChanged(bool)
{
emit changed(true);
}
#include "autobrace_config.moc"
/**
* This file is part of the KDE libraries
* Copyright (C) 2010 André Stein <andre.stein@rwth-aachen.de>
*
* 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.
*/
#ifndef TIMEDATE_CONFIG_H
#define TIMEDATE_CONFIG_H
#include <kcmodule.h>
class QCheckBox;
class AutoBraceConfig
: public KCModule
{
Q_OBJECT
public:
explicit AutoBraceConfig(QWidget *parent = 0, const QVariantList &args = QVariantList());
virtual ~AutoBraceConfig();
virtual void save();
virtual void load();
virtual void defaults();
private Q_SLOTS:
void slotChanged(bool);
private:
QCheckBox* m_autoBrackets;
QCheckBox* m_autoQuotations;
};
#endif // TIMEDATE_CONFIG_H
kde4_install_icons( ${ICON_INSTALL_DIR} )
\ No newline at end of file
[Desktop Entry]
X-KDE-Library=ktexteditor_autobrace
X-KDE-PluginKeyword=ktexteditor_autobrace
X-KDE-PluginInfo-Author=Jakob Petsovits
X-KDE-PluginInfo-Email=jpetso@gmx.at
X-KDE-PluginInfo-Name=ktexteditorautobrace
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://kate.kde.org
X-KDE-PluginInfo-Category=Editor
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-ParentApp=kate
X-KDE-Version=4.0
X-KDE-ServiceTypes=KTextEditor/Plugin
Type=Service
Icon=ktexteditorautobrace
Name=AutoBrace
Name[bg]=Автоматични скоби
Name[bs]=Autozagrade
Name[ca]=Parèntesis automàtics
Name[ca@valencia]=Parèntesis automàtics
Name[cs]=Automatické závorky
Name[da]=AutoBrace
Name[de]=AutoKlammern
Name[el]=AutoBrace
Name[en_GB]=AutoBrace
Name[es]=AutoLlaves
Name[et]=Automaatsulud
Name[eu]=Parentesi automatikoak
Name[fi]=Automaattisulutus
Name[fr]=Accolades automatiques
Name[ga]=AutoBrace
Name[gl]=Parénteses automáticos
Name[hu]=Automatikus zárójelbezáró
Name[ia]=AutoBrace (Parentheses Automatic)
Name[it]=Parentesi automatiche
Name[ja]=AutoBrace
Name[kk]=АвтоЖақшаЖабу
Name[km]=AutoBrace
Name[ko]=자동 괄호
Name[lt]=Automatiniai skliaustai
Name[lv]=Autom. figūriekavas
Name[mr]=ऑटो-ब्रेस
Name[nb]=AutoBrace
Name[nds]=Auto-Klemmen
Name[nl]=AutoHaakjes
Name[pa]=ਆਟੋ-ਬਰੈਕਟ
Name[pl]=Auto-klamrowanie
Name[pt]=Parêntesis Automáticos
Name[pt_BR]=Parênteses automático
Name[ro]=Închidere Automată a Acoladei
Name[ru]=Автоматическое закрытие скобок
Name[si]=AutoBrace
Name[sk]=AutoBrace
Name[sl]=Samodejni oklepaji
Name[sr]=Аутоматске заграде
Name[sr@ijekavian]=Аутоматске заграде
Name[sr@ijekavianlatin]=Automatske zagrade
Name[sr@latin]=Automatske zagrade
Name[sv]=Automatisk parentes
Name[tg]=Қавсҳои худкор
Name[tr]=AutoBrace
Name[ug]=AutoBrace
Name[uk]=Автоматичні дужки
Name[wa]=AutoBrace
Name[x-test]=xxAutoBracexx
Name[zh_CN]=自动括号
Name[zh_TW]=自動產生括號
Comment=Insert closing braces on pressing Enter
Comment[bg]=Затваряне на скобите при натискане на "Enter"
Comment[bs]=Ubacuje zatvarajuće zagrade pritiskom na Enter
Comment[ca]=Insereix els parèntesis de tancament en prémer Retorn
Comment[ca@valencia]=Insereix els parèntesis de tancament en prémer Retorn
Comment[cs]=Vložit uzavírací závorky při stisku Enter
Comment[da]=Indsæt afsluttende klammer ved tryk på Retur
Comment[de]=Beim Drücken der Eingabetaste schließende Klammer einfügen
Comment[el]=Κλείσιμο παρενθέσεων πιέζοντας το Enter
Comment[en_GB]=Insert closing braces on pressing Enter
Comment[es]=Insertar llaves de cierre al presionar Intro
Comment[et]=Lõpetavate sulgude lisamine Enteri vajutamisel
Comment[eu]=Txertatu itxierako parentesia Sartu sakatzean
Comment[fi]=Lisää lopettavat sulut painettaessa Enteriä
Comment[fr]=Insère des accolades fermantes lors d'un appui sur « Entrée »
Comment[ga]=Ionsáigh lúibín deiridh nuair a bhrúitear Enter
Comment[gl]=Insire os parénteses de peche ao premer Intro
Comment[hu]=Az Enter megnyomásakor beszúr egy zárójelet
Comment[ia]=Inserta un parentheses claudente quando on preme Enter
Comment[it]=Inserisci parentesi di chiusura alla pressione del tasto Invio
Comment[kk]=Enter пернені басқанда жақшаны жабу
Comment[km]=បញ្ចូល​ដោយ​បិទ braces ដោយ​ចុច​បញ្ចូល​
Comment[ko]=Enter 키를 누를 때 닫는 괄호 넣기
Comment[lt]=Įterpti uždarančius skliaustus paspaudus Enter
Comment[lv]=Nospiežot Enter, ievietot aizverošās figūriekavas
Comment[mr]=एंटर दाबल्यावर बंद समासचिन्ह अंतर्भूत करतो
Comment[nb]=Sett inn avsluttende krøllparentes når Enter trykkes
Comment[nds]=Afsluten Klemmen mit de Ingaavtast infögen
Comment[nl]=Voert afsluithaakjes in bij indrukken van Enter
Comment[pa]=ਐਂਟਰ ਦੱਬਣ ਉੱਤੇ ਬਰੈਕਟ ਬੰਦ ਕਰੋ
Comment[pl]=Wstaw klamrę zamykającą przy naciśnięciu Enteru
Comment[pt]=Inserir os parêntesis de fecho ao carregar em Enter
Comment[pt_BR]=Insere parênteses de fechamento ao pressionar Enter
Comment[ro]=Inserează acoladele de închidere la apăsarea Enter
Comment[ru]=Вставка парной скобки при нажатии клавиши Enter
Comment[si]=Enter යතුර එබීමේදී රැඳවුම් වසාදැමීම එක් කරන්න
Comment[sk]=Vložiť koniec zátvorky stlačením Enter
Comment[sl]=Vstavi zaklepaje ob pritisku na tipko Enter
Comment[sr]=Умеће затварајуће заграде кад се притисне Enter
Comment[sr@ijekavian]=Умеће затварајуће заграде кад се притисне Enter
Comment[sr@ijekavianlatin]=Umeće zatvarajuće zagrade kad se pritisne Enter
Comment[sr@latin]=Umeće zatvarajuće zagrade kad se pritisne Enter
Comment[sv]=Infoga avslutande parenteser när returtangenten trycks
Comment[tg]=Қавсҳои хотимавиро бо зеркунии тугмаи Enter ворид кунед
Comment[tr]=Enter'a basıldığında parantezi kapat
Comment[ug]=Enter بېسىلغاندا يېپىلغان braces قىستۇر
Comment[uk]=Вставляє завершальні дужки після натискання Enter
Comment[wa]=Stitchî des acolådes cloyantes å tchôcaedje d' Intrêye
Comment[x-test]=xxInsert closing braces on pressing Enterxx
Comment[zh_CN]=按下回车后插入反括号
Comment[zh_TW]=按下 Enter 時自動插入關閉(右側)括號
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=ktexteditor_autobrace
X-KDE-PluginKeyword=ktexteditor_autobrace_config
X-KDE-ParentComponents=ktexteditorautobrace
Name=AutoBrace Configuration
Name[bg]=Настройка на автоматичните скоби
Name[bs]=Konfiguracija automatskih zagrada
Name[ca]=Configuració dels parèntesis automàtics
Name[ca@valencia]=Configuració dels parèntesis automàtics
Name[cs]=Nastavení automatických závorek
Name[da]=Indstilling af AutoBrace
Name[de]=Einstellungen zu automatischer Klammersetzung
Name[el]=Διαμόρφωση AutoBrace
Name[en_GB]=AutoBrace Configuration
Name[es]=Configuración de AutoLlaves
Name[et]=Automaatsete sulgude seadistamine
Name[eu]=Parentesi automatikoen konfigurazioa
Name[fi]=Automaattisulutuksen asetukset
Name[fr]=Configuration des accolades automatiques
Name[ga]=Cumraíocht AutoBrace
Name[gl]=Configuración dos parénteses automáticos
Name[hu]=Beállítások - Automatikus zárójelbezáró
Name[ia]=Configuration de AutoBrace (Parentheses Automatic)
Name[it]=Configurazione parentesi automatiche
Name[ja]=AutoBrace の設定
Name[kk]=АвтоЖақшаЖабу баптауы
Name[km]=ការ​កំណត់​រចនាសម្ព័ន្ធ​ AutoBrace
Name[ko]=자동 괄호 설정
Name[lt]=Automatinių skliaustų konfigūracija
Name[lv]=Automātisko figūriekavu ievietošanas konfigurācija
Name[mr]=ऑटो-ब्रेस संयोजना
Name[nb]=Oppsett for automatisk parenteslukking
Name[nds]=Auto-Klemmen instellen
Name[nl]=Configuratie voor automatische haakjes
Name[pa]=AutoBrace ਸੰਰਚਨਾ
Name[pl]=Konfiguracja auto-klamrowania
Name[pt]=Configuração dos Parêntesis Automáticos
Name[pt_BR]=Configuração automática dos parênteses
Name[ro]=Configurare Închidere Automată a Acoladei
Name[ru]=Настройка автоматического закрытия скобок
Name[si]=AutoBrace සැකසුම
Name[sk]=Konfugurácia AutoBrace
Name[sl]=Nastavitve samodejnih oklepajev
Name[sr]=Подешавање аутоматских заграда
Name[sr@ijekavian]=Подешавање аутоматских заграда
Name[sr@ijekavianlatin]=Podešavanje automatskih zagrada
Name[sr@latin]=Podešavanje automatskih zagrada
Name[sv]=Automatisk parentesinställning
Name[tg]=Танзимоти қавсҳои худкор
Name[tr]=AutoBrace Yapılandırması
Name[ug]=AutoBrace سەپلىمە
Name[uk]=Налаштування автоматичних дужок
Name[wa]=Apontiaedje d' AutoBrace
Name[x-test]=xxAutoBrace Configurationxx
Name[zh_CN]=自动括号配置
Name[zh_TW]=AutoBrace 組態
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment