Mercurial Hosting > editor
comparison src/luan_editor/window.luan @ 46:1eef35fa48f3
list window config
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 19 May 2025 20:14:26 -0600 |
| parents | 0c83b27bb32d |
| children | f66f704118e3 |
comparison
equal
deleted
inserted
replaced
| 45:0c83b27bb32d | 46:1eef35fa48f3 |
|---|---|
| 56 end | 56 end |
| 57 config.size = config.size or { width=700, height=700 } | 57 config.size = config.size or { width=700, height=700 } |
| 58 config.line_wrap = bool( config.line_wrap, true ) | 58 config.line_wrap = bool( config.line_wrap, true ) |
| 59 config.whitespace_visible = bool( config.whitespace_visible, false ) | 59 config.whitespace_visible = bool( config.whitespace_visible, false ) |
| 60 config.tab_size = config.tab_size or 4 | 60 config.tab_size = config.tab_size or 4 |
| 61 config.list_window = config.list_window or {} | |
| 62 config.list_window.size = config.list_window.size or { width=200, height=400 } | |
| 61 | 63 |
| 62 local function save_config() | 64 local function save_config() |
| 63 config_file.write_text( stringify(config).."\n" ) | 65 config_file.write_text( stringify(config).."\n" ) |
| 64 end | 66 end |
| 65 | 67 |
| 69 } | 71 } |
| 70 local list_scroll_pane = new_scroll_pane{ | 72 local list_scroll_pane = new_scroll_pane{ |
| 71 view = list_view | 73 view = list_view |
| 72 } | 74 } |
| 73 local list_window = new_dialog{ | 75 local list_window = new_dialog{ |
| 74 --preferred_size = { width=200, height=400 } | 76 size = config.list_window.size |
| 75 size = { width=200, height=400 } | |
| 76 --maximum_size = { width=200, height=400 } | |
| 77 content_pane = list_scroll_pane | 77 content_pane = list_scroll_pane |
| 78 focusable_window_state = false | 78 focusable_window_state = false |
| 79 } | 79 } |
| 80 list_window.add_resize_stopped_listener( 200, function() | |
| 81 --logger.info(stringify(list_window.size)) | |
| 82 config.list_window.size = list_window.size | |
| 83 save_config() | |
| 84 end) | |
| 85 list_window.add_move_stopped_listener( 200, function() | |
| 86 --logger.info(stringify(list_window.location)) | |
| 87 config.list_window.location = list_window.location | |
| 88 save_config() | |
| 89 end) | |
| 80 local function show_list_window() | 90 local function show_list_window() |
| 91 local location = config.list_window.location | |
| 92 if location ~= nil then | |
| 93 list_window.location = location | |
| 94 end | |
| 81 list_window.visible = true | 95 list_window.visible = true |
| 82 list_scroll_pane.scroll_to_right() | 96 list_scroll_pane.scroll_to_right() |
| 83 end | 97 end |
| 84 | 98 |
| 85 local list_group = new_button_group() | 99 local list_group = new_button_group() |
| 327 new.text_area.set_selection( text_area.get_selection() ) | 341 new.text_area.set_selection( text_area.get_selection() ) |
| 328 end | 342 end |
| 329 window.show_list_window = show_list_window | 343 window.show_list_window = show_list_window |
| 330 add_menu_bar(window) | 344 add_menu_bar(window) |
| 331 frame.pack() | 345 frame.pack() |
| 332 if config.location ~= nil then | 346 local location = config.location |
| 333 frame.location = config.location | 347 if location ~= nil then |
| 348 frame.location = location | |
| 334 end | 349 end |
| 335 frame.visible = true | 350 frame.visible = true |
| 336 text_area.request_focus_in_window() | 351 text_area.request_focus_in_window() |
| 337 n_windows = n_windows + 1 | 352 n_windows = n_windows + 1 |
| 338 return window | 353 return window |
