|
mouser
|
 |
« on: May 18, 2006, 06:36:51 AM » |
|
I just added a new code highlighting mode using geshi ( http://qbnz.com/highlighter/). Let's try it here: Formatted for PHP with the GeSHI Syntax Highlighter [ copy or print] //echo 'our_parent_boards = ' . $our_parent_boards . '<br/>'; if (isset($our_parent_boards)) { $our_parent_boards = array_keys($our_parent_boards); if ($ID_BOARD == 77 || in_array(77,$our_parent_boards)) $formcapturetabs = true; }
sweet - now we have line numbers. Note you should also now be able to type TABS now in the form post textarea when in the Programming School sections of the forum (tested with IE, not sure about ff and others), which should make it easier to post code.
|
|
|
|
« Last Edit: May 18, 2006, 10:51:21 AM by mouser »
|
Logged
|
|
|
|
|
PhilKC
|
 |
« Reply #1 on: May 18, 2006, 06:55:57 AM » |
|
Formatted for C# with the GeSHI Syntax Highlighter [ copy or print] using System; namespace bleh { class program { static void Main() { string message = "testing"; char[] letters = message.ToCharArray(); letters[0] = char.ToUpper(letters[0]); Console.WriteLine(message); } } }
Testing Very nice mouser, far better than the original {code] tags... 
|
|
|
|
« Last Edit: May 18, 2006, 06:58:01 AM by PhilKC »
|
Logged
|
It's not a bug, it's an undocumented and unexplainable feature. Stick it on your site: 
|
|
|
|
mouser
|
 |
« Reply #2 on: May 18, 2006, 07:44:16 AM » |
|
note you can select languages from the drop down code highlighting box available on post form.
note also that php functions are hyperlinked to php documentation.
|
|
|
|
|
Logged
|
|
|
|
|
|
app103
|
 |
« Reply #3 on: May 18, 2006, 08:43:23 AM » |
|
Formatted for Delphi with the GeSHI Syntax Highlighter [ copy or print] unit Unit1; interface uses Windows, Classes, Forms, Dialogs, MmSystem, Controls, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin PlaySound('tada.wav',0,SND_FILENAME); end; end.
|
|
|
|
|
Logged
|
|
|
|
|
taichimaster
|
 |
« Reply #4 on: May 18, 2006, 01:00:26 PM » |
|
Formatted for Python with the GeSHI Syntax Highlighter [ copy or print] import wx class Form1(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) self.quote = wx.StaticText(self, -1, "Your quote :",wx.Point(20, 30)) app = wx.PySimpleApp() frame = wx.Frame(None, -1, " Our first Control") Form1(frame,-1) frame.Show(1) app.MainLoop()
Nice add mouser!
|
|
|
|
|
Logged
|
|
|
|
|
jgpaiva
|
 |
« Reply #5 on: May 18, 2006, 01:30:04 PM » |
|
Here's my contribution, with the worst language ever made: Formatted for Lisp with the GeSHI Syntax Highlighter [ copy or print] (defun min-search (estado alfa beta peca pecaOposta limite profundidade) (cond ((tempo) (cons +infinito1 nil)) ((= 0 limite) (cons (estado-utilidade estado profundidade peca) estado)) (t (let ((best (gera-estados estado))) (do ((nextEstado best (gera-estados estado))) ((not nextEstado)) (let ((temp (max-search nextEstado alfa beta pecaOposta peca (1- limite) (1+ profundidade)))) (if (< (car temp) beta) (setf best nextEstado beta (car temp))) (when (>= alfa beta) ;corte beta (if (= -infinito1 beta) (setf beta +infinito1)) (return)))) (cons beta best)))))
(actually, right now, i'm not too mad at it, it didn't fail me  )
|
|
|
|
« Last Edit: May 18, 2006, 01:31:44 PM by jgpaiva »
|
Logged
|
|
|
|
|
f0dder
|
 |
« Reply #6 on: May 18, 2006, 02:05:26 PM » |
|
Let's see... Formatted for C++ with the GeSHI Syntax Highlighter [ copy or print] #pragma pack(push, 1) struct FileHeader { char signature[8]; // header_v1_signature char hash[sha256::hashbits/8]; // plaintext hash char iv[aes_blocksize]; // initial encryption vector (added in v2) unsigned size; // size of data, padded to crypt blocksize unsigned realsize; // "real" size of data, unpadded unsigned flags; // bitmask of FL_* constants unsigned w, h; // saved width and height... mouser wants this }; #pragma pack(pop)
EDIT: would be nice if you could specify tabs-are-X-spaces setting...
|
|
|
|
|
Logged
|
 - carpe noctem
|
|
|
|
allen
|
 |
« Reply #7 on: May 18, 2006, 03:42:49 PM » |
|
Tabs are x spaces would be nice . . . convert tabs to spaces would also be nice, while we're trying to recreate my text editor  -- This is beautiful, I'm going to have to post some code just for the sake of using it. Formatted for PHP with the GeSHI Syntax Highlighter [ copy or print] if ( !in_array("regex",$syntaxSchemes) ) { echo "It's beautiful, but where's the regex love?"; # OK, so it's not a language unto itself # Using EditPad has taught me that regex # sans syntax highlighting is lame. # I'm spoiled. }
|
|
|
|
|
Logged
|
|
|
|
|
mouser
|
 |
« Reply #8 on: May 18, 2006, 03:48:02 PM » |
|
there's a very cool site for regular expression coloring and find+replace.. i think it's http://rereplace.com/
|
|
|
|
|
Logged
|
|
|
|
|
allen
|
 |
« Reply #9 on: May 18, 2006, 03:59:53 PM » |
|
Ha. That's match highlighting, not syntax -- the author is allegedly anti-ajax, and therefor unwilling to dynamically color the syntax as you type it. I doubt he'd be clever enough to implement it anyway.
|
|
|
|
|
Logged
|
|
|
|
|
mouser
|
 |
« Reply #10 on: May 18, 2006, 04:00:24 PM » |
|
|
|
|
|
|
Logged
|
|
|
|
|
okkoos
|
 |
« Reply #11 on: January 06, 2008, 04:46:27 PM » |
|
Hi GeSHi is a best syntax higlighting script for SMF forums. but a litte bug get in, GeSHi. when add a any programming language code snippets to SMF forum highligh with GeSHi, is best viewing on Forum like following Formatted for Delphi with the GeSHI Syntax Highlighter [ copy or print] procedure RegisterFileType(FileExt: string; exepfad: string); var Registry: TRegistry; begin Registry := TRegistry.Create; with Registry do begin try RootKey := HKEY_CLASSES_ROOT; //create a new key --> .pci OpenKey('.' + FileExt, True); try //create a new value for this key --> pcifile Writestring('', FileExt + 'file'); finally CloseKey; end; //create a new key --> pcifile CreateKey(FileExt + 'file'); //create a new key pcifile\DefaultIcon OpenKey(FileExt + 'file\DefaultIcon', True); //and create a value where the icon is stored --> c:\project1.exe,0 try Writestring('', exepfad + ',0'); finally CloseKey; end; OpenKey(FileExt + 'file\shell\open\command', True); //create value where exefile is stored --> c:\project1.exe "%1" try Writestring('', exepfad + ' "%1"'); finally CloseKey; end; finally Free; end; end; SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil); end;
but when copy snippet from SMF forum and paste any text editor, is only one line. like following [ copy or print] procedure RegisterFileType(FileExt: string; exepfad: string);var Registry: TRegistry;begin Registry := TRegistry.Create; with Registry do begin try RootKey := HKEY_CLASSES_ROOT; //create a new key --> .pci OpenKey('.' + FileExt, True); try //create a new value for this key --> pcifile Writestring('', FileExt + 'file'); finally CloseKey; end; //create a new key --> pcifile CreateKey(FileExt + 'file'); //create a new key pcifile\DefaultIcon OpenKey(FileExt + 'file\DefaultIcon', True); //and create a value where the icon is stored --> c:\project1.exe,0 try Writestring('', exepfad + ',0'); finally CloseKey; end; OpenKey(FileExt + 'file\shell\open\command', True); //create value where exefile is stored --> c:\project1.exe "%1" try Writestring('', exepfad + ' "%1"'); finally CloseKey; end; finally Free; end; end; SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);end; Can anyone fix this bug in GeSHi script and share it this topic? Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Lashiec
|
 |
« Reply #12 on: January 06, 2008, 08:44:32 PM » |
|
For the record, I just tested it, and seems to occur only in Internet Explorer.
|
|
|
|
|
Logged
|
|
|
|
|
f0dder
|
 |
« Reply #13 on: January 06, 2008, 08:50:12 PM » |
|
With FireFox I get it properly as multiple lines... but I get the line numbers copied as well.
|
|
|
|
|
Logged
|
 - carpe noctem
|
|
|
|
jgpaiva
|
 |
« Reply #14 on: January 07, 2008, 04:39:57 AM » |
|
I recommend trying with a standards-compliant browser. It works just as it should 
|
|
|
|
|
Logged
|
|
|
|
|
SleepingWolf
|
 |
« Reply #15 on: March 01, 2009, 09:13:52 AM » |
|
Forgive my ignorance please, 3 simple questions (I hope!):
1) Why would you want line numbers which complicate cut and paste testing? Can you strip them easily when cutting? (Without starting Excel or other tools? 2) How do I paste code using this system? Is there a tutorial/ FAQ? 3) The general gist of your posts so far is that you would type the code untested into your posts? Or am I mistaken?
Thanks in advance.
|
|
|
|
|
Logged
|
-------------------------------------------
Choose life -or at least respect it.
|
|
|
|
Deozaan
|
 |
