Mercurial Hosting > editor
comparison src/luan_editor/find.luan @ 87:bf1046456ce9
better find
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 27 Jun 2025 23:08:34 -0600 |
parents | f4e393a13d59 |
children | 9d32b7115fd1 |
comparison
equal
deleted
inserted
replaced
86:b6ef6aaa9f29 | 87:bf1046456ce9 |
---|---|
16 local new_button = require("luan:swing/Button.luan").new or error() | 16 local new_button = require("luan:swing/Button.luan").new or error() |
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 = "" | |
22 | |
21 local function get_matches(text,s) | 23 local function get_matches(text,s) |
22 local r = regex(s) | 24 local r = regex(s) |
23 local matches = {} | 25 local matches = {} |
24 local i = 1 | 26 local i = 1 |
25 local n = #text | 27 local n = #text |
48 local s = find_field.text | 50 local s = find_field.text |
49 if #s == 0 then | 51 if #s == 0 then |
50 status_bar.text = " " | 52 status_bar.text = " " |
51 return | 53 return |
52 end | 54 end |
55 find_text = s | |
53 if not regex_check_box.is_selected then | 56 if not regex_check_box.is_selected then |
54 s = regex_quote(s) | 57 s = regex_quote(s) |
55 end | 58 end |
56 local matches | 59 local matches |
57 try | 60 try |
100 local find = find_field.text | 103 local find = find_field.text |
101 if #find == 0 then | 104 if #find == 0 then |
102 status_bar.text = " " | 105 status_bar.text = " " |
103 return | 106 return |
104 end | 107 end |
108 find_text = find | |
105 local replace = replace_field.text | 109 local replace = replace_field.text |
106 if not regex_check_box.is_selected then | 110 if not regex_check_box.is_selected then |
107 find = regex_quote(find) | 111 find = regex_quote(find) |
108 replace = regex_quote_replacement(replace) | 112 replace = regex_quote_replacement(replace) |
109 end | 113 end |
210 } | 214 } |
211 } | 215 } |
212 } | 216 } |
213 function window.show_find_panel() | 217 function window.show_find_panel() |
214 find_panel.is_visible = true | 218 find_panel.is_visible = true |
219 find_field.text = find_text | |
215 find_field.request_focus_in_window() | 220 find_field.request_focus_in_window() |
216 find_field.select_all() | 221 find_field.select_all() |
217 end | 222 end |
218 function window.hide_find_panel() | 223 function window.hide_find_panel() |
219 find_panel.is_visible = false | 224 find_panel.is_visible = false |