Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Code Color Syntax

Should We Add a Color-Code Feature?

  • Yes, I think it would be nice to have!

    Votes: 0 0.0%
  • No, I don't think it would be nice to have!

    Votes: 0 0.0%

  • Total voters
    0
  • Poll closed .
Status
Not open for further replies.

EN0

Member
Hey Everyone,

I thought it might be nice to add a feature which will add color to our code that we enter, sort of like compilers out there. This would make reading simpler for everyone! I think it would still be good to keep the old code format, with just black text, then we can also add the color-code feature.

What do you think?

Austin
 
Sorry, pretty silly idea - for a start how would it possibly work?.

Well, I was thinking that we could have CODE tags for code that people input (assembly, C, C++, ect.) and then it would make comment tags green, function declarations blue (void), and similar features. For instance, instead of "looking" for the double slashes (//...) to indicate a comment is being depicted, people can automatically know because it's green. This would result in a faster viewing and understanding time, I think. Basically it would look like the format from a compiler.
 
Last edited:
Well, I was thinking that we could have CODE tags for code that people input (assembly, C, C++, ect.) and then it would make comment tags green, function declarations blue (void), and similar features. For instance, instead of "looking" for the double slashes (//...) to indicate a comment is being depicted, people can automatically know because it's green. This would result in a faster viewing and understanding time, I think. Basically it would look like the format from a compiler.

So you expect code to be written to format every single varient of every single language? - do you think that's at all practical?.
 
So you expect code to be written to format every single varient of every single language? - do you think that's at all practical?.

I don't expect anything at this point, I'm merely suggesting an idea. I think it would best to start out with assembly and C, since that's commonly used for programming more than any other language. Would it be possible to include the format from a pasting website (mufnet.net, pastebin, etc)?
 
It exists here for HTML and PHP already.

Im sure someone has done a C version... maybe ;)
look:

HTML:
<script type="text/javascript" src="clientscript/vborg_miscactions.js?v=3612"></script>
<!-- /VB.ORG -->

	<title>BB Code &quot;code&quot; color changing - vBulletin.org Forum</title>
<script type="text/javascript" src="clientscript/vbulletin_post_loader.js?v=3612"></script>
</head>
<body onload="">
<div id="container" style="width:950px;min-width:950px">
<a name="top"></a>
<table id="header" border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="270" rowspan="2" align="left" id="vheader"><a href="index.php?"><img src="https://www.electro-tech-online.com/images/cstyle/blue/vblogo.gif" border="0" alt="vBulletin.org - The Ultimate vBulletin Resource" title="vBulletin.org - The Ultimate vBulletin Resource" width="250" height="15" /></a>
      <h1 id="headertag">The Official vBulletin Modifications Site.</h1></td>
    <td class="headerlinks" align="right" valign="middle"><div class="smallfont" style="padding:0 4px;white-space:nowrap">
        
          <!-- login form -->
          <form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
            <script type="text/javascript" src="clientscript/vbulletin_md5.js?v=3612"></script>
		<table cellpadding="0" cellspacing="1" border="0">
		<tr>
			<td class="smallfont" align="left"><label for="navbar_username">User Name</label></td>
			<td class="smallfont" align="left" colspan="2"><label for="navbar_password">Password</label></td>
		</tr>
		<tr>

PHP:
$myvar = 'Hello World!';
for ($i = 0; \$i < 10; \$i++)
{
    echo $myvar . "\n";
}
 
Last edited:
There, you see? Now, doesn't that look nice?

Since it already exists for HTML and PHP, I think it would be nice to have it for C and assembly. PHP is similar to C as far as what we would color, so it wouldn't be a difficult project to tweak it a bit.

But it's all up to you guys. I'm still learning how to program efficiently, but I think someone here might be supportive to attempt something like this. We have a lot of dedicated members.
 
Since it already exists for HTML and PHP, I think it would be nice to have it for C and assembly. PHP is similar to C as far as what we would color, so it wouldn't be a difficult project to tweak it a bit.

You keep refering to C and Assembly, but it would need to be different for every single version of C and assembler, people claim C is 'portable' but in practice it's anything but, with every compiler been considerably different.
 
The code painting job is just based on syntax so it would work as long as the syntax is standardized, else it won't.

In that case HTML codes are easy to paint because they're much standardized.

The software plug-in need to be written like this:

if(value of textarea.CODE_TAG.changed())
{
var Color=do_paint(WORD_L_R_TRIMMED);
var colored_Word=<font color=Color>WORD</font>;
replace_the_word :D
}
function do_paint(word)
{
var Color;
for(HTML_SYNTAX_BANK());
{
if(word==HTML_SYNTAX_BANK.getEachWord())
{
Color = getWord().getCorres_Color();
}
}
return Color;
}

HTML SYNTAX BANK
-------------------
<html = blue
<style = green
<script = black
<table = orange

Bit more processing needed for based on tag start/close,<,>,'," etc to find color fragments and to make it accurate.

IMO, this is a so easy task for standardized syntax. The syntax:color mapping file is the keypoint here.

END_OF_BLUNDER
 
Since it doesn't seem to be that difficult, then why don't we standardize it? Eventually, maybe we could add the syntax for different compilers, but until then we could start out with the more frequently used compilers.
 
It definitely can be done - and I'm interested in this idea. I see the problem being able to distinguish between the languages. How would we tell if it's c, basic, hex, etc? Or would it not matter?

I think that we could have them go through a selection process; so when they press the code tags, it will ask them to select the appropriate code type (C, assembly, BASIC, etc.). When the final code is entered, it could entitle which selection you made. Over time, we can add more options for code and compilers.
 
Last edited:
It should be done in the same fashion that html and php is done on vBulletin.
If you are using boostc then <boostc> </boostc>
(flavor)ASM <*asm></*asm>
swordfish basic <sfbasic> </sfbasic>
c18 <c18> </c18>

This way, we can have developers adapt separate vBulletin modules(?) for the compiler they are most proficient in.
This would reduce the complexity of a single vBulletin mod having to figure it out.

Let the poster tell vBulletin which compiler. A master list of which are done, which need help, etc...


I think this is the best, most straightforward way to do it. It follows in the vBulletin convention, and it has the added benefit of letting the reader know what compiler the poster is using. (Something often non mentioned)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top