summaryrefslogtreecommitdiffstats
path: root/kate/part/katedocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kate/part/katedocument.cpp')
-rw-r--r--kate/part/katedocument.cpp107
1 files changed, 65 insertions, 42 deletions
diff --git a/kate/part/katedocument.cpp b/kate/part/katedocument.cpp
index 1404838c4..7781df55e 100644
--- a/kate/part/katedocument.cpp
+++ b/kate/part/katedocument.cpp
@@ -68,7 +68,7 @@
#include <kencodingfiledialog.h>
#include <tdetempfile.h>
#include <kmdcodec.h>
-#include <kstandarddirs.h>
+#include <tdestandarddirs.h>
#include <tqtimer.h>
#include <tqfile.h>
@@ -171,7 +171,7 @@ KateDocument::KateDocument ( bool bSingleViewMode, bool bBrowserView,
setMarksUserChangable( markType01 );
m_undoMergeTimer = new TQTimer(this);
- connect(m_undoMergeTimer, TQT_SIGNAL(timeout()), TQT_SLOT(undoCancel()));
+ connect(m_undoMergeTimer, TQ_SIGNAL(timeout()), TQ_SLOT(undoCancel()));
clearMarks ();
clearUndo ();
@@ -189,24 +189,24 @@ KateDocument::KateDocument ( bool bSingleViewMode, bool bBrowserView,
m_indenter->updateConfig ();
// some nice signals from the buffer
- connect(m_buffer, TQT_SIGNAL(tagLines(int,int)), this, TQT_SLOT(tagLines(int,int)));
- connect(m_buffer, TQT_SIGNAL(codeFoldingUpdated()),this,TQT_SIGNAL(codeFoldingUpdated()));
+ connect(m_buffer, TQ_SIGNAL(tagLines(int,int)), this, TQ_SLOT(tagLines(int,int)));
+ connect(m_buffer, TQ_SIGNAL(codeFoldingUpdated()),this,TQ_SIGNAL(codeFoldingUpdated()));
// if the user changes the highlight with the dialog, notify the doc
- connect(KateHlManager::self(),TQT_SIGNAL(changed()),TQT_SLOT(internalHlChanged()));
+ connect(KateHlManager::self(),TQ_SIGNAL(changed()),TQ_SLOT(internalHlChanged()));
// signal for the arbitrary HL
- connect(m_arbitraryHL, TQT_SIGNAL(tagLines(KateView*, KateSuperRange*)), TQT_SLOT(tagArbitraryLines(KateView*, KateSuperRange*)));
+ connect(m_arbitraryHL, TQ_SIGNAL(tagLines(KateView*, KateSuperRange*)), TQ_SLOT(tagArbitraryLines(KateView*, KateSuperRange*)));
// signals for mod on hd
- connect( KateFactory::self()->dirWatch(), TQT_SIGNAL(dirty (const TQString &)),
- this, TQT_SLOT(slotModOnHdDirty (const TQString &)) );
+ connect( KateFactory::self()->dirWatch(), TQ_SIGNAL(dirty (const TQString &)),
+ this, TQ_SLOT(slotModOnHdDirty (const TQString &)) );
- connect( KateFactory::self()->dirWatch(), TQT_SIGNAL(created (const TQString &)),
- this, TQT_SLOT(slotModOnHdCreated (const TQString &)) );
+ connect( KateFactory::self()->dirWatch(), TQ_SIGNAL(created (const TQString &)),
+ this, TQ_SLOT(slotModOnHdCreated (const TQString &)) );
- connect( KateFactory::self()->dirWatch(), TQT_SIGNAL(deleted (const TQString &)),
- this, TQT_SLOT(slotModOnHdDeleted (const TQString &)) );
+ connect( KateFactory::self()->dirWatch(), TQ_SIGNAL(deleted (const TQString &)),
+ this, TQ_SLOT(slotModOnHdDeleted (const TQString &)) );
// update doc name
setDocName ("");
@@ -220,7 +220,7 @@ KateDocument::KateDocument ( bool bSingleViewMode, bool bBrowserView,
setWidget( view );
}
- connect(this,TQT_SIGNAL(sigQueryClose(bool *, bool*)),this,TQT_SLOT(slotQueryClose_save(bool *, bool*)));
+ connect(this,TQ_SIGNAL(sigQueryClose(bool *, bool*)),this,TQ_SLOT(slotQueryClose_save(bool *, bool*)));
m_isasking = 0;
@@ -356,9 +356,9 @@ void KateDocument::disablePluginGUI (KTextEditor::Plugin *plugin)
KTextEditor::View *KateDocument::createView( TQWidget *parent, const char *name )
{
KateView* newView = new KateView( this, parent, name);
- connect(newView, TQT_SIGNAL(cursorPositionChanged()), TQT_SLOT(undoCancel()));
+ connect(newView, TQ_SIGNAL(cursorPositionChanged()), TQ_SLOT(undoCancel()));
if ( s_fileChangedDialogsActivated )
- connect( newView, TQT_SIGNAL(gotFocus( Kate::View * )), this, TQT_SLOT(slotModifiedOnDisk()) );
+ connect( newView, TQ_SIGNAL(gotFocus( Kate::View * )), this, TQ_SLOT(slotModifiedOnDisk()) );
return newView;
}
@@ -1913,13 +1913,13 @@ void KateDocument::writeConfig(TDEConfig *config)
void KateDocument::readConfig()
{
- TDEConfig *config = kapp->config();
+ TDEConfig *config = tdeApp->config();
readConfig (config);
}
void KateDocument::writeConfig()
{
- TDEConfig *config = kapp->config();
+ TDEConfig *config = tdeApp->config();
writeConfig (config);
config->sync();
}
@@ -1984,10 +1984,10 @@ void KateDocument::configDialog()
i18n("Configure"),
KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help,
KDialogBase::Ok,
- kapp->mainWidget() );
+ tdeApp->mainWidget() );
-#ifndef Q_WS_WIN //TODO: reenable
- KWin::setIcons( kd->winId(), kapp->icon(), kapp->miniIcon() );
+#ifndef TQ_WS_WIN //TODO: reenable
+ KWin::setIcons( kd->winId(), tdeApp->icon(), tdeApp->miniIcon() );
#endif
TQPtrList<KTextEditor::ConfigPage> editorPages;
@@ -2305,11 +2305,11 @@ bool KateDocument::openURL( const KURL &url )
m_job = TDEIO::get ( url, false, isProgressInfoEnabled() );
// connect to slots
- connect( m_job, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ),
- TQT_SLOT( slotDataKate( TDEIO::Job*, const TQByteArray& ) ) );
+ connect( m_job, TQ_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ),
+ TQ_SLOT( slotDataKate( TDEIO::Job*, const TQByteArray& ) ) );
- connect( m_job, TQT_SIGNAL( result( TDEIO::Job* ) ),
- TQT_SLOT( slotFinishedKate( TDEIO::Job* ) ) );
+ connect( m_job, TQ_SIGNAL( result( TDEIO::Job* ) ),
+ TQ_SLOT( slotFinishedKate( TDEIO::Job* ) ) );
TQWidget *w = widget ();
if (!w && !m_views.isEmpty ())
@@ -2411,7 +2411,7 @@ bool KateDocument::openFile(TDEIO::Job * job)
// read dir config (if possible and wanted)
if (!m_reloading)
- readDirConfig ();
+ readDirConfig ();
// do we have success ?
bool success = m_buffer->openFile (m_file);
@@ -2521,7 +2521,7 @@ bool KateDocument::save()
// get the right permissions, start with safe default
mode_t perms = 0600;
TDEIO::UDSEntry fentry;
- if (TDEIO::NetAccess::stat (url(), fentry, kapp->mainWidget()))
+ if (TDEIO::NetAccess::stat (url(), fentry, tdeApp->mainWidget()))
{
kdDebug () << "stating succesfull: " << url() << endl;
KFileItem item (fentry, url());
@@ -2530,8 +2530,8 @@ bool KateDocument::save()
// first del existing file if any, than copy over the file we have
// failure if a: the existing file could not be deleted, b: the file could not be copied
- if ( (!TDEIO::NetAccess::exists( u, false, kapp->mainWidget() ) || TDEIO::NetAccess::del( u, kapp->mainWidget() ))
- && TDEIO::NetAccess::file_copy( url(), u, perms, true, false, kapp->mainWidget() ) )
+ if ( (!TDEIO::NetAccess::exists( u, false, tdeApp->mainWidget() ) || TDEIO::NetAccess::del( u, tdeApp->mainWidget() ))
+ && TDEIO::NetAccess::file_copy( url(), u, perms, true, false, tdeApp->mainWidget() ) )
{
kdDebug(13020)<<"backing up successfull ("<<url().prettyURL()<<" -> "<<u.prettyURL()<<")"<<endl;
}
@@ -3135,15 +3135,27 @@ void KateDocument::backspace( KateView *view, const KateTextCursor& c )
if ((col == 0) && (line == 0))
return;
+ KateTextLine::Ptr tl = m_buffer->plainLine(line);
+ if (!tl)
+ {
+ return;
+ }
+
+ // Make sure to handle surrogate pairs correctly
+ uint fromCol = col - 1;
+ TQChar prevChar = tl->getChar(col - 1);
+ if (prevChar.isLowSurrogate() && tl->getChar(col - 2).isHighSurrogate())
+ {
+ fromCol = col - 2;
+ prevChar = tl->getChar(col - 2);
+ }
+
int complement = 0;
if (col > 0)
{
if (config()->configFlags() & KateDocument::cfAutoBrackets)
{
// if inside empty (), {}, [], '', "" delete both
- KateTextLine::Ptr tl = m_buffer->plainLine(line);
- if(!tl) return;
- TQChar prevChar = tl->getChar(col-1);
TQChar nextChar = tl->getChar(col);
if ( (prevChar == '"' && nextChar == '"') ||
@@ -3158,8 +3170,7 @@ void KateDocument::backspace( KateView *view, const KateTextCursor& c )
if (!(config()->configFlags() & KateDocument::cfBackspaceIndents))
{
// ordinary backspace
- //c.cursor.col--;
- removeText(line, col-1, line, col+complement);
+ removeText(line, fromCol, line, col+complement);
}
else
{
@@ -3215,9 +3226,23 @@ void KateDocument::del( KateView *view, const KateTextCursor& c )
return;
}
- if( c.col() < (int) m_buffer->plainLine(c.line())->length())
+ KateTextLine::Ptr tl = m_buffer->plainLine(c.line());
+ if (!tl)
{
- removeText(c.line(), c.col(), c.line(), c.col()+1);
+ return;
+ }
+ uint lineLen = tl->length();
+ uint col = (uint)c.col();
+ if (col < lineLen)
+ {
+ // Make sure to handle surrogate pairs correctly
+ uint toCol = col + 1;
+ if (tl->getChar(col).isHighSurrogate() && tl->getChar(col + 1).isLowSurrogate())
+ {
+ toCol = col + 2;
+ }
+
+ removeText(c.line(), col, c.line(), toCol);
}
else if ( (uint)c.line() < lastLine() )
{
@@ -4654,7 +4679,7 @@ void KateDocument::readVariableLine( TQString t, bool onlyViewAndRenderer )
bool found = false;
for (TQStringList::size_type i = 0; !found && i < wildcards.size(); ++i)
{
- TQRegExp wildcard (wildcards[i], true/*Qt::CaseSensitive*/, true/*TQRegExp::Wildcard*/);
+ TQRegExp wildcard (wildcards[i], true/*TQt::CaseSensitive*/, true/*TQRegExp::Wildcard*/);
found = wildcard.exactMatch (nameOfFile);
}
@@ -4964,7 +4989,7 @@ bool KateDocument::createDigest( TQCString &result )
if ( f.open( IO_ReadOnly) )
{
KMD5 md5;
- ret = md5.update( TQT_TQIODEVICE_OBJECT(f) );
+ ret = md5.update( f );
md5.hexDigest( result );
f.close();
ret = true;
@@ -4978,13 +5003,13 @@ TQString KateDocument::reasonedMOHString() const
switch( m_modOnHdReason )
{
case 1:
- return i18n("The file '%1' was modified by another program.").arg( url().prettyURL() );
+ return i18n("The file '%1' was modified by another program.").arg( url().pathOrURL() );
break;
case 2:
- return i18n("The file '%1' was created by another program.").arg( url().prettyURL() );
+ return i18n("The file '%1' was created by another program.").arg( url().pathOrURL() );
break;
case 3:
- return i18n("The file '%1' was deleted by another program.").arg( url().prettyURL() );
+ return i18n("The file '%1' was deleted by another program.").arg( url().pathOrURL() );
break;
default:
return TQString();
@@ -5180,5 +5205,3 @@ bool KateDocument::toggleBlockSelectionMode ()
//END DEPRECATED
//END DEPRECATED STUFF
-
-// kate: space-indent on; indent-width 2; replace-tabs on;