Author Topic: Editor Tweaks plugin  (Read 37344 times)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Editor Tweaks plugin
« on: December 09, 2009, 10:58:23 pm »
What is it?
* Temporarily change Word wrap, Line numbers, Tab and EOL handling settings per editor.
* Disables insert key

Uses
* Opened a text file that doesn't use doesn't use newlines in paragraphs? Solution: switch on word wrap without interfering with other open editors
* On windows working with windows sources, but opened a source file with unix newlines? Solution use the EOL tweaks to get the behavior you need for that file without interfering with your other editors.


Source code:
svn checkout http://svn.berlios.de/svnroot/repos/cbilplugin/branches/EditorTweaks


Binaries:
attached


Todo:
1. Use the main menu instead of the popup menu.
2. Implement "Strip Trailing Blanks Now"
3. Make disabling of insert key optional

Screenshot attached
win32 plugin binary attached (built against Nov 2009 nightly build)

The plugin is now one of the contrib plugins in the offical Code::Blocks repository (and has additional features)

[attachment deleted by admin]
« Last Edit: December 14, 2011, 03:03:59 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Editor Tweaks plugin
« Reply #1 on: December 10, 2009, 06:08:46 am »
1. Use the main menu instead of the popup menu.

Done.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Editor Tweaks plugin
« Reply #2 on: December 16, 2009, 11:00:06 pm »
added fold/unfold above level
added win32 plugin binary (see first post)

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Editor Tweaks plugin
« Reply #3 on: December 17, 2009, 02:19:38 am »
@dmoore
can you change the output path,so I don't need to copy the output to the cb relatived folder by myself but use cmd. :D
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Editor Tweaks plugin
« Reply #4 on: December 17, 2009, 03:08:07 am »
as in ../../../devel/share/codeblocks/plugins/LIBNAME? I guess so.

Right now it defaults to building a cbplugin (which is the C::B plugin template default). so maybe I'll just add a second target to handle this case.

Offline cyberdyne

  • Single posting newcomer
  • *
  • Posts: 2
Re: Editor Tweaks plugin
« Reply #5 on: December 14, 2011, 03:56:03 am »
Hi guys, I am new to Cb .I am trying to install the editor tweak plugin and found
that the binaries have been removed.I did the svn checkout and found only the
source files.Could you help me to install it?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Editor Tweaks plugin
« Reply #6 on: December 14, 2011, 09:49:10 am »
Yes, use a nightly build :)
Or tell us your OS so we can guide you to build C::B from source.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Editor Tweaks plugin
« Reply #7 on: December 14, 2011, 03:05:14 pm »
Cyberdine: Some time back the plugin was moved into the official C::B repository and is one of the "contrib" plugins. Apologies for not updating this post.

Offline cyberdyne

  • Single posting newcomer
  • *
  • Posts: 2
Re: Editor Tweaks plugin
« Reply #8 on: December 14, 2011, 09:27:38 pm »
obfuscated:
I am using Ubuntu 11.04  and the code I checked out was for the plugin and not for CB coz I wasnt
clear with my last post.

dmoore:
Do you mean to say that the plugin has been integrated to the repo of CB?

Thanks guys

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Editor Tweaks plugin
« Reply #9 on: December 14, 2011, 09:39:48 pm »
Yes, the code is in svn.

We have nightly build for ubuntu, too. See here for details: http://apt.jenslody.de/
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Editor Tweaks plugin
« Reply #10 on: April 24, 2012, 08:40:35 pm »
Hello, I would like to report a bug in the Aligner feature (very useful, by the way!) of Editor Tweaks.
I am now using a fresh copy of prebuilt Nightly build 7925 for Windows version. I have tested this on 2 machines, Vista and XP and the same happens.

Right after install, the Aligner option of the context menu provides 4 default alignment options, and lets the user create more of its own. This works fine: after creating them, the aligner menu shows all existing options and they work.

