Mercurial Hosting > editor
changeset 75:7f5b3824f4d4 default tip
add Windows
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 18 Jun 2025 18:57:34 -0600 |
parents | c3b0fba5c2bc |
children | |
files | scripts/luan_editor.sh scripts/mac/launcher scripts/windows/build.sh scripts/windows/installer.iss scripts/windows/launcher.vbs src/luan_editor/Java.luan src/luan_editor/Window.luan src/luan_editor/editor.luan |
diffstat | 8 files changed, 146 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/luan_editor.sh Tue Jun 17 13:00:25 2025 -0600 +++ b/scripts/luan_editor.sh Wed Jun 18 18:57:34 2025 -0600 @@ -1,9 +1,11 @@ #!/bin/bash set -e -DICTIONARIES="/Users/fschmidt/hg/editor/build/luan_editor/dictionaries/" +DIR="$(dirname $0)" -for i in "/Users/fschmidt/hg/editor/build/luan_editor"/jars/* ; do CLASSPATH="$CLASSPATH:$i" ; done +DICTIONARIES="$DIR/dictionaries/" + +for i in "$DIR"/jars/* ; do CLASSPATH="$CLASSPATH:$i" ; done CLASSPATH="$(echo -n "$CLASSPATH" | sed 's/^://')" mkdir -p ~/.luan_editor @@ -11,17 +13,7 @@ set +m if [[ "$(uname)" == "Darwin" ]]; then # Mac crap - function runJava() { - java -Ddictionaries="$DICTIONARIES" -Xdock:name="Luan Editor" -Duser.home="$HOME" -classpath "$CLASSPATH" luan.Luan classpath:luan_editor/editor.luan "$@" 2>&1 | grep --line-buffered -v 'NSRemoteView\|NSSavePanel' | tee ~/.luan_editor/error.log & - } - if [[ $# == 0 ]]; then - runJava - else - for file in "$@"; do - runJava "$file" - sleep 0.1 - done - fi + java -Ddictionaries="$DICTIONARIES" -Xdock:name="Luan Editor" -Duser.home="$HOME" -classpath "$CLASSPATH" luan.Luan classpath:luan_editor/editor.luan "$@" 2>&1 | grep --line-buffered -v 'NSRemoteView\|NSSavePanel' | tee ~/.luan_editor/error.log & else java -Duser.home="$HOME" -Ddictionaries="$DICTIONARIES" -classpath "$CLASSPATH" luan.Luan classpath:luan_editor/editor.luan "$@" 2>&1 | tee ~/.luan_editor/error.log & fi
--- a/scripts/mac/launcher Tue Jun 17 13:00:25 2025 -0600 +++ b/scripts/mac/launcher Wed Jun 18 18:57:34 2025 -0600 @@ -2,20 +2,14 @@ set -e -JDK_PATH="/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home" -JAVA_BIN="$JDK_PATH/bin/java" - -if [ ! -x "$JAVA_BIN" ]; then - if [[ $(uname -m) == "arm64" ]]; then - URL='https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=arm-64-bit&package=jdk#zulu' - else - URL='https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=x86-64-bit&package=jdk#zulu' - fi - /usr/bin/osascript -e "display dialog \"Luan Editor requires Zulu JDK 8.\n\nPlease install it from:\n$URL\" buttons {\"OK\"} default button \"OK\"" +if ! JAVA_HOME=$(/usr/libexec/java_home -v 1.8); then + URL="https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html" + osascript -e "display dialog \"Luan Editor requires JDK 8. Please install it from:\n\n$URL\" buttons {\"OK\"}" open "$URL" exit 1 fi +JAVA_BIN="$JAVA_HOME/bin/java" DIR="$(cd "$(dirname "$0")/../Resources" && pwd)"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/windows/build.sh Wed Jun 18 18:57:34 2025 -0600 @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +# assume that regular build.sh has been run + +cd "$(dirname $0)/../../build" + +rm -rf windows +mkdir windows + +cp ../scripts/windows/launcher.vbs windows +cp ../scripts/windows/installer.iss windows +cp -r luan_editor/jars windows +cp -r luan_editor/dictionaries windows + +cd windows +ISCC installer.iss + +cp LuanEditorInstaller.exe ../../website/src/download + +echo "finished windows build"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/windows/installer.iss Wed Jun 18 18:57:34 2025 -0600 @@ -0,0 +1,18 @@ +[Setup] +AppName=Luan Editor +AppVersion=1.0 +DefaultDirName={autopf}\LuanEditor +DefaultGroupName=Luan Editor +OutputBaseFilename=LuanEditorInstaller +OutputDir=. + +[Files] +Source: "launcher.vbs"; DestDir: "{app}"; Flags: ignoreversion +Source: "jars\*.jar"; DestDir: "{app}\jars"; Flags: ignoreversion +Source: "dictionaries\*"; DestDir: "{app}\dictionaries"; Flags: ignoreversion + +[Icons] +Name: "{group}\Luan Editor"; Filename: "{sysnative}\wscript.exe"; Parameters: """{app}\launcher.vbs""" + +[Run] +Filename: "{sysnative}\wscript.exe"; Parameters: """{app}\launcher.vbs"""; Description: "Run Luan Editor"; Flags: postinstall nowait skipifsilent
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/windows/launcher.vbs Wed Jun 18 18:57:34 2025 -0600 @@ -0,0 +1,42 @@ +' test with: wscript launcher.vbs +' compile with: ISCC installer.iss + +url = "https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html" + +Set shell = CreateObject("WScript.Shell") + +' Try to read Oracle JDK install path from registry +On Error Resume Next +jdkHome = shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8\JavaHome") +If jdkHome = "" Then + MsgBox "Oracle JDK 8 not found. Please install it from " & url, vbCritical, "Missing JDK" + shell.Run url + WScript.Quit 1 +End If +On Error GoTo 0 + +' Get the directory of this script +Set fso = CreateObject("Scripting.FileSystemObject") +scriptDir = fso.GetParentFolderName(WScript.ScriptFullName) + +' Build log path +logDir = shell.ExpandEnvironmentStrings("%LOCALAPPDATA%") & "\LuanEditor" +If Not fso.FolderExists(logDir) Then + fso.CreateFolder(logDir) +End If +logFile = logDir & "\error.log" + +configDir = shell.ExpandEnvironmentStrings("%APPDATA%") & "\LuanEditor" +If Not fso.FolderExists(configDir) Then + fso.CreateFolder(configDir) +End If +configFile = """" & configDir & "\config.json""" + +' Build and run the command +classpath = """" & scriptDir & "\jars\*.jar""" ' include all .jar files +dictionaries = """" & scriptDir & "\dictionaries\\""" +cmd = "cmd /c """"" & jdkHome & "\bin\java.exe"" -Dconfig=" & configFile & " -Ddictionaries=" & dictionaries & " -cp """ & scriptDir & "\jars\*"" luan.Luan classpath:luan_editor/editor.luan > """ & logFile & """ 2>&1""" +Set f = fso.OpenTextFile(logDir & "\debug_command.txt", 2, True) +f.WriteLine cmd +f.Close +shell.Run cmd, 0, False
--- a/src/luan_editor/Java.luan Tue Jun 17 13:00:25 2025 -0600 +++ b/src/luan_editor/Java.luan Wed Jun 18 18:57:34 2025 -0600 @@ -6,7 +6,8 @@ local Java = {} -Java.home_dir = System.getProperty("user.home") or error() +local home_dir = System.getProperty("user.home") or error() +Java.config_path = System.getProperty("config") or home_dir.."/.luan_editor/config.json" Java.port = System.getProperty("port")
--- 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
--- a/src/luan_editor/editor.luan Tue Jun 17 13:00:25 2025 -0600 +++ b/src/luan_editor/editor.luan Wed Jun 18 18:57:34 2025 -0600 @@ -6,6 +6,10 @@ local to_number = String.to_number or error() local Io = require "luan:Io.luan" local new_file = Io.schemes.file or error() +local Thread = require "luan:Thread.luan" +local sleep = Thread.sleep or error() +local Swing_runner = require "luan:swing/Swing_runner.luan" +local swing_run = Swing_runner.run or error() local Launcher = require "luan:swing/Launcher.luan" local Java = require "classpath:luan_editor/Java.luan" local Logging = require "luan:logging/Logging.luan" @@ -13,24 +17,46 @@ local function open(args) - local Window = require "classpath:luan_editor/Window.luan" - local new_window = Window.new_window or error() + if #args == 0 then + swing_run( function() + local Window = require "classpath:luan_editor/Window.luan" + local new_window = Window.new_window or error() - if #args == 0 then - new_window() + new_window() + end ) else for _, arg in ipairs(args) do local file = new_file(arg) - new_window(file) + swing_run( function() + local Window = require "classpath:luan_editor/Window.luan" + local new_window = Window.new_window or error() + + new_window(file) + end ) + sleep(100) end end end local function reopen(args) - local Window = require "classpath:luan_editor/Window.luan" - local open_windows = Window.open_windows or error() + if #args == 0 then + swing_run( function() + local Window = require "classpath:luan_editor/Window.luan" + local open_window = Window.open_window or error() - open_windows(args) + open_window(nil) + end ) + else + for _, arg in ipairs(args) do + swing_run( function() + local Window = require "classpath:luan_editor/Window.luan" + local open_window = Window.open_window or error() + + open_window(arg) + end ) + sleep(100) + end + end end local port = Java.port