« Reply #16 on: March 16, 2009, 06:54:51 PM » |
|
Forgive my ignorance please, 3 simple questions (I hope!):
1) Why would you want line numbers which complicate cut and paste testing? Can you strip them easily when cutting? (Without starting Excel or other tools? 2) How do I paste code using this system? Is there a tutorial/ FAQ? 3) The general gist of your posts so far is that you would type the code untested into your posts? Or am I mistaken?
Thanks in advance.
1) Did you attempt to copy any of the code? The line numbers are not selected when you highlight the text. Line numbers are very useful when referring to code and also help you see whether it's a wordwrap or a hard return in the middle of quoted code. 2) When you make a post, simply click the "Code Highlighting" drop down box and select the programming language you want to highlight for. It will put some stuff in the body of the message. Paste all your code within the tags. 3) I believe that the general gist of the post is that since parts of this site talk about code, it's nice to be able to paste code for others to use. Usually it's tested, but not always. It's not like the code is executed or anything just for being posted into a thread.
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #17 on: March 16, 2009, 06:59:20 PM » |
|
I appreciate having the syntax-highlighting functionality  I find that it helps me greatly w.r.t. readability -- among other places, I use it for the Programming School assignments (and it is also nice when looking over other folks' submissions).
|
|
|
|
|
Logged
|
|
|
|
|