├── .gitignore ├── MonacoFX-Tutorial-01 ├── resources │ └── img │ │ └── screenshot.png ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── LICENSE ├── config │ └── HEADER ├── build.gradle ├── gradlew.bat ├── src │ └── main │ │ └── java │ │ └── eu │ │ └── mihosoft │ │ └── monacofx │ │ └── tutorial01 │ │ └── App.java ├── README.md └── gradlew ├── MonacoFX-Tutorial-02 ├── resources │ └── img │ │ └── screenshot.png ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── LICENSE ├── config │ └── HEADER ├── build.gradle ├── gradlew.bat ├── README.md ├── src │ └── main │ │ └── java │ │ └── eu │ │ └── mihosoft │ │ └── monacofx │ │ └── tutorial02 │ │ └── App.java └── gradlew ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .project 3 | .classpath 4 | .settings 5 | 6 | bin/ 7 | build/ 8 | out/ 9 | .gradle/ 10 | .idea 11 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/resources/img/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miho/MonacoFX-Tutorials/HEAD/MonacoFX-Tutorial-01/resources/img/screenshot.png -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/resources/img/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miho/MonacoFX-Tutorials/HEAD/MonacoFX-Tutorial-02/resources/img/screenshot.png -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miho/MonacoFX-Tutorials/HEAD/MonacoFX-Tutorial-01/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miho/MonacoFX-Tutorials/HEAD/MonacoFX-Tutorial-02/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Michael Hoffer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Michael Hoffer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Michael Hoffer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MonacoFX-Tutorials 2 | 3 | Tutorial projects for [MonacoFX](https://github.com/miho/MonacoFX) 4 | 5 | ## Contents 6 | 7 | - [Introduction](https://github.com/miho/MonacoFX-Tutorials/blob/master/README.md#introduction) 8 | - [Getting Started](https://github.com/miho/MonacoFX-Tutorials/tree/master/MonacoFX-Tutorial-01) 9 | - [Registering custom Languages and Themes](https://github.com/miho/MonacoFX-Tutorials/tree/master/MonacoFX-Tutorial-02) 10 | 11 | ## Introduction 12 | 13 | [MonacoFX](https://github.com/miho/MonacoFX) is a powerful editor node for JavaFX. It is based on [Monaco](https://microsoft.github.io/monaco-editor/), the code editor that drives [VSCode](https://github.com/Microsoft/vscode). 14 | 15 | 16 | 17 | It uses the JavaFX WebView node to integrate Monaco into the scene graph. Additionally, it provides a Java API for adding custom languages, code folding and themes. Changing properties, like text and scroll position, are represented as regular JavaFX properties. The correspoonding callbacks into JS are added by [MonacoFX](https://github.com/miho/MonacoFX). 18 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/config/HEADER: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) ${years} ${author1}. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/config/HEADER: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) ${years} ${author1}. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/build.gradle: -------------------------------------------------------------------------------- 1 | import java.text.SimpleDateFormat 2 | 3 | plugins { 4 | id 'java' 5 | id 'application' 6 | id 'org.openjfx.javafxplugin' version '0.0.8' 7 | id 'com.github.hierynomus.license' version '0.15.0' 8 | } 9 | 10 | wrapper { 11 | gradleVersion = '7.5.1' 12 | } 13 | 14 | sourceCompatibility = '11' 15 | targetCompatibility = '11' 16 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 17 | 18 | repositories { 19 | mavenCentral() 20 | } 21 | 22 | dependencies { 23 | testImplementation 'junit:junit:4.13' 24 | 25 | implementation 'eu.mihosoft.monacofx:monacofx:0.0.8' 26 | } 27 | 28 | application { 29 | mainClassName = 'eu.mihosoft.monacofx.tutorial02.App' 30 | } 31 | 32 | javafx { 33 | version = 18 34 | modules = [ 'javafx.controls', 'javafx.web'] 35 | } 36 | 37 | license { 38 | header = rootProject.file('config/HEADER') 39 | 40 | strictCheck = true 41 | ignoreFailures = false 42 | 43 | mapping { 44 | java = 'SLASHSTAR_STYLE' 45 | groovy = 'SLASHSTAR_STYLE' 46 | gradle = 'SLASHSTAR_STYLE' 47 | fxml = 'XML_STYLE' 48 | html = 'XML_STYLE' 49 | } 50 | 51 | ext.yearCurrent = new SimpleDateFormat("yyyy").format(new Date()) 52 | ext.years = ('2020'.equals(ext.yearCurrent)?'':'2020-')+ext.yearCurrent 53 | ext.author1 = 'Michael Hoffer ' 54 | 55 | include '**/*.java' 56 | } 57 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/build.gradle: -------------------------------------------------------------------------------- 1 | import java.text.SimpleDateFormat 2 | 3 | plugins { 4 | id 'java' 5 | id 'application' 6 | id 'org.openjfx.javafxplugin' version '0.0.13' 7 | id 'com.github.hierynomus.license' version '0.15.0' 8 | } 9 | 10 | wrapper { 11 | gradleVersion = '7.5.1' 12 | } 13 | 14 | sourceCompatibility = '11' 15 | targetCompatibility = '11' 16 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 17 | 18 | repositories { 19 | mavenCentral() 20 | mavenLocal() 21 | } 22 | 23 | dependencies { 24 | testImplementation 'junit:junit:4.13' 25 | 26 | implementation 'eu.mihosoft.monacofx:monacofx:0.0.8' 27 | } 28 | 29 | application { 30 | mainClassName = 'eu.mihosoft.monacofx.tutorial01.App' 31 | } 32 | 33 | javafx { 34 | version = 18 35 | modules = [ 'javafx.controls', 'javafx.web'] 36 | } 37 | 38 | license { 39 | header = rootProject.file('config/HEADER') 40 | 41 | strictCheck = true 42 | ignoreFailures = false 43 | 44 | mapping { 45 | java = 'SLASHSTAR_STYLE' 46 | groovy = 'SLASHSTAR_STYLE' 47 | gradle = 'SLASHSTAR_STYLE' 48 | fxml = 'XML_STYLE' 49 | html = 'XML_STYLE' 50 | } 51 | 52 | ext.yearCurrent = new SimpleDateFormat("yyyy").format(new Date()) 53 | ext.years = ('2020'.equals(ext.yearCurrent)?'':'2020-')+ext.yearCurrent 54 | ext.author1 = 'Michael Hoffer ' 55 | 56 | include '**/*.java' 57 | } 58 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/src/main/java/eu/mihosoft/monacofx/tutorial01/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 Michael Hoffer . All rights reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package eu.mihosoft.monacofx.tutorial01; 25 | 26 | import eu.mihosoft.monacofx.*; 27 | import javafx.application.Application; 28 | import javafx.scene.Scene; 29 | import javafx.scene.layout.StackPane; 30 | import javafx.stage.Stage; 31 | 32 | public class App extends Application { 33 | 34 | public static void main(String[] args) { 35 | launch(args); 36 | } 37 | 38 | @Override 39 | public void start(Stage primaryStage) throws Exception { 40 | 41 | // create a new monaco editor node 42 | MonacoFX monacoFX = new MonacoFX(); 43 | StackPane root = new StackPane(monacoFX); 44 | 45 | // set initial text 46 | monacoFX.getEditor().getDocument().setText( 47 | "#include \n" + 48 | "int main() {\n" + 49 | " // printf() displays the string inside quotation\n" + 50 | " printf(\"Hello, World!\");\n" + 51 | " return 0;\n" + 52 | "}"); 53 | 54 | // use a predefined language like 'c' 55 | monacoFX.getEditor().setCurrentLanguage("c"); 56 | monacoFX.getEditor().setCurrentTheme("vs-dark"); 57 | 58 | // the usual scene & stage setup 59 | Scene scene = new Scene(root, 800,600); 60 | primaryStage.setTitle( 61 | "MonacoFX Demo (running on JDK " + System.getProperty("java.version") 62 | +" and JFX " + System.getProperty("javafx.version") 63 | + ")"); 64 | primaryStage.setScene(scene); 65 | primaryStage.show(); 66 | 67 | // monacoFX.getEditor().getDocument().setSelections( 68 | // new Selections(new Selection[]{ 69 | // new Selection(2, 1, 3, 0) 70 | // }) 71 | // ); 72 | 73 | } 74 | } -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/README.md: -------------------------------------------------------------------------------- 1 | # MonacoFX-Tutorial 01 2 | 3 | 4 | [HOME](https://github.com/miho/MonacoFX-Tutorials/blob/master/README.md) 5 | 6 | Introduction tutorial to MonacoFX, a JavaFX editor node based on the powerful Monaco editor that drives VSCode. 7 | 8 | 9 | 10 | ## Using MonacoFX 11 | 12 | Using MonacoFX is straightforward. Just create a MonacoFX node and add it to the scene graph. Here's a an example on how to use MonacoFX with syntax highlighting and code folding for an existing language: 13 | 14 | ```java 15 | public class App extends Application { 16 | 17 | public static void main(String[] args) { 18 | launch(args); 19 | } 20 | 21 | @Override 22 | public void start(Stage primaryStage) throws Exception { 23 | 24 | // create a new monaco editor node 25 | MonacoFX monacoFX = new MonacoFX(); 26 | StackPane root = new StackPane(monacoFX); 27 | 28 | // set initial text 29 | monacoFX.getEditor().getDocument().setText( 30 | "#include \n" + 31 | "int main() {\n" + 32 | " // printf() displays the string inside quotation\n" + 33 | " printf(\"Hello, World!\");\n" + 34 | " return 0;\n" + 35 | "}"); 36 | 37 | // use a predefined language like 'c' 38 | monacoFX.getEditor().setCurrentLanguage("c"); 39 | monacoFX.getEditor().setCurrentTheme("vs-dark"); 40 | 41 | // the usual scene & stage setup 42 | Scene scene = new Scene(root, 800,600); 43 | primaryStage.setTitle("MonacoFX Demo (running on JDK " + System.getProperty("java.version") + ")"); 44 | primaryStage.setScene(scene); 45 | primaryStage.show(); 46 | } 47 | } 48 | ``` 49 | 50 | 51 | ## How to build and run the project 52 | 53 | ### 1. Dependencies 54 | 55 | - JDK >= 11 (tested with JDK 13) 56 | - Internet Connection (other dependencies will be downloaded automatically) 57 | - Optional: IDE with [Gradle](http://www.gradle.org/) support 58 | 59 | ### 2. Building the project 60 | 61 | #### IDE 62 | 63 | To build the project from an IDE do the following: 64 | 65 | - open the [Gradle](http://www.gradle.org/) project 66 | - call the `assemble` Gradle task to build the project 67 | 68 | #### Command Line 69 | 70 | Building the project from the command line is also possible. 71 | 72 | Navigate to the project folder and call the `assemble` [Gradle](http://www.gradle.org/) 73 | task to build the project. 74 | 75 | ##### Bash (Linux/OS X/Cygwin/other Unix-like OS) 76 | 77 | cd Path/To/MonacoFX-Tutorial-01 78 | ./gradlew assemble 79 | 80 | ##### Windows (CMD) 81 | 82 | cd Path\To\MonacoFX-Tutorial-01 83 | gradlew assemble 84 | 85 | ### 3. Running the project 86 | 87 | #### IDE 88 | 89 | To run the project from an IDE do the following: 90 | 91 | - open the [Gradle](http://www.gradle.org/) project 92 | - call the `run` Gradle task to run the project 93 | 94 | #### Command Line 95 | 96 | Running the project from the command line is also possible. 97 | 98 | Navigate to the project folder and call the `run` [Gradle](http://www.gradle.org/) 99 | task to run the project. 100 | 101 | ##### Bash (Linux/OS X/Cygwin/other Unix-like OS) 102 | 103 | cd Path/To/MonacoFX-Tutorial-01 104 | ./gradlew run 105 | 106 | ##### Windows (CMD) 107 | 108 | cd Path\To\MonacoFX-Tutorial-01 109 | gradlew run 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/README.md: -------------------------------------------------------------------------------- 1 | # MonacoFX-Tutorial 02 2 | 3 | 4 | [HOME](https://github.com/miho/MonacoFX-Tutorials/blob/master/README.md) 5 | 6 | In this tutorial you will learn how to register custom languages and themes. 7 | 8 | 9 | 10 | ## Registering a custom language 11 | 12 | The class `LanguageSupport` allows the definition of custom languages. A language support needs a unique name. 13 | Optionally, a folding provider and a syntax highlighter can be provided. In the code sample below, we create custom 14 | fold objects and a monarch-syntax highlighter. 15 | 16 | ```java 17 | // custom language based on 18 | // https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages 19 | LanguageSupport language = new LanguageSupport() { 20 | @Override 21 | public String getName() { 22 | return "mylang"; 23 | } 24 | 25 | @Override 26 | public FoldingProvider getFoldingProvider() { 27 | // register custom code folds: 28 | // 29 | // it's possible to use a custom lexer that generates 30 | // the folds 31 | return editor -> new Folding[]{new Folding(1,5),new Folding(7,10)}; 32 | } 33 | 34 | @Override 35 | public MonarchSyntaxHighlighter getMonarchSyntaxHighlighter() { 36 | // custom syntax highlighter: 37 | // 38 | // currently, only monarch is supported. 39 | // if you'd like to see full support for custom lexers (e.g. based on antlr) 40 | // consider PRs or at least let us know 41 | return () -> "tokenizer: {\n" + 42 | " root: [\n" + 43 | " [/\\[error.*/, \"custom-error\"],\n" + 44 | " [/\\[notice.*/, \"custom-notice\"],\n" + 45 | " [/\\[info.*/, \"custom-info\"],\n" + 46 | " [/\\[[a-zA-Z 0-9:]+\\]/, \"custom-date\"],\n" + 47 | " ]\n" + 48 | "}"; 49 | } 50 | }; 51 | ``` 52 | 53 | To make use of the previously defined syntax highlighter, a custom theme needs to be registered. 54 | 55 | ```java 56 | monacoFX.getEditor().registerLanguage(language); 57 | 58 | // register custom theme for the custom language 59 | monacoFX.getEditor().registerTheme(new EditorTheme("mylang-theme", "vs-dark", true, 60 | new Rule("custom-info", "808080"), 61 | new Rule("custom-error", "ff0000", null, null,null, "bold"), 62 | new Rule("custom-notice", "ffa500"), 63 | new Rule("custom-date", "008800") 64 | )); 65 | ``` 66 | 67 | Finally, set the registered language and theme: 68 | ```java 69 | // use the custom language 70 | monacoFX.getEditor().setCurrentLanguage("mylang"); 71 | // and theme 72 | monacoFX.getEditor().setCurrentTheme("mylang-theme"); 73 | ``` 74 | 75 | 76 | ## How to build and run the project 77 | 78 | ### 1. Dependencies 79 | 80 | - JDK >= 11 (tested with JDK 13) 81 | - Internet Connection (other dependencies will be downloaded automatically) 82 | - Optional: IDE with [Gradle](http://www.gradle.org/) support 83 | 84 | ### 2. Building the project 85 | 86 | #### IDE 87 | 88 | To build the project from an IDE do the following: 89 | 90 | - open the [Gradle](http://www.gradle.org/) project 91 | - call the `assemble` Gradle task to build the project 92 | 93 | #### Command Line 94 | 95 | Building the project from the command line is also possible. 96 | 97 | Navigate to the project folder and call the `assemble` [Gradle](http://www.gradle.org/) 98 | task to build the project. 99 | 100 | ##### Bash (Linux/OS X/Cygwin/other Unix-like OS) 101 | 102 | cd Path/To/MonacoFX-Tutorial-02 103 | ./gradlew assemble 104 | 105 | ##### Windows (CMD) 106 | 107 | cd Path\To\MonacoFX-Tutorial-02 108 | gradlew assemble 109 | 110 | ### 3. Running the project 111 | 112 | #### IDE 113 | 114 | To run the project from an IDE do the following: 115 | 116 | - open the [Gradle](http://www.gradle.org/) project 117 | - call the `run` Gradle task to run the project 118 | 119 | #### Command Line 120 | 121 | Running the project from the command line is also possible. 122 | 123 | Navigate to the project folder and call the `run` [Gradle](http://www.gradle.org/) 124 | task to run the project. 125 | 126 | ##### Bash (Linux/OS X/Cygwin/other Unix-like OS) 127 | 128 | cd Path/To/MonacoFX-Tutorial-02 129 | ./gradlew run 130 | 131 | ##### Windows (CMD) 132 | 133 | cd Path\To\MonacoFX-Tutorial-02 134 | gradlew run 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/src/main/java/eu/mihosoft/monacofx/tutorial02/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 Michael Hoffer . All rights reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package eu.mihosoft.monacofx.tutorial02; 25 | 26 | import eu.mihosoft.monacofx.*; 27 | import javafx.application.Application; 28 | import javafx.scene.Scene; 29 | import javafx.scene.layout.StackPane; 30 | import javafx.stage.Stage; 31 | 32 | public class App extends Application { 33 | 34 | public static void main(String[] args) { 35 | launch(args); 36 | } 37 | 38 | @Override 39 | public void start(Stage primaryStage) throws Exception { 40 | 41 | // create a new monaco editor node 42 | MonacoFX monacoFX = new MonacoFX(); 43 | StackPane root = new StackPane(monacoFX); 44 | 45 | // custom language based on 46 | // https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages 47 | LanguageSupport language = new LanguageSupport() { 48 | @Override 49 | public String getName() { 50 | return "mylang"; 51 | } 52 | 53 | @Override 54 | public FoldingProvider getFoldingProvider() { 55 | // register custom code folds: 56 | // 57 | // it's possible to use a custom lexer that generates 58 | // the folds 59 | return editor -> new Folding[]{new Folding(1,5),new Folding(7,10)}; 60 | } 61 | 62 | @Override 63 | public MonarchSyntaxHighlighter getMonarchSyntaxHighlighter() { 64 | // custom syntax highlighter: 65 | // 66 | // currently, only monarch is supported. 67 | // if you'd like to see full support for custom lexers (e.g. based on antlr) 68 | // consider PRs or at least let us know 69 | return () -> "tokenizer: {\n" + 70 | " root: [\n" + 71 | " [/\\[error.*/, \"custom-error\"],\n" + 72 | " [/\\[notice.*/, \"custom-notice\"],\n" + 73 | " [/\\[info.*/, \"custom-info\"],\n" + 74 | " [/\\[[a-zA-Z 0-9:]+\\]/, \"custom-date\"],\n" + 75 | " ]\n" + 76 | "}"; 77 | } 78 | }; 79 | 80 | monacoFX.getEditor().registerLanguage(language); 81 | 82 | // register custom theme for the custom language 83 | monacoFX.getEditor().registerTheme(new EditorTheme("mylang-theme", "vs-dark", true, 84 | new Rule("custom-info", "808080"), 85 | new Rule("custom-error", "ff0000", null, null,null, "bold"), 86 | new Rule("custom-notice", "ffa500"), 87 | new Rule("custom-date", "008800") 88 | )); 89 | 90 | // set initial text 91 | monacoFX.getEditor().getDocument().setText("[Sun Mar 7 16:02:00 2004] [notice] Apache/1.3.29 (Unix) configured -- resuming normal operations\n" + 92 | "[Sun Mar 7 16:02:00 2004] [info] Server built: Feb 27 2004 13:56:37\n" + 93 | "[Sun Mar 7 16:02:00 2004] [notice] Accept mutex: sysvsem (Default: sysvsem)\n" + 94 | "[Sun Mar 7 16:05:49 2004] [info] [client xx.xx.xx.xx] (104)Connection reset by peer: client stopped connection before send body completed\n" + 95 | "[Sun Mar 7 17:21:44 2004] [info] [client xx.xx.xx.xx] (104)Connection reset by peer: client stopped connection before send body completed\n" + 96 | "[Sun Mar 7 17:23:53 2004] statistics: Use of uninitialized value in concatenation (.) or string at /home/httpd/twiki/lib/TWiki.pm line 528.\n" + 97 | "[Sun Mar 7 17:23:53 2004] statistics: Can't create file /home/httpd/twiki/data/Main/WebStatistics.txt - Permission denied\n" + 98 | "[Sun Mar 7 17:27:37 2004] [info] [client xx.xx.xx.xx] (104)Connection reset by peer: client stopped connection before send body completed\n" + 99 | "[Sun Mar 7 21:16:17 2004] [error] [client xx.xx.xx.xx] File does not exist: /home/httpd/twiki/view/Main/WebHome\n" + 100 | "[Sun Mar 7 21:20:14 2004] [info] [client xx.xx.xx.xx] (104)Connection reset by peer: client stopped connection before send body completed\n"); 101 | 102 | // use the custom language 103 | monacoFX.getEditor().setCurrentLanguage("mylang"); 104 | // and theme 105 | monacoFX.getEditor().setCurrentTheme("mylang-theme"); 106 | 107 | // the usual scene & stage setup 108 | Scene scene = new Scene(root, 1400,600); 109 | primaryStage.setTitle( 110 | "MonacoFX Demo (running on JDK " + System.getProperty("java.version") 111 | +" and JFX " + System.getProperty("javafx.version") 112 | + ")"); 113 | primaryStage.setScene(scene); 114 | primaryStage.show(); 115 | } 116 | } -------------------------------------------------------------------------------- /MonacoFX-Tutorial-01/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /MonacoFX-Tutorial-02/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Stop when "xargs" is not available. 209 | if ! command -v xargs >/dev/null 2>&1 210 | then 211 | die "xargs is not available" 212 | fi 213 | 214 | # Use "xargs" to parse quoted args. 215 | # 216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 217 | # 218 | # In Bash we could simply go: 219 | # 220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 221 | # set -- "${ARGS[@]}" "$@" 222 | # 223 | # but POSIX shell has neither arrays nor command substitution, so instead we 224 | # post-process each arg (as a line of input to sed) to backslash-escape any 225 | # character that might be a shell metacharacter, then use eval to reverse 226 | # that process (while maintaining the separation between arguments), and wrap 227 | # the whole thing up as a single "set" statement. 228 | # 229 | # This will of course break if any of these variables contains a newline or 230 | # an unmatched quote. 231 | # 232 | 233 | eval "set -- $( 234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 235 | xargs -n1 | 236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 237 | tr '\n' ' ' 238 | )" '"$@"' 239 | 240 | exec "$JAVACMD" "$@" 241 | --------------------------------------------------------------------------------