comparison src/luan_editor/find.luan @ 88:9d32b7115fd1 default tip

better replace
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 27 Jun 2025 23:18:08 -0600
parents bf1046456ce9
children
comparison
equal deleted inserted replaced
87:bf1046456ce9 88:9d32b7115fd1
17 local Swing = require "luan:swing/Swing.luan" 17 local Swing = require "luan:swing/Swing.luan"
18 local browse = Swing.browse or error() 18 local browse = Swing.browse or error()
19 19
20 20
21 local find_text = "" 21 local find_text = ""
22 local replace_text = ""
22 23
23 local function get_matches(text,s) 24 local function get_matches(text,s)
24 local r = regex(s) 25 local r = regex(s)
25 local matches = {} 26 local matches = {}
26 local i = 1 27 local i = 1
103 local find = find_field.text 104 local find = find_field.text
104 if #find == 0 then 105 if #find == 0 then
105 status_bar.text = " " 106 status_bar.text = " "
106 return 107 return
107 end 108 end
109 local replace = replace_field.text
108 find_text = find 110 find_text = find
109 local replace = replace_field.text 111 replace_text = replace
110 if not regex_check_box.is_selected then 112 if not regex_check_box.is_selected then
111 find = regex_quote(find) 113 find = regex_quote(find)
112 replace = regex_quote_replacement(replace) 114 replace = regex_quote_replacement(replace)
113 end 115 end
114 local r 116 local r
217 function window.show_find_panel() 219 function window.show_find_panel()
218 find_panel.is_visible = true 220 find_panel.is_visible = true
219 find_field.text = find_text 221 find_field.text = find_text
220 find_field.request_focus_in_window() 222 find_field.request_focus_in_window()
221 find_field.select_all() 223 find_field.select_all()
224 replace_field.text = replace_text
222 end 225 end
223 function window.hide_find_panel() 226 function window.hide_find_panel()
224 find_panel.is_visible = false 227 find_panel.is_visible = false
225 text_area.clear_hightlights() 228 text_area.clear_hightlights()
226 end 229 end