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.7 (Purebasic 4.5 onwards)

Post by dobro »

hello

currently Go_scintilla allows completion using the mouse or the Tab key or Return key...

how to execute the completion with the space key? (as with jaPBe)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by Poshu »

I needed to convert goscintilla to a module library, but had to do some dirty trick because of the osx mandatory procedureDLL callback. Should I post it there?
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by Danilo »

Poshu wrote:Should I post it there?
Of course, post it here! Free wine for all...! ;)
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by Poshu »

So GoScintilla 2.7 converted to module (and, as said before : dirty, dirty solution to make it compatible with OSX). I only converted a single example though, sorry about that.

And now, for some help :
I can't get GoScintilla to behave : I need // to be the start of a comment, and /* */ to set a command block, I tried :

Code: Select all

GoScintilla::GOSCI_AddDelimiter(*WindowData\Scintilla, "//", "", GoScintilla::#GOSCI_DELIMITTOENDOFLINE, #STYLES_COMMENTS)
GoScintilla::GOSCI_AddDelimiter(*WindowData\Scintilla, "/*", "*/", GoScintilla::#GOSCI_DELIMITBETWEEN, #STYLES_COMMENTS)
but it doesn't work, even though the first like works perfectly with ;. Is / some diabolical character or what?

Edit : seems like it doesn't like double character as a delimiter, maybe I should read the doc :oops: ?
Edit 2 : I read the doc, nothing about several character delimiter, and the source is too complicated for me. Any help?
User avatar
Tenaja
Addict
Addict
Posts: 1948
Joined: Tue Nov 09, 2010 10:15 pm

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by Tenaja »

Did you look at the GoSci examples? I am pretty sure there is an example there...I have used it. Look in this folder:
GoScintilla\Demos\AdvancedDemos\BlockComments
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by Poshu »

Tenaja wrote:Did you look at the GoSci examples? I am pretty sure there is an example there...I have used it. Look in this folder:
GoScintilla\Demos\AdvancedDemos\BlockComments
Yup, I didn't check the exemple, should have done that, thanks.

Still on the subject : I know GoScintilla wasn't tested on OSX, and it seems to work, but I can't fold anything, even though the folding [+] does appear.
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by staringfrog »

Changing *bytePointer.i to *bytePointer didn't help much, as the next error occurred

Code: Select all

Line 1787: Constant not found: #PB_Sort_String
(and not only in this line).
Should it be changed to #PB_String or what?
All these lil' initial setup errors make me think I do something wrong, and the whole grand thing wouldn't work as expected.
Coding's men's knitwork.
User avatar
Kiffi
Addict
Addict
Posts: 1353
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by Kiffi »

staringfrog wrote:Should it be changed to #PB_String or what?
yes:
PB-History wrote:14th February 2013 : Version 5.10
- Changed: replaced #PB_Sort_<Type> with #PB_<Type> to avoid possible errors
Hygge
User avatar
fsw
Addict
Addict
Posts: 1572
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by fsw »

@PoShu
Marvelous idea!
Thank you for getting this started...
Poshu wrote:Still on the subject : I know GoScintilla wasn't tested on OSX, and it seems to work, but I can't fold anything, even though the folding [+] does appear.
Same on Linux, folding doesn't work.

:cry:


On a different note:
Because there is a lot of redundancy while using this module:

Code: Select all

    GoScintilla::GOSCI_Create(1, 10, 10, 580, 280, 0, GoScintilla::#GOSCI_AUTOSIZELINENUMBERSMARGIN)
I changed the module to accept this:

Code: Select all

    GoSci::Create(1, 10, 50, 580, 280, 0, GoSci::#AUTOSIZELINENUMBERSMARGIN)
Makes a lot of sense to me...

Almost forgot:
Had some crashes while testing this module on Windows7-64.
Found out to take out the FreeMemory line here in order to avoid the crashes:

Code: Select all

Procedure Free(id)
  Protected *this._GoScintilla
  If IsGadget(id) And GadgetType(id) = #PB_GadgetType_Scintilla
    *this = GetGadgetData(id)
    If *this
      ClearStructure(*this, _GoScintilla)
      ; activating FreeMemory will sometimes cause a crash on Windows7-64
      ;FreeMemory(*this)
    EndIf
    FreeGadget(id)
  EndIf
EndProcedure
PureBasic should release the memory by his own, should it not?

I am to provide the public with beneficial shocks.
Alfred Hitshock
slagusev
New User
New User
Posts: 6
Joined: Fri Nov 29, 2013 2:24 am

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by slagusev »

Where can I download the latest version of this library? The site does not work :?:
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by RSBasic »

Image
Image
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by dobro »

hi ,

I'm stuck with Goscintilla

I am defining a color for the Api with the function:

Code: Select all

GOSCI_AddDelimiter(onglet, "", "_", #GOSCI_DELIMITBETWEEN   ,  #styles_Api)
but it seems that this does not work you have an idea ??

the aim is to color all text between the beginning of the line (or word) and character "_"
Beep_(440.100)

an idea ?? :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Chaosmal
New User
New User
Posts: 3
Joined: Sun Jan 15, 2017 1:15 pm

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by Chaosmal »

Del
Last edited by Chaosmal on Sun Apr 16, 2017 3:19 pm, edited 1 time in total.
Chaosmal
New User
New User
Posts: 3
Joined: Sun Jan 15, 2017 1:15 pm

Re: GoScintilla 2.7 (Purebasic 4.5 onwards)

Post by Chaosmal »

Hi
I'm new to PureBasic and I'm stuck with Goscintilla
1: I can not assign a delimiter " (Chr(34)), This leads to other problems
2: Unable to collapse the lines ;! @Install @! UTF-8! and ;!@InstallEnd
3: It does not work properly to highlight words of the form( %%^S %%S %%T %%^T), I'm not strong in regular expressions.
4 :plus the rest, just the head is all around!
Please help fix my clumsy code. :?: :o :shock: :? :?: :?: :?:

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***Go-Scintilla 2***
;/////////////////////////////////////////////////////////////////////////////////

XIncludeFile "GoScintilla.pbi"

Procedure GOSCI_SetLineHighlightColor(id, color)
    #GOSCI_HIGHLIGHTERMARKERNUM=#GOSCI_BOOKMARKMARKERNUM+1
    ScintillaSendMessage(1, #SCI_MARKERSETBACK, #GOSCI_HIGHLIGHTERMARKERNUM, color)
    ScintillaSendMessage(1, #SCI_MARKERDEFINE, #GOSCI_HIGHLIGHTERMARKERNUM, #SC_MARK_BACKGROUND)
EndProcedure
Procedure GOSCI_SetLineHighlighted(id, lineIndex, flag=#True)
    If IsGadget(id) And GadgetType(id)=#PB_GadgetType_Scintilla
        If flag
            ScintillaSendMessage(id, #SCI_MARKERADD, lineIndex, #GOSCI_HIGHLIGHTERMARKERNUM)
        Else
            ScintillaSendMessage(id, #SCI_MARKERDELETE, lineIndex, #GOSCI_HIGHLIGHTERMARKERNUM)
        EndIf
    EndIf
EndProcedure

Declare.i MyLineStyler(id, *utf8Buffer.ASCII, numUtf8Bytes, currentLine, startLine, originalEndLine)

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

If OpenWindow(0, 100, 200, 700, 600, "Test!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
    ;Required for the tab key to function correctly when the Scintilla control has the focus.
    RemoveKeyboardShortcut(0, #PB_Shortcut_Tab)
    RemoveKeyboardShortcut(0, #PB_Shortcut_Tab | #PB_Shortcut_Shift)
    
    ;Create our Scintilla control. Note that we do not specify a callback; this is optional for GoSctintilla.
    GOSCI_Create(1, 10, 10, 680, 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, 12)
    
    ;Set font.
    GOSCI_SetFont(1, "Courier New", 12)
    
    ;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, 3)
    
    ;Set colors of text area
    GOSCI_SetColor(1, #GOSCI_FORECOLOR, $FFFFFF)
    GOSCI_SetColor(1, #GOSCI_BACKCOLOR, $9f5000)
    
    ;Set colors of caret (caret color and the back color of the line containing the caret)
    GOSCI_SetColor(1, #GOSCI_CARETFORECOLOR, $FFFFFF)
    GOSCI_SetColor(1, #GOSCI_CARETLINEBACKCOLOR, $b35900)
    
    ;Set colors of selection
    GOSCI_SetColor(1, #GOSCI_SELECTIONBACKCOLOR, $8080ff)
    GOSCI_SetColor(1, #GOSCI_SELECTIONFORECOLOR, $000000)
    
    ;Set colors of line margin
    GOSCI_SetColor(1, #GOSCI_LINENUMBERFORECOLOR, $c0c0c0)
    GOSCI_SetColor(1, #GOSCI_LINENUMBERBACKCOLOR, $804000)
    
    ;Set colors of fold margin
    GOSCI_SetColor(1, #GOSCI_FOLDMARGINHIBACKCOLOR, $804000)
    GOSCI_SetColor(1, #GOSCI_FOLDMARGINLOBACKCOLOR, $804000)
    
    ;Set colors of fold markers
    GOSCI_SetColor(1, #GOSCI_FOLDMARKERSFORECOLOR, $804000)
    GOSCI_SetColor(1, #GOSCI_FOLDMARKERSBACKCOLOR, $c0c0c0)
    
    ;Highlighters
    ;==========
    ;Set colors of line highlighter.
    GOSCI_SetLineHighlightColor(1, $aa5500)
    
    ;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_VARIABLES
        #STYLES_COMMENTS
        #STYLES_LITERALSTRINGS
        #STYLES_NUMBERS
        #STYLES_CONSTANTS
        #STYLES_FUNCTIONS
        #STYLES_SEPARATORS
        #STYLES_OPERATORS
        #STYLES_TYPES
    EndEnumeration
    
    ;Set individual styles for commands.
    GOSCI_SetStyleFont(1, #STYLES_COMMANDS, "", -1, #PB_Font_Bold)
    GOSCI_SetStyleColors(1, #STYLES_COMMANDS, $ffff80)    
    
    ;Set individual styles for comments.
    GOSCI_SetStyleColors(1, #STYLES_COMMENTS, $00ffff)    
    
    ;Set individual styles for literal strings.
    GOSCI_SetStyleColors(1, #STYLES_VARIABLES, $00ff00)  
    
    ;Set individual styles for numbers.
    GOSCI_SetStyleColors(1, #STYLES_NUMBERS, $FF00FF)     
    
    ;Set individual styles for constants.
    GOSCI_SetStyleColors(1, #STYLES_CONSTANTS, $66b3ff)   ;We have omitted the optional back color.
    
    ;Set individual styles for functions.
     GOSCI_SetStyleColors(1, #STYLES_FUNCTIONS, $fdb382)   ;We have omitted the optional back color.
    
    ;Set individual styles for separators.
    GOSCI_SetStyleColors(1, #STYLES_SEPARATORS, $0032FF)  ;We have omitted the optional back color.
    
    ;Set individual styles for operators.
    GOSCI_SetStyleColors(1, #STYLES_OPERATORS, $8080ff)   ;We have omitted the optional back color.
    
    ;Set individual styles for types.
    GOSCI_SetStyleColors(1, #STYLES_TYPES, $ffccff)       ;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.
    GOSCI_AddDelimiter(1, ";", "", #GOSCI_DELIMITTOENDOFLINE, #STYLES_COMMENTS)
    ;Now set up quotes to denote literal strings.
    GOSCI_AddDelimiter(1, "%", "%", #GOSCI_DELIMITBETWEEN, #STYLES_VARIABLES)
    ;Now set up a # symbol to denote a constant.
    GOSCI_AddDelimiter(1, ":",Chr(34),#GOSCI_RIGHTDELIMITWITHOUTWHITESPACE , #STYLES_CONSTANTS)
    
    GOSCI_AddKeywords(1, ";!@Install@!UTF-8!", #STYLES_COMMENTS, #GOSCI_OPENFOLDKEYWORD | #GOSCI_ADDTOCODECOMPLETION)
    GOSCI_AddKeywords(1, ";!@InstallEnd", #STYLES_COMMENTS, #GOSCI_CLOSEFOLDKEYWORD | #GOSCI_ADDTOCODECOMPLETION)
    
    
    ;Basic command keywords.
    GOSCI_AddKeywords(1, "Title Directory Shortcut Shortcut1 Flags SetEnvironment", #STYLES_COMMANDS)
    
    GOSCI_AddKeywords(1,"Name FullName Vers ",#STYLES_CONSTANTS,#GOSCI_ADDTOCODECOMPLETION)

    
    ;Add separator keywords
    GOSCI_AddKeywords(1, "/ \ { } = Chr(34) , .", #STYLES_SEPARATORS)
    
    ;Add operator keywords
    GOSCI_AddKeywords(1, " + - * & | < > -", #STYLES_OPERATORS)
    
    ;Additional lexer options.
    ;=========================
    GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_SEPARATORSYMBOLS, @"/\={}Chr(34),-+")
    GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_NUMBERSSTYLEINDEX, #STYLES_NUMBERS)
    
    ;===========================================
    GOSCI_SetLineStylingFunction(1, @MyLineStyler())
    
    ;======================
    text$ = ";!@Install@!UTF-8!"+ #CRLF$
    text$ + ";{ GoScintilla." + #CRLF$ + #CRLF$ + #CRLF$
    text$ + ";} By Stephen Rodriguez." + #CRLF$ + #CRLF$
    text$ + "SetEnvironment=" + Chr(34) + "Name=Programs" + Chr(34) + #CRLF$
    text$ + "SetEnvironment=" + Chr(34) + "Vers=0.0.0." + Chr(34) + #CRLF$
    text$ + "Title=" + Chr(34) + "Bla-Bla-Bla %Name% %Vers%" + Chr(34) + #CRLF$
    text$ + "Flags=" + Chr(34) + "2+4+8+16+32+2048+4096" + Chr(34) + #CRLF$
    text$ + "Directory=" + Chr(34) + "x86:fm20:\"+ Chr(34) + "%StartEXE%\" + Chr(34) + #CRLF$
    text$ + "Shortcut=" + Chr(34) + "Du,{%%T\\Name.exe},{},{},{},{%FullName%}" + Chr(34) + #CRLF$
    text$ + "Shortcut1=" + Chr(34) + "Pu,{%%S\\Name2.exe},{},{},{},{%FullName%},{1}" + Chr(34) + #CRLF$ + #CRLF$
    text$ + ";!@InstallEnd" + #CRLF$
    GOSCI_SetText(1, text$)
    
    Repeat
        eventID=WaitWindowEvent()
        Select eventID
            Case #PB_Event_Gadget
                Select EventGadget()
                EndSelect
        EndSelect
    Until eventID=#PB_Event_CloseWindow
    
    GOSCI_Free(1)
EndIf

;/////////////////////////////////////////////////////////////////////////////////
;The following is our user-defined line-styling function, called whenever GoScintilla is called upon to style lines.
Procedure.i MyLineStyler(id, *utf8Buffer.ASCII, numUtf8Bytes, currentLine, startLine, originalEndLine)
    Protected result=#GOSCI_STYLELINESASREQUIRED, numBytesStyled, symbolJustStyled$, *ptrAscii.ASCII
    Static regexVAR
    If Not regexVAR
        ;{ Init search patterns
        Enumeration
            #Highlight_Remove=-1
            #Highlight_None=0
            #Highlight_Visible=1
            #Highlight_End=2
        EndEnumeration
        
        regexVAR=CreateRegularExpression(#PB_Any, "[%][%][\S]")  ; %%S  %%T  %%^S  %%^T
        ;}
    EndIf
    
    lineHighlighting=GOSCI_GetLineData(id, currentLine-1)
    
    While numUtf8Bytes
        Dim foundSymbol$(0)
        Select *utf8Buffer\a
            Case ';'
                ;{ search fold markers to update fold levels
                textToExamine$=LCase(PeekS(*utf8Buffer, numUtf8Bytes, #PB_UTF8))
                Select Left(textToExamine$, 2)
                    Case ";{"
                        GOSCI_IncFoldLevel(id)
                    Case ";}"
                        GOSCI_DecFoldLevel(id)
                EndSelect
;             Select Left(textToExamine$, 2)
;                Case ";!"
;                   GOSCI_IncFoldLevel(id)
;                Case ";!"
;                   GOSCI_DecFoldLevel(id)
;             EndSelect
                
            Case '%'
                textToExamine$=LCase(PeekS(*utf8Buffer, numUtf8Bytes, #PB_UTF8))
                If ExtractRegularExpression(regexVAR, textToExamine$, foundSymbol$()) Or ExtractRegularExpression(regexBIN, textToExamine$, foundSymbol$())
                    numBytesStyled=Len(foundSymbol$(0))
                    ScintillaSendMessage(id, #SCI_SETSTYLING, numBytesStyled, #STYLES_VARIABLES)
                    numUtf8Bytes-numBytesStyled
                    *utf8Buffer+numBytesStyled
                    Continue
                EndIf
        EndSelect
        
        numBytesStyled=GOSCI_StyleNextSymbol(id, *utf8Buffer, numUtf8Bytes)
        symbolJustStyled$=LCase(PeekS(*utf8Buffer, numBytesStyled, #PB_UTF8))
        
        If symbolJustStyled$=";!@Install@!UTF-8!"
            lineHighlighting=#Highlight_Visible
        ElseIf symbolJustStyled$=";!@InstallEnd"
            If lineHighlighting=#Highlight_Visible
                lineHighlighting=#Highlight_End
            Else
                lineHighlighting=#Highlight_Remove
            EndIf
        EndIf
        
        numUtf8Bytes-numBytesStyled
        *utf8Buffer+numBytesStyled
    Wend
    
;     If GOSCI_GetLineData(id, currentLine)<>lineHighlighting
;         Select lineHighlighting
;             Case #Highlight_Visible
;                 GOSCI_SetLineData(id, currentLine, #Highlight_Visible)
;                 GOSCI_SetLineHighlighted(id,currentLine,1)
;             Case #Highlight_End
;                 GOSCI_SetLineData(id, currentLine, #Highlight_None)
;                 GOSCI_SetLineHighlighted(id, currentLine, 1)
;             Case #Highlight_None, #Highlight_Remove
;                 GOSCI_SetLineData(id, currentLine, #Highlight_None)
;                 GOSCI_SetLineHighlighted(id, currentLine, 0)
;         EndSelect
;         result=#GOSCI_STYLENEXTLINEREGARDLESS
;     EndIf
    
    ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
I apologize for the translator.
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Re: GoScintilla - 2.7 (Purebasic 4.5 onwards)

Post by LCD »

Scilexer has internal lexing ability. Maybe someone can explain, how it can be written? I made a lexer in GoScintilla, but it is extremly slow. After loading a sourcer code it takes minutes until the highlightning and folding is finished, and sometimes new entered code is not highlighted after all, unlass I update it manually (delerting a non existent command from command list).
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Post Reply