Shardik
Code: Select all
SendMessage_(GadgetID(EditorGadgetID), #EM_SETSEL, -1, -1)
SendMessage_(GadgetID(EditorGadgetID), #EM_REPLACESEL, 0,
AttributeTextASCII)
I tried, but this method works slowly and everything blinks at the moment the style of each word changes. I used it like this:
Code: Select all
ForEach TotalList()
RTFcode$ + "\cf2" + TotalList()\path + "\cf0" + #CRLF$
ForEach TotalList()\find()
RTFcode$ + TotalList()\find()\stringStart
RTFcode$ + "\cf1" + TotalList()\find()\found + "\cf0"
RTFcode$ + TotalList()\find()\stringEnd + #CRLF$
Next
RTFcode$ + #CRLF$
Next
complete example
Code: Select all
; Generating RTF code from search results located in an array
If ListSize(TotalList())
ForEach TotalList()
i + 1
RTFcode$ + #CRLF$ + Chr(1) + "cf2 " + Str(i) + ". " + Mid(TotalList()\path, LenForTrim) + Chr(1) + "cf0 " + #CRLF$ ; path
j = 0
ForEach TotalList()\find()
j + 1
RTFcode$ + Chr(1) + "cf3 " + Str(j) + " -->| " + Chr(1) + "cf0 " + TotalList()\find()\stringStart +
Chr(1) + "cf1 " + TotalList()\find()\found +
Chr(1) + "cf0 " + TotalList()\find()\stringEnd + #CRLF$
Next
; RTFcode$ + #CRLF$
Next
EndIf
; Escape metacharacters in the text that RTF will consider as code
RTFcode$ = ReplaceString(RTFcode$, "\", "\\", #PB_String_CaseSensitive)
RTFcode$ = ReplaceString(RTFcode$, "{", "\{", #PB_String_CaseSensitive)
RTFcode$ = ReplaceString(RTFcode$, "}", "\}", #PB_String_CaseSensitive)
; Restoring the previously imported RTF code
RTFcode$ = ReplaceString(RTFcode$, Chr(1), "\", #PB_String_CaseSensitive)
; replacing unreadable characters with questions, otherwise the text is not inserted into RichEdit after the first unreadable character encountered
re = CreateRegularExpression(#PB_Any, "[\001-\007\010\016\017\020-\027\030-\037\177]+") ; I removed \000 because it won’t appear here
If re
RTFcode$ = ReplaceRegularExpression(re, RTFcode$, Chr($25A1))
FreeRegularExpression(re)
EndIf
RTFcode$ = ReplaceString(RTFcode$, #CRLF$, "\par " + #CRLF$, #PB_String_CaseSensitive) ; replace word wrap with paragraph metacharacter
RTFcode$ = ReplaceString(RTFcode$, #TAB$, "\tab ", #PB_String_CaseSensitive) ; replace tabs with tab metacharacter
; add a header to the processed code
If iniFontSize
Font = iniFontSize * 2
Else
Font = 18
EndIf
; \fswiss instead of \fnil
RTFColorTable$ = "\red255\green0\blue0;" + ; red
"\red0\green0\blue255;" + ; blue
"\red99\green99\blue99;" ; grey
RTFcode$ = "{\rtf1\ansi\ansicpg1251\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset204 Arial;}}" + ; Arial font
"{\colortbl;" + RTFColorTable$ + "}{\*\generator Riched20 10.0.16299}\viewkind4\uc1\pard\f0\fs" + Font + ; font size 18
RTFcode$ + "}"
SetGadgetText(#Edit, RTFcode$)
I don't know if I should get GetACP_() instead of ansicpg1251. When I change the code page to 1252, the operating system still uses 1251 by default.
Using the
TextReplace program, I made the output in RTF (Windows), in Scintilla (Linux), in HTML (Windows, Linux)
I tried your code on Linux, but for some reason when I re-create a child window with text, the text is not highlighted.
Code: Select all
If ListSize(TotalList())
ForEach TotalList()
i + 1
AddTextWithAttributes(#Edit, #CRLF$ + "[bu]" + Str(i) + ". " + Mid(TotalList()\path, LenForTrim) + "[bu]" + #CRLF$)
j = 0
ForEach TotalList()\find()
j + 1
AddTextWithAttributes(#Edit, Str(j) + " -->| " + TotalList()\find()\stringStart +
"[bu]" + TotalList()\find()\found + "[bu]" +
TotalList()\find()\stringEnd + #CRLF$)
Next
Next
EndIf