File: w_replace.srw
Size: 12285
Date: Mon, 08 Jul 2019 20:17:00 +0200
$PBExportHeader$w_replace.srw
forward
global type w_replace from window
end type
type cbx_ignorecomment from checkbox within w_replace
end type
type cbx_regex from checkbox within w_replace
end type
type cbx_withcrlf from checkbox within w_replace
end type
type cb_replaceall from commandbutton within w_replace
end type
type st_with from statictext within w_replace
end type
type ddlb_replace from u_ddlb_history within w_replace
end type
type cb_replace from commandbutton within w_replace
end type
type ddlb_find from u_ddlb_history within w_replace
end type
type cbx_wordstart from checkbox within w_replace
end type
type cbx_backwards from checkbox within w_replace
end type
type cbx_whole from checkbox within w_replace
end type
type cbx_case from checkbox within w_replace
end type
type st_replace from statictext within w_replace
end type
type cb_close from commandbutton within w_replace
end type
type cb_findnext from commandbutton within w_replace
end type
end forward

global type w_replace from window
integer width = 1806
integer height = 788
boolean titlebar = true
string title = "Replace Text"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cbx_ignorecomment cbx_ignorecomment
cbx_regex cbx_regex
cbx_withcrlf cbx_withcrlf
cb_replaceall cb_replaceall
st_with st_with
ddlb_replace ddlb_replace
cb_replace cb_replace
ddlb_find ddlb_find
cbx_wordstart cbx_wordstart
cbx_backwards cbx_backwards
cbx_whole cbx_whole
cbx_case cbx_case
st_replace st_replace
cb_close cb_close
cb_findnext cb_findnext
end type
global w_replace w_replace

type variables

end variables

on w_replace.create
this.cbx_ignorecomment=create cbx_ignorecomment
this.cbx_regex=create cbx_regex
this.cbx_withcrlf=create cbx_withcrlf
this.cb_replaceall=create cb_replaceall
this.st_with=create st_with
this.ddlb_replace=create ddlb_replace
this.cb_replace=create cb_replace
this.ddlb_find=create ddlb_find
this.cbx_wordstart=create cbx_wordstart
this.cbx_backwards=create cbx_backwards
this.cbx_whole=create cbx_whole
this.cbx_case=create cbx_case
this.st_replace=create st_replace
this.cb_close=create cb_close
this.cb_findnext=create cb_findnext
this.Control[]={this.cbx_ignorecomment,&
this.cbx_regex,&
this.cbx_withcrlf,&
this.cb_replaceall,&
this.st_with,&
this.ddlb_replace,&
this.cb_replace,&
this.ddlb_find,&
this.cbx_wordstart,&
this.cbx_backwards,&
this.cbx_whole,&
this.cbx_case,&
this.st_replace,&
this.cb_close,&
this.cb_findnext}
end on

on w_replace.destroy
destroy(this.cbx_ignorecomment)
destroy(this.cbx_regex)
destroy(this.cbx_withcrlf)
destroy(this.cb_replaceall)
destroy(this.st_with)
destroy(this.ddlb_replace)
destroy(this.cb_replace)
destroy(this.ddlb_find)
destroy(this.cbx_wordstart)
destroy(this.cbx_backwards)
destroy(this.cbx_whole)
destroy(this.cbx_case)
destroy(this.st_replace)
destroy(this.cb_close)
destroy(this.cb_findnext)
end on

event open;Long ll_len

gn_app.ii_replaced = -1

If Len(gn_app.is_findstr) > 0 Then
   If gn_app.ib_RegEx = False Then
      ddlb_find.text = gn_app.is_findstr
      ddlb_find.AddItem(gn_app.is_findstr)
   End If
End If

cbx_case.checked           = gn_app.ib_MatchCase
cbx_whole.checked          = gn_app.ib_WholeWord
cbx_wordstart.checked      = gn_app.ib_WordStart
cbx_regex.checked          = gn_app.ib_RegEx
cbx_backwards.checked      = gn_app.ib_Backwards
cbx_ignorecomment.checked  = gn_app.ib_IgnoreComment

ll_len = Len(ddlb_find.Text)
If ll_len = 0 Then
   ddlb_find.of_load("find_string", True)
Else
   ddlb_find.SelectText(1, ll_len + 1)
   ddlb_find.of_load("find_string", False)
End If

If Len(ddlb_find.Text) > 0 Then
   cb_findnext.enabled = True
End If

ddlb_replace.of_load("replace_string", True)

ddlb_find.Event EditChanged()

end event

event close;gw_frame.SetFocus()
gw_frame.uo_editor.SetFocus()

end event

type cbx_ignorecomment from checkbox within w_replace
integer x = 622
integer y = 480
integer width = 517
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Ignore Comment"
end type

type cbx_regex from checkbox within w_replace
integer x = 37
integer y = 480
integer width = 535
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Regular Expression"
end type

type cbx_withcrlf from checkbox within w_replace
integer x = 37
integer y = 576
integer width = 581
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Append CRLF to With"
end type

type cb_replaceall from commandbutton within w_replace
integer x = 1390
integer y = 304
integer width = 334
integer height = 92
integer taborder = 50
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
boolean enabled = false
string text = "Replace &All"
end type

