Mercurial Hosting > editor
diff src/luan_editor/Window.luan @ 75:7f5b3824f4d4
add Windows
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 18 Jun 2025 18:57:34 -0600 |
parents | e972fb08a574 |
children | 1beb4c57c269 |
line wrap: on
line diff
--- a/src/luan_editor/Window.luan Tue Jun 17 13:00:25 2025 -0600 +++ b/src/luan_editor/Window.luan Wed Jun 18 18:57:34 2025 -0600 @@ -12,6 +12,9 @@ local replace = String.replace or error() local starts_with = String.starts_with or error() local Io = require "luan:Io.luan" +local Thread = require "luan:Thread.luan" +local sleep = Thread.sleep or error() +local thread_safe_function = Thread.thread_safe_function or error() local new_file = Io.schemes.file or error() local new_text_area = require("luan:swing/Text_area.luan").new or error() local new_frame = require("luan:swing/Frame.luan").new or error() @@ -32,6 +35,8 @@ local Option_pane = require "luan:swing/Option_pane.luan" local show_message_dialog = Option_pane.show_message_dialog or error() local Clipboard = require "luan:swing/Clipboard.luan" +local Swing_runner = require "luan:swing/Swing_runner.luan" +local swing_run = Swing_runner.run or error() local Java = require "classpath:luan_editor/Java.luan" local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "editor/Window" @@ -50,7 +55,7 @@ end end -local config_file = Io.uri("file:"..Java.home_dir.."/.luan_editor/config.json") +local config_file = Io.uri("file:"..Java.config_path) local config = {} if config_file.exists() then try @@ -363,9 +368,15 @@ if files == nil then return false end - for _, file in ipairs(files) do - new_window(file) - 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 ) return true end local add_menu_bar = require "classpath:luan_editor/menu.luan" @@ -382,16 +393,14 @@ end Window.new_window = new_window -function Window.open_windows(file_paths) - list_window.to_front() - for _, file_path in ipairs(file_paths) do - local file = new_file(file_path) - new_window(file) - end - if #file_paths == 0 then +function Window.open_window(file_path) + if file_path == nil then local window = list_view.selected_value.window window.frame.to_front() window.text_area.request_focus_in_window() + else + local file = new_file(file_path) + new_window(file) end end