Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Source Formatter
Ceniza:
thomas: by "full redisign" I meant doing it totally different. It could be, for example, an interface with all productions and some widget to choose what to do with every token there (put it in the next line, add space before/after, next line and indent, keep original style, ...). That'd be the Stiff GUI.
Heh, and I wouldn't feel like trying to fix bugs in, or adapt, a 5000+ lines project that wasn't written by me and where all that bunch of lines is in just a few files. Code::Blocks is huge, but at least it's well divided in many modules :)
--- Quote from: thomas ---Hey! Why not an "indent between <regex> and <regex>" option? That might be good for other things, too (not just event tables).
--- End quote ---
See? That'd be a hack! The regex would apply to tokens! :? :( :cry:
What about a special IDs thingy? You could add BEGIN_EVENT_TABLE with something like "next line + indent" and END_EVENT_TABLE with "unindent".
thomas:
--- Quote from: Ceniza on January 18, 2006, 09:29:52 am ---What about a special IDs thingy? You could add BEGIN_EVENT_TABLE with something like "next line + indent" and END_EVENT_TABLE with "unindent".
--- End quote ---
Sounds good. :)
Raindog:
Might I suggest looking at the features that ReSharper or IntelliJ IDEA offer for source code formatting?
www.jetbrains.com
IMO they offer a real complete solution to formatting source code, and instead of using a large screen space to display the formatted source, they use a scrollable text view.
Ceniza:
News: I'ven't coded any kind of parser :)
Anyway, I just wanted to comment you about a little source formatter I found and its configuration concept. I'm talking about NiceC, where the idea is to make it learn from existing formatted code. Then I came with the idea of a "learning session".
Here's a scenario (images are for illustrative purposes):
You have Code::Blocks opened, the plugin installed, and a source file loaded. You go to Plugins and select SourceFormatter.
It'll display a dialog showing you the current styles (predefined + user defined), a button to create a new empty style, a button to create a new style from an existing one, a button to apply the style and another button to learn.
You decide to create a new style, select it and click Learn.
Now tokens are found and a dialog pops-up. It'll allow you to configure some behavior based in the current scenario. Say it found a '{' that belongs to an if. Here you can select a set of actions based on some rules like: we're currently in an IF, previous token is, next token is, previous actions, next actions, ...
That one needs more "tuning". An option to add custom states could also be added.
States are pushed in a stack. The IF one would be pushed when a LPAREN token is found and the previous token is IF. Who removes it? :)
The configuration dialog should allow you to see, remove, modify and add actions (dialog not defined yet).
Anyway, what you'd get with that action would be (comments for clarification; dots mean space; indentation is 4 spaces):
Original code:
--- Code: (cpp) ---if.(1.+.1.==.5).{
--- End code ---
Formatted code:
--- Code: (cpp) ---if.(1.+.1.==.5)// pre-action: Go to next line
{// post-action: Go to next line
....// post-action: Indent
--- End code ---
Now it's your turn to say how much this idea sucks :D
Michael:
Look really cool :D. But before a final judgement I would like to see it in action... :D
Michael
[EDIT] @Ceniza: I cannot SVN update the SourceFormatter, because it seems that your server refuses the connection. Should I try later?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version