The bug comes when restarting C::B. It seems that the menu always loads only 4 entries. I have verified that even when default.conf contains more entries, the menu always shows only 4, and they may not be the default ones. Not a critical bug, but rather annoying!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Editor Tweaks plugin
« Reply #11 on: April 25, 2012, 06:19:58 am »
the menu always shows only 4, and they may not be the default ones. Not a critical bug, but rather annoying!
It is hard coded in EditorTweaks.cpp:
Code
    const unsigned int MaxStoreAlignerdEntries = 4;
The reason might be that dmoore didn't want to clutter the editor menu too much.However, if you compile C::B yourself you can just change the value (or use one of the first 4 entries ;))
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Editor Tweaks plugin
« Reply #12 on: April 25, 2012, 09:37:47 am »
Well I don't compile C::B so I will have to use it as it is. It does seem weird though, that you are given the option to create more, and the code doesn't take this into account.

As an idea: If we don't want to clutter menu options, a better way to do this would be to not provide submenus: instead, just pop up an input box where you enter the character to be used for alignment in each use. This would be fast and practical, since in most cases it will be a single keystroke.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Editor Tweaks plugin
« Reply #13 on: April 25, 2012, 09:53:50 am »
Another problem is that the Aligner menu is missing from the main menu.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Editor Tweaks plugin
« Reply #14 on: April 25, 2012, 10:55:20 am »
Yeah, it is certainly not there. I did not even know that it was supposed to be there!
Well it seems to me much quicker to use the context menu, but it won't hurt if the option is in the main menu as well.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Editor Tweaks plugin
« Reply #15 on: April 25, 2012, 01:01:56 pm »
If it is in the main menu one can setup a key shortcut for it :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Editor Tweaks plugin
« Reply #16 on: April 25, 2012, 02:36:02 pm »
You are right... I learned about that AFTER my last post.

BTW: with the shortcut, my previous idea would work even better: you just press Ctrl+??, enter a character (or 2 at most, usually) and hit enter: done. Quite quick and totally flexible. No need to save configuration options, no large submenus.

Offline Kalith

  • Multiple posting newcomer
  • *
  • Posts: 67
Re: Editor Tweaks plugin
« Reply #17 on: November 25, 2012, 07:53:34 pm »
I didn't know about this plugin until quite recently when bug #18795 happened to me. It has been fixed now, but I still think that the plugin behaves strangely...

The default setting is to have "Editor caret buffer" (which is not a very explicit name, by the way) equal to 4, that is the plugin will try to always keep the caret 4 lines away from the borders of the view (at least that's what I think is the intended behavior).

The thing is, if you position the caret somewhere and scroll away so that it is no longer visible :
  • after typing a first character, the caret will be visible and located at the topmost/bottommost visible line
  • for each consequent character, the view will scroll one line at a time until the line on which the caret is positioned is the 4th visible line (or the n-4th one)
This is very confusing... But maybe this is intended behavior ?

Anyway, this is a quite an uncommon and undocumented feature, plus it is not clear how to disable it (Settings -> Editor -> EditorTweaks settings -> Editor caret buffer = None).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Editor Tweaks plugin
« Reply #18 on: November 25, 2012, 07:56:40 pm »
Anyway, this is a quite an uncommon and undocumented feature, plus it is not clear how to disable it (Settings -> Editor -> EditorTweaks settings -> Editor caret buffer = None).
Thats just because you used recent nightlies where it was on by default. If you have a fresh installation, its off by default and won't harm unless you turn it on. Sorry for the inconvenience.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Kalith

  • Multiple posting newcomer
  • *
  • Posts: 67
Re: Editor Tweaks plugin
« Reply #19 on: November 25, 2012, 07:59:05 pm »
No worries, I was more concerned about C::B being at its best for the 12.11 release :)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Editor Tweaks plugin
« Reply #20 on: November 26, 2012, 12:09:36 am »
Thats just because you used recent nightlies where it was on by default. If you have a fresh installation, its off by default and won't harm unless you turn it on.
Um... this feature is on by default.  I wrote it with a default 4 line buffer because that is what I personally found most useful.  However, from the sounds of various recent posts, this behavior is rather unexpected.  Would it be preferred if the default setting is a 1 line buffer (so the feature is still discoverable, but acts very conservatively, so it should not be too bothersome).  Or should it be off by default?  Or are there some other "4 line buffer supporters" out there who are remaining silent :)?

