Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Allefant on April 01, 2006, 02:40:05 pm

Title: how can i insert a hard tab?
Post by: Allefant on April 01, 2006, 02:40:05 pm
I often want to insert a TAB character (ascii 09) into text, for example when I need to modify a makefile, or when I need to modify a source which has such ascii codes in it. Is there a way to do it?

(Without going to settings and enabling tabs there.. since I only need one single tab, but normal indentation for my normal source code..)
Title: Re: how can i insert a hard tab?
Post by: thomas on April 01, 2006, 02:48:59 pm
Since you do not want to edit settings, the only way to get this done is to type a tab char in notepad, copy that char, and paste it into the source...

If you need a tab character in a character string, it is of course easier to use \t :)
Title: Re: how can i insert a hard tab?
Post by: takeshimiya on April 01, 2006, 03:07:10 pm
Or another more funny solution would be using AngelScript.

You would only need to create a script that does something like:
Code: cpp
// toggle tab usage
bool use = editor->GetUseTabs();
editor->SetUseTabs(!use);

And then register a menu with it along with an accelerator.

The only (minor?) problems with it are:
-*UseTabs() function are not registered, you'll need to register it in scriptbindings.cpp, and recompile C::B.
-Can a script create a new menu entry with an accelerator?
-The script would be loaded once, or it would be loaded each time the function is needed?
Title: Re: how can i insert a hard tab?
Post by: Allefant on April 01, 2006, 08:19:23 pm
A menu entry would be perfect. Anyway, since I don't feel like recompiling myself, I just filed a feature request :)
Title: Re: how can i insert a hard tab?
Post by: takeshimiya on April 01, 2006, 08:28:42 pm
But it'd be of actually use with AngelScript, or the ActionsManager stuff, or perhaps some future Macros recording feature.
As of now, putting a hardcoded menu for SetUseTabs() would polute menus only.
Title: Re: how can i insert a hard tab?
Post by: Allefant on April 01, 2006, 10:25:36 pm
Yes, I guess having a script for it (which I could add/enable/install/[anything but requiring me to completely recompile a huge C++ project]) would be best.