comparison src/luan_editor/window.luan @ 48:ca5ae0a36db7

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 20 May 2025 20:16:58 -0600
parents f66f704118e3
children c17c5312e8de
comparison
equal deleted inserted replaced
47:f66f704118e3 48:ca5ae0a36db7
150 end 150 end
151 end 151 end
152 end 152 end
153 text_area.set_selection(0) 153 text_area.set_selection(0)
154 local list_window_item = { 154 local list_window_item = {
155 text = title 155 --text = title
156 window = window 156 window = window
157 } 157 }
158 add_list_window_item(list_window_item) 158 add_list_window_item(list_window_item)
159 local status_bar = new_label{ 159 local status_bar = new_label{
160 constraints = "span,growx" 160 constraints = "span,growx"
212 local s = title 212 local s = title
213 if not is_unedited then 213 if not is_unedited then
214 s = s.." *" 214 s = s.." *"
215 end 215 end
216 frame.title = s 216 frame.title = s
217 list_window_item.text = title
217 list_window_item.foreground_color = is_unedited and black or dark_blue 218 list_window_item.foreground_color = is_unedited and black or dark_blue
218 list_view.repaint(list_window_item) 219 list_view.repaint(list_window_item)
219 end 220 end
220 undo_listener() 221 undo_listener()
221 --window.undo_listener = undo_listener -- dont gc 222 --window.undo_listener = undo_listener -- dont gc
222 text_area.document.add_undo_listener(undo_listener) 223 text_area.document.add_undo_listener(undo_listener)
223 window.new = new_window 224 window.new = new_window
225 function window.title()
226 return title
227 end
224 function window.open() 228 function window.open()
225 local new_file = choose_file{ 229 local new_file = choose_file{
226 action = "load" 230 action = "load"
227 parent = frame 231 parent = frame
228 directory = file and file.parent() 232 directory = file and file.parent()
239 } 243 }
240 if file == nil then 244 if file == nil then
241 return false 245 return false
242 end 246 end
243 title = file.canonical().to_string() 247 title = file.canonical().to_string()
244 frame.title = title
245 documents[title] = text_area.document 248 documents[title] = text_area.document
249 window.is_unedited = nil
250 undo_listener()
246 end 251 end
247 try 252 try
248 file.write_text(text_area.text) 253 file.write_text(text_area.text)
249 catch e 254 catch e
250 show_message_dialog( frame, e.get_message() ) 255 show_message_dialog( frame, e.get_message() )