Mercurial Hosting > editor
changeset 84:eb6c42083100 default tip
open multiple files
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 26 Jun 2025 23:14:21 -0600 |
parents | b9be4afaf597 |
children | |
files | src/luan_editor/Window.luan |
diffstat | 1 files changed, 22 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan_editor/Window.luan Mon Jun 23 15:22:40 2025 -0600 +++ b/src/luan_editor/Window.luan Thu Jun 26 23:14:21 2025 -0600 @@ -133,7 +133,21 @@ local dark_blue = int_to_color(0x0000C0) local grey = int_to_color(0x888888) -local function new_window(file,document) +local new_window + +local function open_files(files) + local fn = thread_safe_function( new_window ) + Thread.run( function() + for _, file in ipairs(files) do + swing_run( function() + fn(file) + end ) + sleep(100) + end + end, true ) +end + +function new_window(file,document) local window = {} if file == nil or not file.exists() then window.has_file = false @@ -258,24 +272,24 @@ return title end function window.open() - local new_file = choose_file{ + local new_files = choose_file{ action = "load" parent = frame directory = file and file.parent() + multiple = true } - if new_file ~= nil then - new_window(new_file) - end + open_files(new_files) end function window.save() if file == nil then - file = choose_file{ + local files = choose_file{ action = "save" parent = frame } - if file == nil then + if #files == 0 then return false end + file = files[1] title = file.canonical().to_string() documents[title] = { document = text_area.document, count = 1 } window.is_unedited = nil @@ -376,15 +390,7 @@ if files == nil then return false end - local fn = thread_safe_function( new_window ) - Thread.run( function() - for _, file in ipairs(files) do - swing_run( function() - fn(file) - end ) - sleep(100) - end - end, true ) + open_files(files) return true end local add_menu_bar = require "classpath:luan_editor/menu.luan"