[...] This is very confusing... But maybe this is intended behavior ?
Intended, yes (well, sort of), but confusing, it seems also yes :-\.

It only scrolls one line at a time so a user's eyes do not (potentially) have to jump a great distance.  Unfortunately, this currently means 1 keypress == 1 line.
I have an idea for a smooth scroll to position, which would prevent the confusion of multiple scrolls when typing on the same line, but I do not know if this will make it into into the current release.  If the developers think it will be faster to just reduce the default setting, I would not want to delay this release with another patch.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Editor Tweaks plugin
« Reply #21 on: November 26, 2012, 01:28:59 am »
Patch 3379 for smooth scroll is available, but no pressure to review it for this release.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Editor Tweaks plugin
« Reply #22 on: November 26, 2012, 06:28:24 am »
Um... this feature is on by default.  I wrote it with a default 4 line buffer because that is what I personally found most useful.
As always: Magic needs to be turned off by default. Standard (expected) behaviour is what should be enabled.

But didn't I change the default to be off in the commit?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Editor Tweaks plugin
« Reply #23 on: November 26, 2012, 09:32:16 pm »
Magic down:
Code
Index: src/plugins/contrib/EditorTweaks/EditorTweaksConfDlg.cpp
===================================================================
--- src/plugins/contrib/EditorTweaks/EditorTweaksConfDlg.cpp (revision 8624)
+++ src/plugins/contrib/EditorTweaks/EditorTweaksConfDlg.cpp (working copy)
@@ -26,7 +26,7 @@
     int maxSavedAlignerEntries = cfg->ReadInt(_T("/aligner/max_saved_entries"),4);
     SpinCtrl1->SetValue(maxSavedAlignerEntries);
 
-    Choice1->SetSelection(cfg->ReadInt(wxT("/buffer_caret"), 4));
+    Choice1->SetSelection(cfg->ReadInt(wxT("/buffer_caret"), 1));
 }
 
 EditorTweaksConfDlg::~EditorTweaksConfDlg()
@@ -44,7 +44,7 @@
     if(oldSavedAlignerEntries != newSavedAlignerEntries )
         cfg->Write(_T("aligner/max_saved_entries"),newSavedAlignerEntries);
 
-    const int oldBuffer = cfg->ReadInt(wxT("/buffer_caret"), 4);
+    const int oldBuffer = cfg->ReadInt(wxT("/buffer_caret"), 1);
     const int newBuffer = Choice1->GetSelection();
     if (oldBuffer != newBuffer)
         cfg->Write(wxT("/buffer_caret"), newBuffer);
