Welcome Guest.   Make a donation to an author on the site October 22, 2014, 10:56:47 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the Practical Guide to DonationCoder.com Forum Search Features
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: New code syntax highlighting and tab entering with line numbers  (Read 17232 times)
mouser
First Author
Administrator
*****
Posts: 33,578



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« 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]
  1. //echo 'our_parent_boards = ' . $our_parent_boards . '<br/>';
  2. if (isset($our_parent_boards))
  3. {
  4. $our_parent_boards = array_keys($our_parent_boards);
  5. if ($ID_BOARD == 77 || in_array(77,$our_parent_boards))
  6. $formcapturetabs = true;
  7. }

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
Charter Member
***
Posts: 117



View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: May 18, 2006, 06:55:57 AM »

Formatted for C# with the GeSHI Syntax Highlighter [copy or print]
  1. using System;
  2.  
  3. namespace bleh {
  4. class program {
  5. static void Main() {
  6. string message = "testing";
  7. char[] letters = message.ToCharArray();
  8. letters[0] = char.ToUpper(letters[0]);
  9. Console.WriteLine(message);
  10. }
  11. }
  12. }

Testing

Very nice mouser, far better than the original {code] tags...

smiley
« 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
First Author
Administrator
*****
Posts: 33,578



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« 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
That scary taskbar girl
Global Moderator
*****
Posts: 5,270



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: May 18, 2006, 08:43:23 AM »

Formatted for Delphi with the GeSHI Syntax Highlighter [copy or print]
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.  Windows, Classes, Forms, Dialogs, MmSystem, Controls, StdCtrls;
  7.  
  8. type
  9.  TForm1 = class(TForm)
  10.    Button1: TButton;
  11.    procedure Button1Click(Sender: TObject);
  12.  private
  13.    { Private declarations }
  14.  public
  15.    { Public declarations }
  16.  end;
  17.  
  18. var
  19.  Form1: TForm1;
  20.  
  21. implementation
  22.  
  23. {$R *.DFM}
  24.  
  25. procedure TForm1.Button1Click(Sender: TObject);
  26. begin
  27. PlaySound('tada.wav',0,SND_FILENAME);
  28. end;
  29.  
  30. end.
Logged

taichimaster
Charter Member
***
Posts: 159



View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: May 18, 2006, 01:00:26 PM »

Formatted for Python with the GeSHI Syntax Highlighter [copy or print]
  1. import wx
  2. class Form1(wx.Panel):
  3.        def __init__(self, parent, id):
  4.        wx.Panel.__init__(self, parent, id)
  5.        self.quote = wx.StaticText(self, -1, "Your quote :",wx.Point(20, 30))
  6.  
  7. app = wx.PySimpleApp()
  8. frame = wx.Frame(None, -1, " Our first Control")
  9. Form1(frame,-1)
  10. frame.Show(1)
  11. app.MainLoop()

Nice add mouser!
Logged

jgpaiva
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« 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]
  1. (defun min-search (estado alfa beta peca pecaOposta limite profundidade)
  2.  (cond ((tempo) (cons +infinito1 nil))
  3. ((= 0 limite) (cons (estado-utilidade estado profundidade peca) estado))
  4. (t
  5. (let ((best (gera-estados estado)))
  6.   (do ((nextEstado best (gera-estados estado)))
  7.       ((not nextEstado))
  8.     (let ((temp (max-search nextEstado alfa beta
  9. pecaOposta peca
  10. (1- limite) (1+ profundidade))))
  11.       (if (< (car temp) beta)
  12.   (setf best nextEstado beta (car temp)))
  13.       (when (>= alfa beta)          ;corte beta  
  14.   (if (= -infinito1 beta)    
  15.       (setf beta +infinito1))
  16.   (return))))
  17.   (cons beta best)))))

(actually, right now, i'm not too mad at it, it didn't fail me Wink )
« Last Edit: May 18, 2006, 01:31:44 PM by jgpaiva » Logged

f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: May 18, 2006, 02:05:26 PM »

Let's see...

Formatted for C++ with the GeSHI Syntax Highlighter [copy or print]
  1. #pragma pack(push, 1)
  2. struct FileHeader
  3. {
  4. char signature[8]; // header_v1_signature
  5. char hash[sha256::hashbits/8]; // plaintext hash
  6. char iv[aes_blocksize]; // initial encryption vector (added in v2)
  7. unsigned size; // size of data, padded to crypt blocksize
  8. unsigned realsize; // "real" size of data, unpadded
  9. unsigned flags; // bitmask of FL_* constants
  10. unsigned w, h; // saved width and height... mouser wants this
  11. };
  12. #pragma pack(pop)

EDIT: would be nice if you could specify tabs-are-X-spaces setting...
Logged

- carpe noctem
allen
Charter Member
***
Posts: 1,173



Powered by Beard

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« 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 smiley -- 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]
  1. if  ( !in_array("regex",$syntaxSchemes) ) {
  2.  echo "It's beautiful, but where's the regex love?";
  3.  # OK, so it's not a language unto itself
  4.  # Using EditPad has taught me that regex
  5.  # sans syntax highlighting is lame.
  6.  # I'm spoiled.
  7. }
Logged
mouser
First Author
Administrator
*****
Posts: 33,578



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« 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
Charter Member
***
Posts: 1,173



Powered by Beard

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« 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
First Author
Administrator
*****
Posts: 33,578



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #10 on: May 18, 2006, 04:00:24 PM »

smiley
Logged
okkoos
Participant
*
Posts: 1

View Profile Give some DonationCredits to this forum member
« 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]
  1. procedure RegisterFileType(FileExt: string; exepfad: string);
  2. var
  3.  Registry: TRegistry;
  4. begin
  5.  Registry := TRegistry.Create;
  6.  with Registry do
  7.  begin
  8.  try
  9.    RootKey := HKEY_CLASSES_ROOT;
  10.    //create a new key  --> .pci
  11.    OpenKey('.' + FileExt, True);
  12.    try
  13.      //create a new value for this key --> pcifile
  14.      Writestring('', FileExt + 'file');
  15.    finally
  16.      CloseKey;
  17.    end;
  18.    //create a new key --> pcifile
  19.    CreateKey(FileExt + 'file');
  20.    //create a new key pcifile\DefaultIcon
  21.    OpenKey(FileExt + 'file\DefaultIcon', True);
  22.    //and create a value where the icon is stored --> c:\project1.exe,0
  23.    try
  24.      Writestring('', exepfad + ',0');
  25.    finally
  26.      CloseKey;
  27.    end;
  28.    OpenKey(FileExt + 'file\shell\open\command', True);
  29.    //create value where exefile is stored --> c:\project1.exe "%1"
  30.    try
  31.      Writestring('', exepfad + ' "%1"');
  32.    finally
  33.      CloseKey;
  34.    end;
  35.  finally
  36.    Free;
  37.  end;
  38.  end;
  39.  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
  40. 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
Member
**
Posts: 2,374


see users location on a map View Profile Give some DonationCredits to this forum member
« 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
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« 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
Global Moderator
*****
Posts: 4,710



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #14 on: January 07, 2008, 04:39:57 AM »

I recommend trying with a standards-compliant browser. It works just as it should Wink
Logged

SleepingWolf
Supporting Member
**
Posts: 104


see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« 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
Charter Member
***
Posts: 6,418



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« 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
Honorary Member
**
Posts: 2,479



View Profile Give some DonationCredits to this forum member
« Reply #17 on: March 16, 2009, 06:59:20 PM »

I appreciate having the syntax-highlighting functionality  Thmbsup

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
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.251s | Server load: 0.1 ]