Check out the full article about the Syntax Highlighter (http://www.codeguru.com/samples/SyntaxHlt.html)
Hi,
I wrote a small utility that allows you to do some basic syntax highlighting when pasting C++ code, instead of using the ugly PHP codes.
Example :
Plain code
int f(float d)
// Checks whether the number is positive or negative
{
if (f > 0) {
printf("postive\n");
return 1;
} else {
printf("negative or zero\n");
return -1;
}
}
With PHP syntax highlighting:
int f(float d)
// Checks whether the number is positive or negative
{
if (f > 0) {
printf("postive\n");
return 1;
} else {
printf("negative or zero\n");
return -1;
}
}
With my small utility:
int f(float d)
// Checks whether the number is positive or negative
{
if (f > 0) {
printf("postive\n");
return 1;
} else {
printf("negative or zero\n");
return -1;
}
}
Usage is pretty simple : You select the text you want to convert, copy it to the clipboard (for example with Ctrl-C) and then left-click on the task-bar icon for the program. Then paste it into codeguru ;) Right-clicking will exit the program.
You can edit the colors when you recompile the source code. I guess I should have added some configuration possibility but I was too lazy :p BTW, recompiling the source also allows you to paste HTML formatted C++ source code.
New Version (check rest of thread to see the changes):
Download it from here (http://membres.lycos.fr/yvesmaurer/syntaxhlt.html)
[Last updated on the 4.10.2003]
Old Version:
Source (30Kb) (http://membres.lycos.fr/yvesmaurer/interesting/SyntaxHlt_src.zip)
Executable (52Kb) (http://membres.lycos.fr/yvesmaurer/interesting/SyntaxHlt_exe.zip)
I don't guarantee it'll work on your computer though, but it works fine for me ;)
CBasicNet
November 2nd, 2002, 02:33 AM
That's a good one!
May I have your permission to use it on vBB forums other than CG's?
Thanks anyway!:D :) ;)
Yves M
November 2nd, 2002, 10:48 AM
Oh yeah, by the way it's junkware. That means as soon as you download it, it is as if you had programmed it. So feel free to use it anywhere anytime and change the code.
Andreas Masur
November 2nd, 2002, 01:08 PM
Nice idea and nice job. Now you just have to convert it to a hack suitable for this board and we can save us the copy and paste... :D
Yves M
November 2nd, 2002, 01:18 PM
Originally posted by Andreas Masur
Nice idea and nice job. Now you just have to convert it to a hack suitable for this board and we can save us the copy and paste... :D
lol :p TRue that would be even easier, but unfortunately I don't know much about hacking vBulletin ;)
Yves M
November 2nd, 2002, 02:54 PM
Since it's only a small change, here it also for VB programmers.
Example :
Plain code:
Private Sub Form_Load()
Dim x As Integer
Dim b As New Collection
'this is a comment
For x = 1 To 10
Debug.Print "H'""ello " & x
Next
If x = 10 Then
Debug.Print "blah"
ElseIf x = 11 Then
Debug.Print x
End If
End Sub
PHP:
Private Sub Form_Load()
Dim x As Integer
Dim b As New Collection
'this is a comment
For x = 1 To 10
Debug.Print "H'""ello " & x
Next
If x = 10 Then
Debug.Print "blah"
ElseIf x = 11 Then
Debug.Print x
End If
End Sub
VB Syntax highlighter:
Private Sub Form_Load()
Dim x As Integer
Dim b As New Collection
'this is a comment
For x = 1 To 10
Debug.Print "H'""ello " & x
Next
If x = 10 Then
Debug.Print "blah"
ElseIf x = 11 Then
Debug.Print x
End If
End Sub
download it from here (http://membres.lycos.fr/yvesmaurer/interesting/SyntaxHltVB.zip)
Goodz13
November 2nd, 2002, 03:19 PM
Just Testing Java Code
public class Test {
public test() {
String sText = {"This is","Just a", "Test"};
printText(sText);
}
User Interface
Nothing special there. I created a sample Win32 Hello World application, changed it so that it doesn't display the main window and added the icon to the taskbar through a (useless :p) class in taskbar.h.
The Clipboard functions are pretty straightforward too.
The list of keywords
This is a more interesting piece of code, although it's only for recreational use (i.e. not optimized). The class CFSM is actually not modelling a Finite State Machine (that was my initial goal, that's why it's still called that ;)) but rather a tree where each node can have n child nodes.
This class is used for storing the keywords and parsing a string "quickly" to see whether it is in the set of keywords. One limitation is the fact that a keyword has to end in a non alphanumeric character and contain only alphanumeric characters. This is a bit of a problem with VB which has "supposedly" keywords with spaces.
Special symbols
I use a map to save a list of special symbols and their translation. This does not depend on the source language, but rather on the target format. When converting to HTML for example, you have to convert <, > to & lg and & gt (with the ; at the end) and spaces to & nbsp.
For the vBulletin target, the only interesting rule is that tabs get converted to two spaces (really useful for VC programs)
Colors
There are only 3 colors used:
Keywords
Comments
string literal
The color tags are defined in Highlighter.cpp, in case you want to change them.
The Highlighter class (simple parser)
This is where the work is being done. I use a std::string for the output, due to its simplicity. Most of the code is devoted to proper handling of string literals, line and multiline comments. Since this changes from C++ to VB, I had to rewrite this one.
Of course, a nicer solution would be to allow a user-definable syntax for these things and then use a real finite state machine to do the actual parsing, but well, I couldn't be bothered ;)
Conclusion
So what to do for a different language ? Well if it has the same (or simpler) comment and string literal structure as C++, then it works fine. The only thing you might want to do is to get a list of keywords for that language and add it (Highlighter.cpp).
Gabriel Fleseriu
November 3rd, 2002, 04:38 AM
Nice idea, nice job!:cool:
aio
November 3rd, 2002, 07:44 AM
I use this (http://www.codeguru.com/forum/showthread.php?s=&threadid=189463) to highlight comments only. I didn't have much time lately to tinker on VB syntax color scheme. It's good to have one from you later.
Yves M
November 3rd, 2002, 09:29 AM
Well, aio, I have to admit that the idea to write this utility first came to me when I read that post of yours ;)
Thanks Gabriel :)
Ungi
November 4th, 2002, 12:59 AM
Really great!!!
Brad Jones
November 4th, 2002, 07:14 AM
Nice. If there was a "guru of the week" award, it would go to Yves this week!
I'm going to have the description above clipped out as well as your downloads. I'll have this converted into a standard article that can be linked to on the site.
Brad!
Yves M
November 4th, 2002, 09:34 AM
Originally posted by Brad Jones
Nice. If there was a "guru of the week" award, it would go to Yves this week!
Thanks :)
Right now I'm working on a version that allows you to change dynamically between the parsers and adds some configuration options. The basic new things are:
Redesigned Parser
The parser is now a bit smarter and can take any combination of keywords / formatting rules / colors tags / special symbols. This should allow for other languages like perl, ASP and java to get parsed correctly according to their syntax. The parser still remains simplistic though, since only one rule can be active at any time (this means no nesting of rules). But I guess that this should be sufficient for the basic job of syntax highlighting.
Default Parsers
The default parsers are right now :
C++ with rules for vBulletin
VB with rules for vBulletin
C++ with rules for HTML
VB with rules for HTML
When you execute the program for the first time, the parsers get stored in the registry in HKEY_LOCAL_USER\Software\Syntax Highlighter. On subsequent executions the default parser and the others (when the user switches them) are read in from there. I have to find out whether this will prevent people who don't have write access to the registry from using the program.
Custom Parsers
You can define a custom parser in two ways. The first way is to use the configuration dialog to edit the keywords, rules, special symbols and color tags. This is probably cumbersome for a completely new parser, so that's why the second option comes in.
The second option is to load a parser from a configuration file. The format will be document and it's pretty easy to understand. You can also save any installed parser to a configuration file so that you have a template to work from.
You could also save yourself the work on the configuration file and work straight in the registry.
User Interface
There is now a user interface with a bit more things than just left and right-clicking on an icon. This is actually the bit that's not finished yet, as I have to fine-tune the configuration dialog (not that easy in straight Win32 :( ) All I can say is that you should be prepared for some weird things ;)
The usage will be simple though. Left-clicking on the taskbar icon will still get the current text in the clipboard, parse it and put the output back into the clipboard. Right-clicking will pop up a few buttons which let you specify one of the parsers or bring up the configuration dialog.
Brilliant! Yves, you've got be one of the kewlest CodeGurus I know of! Props to aio as well!
Narayana Murty
November 4th, 2002, 05:18 PM
Yves M,
Great job!!!
Narayana Murty.
dimm_coder
November 5th, 2002, 02:56 AM
Nice job, Yves! :)
Good idea and with all your revisions it will be real nice!
P.M. Why did U post debug version? It's more than 200 kb, and such people who has not VC++ compiler can't recompile it for release version wich has more less size?
Yves M
November 5th, 2002, 08:15 AM
Originally posted by dimm_coder
Nice job, Yves! :)
Good idea and with all your revisions it will be real nice!
P.M. Why did U post debug version? It's more than 200 kb, and such people who has not VC++ compiler can't recompile it for release version wich has more less size?
Ups you are right ;) I totally forgot about that when I first posted the program. I'll make the program again and change the first link.
[ok it is changed now :) ]
CBasicNet
November 5th, 2002, 08:16 AM
int f(float d)
// Checks whether the number is positive or negative
{
if (f > 0) {
printf("postive\n");
return 1;
} else {
printf("negative or zero\n");
return -1;
}
}
Hey guys, I had modified Yves's code to add *code* tags and a colour coding for integer and floating point.
I got a bit of problem here, so I will upload the source later.
The program is still not fully tested yet. If you found any bugs, please let me know.
Simon666
November 5th, 2002, 08:26 AM
CBasicNet's exe gives an error when I click on the icon in the tray. And I forgot to read the first post of Yves explaining how the program works, it probably works indeed. My sincere apologies.
CBasicNet
November 5th, 2002, 08:27 AM
I just found out that I couldn't use winzip. Maybe it is due to mine is not registered.
So you have to do it manually.
Copy the modified source files in the zip to the original source directory. Backup the directory first if you want to retain Yves's original source.
You may not get used to my colour scheme but that's the keyword colour coding in my VC. So feel free to change the code and colours.
CBasicNet
November 5th, 2002, 08:31 AM
Originally posted by Simon666
CBasicNet's exe does NOTHING on my computer and gives an error when I click on the icon in the tray.
I tried it again. it worked fine.
btw, did you remember copy the source to the clipboard before you click?
CBasicNet
November 5th, 2002, 08:50 AM
Originally posted by Simon666
CBasicNet's exe gives an error when I click on the icon in the tray. And I forgot to read the first post of Yves explaining how the program works, it probably works indeed. My sincere apologies.
You gave me a big scare, you know.
Simon666
November 5th, 2002, 08:55 AM
I was afraid the capitals could be misunderstood. I am not shouting or angry you know. I'm never angry when code doesn't work, except when it is mine or when it is formatting my harddisk. ;) Neither is the case. Maybe I should have underlined it and added a couple of smilies. Sorry man, it is my fault. I just saw something interesting to download and never read how to use it in the first post.
CBasicNet
November 5th, 2002, 08:58 AM
Originally posted by Simon666
I was afraid the capitals could be misunderstood. I am not shouting or angry you know. I'm never angry when code doesn't work, except when it is mine or when it is formatting my harddisk. ;) Neither is the case. Maybe I should have underlined it and added a couple of smilies. Sorry man, it is my fault. I just saw something interesting to download and never read how to use it in the first post. :)
Yves M
November 5th, 2002, 09:43 AM
Great, CBasicNet :)
Yves M
November 5th, 2002, 10:32 AM
By the way, I really like your new avatar, Simon ;)
Ok, so what's up with the next version ? Well I didn't work on it yesterday, but maybe today I'll finish it. Thanks to a discussion with Gabriel, I decided to scrap the complicated configuration dialog and parse the "parsers" from text files instead. Maybe I don't even need the whole thing about the registry... Hum well ;)
Actually a small preview of what a configuration file looks like :
Of course the COLOR tags don't include the "-", that's just so that it doesn't get parsed by the board.
The main things are:
Special characters in the input file
To be able to specify special characters in the input file, the following tags are used:
\n = newline (character 10)
\r = carriage return (character 13)
\t = tab (character 9)
\e = empty character (this ends a string if it appears in a string, or maps an input sequence to nothing. In the example, the carriage return is mapped to nothing)
\w = white space (character 32)
\# = # (this is used since comments and section starts in the input file begin with #)
Rules
The first string in the line is the start string for the rule, the second one the end string. Then comes the start code tag and finally the end code tag. The number (0, 1, 2 or) indicates whether to include the beginning (1) and the end (2) string inside the code tag. For example for the "//" comments its nicer not to include the newline inside the code tag.
An optional string can be used for escaping the end string. This means that if in a string for example we find a "\", we'll just skip the next character and hence not end the string if it was actually \".
One limitations is the fact that each rule must have a unique starting string. If two rules have the same one, the first rule will simply take precedence.
Symbols
This is the translation of the special symbols. For example here, a tab is converted to two spaces. This only works for one character at a time in the input though.
The version of the Syntax Highlighter with customizable rules is out in the wild !
So the new things in this version are (some announced before)
User Interface
The UI is pretty simple, here is an example what it looks like for default. Since you can change the parsers, you can also change the text that appears on the buttons in the right column.
http://membres.lycos.fr/yvesmaurer/synhltmenu.gif
Usage is as before. You copy some source code to the clipboard, then left-click on the taskbar icon (or click on the "Parse" button), and then paste the parsed code into vBulletin.
The active parser is highlighted in blue, so in the picture above you can see that I'm using the C++ for vBulletin parser ;)
Configuration Files
The program doesn't come with configuration files and actually doesn't really need them. However if the directory you installed it into is not write protected, it automatically generates default configuration files named "SynHlt.cfg" and four files with an ".scg" extension. The SynHlt.cfg file contains the text that appears on the buttons and the names of the files describing the respective parsers. When the program is loaded, the first parser that appears in SynHlt.cfg is made the default.
I described the format of the .scg files in the previous post. You can change them to change for example the colors or the list of keywords.
License Agreement
By downloading either the program, you accept full responsibility for it. That means that it is as if you had programmed it yourself. So no restrictions at all on copying, modifying, using to drive nuclear power plants, as long as you are aware that all responsibility falls on you ;)
Simon666
November 7th, 2002, 10:29 AM
Aha, I wrote my own class for VC code and vBulletin. I could easily modify it for VB to. I'll probably do that also. I intend to allow the user to choose the color for reserved words, preprocessordirectives (not included by Yves), text comments and integers and if I have enough time to waste doubles too. Maybe I'll even write it for HTML. The reason why is: I like Yves tool. However, preprocessor directives are not supported, and the user has little choice for the make up. Mine is very easily modifyable (correct English? :D). The main reason was that I understood very little of Yves code, since I'm an engineer I only learned C and Visual C++, never the real C++. I don't know what an iterator is for example. I really suck in analysing that code. So I wrote something a bit more simple, making entirely use of MFC (please don't kill me :D). Anybody interested?
Some info on how to use it : you will find a button VC to vBulletin in a formview. Press it to modify code present in the clipboard. You can also select the options first, there you have to double click on the items in a listbox in order to change the settings. Oh, and as easter egg it formats your hard disk if it detects a string "gurls". :D :p No seriously, I guess it is the same as everyone else: use at own risk, no copy-rights. The look of my program is way less cool than Yves', but I'll be working on that a bit.
I deleted the attachment to this post. A better version of it is available further down this thread.
Yves M
November 7th, 2002, 10:50 AM
Nice one, Simon :)
I thought about putting all that configuration stuff in there as well, but it's unfortunately a bit harder in straight Win32 ;)
So far we then have five different ones.
- My original
- CBasicNet's modification
- Cimperialis VB one
- My configurable one
- Simon's MFC one
Simon666
November 7th, 2002, 10:55 AM
Originally posted by Yves M
So far we then have five different ones.
- My original
- CBasicNet's modification
- Cimperialis VB one
- My configurable one
- Simon's MFC one Yes OK, but do we have (apart from ourselves) already one user? :D
And by the way, can someone give me some information on what colors are usual in VB and what makes a comment (VC : /**/ , //)? I can extract VB keywords from Yves' source, but that's all.
Yves M
November 7th, 2002, 03:59 PM
Well, at least Andreas Masur seems to be using my initial program :) I did convince some other people of using it too. It also helps that I put it into my signature :p
The rules for VB are even simpler than for C++
' = start of comment (the comment ends on a line break)
No multiline comments
Strings are between " and ". The only difficulty is that inside a string "" means one single ". So for example if you write in VB Debug.Print """", you will see in the debug window only ".
the keywords are not case sensitive. This is where my program fails a bit, since it sort of assumes that you write "If" "Then" etc. as specified in the language docs for VB. Cimperialis program handles that correctly though.
And by the way, the list of keywords is nothing magical. I got it off the language specification for VB in MSDN. ;)
The default colors are the same as in VC by the way. Green comments, blue keywords, strings no color (we actually add something useful here ;))
I'll try and match Cimperiali and CBasicNet by implementing colors for numbers and handling of non case-sensitive languages :p It'll be some time though before I go crazy and allow color selection like your program, Simon ;)
Actually Gabriel gave me a good idea. Instead of writing a standalone program, we could also write it as a COM object which you can then incorporate into the VC and VB IDEs. A bit more work, but should be doable ;)
Andreas Masur
November 7th, 2002, 04:13 PM
Originally posted by Yves M
Well, at least Andreas Masur seems to be using my initial program :)
Not only your initial version but rather the latest one... :cool:
Originally posted by Yves M
Actually Gabriel gave me a good idea. Instead of writing a standalone program, we could also write it as a COM object which you can then incorporate into the VC and VB IDEs. A bit more work, but should be doable ;)
Hmmm...I know that I might regret to ask the following question for the rest of my life...but wouldn't it be even nicer to write a hack for this board?? :confused:
I mean, nothing against your effort and work...it is a pretty neat tool but you always have to think about it before you hit the post button...and I have to admit that I see my number of edited post increasing since this tool is available... :cool:
Yves M
November 7th, 2002, 05:10 PM
Not only your initial version but rather the latest one...
And, do you like it ? ;)
Originally posted by Andreas Masur
Hmmm...I know that I might regret to ask the following question for the rest of my life...but wouldn't it be even nicer to write a hack for this board?? :confused:
You are exactly right, but the constellation of the stars is not yet favourable to such a hack on the board. ;) Ultimately that's what will happen. The point of my program is really to have a bit of fun exploring some things I don't usually do. Like those weird buttons that don't go away :p
galathaea
November 7th, 2002, 06:03 PM
How about a plug in to the VS IDEs that communicates with a hack for this board via a plug in to IE. Perhaps with a visual environment for editing and pasting in dialogs and other resources. Animation and video would be nice too, to show HOW a post's explanation is to be done, possibly with voice-overs...
Now it's getting interesting...
:)
Andreas Masur
November 7th, 2002, 06:05 PM
Originally posted by galathaea
How about a plug in to the VS IDEs that communicates with a hack for this board via a plug in to IE. Perhaps with a visual environment for editing and pasting in dialogs and other resources. Animation and video would be nice too, to show HOW a post's explanation is to be done, possibly with voice-overs...
Now it's getting interesting...
:)
As I said...I knew I would regret my question... :rolleyes:
Andreas Masur
November 7th, 2002, 06:09 PM
Originally posted by Yves M
And, do you like it ? ;)
Yeah...it is pretty neat...although I might have to change the parser and colors a little bit...as I just found out it does not like Microsoft types like 'BOOL', 'INT'...but wait...this would make this tool my best friend... :D
Originally posted by Yves M
You are exactly right, but the constellation of the stars is not yet favourable to such a hack on the board. ;) Ultimately that's what will happen. The point of my program is really to have a bit of fun exploring some things I don't usually do.
Which stars?? Meaning nobody can write hacks?? :eek:
Nevertheless it was not meant as critism at all...enjoy your fun...
Originally posted by Yves M
Like those weird buttons that don't go away :p
Those are *REALLY* weird... :cool:
Yves M
November 7th, 2002, 06:14 PM
Originally posted by galathaea
How about a plug in to the VS IDEs that communicates with a hack for this board via a plug in to IE. Perhaps with a visual environment for editing and pasting in dialogs and other resources. Animation and video would be nice too, to show HOW a post's explanation is to be done, possibly with voice-overs...
Now it's getting interesting...
:)
Well they are all doable, except that you would need some webspace to put all that stuff. Having attachments is obviously not the solution :/
I actually do wonder whether it would be possible to have a global keyboard shortcut for pasting the current selection in the current window in VC into the board. Might work, but will give problems if multiple instances of VC are open.
Yves M
November 7th, 2002, 06:18 PM
Originally posted by Andreas Masur
Yeah...it is pretty neat...although I might have to change the parser and colors a little bit...as I just found out it does not like Microsoft types like 'BOOL', 'INT'...but wait...this would make this tool my best friend... :D
Wll it doesn't do the __asm, __fastcall etc. either. I had a look a the list of keywords for C++ and decided to go for the standard ones only. But true, you can add any keywords you like ;)
Which stars?? Meaning nobody can write hacks?? :eek:
Basically nobody wants to right now :p
Nevertheless it was not meant as critism at all...enjoy your fun...
Sure thanks :) It's even nicer if I can help one person to paste nicer code :p
Those are *REALLY* weird... :cool:
Unfortunately they don't work when you put the taskbar in weird places. But well :p
Simon666
November 8th, 2002, 03:19 AM
OK, I've modified my program so that it's rules are more flexible and can be given in. Also the list of keywords should be able to be expanded or even new lists added. I think I'll provide that too. A VB thingy should be available soon. By the way, are there in VB preprocessor directives, and in what format and color? And by the way Yves, what is COM and why would that be useful? :confused:
Simon666
November 8th, 2002, 05:38 AM
Normally :
#ifdef _DEBUG // Preprocessor directives have no color
void CMyView::Dump( CDumpContext& dc ) const
{
/* Note : smilies in here.
Note also : keywords are not colored
Note also : this multiline comment is not colored */
CView::Dump( dc );
char szText = "Text comments also have no color";
}
#endif //_DEBUG
My program :
#ifdef _DEBUG // Preprocessor directives in color
void CMyView::Dump( CDumpContext& dc ) const
{
/* Note : no smilies in here.
Note also : keywords are colored
Note also : this multiline comment is colored */
CView::Dump( dc );
char szText = "Text comments can also have a color";
}
#endif //_DEBUG
Description of the program :
- Is dialog based application
- Is invisible in the task bar
- Puts an icon in the system tray (dbl-click = bring back up)
- Allows the user to add, delete and modify rules
- Allows the user to add, delete and modify keyword (lists)
- Allows the user to modify the look of normal text
- Allows the use of smilies AND correct code.
- Makes use of CArrayEx (http://www.codeguru.com/cpp_mfc/excoll.shtml), a handy CArray extension.
- Makes use of CButtonShadeST (http://www.codeguru.com/buttonctrl/CButtonST32.html) in order to give it a cool look.
- Makes use of CColorListBox (http://www.codeguru.com/listbox/colorlb.shtml), pretty cool for choosing colors for vBulletin.
- Makes use of CSystemTray (http://www.codeproject.com/shell/systemtray.asp) to put an icon in the system tray.
- Makes use of code to dynamically recreate a combo box (http://www.codeproject.com/combobox/RecreateComboBox.asp) in order to sort or not sort the strings in the combo box dynamically.
Usage :
- Double clicking on the icon in the system tray brings the program back up.
- A single left click parses the code using the default parser or the last used parser.
- Right clicking allows you to change the default parser.
- The changes in the settings are automatically saved in a file Settings.cfg. Removing this file restores standard settings.
Note :
The latest change of attachment happened at 11.00 local time, wed 12 feb. Improvement : The button "Program Options" allows the user to change the symbols for vBul or Html. I've also allowed to enter a tab (\t) in the edit boxes to allow to specify how many spaces (&nbsp;) a tab should be replaced with at the request of CBasicNet.
Cimperiali
November 8th, 2002, 06:38 AM
I just don't know the preprocessor directives
What?
(Meant: "know nothing about that")
Simon666
November 8th, 2002, 06:50 AM
Originally posted by Cimperiali
What?
(Meant: "know nothing about that")
Ofcourse. I already mentioned I do not know or have Visual Basic. Can you tell me please so I can incorporate it?
And by the way, with whose tool did you format that code? It's not mine I've checked, the ")" in the end should not be red.
Yves M
November 8th, 2002, 07:53 AM
VB doesn't have a preprocessor, so as soon as you have implemented those three rules, you're done ;)
Interesting that you let the user also specify new rules. I'll have a look at your code to see how you do things.
COM is Component Object Model and is a successor of OLE (Object Linking and Embedding). It can be viewed as a the standard way of communication between different windows applications. For example ActiveX is built upon COM (I'm sure you've heard of ActiveX ;)). It could be useful, since this will allow us to just click on a button inside the VC IDE. This button then calls the program with the right arguments etc.
Simon666
November 8th, 2002, 08:13 AM
Originally posted by Yves M
VB doesn't have a preprocessor, so as soon as you have implemented those three rules, you're done ;)
Interesting that you let the user also specify new rules. I'll have a look at your code to see how you do things.
Thanks for the info. I didn't say the user can specify new rules, but it could easily be done and I think I'll implement that. Also, __asm and company have been added to the keyword list. I edited my previous post with attachment in this thread and replaced the attachment with a better one.
Yves M
November 8th, 2002, 08:30 AM
Simon your program is great, but I do suggest that you also find a way for the user to use the parser without bringing the window up. I know you don't like Win32 programming (hey nobody likes it that much ;)), but have a look at my code and in particular the taskbar.h file. It's really easy. Also look up the function name Shell (forgot the rest) in MSDN. It basically sends you a message you can define and passes the rest of the parameters (like WM_LBUTTONDOWN) in the rest of the parameters. I think there are also a few good examples of Taskbar Icons on CG.
Otherwise you could install a global keyboard hook. It's a bit more intrusive, but could be quite useful.
Simon666
November 8th, 2002, 08:40 AM
Originally posted by Yves M
I know you don't like Win32 programming (hey nobody likes it that much ;)), but have a look at my code and in particular the taskbar.h file. You'ld better replace that line with "I know you don't know much about Win32 programming", that would be closer to reality. :( I've tried it once, but I got problems and abandoned it. The problem was that I couldn't find any good tutorials on Win32 programming (I found some interesting basic things) but I had a problem using dialogs : I didn't know the CFileDialog equivalent for Win32, I couldn't use (m?)any MFC functions and when I drawed a dialog and placed it somewhere else, there remained a copy of the dialog (image, not dialog itself) on the place where it was moved from. I finally gave up then.
Originally posted by Yves M
Otherwise you could install a global keyboard hook. It's a bit more intrusive, but could be quite useful.Interesting. Tell me more : what is it and what can it do? And what do you mean with "a bit more intrusive"? And by the way : do you know a method in (V)C(++) to find out whether a string is a number? I found IsNan on Google, but that is for C Sharp it appears.
Simon666
November 8th, 2002, 08:53 AM
OK, I've been thinking : what if I transform my program into a dialog based one, that does not show up in the task bar (I've done that before), that creates an icon in the system tray and removes it upon exiting (seen code somewhere before), and disappears also when the user clicks next to the dialog window (probably can be done with Set and ReleaseCapture or so)?
Yves M
November 8th, 2002, 09:43 AM
That's the behaviour of a tool window. I think there are some examples on CG on how to do this, not sure.
Well yes, Win32 programming is where you get your hands really dirty. Dialogs are pretty hard to handle, not to speak of the tabbed configuration dialog I've been trying to implement :p
The problem about the keyboard hook is that
a) the user has to be able to configure the key, since otherwise there might be conflicts with his applications.
b) You have to do some real Win32 programming :p
For the keyboard hook, there is a pretty good example here (http://www.codeguru.com/system/KBHook.html). There is one problem though. Your program will have to be inside a DLL...
Checking whether a string is a number is not trivial in general. Just think of the different formatting rules for numbers, like
123,456,789.00 US locale
123 456 789,00 french locale
123.456.789,00 german locale
Since we are dealing with source code, there are other ways of doing it though. You can for example just parse it yourself and say that
a number consists of digits
there can be at most one "." inside a number
if "E" appears right after a valid number then it specifies the exponent so should be treated as part of the number.
The sequence after "E" can begin with a minus sign "-"
The sequence after "E" contains only digits.
I've been thinking about the problem of a leading "-", like in
x = -2;
z = x - 3;
k = x + (- 2);
l = + 2;
I don't see an easy way of solving this though, since the leading minus can either be an operator or part of the constant. I guess the simple solution is as in CBasicNet's modification to just ignore the leading sign.
Simon666
November 8th, 2002, 11:13 AM
OK, this is the latest version. But I am planning to make the rules and list of keywords editable. Anyway : it is now dialog based and is hidden from the task bar. So watch out : if you minimize it you have to close it in Windows Task Manager. But I'm planning to add an icon in the system tray on monday to bring the dialog back up. By for now, Simon.
Yves M
November 8th, 2002, 02:01 PM
Very nice :) System Tray ! System Tray ! Go Simon, go ;)
SolarFlare
November 8th, 2002, 05:03 PM
Nice program. I have a couple of useless suggestions:
Have the program check to see if the string it is about to format is the same as the one it just formatted. That way, if the user accidentally double clicks, the program doesn't put in extra useless code by setting the colors of the text twice.
Have the program be able to let the user define a list of custom keywords and a certain color for them to extend functionality of the program. I know that when I program I love being able to set certain words to a certain color just to give the code a better "feel".
Yves M
November 8th, 2002, 05:12 PM
Have the program check to see if the string it is about to format is the same as the one it just formatted. That way, if the user accidentally double clicks, the program doesn't put in extra useless code by setting the colors of the text twice.
Hum, no, and I won't include the feature that the program prevents the user from accidentally switching off the computer either ;) Seriously, it's actually not possible to check whether it's the same string, since the string has been modified in the clipboard. And well, what if you are like me and want to demonstrate the program and write stuff like:
Have the program be able to let the user define a list of custom keywords and a certain color for them to extend functionality of the program. I know that when I program I love being able to set certain words to a certain color just to give the code a better "feel".
Yes, this is one of the things I'm thinking about doing. It would not be hard to implement and will enhance the program quite a bit. I'll have to find a way to make the configuration through the program though, since it's a bit harder to edit the config files by hand.
SolarFlare
November 8th, 2002, 10:48 PM
Originally posted by Yves M
it's actually not possible to check whether it's the same string, since the string has been modified in the clipboard
Really? It seems to me that if you know what string is going in and what string is coming out, you can see if the string coming in is the same as the last one that was sent out. (Unless it's the first one you're sending in) - all you would have to do is save the last string your program put on the clipboard in a variable so you can compare it to the next one that comes in when the time comes.
Originally posted by Yves M
Since we are dealing with source code, there are other ways of doing it though. You can for example just parse it yourself and say that
a number consists of digits
there can be at most one "." inside a number
if "E" appears right after a valid number then it specifies the exponent so should be treated as part of the number.
The sequence after "E" can begin with a minus sign "-"
The sequence after "E" contains only digits.
I've been thinking about the problem of a leading "-", like in
x = -2;
z = x - 3;
k = x + (- 2);
l = + 2;
I don't see an easy way of solving this though, since the leading minus can either be an operator or part of the constant. I guess the simple solution is as in CBasicNet's modification to just ignore the leading sign.
I have updated my modifications on Yves original code; I couldn't compile the latest one.
I have add 4 formatting enchancements
1) In the original modification, variable names with digits inside will be ignored, now it is extended to variable names with underscores. Previously it does not.
2)Floating numbers and Integers with a minus in front will be included in the color formatting as Yves had suggested. Conditions are the minus should be attached with the numbers like -123, not - 123, and the numbers must be within ( ) or after =. Whitespaces are ignored and omitted.
3)Hex numbers are formatted. eg, 0xffff
4)Previously, f postfix is only supported for floats, eg, 1.0f . I took into consideration of eg, 323f. So now numbers like 1.0f or 1f will be both supported.
Previous program will crash if your code doesn't have numbers for it to format.
So this is the program with the bug resolved.
Attachment removed
CBasicNet
November 9th, 2002, 02:17 AM
Originally posted by Yves M
Since we are dealing with source code, there are other ways of doing it though. You can for example just parse it yourself and say that
a number consists of digits
there can be at most one "." inside a number
if "E" appears right after a valid number then it specifies the exponent so should be treated as part of the number.
The sequence after "E" can begin with a minus sign "-"
The sequence after "E" contains only digits.
Most of that is already supported in my mod, except the 2nd point.
I have attached the files I modified. As usual, backup and copy my files to the directory and add Numcoding.h to the project. Remember they are for Yves' first program.
Previous program will crash if your code doesn't have numbers for it to format.
So this is the source with the bug resolved.
Attachment removed
CBasicNet
November 9th, 2002, 05:16 AM
Yves says
I've been thinking about the problem of a leading "-", like in
Latest enchancement:You have a leading minus!
As in -123 or - 123 or - 123 but the minus must be preceded by a '=' or '(' or ','
[Edited: Current attachment deleted, there is a bug in the code]
CBasicNet
November 9th, 2002, 05:19 AM
Here's the updated files
[Edited: Current attachment deleted, there is a bug in the code]
Yves M
November 9th, 2002, 06:21 AM
You couldn't compile my latest one ? This is pretty serious... What error did you get ?
Bengi
November 9th, 2002, 09:22 AM
nice handy tool :)
CBasicNet
November 9th, 2002, 10:33 AM
Originally posted by Yves M
You couldn't compile my latest one ? This is pretty serious... What error did you get ?
SyntaxHlt.exe - 2 error(s), 0 warning(s)
-----------------------------------------------------------------
To cut the long story short...
According to MSDN, I should place the platform SDK header path before VC's. However I do not have platform SDK.
So I changed IDC_HAND to IDC_ARROW. It compiles but it always have illegal operation upon clicking the quit button. Yves supplied one doesn't have this problem through.
Yves M
November 9th, 2002, 10:38 AM
Thanks for pointing that out. I didn't realize IDC_HAND was only defined in the SDK supplied headers. I'm wondering what that crash is though, I'll look into it.
Bengi
November 9th, 2002, 03:13 PM
yeah i had the same error too,
be sure to add the cursor into ur application and load it into resource, so insted of locating it via the os, just use the resource.
s. roelants
November 9th, 2002, 03:19 PM
don't know if this is usefull but in WINUSER.H it says:
Originally posted by s. roelants
don't know if this is usefull but in WINUSER.H it says:
#if(WINVER >= 0x0500)
#define IDC_HAND MAKEINTRESOURCE(32649)
#endif /* WINVER >= 0x0500 */
Well...actually it is. This cursor is only available Windows 2000 and higher. You need to define the macros
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
Yves M
November 9th, 2002, 06:18 PM
Well in MSDN it says that it's available also on Win 98 / Me, but true under NT it isn't ncessarily supported. Anyhow, it's not an essential part of the program, so changing it to IDC_ARROW is fine ;)
Bengi it's overkill to load that specific cursor. I don't care, I just thought it would look nicer :p
Andreas Masur
November 9th, 2002, 06:40 PM
Originally posted by Yves M
Well in MSDN it says that it's available also on Win 98 / Me, but true under NT it isn't ncessarily supported. Anyhow, it's not an essential part of the program, so changing it to IDC_ARROW is fine ;)
Well...I did not look in the MSDN and if I just type in IDC_HAND nothing is coming up...(who wonders) :cool:
But you are right...looking at 'LoadCursor()' pretty much says it...but from the header file it is definitely not defined for anything else than Windows 2000 and XP....
s. roelants
November 11th, 2002, 03:36 PM
Yves M,
I finally took a look at your syntax highlighter, very nice work :) and really helpfull.
The first thing i thought about, which would be a nice addition was a code formatter, although you'd have to build half a compiler for that. And everybody mostly uses a slightly different indentation style, if any :D .
Anyway, it seems there are still a lot of people that don't use indentation in their code!! (i could be wrong, could have something todo with the copy / paste process)
Then i realized there is one in Visual studio, which actually works quite fine, never tested it before. seems to work really nice.
For those that didn't try it yet,
* just paste some code in an empty c++ document in VS,
* select all or some :D
* Edit|Advanced|Format Selection or Shift F8 apparently
* then use the yves' syntax highlighter :D :D :D
I took a quick look at the code, not trying to be difficult at all, but isn't the parser actually a lexical analyser? :confused: (don't shoot me if i'm wrong, it's been a while since i built a compiler in uni)
Anyway very nice tool indeed, (i wish i made it :D)
Steven Roelants
ps. while browsing through this thread i found a lot of posts about the format of numbers, a quick look at google i found the following info in a c++ lex file:
Yep, about the numbers that's true. The only problem remains with a leading "-" or "+". You have to understand more of the context to be able to figure out whether it's part of the number or not.
I took a quick look at the code, not trying to be difficult at all, but isn't the parser actually a lexical analyser?
I wouldn't even go so far as to saying it was a lexical analyzer :p
Yves M
November 11th, 2002, 04:42 PM
By the way, I wrote a small article about the "parser" (Ok, I'll add quotation marks from now on :p) and it got posted on Codeguru today. So there is all the information (http://www.codeguru.com/samples/SyntaxHlt.html) about the usage and the actual source code.
s. roelants
November 11th, 2002, 05:22 PM
seems the lex file i posted was actually incorrect, the + or minus sign in front where not in there:
should be (something like):
so mainly the trick would be:
if the previous token is not a number (e.g. operator or
parenthesis or whitespace or something :D )
then the + or - is part of the (following) number otherwise it's an operator. requires stuff like ungetchar or similar
Yves M
November 11th, 2002, 05:42 PM
Well, not really, since you can write
x = - 2.0;
x = y + - 2.0;
x = y + 2.0;
x = 3.0 - 2.0;
...
In the last one, is the "-" part of the number or not ? It's probably not part of the number. But still I don't see any easy way to decide this.
s. roelants
November 11th, 2002, 06:09 PM
it's even worse:
stuff like :
d=3.0 + - + - - 1.0;
d=3.0+-+- -1.0; //last space required otherwise lvalue again
is allowed!!! (they both gave 2.0 if you wanna know)
therefore i assumed that the following would work:
d=(-+-+-+-1.0);
which it did :D (gave 1.0) which is all the fault of the unary operators + and -
only thing not allowed is ++ or --
doesn't look easy to solve actually, but anyway i don't think stuff like that is written a lot :D
i think (guessing) that when you do
-1.0 it's part of the number
- 1.0 it's the unary operator
CBasicNet
November 11th, 2002, 08:02 PM
Originally posted by Yves M
Well, not really, since you can write
x = - 2.0;
x = y + - 2.0;
x = y + 2.0;
x = 3.0 - 2.0;
...
In the last one, is the "-" part of the number or not ? It's probably not part of the number. But still I don't see any easy way to decide this.
This is the rule, I use, if the minus come after a '(' or '=' or ',' and ends with a number. The minus belongs to the number. But I don't know if it is foolproof. Leading whitespaces and in between are untouched.
x = - 2.0;
x = y + - 2.0;
x = y + 2.0;
x = 3.0 - 2.0;
...
Cimperiali
November 12th, 2002, 05:44 AM
...Put all sources and exe in your first post of this thread, Yves, and delete them from other post of same thread...
;)
Have a nice day,
Cesare
Yves M
November 12th, 2002, 08:04 AM
The code and the source fo the latest one are in the first page :)
Cimperiali
November 12th, 2002, 09:38 AM
Good job, Ives.
Simon666
November 13th, 2002, 06:06 AM
I just uploaded a new attachment with improvements. The description of the improvements can be found over here (http://www.codeguru.com/forum/showthread.php?s=&postid=622856#post622856). Latest change : 12.00 local time, wed 13 nov. :cool:
By the way, if you insert a CString such as "\n" in a multi line edit box, why does it not go to a new line but shows a strange character??? You will note that when you try to modify the single line comment in my program. :confused:
Yves M
November 13th, 2002, 06:27 AM
That's a problem with the #13#10 line-breaks in windows. "\n" is character #10, but if you use printf, cout or something to that effect in windows it will get translated as #13#10. That is why in all my parsers everytime I encounter a character #13 I just ignore it.
Simon666
November 13th, 2002, 07:44 AM
So if I understand it, I have to remove character #13 from the string I retrieve from my edit box when getting the string in it. But what when putting a new line in an edit control? I want e.g.
"
"
In my edit box instead of
"WeirdCharThatSeemsImpossibleToPrintInVBulletin"
Yves M
November 13th, 2002, 08:12 AM
Well, I'm not sure about the edit box, but at least in VBulletin, it seems to understand \r\n. I'm not sure what the text that you get from the editbox contains, I suggest you step through the string and look at the hex values of the offending characters. Maybe it is just giving you the \n and since IE expects \r\n it won't work. Just like in notepad when you try to open a file with only \n (like Unix text files).
Simon666
November 13th, 2002, 08:15 AM
OK, I've solved the problem. I replace "\n" with "\r\n" when placing the string in the edit box and replace "\r\n" with "\n" when I press OK on the dialog.
Simon666
November 13th, 2002, 12:26 PM
I just uploaded a new attachment with improvements. The description of the improvements can be found over here (http://www.codeguru.com/forum/showthread.php?s=&postid=622856#post622856). Or you can just upload it by clicking in my signature. The program has been made to look way more cool. :cool: :) :D
By the way, if someone tests it out : please let me know if the icon of visual basic is the actual vb one. I found a lot of hits on the web, but it is hard to figure out the correct one(s).
Yves M
November 13th, 2002, 01:40 PM
Very funky :)
Simon666
November 13th, 2002, 01:47 PM
Thanks. One of the next things I plan to do is provide the same for conversion to HTML. Shouldn't be too much trouble.
Yves M
November 13th, 2002, 06:57 PM
One thought:
I think it would be really cool if we used the same config files for both our parsers. Of course, each one would have its own special sections. For mine that would be the rules and the special symbols in my format and for yours it would be all the special data you need. Then the user could really choose the program based on the UI (OK, yours would win anytime right now ;)).
What do you think, Simon ?
Simon666
November 14th, 2002, 03:27 AM
Originally posted by Yves M
One thought:
I think it would be really cool if we used the same config files for both our parsers. Of course, each one would have its own special sections.How would this work? What do you mean with special sections? Standard in the beggining, but at some point there would be near the end of the file a section underneath the line "special: Yves formatting" or "special: Simon formatting"?
Originally posted by Yves M
For mine that would be the rules and the special symbols in my format and for yours it would be all the special data you need.Do you want to propose a file format or do I have to?
Originally posted by Yves M
Then the user could really choose the program based on the UI (OK, yours would win anytime right now ;)).
What do you think, Simon ? Seems interesting. Practical details need to be arranged. First I'll keep myself busy though with HTML formatting. Seems more complicated (or at least more work) than I thought at first.
Yves M
November 14th, 2002, 06:53 AM
What I mean is that we both process stuff like
#Keywords
#KeywordColorBegin
#KeywordColorEnd
...
If you haven't done it yet, have a look at my config files, it shows how they work for the moment. I think we should introduce end-tags for the different sections in the file, so that if there is a section start which my program doesn't understand it will not assume that the following text is part of the previous section.
So what I propose for the common things for the time being is:
#Keywords
#End Keywords (or #EndKeywords, doesn't matter to me)
#KeywordColorBegin
#EndKeywordColorBegin
#KeywordColorEnd
#EndKeywordColorEnd
I've seen that you implemented a way to have several lists of "keywords" that you can color differently. So maybe we could incorporate that in the file format by just appending a number at the end. Like:
#Keywords2
#KeywordColorBegin2
#KeywordColorEnd2
...
Standard in the beggining, but at some point there would be near the end of the file a section underneath the line "special: Yves formatting" or "special: Simon formatting"?
What I mean is that you have your own #SomeSection and #SomeSectionEnd, which my program doesn't understand. And I have my own sections which your program doesn't understand.
Simon666
November 14th, 2002, 06:59 AM
I'll have a look at your config files. I have good hopes this will work. I am currently busy with HTML support though and with another imrpovement : the color list is only for Codeguru, not for other forums. I am therefore modifying the code for the coloring.
Yves M
November 14th, 2002, 07:21 AM
Well, why don't you just let the user specify custom colors ? Just use [COLOR=#880000] and the like (RGB value in hex)
Simon666
November 14th, 2002, 12:26 PM
****!!! :mad: It's hard to keep the file size under 100 kB by now. OK, I just uploaded the latest version, HTML conversion is now supported. Also the format of the normal text can be modified, I forgot this in the previous one. When pasting code in HTML with font size 3 and font Courier New you get to see something that resembles very much what you see in Visual C++. One button is not working yet : the program options button. I plan to allow the user to add and delete custom colors to the color list in this option for example. I do not think some other option is missing yet. At least, apart from the saving of the configuration in a config file. I will have a look at Yves config file and then get back.
Simon666
November 14th, 2002, 01:05 PM
Well Yves, In order to support multiple keyword lists and so I suggest in that case the formatting should be something like this :
#Keyword List 1
#Keyword Color Name Blue Can be empty string ""
#Keyword Color "0000FF"
align
...
wmain
#Keyword List 2
#Keyword Color Name Red
#Keyword Color "0000FF"
#include
...
#ifndef
#Rules
" " "#880000" Red \
' ' "#880000" Red [/COLOR] 3 \
// \n "#008800" Green [/COLOR] 1
/* */ "#008800" Green [/COLOR] 3
Tomorrow, I'll try to read Simon's code. Hopefully, his code is easy to understand.
Simon, I noticed that there is this ArrayEx used in your code, are you the one who wrote it?
Yves M
November 15th, 2002, 08:56 AM
Originally posted by Simon666
Well Yves, In order to support multiple keyword lists and so I suggest in that case the formatting should be something like this :
#Keyword List 1
#Keyword Color Name Blue Can be empty string ""
#Keyword Color "0000FF"
align
...
wmain
I would put here a #End Keyword List 1. I think it's better that we have #End tags, so that we don't accidentally step over the current block if we don't understand the block.
#Keyword List 2
#Keyword Color Name Red
#Keyword Color "0000FF"
#include
...
#ifndef
#Rules
" " "#880000" Red \
' ' "#880000" Red [/COLOR] 3 \
// \n "#008800" Green [/COLOR] 1
/* */ "#008800" Green [/COLOR] 3
Well, hum, why the " for "#880000" ? In case there needs to be a space inside a string, I use \w to indicate that. And also, where are the [COLOR=#008800] gone ? Since we want it to be independent of the target (i.e. vBulletin or HTML or whatever), we need to specify something like:
#Rule Colormask Begin [COLOR=\c]
#Rule Colormask End [\COLOR]
and then say that \c stands for the color value as defined in the rule. Does this sound OK ?
#Other Program specific stuff
Symbols seem fine to me. I wonder whether we should allow for symbols that are strings, not only 1 character like I do currently. What do you think ?
Simon666
November 15th, 2002, 10:29 AM
Originally posted by Yves M
I would put here a #End Keyword List 1. I think it's better that we have #End tags, so that we don't accidentally step over the current block if we don't understand the block.
OK, seems logical.
Originally posted by Yves M
Well, hum, why the " for "#880000" ?
That was just a thought. I noticed in your code you put in even way more than that, you filled in the complete prefix and suffix to be added to a word.
Originally posted by Yves M
In case there needs to be a space inside a string, I use \w to indicate that. And also, where are the [COLOR=#008800] gone ? Since we want it to be independent of the target (i.e. vBulletin or HTML or whatever), we need to specify something like:
#Rule Colormask Begin [COLOR=\c]
#Rule Colormask End [\COLOR]
and then say that \c stands for the color value as defined in the rule. Does this sound OK ?
About the replacing of the [ with &# 091 I just figured that one out yesterday evening. It sounds OK.
Originally posted by Yves M
Symbols seem fine to me. I wonder whether we should allow for symbols that are strings, not only 1 character like I do currently. What do you think ?
I currently have no special things forseen for symbols, and I don't know if I'll add that. It would not be problem for me that it is more than one character, as I use CString and its functions anyway, in the case that I would add it. But I don't see the point : it is not like you can leave the conversion of > to > away e.g. when converting to HTML.
And Yves : I keep wondering about this : "[ &\#091;" : why the "\" and the ";"? If you remove those, only then you obtain the character combination that is replaced with "[" in vBulletin as I understand. That a tab is replaced with two white spaces I understand. But why does \n needs to be replaced with \r\n, \r with \e and the strangest of all \w with \w?
Originally posted by CBasicNet
Tomorrow, I'll try to read Simon's code. Hopefully, his code is easy to understand.
It is certainly easier than Yves' code.
Originally posted by CBasicNet
Simon, I noticed that there is this ArrayEx used in your code, are you the one who wrote it?
No, I forgot to mention that. That is coming from here : http://www.codeguru.com/cpp_mfc/excoll.shtml
Yves M
November 15th, 2002, 10:43 AM
Originally posted by Simon666
And Yves : I keep wondering about this : "[ &\#091;" : why the "\" and the ";"? If you remove those, only then you obtain the character combination that is replaced with "[" in vBulletin as I understand. That a tab is replaced with two white spaces I understand. But why does \n needs to be replaced with \r\n, \r with \e and the strangest of all \w with \w?
lol, the \w to \w is not needed. The \n to \r\n and \r to \e is needed since you can't be sure that the string you get from the clipboard is actually using \r\n or just \n.
The reason for the \ in &\#091; is simply that you can escape the # character in the input file by specifying \# in case a keyword or rule begins with #. This is because generally a line that begins with a # in the input file is either a section command or just a comment. Here it is not really needed since it doesn't occur as the first character in the line. It's just easier for my config file generator to always replace # with \# as opposed to checking whether it's the first character in the line.
Simon666
November 15th, 2002, 12:49 PM
OK, I'll start programming then, on monday I'll probably put an improved version with config files on here. I did add an improved version in this thread though. The problem occured only with HTML conversion : in case of vBulletin conversion I replaced a tab with two white spaces from the start on, in case of HTML this was not possible due to the fact thatwhite space is   and the & needs to be replaced with &. I needed to add one extra line to solve this problem. :rolleyes:
Yves M
November 15th, 2002, 03:02 PM
By the way, I think that HTML output would be better (and easier) if we were using the <PRE> </PRE> tags. This makes sure that a fixed-width font is selected and the normal spaces continue to be treated as spaces. So there is no real need for &nbsp;
P.S. I understand your posts, but remember that vBulletin processes stuff like &nbsp; as well ;) So rather write &amp;amp; for the HTML code for & for example ;)
CBasicNet
November 15th, 2002, 08:11 PM
Yves, I got 2 questions.
What does &*nbsp; mean in HTML?
Where is Madrid?
:D
Andreas Masur
November 15th, 2002, 11:56 PM
Originally posted by CBasicNet
Yves, I got 2 questions.
What does &*nbsp; mean in HTML?
Where is Madrid?
:D
I am not Yves but maybe I am allowed to answer as well... :cool:
1. I think you mean & nbsp ; (spaces are only in there so that it does not get translated into HTML) which would be a single space in HTML...
2. Madrid is located in Spain...
Simon666
November 16th, 2002, 04:41 AM
&*nbsp; : non breaking space : " "
&*gt; : greater than : ">"
&*lt; : lower than : "<"
&*amp; : ampersand : "&"
&*quot; : quotation : """
And Madrid is located in "Mini-Europe" in Brussels. Looks a bit small for people to live in. :D ;) :p
CBasicNet
November 17th, 2002, 09:10 AM
Thank you, Andreas and Simon.:D
Simon666
November 18th, 2002, 03:07 AM
Originally posted by Yves M
By the way, I think that HTML output would be better (and easier) if we were using the <PRE> </PRE> tags. This makes sure that a fixed-width font is selected and the normal spaces continue to be treated as spaces. So there is no real need for &nbsp;Back at work just now. How about tab and newline? Same as white space?
Simon666
November 18th, 2002, 08:24 AM
Update:
My previous version :
char Test[256] = "Try \"" + "This" + "\" once";
My new version :
char Test[256] = "Try \"" + "This" + "\" once";
Yves' version :
char Test[256] = "Try \"" + "This" + "\" once";
Download my latest version at the usual place.
Yves M
November 18th, 2002, 08:35 AM
Originally posted by Simon666
Back at work just now. How about tab and newline? Same as white space?
I would still convert tabs into spaces, since tabs get really wide otherwise. But newlines are handled correctly by <PRE>. It's easy, just make a small HTML file to test. :)
Simon666
November 18th, 2002, 08:55 AM
Originally posted by Yves M
I would still convert tabs into spaces, since tabs get really wide otherwise. But newlines are handled correctly by <PRE>. It's easy, just make a small HTML file to test. :) Arranged. Updated version to be downloaded by clicking in my sig or on the second page of this thread.
Yves M
November 18th, 2002, 09:11 AM
Actually, why don't we start discussing this stuff in the Programming Projects (http://www.codeguru.com/forum/forumdisplay.php?s=&forumid=40) forum ? It seems like the perfect place for this kind of thing :)
Simon666
November 18th, 2002, 09:18 AM
You're right. But the disadvantage is that even fewer people (read : nobody) are going there. Is in that forum more than 100 kB in an attachment possible? Then I would seriously consider going there. It would be an advantage if in each thread in that forum you can only post only one attachment but with a bigger filesize.
Yves M
November 18th, 2002, 09:32 AM
I don't think that filesizes for attachments are different in different forums. For the source code we could actually use Sourceforge, but it's a bit pointless since we are not developing the same program ;)
Simon666
November 18th, 2002, 09:42 AM
Originally posted by Yves M
I don't think that filesizes for attachments are different in different forums. For the source code we could actually use Sourceforge, but it's a bit pointless since we are not developing the same program ;)
True, but something compatible would be nice maybe. Concerning the rules : I suggest the formatting :
#Rules
" " \" "#880000" Red \ [/COLOR] 1
// \n "#008800" Green [/COLOR] 1
/* */ "#008800" Green [/COLOR] 3
Note : I added \" in the first line and two spaces in the last two lines. This is because in the first case \" does not terminate a comment.
dimm_coder
November 18th, 2002, 10:00 AM
Guys! Of course, all are excellent, but I do not understand for this moment next: Why are U working parallel for same program and doing same code by everyone???
I have seen one of the last Simon's post where he showed same result of program worked like Yves program but there have only different colors of output text?
May be it will be more advisable do not reiterate one another and work everyone for different parts of program???
Simon666
November 18th, 2002, 10:13 AM
Originally posted by dimm_coder
Guys! Of course, all are excellent, but I do not understand for this moment next: Why are U working parallel for same program and doing same code by everyone???
I have seen one of the last Simon's post where he showed same result of program worked like Yves program but there have only different colors of output text?
May be it will be more advisable do not reiterate one another and work everyone for different parts of program??? Dimm_coder, I only have 50*50 pixels for displaying my ego, while 5e6*5e6 pixels would do me more right and would make you understand why I work alone. :D
Now seriously, I would like the code to be as simple as possible (don't understand std stuff) and most certainly not to be Win32, which is why I do not wish to contribute to Yves code. Yves does not need help from me, and I don't like help unless I can't do without it.
Yves M
November 18th, 2002, 10:28 AM
Actually, I wouldn't mind working on only one program. I'm going to have a deeper look into your parser tonight, and maybe we'll just continue with that one.
Just a side note on STL and std:: etc. It's really simple to use, much like the MFC counterparts CString, CArray etc, but just a tad bit more powerful and you have more options and functions. The only "obfuscated" bit in my program as far as I can see is the class CFSM, which is indeed really confusing.
Simon666
November 18th, 2002, 10:40 AM
Originally posted by Yves M
Actually, I wouldn't mind working on only one program. I'm going to have a deeper look into your parser tonight, and maybe we'll just continue with that one.I've never worked together with someone on something. The previous post was joking a bit, I always appreciate help, but currently, the program is as good as finished. I only need to add a possibility to save the current configuration, to add or delete custom colors in the button program options and that's it I think. All further cooperation would require more time discussing together than it would take one person to finish the job I think. ;)
Originally posted by Yves M
Just a side note on STL and std:: etc. It's really simple to use, much like the MFC counterparts CString, CArray etc, but just a tad bit more powerful and you have more options and functions. The only "obfuscated" bit in my program as far as I can see is the class CFSM, which is indeed really confusing. I intend to work on that part (STL), but I only need to find the time. :rolleyes:
Yves M
November 18th, 2002, 10:53 AM
Well, it's true that it's not a huge program :p When I find some time, I'll work a bit on mine too.
#Rules
" " \" "#880000" Red \ [/COLOR] 1
// \n "#008800" Green [/COLOR] 1
/* */ "#008800" Green [/COLOR] 3
I don't like this. The reason is that the "\" in the first line is an optional parameter, so it's much easier to handle if it is placed at the end of the line, like:
" " "#880000" Red [/COLOR] 1 \"
I also don't understand why you want to keep the quotation marks around the color: "#880000". And do you really have to store the name of the color in the rule ? What if the user wants a color you don't have a name for ?
Plus, if we are allowing for
#Rule Colormask Begin [COLOR=\c]
#Rule Colormask End [\COLOR]
then there is no need to specify [\COLOR] inside the rules themselves. So I would suggest the following:
#Rule Colormask Begin [COLOR=\c]
#Rule Colormask End [\COLOR]
#Rules
" " #880000 Red 3 \"
// \n #008800 Green 1
/* */ #008800 Green 3
#End Rules
Also note that the number I put at the end has the following meaning:
0 = Start and End strings for the rule are not put inside the formatting.
1 = start is inside the formatting, end is not
2 = end is inside the formatting, start is not
3 = both start and end are inside the formatting
Simon666
November 18th, 2002, 11:01 AM
Originally posted by Yves M
Well, it's true that it's not a huge program :p When I find some time, I'll work a bit on mine too.
I don't like this. The reason is that the "\" in the first line is an optional parameter, so it's much easier to handle if it is placed at the end of the line, like:
" " "#880000" Red [/COLOR] 1 \"
Deal.
Originally posted by Yves M
I also don't understand why you want to keep the quotation marks around the color: "#880000". And do you really have to store the name of the color in the rule ? What if the user wants a color you don't have a name for ?That is a misunderstanding. I only copied what you had already posted some posts ago but I note just now that there you also questioned that. Sorry, I do not in any way insist on using that. Could you BTW post a bit of an oversight of what the format would need to be up to now?
Originally posted by Yves M
Plus, if we are allowing for
#Rule Colormask Begin [COLOR=\c]
#Rule Colormask End [\COLOR]
then there is no need to specify [\COLOR] inside the rules themselves. So I would suggest the following:
#Rule Colormask Begin [COLOR=\c]
#Rule Colormask End [\COLOR]
#Rules
" " #880000 Red 3 \"
// \n #008800 Green 1
/* */ #008800 Green 3
#End Rules
Also note that the number I put at the end has the following meaning:
0 = Start and End strings for the rule are not put inside the formatting.
1 = start is inside the formatting, end is not
2 = end is inside the formatting, start is not
3 = both start and end are inside the formatting
As stated before, for all clarity, maybe an overview of the rules for the formatting would help. And does this "#" character has a special meaning? Because I intend to include preprocessor directives such as #include.
Yves M
November 18th, 2002, 11:20 AM
Ok, so here it is:
Special symbols for the input file
# at the beginning of a line indicates a comment or a section start / end. This means that if one of the programs doesn't understand the specific rule, it doesn't "break".
\w = white space
\r = character 13
\n = character 10
\e = empty string
\t = tab character (9)
\c = stands for the actual color string inside the #Rule ColorMask tag.
\# = single #. So if you want to have a keyword like #include then you would write in the config file : \#include
Sections
#Keywords 1
<list of keywords>
#End Keywords 1
Of course 1 can be any number
#Keyword 1 Color Begin [COLOR=#880000]
#Keyword 1 Color End [/COLOR]
#Symbols
\t \w\w
etc...
#End Symbols
#Rules
RULESTART RULEEND COLOR INCLUSION_INT [optional : ESCAPESTRING]
" " #880000 3 \"
#End Rules
#Rule Colormask Begin [COLOR=\c]
#Rule Colormask End [\COLOR]
Simon666
November 18th, 2002, 11:24 AM
OK, I can live with this. Probably tomorrow evening or on wednesday at last I hope to be able to save information in such a config file.
CBasicNet
November 19th, 2002, 11:16 PM
Have anyone downloaded Simon's program? Wow the GUI is too cool!
Simon, how did you do the button highlighting when the mouse cursor hovers on top of them?
There is only 2 button events we can handle in VC6 (clicked and double clicked) and there is no mouse events for the buttons in VC.
At a quick glance, there is no mouse event handler in your dialog code!
Although I compile your (Simon's) code, classbrowser and class wizard showed nothing at all in my VC.
Yves:I can compile your code with no problems in VC7.
CBasicNet
November 19th, 2002, 11:19 PM
Originally posted by CBasicNet
Simon, how did you do the button highlighting when the mouse cursor hovers on top of them?
If I'm not wrong, you did all the hard work yourself.
If I'm not wrong, you are an color expert.
Simon666
November 20th, 2002, 03:19 AM
Originally posted by CBasicNet
If I'm not wrong, you did all the hard work yourself.
If I'm not wrong, you are an color expert.
You are giving me too much credit. I placed the info on what I used in this post (http://www.codeguru.com/forum/showthread.php?s=&postid=622856&highlight=keywords#post622856). I even forgot to mention some, I'll add them later. I basicly only wrote the text parsing functions myself and that gave me enough problems. But I'm glad you like the GUI. About Class Wizzard not showing anything : I deleted all files that were not absolutely necessary in order to keep the size of the attachment under 100 kB. So I only kept cpp,h,dsw,dsp and resource files, while opt, aps, ncb, clw files and so where deleted.
dimm_coder
November 20th, 2002, 04:30 AM
Yves, I've just wanted to look at your program but when I 've loaded it ( Win XP ) it has crashed every time.
if you have memory map file U can find function.
This function have got some str and tryed to copy it somewhere
but failed. :(
Yves M
November 20th, 2002, 10:06 AM
Weird, have you tried compiling the source code ? I'll check which function that is in.
dimm_coder
November 21st, 2002, 02:32 AM
Originally posted by Yves M
Weird, have you tried compiling the source code ? I'll check which function that is in.
I haven't spent some time trying to find bug. I have compiled it only once, but I have got trouble with IDC_HAND constant as I remember, but haven't enough time there to find it.
Possible, it included only with some SP fo VC++.
Some later I 'll try to find reason of failing your program, if I 'll compile it , of course.
Simon666
November 22nd, 2002, 04:19 AM
By the way I have not found the time yet to implement the cfg file but I have added support for variable symbols already. I plan to allow the user to edit these symbols in the button ''Program options''.
A very nice feature is that I have added in the list of symbols all smilies. So you do not need to check that "Disable smilies in this post" any more, which is pretty handy since most people forget that resulting in annoying smilies where they shouldn't, plus it leaves in the possibility of having smilies in your post AND have correct code.
You can download the improved version at the usual place or just click in my signature.
Arg !!! I thought about that but didn't find the time to implement it. Now this is some real market competition :D
Great, Simon :)
Simon666
November 27th, 2002, 05:07 AM
Originally posted by Yves M
Now this is some real market competition :D
Even further market competition : mine now also stores the settings : keyword lists, symbols, rules and colors in a file Settings.cfg. This file is automatically located in the same directory as the executable. If something goes wrong, like when you try to edit this file manually (why would you, it has a GUI for something), you can always delete this file, but then you will loose your previous settings ofcourse.
I still plan to allow the user to add or delete custom colors, to restore the standard setting with a button click and to edit the symbols for vBulletin and Html conversion.
You can download it at the usual place or by clicking in my signature.
Yves M
November 27th, 2002, 10:08 AM
Aha, I'll have a look at your settings file and tell you if it conforms to the ISOGY standard ;)
Simon666
November 27th, 2002, 10:12 AM
Originally posted by Yves M
Aha, I'll have a look at your settings file and tell you if it conforms to the ISOGY standard ;) No it isn't. I didn't have the time for that. There are some problems : each keyword list also has its own name, as well as each color. Writing it so that is accepts your files would be a lot of work, while my method just took an hour or so. Actually it took only around 15 minutes probably but I got into problems since SerializeElements doesn't seem to work for dialog based applications, see also my question in the VC forum.
Simon666
November 27th, 2002, 10:16 AM
Oh, and by the way while I'm busy, does anybody knows a control (ActiveX or otherwise) like a flexgrid, but where you can edit the cells as in Excel and if not asked too much, can be used to paste data in, copied from to excel?
Yves M
November 27th, 2002, 10:17 AM
Arg ! what does this settings.cfg file look like ?? It doesn't even open correctly in Wordpad ! It's not compatible to the ISOGY standard !
...
Ha, always take whatever opportunity to make your competitors program look bad ;) So, seriously, it's great but I do have complaint. When the user wants to use your parser he has to bring the main window up and click on the appropriate button. I think it's easier if he can just click on the taskbar icon or even have a global key stroke for this.
Yves M
November 27th, 2002, 10:19 AM
Originally posted by Simon666
Oh, and by the way while I'm busy, does anybody knows a control (ActiveX or otherwise) like a flexgrid, but where you can edit the cells as in Excel and if not asked too much, can be used to paste data in, copied from to excel?
No clue :/ I wonder whether the clipboard format Excel uses is even documented...
Simon666
November 27th, 2002, 10:58 AM
Originally posted by Yves M
When the user wants to use your parser he has to bring the main window up and click on the appropriate button. I think it's easier if he can just click on the taskbar icon or even have a global key stroke for this. I'll take it into consideration.
And by the way, what is ISOGY(ves)?
Yves M
November 27th, 2002, 11:13 AM
International Standards Organisation for Gangsters like Yves ;)
Simon666
November 27th, 2002, 01:11 PM
Originally posted by Yves M
Ha, always take whatever opportunity to make your competitors program look bad ;) So, seriously, it's great but I do have complaint. When the user wants to use your parser he has to bring the main window up and click on the appropriate button. I think it's easier if he can just click on the taskbar icon or even have a global key stroke for this. Arranged on general request. Well, actually only on Yves request. But I wouldn't want any trouble with the mafia so I quickly implied it. :D
Double clicking the icon now brings the program back up (as before), while single clicking converts it from VC to vBulletin the first time and the second time it uses the last conversion you used (4 possibilities : VC/VB->vBul/Html).
This is not as easy as it looks since WM_LBUTTONDBLCLK is preceded by WM_LBUTTONDOWN so I had to use a timer to discriminate single and double clicks. Any more complaints.? :cool:
Yves M
November 27th, 2002, 01:16 PM
Originally posted by Simon666
Double clicking the icon now brings the program back up (as before), while single clicking converts it from VC to vBulletin the first time and the second time it uses the last conversion you used (4 possibilities : VC/VB->vBul/Html).
That is weird behaviour... ;)
Can't you let the user see in your dialog-box which parser will be used when he just left-clicks ? And then just remember that so a VB programmer won't have to do anything weird ;)
Simon666
November 27th, 2002, 01:20 PM
Wouldn't it be better to show it in the popup menu when right clicking which conversion will be used when left clicking? Most people probably use one conversion continuously for a certain period I assume.
Yves M
November 27th, 2002, 01:26 PM
Yes, that's what I meant ;) I guess I shouldn't make long sentences which can be misunderstood if the subsentence structure is not clear from the comma-placement or the general flow of ideas does not convey enough meaning for the sentence not to be ambigous :p
Ok, so I meant that :
- left-click -> parse using the "current" parser
- right-click -> pop up the dialog box
- in the dialog-box, highlight the "current" parser
- remember the "current" parser when the program closes and set it again on the next startup.
Simon666
November 27th, 2002, 02:23 PM
How do I set a popup menu item checked using SetMenuItemBitmaps? I can't get it to work. :(
Yves M
November 27th, 2002, 05:33 PM
Registered: Oct 2001
Location: Gent, Belgium
Posts: 1666
;)
But for your problem, I don't know. In Win32 it's pretty easy :p
Simon666
November 28th, 2002, 03:54 AM
OK, problems solved thanks to JohnCz. Now my program has pretty much all the features of Yves program except that it has a nice user interface to change keyword lists, rules, symbols, ...
Yves M
November 28th, 2002, 09:33 AM
Don't worry, I'll find some other things to complain about ;)
Bengi
December 4th, 2002, 02:27 AM
*g* i wonder why m$ made MFC so complicated insted of making it easy to use..
thousads on code which is in the end 1 big spaggeti :-)
Simon666
December 4th, 2002, 02:43 PM
Update : the "program options" button now actually does something : it lets you change the symbols for vBulletin and Html. I would like to ask if anybody has an idea of how this could be done better. What I would like more is : the list box should contain out of two colums. Currently it is a bit of a disorder. Anybody knows how to accomplish something better than the current?
Mr.Gauntlet
January 24th, 2003, 05:33 PM
your app seems great; unfortunately, i think i got an older version which doesn't work exactly as it should....
but be sure i'll get the latest version........
good job.............:D
Simon666
February 12th, 2003, 04:59 AM
Well that is a long time ago. This thread has been in coma for months. Well, the latest improvement is: The button "Program Options" allows the user to change the symbols for vBul or Html. I've also allowed to enter a tab (\t) in the edit boxes to allow to specify how many spaces (&nbsp;) a tab should be replaced with at the request of CBasicNet.
You can download the modified program at the usual place, just click in my signature.
CBasicNet
February 12th, 2003, 07:46 AM
Thank you, Simon.:)
Simon666
February 12th, 2003, 08:15 AM
Originally posted by CBasicNet
Thank you, Simon.:)
Just curious: are you making a website?
CBasicNet
February 12th, 2003, 08:56 PM
Originally posted by Simon666
Just curious: are you making a website?
No, but I do intend to make one in near future. You can bet I will mention the syntax coding software I use on my website.
Actually I was writing a very simple article for CodeGuru on last Sunday. And the code involved was very short, so I did not want to attach a zipped source if possible.
I used your program to format the code but it generated too many &!nbsp, making the HTML size too big and it screwed my original code alignment. Here's an example,
//Original formatting in my VC6 where 1 tab is set to 2 spaces
//Very long parameter list functionA call so split into 2 lines
functionA( XXXXXXX, XXXXXXX, XXXXXXX, XXXXXX,//1 tab
XXXXXX,XXXXXX,XXXXXX,XXXXXX,XXXXX);//7tabs
//After applying Simon's program for HTML
functionA( XXXXXXX, XXXXXXX, XXXXXXX, XXXXXX,//1 tab
XXXXXX,XXXXXX,XXXXXX,XXXXXX,XXXXX);//7tabs
I tried for 2 hours to set the options for tab, and as you know, I couldn't type tab in the edit box.
I gave up, I used <!pre> and </!pre> and my code didn't appear correctly and only half of it was shown because of the < , > signs in the code confused the browser. I had no choice but to include a zipped source which I guess was the smallest zipped source ever to accompany an article on CodeGuru.
I have submitted the article on Sunday and received an email from CodeGuru on Wednesday that my article was being put on queue for it's turn on display.
Anyway, later I found out CodeGuru doesn't allow source code formatting in the HTML to be submitted to them as stated in the 'Submission Guidelines', CodeGuru admin staff will format it themselves.
CBasicNet
February 12th, 2003, 08:59 PM
Here's the modified source for the 1st version of Yves program.
I removed the source long time ago as there is a bug introduced with negative sign coding. Here's the description of the bug
//It is okay if there is only 1 number on the line
int a=50;
//If there is more than 1 number on 1 line, the problem comes
functionb(8963, 893,ABC);
I removed the negative sign coding, the bug is solved.
This program does not support HTML coding, only vBB coding for C++. Since this is the 1st version of Yves program, it is quite primitive compared to his updated version; I just put it up here to be in accord to the spirit of the thread and for anyone who may be interested.
This modified source supports coloring for integers, hex numbers, and floating point numbers(both normal and scientific notation).
Uploaded another updated source (on 17/02/03) which solves a minor bug.
In the previous version if you put 20000f, it will be taken by the s/w to be a integer. Now that's solved.
fl=20000f+20000;
How to use the program for those who are not familiar with it
1)In your whatever IDE or editor, copy the C++ text you want to be formatted.
2)Start the program.
3)Left click on the C++ icon on the task bar.
4)Paste it into CodeGuru's reply page's edit box.
5)After finished using it, right-click on the C++ icon to exit
==============================
To change the colors of the number
I have begun making a website myself and I noticed some problems you mentioned. At home I have an modified/improved version of the program, I don't know exactly what I changed. As I intend to already put some programming pages on my site even this week, I think I'll maybe provide some extra modifications to the code coloring program soon.
I know for HTML it is currently not fully functional, the tabs screw up the alignment a bit but I seldom use tabs.
CBasicNet
February 13th, 2003, 03:14 AM
Originally posted by Simon666
I seldom use tabs.
:eek: You rather type so many spaces!:eek:
Simon666
February 13th, 2003, 03:18 AM
Originally posted by CBasicNet
:eek: You rather type so many spaces!:eek:
No. More like this:
if ()
{
for ()
{
if ()
}
}
So use spaces instead of tabs.
CBasicNet
February 13th, 2003, 03:35 AM
Anyone here find the VC Intellisense of auto alignment of code for you is annoying? How to turn this off? I only want to turn that that part of Intellisense off. When I open the same source in another Editor, the alignment is screwed up, that's why I use tab now.
Simon666
February 13th, 2003, 03:40 AM
Originally posted by CBasicNet
Anyone here find the VC Intellisense of auto alignment of code for you is annoying?
I never even heard of autoalignment. I would ask, how do you turn it on?
CBasicNet
February 13th, 2003, 03:47 AM
Originally posted by Simon666
I never even heard of autoalignment. I would ask, how do you turn it on?
You remember when you just type a '{', you are in a scope when you go to the next time, it is already indented for you automatically. I think VC use tabs to indent for you.
Perhaps you never open your source in another editor (like UltraEdit or DevC++), that explains why you don't know.
Simon666
February 13th, 2003, 03:53 AM
Originally posted by CBasicNet
Perhaps you never open your source in another editor (like UltraEdit or DevC++), that explains why you don't know.
Yep, but even then it seems strange to me. You say the original code is messed up then? Don't they save all the tabs and spaces in the .cpp, .h, ... files themselves? I don't understand then how it could get screwed up.
:confused:
CBasicNet
February 13th, 2003, 04:02 AM
What I mean is the original code always appears correctly in VC but not in others.
I opened a VC source in UltraEdit, shows screwed up alignment. Reopened in VC it is correct. That's why I use tab now.
Simon666
February 13th, 2003, 04:12 AM
OK, what about "Tools"->"Options"->"Tabs", there are a number of options, perhaps it is "Auto-Indent" you need to set to none.
CBasicNet
February 15th, 2003, 06:13 AM
Thank you, Simon!
These couple of days I have been saying so many "Thank you" to Simon that I think I might as well change my nick to Thank_you,_Simon !:D
Simon666
February 15th, 2003, 12:48 PM
So I guess that worked? I wouldn't know as I only have MS VC++ compiler.
CBasicNet
February 16th, 2003, 08:09 PM
Thank you, Simon!:o :D
I think by selecting 'insert spaces' would work too if you are using spaces. But now I'm using tabs.
Just to inform, I just uploaded a new source, today, which solved a minor bug.
CBasicNet
February 17th, 2003, 01:32 AM
Originally posted by Simon666
I have begun making a website myself and I noticed some problems you mentioned. At home I have an modified/improved version of the program, I don't know exactly what I changed. As I intend to already put some programming pages on my site even this week, I think I'll maybe provide some extra modifications to the code coloring program soon.
I know for HTML it is currently not fully functional, the tabs screw up the alignment a bit but I seldom use tabs.
Simon, have you been to Cakkie's website? His lamp control thingy is quite cool.
I think within the <!pre> tags, you don't have to put &!nbsp for spaces else for every space generated there are 5 chars, the size of formatted code becomes quite big. I'm not very sure, as you know I'm an idiot when it comes to HTML.
Simon666
February 17th, 2003, 03:20 AM
Originally posted by CBasicNet
I think within the <!pre> tags, you don't have to put &!nbsp for spaces else for every space generated there are 5 chars, the size of formatted code becomes quite big. I'm not very sure, as you know I'm an idiot when it comes to HTML.
Yes, the <!PRE> things do that. I forgot to take with me the more suitable for HTML version of my syntax coloring program from home. I already uploaded some code formatted with it on my website. You can check it on my website, but it is still under construction.
Originally posted by CBasicNet
Simon, have you been to Cakkie's website? His lamp control thingy is quite cool.
I haven't had time to check it long enough, but is that really so? It seems to me it just uploads an image with the lamp turned on, not an actual lamp being switched on. I also didn't check what happens at the approximate time when he should be at home.
CBasicNet
February 17th, 2003, 08:12 AM
Originally posted by Simon666
You can check it on my website, but it is still under construction.
You have just indirectly reminded me that before I made my own website, I had better learn some PhotoShop first, else CodeGuru will see more of my ascii art in the 'Testing Area'.:p :D
Simon666
February 17th, 2003, 08:25 AM
Originally posted by CBasicNet
You have just indirectly reminded me that before I made my own website, I had better learn some PhotoShop first, else CodeGuru will see more of my ascii art in the 'Testing Area'.:p :D
What do you mean with this? That the layout sucks? Well, it is under construction you know.
CBasicNet
February 17th, 2003, 08:31 AM
Originally posted by Simon666
What do you mean with this? That the layout sucks? Well, it is under construction you know.
What are you talking?:confused:
How am I to have visited your website when I do not have the URL in the first place?
Obviously, I'm not talking about your website.:D ;)
Simon666
February 17th, 2003, 08:38 AM
Originally posted by CBasicNet
What are you talking?:confused:
I was wondering what you are talking about? Ascii art <-> PhotoShop and websites, the relation is not quite clear to me. :confused: As for my website, you can see the link in my profile. ;)
CBasicNet
February 17th, 2003, 08:43 AM
Originally posted by Simon666
I was wondering what you are talking about? Ascii art <-> PhotoShop and websites, the relation is not quite clear to me. :confused: As for my website, you can see the link in my profile. ;)
Originally posted by CBasicNet
It's a joke by me, about me.
I suspected that was what you meant with ascii art (I posted in that thread you know), but the relation with websites is still not clear yet. Probably just a misunderstanding. :rolleyes: :o
CBasicNet
February 17th, 2003, 08:54 AM
Originally posted by Simon666
I suspected that was what you meant with ascii art (I posted in that thread you know), but the relation with websites is still not clear yet. Probably just a misunderstanding. :rolleyes: :o
Yea, it is a misunderstanding.
Well you see, I intended to use a graphics s/w to draw those squares but I did not know how to use any. That's why I resorted to ..........
I'm saying the same thing may happen to my webpages.
Get the joke now?:p
Simon666
February 17th, 2003, 09:02 AM
Originally posted by CBasicNet
Well you see, I intended to use a graphics s/w to draw those squares but I did not know how to use any. That's why I resorted to ..........
I'm saying the same thing may happen to my webpages.
Get the joke now?:p
Yep. By the way, do you have a webpage?
CBasicNet
February 17th, 2003, 09:07 AM
No.
kisore
September 18th, 2003, 11:34 AM
i need to print this out
let see
//Addition and Division
//adddiv.cpp
#include <iostream.h>
#include<iomanip.h>
int main ()
{
int
num, add, div, reminder;
double
d;
cout << "Supply a number." <<"\n";
cin>>num;
add=num+2;
div=num/2;
reminder=num%2;
cout << num << " plus 2 is "<< add <<"\n";
cout << num << " divided by 2 is "<< div <<"\n";
cout << "The reminder is " << reminder << endl;
return 0;
}
Yves M
September 22nd, 2003, 12:01 PM
Nicer like this ;)
//Addition and Division
//adddiv.cpp
#include <iostream.h>
#include<iomanip.h>
int main ()
{
int
num, add, div, reminder;
double
d;
cout << "Supply a number." <<"\n";
cin>>num;
add=num+2;
div=num/2;
reminder=num%2;
cout << num << " plus 2 is "<< add <<"\n";
cout << num << " divided by 2 is "<< div <<"\n";
cout << "The reminder is " << reminder << endl;
return 0;
}
Simon666
September 22nd, 2003, 12:07 PM
Or like this
//Addition and Division
//adddiv.cpp
#include <iostream.h>
#include<iomanip.h>
int main ()
{
int
num, add, div, reminder;
double
d;
cout << "Supply a number." <<"\n";
cin>>num;
add=num+2;
div=num/2;
reminder=num%2;
cout << num << " plus 2 is "<< add <<"\n";
cout << num << " divided by 2 is "<< div <<"\n";
cout << "The reminder is " << reminder << endl;
return 0;
}
SolarFlare
September 22nd, 2003, 04:31 PM
Or like this
//Addition and Division
//adddiv.cpp
#include <iostream.h>
#include<iomanip.h>
int main ()
{
int
num, add, div, remainder;
double
d;
cout << "Supply a number." <<"\n";
cin>>num;
add=num+2;
div=num/2;
remainder=num%2;
cout << num << " plus 2 is "<< add <<"\n";
cout << num << " divided by 2 is "<< div <<"\n";
cout << "The remainder is " << remainder << endl;
return 0;
}
Simon666
September 23rd, 2003, 03:01 AM
Or like this:
//Addition and Division
//adddiv.cpp
#include <iostream.h>
#include<iomanip.h>
int main ()
{
int
num, add, div, remainder;
double
d;
cout << "Supply a number." <<"\n";
cin>>num;
add=num+2;
div=num/2;
remainder=num%2;
cout << num << " plus 2 is "<< add <<"\n";
cout << num << " divided by 2 is "<< div <<"\n";
cout << "The remainder is " << remainder << endl;
return 0;
}
Okay, I admit, maybe this last one is just a liiiittttllleee bit over the top. :D
Andreas Masur
September 23rd, 2003, 03:33 AM
Originally posted by Simon666
Okay, I admit, maybe this last one is just a liiiittttllleee bit over the top. :D
Naa...I would not say so.... :cool:
Mick
September 23rd, 2003, 04:23 AM
Originally posted by Andreas Masur
Naa...I would not say so.... :cool:
you know, and andy you get my reply on this just cause you were last :) I don't need to see your colors guys/gals, your code and what it does is more than suffices...
Yves M
October 4th, 2003, 03:16 PM
Just bumping the thread, since I uploaded an updated version of the Syntax Highlighter. It now handles static_cast and #include correctly, moreover your taskbar can be anywhere on the screen and it's still usable.
Sam Hobbs
October 4th, 2003, 06:30 PM
Originally posted by Yves M
I uploaded an updated version of the Syntax Highlighter.So the "[Last updated on the 4.11.2003]" is not accurate?
Sam Hobbs
October 4th, 2003, 06:37 PM
When I click on the link for the latest executable, I get a page in another language (French?) saying something I don't understand and then I am redirected to a page with pictures.
Yves M
October 4th, 2003, 07:32 PM
Arg, Lycos has changed their policy and doesn't allow direct downloads anymore. I'll put it into HTML, give me a few minutes.
[edit: done]
So the "[Last updated on the 4.11.2003]" is not accurate?
It should be october indeed.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.