Scintilla find/replace

Just starting out? Need help? Post your questions and find answers here.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Scintilla find/replace

Post by dobro »

yes, I know, I hope Falsam change the code :)

for GoScintilla, I use for a longtime ago
unfortunately,
all the examples found, the search function requires a select the search term

My editor (EPB) based on Go_Scintilla
uses a window, or I send a search term (like jaPBe)
without that it is selected in the editor ...
(I grab the word present under the cursor)
and this term to send at the procedure of research ....

and this is the search procedure, which selects the term found in the editor

Finally, as same system research of jaPBe

I programmed a system that works, but unfortunately not with Accents ....
then, for spite, I go a fishing of any procedures done ...

I will end by banning the accents of my editor :lol:

Thanks :)


in French
oui , je sais , j'espere que Falsam modifiera le code :)

pour GoScintilla, je l'utilise depuis longtemps
malheuresement ,
tout les exemples trouvé, la fonction recherche oblige a selectionner le terme a rechercher

mon editeur (EPB) basé sur Go_Scintilla
utilise une fenetre , ou je transmet un terme a rechercher (comme Japbe)
sans que celui-ci ne soit selectionné dans l'editeur ...
(je recupere le terme présent sous le curseur )

et c'est la procedure de recherche, qui selectionne, le term trouvé dans l'editeur

enfin, comme lle systeme de recherche de Japbe

j'ai programmé un systeme qui fonctionne , mais malheuresement pas avec les Accents ....
alors , par depit , je part a la peche des procedures toute faites ...

Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Scintilla find/replace

Post by falsam »

GoScintilla Example

Code: Select all

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

Enumeration
  #Mainform
  #Editor
    
  #StringSearch
  #Search
  
EndEnumeration

;Initialise the Scintilla library for Windows.
CompilerIf  #PB_Compiler_OS = #PB_OS_Windows 
  InitScintilla()
CompilerEndIf


If OpenWindow(#Mainform, 100, 200, 600, 300, "Find Replace!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  ;Required for the tab key to function correctly when the Scintilla control has the focus.
  RemoveKeyboardShortcut(#Mainform, #PB_Shortcut_Tab)
  
  ;Search String
  TextGadget(#PB_Any, 10, 10, 80, 20, "Search")
  StringGadget(#StringSearch, 90, 10, 200, 22, "ignoré")
  ButtonGadget(#Search, 300, 10, 80, 22, "Search")
  
  ;Create our Scintilla control. Note that we do not specify a callback; this is optional for GoSctintilla.
  GOSCI_Create(#Editor, 10, 40, 580, 250, 0, #GOSCI_AUTOSIZELINENUMBERSMARGIN)
    
  ;Set the padding added to the width of the line-number margin.
  GOSCI_SetAttribute(#Editor, #GOSCI_LINENUMBERAUTOSIZEPADDING, 10)

  ;Set folding symbols margin width.
  GOSCI_SetMarginWidth(#Editor, #GOSCI_MARGINFOLDINGSYMBOLS, 24)

  ;Set the back color of the line containing the caret.
  GOSCI_SetColor(#Editor, #GOSCI_CARETLINEBACKCOLOR, $B4FFFF)

  ;Set font.
  GOSCI_SetFont(#Editor, "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(#Editor, 2)
  
  ;Set some initial text.
  text$ = "Cet espace sera ignoré lors de la compilation" + #CRLF$ +
          "Cet espace sera ignoré lors de la compilation" + #CRLF$ +  
          "Cet espace sera ignoré lors de la compilation" + #CRLF$
    
  GOSCI_SetText(#Editor, text$)
  
  SetActiveGadget(#Editor)
  ScintillaSendMessage(#Editor, #SCI_GOTOLINE, 0, 0)

  Repeat
    eventID = WaitWindowEvent()
    Select eventID
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Search
            SetActiveGadget(#Editor)
            GOSCI_Search(#Editor, GetGadgetText(#StringSearch), #GOSCI_SEARCHFORWARDS)
        EndSelect
    EndSelect
  Until eventID = #PB_Event_CloseWindow 

  ;Free the Scintilla gadget.
  GOSCI_Free(#Editor)
EndIf


➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Scintilla find/replace

Post by dobro »

disconcerting :shock:

I do not understand why my home on my editor, it does not work :?
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Scintilla find/replace

Post by falsam »

dobro wrote:I do not understand why my home on my editor, it does not work :?
When you start searching, gives focus to the editor.

Code: Select all

Case #Search
   SetActiveGadget(#Editor)
   GOSCI_Search(#Editor, GetGadgetText(#StringSearch), #GOSCI_SEARCHFORWARDS)

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Scintilla find/replace

Post by dobro »

And the problem is as follows:
And if the search term contains accents, selection by scintilla functions will not work
, Because the accents are two characters .... (UTF8)
, To know where to start the selection of search word
, I used FindString (), it no heed, double accented character
And for FindString (), an accented character is one character
, While for the type scintilla selections,

ScintillaSendMessage (tab # SCI_SETSELECTIONSTART, posf) selects there
ScintillaSendMessage (tab # SCI_SETSELECTIONEND, posf Longg +) was there!

an accented character is 2 character!
, we can not, then synchronize the two types of function and use ... FindString to know the departure of the selection that will make scintilla ...
; le probleme est le suivant :
; si le mot recherché contient des accents , la selection par les fonctions scintilla ne vont pas fonctionner
; car les accents prennent 2 caracteres....(UTF8)
; pour savoir ou commencer la selection du mot recherché,
; j'utilise, Findstring() , qui lui ne tiens pas compte ,des doubles caractere accentué
; pour Findstring(), un caractere accentué, c'est 1 caractere
; alors que , pour les selections de type scintilla ,

ScintillaSendMessage(onglet, #SCI_SETSELECTIONSTART, posf); selectionne de là
ScintillaSendMessage(onglet, #SCI_SETSELECTIONEND,posf+longg) ; a là !

un caractere accentué c'est 2 caractere !!
;on ne peux pas , alors synchroniser les 2 type de fonction...et utiliser findstring , pour connaitre le depart de la selection que scintilla devra faire ...
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Scintilla find/replace

Post by dobro »

littl video , show the problem of selection with Goscintilla and word emphasis
https://www.youtube.com/watch?v=3DQlH6_k-qwe
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Post Reply