12-15-2024, 05:06 PM
Pressing "find" in below dialog focusses on the first occurrence of 'abc'
But in line 3 there is an symbol that looks like a pipe (ASCII extended symbol 179) it causes incorrect selection of 'abc'
(remove the symbol on line 3 and it works)
Is there a solution/workaround? (I tried converting to other encoding and replacing characters outside basic ASCII with space: [^\x00-\x7F] used this regex)
Function test_find_setcaret_multiline2
But in line 3 there is an symbol that looks like a pipe (ASCII extended symbol 179) it causes incorrect selection of 'abc'
(remove the symbol on line 3 and it works)
Is there a solution/workaround? (I tried converting to other encoding and replacing characters outside basic ASCII with space: [^\x00-\x7F] used this regex)
Function test_find_setcaret_multiline2
str dd=
;BEGIN DIALOG
;0 "" 0x90CC0AC8 0x0 0 0 258 172 "Dialog" "4"
;3 Edit 0x54321044 0x200 21 2 230 102 ""
;6 Edit 0x54021846 0x204 3 2 18 104 ""
;4 Edit 0x54030080 0x200 58 111 96 12 ""
;5 Button 0x54032000 0x0 4 110 48 14 "find"
;7 Static 0x54000000 0x0 20 136 228 12 "│ <- Extended ASCII Code: [91]179] https://www.asciitable.com/"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""
str controls = "3 6 4"
str e3 e6 e4
e3=
;test line 1
;test line 2
;│
;test abc line 3
;test line 4
;test line 5
e4=
;abc
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- main_dlg
main_dlg=hDlg
sel message
,case WM_INITDIALOG
,,str t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
,,int i j k
,,SetTimer hDlg 1 50 &sub.Timer
,,int- black;black=ColorFromRGB(0 0 0)
,,int- blue;blue=ColorFromRGB(0 0 200)
,,__Font-- fnt_multiline fnt_title
,,fnt_multiline.CreateNew(hDlg "Courier New" 8 0)
,,fnt_multiline.SetDialogFont(hDlg F"6 3")
,,DT_SetTextColor hDlg black F"3"
,,DT_SetTextColor hDlg blue F"6"
,,sub.SetLineNumbers(hDlg 0)
,,DT_SetAutoSizeControls(hDlg "3s 6sv 5mv 4mv")
,case WM_DESTROY
,case WM_ACTIVATE
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case EN_CHANGE<<16|3
,,sub.SetLineNumbers(hDlg 0)
,case 5
,,act id(3 hDlg)
,,t0.getwintext(id(3 hDlg)) ;; TEXT
,,t1.getwintext(id(4 hDlg)) ;; KEYWORD
,,ARRAY(CHARRANGE) charranges
,,findrx(t0 F"\Q{t1}\E" 0 1|4|8 charranges)
,,_s.left(t0 charranges[0 0].cpMin)
,,k=numlines(_s)
,,SendDlgItemMessage hDlg 6 WM_VSCROLL MakeInt(SB_THUMBPOSITION k) 0
,,SendDlgItemMessage hDlg 3 WM_VSCROLL MakeInt(SB_THUMBPOSITION k) 0
,,SendMessage(id(3 hDlg) EM_SETSEL charranges[0 0].cpMin charranges[0 0].cpMax)
,,out F"selected range: {charranges[0 0].cpMin} - {charranges[0 0].cpMax}"
ret 1
#sub SetLineNumbers
function int'hDlg int'firstboot_set
int i
str get_lns set_lns
get_lns.getwintext(id(3 hDlg)) ;; TEXTVIEW
ARRAY(str) ln_arr.create(numlines(get_lns))
for i 0 ln_arr.len
,ln_arr[i]=i+1
_s=ln_arr
_s.setwintext(id(6 hDlg)) ;; LINENUMBERS
#sub Timer
function
int- main_dlg
int pos=GetScrollPos(id(3 main_dlg) SB_VERT) ;; TEXTVIEW MULTILINE
SendDlgItemMessage main_dlg 6 WM_VSCROLL MakeInt(SB_THUMBPOSITION pos) 0 ;; LINENUMBERS