Scintilla Enumeration

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Scintilla Enumeration

Post by rndrei »

If Enumeration > 255 then it doesn't work! How can I make enumeration > 255?

Code: Select all

Enumeration 10    ; work
;Enumeration 255  ; not work
  #LexerState_Space 
  #LexerState_Comment 
  #LexerState_Keyword 
  #LexerState_FoldKeyword 
EndEnumeration 

Procedure Scintilla_CB(Gadget, *scinotify.SCNotification)
  code=             *scinotify.SCNotification\nmhdr\code 
  pos=              *scinotify.SCNotification\Position 
  ch=               *scinotify.SCNotification\ch 
  modificationType= *scinotify.SCNotification\modifiers 
  text=             *scinotify.SCNotification\text 
  Length=           *scinotify.SCNotification\length 
  linesAdded=       *scinotify.SCNotification\linesAdded 
  message=          *scinotify.SCNotification\message 
  wParam=           *scinotify.SCNotification\wParam 
  lParam=           *scinotify.SCNotification\lParam 
  line=             *scinotify.SCNotification\line 
  foldLevelNow=     *scinotify.SCNotification\foldLevelNow 
  foldLevelPrev=    *scinotify.SCNotification\foldLevelPrev 
  margin=           *scinotify.SCNotification\margin 
  listType=         *scinotify.SCNotification\listType 
  x=                *scinotify.SCNotification\x 
  y=                *scinotify.SCNotification\y 
  Select code     
    Case #SCN_STYLENEEDED 
      ; Syntax highlighter    
      EndPos=pos 
      EndStyledPos = ScintillaSendMessage(4,#SCI_GETENDSTYLED) 
      linenumber = ScintillaSendMessage(4,#SCI_LINEFROMPOSITION,EndStyledPos)     
      If linenumber = 0 
        level = #SC_FOLDLEVELBASE 
      Else 
        linenumber - 1 
        level = ScintillaSendMessage(4,#SCI_GETFOLDLEVEL,linenumber) & ~ #SC_FOLDLEVELHEADERFLAG 
      EndIf  
      thislevel = level 
      nextlevel = level 
      CurrentPos.l = ScintillaSendMessage(4,#SCI_POSITIONFROMLINE,linenumber)
      ScintillaSendMessage(4,#SCI_STARTSTYLING,CurrentPos, $1F | #INDICS_MASK)
      State = #LexerState_Space 
      KeywordStartPos = CurrentPos 
      keyword.s = ""      
      While CurrentPos <= EndPos 
        OldState = State         
        Char.l = ScintillaSendMessage(4,#SCI_GETCHARAT, CurrentPos)
        If Char = ';' 
          State = #LexerState_Comment 
        ElseIf Char = 10 Or Char = 13 
          State = #LexerState_Space 
        ElseIf State <> #LexerState_Comment 
          If Char = 9 Or Char = ' ' Or Char = '.' 
            State = #LexerState_Space 
          Else 
            State = #LexerState_Keyword 
            keyword + Chr(Char) 
          EndIf 
        EndIf        
        If OldState <> State Or CurrentPos = EndPos 
          If OldState = #LexerState_Keyword 
            lkeyword.s = LCase(keyword)            
           Restore String_code
            For i=1 To 41
              Read.s Slovo.s           
              If lkeyword=Slovo 
                OldState = #LexerState_FoldKeyword 
                Break 
              EndIf 
            Next i           
            keyword = "" 
          EndIf 
          ScintillaSendMessage(4,#SCI_SETSTYLING, CurrentPos - KeywordStartPos, OldState)
          KeywordStartPos = CurrentPos 
        EndIf        
        If Char = 10 Or CurrentPos = EndPos 
          ScintillaSendMessage(4,#SCI_SETFOLDLEVEL, linenumber, thislevel) 
          thislevel = nextlevel 
          linenumber + 1 
        EndIf       
        CurrentPos + 1 
      Wend    
  EndSelect 
EndProcedure 

exit=0

If OpenWindow(0,100,100,700,500,"test",#PB_Window_SystemMenu | #PB_Window_ScreenCentered) 

    ScintillaGadget(4,2,30,700,500,@Scintilla_CB() ) 
    Gosub ScintillaInit   
    text.s = ""
    ScintillaSendMessage(4,#SCI_SETTEXT,0, @text)
    ScintillaSendMessage(4, #SCI_SETCARETFORE,RGB(2, 4, 231) )
    SetActiveGadget(4)
    
 Repeat 
      Event=WaitWindowEvent() 
      Gadget=EventGadget() 
      Menu=EventMenu() 
      Window=EventWindow()   
      If Event=#PB_Event_SizeWindow 
        ResizeGadget(4,#PB_Ignore,#PB_Ignore,WindowWidth(0)-4,WindowHeight(0)-74) 
      EndIf 
      If Event=#PB_Event_CloseWindow 
        Exit=1 
      EndIf     
 Until Exit=1 
EndIf
End 

ScintillaInit:
ScintillaSendMessage(4, #SCI_STYLESETFONT,#STYLE_DEFAULT, @"Peddana") 
ScintillaSendMessage(4, #SCI_STYLESETSIZE,#STYLE_DEFAULT, 18) 
ScintillaSendMessage(4, #SCI_STYLECLEARALL) 
ScintillaSendMessage(4, #SCI_SETCARETLINEBACK,RGB(226, 255, 233)) 
ScintillaSendMessage(4, #SCI_SETCARETLINEVISIBLE,#True) 
ScintillaSendMessage(4, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER) 
ScintillaSendMessage(4, #SCI_SETMARGINWIDTHN, 0, 40) 
ScintillaSendMessage(4, #SCI_STYLESETFORE,#LexerState_Comment,RGB(23, 104, 232) ) 
ScintillaSendMessage(4, #SCI_STYLESETFORE,#LexerState_Keyword, 0) 
ScintillaSendMessage(4, #SCI_STYLESETFORE,#LexerState_FoldKeyword, RGB(0, 136, 0))
ScintillaSendMessage(4, #SCI_STYLESETBOLD,#LexerState_FoldKeyword, 1) 
Return 

DataSection 
  String_code: 
  Data.s  "break","messagebox"
  Data.s "beep","show","if","nop","rlf","rrf","subwf","swapf","xorwf" 
  Data.s "openconsole","closeconsole","end","exit","clear","set","get","write","writeln","read","bcf","bsf","btfsc","btfss","addlw","andlw","call","clrwdt","goto" ,"initcrt"
  Data.s "iorlw","movlw","retfie","retlw","return","sleep","sublw","xorlw" 
  Data.s "gogo","int","poke"
EndDataSection
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Scintilla Enumeration

Post by AZJIO »

STYLE_MAX = 255

Code: Select all

Enumeration 255  ; not work
  #LexerState_Space 
  #LexerState_Comment 
  #LexerState_Keyword 
  #LexerState_FoldKeyword 
EndEnumeration 
Debug #LexerState_FoldKeyword
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla Enumeration

Post by rndrei »

It's a pity that STYLE_MAX = 255!
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Scintilla Enumeration

Post by AZJIO »

rndrei wrote: Mon Sep 30, 2024 8:01 am It's a pity that STYLE_MAX = 255!
Are 255 types of lexemes not enough for you? Any language uses a maximum of 30 lexemes, and on average 10-15. You most likely need to change the way you solve a problem, rather than demand something that has already been done in excess.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla Enumeration

Post by rndrei »

Yes, apparently it is necessary to change the method
Post Reply