GoScintilla with white space scroll

Just starting out? Need help? Post your questions and find answers here.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Dec 04, 2015 9:26 pm

GoScintilla with white space scroll

Post by skinkairewalker »

Hi guys, does anyone out there know anything about Go Scintilla? I would like to know how to remove this white space, I've gone through the code end to end and nothing to find the line that generates this white space ... does anyone know how to solve this?

Screenshot :
Image
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: GoScintilla with white space scroll

Post by Tenaja »

I think that might be a width setting... I've never seen gosci insert white spaces in my text, so it probably has to do with width or maybe scrollbar settings.

Post code... It'll be easier to tell.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Dec 04, 2015 9:26 pm

Re: GoScintilla with white space scroll

Post by skinkairewalker »

hi Tenaja

i am using this code :

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***Go-Scintilla 2***
;*===================
;*
;*©nxSoftWare (www.nxSoftware.com) 2010.
;*======================================
;*    
;*  Multiword keyword demo.
;*  We show how to use a user-defined line styling function to trap 'End Function' as a close-fold 'keyword'.
;/////////////////////////////////////////////////////////////////////////////////


IncludePath "../../../"
XIncludeFile "GoScintilla.pbi"


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, 600, 600, "GoScintilla demo!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
  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)

  ;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)

  ;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_LITERALSTRINGS
        #STYLES_NUMBERS
        #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 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 functions.
      GOSCI_SetStyleColors(1, #STYLES_FUNCTIONS, #Blue)  ;We have omitted the optional back color.

  ;Set delimiters and keywords for our syntax highlighting.
  ;========================================================
    ;First some commands.
      GOSCI_AddKeywords(1, "As ByVal End Function Integer", #STYLES_COMMANDS)
    ;Now set up quotes to denote literal strings. Note the space separating the pair of quotes from the pait of ' symbols.
      GOSCI_AddDelimiter(1, Chr(34), Chr(34), #GOSCI_DELIMITBETWEEN, #STYLES_LITERALSTRINGS)
    ;Now set up a ( symbol to denote a function.
      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)

  ;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 our user-defined line styling function.
  ;===========================================
    GOSCI_SetLineStylingFunction(1, @MyLineStyler())

  ;Set some initial text.
  ;======================
    text$ + "Function test(ByVal a As Integer, ByVal b As Integer)" + #CRLF$ + #CRLF$
    text$ + "End Function" + #CRLF$
    
    GOSCI_SetText(1, text$)

  Repeat
    eventID = WaitWindowEvent()
    Select eventID
      Case #PB_Event_SizeWindow
        ResizeGadget(1, #PB_Ignore, #PB_Ignore, WindowWidth(0)-20, WindowHeight(0)-20)
      
      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


;/////////////////////////////////////////////////////////////////////////////////
;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$, lastSymbolStyled$
  ;Need to loop through the UTF-8 buffer invoking GoScintilla's styling lexer as appropriate.
    While numUtf8Bytes
      numBytesStyled = GOSCI_StyleNextSymbol(id, *utf8Buffer, numUtf8Bytes)
      numUtf8Bytes - numBytesStyled
      ;Examine the symbol just styled.
        If numBytesStyled
          symbolJustStyled$ = LCase(PeekS(*utf8Buffer, numBytesStyled, #PB_UTF8))
          If symbolJustStyled$ = "function"
            ;Was the previous symbol "end" ? If so, we decrease the current line's fold level as appropriate for a close-fold keyword.
            ;Otherwise, we increment the fold level as appropriate for an open-fold keyword.
              If lastSymbolStyled$ = "end"
                GOSCI_DecFoldLevel(id)
              Else
                GOSCI_IncFoldLevel(id)              
              EndIf      
          EndIf
          ;If the current symbol is not a stream of whitespace characters (space or #TAB) then record it in the lastSymbolStyled$.
            If *utf8Buffer\a <> 32 And *utf8Buffer\a <> 9
              lastSymbolStyled$ = symbolJustStyled$
            EndIf
        EndIf
      *utf8Buffer + numBytesStyled
    Wend
  ProcedureReturn result
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////



and i get this :
Image

you can download this way :> https://soqueto.com/imgs/GoScintilla.zip
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: GoScintilla with white space scroll

Post by Tenaja »

User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Dec 04, 2015 9:26 pm

Re: GoScintilla with white space scroll

Post by skinkairewalker »

wow, thanks Tanaja

I added the following line:

Code: Select all

    ScintillaSendMessage(1,#SCI_SETSCROLLWIDTH,500)
    ScintillaSendMessage(1,#SCI_SETSCROLLWIDTHTRACKING,1)
works, but have a bug ...

if I press tab or space until the cursor is far away, and I try to get back to the text field of view, the scroll doesn't shrink the size again, and even if I erase everything, the cursor stays until the last space I defined, as shown in the screenshot below:

in the screenshot below, it shows that everything works fine .
Image

in the screenshot below, it shows me clicking countless times on TAB or SPACE so that the courses go far and the scrollwitdh increases as I move the cursor away .
Image

in the screenshot below, it shows that even erasing or returning the cursor to where the visible code snippet is, the scrolwidth doesn't retreat or decrease back to the visible code snippet...
Image
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: GoScintilla with white space scroll

Post by Tenaja »

Read above and below that command in the sci docs. There's probably a way to turn on auto resize. I don't recall having this issue, but I cannot pull out my PC.

Are you on windows?

I know I typically used the dll instead of the PB library--that PB version was always way out of date.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Dec 04, 2015 9:26 pm

Re: GoScintilla with white space scroll

Post by skinkairewalker »

Tenaja wrote: Tue Jun 01, 2021 4:25 am Are you on windows?
Yes :D
Tenaja wrote: Tue Jun 01, 2021 4:25 am
I know I typically used the dll instead of the PB library--that PB version was always way out of date.
do you have an example of how it's importing a DLL?
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: GoScintilla with white space scroll

Post by Tenaja »

No dll example, but there are many in the forum, but Google is better due to dll character length.
viewtopic.php?t=31731

Just use the dll like any other dll. The SendScintilla commands still work the same as with the outdated pb library.

There are numerous examples on this forum, and gosci had a handful as well. I just posted the first one I saw.
Post Reply