Page 2 of 20

Re: GoScintilla (PB 4.4 only)

Posted: Fri Nov 27, 2009 3:40 pm
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.

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

Posted: Sat Nov 28, 2009 2:23 pm
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.

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

Posted: Sat Nov 28, 2009 3:33 pm
by JCV
Thanks srod!

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

Posted: Sat Nov 28, 2009 3:54 pm
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

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

Posted: Sat Nov 28, 2009 4:07 pm
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 ?

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

Posted: Sun Nov 29, 2009 12:06 am
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.

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

Posted: Sun Nov 29, 2009 5:22 am
by Mistrel
Wewt! With source code to boot. Thanks for this, srod. :D

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

Posted: Sun Nov 29, 2009 7:05 am
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...

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

Posted: Sun Nov 29, 2009 12:43 pm
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.

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

Posted: Mon Nov 30, 2009 7:55 am
by ts-soft
My wish for christmas:
1. autocomplete feature
2. case correction

greetings
Thomas

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

Posted: Mon Nov 30, 2009 10:18 am
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. :)

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

Posted: Mon Nov 30, 2009 12:20 pm
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.

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

Posted: Mon Nov 30, 2009 6:38 pm
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.

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

Posted: Mon Nov 30, 2009 8:44 pm
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.

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

Posted: Tue Dec 01, 2009 4:04 am
by fsw
srod wrote: I shall add the functionality requested by fsw later today.
Thank you srod, works fine for the intended purpose :)