event clicked;// replace the current text

Integer li_hits
String ls_replace

gn_app.is_findstr = ddlb_find.text

gn_app.ib_MatchCase     = cbx_case.checked
gn_app.ib_WholeWord     = cbx_whole.checked
gn_app.ib_WordStart     = cbx_wordstart.checked
gn_app.ib_RegEx         = cbx_regex.checked
gn_app.ib_Backwards     = cbx_backwards.checked
gn_app.ib_IgnoreComment = cbx_ignorecomment.checked

ls_replace = ddlb_replace.text
If cbx_withcrlf.checked Then
   ls_replace = ls_replace + "~r~n"
End If

ddlb_find.of_save("find_string")
ddlb_replace.of_save("replace_string")

gn_app.ii_replaced = 0

w_main.uo_editor.of_SetFindOptions(gn_app.ib_MatchCase, gn_app.ib_WholeWord, &
                     gn_app.ib_WordStart, gn_app.ib_RegEx, &
                     gn_app.ib_Backwards, gn_app.ib_IgnoreComment)

li_hits = w_main.uo_editor.of_ReplaceAll(ddlb_find.text, ls_replace)

gn_app.ii_replaced = li_hits

Close(Parent)

end event

type st_with from statictext within w_replace
integer x = 37
integer y = 172
integer width = 219
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "W&ith:"
boolean focusrectangle = false
end type

type ddlb_replace from u_ddlb_history within w_replace
integer x = 256
integer y = 164
integer width = 1065
integer taborder = 20
boolean autohscroll = true
integer accelerator = 105
end type

type cb_replace from commandbutton within w_replace
integer x = 1390
integer y = 168
integer width = 334
integer height = 92
integer taborder = 40
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
boolean enabled = false
string text = "&Replace"
end type

event clicked;// replace the current text

String ls_replace

gn_app.is_findstr = ddlb_find.text

gn_app.ib_MatchCase     = cbx_case.checked
gn_app.ib_WholeWord     = cbx_whole.checked
gn_app.ib_WordStart     = cbx_wordstart.checked
gn_app.ib_RegEx         = cbx_regex.checked
gn_app.ib_Backwards     = cbx_backwards.checked
gn_app.ib_IgnoreComment = cbx_ignorecomment.checked

ls_replace = ddlb_replace.text
If cbx_withcrlf.checked Then
   ls_replace = ls_replace + "~r~n"
End If

ddlb_find.of_save("find_string")
ddlb_replace.of_save("replace_string")

If w_main.uo_editor.of_CanCopy() Then
   w_main.uo_editor.of_ReplaceSelectedText(ls_replace)
End If

w_main.Event m_findnext()

end event

type ddlb_find from u_ddlb_history within w_replace
integer x = 256
integer y = 36
integer width = 1065
boolean autohscroll = true
integer accelerator = 101
end type

event editchanged;call super::editchanged;If this.text = "" Then
   cb_findnext.enabled = False
   cb_findnext.default = False
   cb_replace.enabled = False
   cb_replace.default = False
   cb_replaceall.enabled = False
   cb_replaceall.default = False
Else
   cb_findnext.enabled = True
   cb_replace.enabled = True
   cb_replaceall.enabled = True
   cb_replaceall.default = True
End If

end event

event selectionchanged;call super::selectionchanged;this.Event EditChanged()

end event

type cbx_wordstart from checkbox within w_replace
integer x = 622
integer y = 384
integer width = 517
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Word Starts With"
end type

type cbx_backwards from checkbox within w_replace
integer x = 622
integer y = 288
integer width = 517
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Search Backwards"
end type

type cbx_whole from checkbox within w_replace
integer x = 37
integer y = 384
integer width = 370
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Whole word"
end type

type cbx_case from checkbox within w_replace
integer x = 37
integer y = 288
integer width = 370
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Match case"
end type

type st_replace from statictext within w_replace
integer x = 37
integer y = 48
integer width = 219
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "R&eplace:"
boolean focusrectangle = false
end type

type cb_close from commandbutton within w_replace
integer x = 1390
integer y = 552
integer width = 334
integer height = 92
integer taborder = 60
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "&Close"
boolean cancel = true
end type

event clicked;Close(Parent)

end event

type cb_findnext from commandbutton within w_replace
integer x = 1390
integer y = 32
integer width = 334
integer height = 92
integer taborder = 30
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
boolean enabled = false
string text = "&Find Next"
boolean default = true
end type

event clicked;gn_app.is_findstr = ddlb_find.text

gn_app.ib_MatchCase     = cbx_case.checked
gn_app.ib_WholeWord     = cbx_whole.checked
gn_app.ib_WordStart     = cbx_wordstart.checked
gn_app.ib_RegEx         = cbx_regex.checked
gn_app.ib_Backwards     = cbx_backwards.checked
gn_app.ib_IgnoreComment = cbx_ignorecomment.checked

ddlb_find.of_save("find_string")
ddlb_replace.of_save("replace_string")

w_main.Event m_findnext()

cb_replace.enabled = True
cb_replace.default = True

end event