GoScintilla - 2.7 (Purebasic 4.5 onwards)

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

Private Message ;)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by srod »

Fixed. Look out for GoScintilla 2.3.

Thanks for the report and example code.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by srod »

GoScintilla 2.3 - 4th Apr 2011

GoScintilla 2.3 fixes a bug with GOSCI_InsertLineOfText(). Thanks to Dobro.

Please see the nxSoftware site for the download.
I may look like a mule, but I'm not a complete ass.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

it works!
Thanks to U !! :D
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

hello Srod :)

for, all Folding
you have given this code:

Code: Select all

 IncludePath "..\..\"
 XIncludeFile "GoScintilla.pbi"

  CompilerIf  #PB_Compiler_OS = #PB_OS_Windows
    InitScintilla()
  CompilerEndIf

If OpenWindow(0, 100, 200, 600, 600, "GoScintilla demo!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  RemoveKeyboardShortcut(0, #PB_Shortcut_Tab) ;Required for the tab key to function correctly when the Scintilla control has the focus.

    GOSCI_Create(1, 10, 40, 580, 550, 0, #GOSCI_AUTOSIZELINENUMBERSMARGIN|#GOSCI_ALLOWCODEFOLDING)
    ButtonGadget(10, 0, 10, 150, 20, "COLLAPSE ALL ITEMS!")
    ButtonGadget(11, 180, 10, 150, 20, "EXPAND ALL ITEMS!")

    GOSCI_SetAttribute(1, #GOSCI_LINENUMBERAUTOSIZEPADDING, 10)

    GOSCI_SetMarginWidth(1, #GOSCI_MARGINFOLDINGSYMBOLS, 24)

    GOSCI_SetColor(1, #GOSCI_CARETLINEBACKCOLOR, $B4FFFF)

    GOSCI_SetFont(1, "Courier New", 10)

    GOSCI_SetTabs(1, 2)

  ;Set styles for our syntax highlighting.
  ;=======================================
      Enumeration
        #STYLES_COMMANDS = 1
        #STYLES_COMMENTS
        #STYLES_LITERALSTRINGS
        #STYLES_NUMBERS
        #STYLES_CONSTANTS
        #STYLES_FUNCTIONS
      EndEnumeration

    ;Set individual styles for commands.
      GOSCI_SetStyleFont(1, #STYLES_COMMANDS, "", -1, #PB_Font_Bold)
      GOSCI_SetStyleColors(1, #STYLES_COMMANDS, $800000)  ;We have omitted the optional back color.

    ;Set individual styles for comments.
      GOSCI_SetStyleFont(1, #STYLES_COMMENTS, "", -1, #PB_Font_Italic)
      GOSCI_SetStyleColors(1, #STYLES_COMMENTS, $006400)  ;We have omitted the optional back color.

    ;Set individual styles for literal strings.
      GOSCI_SetStyleColors(1, #STYLES_LITERALSTRINGS, #Gray)  ;We have omitted the optional back color.

    ;Set individual styles for numbers.
      GOSCI_SetStyleColors(1, #STYLES_NUMBERS, #Red)  ;We have omitted the optional back color.

    ;Set individual styles for constants.
      GOSCI_SetStyleColors(1, #STYLES_CONSTANTS, $2193DE)  ;We have omitted the optional back color.

    ;Set individual styles for functions.
      GOSCI_SetStyleColors(1, #STYLES_FUNCTIONS, #Blue)  ;We have omitted the optional back color.

  ;Set keywords for our syntax highlighting.
  ;=========================================
      GOSCI_AddKeywords(1, "Debug End If ElseIf Else EndIf For To Next Step Protected ProcedureReturn", #STYLES_COMMANDS)
      GOSCI_AddKeywords(1, ";", #STYLES_COMMENTS, #GOSCI_DELIMITTOENDOFLINE)
      GOSCI_AddKeywords(1, Chr(34) + Chr(34), #STYLES_LITERALSTRINGS, #GOSCI_DELIMITBETWEEN)
      GOSCI_AddKeywords(1, "#", #STYLES_CONSTANTS, #GOSCI_LEFTDELIMITWITHOUTWHITESPACE)
      GOSCI_AddKeywords(1, "(", #STYLES_FUNCTIONS, #GOSCI_RIGHTDELIMITWITHWHITESPACE)
      GOSCI_AddKeywords(1, ")", #STYLES_FUNCTIONS)

    ;Add some folding keywords.
      GOSCI_AddKeywords(1, "Procedure Macro", #STYLES_COMMANDS, #GOSCI_OPENFOLDKEYWORD|#GOSCI_DELIMITNONE)
      GOSCI_AddKeywords(1, "EndProcedure EndMacro", #STYLES_COMMANDS, #GOSCI_CLOSEFOLDKEYWORD|#GOSCI_DELIMITNONE)

  ;Additional lexer options.
  ;=========================
      GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_SEPARATORSYMBOLS, @"=+-*/%()[],.") ;You would use GOSCI_AddKeywords() to set a style for some of these if required.
      GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_NUMBERSSTYLEINDEX, #STYLES_NUMBERS)

  ;Set some initial text.
  ;======================
    text$ = "; GoScintilla." + #CRLF$
    text$ + "; By Stephen Rodriguez." + #CRLF$ + #CRLF$
    text$ + "#MyConstant$ = " + Chr(34) + "Version = 1.0" + Chr(34) + #CRLF$ + #CRLF$
    text$ + "Procedure.i AddIntegers(a, b)" + #CRLF$
    text$ + #TAB$ + "Protected result" + #CRLF$
    text$ + #TAB$ + "result = a + b  ; Calculate the sum of the 2 integers." + #CRLF$
    text$ + #TAB$ + "ProcedureReturn result" + #CRLF$
    text$ + "EndProcedure" + #CRLF$ + #CRLF$
    text$ + "Debug " + Chr(34) + "The sum of 10 and 20 is " + Chr(34) + " + Str(AddIntegers(10, 20))" + #CRLF$ + #CRLF$
    text$ + "End" + #CRLF$
   
    GOSCI_SetText(1, text$)
  Repeat
    eventID = WaitWindowEvent()
    Select eventID
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 10 ;Collapse all items.
            For i=0 To ScintillaSendMessage(1, #SCI_GETLINECOUNT)-1
              If ScintillaSendMessage(1, #SCI_GETFOLDLEVEL, i) & #SC_FOLDLEVELHEADERFLAG
                If ScintillaSendMessage(1, #SCI_GETFOLDEXPANDED, i)
                  ScintillaSendMessage(1, #SCI_TOGGLEFOLD, i)
                EndIf
              EndIf
            Next
          Case 11 ;Expand all items.
            For i=0 To ScintillaSendMessage(1, #SCI_GETLINECOUNT)-1
              If ScintillaSendMessage(1, #SCI_GETFOLDLEVEL, i) & #SC_FOLDLEVELHEADERFLAG
                If ScintillaSendMessage(1, #SCI_GETFOLDEXPANDED, i) = 0
                  ScintillaSendMessage(1, #SCI_TOGGLEFOLD, i)
                EndIf
              EndIf
            Next
        EndSelect
    EndSelect
  Until eventID = #PB_Event_CloseWindow

  ;Free the Scintilla gadget.
    GOSCI_Free(1)
EndIf
but apparently in the latest version of Go_scintilla
the constant #GOSCI_ALLOWCODEFOLDING is no defined ... :shock: :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by srod »

That was removed a long time ago.

See the GOSCI_SetLexerState() function. (Code folding is enabled by default.) You will see in the GoScintilla download that I altered the relevant demo program to show how to collapse/expand all nodes etc.
I may look like a mule, but I'm not a complete ass.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

srod wrote:TYou will see in the GoScintilla download that I altered the relevant demo program to show how to collapse/expand all nodes etc.
arg !! I had not seen!

Because your example is in the folder "\ SimplePBSyntax \"

when they should be in the folder "\ AdvancedDemos \ Folding\" :twisted:

:lol: thanks... :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

@Srod

I needed a function
which selects a portion of the line
(One word)
I added this feature in Go_Scintilla :)

Code: Select all

ProcedureDLL GOSCI_select_word(id,number_line,startseg,longseg)
    ;by Dobro
    ;Selection an segment of line
    ScintillaSendMessage(id, #SCI_GOTOLINE, number_line)
    posx= ScintillaSendMessage(id, #SCI_POSITIONFROMLINE,number_line) 
    ScintillaSendMessage(id, #SCI_SetSelectionStart,posx+startseg)
    ScintillaSendMessage(id, #SCI_SetSelectionEnd,posx+startseg+longseg)
EndProcedure


sample :

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***Go-Scintilla 2***
;*=================
;*
;*©nxSoftWare (www.nxSoftware.com) 2010.
;*======================================
;*    
;*  Commented demo program.
;/////////////////////////////////////////////////////////////////////////////////


;IncludePath "..\..\"
;XIncludeFile "GoScintilla.pbi"


;Initialise the Scintilla library for Windows.
CompilerIf  #PB_Compiler_OS = #PB_OS_Windows 
    InitScintilla()
CompilerEndIf

If OpenWindow(0, 100, 200, 600, 600, "GoScintilla demo!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
    RemoveKeyboardShortcut(0, #PB_Shortcut_Tab) ;Required for the tab key to function correctly when the Scintilla control has the focus.
    ;Create our Scintilla control. Note that we do not specify a callback; this is optional for GoSctintilla.
    GOSCI_Create(1, 10, 10, 580, 580, 0, #GOSCI_AUTOSIZELINENUMBERSMARGIN)
    
    ;Set the padding added to the width of the line-number margin.
    GOSCI_SetAttribute(1, #GOSCI_LINENUMBERAUTOSIZEPADDING, 10)
    
    ;Set folding symbols margin width.
    GOSCI_SetMarginWidth(1, #GOSCI_MARGINFOLDINGSYMBOLS, 24)
    
    ;Set the back color of the line containing the caret.
    GOSCI_SetColor(1, #GOSCI_CARETLINEBACKCOLOR, $B4FFFF)
    
    ;Set font.
    GOSCI_SetFont(1, "Courier New", 10,#PB_Default)
    
    ;Set tabs. Here we use a 'hard' tab in which a tab character is physically inserted. Set the 3rd (optional) parameter to 1 to use soft-tabs.
    GOSCI_SetTabs(1, 2,#PB_Default)
    
    ;Set styles for our syntax highlighting.
    ;=======================================
    ;First define some constants to identify our various styles.
    ;You can name these as we wish.
    Enumeration
        #STYLES_COMMANDS = 1
        #STYLES_COMMENTS
        #STYLES_LITERALSTRINGS
        #STYLES_NUMBERS
        #STYLES_CONSTANTS
        #STYLES_FUNCTIONS
EndEnumeration

    ;Set individual styles for commands.
GOSCI_SetStyleFont(1, #STYLES_COMMANDS, "", -1, #PB_Font_Bold)
GOSCI_SetStyleColors(1, #STYLES_COMMANDS, $800000,#PB_Default)  ;We have omitted the optional back color.

    ;Set individual styles for comments.
GOSCI_SetStyleFont(1, #STYLES_COMMENTS, "", -1, #PB_Font_Italic)
GOSCI_SetStyleColors(1, #STYLES_COMMENTS, $006400,#PB_Default)  ;We have omitted the optional back color.

    ;Set individual styles for literal strings.
GOSCI_SetStyleColors(1, #STYLES_LITERALSTRINGS, #Gray,#PB_Default)  ;We have omitted the optional back color.

    ;Set individual styles for numbers.
GOSCI_SetStyleColors(1, #STYLES_NUMBERS, #Red,#PB_Default)  ;We have omitted the optional back color.

    ;Set individual styles for constants.
GOSCI_SetStyleColors(1, #STYLES_CONSTANTS, $2193DE,#PB_Default)  ;We have omitted the optional back color.

    ;Set individual styles for functions.
GOSCI_SetStyleColors(1, #STYLES_FUNCTIONS, #Blue,#PB_Default)  ;We have omitted the optional back color.

  ;Set delimiters and keywords for our syntax highlighting.
  ;========================================================
    ;Delimiters.
    ;First set up a ; symbol to denote a comment. Note the use of #GOSCI_DELIMITTOENDOFLINE.
    ;Note also that this symbol will act as an additional separator.
GOSCI_AddDelimiter(1, ";", "", #GOSCI_DELIMITTOENDOFLINE, #STYLES_COMMENTS)
    ;Now set up quotes to denote literal strings.
    ;We do this by passing the beginning and end delimiting characters; in this case both are quotation marks. Note the use of #GOSCI_DELIMITBETWEEN.
    ;Note also that a quote will subsequently act as an additional separator.
GOSCI_AddDelimiter(1, Chr(34), Chr(34), #GOSCI_DELIMITBETWEEN, #STYLES_LITERALSTRINGS)
    ;Now set up a # symbol to denote a constant. Note the use of #GOSCI_LEFTDELIMITWITHOUTWHITESPACE.
GOSCI_AddDelimiter(1, "#", "", #GOSCI_LEFTDELIMITWITHOUTWHITESPACE, #STYLES_CONSTANTS)
    ;Now set up a ( symbol to denote a function. Note the use of #GOSCI_RIGHTDELIMITWITHWHITESPACE.
GOSCI_AddDelimiter(1, "(", "", #GOSCI_RIGHTDELIMITWITHWHITESPACE, #STYLES_FUNCTIONS)
    ;We arrange for a ) symbol to match the coloring of the ( symbol.
GOSCI_AddDelimiter(1, ")", "", 0, #STYLES_FUNCTIONS)

    ;Basic command keywords.
GOSCI_AddKeywords(1, "Debug End If ElseIf Else EndIf For To Next Step Protected ProcedureReturn", #STYLES_COMMANDS,#PB_Default,#PB_Default)

    ;Add some folding keywords.
GOSCI_AddKeywords(1, "Procedure Macro", #STYLES_COMMANDS, #GOSCI_OPENFOLDKEYWORD,#PB_Default)
GOSCI_AddKeywords(1, "EndProcedure EndMacro", #STYLES_COMMANDS, #GOSCI_CLOSEFOLDKEYWORD,#PB_Default)

  ;Additional lexer options.
  ;=========================
    ;The lexer needs to know what separator characters we are using.
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_SEPARATORSYMBOLS, @"=+-*/%()[],.") ;You would use GOSCI_AddKeywords() to set a style for some of these if required.
    ;We can also set a style for numbers.
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_NUMBERSSTYLEINDEX, #STYLES_NUMBERS)
      
  ;Set some initial text.
  ;======================
text$ = "; GoScintilla 2.0." + #CRLF$
text$ + "; By Stephen Rodriguez." + #CRLF$ + #CRLF$
text$ + "#MyConstant$ = " + Chr(34) + "Version = 1.0" + Chr(34) + #CRLF$ + #CRLF$
text$ + "Procedure.i AddIntegers(a, b)" + #CRLF$
text$ + #TAB$ + "Protected result" + #CRLF$
text$ + #TAB$ + "result = a + b  ; Calculate the sum of the 2 integers." + #CRLF$
text$ + #TAB$ + "ProcedureReturn result" + #CRLF$
text$ + "EndProcedure" + #CRLF$ + #CRLF$
text$ + "Debug " + Chr(34) + "The sum of 10 and 20 is " + Chr(34) + " + Str(AddIntegers(10, 20))" + #CRLF$ + #CRLF$
text$ + "End" + #CRLF$
    
    
GOSCI_SetText(1, text$,#PB_Default)
    
MessageRequester("message" ,"select of "+Chr(34)+"The sum"+Chr(34))
start=29 
line=7
GOSCI_select_word(1,line,start,Len("The sum"))
    
    
Repeat
    eventID = WaitWindowEvent()
    Select eventID
        Case #PB_Event_Gadget
            Select EventGadget()
                    
            EndSelect
    EndSelect
    
Until eventID = #PB_Event_CloseWindow 

  ;Free the Scintilla gadget.
  ;This needs explicitly calling in order to free resources used by GoScintilla.
GOSCI_Free(1)
EndIf

:)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

hello ,

where is GoScintilla 2.3 please for the 4.60 ?? :shock:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by ts-soft »

dobro wrote:where is GoScintilla 2.3 please for the 4.60 ?? :shock:
Works fine here with PB4.60.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

for me , error on compilation ,on Goscintilla 2.3 with structure stylingFunction no found ! ;
on line : " If *this\stylingFunction" :shock:

on win7 64 bit , compilation 32 bit (tailbite) :?
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by ts-soft »

I have tested all examples on win7 as 32 and 64-bit without problems.

What do you mean with tailbite? I use it as includefile!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by dobro »

ok fixed :)

just my version was corrupted :) thanks
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by le_magn »

hi, i tried to go http://www.nxsoftware.com but i receive this error "No input file specified. "
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 2.2 (Purebasic 4.5 only)

Post by srod »

Yes, sorry, been so busy that I haven't had time to sort out the site as yet. I will get on it as soon as I can.
I may look like a mule, but I'm not a complete ass.
Post Reply