GoScintilla - 2.7 (Purebasic 4.5 onwards)

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla (PB 4.4 only)

Post by srod »

Version 1.0 beta 2 - 27th November 2009

Having just integrated GoScintilla into an existing project, I found myself making the following changes ;
  • Fixed a bug with GOSCI_Create() (it wasn't returning any value!)
  • Added function : GOSCI_ReplaceSelectedText(id, text$, blnScrollCaretIntoView=#False).
  • Modified the GOSCI_SetText() function by the addition of an optional parameter; clearUndoStack (default #False).
    Set to non-zero to have the undo stack cleared so that this operation cannot be undone.
  • Added a new get/set attribute : #GOSCI_WRAPLINES. Turn wrapping lines on/off.
  • Added a new get/set attribute : #GOSCI_WRAPLINESVISUALMARKER. Give wrapped lines a visual marker.
  • By default, all delimiter characters are also regarded as separators. This can now be over-ruled when adding delimiter keywords by using the new #GOSCI_NONSEPARATINGDELIMITER flag.

    This was added to allow one type of delimiter to be styled as part of another delimiter.

    E.g. imagine the situation with Purebasic syntax in which we may opt to declare both the # and $ symbols as delimiters in order to style constants and string variables appropriately.

    What happens then with the symbol #StringConstant$ ?

    The first version of GoScintilla would apply one style to #StringConstant and another style to $ !

    By making the $ symbol a non-separating delimiter, however, #StringConstant$ would now be styled correctly as befitting a constant.

Please see the nxSoftware site for the download.
I may look like a mule, but I'm not a complete ass.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by eddy »

nice job
Your lib makes Scintilla really simple to code.


here is my first contribution (an minor addon for your PB lexer example)

Code: Select all

   ;Additional lexer options for pointer.
   ;=====================================
   Enumeration #PB_Compiler_EnumerationValue
      #STYLES_POINTER
   EndEnumeration
   ;Set individual styles for pointers.
   GOSCI_SetStyleColors(1, #STYLES_POINTER, #Cyan)  ;We have omitted the optional back color.   
   ;Now set up a * symbol to denote a pointer. Note the use of #GOSCI_LEFTDELIMITWITHOUTWHITESPACE.
   GOSCI_AddKeywords(1, "*", #STYLES_POINTER, #GOSCI_LEFTDELIMITWITHOUTWHITESPACE)
   ;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.
Last edited by eddy on Sat Nov 28, 2009 6:06 pm, edited 2 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by JCV »

Thanks srod!

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by eddy »

Second contribution ;)
- append / prepend text mode for GOSCI_SetText()

Code: Select all

   ;General function options.
   ;Use with GOSCI_SetText()
   Enumeration 0
      #GOSCI_TEXT_RELOAD ; Replace the current text
      #GOSCI_TEXT_RELOAD_CLEARUNDOSTACK ; Replace the current text and clear undo stack
      #GOSCI_TEXT_APPEND ; Add text at the end of current text
      #GOSCI_TEXT_PREPEND ; Insert text before the beginning of current text
   EndEnumeration
   
   ;/////////////////////////////////////////////////////////////////////////////////
   ;The following function sets the text for the entire control.
   ;No return value.
   Procedure GOSCI_SetText(id, text$, mode=#GOSCI_TEXT_RELOAD)
      Protected utf8Buffer
      If IsGadget(id) And GadgetType(id)=#PB_GadgetType_Scintilla
         ;Need to convert to utf-8 first.
         utf8Buffer=AllocateMemory(StringByteLength(text$, #PB_UTF8)+1)
         If utf8Buffer
            PokeS(utf8Buffer, text$, -1, #PB_UTF8)
            Select mode
               Case #GOSCI_TEXT_APPEND
                  ScintillaSendMessage(id, #SCI_APPENDTEXT, MemorySize(utf8Buffer)-1, utf8Buffer)
               Case #GOSCI_TEXT_PREPEND
                  ScintillaSendMessage(id, #SCI_INSERTTEXT, 0, utf8Buffer)
               Case #GOSCI_TEXT_RELOAD, #GOSCI_TEXT_RELOAD_CLEARUNDOSTACK
                  ScintillaSendMessage(id, #SCI_SETTEXT, 0, utf8Buffer)
                  If #GOSCI_TEXT_RELOAD_CLEARUNDOSTACK
                     ScintillaSendMessage(id, #SCI_EMPTYUNDOBUFFER)
                  EndIf
            EndSelect
            FreeMemory(utf8Buffer)
         EndIf
      EndIf
   EndProcedure
   ;/////////////////////////////////////////////////////////////////////////////////
Here is a code sample :

Code: Select all

   ;you have to active 'CREATE UNICODE EXECUTABLE' options
   CompilerIf #PB_Compiler_Unicode 
      GOSCI_SetText(1, "ă prepended text", #GOSCI_TEXT_PREPEND)
      GOSCI_SetText(1, "ă appended text", #GOSCI_TEXT_APPEND)
   CompilerEndIf
Last edited by eddy on Sat Nov 28, 2009 7:15 pm, edited 2 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by eddy »

I didn't found this new function : GOSCI_ReplaceSelectedText() and the new flag of GOSCI_SetText().
The download link is not up-to-date :roll:

Where can we download the beta 2 ?
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by srod »

Sorry, I uploaded beta 2 with the wrong filename which is why you could not access it.

I have uploaded beta 3 now which has a couple of extra functions thrown in : GOSCI_GetLexerState() and GOSCI_SetLexerState(). Please see the manual for details.
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by Mistrel »

Wewt! With source code to boot. Thanks for this, srod. :D
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by fsw »

How can folding keywords be done when the "open folding" keyword is also part of the "close folding" keyword like:

Code: Select all

Function
...
End Function
As you can see there is a white space between the 2 "close folding" keywords...
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by srod »

You can't. GoScintilla's Lexer will of course not suit every need. When dealing with code-folding it is primed only to recognise single word keywords and so it will not recognise End Function as being a close-fold terminal symbol.

You will have to utilise a user-defined line-styling function for this; although the truth is that I haven't really made GoScintilla's code-folding logic available to such functions (just the syntax styling parts). I'll have to give this some thought when I have a spare moment or two.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by ts-soft »

My wish for christmas:
1. autocomplete feature
2. case correction

greetings
Thomas
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by srod »

ts-soft wrote:My wish for christmas:
1. autocomplete feature
2. case correction

greetings
Thomas
New features will be added Thomas only as I require them. I shall add the functionality requested by fsw later today. As for the rest, well, I shall eventually be using GoSctintilla as part of an IDE and that will probably require me to add all kinds of things. :)
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by Mistrel »

If you an figure out how to incorporate C/C++ and Java code completion I will gladly pay for it. Though it might be a bit over your head. It's well over mine.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: GoScintilla - 1.0 beta 2 (PB 4.4 only)

Post by srod »

At five feet four inches, most things are over my head! :wink:

Code completion is not something that interests me at this time.
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 - 1.0 beta 4 (PB 4.4 only)

Post by srod »

Version 1.0 beta 4 - 30th November 2009

This update has been motivated by a desire to allow for automatic code folding of multi-word keywords such as "Function" and "End Function" etc.
GoScintilla's lexer will only work with single word keywords and thus cannot natively support combinations such as "End Function" as representing a close-fold terminal.

Extending GoScintilla's lexer to allow this is not an option as it will slow things down (in my judgement) too much. Instead, we can make use of a user-defined line styling function to supplement the lexer's capabilities.
  • Added functions : GOSCI_DecFoldLevel(id) and GOSCI_IncFoldLevel(id) to be used within a user-defined line styling function only.
  • Added an additional demo program "Multiword" to demonstrate how to use a very simple user-defined line styling function together with the new functions to implement code folding on the aforementioned "Function" and "End Function" etc.
Please see the nxSoftware site for the download.
I may look like a mule, but I'm not a complete ass.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: GoScintilla - 1.0 beta 4 (PB 4.4 only)

Post by fsw »

srod wrote: I shall add the functionality requested by fsw later today.
Thank you srod, works fine for the intended purpose :)
Post Reply