Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sets the color for specific text within the RichEdit control
#4
Scintilla documentation:
https://www.scintilla.org/ScintillaDoc.html

Example:
Function example_dialog_scintilla
Code:
Copy      Help
out

str text=
;aaa [[blue]] bbb
;ccc [[orange]] ddd
;ddd [[blue]] ddd
;

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 336 208 "Dialog" "4"
;3 Scintilla 0x54000000 0x20000 60 0 276 202 ""
;4 Button 0x54032000 0x0 4 4 48 14 "Clear"
;5 Button 0x54032000 0x0 4 24 48 14 "Update"
;1 Button 0x54030001 0x4 4 172 48 14 "OK"
;2 Button 0x54030000 0x4 4 188 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

int sci
int indicBlue(0) indicOrange(1)

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,sci=id(3 hDlg)
,
,sub.DefineIndicator(indicBlue 0xff0000)
,sub.DefineIndicator(indicOrange 0x00e0ff)
,
,sub.SetText(text)
,
,sub.SetIndicator(indicBlue "[[blue]]")
,sub.SetIndicator(indicOrange "[[orange]]")
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;Clear
,sub.ClearIndicator(indicBlue)
,sub.ClearIndicator(indicOrange)
,case 5 ;;Update
,sub.ClearIndicator(indicBlue)
,sub.ClearIndicator(indicOrange)
,sub.SetIndicator(indicBlue "[[blue]]")
,sub.SetIndicator(indicOrange "[[orange]]")
,
ret 1
;messages3
SCI.SCNotification* k=+lParam
sel k.nmhdr.code
,case SCI.SCN_MODIFIED
,if k.modificationType&(SCI.SC_MOD_INSERTTEXT|SCI.SC_MOD_DELETETEXT)
,,out "modified"


#sub Sci v
function# message [param1] [param2]
ret SendMessage(sci message param1 param2)

#sub Sci2 v
function# message [param1] [$text]
ret SendMessage(sci message param1 text)

#sub DefineIndicator v
function indicator color
sub.Sci(SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX)
sub.Sci(SCI.SCI_INDICSETFORE indicator color)
sub.Sci(SCI.SCI_INDICSETUNDER indicator 1)
sub.Sci(SCI.SCI_INDICSETALPHA indicator 128)

#sub SetIndicator v
function indicator $s
str text; sub.GetText(text)
int i n
rep
,i=find(text s i+n); if(i<0) break
,n=len(s)
,sub.Sci(SCI.SCI_SETINDICATORCURRENT indicator)
,sub.Sci(SCI.SCI_INDICATORFILLRANGE i n)

#sub ClearIndicator v
function indicator
sub.Sci(SCI.SCI_SETINDICATORCURRENT indicator)
sub.Sci(SCI.SCI_INDICATORCLEARRANGE 0 SendMessage(sci SCI.SCI_GETTEXTLENGTH 0 0))

#sub GetText v
function str&text
int n=SendMessage(sci SCI.SCI_GETTEXTLENGTH 0 0)
text.fix(SendMessage(sci SCI.SCI_GETTEXT n text.all(n)))

#sub SetText v
function $text
sub.Sci2(SCI.SCI_SETTEXT 0 text)


Messages In This Thread
RE: Sets the color for specific text within the RichEdit control - by Gintaras - 09-02-2022, 12:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)