Patch #3237 2011-11-25 15:14

alpha0010

Tab and Enter keys emit escape sequences when in strings
Download
3237-Tab_and_Enter.patch (24.5 KB)
Category
Application::FeatureAdd
Status
Postponed
Close date
2012-06-16 06:57
Assigned to
mortenmacfly
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp    (revision 8148)
+++ src/sdk/editorconfigurationdlg.cpp    (working copy)
@@ -121,6 +121,7 @@
     XRCCTRL(*this, "chkSelectionBraceCompletion", wxCheckBox)->SetValue(cfg->ReadBool(_T("/selection_brace_completion"), false));
     XRCCTRL(*this, "chkTabIndents",               wxCheckBox)->SetValue(cfg->ReadBool(_T("/tab_indents"),                true));
     XRCCTRL(*this, "chkBackspaceUnindents",       wxCheckBox)->SetValue(cfg->ReadBool(_T("/backspace_unindents"),        true));
+    XRCCTRL(*this, "chkAutoEscape",               wxCheckBox)->SetValue(cfg->ReadBool(_T("/auto_escape"),                false));
     XRCCTRL(*this, "chkWordWrap",                 wxCheckBox)->SetValue(cfg->ReadBool(_T("/word_wrap"),                  false));
     XRCCTRL(*this, "chkWordWrapStyleHomeEnd",     wxCheckBox)->SetValue(cfg->ReadBool(_T("/word_wrap_style_home_end"),   true));
     XRCCTRL(*this, "chkPosixRegex",               wxCheckBox)->SetValue(cfg->ReadBool(_T("/use_posix_style_regexes"),    false));
@@ -801,6 +802,7 @@
         cfg->Write(_T("/selection_brace_completion"),          XRCCTRL(*this, "chkSelectionBraceCompletion", wxCheckBox)->GetValue());
         cfg->Write(_T("/tab_indents"),                         XRCCTRL(*this, "chkTabIndents",               wxCheckBox)->GetValue());
         cfg->Write(_T("/backspace_unindents"),                 XRCCTRL(*this, "chkBackspaceUnindents",       wxCheckBox)->GetValue());
+        cfg->Write(_T("/auto_escape"),                         XRCCTRL(*this, "chkAutoEscape",               wxCheckBox)->GetValue());
         cfg->Write(_T("/word_wrap"),                           XRCCTRL(*this, "chkWordWrap",                 wxCheckBox)->GetValue());
         cfg->Write(_T("/word_wrap_style_home_end"),            XRCCTRL(*this, "chkWordWrapStyleHomeEnd",     wxCheckBox)->GetValue());
         cfg->Write(_T("/use_posix_style_regexes"),             XRCCTRL(*this, "chkPosixRegex",               wxCheckBox)->GetValue());
Index: src/sdk/resources/editor_configuration.xrc
===================================================================
--- src/sdk/resources/editor_configuration.xrc    (revision 8148)
+++ src/sdk/resources/editor_configuration.xrc    (working copy)
@@ -1,6 +1,9 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8" ?>
 <resource xmlns="http://www.wxwidgets.org/wxxrc">
   <object class="wxScrollingDialog" name="dlgConfigureEditor">
+    <title>Configure editor</title>
+    <centered>1</centered>
+    <style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
     <object class="wxBoxSizer">
       <orient>wxVERTICAL</orient>
       <object class="sizeritem">
@@ -37,7 +40,7 @@
         <border>5</border>
       </object>
       <object class="sizeritem">
-        <object class="wxStaticLine" name="ID_STATICLINE1"/>
+        <object class="wxStaticLine" name="ID_STATICLINE1" />
         <flag>wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP</flag>
       </object>
       <object class="sizeritem">
@@ -50,6 +53,7 @@
                   <object class="wxNotebook" name="wxID_ANY">
                     <object class="notebookpage">
                       <object class="wxPanel" name="wxID_ANY">
+                        <pos>33,178</pos>
                         <object class="wxBoxSizer">
                           <orient>wxVERTICAL</orient>
                           <object class="sizeritem">
@@ -386,7 +390,6 @@
                                     </object>
                                     <flag>wxALIGN_LEFT|wxALIGN_TOP</flag>
                                   </object>
-                                                                    
                                   <object class="sizeritem">
                                     <object class="wxCheckBox" name="chkHighlightCaretLine">
                                       <label>Highlight line under caret</label>
@@ -420,40 +423,29 @@
                             <border>5</border>
                           </object>
                         </object>
-                        <pos>33,178</pos>
                       </object>
                       <label>Editor settings</label>
                     </object>
                     <object class="notebookpage">
                       <object class="wxPanel" name="wxID_ANY">
-                        <object class="wxBoxSizer" name="wxID_ANY">
+                        <pos>64,15</pos>
+                        <object class="wxBoxSizer">
                           <orient>wxVERTICAL</orient>
-                                                    
-                                                    
-                                                    
-                                                    
                           <object class="sizeritem">
                             <object class="wxStati
download for full patch...
alpha0010 2011-11-25 15:16

Should this be controlled by a switch (right now it is always active)?

alpha0010 2011-11-27 21:39

Added improved string-logic.

This feature should now be very useful when writing blocks of text (ex. command line help).

alpha0010 2011-12-12 01:08

Fixed errors in the logic added in the previous patch.

Modification -> pressing Alt-Enter within a string creates a newline (instead of an escape sequence).

(The code is a bit messy, but it runs much better.)

mortenmacfly 2012-02-25 20:35

What exactly does this?

alpha0010 2012-02-26 22:06

This patch alters what Tab, Enter, and Alt-Enter do when the cursor is inside a quoted string. Tab and Enter are overwritten to instead insert their escape sequences ("\t" and "\n"). If the cursor is at the end of a line (but still within a string), a literal return and the closing/opening of a new string on the next line will be entered. Alt-Enter enables literal returns from the middle of a string.

mortenmacfly 2012-03-03 13:47

OK - I tried and YES: there should be definitely a toggle switch (off by default).

alpha0010 2012-03-03 14:35

Will update as soon as I get the chance.

alpha0010 2012-04-07 18:53

Added switch "Auto escape sequences" to control this feature.

Fixed a small error in the logic.

mortenmacfly 2012-06-16 06:57

By the way: For this to be applied the option is still missing, that's why it is "on halt". Such things require an option in the editor settings, turned off (!) by default.

alpha0010 2012-06-16 16:16

Hmm, my last revision added this option, which works on my copy of Code::Blocks. Does it fail to show up when you test it?

alpha0010 2012-07-19 22:04

Updated to apply to trunk.