Scintilla change STYLE of part of text on the fly [Resolved]

Just starting out? Need help? Post your questions and find answers here.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Scintilla change STYLE of part of text on the fly [Resolved]

Post by boddhi »

Salut KCC,

With my Win10 & PB 6.11 x64, the text is red:
Image
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5500
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Scintilla change STYLE of part of text on the fly [Resolved]

Post by Kwai chang caine »

Hello BODHHI :wink:

What !!!! incredible :shock:
I have again try and me....i have an underline with 5.73 X86
But you have right...with 6.10 the fore is good red :shock:
I begin to coming crazy with this library :twisted:

I continue my try and you imagine...even the ITALIC and BOLD can't be changed on the fly :shock:

Code: Select all

; https://www.purebasic.fr/english/viewtopic.php?p=624896#p624896

InitScintilla("Scintilla.dll")

OpenWindow(0, 0, 0, 500, 300, "Essais Scintilla", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
ScintillaGadget(1, 0, 0, WindowWidth(0), WindowHeight(0) - 30, 0)

*t = UTF8("Courier")                                          
ScintillaSendMessage(1, #SCI_STYLESETFONT, #STYLE_DEFAULT, *t)            ; 
FreeMemory(*t)                              

ScintillaSendMessage(1, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 15)
ScintillaSendMessage(1, #SCI_STYLECLEARALL)

For i = 1 To 100

 Ascii = Random(125, 32)
 
 If Sentence = 40
  Text$ + #CRLF$
  Sentence = 0
 Else
  Sentence + 1 
 EndIf
 
 Text$ + Chr(Ascii)
 
Next
Text$ + "Coucou"
For i = 1 To 200

 Ascii = Random(125, 32)
 
 If Sentence = 40
  Text$ + #CRLF$
  Sentence = 0
 Else
  Sentence + 1 
 EndIf
 
 Text$ + Chr(Ascii)
 
Next

*t = UTF8(Text$)
ScintillaSendMessage(1, #SCI_SETTEXT, 0, *t)
FreeMemory(*t) 

#StyleRouge = 1
#StyleBleu = 2

ScintillaSendMessage(1, #SCI_STYLESETFORE, #StyleRouge, #Red)
ScintillaSendMessage(1, #SCI_STYLESETFORE, #StyleBleu, #Blue)
	
; <== This is a dirty hack ==> 
Dim MyColor(1300) 
MyColor(1) = #Red 
MyColor(2) = #Blue

; Creation des STYLES
ScintillaSendMessage(1, #SCI_STYLESETFORE, #StyleRouge, MyColor(1))
ScintillaSendMessage(1, #SCI_STYLESETFORE, #StyleBleu, MyColor(2))

StartStyling = 5
SizeStyling = 10
ScintillaSendMessage(1, #SCI_STYLESETITALIC, #StyleRouge, #True) 
ScintillaSendMessage(1, #SCI_STYLESETBOLD, #StyleRouge, #True) 
ScintillaSendMessage(1, #SCI_STARTSTYLING, StartStyling, #StyleRouge)  ; Color is the index of the Array (see Dim Mycolor() 
ScintillaSendMessage(1, #SCI_SETSTYLING, SizeStyling, #StyleRouge)   ; 

StartStyling = 30
SizeStyling = 10
ScintillaSendMessage(1, #SCI_STYLESETITALIC, #StyleRouge, #False) 
ScintillaSendMessage(1, #SCI_STYLESETBOLD, #StyleRouge, #False) 
ScintillaSendMessage(1, #SCI_STARTSTYLING, StartStyling, #StyleRouge)  ; Color is the index of the Array (see Dim Mycolor() 
ScintillaSendMessage(1, #SCI_SETSTYLING, SizeStyling, #StyleRouge)   ; 

StartStyling = 60
SizeStyling = 10
ScintillaSendMessage(1, #SCI_STYLESETITALIC, #StyleBleu, #False) 
ScintillaSendMessage(1, #SCI_STYLESETBOLD, #StyleBleu, #False) 
ScintillaSendMessage(1, #SCI_STARTSTYLING, StartStyling, #StyleBleu)  ; Color is the index of the Array (see Dim Mycolor() 
ScintillaSendMessage(1, #SCI_SETSTYLING, SizeStyling, #StyleBleu)   ; 

StartStyling = 110
SizeStyling = 10
ScintillaSendMessage(1, #SCI_STYLESETITALIC, #StyleBleu, #True) 
ScintillaSendMessage(1, #SCI_STYLESETBOLD, #StyleBleu, #True) 
ScintillaSendMessage(1, #SCI_STARTSTYLING, StartStyling, #StyleBleu)  ; Color is the index of the Array (see Dim Mycolor() 
ScintillaSendMessage(1, #SCI_SETSTYLING, SizeStyling, #StyleBleu)   ; 

Repeat  
 
 Evenement = WaitWindowEvent()
 
Until Evenement = #PB_Event_CloseWindow
Seriously....can't update or delete a STYLE...then the number of style is limited, it's iincredible, I'm really disappointed :|
Furthermore, not simply can change a part of text, like in EditorGadget
Since all the time i heard talking of this "Merveillous" library, even if it's difficult to use, never i believed it has so limited
ImageThe happiness is a road...
Not a destination
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Scintilla change STYLE of part of text on the fly [Resolved]

Post by boddhi »

I've tested from 5.73 to 6.10 and the behaviour is normal since 6.03.

I think it's due to new Scintilla 5.3.5 on all platforms update with this latter...
Maybe, try to change lib version used with your PB 5.73 or adapt your code with a PB version higher than 6.02...
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5500
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Scintilla change STYLE of part of text on the fly [Resolved]

Post by Kwai chang caine »

It's a good idea, thanks for share it :idea:

The problem is i'm affraid to think that is also "simple" to change the version, than use the library :lol:
I have see, there are a scintilla.dll in pb.exe folder, but also a scintilla.lib and scintilla.exp, and i not see the same files in the new Scintilla
Never mind, i create numerous STYLES :|

I feel that "thanks" to Scintilla, I'm going to be the new one Jean paul of the programmation :mrgreen:

Image
ImageThe happiness is a road...
Not a destination
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Scintilla change STYLE of part of text on the fly [Resolved]

Post by boddhi »

Kwai chang caine wrote: The problem is i'm affraid to think that is also "simple" to change the version, than use the library :lol:
And adapt your code to more recent PB version would be so difficult or complicated?

Impossible n'est pas FRANÇAIS !!!
Image
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Post Reply