Patch #3354 2012-10-29 22:35

alpha0010

EditorTweaks: buffer caret position
Download
3354-EditorTweaks_b.patch (7.8 KB)
Category
Plugin::FeatureAdd
Status
Accepted
Close date
2012-11-11 13:13
Assigned to
mortenmacfly
Index: src/plugins/contrib/EditorTweaks/EditorTweaks.cpp
===================================================================
--- src/plugins/contrib/EditorTweaks/EditorTweaks.cpp    (revision 8526)
+++ src/plugins/contrib/EditorTweaks/EditorTweaks.cpp    (working copy)
@@ -40,34 +40,35 @@
 
 }
 
-int id_et= wxNewId();
-int id_et_WordWrap= wxNewId();
-int id_et_ShowLineNumbers= wxNewId();
-int id_et_TabChar = wxNewId();
-int id_et_TabIndent = wxNewId();
-int id_et_TabSize2 = wxNewId();
-int id_et_TabSize4 = wxNewId();
-int id_et_TabSize6 = wxNewId();
-int id_et_TabSize8 = wxNewId();
-int id_et_ShowEOL = wxNewId();
+int id_et                     = wxNewId();
+int id_et_WordWrap            = wxNewId();
+int id_et_ShowLineNumbers     = wxNewId();
+int id_et_TabChar             = wxNewId();
+int id_et_TabIndent           = wxNewId();
+int id_et_TabSize2            = wxNewId();
+int id_et_TabSize4            = wxNewId();
+int id_et_TabSize6            = wxNewId();
+int id_et_TabSize8            = wxNewId();
+int id_et_ShowEOL             = wxNewId();
 int id_et_StripTrailingBlanks = wxNewId();
 int id_et_EnsureConsistentEOL = wxNewId();
-int id_et_EOLCRLF = wxNewId();
-int id_et_EOLCR = wxNewId();
-int id_et_EOLLF = wxNewId();
-int id_et_Fold1= wxNewId();
-int id_et_Fold2= wxNewId();
-int id_et_Fold3= wxNewId();
-int id_et_Fold4= wxNewId();
-int id_et_Fold5= wxNewId();
-int id_et_Unfold1= wxNewId();
-int id_et_Unfold2= wxNewId();
-int id_et_Unfold3= wxNewId();
-int id_et_Unfold4= wxNewId();
-int id_et_Unfold5= wxNewId();
-int id_et_align_others= wxNewId();
-int id_et_SuppressInsertKey= wxNewId();
-int id_et_ConvertBraces= wxNewId();
+int id_et_EOLCRLF             = wxNewId();
+int id_et_EOLCR               = wxNewId();
+int id_et_EOLLF               = wxNewId();
+int id_et_Fold1               = wxNewId();
+int id_et_Fold2               = wxNewId();
+int id_et_Fold3               = wxNewId();
+int id_et_Fold4               = wxNewId();
+int id_et_Fold5               = wxNewId();
+int id_et_Unfold1             = wxNewId();
+int id_et_Unfold2             = wxNewId();
+int id_et_Unfold3             = wxNewId();
+int id_et_Unfold4             = wxNewId();
+int id_et_Unfold5             = wxNewId();
+int id_et_align_others        = wxNewId();
+int id_et_SuppressInsertKey   = wxNewId();
+int id_et_ConvertBraces       = wxNewId();
+int id_et_CenterCaret         = wxNewId();
 
 // events handling
 BEGIN_EVENT_TABLE(EditorTweaks, cbPlugin)
@@ -114,7 +116,8 @@
 
     EVT_MENU(id_et_SuppressInsertKey, EditorTweaks::OnSuppressInsert)
     EVT_MENU(id_et_ConvertBraces, EditorTweaks::OnConvertBraces)
+    EVT_MENU(id_et_CenterCaret, EditorTweaks::OnCenterCaret)
     EVT_MENU(id_et_align_others, EditorTweaks::OnAlignOthers)
 END_EVENT_TABLE()
 
 // constructor
@@ -178,8 +182,9 @@
         AlignerMenuEntries.push_back(e);
         Connect(e.id, wxEVT_COMMAND_MENU_SELECTED,  wxCommandEventHandler(EditorTweaks::OnAlign) );
     }
-    m_suppress_insert=cfg->ReadBool(_("/suppress_insert_key"),false);
-    m_convert_braces=cfg->ReadBool(_("/convert_braces"),false);
+    m_suppress_insert = cfg->ReadBool(wxT("/suppress_insert_key"), false);
+    m_convert_braces  = cfg->ReadBool(wxT("/convert_braces"),      false);
+    m_center_caret    = cfg->ReadBool(wxT("/center_caret"),        false);
 }
 
 void EditorTweaks::OnRelease(bool /*appShutDown*/)
@@ -214,8 +219,9 @@
     cfg->Write(_T("/aligner/saved_entries"),i);
     for (; i < static_cast<int>(AlignerMenuEntries.size()) ; ++i)
         Disconnect(AlignerMenuEntries[i].id, wxEVT_COMMAND_MENU_SELECTED,  wxCommandEventHandler(EditorTweaks::OnAlign) );
-    cfg->Write(_("/suppress_insert_key"),m_suppress_insert);
-    cfg->Write(_("/convert_braces"),m_convert_braces);
+    cfg->Write(wxT("/suppress_insert_key"), m_suppress_insert);
+    cfg->Write(wxT("/convert_braces"),      m_convert_braces);
+    cfg->Write(wxT("/center_caret"),        m_center_caret);
 }
 
 cbConfigurationPanel* EditorTweaks::GetConfigurationPanel(wxWindow* parent)
@@ -288,6 +294,7 @@
     submenu->AppendSeparator();
     submenu->AppendCheckItem( id_et_SuppressInsertKey, _("Suppress Insert Key"), _("Disable toggle between insert and overwrite mode using the insert key") );
     submenu->AppendCheckItem( id_et_ConvertBraces, _("Convert Matching Braces"), _("Selecting a brace and typing a new brace character will change the matching brace appropriately") );
+    submenu->AppendCheckItem( id_et_CenterCaret, _("Center Caret"), _("Scroll the editor so the caret is always near the center") );
 
 
     wxMenu *foldmenu = 0;
@@ -360,6 +367,7 @@
     submenu->Check(id_et_ShowEOL,ed->GetControl()->GetViewEOL());
     submenu->Check(id_et_SuppressInsertKey,m_suppress_insert);
     submenu->Check(id_et_ConvertBraces,m_convert_braces);
+    submenu->Check(id_et_CenterCaret,m_center_caret);
 }
 
 void EditorTweaks::OnEditorUpdateUI(CodeBlocksEvent& /*event*/)
@@ -425,11 +433,17 @@
 
 void EditorTweaks::OnKeyPress(wxKeyEvent& eve
download for full patch...
mortenmacfly 2012-11-07 10:14

...or was it this one? Either this or patch #3354 needs an update in SVN to comply with the latest changes... I've applied them both and I am not sure yet which was the right one - its about the config keywords...

alpha0010 2012-11-08 01:04

Updated to trunk and improved scrolling logic.

This is the one that conflicted with the SVN (but this patch probably also overlaps some of #3355).