Page 1 of 1

PB Forum Color Quote Formatter

Posted: Tue Jul 24, 2007 2:07 am
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

Posted: Tue Jul 24, 2007 9:17 am
by dige
Sounds good to me!

Posted: Fri Sep 28, 2007 7:02 pm
by DevilDog
JCV,
That's cool!

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

Devildog

Posted: Sat Sep 29, 2007 12:26 pm
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 :).

Posted: Thu Sep 04, 2008 5:30 am
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

Posted: Thu Sep 04, 2008 11:26 am
by PB
Who's going to pay for all the extra bandwidth that this brings? :roll:

Posted: Thu Sep 04, 2008 12:57 pm
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..

Posted: Thu Sep 04, 2008 2:01 pm
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.

Posted: Thu Sep 04, 2008 2:16 pm
by Fred
Sure, and we will handle it if we run into problems, no need to worry ;)

Posted: Thu Sep 04, 2008 2:22 pm
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!

Posted: Thu Sep 04, 2008 3:01 pm
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.

Posted: Thu Sep 04, 2008 3:35 pm
by freak
Keep in mind though that not everyone may agree with your choise of colors ;)

Posted: Thu Sep 04, 2008 7:19 pm
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

Posted: Thu Sep 04, 2008 7:57 pm
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...