Index: src/plugins/contrib/EditorTweaks/EditorTweaks.cpp
===================================================================
--- src/plugins/contrib/EditorTweaks/EditorTweaks.cpp (revision 8624)
+++ src/plugins/contrib/EditorTweaks/EditorTweaks.cpp (working copy)
@@ -1184,7 +1184,7 @@
 void EditorTweaks::DoBufferEditorPos(int delta)
 {
     if (m_buffer_caret == -1)
-        m_buffer_caret = Manager::Get()->GetConfigManager(wxT("EditorTweaks"))->ReadInt(wxT("/buffer_caret"), 4);
+        m_buffer_caret = Manager::Get()->GetConfigManager(wxT("EditorTweaks"))->ReadInt(wxT("/buffer_caret"), 1);
     if (m_buffer_caret < 1) // feature disabled (selected "None" in settings)
         return;
     cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Editor Tweaks plugin
« Reply #24 on: November 27, 2012, 06:27:46 am »
Magic down:
It was really by default at 4? Well this is going to be fun with the release then... 8)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5519
Re: Editor Tweaks plugin
« Reply #25 on: November 27, 2012, 07:34:07 am »
hhm, if in the release it is not default off, we need to rebuild, really, this is a non normal situation. We don't want to scare users away (it is ok we use ubuntu numbering, but we should not take over ubuntu attitude)  :P

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Editor Tweaks plugin
« Reply #26 on: November 27, 2012, 08:41:21 am »
hhm, if in the release it is not default off, we need to rebuild, really, this is a non normal situation.
Are you serious? Actually we can't do that - you know...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5519
Re: Editor Tweaks plugin
« Reply #27 on: November 27, 2012, 09:56:28 am »
I am serious yes, I also ran into this, and it is strange when you are not used to it, and most people , I think, are not used to such a thing. I want to avoid to annoy users which such things. And if rebuilding is the only thing we should do, well let's do it. It is not fun, but it is because we made a mistake to make this the default in the first place, we should pay for our mistakes, not the user. And since Jens is most of all affected, he should come to Brussels and I will bribe him with Belgian beers  ;D
Others also welcome to come over for beers  :D

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Editor Tweaks plugin
« Reply #28 on: November 27, 2012, 11:30:08 pm »
It is not fun, but it is because we made a mistake to make this the default in the first place, we should pay for our mistakes, not the user.
I was the one who made the mistake, not any of you.
I guess I will now have to go write some more code for the patch tracker, to say sorry ;).

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5519
Re: Editor Tweaks plugin
« Reply #29 on: November 28, 2012, 07:29:43 am »
we are a group, so WE made the mistake. Mistakes happen, so don't worry, what matters is how we solve them, and try to avoid them.

Offline Kalith

  • Multiple posting newcomer
  • *
  • Posts: 67
Re: Editor Tweaks plugin
« Reply #30 on: November 29, 2012, 11:51:41 am »
I don't know if this is related, but the current nightly build doesn't really remember my setting for this particular feature.
The value is correctly saved (for example if I choose "None", then "Settings -> Editor -> EditorTweaks settings -> Editor caret buffer" correctly shows "None" after restarting C::B), but not properly restored : after a fresh restart of C::B, the plugin behaves as if "Center carret" was selected. I have to change the setting to some other value, and change it back to "None" for it to be disabled correctly.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Editor Tweaks plugin
« Reply #31 on: November 29, 2012, 09:15:19 pm »
I don't know if this is related, but the current nightly build doesn't really remember my setting for this particular feature.
[...]

I'm just downloaded RC2 vesrion, and I noticed, that when I'm putting new charcters or delete them from to top most or bottom lines in current view in editor, whole tekst scrolls in direction to achive active line as close to middle as it can be. It happens every typed key in the new opened file. It may stop for a while but it comes back in non determistic moment ;)
As a warning, the annoyance may have been removed, but the position buffering settings are not loaded until the settings window is opened (at least once) due to a missing initialization.
Done in trunk.
Sorry, RC2 is rev 8598, but the missing initialization was fixed in rev 8599 (fix arrived one commit too late :().  This means that in RC2, this one setting (for buffering the caret position in the editor) is a random number at startup, and only reads your config when the editor settings window is opened.
You may want to disable the EditorTweaks plugin until you either create your own build from the trunk, or the next RC is released.

RC2 does remember your settings, it just does not read the config file until the editor settings window is open (this bug is already fixed in the trunk).

Offline Kalith

  • Multiple posting newcomer
  • *
  • Posts: 67
Re: Editor Tweaks plugin
« Reply #32 on: November 29, 2012, 11:05:54 pm »
Nice, thank you :)