Well this is on hold until they get this stuff stable. The newest package I made for testing purposes for no good reason has made Firefox un-openable. Not even re-isntalls help and there is no information on exactly where this stuff gets stored when a package is installed, so screw it for now until they get some proper information circulating.
That might be helpful. Its not completely dead in the water, the project, im just waiting for a little more about the changes to come out and make sure they dont make any more huge changes real soon wit hthe problems they are having with the .9 versions.
I have worked on the python thingy for a long time now. And suddenly I realised it is a bug in the code and not my RegEx. Everytime the setLanguage(...) function fires, the "key" array has to be emptied. If not there will be a problem.
I.E, you first heighlight something with C++, then try to heilight something with Java, then the Java will be heilighted with C++ heighlighting.
I am not sure what the right way to empty an array is. But as a work around I have now added an extra keys = new Array(); inside the setLanguage function before the switch. Do anyone know about a better way? Or if this is OK JS?
I have tried a lot of things the last two hours to be able to check where the function declarations are. They look like this:
def main():
so I have to search for def, but not include it, and ( but not include it. And a valid RegEx for this is:
(?<=def\s)\w+(?=\()
but JS won't listen. So I wil ahve a look at it again next week. Except taht everything is working for Python heiglighting too now. And fixed a couple of small buggs here and there. but still not sure about the easiest and safest way to reset an array.
So this is the current version of the extension. Nothing Neb has done the two last days are in it. So hope you can add it to this version. All the files are on the server too.
OK...I think I have a solution. But I need some help from you. Because the function:
function colorCode(f,language)
is a bit messy.....
If I use a regular expression to fetch:
def main
Then I guess I can later on strip out "def ", can't I? But if so how? Where is the fetch actualy stored? And is it an index that is stored? Or the actual text? I guess it is an index. But I can't get that to work...hmmmm...any insight help.
I think my problem is that I don't understand the keys structure you have made. Can you elaborte a bit on it.
Is it something like this.
- keys (array of structs?)
member variables:
- color
- bold
- italic
- name
but where is the actual information stored? And is it stored as an index or the word it self. I need to manipulate it. But I fail too see how it stores it.
Well, I still can't see if you are actualy declearing keys anywhere, or if you even have to do that in JS, but I managed to make it work anyway.....this brings a new feauture to the color heiglighting. We now have the code and the RegEx to heiglight funciton declerations..:....just look how pretty it is...
Code:
#Hello mother
def _ma5in_():
if len(sys.argv) < 1:
usage() #Yeah thats your mother all right
else:
kek_number_list = tidy_up_file(sys.argv[1])
if kek_number_list != -1:
download_pdf(kek_number_list)
#Poo is a country
Here is the new and updated XPI.
BTW Cander, what editor are you using. I am in my appartment now, and now the code looks much better then in Emacs. But I still think you should be kicked in the ass for writing lines like this:
Code:
for (var i = 0; i != keys.length; ++i) keys[i].startPos = -1;
and this too...
Code:
for (var i = 1; i < keys.length; ++i) // find first matching key
if (keys[i].startPos < keys[match].startPos) match = i;
if (keys[match].end != undefined) { // end must be found
var end = new RegExp(keys[match].end.source + "|" + keys[match].neglect.source, "mg");
end.lastIndex = keys[match].endPos;
while (keys[match].endPos != s.length)
Version 0.2.6 is now on the server. Use FTP or IE to download it.
As a note. If we are going to get tabs on smilies I guess we have to put the menu toolbars that we are using now on TOP of a window or something, and then add tabs to the windows rather then the menu toolbar it self.
BTW I can't belive it is soooo hard for different text editors to make the indent look the same in them. It ticks me off that they are not working the same way.
Well, at least we have come a long way though. Even if we havn't cleaned up much.....I don't have any time to work on it today, and probably not tomorrow either. But there is still some things to do, so I'll be back..
Hehehe....are they so big that you need a couple of days off...well well. But just before you go. Can you tell me a bit about the Keys array?
Is it an array of Objects/structs? Is it declared somewhere at all? Or don't you have to do that in JS? I am so confused by what actualy happens when you use pop on that array (stack)...
But that doesn't say anything about how it is laied out. For me it looks like you have one struckt in the array for name, colour, bold and so on, and then I guess there is something more to it. Becasuse the regular expression has to store something to, but how/where/what...hmmm
And it also seems to me that each regular expression only uses ONE "cell" in the array. So does that make it two dimensional, or how is the results for the regex stored?
think of it as CSS where you define a class and its properties (in the case of style being the class and color, bold, etc are the properties. But it placed into an array.
<html>
<body>
var codeme = "#Hello mother def _ma5in_(): if len(sys.argv) < 1: usage() #Yeah thats your mother all right else: kek_number_list = tidy_up_file(sys.argv[1]) if kek_number_list != -1: download_pdf(kek_number_list) #Poo is a country"
<script type="text/javascript">
var keys = new Array()
keys.push({style:{color:"#CC0000", bold:true, italic:false, name:"pythondef"}, start:/\bdef\s\w+(?=\()/mg});
keys.push({style:{color:"#FF6666", bold:false, italic:false, name:"functions2"}, start:/\b\w+(?=\()/mg, neglect:/\sdef\s\w+(?=\()/mg});
keys.push({style:{color:"#009900", bold:false, italic:true, name:"comment"}, start:/\s*\#/mg, end:/\n/mg, neglect:/\\|\?\?\//mg}); //start:/\#[\w\s]*\n/mg});
keys.push({style:{color:"#009900", bold:false, italic:false, name:"comment"}, start:/\s*?^\s*(?:#|\?\?=|%:)/mg, end:/\n/m, neglect:/\\[\s\S]|\?\?\/[\s\S]/m});
keys.push({style:{color:"#3333FF", bold:false, italic:false, name:"keyword"}, start:/\s*\b(?:__name__|def|elif|else|except|file|for|if|import|in|len|open|print|return|str|try)\b/mg});
keys.push({style:{color:"#000000", bold:true, italic:false, name:"operator"}, start:/:/mg});
keys.push({style:{color:"#CC9933", bold:false, italic:false, name:"string"}, start:/\s*(?:\bL)?"/mg, end:/"/m, neglect:/\\[\s\S]|\?\?\/[\s\S]/m});
keys.push({style:{color:"#CC9933", bold:false, italic:false, name:"char"}, start:/\s*(?:\bL)?'/mg, end:/'/m, neglect:/\\[\s\S]|\?\?\/[\s\S]/m});
keys.push({style:{color:"#993399", bold:false, italic:false, name:"int"}, start:/\s*\b(?:0[0-7]*|[1-9]\d*|0x[\dA-F]+)(?:UL?|LU?)?\b/mgi});
for (i=0; i<famname.length; i++)
{
document.write(keys[i] + "<br>")
}
</script>
</body>
</html>
What do I have to edit where I have heiglighted now to get what is inside the array if you look away from the color, bold, name, italic? What does the regular expression store, and where..
think of it as CSS where you define a class and its properties (in the case of style being the class and color, bold, etc are the properties. But it placed into an array.
Get it?
Yeah I get that. But is what the RegEx returned also a property? If so what is it called? How do I get it out..
Ohhh...I might start to understand now....it often helps to ask stupid questions for me..
The RegEx isn't executed on that line? Is that it? Ahha...it only STORES the reg ex on that line. The actual reg ex is called in that other function? And then it stores the startPos then. That has NOTHING to do with that line at all...grrrr....*smacks my head in the wall*.....
I really thought it was executing the RegEx THERE, since it is not in the {color, bold, italic, name} array at all, but outside it..
Ok, last question about it. On lines like this (I can't say how much I hate one line braching though..):
Code:
if (keys[i].style.bold) keys[i].before += "[b]";
the before "property", that is a property right? I can't find any method called that. but the werid thing is that there was no property called that when you started the array. So I guess you can add properties too then? Like Before/After/StartPos?
So I also guess that the array in JS is not actualy an array, but some advanced List that can expand over time? ?
Just answer this, and I will go home from work and do nothing else then smack my head for the rest of the day..
OK. I totaly got it now. I can even see why my python thingy worked now in the end....It wasn't weird I used a lot of time to try to move the startPos 4 places forward when I thought it was executed in the big Case test function.
Well I have a vague idea on how to colour import modules for python too now. Not sure if it is nessesary for other languages. People seldom need it in C++, except if they insist to write the whole name for namespaces and so on.
std::cout
Will try one day when I have the time. Guess I need an other array to remember the import modules, and then color every occourence of them in some way.
Thanks for your help. Your code doesn't look THAT sloppy now...
Greg Snooks law:
Note: For every coder, there is a coder that doesn't like his coding style.