PB Forum Color Quote Formatter

Developed or developing a new product in PureBasic? Tell the world about it.
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

PB Forum Color Quote Formatter

Post by JCV »

This will make our code that we post more readable and easier to read.
See the sourcecode below and thats the sample output. :wink:

How to use:
-Download http://purebasic.jcvsite.com/v4/Forum_Quote_Code.zip
-Extract to your PB folder (ex ../Purebasic/plugins/) or jaPBe plugins folder
-Add it to Tools Menu in your PB
-Just highlight your code and press-c to copy to clipboard and open "Forum Quote.exe" or from your Tools/plugins in IDE


Sample output - (Sourcecode) This is included in the zip archive.
Enumeration
  #SYNTAX_Text
  #SYNTAX_Keyword
  #SYNTAX_Comment
  #SYNTAX_Constant
  #SYNTAX_String
  #SYNTAX_Function
  #SYNTAX_Asm
  #SYNTAX_Operator
  #SYNTAX_Structure
  #SYNTAX_Number
  #SYNTAX_Pointer
  #SYNTAX_Separator
  #SYNTAX_Label
EndEnumeration

#Dll = 0
Global highlighted.s

Procedure CallbackHighlight(*Position, length, color)
  place.= PeekS(*Position, length, #PB_UTF8)
  place = ReplaceString(place, " ", " ")
  If Len(place)>0
    Select color
      Case #SYNTAX_Text
        highlighted + Chr(91) + "color=#0000FF" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93)
      Case #SYNTAX_Keyword
        highlighted + Chr(91) + "b" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/b" + Chr(93)
      Case #SYNTAX_Comment
        highlighted + Chr(91) + "color=#008000" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93)
      Case #SYNTAX_Constant
        highlighted + Chr(91) + "color=#924B72" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93)
      Case #SYNTAX_String
        highlighted + Chr(91) + "color=#800080" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93)
      Case #SYNTAX_Function
        highlighted + Chr(91) + "color=#006666" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93)
      Case #SYNTAX_Asm
        highlighted + Chr(91) + "color=#800000" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93)
      Case #SYNTAX_Structure
        highlighted + Chr(91) + "b" + Chr(93) + Chr(91) + "color=#59017E" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93) + Chr(91) + "/b" + Chr(93)
      Case #SYNTAX_Number
        highlighted + Chr(91) + "i" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/i" + Chr(93)
      Case #SYNTAX_Pointer
        highlighted + Chr(91) + "color=#003264" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93)
      Case #SYNTAX_Label
        highlighted + Chr(91) + "b" + Chr(93) + Chr(91) + "color=#5A5AAD" + Chr(93)
        highlighted + place
        highlighted + Chr(91) + "/color" + Chr(93) + Chr(91) + "b" + Chr(93)
        
      Default
        highlighted + place
    EndSelect
  EndIf
EndProcedure

If OpenLibrary(#Dll, "SyntaxHilighting.dll")
  
  SelectedText.= GetClipboardText()
  Length = Len(SelectedText)
  *Buffer = AllocateMemory(Length + 1)
  PokeS(*Buffer, SelectedText, Length, #PB_UTF8)
  
  If *Buffer
    ClearClipboard()
    highlighted = Chr(91) + "quote" + Chr(93)
    CallFunction(#Dll, "SyntaxHighlight", *Buffer, Length, @CallbackHighlight(), 0)
    highlighted + Chr(91) + "/quote" + Chr(93)
    SetClipboardText(highlighted)
    MessageRequester("Forum Quote", "Code ready to paste in the forum!")
  EndIf
  
  CloseLibrary(#Dll)
EndIf
Last edited by JCV on Thu Sep 04, 2008 5:27 am, edited 1 time in total.
dige
Addict
Addict
Posts: 1406
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

Sounds good to me!
DevilDog
Enthusiast
Enthusiast
Posts: 210
Joined: Thu Aug 04, 2005 9:32 pm
Location: Houston, Tx.

Post by DevilDog »

JCV,
That's cool!

Question: Where can I get more information on interacting with JaPBe?

Devildog
When all is said and done, more is said than done.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Hi JCV,

Thanks for the tool. Could you possibly make a version for the good old PureBasic editor? I am so used to it that I can't quit for any other editor :).
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

I updated the tool and much simpler.
Just highlight your sourcecode and press-c to copy to clipboard then call the tool and paste it here in forum. You can add shortcut to your PB IDE tools or as jaPBe plugin.

Image

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Who's going to pay for all the extra bandwidth that this brings? :roll:
Fred
Administrator
Administrator
Posts: 18237
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

PB wrote:Who's going to pay for all the extra bandwidth that this brings? :roll:
Such remarks are out of context here..
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Such remarks are out of context here

:?: It wasn't meant as a personal attack or anything. You're the one who has
to pay for the bandwidth, so I just highlighting the fact that using such a tool
would be adding to your costs, and not to anyone else's.
Fred
Administrator
Administrator
Posts: 18237
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Sure, and we will handle it if we run into problems, no need to worry ;)
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Who the heck wants to abuse his browser as a programming IDE? What's the point? It costs more bandwidth but more importantly it increases loading times of large codes!
Last edited by Fluid Byte on Thu Sep 04, 2008 2:23 pm, edited 1 time in total.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

Sourcecodes posted are usually in Kilobytes only. imho images posted like hoff for example uses more bandwidth. It just makes the code posted more readable.

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Keep in mind though that not everyone may agree with your choise of colors ;)
quidquid Latine dictum sit altum videtur
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

JCV wrote:Sourcecodes posted are usually in Kilobytes only. imho images posted like hoff for example uses more bandwidth. It just makes the code posted more readable.
Well, you have to admit that this is a programmers forum and not a Hasselhoff fan board so it's likely that ....

Hey, wait a second! That's actually not true ...

Image
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

aktuly, I miss the monospace font in such quotes.
nothing against some highlighting, but monospacing is important for me.

some server-sited sytax-highlighting in the native IDE colors would perhaps be nice...
oh... and have a nice day.
Post Reply