User forums > Using Code::Blocks

EditorTweaks: new option 'Convert Matching Braces' : little bug

<< < (8/12) > >>

Alpha:
Here is python triple quote completion (it requires the patch from my last post be applied to everything but PythonSmartIndent.cpp).

--- Code: ---Index: src/plugins/contrib/SmartIndent/PythonSmartIndent.cpp
===================================================================
--- src/plugins/contrib/SmartIndent/PythonSmartIndent.cpp (revision 8500)
+++ src/plugins/contrib/SmartIndent/PythonSmartIndent.cpp (working copy)
@@ -71,6 +71,18 @@
         }
     }
 
+    bool braceCompleted = false;
     if ( SelectionBraceCompletionEnabled() || stc->IsBraceShortcutActive() )
-        ed->DoSelectionBraceCompletion(stc, ch);
+        braceCompleted = ed->DoSelectionBraceCompletion(stc, ch);
+    if (!braceCompleted && BraceCompletionEnabled())
+    {
+        ed->DoBraceCompletion(stc, ch);
+        if (  !(stc->IsComment(stc->GetStyleAt(pos)) || stc->IsComment(stc->GetStyleAt(pos - 2)))
+            && (ch == wxT('"') || ch == wxT('\'')) )
+        {
+            const wxString tripleQuote(3, ch);
+            if (stc->GetTextRange(pos - 3, pos) == tripleQuote && !stc->IsString(stc->GetStyleAt(pos - 4)))
+                stc->InsertText(pos, tripleQuote);
+        }
+    }
 }

--- End code ---

I also wanted to add term -> end term "brace" completion (similar to how C++ matches PP directives, and XML matches tags), but I realized that I do not use/understand those languages enough to be able to create something that functions as expected.

dmoore:
I tried your last patch last night and it seemed to be working well on python files. So should I take this new patch, test a little more then commit over the weekend?

One thing I wondered about was whether you it is better add the sdk functions to cbEditor (as you do now) or to cbStyledTextCtrl. The advantage of the latter is that you don't need to pass around the redundant cbStyleTextCtrl pointer as the first arg.

Alpha:
Assuming it passes your testing, I believe the patch is ready for commit.

Attached I have refactored to cbStyledTextCtrl (plus a slight improvement to brace completion).

dmoore:
Tested and works well enough for me.

Unless someone has objections to putting the Do*BraceCompletion methods in cbStyleTextCtrl or finds some other major problem, I will commit within the next 24 hours.  (The alternative would be to put the methods in cbEditor but I think this is stuff that doesn't need to be exposed in the SDK to anything other than smart indent plugins, so hiding them away makes some sense.)

dmoore:
aaargh! The commit would be a big mess of line ending changes on Linux because I had to dos2unix before applying the patch. (Some of the line ending changes might be unavoidable due to the changes to xml lexer files)

@Morten: please do the propset magic if you have time. (I would do it myself, but only have linux access ATM which will commit a huge batch of unwanted line ending changes if I do the propset)

EDIT: In case I wasn't clear, I am going to hold off on the commit until I resolve the line endings.

Never mind. I figured this out and made the eol propset changes.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version