Author Topic: About visualizing code  (Read 5930 times)

Offline Oon Kuka Oon

  • Single posting newcomer
  • *
  • Posts: 4
About visualizing code
« on: May 03, 2012, 03:48:21 pm »
I have a suggestion. (Just skip the following two lines.)
In the old times the only ways to make code more readable were indentation, padding empty lines and positioning brackets logically. Today there's also highlighting, folding and tooltips, but even more could be done!

Code blocks' dimensions would be easier to perceive if each of them had a background color that distinguishes them of the surroundings. Though they should be chosen so that they don't make highlights virtually invisible.
A rectangle could also be drawn around code block to mark its borders. Actually, if the IDE allowed spawning new blocks and enclosing code fragments or undoing that through hotkeys, coders would never need to manually write braces, which would prevent "odd brace" errors.

This is what I have come up with so far.

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: About visualizing code
« Reply #1 on: May 03, 2012, 04:13:32 pm »
I see some issues in your idea.
First, in cpp, character { and } can be replaced by macros. This technique is not so rare, by example when you provide macros to create wrappers without writing all glue code.

How to choose colors? You said yourself that highlighting should not be made invisible, but do not forget that on computers people can change colors of their desktop environment. We often use light themes, but some people like dark themes (I like them, but they are often not very easy to use, many applications do not take care correctly of such things) Another problem with colors is that screen does not always have same setups. By example, I never use original settings of C::B for some comments, because they are near invisible.

How to manage nested blocks?
A namespace can contain functions, which can contain nested if and loops. C::B could quickly become a Christmas tree...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: About visualizing code
« Reply #2 on: May 03, 2012, 04:17:50 pm »
Oon Kuka Oon:
C::B uses Scintilla (in fact the wxScintilla's version) for the editor component and as far as I know drawing random rectangles is not possible with it,
so this request should be made on their support channels (mailing list in google groups).
See http://www.scintilla.org/ for more details.
(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 Oon Kuka Oon

  • Single posting newcomer
  • *
  • Posts: 4
Re: About visualizing code
« Reply #3 on: May 04, 2012, 12:46:54 am »
Apparently you'd need to be a member to email them? I got the following message from Google:

Quote from: Mail Delivery Subsystem <mailer-daemon@google.com>
We're writing to let you know that the group you tried to contact (scintilla-interest) may not exist, or you may not have permission to post messages to the group. A few more details on why you weren't able to post:

* You might have spelled or formatted the group name incorrectly.
* The owner of the group may have removed this group.
* You may need to join the group before receiving permission to post.
* This group may not be open to posting.

Freem:
Why use macros if there could be more elegant way?
Background colors could be pretty pale, so they don't hide highlights even if they have same hue. And naturally user should be able to adjust the colors to suit his monitor and eye.
2 background colors can be recycled when drawing nested blocks, and with third one you can draw subsequent same level blocks differently so they can be distinguished even if there aren't any "parent block" lines between.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: About visualizing code
« Reply #4 on: May 04, 2012, 12:49:07 am »
Apparently you'd need to be a member to email them? I got the following message from Google:
Apparently you'd have to become member :)
(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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: About visualizing code
« Reply #5 on: May 04, 2012, 03:13:23 am »
[...] as far as I know drawing random rectangles is not possible with it [...]
Out of curiosity, what does this mean "Highlight occurrences" uses?  Is it just a call to specific Scintilla method?

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: About visualizing code
« Reply #6 on: May 04, 2012, 09:35:23 am »
2 background colors can be recycled when drawing nested blocks, and with third one you can draw subsequent same level blocks differently so they can be distinguished even if there aren't any "parent block" lines between.
Hum... not convinced. Maybe I do not see correctly what you mean... I have nothing against such feature, but just let me disable it.

HS:
Freem:
Why use macros if there could be more elegant way?
Because sometimes, macro are the elegant way.
I used them in a professional project. Without macros, users of my library had to writes classes of near 100 lines. 100 lines which could be mostly written by a robot, with not so well known calls to stl (my colleagues are not C++ dev). With macros, the resulting code was of 20 lines of a pseudo language, far easier to write and read. Those macros also allowed me to fix some bugs I never understood, thanks to gain of readability.
Interest of macros against inline functions, by example, is that they do not need to respect C or C++ syntax, and that give some powerful features. Now I am thinking about that, maybe in C++11 some of macros uses can be replaced by lambdas, but I do not think lambdas are so easy to read. Other problem is that some people can not use C++11 at the moment.

Offline Oon Kuka Oon

  • Single posting newcomer
  • *
  • Posts: 4
Re: About visualizing code
« Reply #7 on: May 04, 2012, 04:37:12 pm »
Apparently you'd need to be a member to email them? I got the following message from Google:
Apparently you'd have to become member :)
Apparently you'd need a Google account to join them ;D
Apparently I have to create one... ::)

[...] as far as I know drawing random rectangles is not possible with it [...]
Out of curiosity, what does this mean "Highlight occurrences" uses?  Is it just a call to specific Scintilla method?
That's a good point!

Freem: Naturally background colors should be optional like any highlighting.