Automated D code editing?

Lubos Pintes lubos.pintes at gmail.com
Sat Oct 13 00:13:44 PDT 2012


Blindly replacing identifiers is certainly not what I need, I want for 
example
FormStartPosition.CENTER_SCREEN to be written like 
FormStartPosition.centerScreen;
Enums in DGUI are written like
enum FormStartPosition {
   CENTER_SCREEN = SOME_WINDOWS_API_VALUE,
   ...
}
I need SOME_WINDOWS_API_VALUE unchanged. But it may be possible to do 
this with some script, I certainly check the notepad2.

Dňa 12. 10. 2012 22:36 Nick Sabalausky  wrote / napísal(a):
> On Fri, 12 Oct 2012 19:51:02 +0200
> Lubos Pintes <lubos.pintes at gmail.com> wrote:
>
>> Hi,
>> I am still playing with DGUI library. Besides other things, I would
>> like to convert enum names from
>> "THIS_STUPID_NAMING_CONVENTION_WHICH_I_ABSOLUTELY_HATE" to
>> "thisGoodOne". Obviously I could do this by hand but it is a bit time
>> consuming. Any tool / hack to help me with this?
>> Thank
>
> If you're on Windows and know Python, you could download Programmer's
> Notepad 2 <http://www.pnotepad.org/> which supports scripting in
> Python to make custom macros/tools/extensions/etc. Maybe someone
> already made such a PN2 script, I don't know. It does already have a
> built-in keyboard shortcut for "convert to lowercase" (ctrl-u), which
> might at least help. Then you could manually uppercase the letter
> after each _ and then regex search/replace to get rid of the _'s.
>
> IIRC, Visual Studio has a similar scripting feature, but not in Python
> (VBScript maybe? Or C#? I forget), so maybe you could do the same with
> Visual-D.
>
> Or, it would probably be pretty simple to write a little script in D
> that just does a regex search for say, `[A-Z_][A-Z_]+` and then
> converts each instance.
>
> Unfortunately I don't know offhand of a tool that would do it all
> automatically without code needing to be written. :(
>



More information about the Digitalmars-d-learn mailing list