comparison src/luan_editor/window.luan @ 42:b76918e3e77c

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 18 May 2025 14:37:06 -0600
parents f7e8c1f532c8
children 48c35fdccb31
comparison
equal deleted inserted replaced
41:f7e8c1f532c8 42:b76918e3e77c
62 config_file.write_text( stringify(config).."\n" ) 62 config_file.write_text( stringify(config).."\n" )
63 end 63 end
64 64
65 local list_view = new_panel{ 65 local list_view = new_panel{
66 --layout = new_mig_layout("insets 0,wrap,fill") 66 --layout = new_mig_layout("insets 0,wrap,fill")
67 layout = new_mig_layout("wrap","[grow]") 67 layout = new_mig_layout("wrap,debug","[grow]")
68 } 68 }
69 local list_scroll_pane = new_scroll_pane{ 69 local list_scroll_pane = new_scroll_pane{
70 view = list_view 70 view = list_view
71 } 71 }
72 local list_window = new_dialog{ 72 local list_window = new_dialog{
73 preferred_size = { width=200, height=400 } 73 preferred_size = { width=200, height=400 }
74 content_pane = list_scroll_pane 74 content_pane = list_scroll_pane
75 } 75 }
76 local list_group = new_button_group() 76 local list_group = new_button_group()
77
77 local function new_list_window_item(text) 78 local function new_list_window_item(text)
78 local rb = new_radio_button{ 79 local rb = new_radio_button{
79 constraints = "grow" 80 constraints = "grow"
80 text = text 81 text = text
81 horizontal_text_position = "left" 82 horizontal_text_position = "left"
84 list_view.add(rb) 85 list_view.add(rb)
85 list_group.add(rb) 86 list_group.add(rb)
86 list_scroll_pane.scroll_to_right() 87 list_scroll_pane.scroll_to_right()
87 list_window.pack() 88 list_window.pack()
88 return rb 89 return rb
90 end
91 local function remove_list_window_item(list_window_item)
92 list_view.remove(list_window_item)
93 list_group.remove(list_window_item)
94 list_window.pack()
95 list_window.repaint()
89 end 96 end
90 97
91 local function new_window(file,document) 98 local function new_window(file,document)
92 local window = {} 99 local window = {}
93 if file == nil or not file.exists() then 100 if file == nil or not file.exists() then
157 frame.add_close_listener(function() 164 frame.add_close_listener(function()
158 n_windows = n_windows - 1 165 n_windows = n_windows - 1
159 if n_windows == 0 then 166 if n_windows == 0 then
160 Luan.exit() 167 Luan.exit()
161 end 168 end
169 remove_list_window_item(window.list_window_item)
162 end) 170 end)
163 frame.add_resize_stopped_listener( 200, function() 171 frame.add_resize_stopped_listener( 200, function()
164 --logger.info(stringify(frame.size)) 172 --logger.info(stringify(frame.size))
165 config.size = frame.size 173 config.size = frame.size
166 save_config() 174 save_config()
174 local s = title 182 local s = title
175 if not text_area.document.is_unedited() then 183 if not text_area.document.is_unedited() then
176 s = s.." *" 184 s = s.." *"
177 end 185 end
178 frame.title = s 186 frame.title = s
179 new_list_window_item(title)
180 end 187 end
181 set_title() 188 set_title()
189 window.list_window_item = new_list_window_item(title)
182 window.set_title = set_title -- dont gc 190 window.set_title = set_title -- dont gc
183 text_area.document.add_undo_listener(set_title) 191 text_area.document.add_undo_listener(set_title)
184 window.new = new_window 192 window.new = new_window
185 function window.open() 193 function window.open()
186 local new_file = choose_file{ 194 local new_file = choose_file{