[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    KDE/kdelibs
From:       Joseph Wenninger <kde () jowenn ! at>
Date:       2006-09-24 13:58:03
Message-ID: 1159106283.813345.27587.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 587934 by jowenn:

detach cursor in the interface. I found it irritating that if I call cursorPosition I \
don't get a snapshot, but really a smart cursor in the kate implementation

CCMAIL:rodda@kde.org
CCMAIL:kwrite-devel@kde.org

 M  +2 -2      interfaces/ktexteditor/view.h  
 M  +3 -3      kate/part/katedocument.cpp  
 M  +1 -1      kate/part/katedocument.h  
 M  +23 -2     kate/part/katetemplatehandler.cpp  
 M  +9 -2      kate/part/kateview.cpp  
 M  +2 -2      kate/part/kateview.h  


--- trunk/KDE/kdelibs/interfaces/ktexteditor/view.h #587933:587934
@@ -315,7 +315,7 @@
      * \return \e true on success, otherwise \e false
      * \see cursorPosition()
      */
-    virtual bool setCursorPosition (const Cursor &position) = 0;
+    virtual bool setCursorPosition (Cursor position) = 0;
 
     /**
      * Get the view's current cursor position. A \e TAB character is
@@ -323,7 +323,7 @@
      * \return current cursor position
      * \see setCursorPosition()
      */
-    virtual const Cursor &cursorPosition () const = 0;
+    virtual Cursor cursorPosition () const = 0;
 
     /**
      * Get the current \e virtual cursor position, \e virtual means the
--- trunk/KDE/kdelibs/kate/part/katedocument.cpp #587933:587934
@@ -4943,12 +4943,12 @@
       return (new KateTemplateHandler(this,c,templateString,initialValues))->initOk();
  }
 
-#if 0
 void KateDocument::testTemplateCode() {
-  insertTemplateText(activeView()->cursorPosition(),"for ${index} \\${NOPLACEHOLDER} \
${index} ${blah} ${fullname} \\$${Placeholder} \\${${PLACEHOLDER2}}\n next \
line:${ANOTHERPLACEHOLDER} $${DOLLARBEFOREPLACEHOLDER} {NOTHING} \
{\n${cursor}\n}",QMap<QString,QString>()); +  \
//qobject_cast<KTextEditor::TemplateInterface*>(activeView())->insertTemplateText(activeView()->cursorPosition(),"for \
${index} \\${NOPLACEHOLDER} ${index} ${blah} ${fullname} \\$${Placeholder} \
\\${${PLACEHOLDER2}}\n next line:${ANOTHERPLACEHOLDER} $${DOLLARBEFOREPLACEHOLDER} \
{NOTHING} {\n${cursor}\n}",QMap<QString,QString>()); +  \
qobject_cast<KTextEditor::TemplateInterface*>(activeView())->insertTemplateText(activeView()->cursorPosition(),"for \
${index} \\${NOPLACEHOLDER} ${index} ${blah} \\$${Placeholder} \\${${PLACEHOLDER2}}\n \
next line:${ANOTHERPLACEHOLDER} $${DOLLARBEFOREPLACEHOLDER} {NOTHING} \
{\n${cursor}\n}",QMap<QString,QString>());  }
-#endif
 
+
 bool KateDocument::invokeTabInterceptor(int key) {
   if (m_tabInterceptor) return (*m_tabInterceptor)(key);
   return false;
--- trunk/KDE/kdelibs/kate/part/katedocument.h #587933:587934
@@ -963,7 +963,7 @@
       KateKeyInterceptorFunctor *m_tabInterceptor;
 
   protected Q_SLOTS:
-      //void testTemplateCode();
+      void testTemplateCode();
       void dumpRegionTree();
   public:
       class LoadSaveFilterCheckPlugins;
--- trunk/KDE/kdelibs/kate/part/katetemplatehandler.cpp #587933:587934
@@ -22,6 +22,10 @@
 #include "katesmartcursor.h"
 #include "kateview.h"
 
+#include <ktexteditor/cursor.h>
+#include <ktexteditor/smartcursor.h>
+#include <ktexteditor/smartrange.h>
+#include <ktexteditor/range.h>
 #include <ktexteditor/attribute.h>
 
 #include <qregexp.h>
@@ -137,6 +141,21 @@
 
 void KateTemplateHandler::generateRangeTable( const KTextEditor::Cursor& \
insertPosition, const QString& insertString, const \
QList<KateTemplateHandlerPlaceHolderInfo> &buildList )  {
+  kDebug(13020)<<"<<<<"<<insertPosition.line()<<"/"<<insertPosition.column()<<endl;
+  m_doc->insertText(insertPosition,insertString);
+  KTextEditor::SmartCursor *endC= m_doc->newSmartCursor(insertPosition);
+  endC->advance(insertString.length());
+  kDebug(13020)<<">>>>"<<insertPosition.line()<<"/"<<insertPosition.column()<<endl;
+  kDebug(13020)<<"|||||"<<insertPosition.line()<<"/"<<insertPosition.column()<<"--"<<endC->line()<<"/"<<endC->column()<<"++++"<<endl;
 +  KTextEditor::SmartRange \
*templateRange=m_doc->newSmartRange(KTextEditor::Range(insertPosition,*endC)); +  \
kDebug(13020)<<insertPosition.line()<<"/"<<insertPosition.column()<<"--"<<endC->line()<<"/"<<endC->column()<<"++++"<<templateRange<<endl;
 +  delete endC;
+
+  KTextEditor::Attribute::Ptr attr(new KTextEditor::Attribute());
+  attr->setBackground(Qt::blue);
+  templateRange->setAttribute(attr);
+  m_doc->addHighlightToDocument(templateRange,false);
+#if 0
   uint line = insertPosition.line();
   uint col = insertPosition.column();
   uint colInText = 0;
@@ -185,6 +204,7 @@
   KateTemplatePlaceHolder *cursor = m_dict[ "cursor" ];
 
   if ( cursor ) m_tabOrder.append( cursor );
+#endif
 }
 
 void KateTemplateHandler::slotTextInserted( int line, int col )
@@ -271,6 +291,7 @@
 
 bool KateTemplateHandler::operator() ( int key )
 {
+#if 0
   if ( key==Qt::Key_Tab )
   {
     m_currentTabStop++;
@@ -285,7 +306,7 @@
     if ( m_currentTabStop < 0 ) m_currentTabStop = m_tabOrder.count() - 1;
   }
 
-    //m_currentRange = m_tabOrder.at( m_currentTabStop \
)->ranges.topRange()->firstChildRange(); +  m_currentRange = m_tabOrder.at( \
m_currentTabStop )->ranges.topRange()->firstChildRange();  
   if ( m_tabOrder.at( m_currentTabStop ) ->isInitialValue )
   {
@@ -295,7 +316,7 @@
 
   m_doc->activeView()->setCursorPosition( m_currentRange->end() );
   m_doc->activeKateView()->tagLine( m_currentRange->end() );
-
+#endif
   return true;
 }
 
--- trunk/KDE/kdelibs/kate/part/kateview.cpp #587933:587934
@@ -654,6 +654,13 @@
     a = new KAction(i18n("Backspace"), ac, "backspace");
     a->setShortcut(Qt::Key_Backspace);
     connect(a, SIGNAL(triggered(bool)), SLOT(backspace()));
+
+
+#warning REMOVE THIS IN THE RELEASE
+    a = new KAction(i18n("Debug TemplateCode"), ac, "debug_template_code");
+    a->setShortcut(Qt::CTRL+Qt::Key_1);
+    connect(a, SIGNAL(triggered(bool)), m_doc,SLOT(testTemplateCode()));
+
   }
 
   m_editActions->setConfigGroup("Katepart Shortcuts");
@@ -2082,12 +2089,12 @@
   m_viewInternal->repaint();
 }
 
-bool KateView::setCursorPosition( const KTextEditor::Cursor & position )
+bool KateView::setCursorPosition( KTextEditor::Cursor position )
 {
   return setCursorPositionInternal( position, 1, true );
 }
 
-const KTextEditor::Cursor & KateView::cursorPosition( ) const
+KTextEditor::Cursor KateView::cursorPosition( ) const
 {
   return m_viewInternal->getCursor();
 }
--- trunk/KDE/kdelibs/kate/part/kateview.h #587933:587934
@@ -161,9 +161,9 @@
   // KTextEditor::ViewCursorInterface
   //
   public:
-    bool setCursorPosition (const KTextEditor::Cursor &position);
+    bool setCursorPosition (KTextEditor::Cursor position);
 
-    const KTextEditor::Cursor &cursorPosition () const;
+    KTextEditor::Cursor cursorPosition () const;
 
     KTextEditor::Cursor cursorPositionVirtual () const;
 
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic