├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── editor_from_scratch │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── fonts ├── DejaVu Sans Mono for Powerline.ttf ├── FiraCode-Regular.ttf └── Source Code Pro for Powerline.otf ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── document.dart ├── highlighter.dart ├── input.dart ├── main.dart └── view.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── screenshots └── basic-editor.png ├── test └── doc_test.dart └── tests ├── sqlite3.c └── tinywl.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # editor_from_scratch 2 | 3 | This is the source for the flutter editor under 1000 lines of code - as written for the article at medium: 4 | 5 | https://medium.com/@marvinsanchez_43796/build-a-text-editor-with-flutter-ui-under-1000-lines-of-code-5a9dd2a053da 6 | 7 | # flutter_editor 8 | 9 | This project is for article purposes onl - for tutorial or for proof of concept. A more complete editor is flutter_editor: 10 | 11 | https://github.com/icedman/flutter_editor 12 | 13 | ![screenshot](https://raw.githubusercontent.com/icedman/flutter_editor/main/screenshots/Screenshot%20from%202022-03-09%2018-11-43.png) 14 | 15 | # Ashlar Code (Android) 16 | 17 | And some concepts here are used in the more advanced android app Ashlar Code (http://www.munchyapps.com/) 18 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | 40 | sourceSets { 41 | main.java.srcDirs += 'src/main/kotlin' 42 | } 43 | 44 | defaultConfig { 45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 46 | applicationId "com.example.editor_from_scratch" 47 | minSdkVersion flutter.minSdkVersion 48 | targetSdkVersion flutter.targetSdkVersion 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | } 69 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/editor_from_scratch/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.editor_from_scratch 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /fonts/DejaVu Sans Mono for Powerline.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/fonts/DejaVu Sans Mono for Powerline.ttf -------------------------------------------------------------------------------- /fonts/FiraCode-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/fonts/FiraCode-Regular.ttf -------------------------------------------------------------------------------- /fonts/Source Code Pro for Powerline.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/fonts/Source Code Pro for Powerline.otf -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 94 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 95 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 96 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 97 | ); 98 | path = Runner; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 97C146ED1CF9000F007C117D /* Runner */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 107 | buildPhases = ( 108 | 9740EEB61CF901F6004384FC /* Run Script */, 109 | 97C146EA1CF9000F007C117D /* Sources */, 110 | 97C146EB1CF9000F007C117D /* Frameworks */, 111 | 97C146EC1CF9000F007C117D /* Resources */, 112 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 113 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Runner; 120 | productName = Runner; 121 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 122 | productType = "com.apple.product-type.application"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | 97C146E61CF9000F007C117D /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1300; 131 | ORGANIZATIONNAME = ""; 132 | TargetAttributes = { 133 | 97C146ED1CF9000F007C117D = { 134 | CreatedOnToolsVersion = 7.3.1; 135 | LastSwiftMigration = 1100; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 140 | compatibilityVersion = "Xcode 9.3"; 141 | developmentRegion = en; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 97C146E51CF9000F007C117D; 148 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 97C146ED1CF9000F007C117D /* Runner */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 97C146EC1CF9000F007C117D /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 163 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 164 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 165 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXShellScriptBuildPhase section */ 172 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 173 | isa = PBXShellScriptBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | ); 177 | inputPaths = ( 178 | ); 179 | name = "Thin Binary"; 180 | outputPaths = ( 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 185 | }; 186 | 9740EEB61CF901F6004384FC /* Run Script */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "Run Script"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 199 | }; 200 | /* End PBXShellScriptBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 97C146EA1CF9000F007C117D /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 208 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 97C146FB1CF9000F007C117D /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C147001CF9000F007C117D /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SUPPORTED_PLATFORMS = iphoneos; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Profile; 283 | }; 284 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 285 | isa = XCBuildConfiguration; 286 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | CLANG_ENABLE_MODULES = YES; 290 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 291 | DEVELOPMENT_TEAM = 86487923D8; 292 | ENABLE_BITCODE = NO; 293 | INFOPLIST_FILE = Runner/Info.plist; 294 | LD_RUNPATH_SEARCH_PATHS = ( 295 | "$(inherited)", 296 | "@executable_path/Frameworks", 297 | ); 298 | PRODUCT_BUNDLE_IDENTIFIER = com.example.editorFromScratch; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 301 | SWIFT_VERSION = 5.0; 302 | VERSIONING_SYSTEM = "apple-generic"; 303 | }; 304 | name = Profile; 305 | }; 306 | 97C147031CF9000F007C117D /* Debug */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ALWAYS_SEARCH_USER_PATHS = NO; 310 | CLANG_ANALYZER_NONNULL = YES; 311 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 312 | CLANG_CXX_LIBRARY = "libc++"; 313 | CLANG_ENABLE_MODULES = YES; 314 | CLANG_ENABLE_OBJC_ARC = YES; 315 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 316 | CLANG_WARN_BOOL_CONVERSION = YES; 317 | CLANG_WARN_COMMA = YES; 318 | CLANG_WARN_CONSTANT_CONVERSION = YES; 319 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 320 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 321 | CLANG_WARN_EMPTY_BODY = YES; 322 | CLANG_WARN_ENUM_CONVERSION = YES; 323 | CLANG_WARN_INFINITE_RECURSION = YES; 324 | CLANG_WARN_INT_CONVERSION = YES; 325 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 326 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 327 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 330 | CLANG_WARN_STRICT_PROTOTYPES = YES; 331 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 332 | CLANG_WARN_UNREACHABLE_CODE = YES; 333 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 334 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 335 | COPY_PHASE_STRIP = NO; 336 | DEBUG_INFORMATION_FORMAT = dwarf; 337 | ENABLE_STRICT_OBJC_MSGSEND = YES; 338 | ENABLE_TESTABILITY = YES; 339 | GCC_C_LANGUAGE_STANDARD = gnu99; 340 | GCC_DYNAMIC_NO_PIC = NO; 341 | GCC_NO_COMMON_BLOCKS = YES; 342 | GCC_OPTIMIZATION_LEVEL = 0; 343 | GCC_PREPROCESSOR_DEFINITIONS = ( 344 | "DEBUG=1", 345 | "$(inherited)", 346 | ); 347 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 348 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 349 | GCC_WARN_UNDECLARED_SELECTOR = YES; 350 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 351 | GCC_WARN_UNUSED_FUNCTION = YES; 352 | GCC_WARN_UNUSED_VARIABLE = YES; 353 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 354 | MTL_ENABLE_DEBUG_INFO = YES; 355 | ONLY_ACTIVE_ARCH = YES; 356 | SDKROOT = iphoneos; 357 | TARGETED_DEVICE_FAMILY = "1,2"; 358 | }; 359 | name = Debug; 360 | }; 361 | 97C147041CF9000F007C117D /* Release */ = { 362 | isa = XCBuildConfiguration; 363 | buildSettings = { 364 | ALWAYS_SEARCH_USER_PATHS = NO; 365 | CLANG_ANALYZER_NONNULL = YES; 366 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 367 | CLANG_CXX_LIBRARY = "libc++"; 368 | CLANG_ENABLE_MODULES = YES; 369 | CLANG_ENABLE_OBJC_ARC = YES; 370 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 371 | CLANG_WARN_BOOL_CONVERSION = YES; 372 | CLANG_WARN_COMMA = YES; 373 | CLANG_WARN_CONSTANT_CONVERSION = YES; 374 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 375 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 376 | CLANG_WARN_EMPTY_BODY = YES; 377 | CLANG_WARN_ENUM_CONVERSION = YES; 378 | CLANG_WARN_INFINITE_RECURSION = YES; 379 | CLANG_WARN_INT_CONVERSION = YES; 380 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 381 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 382 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 383 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 384 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 385 | CLANG_WARN_STRICT_PROTOTYPES = YES; 386 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 387 | CLANG_WARN_UNREACHABLE_CODE = YES; 388 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 389 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 390 | COPY_PHASE_STRIP = NO; 391 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 392 | ENABLE_NS_ASSERTIONS = NO; 393 | ENABLE_STRICT_OBJC_MSGSEND = YES; 394 | GCC_C_LANGUAGE_STANDARD = gnu99; 395 | GCC_NO_COMMON_BLOCKS = YES; 396 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 397 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 398 | GCC_WARN_UNDECLARED_SELECTOR = YES; 399 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 400 | GCC_WARN_UNUSED_FUNCTION = YES; 401 | GCC_WARN_UNUSED_VARIABLE = YES; 402 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 403 | MTL_ENABLE_DEBUG_INFO = NO; 404 | SDKROOT = iphoneos; 405 | SUPPORTED_PLATFORMS = iphoneos; 406 | SWIFT_COMPILATION_MODE = wholemodule; 407 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 408 | TARGETED_DEVICE_FAMILY = "1,2"; 409 | VALIDATE_PRODUCT = YES; 410 | }; 411 | name = Release; 412 | }; 413 | 97C147061CF9000F007C117D /* Debug */ = { 414 | isa = XCBuildConfiguration; 415 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 416 | buildSettings = { 417 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 418 | CLANG_ENABLE_MODULES = YES; 419 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 420 | DEVELOPMENT_TEAM = 86487923D8; 421 | ENABLE_BITCODE = NO; 422 | INFOPLIST_FILE = Runner/Info.plist; 423 | LD_RUNPATH_SEARCH_PATHS = ( 424 | "$(inherited)", 425 | "@executable_path/Frameworks", 426 | ); 427 | PRODUCT_BUNDLE_IDENTIFIER = com.example.editorFromScratch; 428 | PRODUCT_NAME = "$(TARGET_NAME)"; 429 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 430 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 431 | SWIFT_VERSION = 5.0; 432 | VERSIONING_SYSTEM = "apple-generic"; 433 | }; 434 | name = Debug; 435 | }; 436 | 97C147071CF9000F007C117D /* Release */ = { 437 | isa = XCBuildConfiguration; 438 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 439 | buildSettings = { 440 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 441 | CLANG_ENABLE_MODULES = YES; 442 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 443 | DEVELOPMENT_TEAM = 86487923D8; 444 | ENABLE_BITCODE = NO; 445 | INFOPLIST_FILE = Runner/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = ( 447 | "$(inherited)", 448 | "@executable_path/Frameworks", 449 | ); 450 | PRODUCT_BUNDLE_IDENTIFIER = com.example.editorFromScratch; 451 | PRODUCT_NAME = "$(TARGET_NAME)"; 452 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 453 | SWIFT_VERSION = 5.0; 454 | VERSIONING_SYSTEM = "apple-generic"; 455 | }; 456 | name = Release; 457 | }; 458 | /* End XCBuildConfiguration section */ 459 | 460 | /* Begin XCConfigurationList section */ 461 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | 97C147031CF9000F007C117D /* Debug */, 465 | 97C147041CF9000F007C117D /* Release */, 466 | 249021D3217E4FDB00AE95B9 /* Profile */, 467 | ); 468 | defaultConfigurationIsVisible = 0; 469 | defaultConfigurationName = Release; 470 | }; 471 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 472 | isa = XCConfigurationList; 473 | buildConfigurations = ( 474 | 97C147061CF9000F007C117D /* Debug */, 475 | 97C147071CF9000F007C117D /* Release */, 476 | 249021D4217E4FDB00AE95B9 /* Profile */, 477 | ); 478 | defaultConfigurationIsVisible = 0; 479 | defaultConfigurationName = Release; 480 | }; 481 | /* End XCConfigurationList section */ 482 | }; 483 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 484 | } 485 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Editor From Scratch 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | editor_from_scratch 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/document.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:convert'; 3 | 4 | class Cursor { 5 | Cursor( 6 | {this.line = 0, 7 | this.column = 0, 8 | this.anchorLine = 0, 9 | this.anchorColumn = 0}); 10 | 11 | int line = 0; 12 | int column = 0; 13 | int anchorLine = 0; 14 | int anchorColumn = 0; 15 | 16 | Cursor copy() { 17 | return Cursor( 18 | line: line, 19 | column: column, 20 | anchorLine: anchorLine, 21 | anchorColumn: anchorColumn); 22 | } 23 | 24 | Cursor normalized() { 25 | Cursor res = copy(); 26 | if (line > anchorLine || (line == anchorLine && column > anchorColumn)) { 27 | res.line = anchorLine; 28 | res.column = anchorColumn; 29 | res.anchorLine = line; 30 | res.anchorColumn = column; 31 | return res; 32 | } 33 | return res; 34 | } 35 | 36 | bool hasSelection() { 37 | return line != anchorLine || column != anchorColumn; 38 | } 39 | } 40 | 41 | class Document { 42 | String docPath = ''; 43 | List lines = ['']; 44 | Cursor cursor = Cursor(); 45 | String clipboardText = ''; 46 | 47 | Future openFile(String path) async { 48 | lines = ['']; 49 | docPath = path; 50 | File f = File(docPath); 51 | await f.openRead().map(utf8.decode).transform(const LineSplitter()).forEach((l) { 52 | insertText(l); 53 | insertNewLine(); 54 | }); 55 | moveCursorToStartOfDocument(); 56 | return true; 57 | } 58 | 59 | Future saveFile({String? path}) async { 60 | File f = File(path ?? docPath); 61 | String content = ''; 62 | for (var l in lines) { 63 | content += l + '\n'; 64 | } 65 | f.writeAsString(content); 66 | return true; 67 | } 68 | 69 | void _validateCursor(bool keepAnchor) { 70 | if (cursor.line >= lines.length) { 71 | cursor.line = lines.length - 1; 72 | } 73 | if (cursor.line < 0) cursor.line = 0; 74 | if (cursor.column > lines[cursor.line].length) { 75 | cursor.column = lines[cursor.line].length; 76 | } 77 | if (cursor.column == -1) cursor.column = lines[cursor.line].length; 78 | if (cursor.column < 0) cursor.column = 0; 79 | if (!keepAnchor) { 80 | cursor.anchorLine = cursor.line; 81 | cursor.anchorColumn = cursor.column; 82 | } 83 | } 84 | 85 | void moveCursor(int line, int column, {bool keepAnchor = false}) { 86 | cursor.line = line; 87 | cursor.column = column; 88 | _validateCursor(keepAnchor); 89 | } 90 | 91 | void moveCursorLeft({int count = 1, bool keepAnchor = false}) { 92 | cursor.column = cursor.column - count; 93 | if (cursor.column < 0) { 94 | moveCursorUp(keepAnchor: keepAnchor); 95 | moveCursorToEndOfLine(keepAnchor: keepAnchor); 96 | } 97 | _validateCursor(keepAnchor); 98 | } 99 | 100 | void moveCursorRight({int count = 1, bool keepAnchor = false}) { 101 | cursor.column = cursor.column + count; 102 | if (cursor.column > lines[cursor.line].length) { 103 | moveCursorDown(keepAnchor: keepAnchor); 104 | moveCursorToStartOfLine(keepAnchor: keepAnchor); 105 | } 106 | _validateCursor(keepAnchor); 107 | } 108 | 109 | void moveCursorUp({int count = 1, bool keepAnchor = false}) { 110 | cursor.line = cursor.line - count; 111 | _validateCursor(keepAnchor); 112 | } 113 | 114 | void moveCursorDown({int count = 1, bool keepAnchor = false}) { 115 | cursor.line = cursor.line + count; 116 | _validateCursor(keepAnchor); 117 | } 118 | 119 | void moveCursorToStartOfLine({bool keepAnchor = false}) { 120 | cursor.column = 0; 121 | _validateCursor(keepAnchor); 122 | } 123 | 124 | void moveCursorToEndOfLine({bool keepAnchor = false}) { 125 | cursor.column = lines[cursor.line].length; 126 | _validateCursor(keepAnchor); 127 | } 128 | 129 | void moveCursorToStartOfDocument({bool keepAnchor = false}) { 130 | cursor.line = 0; 131 | cursor.column = 0; 132 | _validateCursor(keepAnchor); 133 | } 134 | 135 | void moveCursorToEndOfDocument({bool keepAnchor = false}) { 136 | cursor.line = lines.length - 1; 137 | cursor.column = lines[cursor.line].length; 138 | _validateCursor(keepAnchor); 139 | } 140 | 141 | void insertNewLine() { 142 | deleteSelectedText(); 143 | insertText('\n'); 144 | } 145 | 146 | void insertText(String text) { 147 | deleteSelectedText(); 148 | String l = lines[cursor.line]; 149 | String left = l.substring(0, cursor.column); 150 | String right = l.substring(cursor.column); 151 | 152 | // handle new line 153 | if (text == '\n') { 154 | lines[cursor.line] = left; 155 | lines.insert(cursor.line + 1, right); 156 | moveCursorDown(); 157 | moveCursorToStartOfLine(); 158 | return; 159 | } 160 | 161 | lines[cursor.line] = left + text + right; 162 | moveCursorRight(count: text.length); 163 | } 164 | 165 | void deleteText({int numberOfCharacters = 1}) { 166 | String l = lines[cursor.line]; 167 | 168 | // handle join lines 169 | if (cursor.column >= l.length) { 170 | Cursor cur = cursor.copy(); 171 | lines[cursor.line] += lines[cursor.line + 1]; 172 | moveCursorDown(); 173 | deleteLine(); 174 | cursor = cur; 175 | return; 176 | } 177 | 178 | Cursor cur = cursor.normalized(); 179 | String left = l.substring(0, cur.column); 180 | String right = l.substring(cur.column + numberOfCharacters); 181 | cursor = cur; 182 | 183 | // handle erase entire line 184 | if (lines.length > 1 && (left + right).isEmpty) { 185 | lines.removeAt(cur.line); 186 | moveCursorUp(); 187 | moveCursorToStartOfLine(); 188 | return; 189 | } 190 | 191 | lines[cursor.line] = left + right; 192 | } 193 | 194 | void deleteLine({int numberOfLines = 1}) { 195 | for (int i = 0; i < numberOfLines; i++) { 196 | moveCursorToStartOfLine(); 197 | deleteText(numberOfCharacters: lines[cursor.line].length); 198 | } 199 | _validateCursor(false); 200 | } 201 | 202 | List selectedLines() { 203 | List res = []; 204 | Cursor cur = cursor.normalized(); 205 | if (cur.line == cur.anchorLine) { 206 | String sel = lines[cur.line].substring(cur.column, cur.anchorColumn); 207 | res.add(sel); 208 | return res; 209 | } 210 | 211 | res.add(lines[cur.line].substring(cur.column)); 212 | for (int i = cur.line + 1; i < cur.anchorLine; i++) { 213 | res.add(lines[i]); 214 | } 215 | res.add(lines[cur.anchorLine].substring(0, cur.anchorColumn)); 216 | return res; 217 | } 218 | 219 | String selectedText() { 220 | return selectedLines().join('\n'); 221 | } 222 | 223 | void deleteSelectedText() { 224 | if (!cursor.hasSelection()) { 225 | return; 226 | } 227 | 228 | Cursor cur = cursor.normalized(); 229 | List res = selectedLines(); 230 | if (res.length == 1) { 231 | print(cur.anchorColumn - cur.column); 232 | deleteText(numberOfCharacters: cur.anchorColumn - cur.column); 233 | clearSelection(); 234 | return; 235 | } 236 | 237 | String l = lines[cur.line]; 238 | String left = l.substring(0, cur.column); 239 | l = lines[cur.anchorLine]; 240 | String right = l.substring(cur.anchorColumn); 241 | 242 | cursor = cur; 243 | lines[cur.line] = left + right; 244 | lines[cur.anchorLine] = lines[cur.anchorLine].substring(cur.anchorColumn); 245 | for (int i = 0; i < res.length - 1; i++) { 246 | lines.removeAt(cur.line + 1); 247 | } 248 | _validateCursor(false); 249 | } 250 | 251 | void clearSelection() { 252 | cursor.anchorLine = cursor.line; 253 | cursor.anchorColumn = cursor.column; 254 | } 255 | 256 | void command(String cmd) { 257 | switch (cmd) { 258 | case 'ctrl+c': 259 | clipboardText = selectedText(); 260 | break; 261 | case 'ctrl+x': 262 | clipboardText = selectedText(); 263 | deleteSelectedText(); 264 | break; 265 | case 'ctrl+v': 266 | insertText(clipboardText); 267 | break; 268 | case 'ctrl+s': 269 | saveFile(); 270 | break; 271 | } 272 | } 273 | } 274 | -------------------------------------------------------------------------------- /lib/highlighter.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:collection'; 3 | import 'dart:ui' as ui; 4 | 5 | import 'document.dart'; 6 | 7 | double fontSize = 18; 8 | double gutterFontSize = 16; 9 | 10 | Size getTextExtents(String text, TextStyle style) { 11 | final TextPainter textPainter = TextPainter( 12 | text: TextSpan(text: text, style: style), 13 | maxLines: 1, 14 | textDirection: TextDirection.ltr) 15 | ..layout(minWidth: 0, maxWidth: double.infinity); 16 | return textPainter.size; 17 | } 18 | 19 | Color foreground = const Color(0xfff8f8f2); 20 | Color background = const Color(0xff272822); 21 | Color comment = const Color(0xff88846f); 22 | Color selection = const Color(0xff44475a); 23 | Color function = const Color(0xff50fa7b); 24 | Color keyword = const Color(0xffff79c6); 25 | Color string = Colors.yellow; 26 | 27 | class LineDecoration { 28 | int start = 0; 29 | int end = 0; 30 | Color color = Colors.white; 31 | Color background = Colors.white; 32 | bool underline = false; 33 | bool italic = false; 34 | } 35 | 36 | class CustomWidgetSpan extends WidgetSpan { 37 | final int line; 38 | const CustomWidgetSpan({required Widget child, this.line = 0}) 39 | : super(child: child); 40 | } 41 | 42 | class Highlighter { 43 | HashMap colorMap = HashMap(); 44 | 45 | Highlighter() { 46 | colorMap.clear(); 47 | colorMap['\\b(class|struct)\\b'] = function; 48 | colorMap['("|<){1}\\b(.*)\\b("|>){1}'] = string; 49 | // keywords and meta-keywords list is copied from flutter_highlight 50 | colorMap[ 51 | '\\b(if|else|elif|endif|define|undef|warning|error|line|pragma|_Pragma|ifdef|ifndef|include)\\b'] = 52 | function; 53 | colorMap[ 54 | '\\b(keyword|int|float|while|private|char|char8_t|char16_t|char32_t|catch|import|module|export|virtual|operator|sizeof|dynamic_cast|10|typedef|const_cast|10|const|for|static_cast|10|union|namespace|unsigned|long|volatile|static|protected|bool|template|mutable|if|public|friend|do|goto|auto|void|enum|else|break|extern|using|asm|case|typeid|wchar_tshort|reinterpret_cast|10|default|double|register|explicit|signed|typename|try|this|switch|continue|inline|delete|alignas|alignof|constexpr|consteval|constinit|decltype|concept|co_await|co_return|co_yield|requires|noexcept|static_assert|thread_local|restrict|final|override|atomic_bool|atomic_char|atomic_schar|atomic_uchar|atomic_short|atomic_ushort|atomic_int|atomic_uint|atomic_long|atomic_ulong|atomic_llong|atomic_ullong|new|throw|return|and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq)\\b'] = 55 | keyword; 56 | } 57 | 58 | List run(String text, int line, Document document) { 59 | TextStyle defaultStyle = TextStyle( 60 | fontFamily: 'FiraCode', fontSize: fontSize, color: foreground); 61 | List res = []; 62 | List decors = []; 63 | 64 | for (var exp in colorMap.keys) { 65 | RegExp regExp = RegExp(exp, caseSensitive: false, multiLine: false); 66 | var matches = regExp.allMatches(text); 67 | for (var m in matches) { 68 | if (m.start == m.end) continue; 69 | LineDecoration d = LineDecoration(); 70 | d.start = m.start; 71 | d.end = m.end - 1; 72 | d.color = colorMap[exp] ?? foreground; 73 | decors.add(d); 74 | } 75 | } 76 | 77 | text += ' '; 78 | String prevText = ''; 79 | for (int i = 0; i < text.length; i++) { 80 | String ch = text[i]; 81 | TextStyle style = defaultStyle.copyWith(); 82 | Cursor cur = document.cursor.normalized(); 83 | 84 | // decorate 85 | for (var d in decors) { 86 | if (i >= d.start && i <= d.end) { 87 | style = style.copyWith(color: d.color); 88 | } 89 | } 90 | 91 | // is within selection 92 | if (cur.hasSelection()) { 93 | if (line < cur.line || 94 | (line == cur.line && i < cur.column) || 95 | line > cur.anchorLine || 96 | (line == cur.anchorLine && i + 1 > cur.anchorColumn)) { 97 | } else { 98 | style = style.copyWith(backgroundColor: selection.withOpacity(0.75)); 99 | } 100 | } 101 | 102 | // is within caret 103 | if ((line == document.cursor.line && i == document.cursor.column)) { 104 | res.add(WidgetSpan( 105 | alignment: ui.PlaceholderAlignment.baseline, 106 | baseline: TextBaseline.alphabetic, 107 | child: Container( 108 | decoration: BoxDecoration( 109 | border: Border( 110 | left: BorderSide( 111 | width: 1.2, color: style.color ?? Colors.yellow))), 112 | child: Text(ch, style: style.copyWith(letterSpacing: -1.5))))); 113 | continue; 114 | } 115 | 116 | if (res.isNotEmpty && res[res.length - 1] is! WidgetSpan) { 117 | TextSpan prev = res[res.length - 1] as TextSpan; 118 | if (prev.style == style) { 119 | prevText += ch; 120 | res[res.length - 1] = TextSpan( 121 | text: prevText, 122 | style: style, 123 | mouseCursor: MaterialStateMouseCursor.textable); 124 | continue; 125 | } 126 | } 127 | 128 | res.add(TextSpan( 129 | text: ch, 130 | style: style, 131 | mouseCursor: MaterialStateMouseCursor.textable)); 132 | prevText = ch; 133 | } 134 | 135 | res.add(CustomWidgetSpan( 136 | child: const SizedBox(height: 1, width: 8), line: line)); 137 | return res; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /lib/input.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:flutter/rendering.dart'; 4 | import 'package:provider/provider.dart'; 5 | 6 | import 'document.dart'; 7 | import 'view.dart'; 8 | import 'highlighter.dart'; 9 | 10 | Offset screenToCursor(RenderObject? obj, Offset pos) { 11 | List pars = []; 12 | findRenderParagraphs(obj, pars); 13 | 14 | RenderParagraph? targetPar; 15 | int line = -1; 16 | 17 | for (final par in pars) { 18 | Rect bounds = const Offset(0, 0) & par.size; 19 | Offset offsetForCaret = par.localToGlobal( 20 | par.getOffsetForCaret(const TextPosition(offset: 0), bounds)); 21 | Rect parBounds = 22 | offsetForCaret & Size(par.size.width * 10, par.size.height); 23 | if (parBounds.inflate(2).contains(pos)) { 24 | targetPar = par; 25 | break; 26 | } 27 | } 28 | 29 | if (targetPar == null) return const Offset(-1, -1); 30 | 31 | Rect bounds = const Offset(0, 0) & targetPar.size; 32 | List children = 33 | (targetPar.text as TextSpan).children ?? []; 34 | Size fontCharSize = const Size(0, 0); 35 | int textOffset = 0; 36 | bool found = false; 37 | for (var span in children) { 38 | if (found) break; 39 | if (span is! TextSpan) { 40 | continue; 41 | } 42 | 43 | if (fontCharSize.width == 0) { 44 | fontCharSize = getTextExtents(' ', span.style ?? const TextStyle()); 45 | } 46 | 47 | String txt = (span).text ?? ''; 48 | for (int i = 0; i < txt.length; i++) { 49 | Offset offsetForCaret = targetPar.localToGlobal(targetPar 50 | .getOffsetForCaret(TextPosition(offset: textOffset), bounds)); 51 | Rect charBounds = offsetForCaret & fontCharSize; 52 | if (charBounds.inflate(2).contains(Offset(pos.dx + 1, pos.dy + 1))) { 53 | found = true; 54 | break; 55 | } 56 | textOffset++; 57 | } 58 | } 59 | 60 | if (children.isNotEmpty && children.last is CustomWidgetSpan) { 61 | line = (children.last as CustomWidgetSpan).line; 62 | } 63 | 64 | return Offset(textOffset.toDouble(), line.toDouble()); 65 | } 66 | 67 | void findRenderParagraphs(RenderObject? obj, List res) { 68 | if (obj is RenderParagraph) { 69 | res.add(obj); 70 | return; 71 | } 72 | obj?.visitChildren((child) { 73 | findRenderParagraphs(child, res); 74 | }); 75 | } 76 | 77 | class InputListener extends StatefulWidget { 78 | final Widget child; 79 | 80 | const InputListener({required this.child, super.key}); 81 | @override 82 | _InputListener createState() => _InputListener(); 83 | } 84 | 85 | class _InputListener extends State { 86 | late FocusNode focusNode; 87 | 88 | @override 89 | void initState() { 90 | super.initState(); 91 | focusNode = FocusNode(); 92 | } 93 | 94 | @override 95 | void dispose() { 96 | super.dispose(); 97 | focusNode.dispose(); 98 | } 99 | 100 | @override 101 | Widget build(BuildContext context) { 102 | if (!focusNode.hasFocus) { 103 | focusNode.requestFocus(); 104 | } 105 | 106 | DocumentProvider doc = Provider.of(context); 107 | Document d = doc.doc; 108 | return GestureDetector( 109 | child: Focus( 110 | child: widget.child, 111 | focusNode: focusNode, 112 | autofocus: true, 113 | onKey: (FocusNode node, RawKeyEvent event) { 114 | if (event.runtimeType.toString() == 'RawKeyDownEvent') { 115 | switch (event.logicalKey.keyLabel) { 116 | case 'Home': 117 | if (event.isControlPressed) { 118 | d.moveCursorToStartOfDocument(); 119 | } else { 120 | d.moveCursorToStartOfLine(); 121 | } 122 | break; 123 | case 'End': 124 | if (event.isControlPressed) { 125 | d.moveCursorToEndOfDocument(); 126 | } else { 127 | d.moveCursorToEndOfLine(); 128 | } 129 | break; 130 | case 'Tab': 131 | d.insertText(' '); 132 | break; 133 | case 'Enter': 134 | d.deleteSelectedText(); 135 | d.insertNewLine(); 136 | break; 137 | case 'Backspace': 138 | if (d.cursor.hasSelection()) { 139 | d.deleteSelectedText(); 140 | } else { 141 | d.moveCursorLeft(); 142 | d.deleteText(); 143 | } 144 | break; 145 | case 'Delete': 146 | if (d.cursor.hasSelection()) { 147 | d.deleteSelectedText(); 148 | } else { 149 | d.deleteText(); 150 | } 151 | break; 152 | case 'Arrow Left': 153 | d.moveCursorLeft(keepAnchor: event.isShiftPressed); 154 | break; 155 | case 'Arrow Right': 156 | d.moveCursorRight(keepAnchor: event.isShiftPressed); 157 | break; 158 | case 'Arrow Up': 159 | d.moveCursorUp(keepAnchor: event.isShiftPressed); 160 | break; 161 | case 'Arrow Down': 162 | d.moveCursorDown(keepAnchor: event.isShiftPressed); 163 | break; 164 | default: 165 | { 166 | int k = event.logicalKey.keyId; 167 | if ((k >= LogicalKeyboardKey.keyA.keyId && 168 | k <= LogicalKeyboardKey.keyZ.keyId) || 169 | (k + 32 >= LogicalKeyboardKey.keyA.keyId && 170 | k + 32 <= LogicalKeyboardKey.keyZ.keyId)) { 171 | String ch = String.fromCharCode( 172 | 97 + k - LogicalKeyboardKey.keyA.keyId); 173 | if (event.isControlPressed) { 174 | d.command('ctrl+$ch'); 175 | break; 176 | } 177 | d.insertText(ch); 178 | break; 179 | } 180 | } 181 | if (event.logicalKey.keyLabel.length == 1) { 182 | d.insertText(event.logicalKey.keyLabel); 183 | } 184 | // print(event.logicalKey.keyLabel); 185 | break; 186 | } 187 | doc.touch(); 188 | } 189 | if (event.runtimeType.toString() == 'RawKeyUpEvent') {} 190 | return KeyEventResult.handled; 191 | }), 192 | onTapDown: (TapDownDetails details) { 193 | Offset o = screenToCursor( 194 | context.findRenderObject(), details.globalPosition); 195 | d.moveCursor(o.dy.toInt(), o.dx.toInt()); 196 | doc.touch(); 197 | }, 198 | onPanUpdate: (DragUpdateDetails details) { 199 | Offset o = screenToCursor( 200 | context.findRenderObject(), details.globalPosition); 201 | if (o.dx == -1 || o.dy == -1) return; 202 | d.moveCursor(o.dy.toInt(), o.dx.toInt(), keepAnchor: true); 203 | doc.touch(); 204 | }); 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:provider/provider.dart'; 3 | 4 | import 'view.dart'; 5 | import 'input.dart'; 6 | import 'highlighter.dart'; 7 | 8 | class Editor extends StatefulWidget { 9 | const Editor({super.key, this.path = ''}); 10 | final String path; 11 | @override 12 | _Editor createState() => _Editor(); 13 | } 14 | 15 | class _Editor extends State { 16 | late DocumentProvider doc; 17 | @override 18 | void initState() { 19 | doc = DocumentProvider(); 20 | doc.openFile(widget.path); 21 | super.initState(); 22 | } 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return MultiProvider(providers: [ 27 | ChangeNotifierProvider(create: (context) => doc), 28 | Provider(create: (context) => Highlighter()) 29 | ], child: const InputListener(child: View())); 30 | } 31 | } 32 | 33 | void main() async { 34 | ThemeData themeData = ThemeData( 35 | fontFamily: 'FiraCode', 36 | primaryColor: foreground, 37 | backgroundColor: background, 38 | scaffoldBackgroundColor: background, 39 | ); 40 | return runApp(MaterialApp( 41 | debugShowCheckedModeBanner: false, 42 | theme: themeData, 43 | home: const Scaffold(body: Editor(path: './tests/tinywl.c')))); 44 | } 45 | -------------------------------------------------------------------------------- /lib/view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:provider/provider.dart'; 3 | 4 | import 'document.dart'; 5 | import 'highlighter.dart'; 6 | 7 | class DocumentProvider extends ChangeNotifier { 8 | Document doc = Document(); 9 | 10 | Future openFile(String path) async { 11 | bool res = await doc.openFile(path); 12 | touch(); 13 | return res; 14 | } 15 | 16 | void touch() { 17 | notifyListeners(); 18 | } 19 | } 20 | 21 | class ViewLine extends StatelessWidget { 22 | const ViewLine({this.lineNumber = 0, this.text = '', super.key}); 23 | 24 | final int lineNumber; 25 | final String text; 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | DocumentProvider doc = Provider.of(context); 30 | Highlighter hl = Provider.of(context); 31 | List spans = hl.run(text, lineNumber, doc.doc); 32 | 33 | final gutterStyle = TextStyle( 34 | fontFamily: 'FiraCode', fontSize: gutterFontSize, color: comment); 35 | double gutterWidth = 36 | getTextExtents(' ${doc.doc.lines.length} ', gutterStyle).width; 37 | 38 | return Stack(children: [ 39 | Padding( 40 | padding: EdgeInsets.only(left: gutterWidth), 41 | child: RichText(text: TextSpan(children: spans), softWrap: true)), 42 | Container( 43 | width: gutterWidth, 44 | alignment: Alignment.centerRight, 45 | child: Text('${lineNumber + 1} ', style: gutterStyle)), 46 | ]); 47 | } 48 | } 49 | 50 | class View extends StatefulWidget { 51 | const View({super.key, this.path = ''}); 52 | final String path; 53 | 54 | @override 55 | _View createState() => _View(); 56 | } 57 | 58 | class _View extends State { 59 | late ScrollController scroller; 60 | 61 | @override 62 | void initState() { 63 | scroller = ScrollController(); 64 | super.initState(); 65 | } 66 | 67 | @override 68 | void dispose() { 69 | scroller.dispose(); 70 | super.dispose(); 71 | } 72 | 73 | @override 74 | Widget build(BuildContext context) { 75 | DocumentProvider doc = Provider.of(context); 76 | return ListView.builder( 77 | controller: scroller, 78 | itemCount: doc.doc.lines.length, 79 | itemBuilder: (BuildContext context, int index) { 80 | return ViewLine(lineNumber: index, text: doc.doc.lines[index]); 81 | }); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(runner LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "editor_from_scratch") 5 | set(APPLICATION_ID "com.example.editor_from_scratch") 6 | 7 | cmake_policy(SET CMP0063 NEW) 8 | 9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 10 | 11 | # Root filesystem for cross-building. 12 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 13 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 14 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 15 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 16 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 17 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 18 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 19 | endif() 20 | 21 | # Configure build options. 22 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 23 | set(CMAKE_BUILD_TYPE "Debug" CACHE 24 | STRING "Flutter build mode" FORCE) 25 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 26 | "Debug" "Profile" "Release") 27 | endif() 28 | 29 | # Compilation settings that should be applied to most targets. 30 | function(APPLY_STANDARD_SETTINGS TARGET) 31 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 32 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 33 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 34 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 35 | endfunction() 36 | 37 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 38 | 39 | # Flutter library and tool build rules. 40 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 41 | 42 | # System-level dependencies. 43 | find_package(PkgConfig REQUIRED) 44 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 45 | 46 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 47 | 48 | # Application build 49 | add_executable(${BINARY_NAME} 50 | "main.cc" 51 | "my_application.cc" 52 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 53 | ) 54 | apply_standard_settings(${BINARY_NAME}) 55 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 56 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 57 | add_dependencies(${BINARY_NAME} flutter_assemble) 58 | # Only the install-generated bundle's copy of the executable will launch 59 | # correctly, since the resources must in the right relative locations. To avoid 60 | # people trying to run the unbundled copy, put it in a subdirectory instead of 61 | # the default top-level location. 62 | set_target_properties(${BINARY_NAME} 63 | PROPERTIES 64 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 65 | ) 66 | 67 | # Generated plugin build rules, which manage building the plugins and adding 68 | # them to the application. 69 | include(flutter/generated_plugins.cmake) 70 | 71 | 72 | # === Installation === 73 | # By default, "installing" just makes a relocatable bundle in the build 74 | # directory. 75 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 76 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 77 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 78 | endif() 79 | 80 | # Start with a clean build bundle directory every time. 81 | install(CODE " 82 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 83 | " COMPONENT Runtime) 84 | 85 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 86 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 87 | 88 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 89 | COMPONENT Runtime) 90 | 91 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 92 | COMPONENT Runtime) 93 | 94 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 95 | COMPONENT Runtime) 96 | 97 | if(PLUGIN_BUNDLED_LIBRARIES) 98 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 99 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 100 | COMPONENT Runtime) 101 | endif() 102 | 103 | # Fully re-copy the assets directory on each build to avoid having stale files 104 | # from a previous install. 105 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 106 | install(CODE " 107 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 108 | " COMPONENT Runtime) 109 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 110 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 111 | 112 | # Install the AOT library on non-Debug builds only. 113 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 114 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 115 | COMPONENT Runtime) 116 | endif() 117 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | 11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 12 | # which isn't available in 3.10. 13 | function(list_prepend LIST_NAME PREFIX) 14 | set(NEW_LIST "") 15 | foreach(element ${${LIST_NAME}}) 16 | list(APPEND NEW_LIST "${PREFIX}${element}") 17 | endforeach(element) 18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 19 | endfunction() 20 | 21 | # === Flutter Library === 22 | # System-level dependencies. 23 | find_package(PkgConfig REQUIRED) 24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 27 | 28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 29 | 30 | # Published to parent scope for install step. 31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 35 | 36 | list(APPEND FLUTTER_LIBRARY_HEADERS 37 | "fl_basic_message_channel.h" 38 | "fl_binary_codec.h" 39 | "fl_binary_messenger.h" 40 | "fl_dart_project.h" 41 | "fl_engine.h" 42 | "fl_json_message_codec.h" 43 | "fl_json_method_codec.h" 44 | "fl_message_codec.h" 45 | "fl_method_call.h" 46 | "fl_method_channel.h" 47 | "fl_method_codec.h" 48 | "fl_method_response.h" 49 | "fl_plugin_registrar.h" 50 | "fl_plugin_registry.h" 51 | "fl_standard_message_codec.h" 52 | "fl_standard_method_codec.h" 53 | "fl_string_codec.h" 54 | "fl_value.h" 55 | "fl_view.h" 56 | "flutter_linux.h" 57 | ) 58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 59 | add_library(flutter INTERFACE) 60 | target_include_directories(flutter INTERFACE 61 | "${EPHEMERAL_DIR}" 62 | ) 63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 64 | target_link_libraries(flutter INTERFACE 65 | PkgConfig::GTK 66 | PkgConfig::GLIB 67 | PkgConfig::GIO 68 | ) 69 | add_dependencies(flutter flutter_assemble) 70 | 71 | # === Flutter tool backend === 72 | # _phony_ is a non-existent file to force this command to run every time, 73 | # since currently there's no way to get a full input/output list from the 74 | # flutter tool. 75 | add_custom_command( 76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 78 | COMMAND ${CMAKE_COMMAND} -E env 79 | ${FLUTTER_TOOL_ENVIRONMENT} 80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 82 | VERBATIM 83 | ) 84 | add_custom_target(flutter_assemble DEPENDS 85 | "${FLUTTER_LIBRARY}" 86 | ${FLUTTER_LIBRARY_HEADERS} 87 | ) 88 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "editor_from_scratch"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "editor_from_scratch"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | 9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 10 | } 11 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 51; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; 13 | buildPhases = ( 14 | 33CC111E2044C6BF0003C045 /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | ); 18 | name = "Flutter Assemble"; 19 | productName = FLX; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 25 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 26 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 27 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 28 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 33CC10E52044A3C60003C045 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 33CC111A2044C6BA0003C045; 37 | remoteInfo = FLX; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXCopyFilesBuildPhase section */ 42 | 33CC110E2044A8840003C045 /* Bundle Framework */ = { 43 | isa = PBXCopyFilesBuildPhase; 44 | buildActionMask = 2147483647; 45 | dstPath = ""; 46 | dstSubfolderSpec = 10; 47 | files = ( 48 | ); 49 | name = "Bundle Framework"; 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXCopyFilesBuildPhase section */ 53 | 54 | /* Begin PBXFileReference section */ 55 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 56 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; 57 | 33CC10ED2044A3C60003C045 /* editor_from_scratch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "editor_from_scratch.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 59 | 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 60 | 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 61 | 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; 62 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; 63 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 64 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 65 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; 66 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 67 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 68 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 69 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 70 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; 71 | /* End PBXFileReference section */ 72 | 73 | /* Begin PBXFrameworksBuildPhase section */ 74 | 33CC10EA2044A3C60003C045 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 33BA886A226E78AF003329D5 /* Configs */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */, 88 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 89 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 90 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, 91 | ); 92 | path = Configs; 93 | sourceTree = ""; 94 | }; 95 | 33CC10E42044A3C60003C045 = { 96 | isa = PBXGroup; 97 | children = ( 98 | 33FAB671232836740065AC1E /* Runner */, 99 | 33CEB47122A05771004F2AC0 /* Flutter */, 100 | 33CC10EE2044A3C60003C045 /* Products */, 101 | D73912EC22F37F3D000D13A0 /* Frameworks */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | 33CC10EE2044A3C60003C045 /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 33CC10ED2044A3C60003C045 /* editor_from_scratch.app */, 109 | ); 110 | name = Products; 111 | sourceTree = ""; 112 | }; 113 | 33CC11242044D66E0003C045 /* Resources */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 33CC10F22044A3C60003C045 /* Assets.xcassets */, 117 | 33CC10F42044A3C60003C045 /* MainMenu.xib */, 118 | 33CC10F72044A3C60003C045 /* Info.plist */, 119 | ); 120 | name = Resources; 121 | path = ..; 122 | sourceTree = ""; 123 | }; 124 | 33CEB47122A05771004F2AC0 /* Flutter */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, 128 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 129 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 130 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, 131 | ); 132 | path = Flutter; 133 | sourceTree = ""; 134 | }; 135 | 33FAB671232836740065AC1E /* Runner */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */, 139 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, 140 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */, 141 | 33E51914231749380026EE4D /* Release.entitlements */, 142 | 33CC11242044D66E0003C045 /* Resources */, 143 | 33BA886A226E78AF003329D5 /* Configs */, 144 | ); 145 | path = Runner; 146 | sourceTree = ""; 147 | }; 148 | D73912EC22F37F3D000D13A0 /* Frameworks */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | ); 152 | name = Frameworks; 153 | sourceTree = ""; 154 | }; 155 | /* End PBXGroup section */ 156 | 157 | /* Begin PBXNativeTarget section */ 158 | 33CC10EC2044A3C60003C045 /* Runner */ = { 159 | isa = PBXNativeTarget; 160 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; 161 | buildPhases = ( 162 | 33CC10E92044A3C60003C045 /* Sources */, 163 | 33CC10EA2044A3C60003C045 /* Frameworks */, 164 | 33CC10EB2044A3C60003C045 /* Resources */, 165 | 33CC110E2044A8840003C045 /* Bundle Framework */, 166 | 3399D490228B24CF009A79C7 /* ShellScript */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | 33CC11202044C79F0003C045 /* PBXTargetDependency */, 172 | ); 173 | name = Runner; 174 | productName = Runner; 175 | productReference = 33CC10ED2044A3C60003C045 /* editor_from_scratch.app */; 176 | productType = "com.apple.product-type.application"; 177 | }; 178 | /* End PBXNativeTarget section */ 179 | 180 | /* Begin PBXProject section */ 181 | 33CC10E52044A3C60003C045 /* Project object */ = { 182 | isa = PBXProject; 183 | attributes = { 184 | LastSwiftUpdateCheck = 0920; 185 | LastUpgradeCheck = 1300; 186 | ORGANIZATIONNAME = ""; 187 | TargetAttributes = { 188 | 33CC10EC2044A3C60003C045 = { 189 | CreatedOnToolsVersion = 9.2; 190 | LastSwiftMigration = 1100; 191 | ProvisioningStyle = Automatic; 192 | SystemCapabilities = { 193 | com.apple.Sandbox = { 194 | enabled = 1; 195 | }; 196 | }; 197 | }; 198 | 33CC111A2044C6BA0003C045 = { 199 | CreatedOnToolsVersion = 9.2; 200 | ProvisioningStyle = Manual; 201 | }; 202 | }; 203 | }; 204 | buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; 205 | compatibilityVersion = "Xcode 9.3"; 206 | developmentRegion = en; 207 | hasScannedForEncodings = 0; 208 | knownRegions = ( 209 | en, 210 | Base, 211 | ); 212 | mainGroup = 33CC10E42044A3C60003C045; 213 | productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; 214 | projectDirPath = ""; 215 | projectRoot = ""; 216 | targets = ( 217 | 33CC10EC2044A3C60003C045 /* Runner */, 218 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */, 219 | ); 220 | }; 221 | /* End PBXProject section */ 222 | 223 | /* Begin PBXResourcesBuildPhase section */ 224 | 33CC10EB2044A3C60003C045 /* Resources */ = { 225 | isa = PBXResourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 229 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | /* End PBXResourcesBuildPhase section */ 234 | 235 | /* Begin PBXShellScriptBuildPhase section */ 236 | 3399D490228B24CF009A79C7 /* ShellScript */ = { 237 | isa = PBXShellScriptBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | ); 241 | inputFileListPaths = ( 242 | ); 243 | inputPaths = ( 244 | ); 245 | outputFileListPaths = ( 246 | ); 247 | outputPaths = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | shellPath = /bin/sh; 251 | shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; 252 | }; 253 | 33CC111E2044C6BF0003C045 /* ShellScript */ = { 254 | isa = PBXShellScriptBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | ); 258 | inputFileListPaths = ( 259 | Flutter/ephemeral/FlutterInputs.xcfilelist, 260 | ); 261 | inputPaths = ( 262 | Flutter/ephemeral/tripwire, 263 | ); 264 | outputFileListPaths = ( 265 | Flutter/ephemeral/FlutterOutputs.xcfilelist, 266 | ); 267 | outputPaths = ( 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | shellPath = /bin/sh; 271 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; 272 | }; 273 | /* End PBXShellScriptBuildPhase section */ 274 | 275 | /* Begin PBXSourcesBuildPhase section */ 276 | 33CC10E92044A3C60003C045 /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, 281 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, 282 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | /* End PBXSourcesBuildPhase section */ 287 | 288 | /* Begin PBXTargetDependency section */ 289 | 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { 290 | isa = PBXTargetDependency; 291 | target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; 292 | targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; 293 | }; 294 | /* End PBXTargetDependency section */ 295 | 296 | /* Begin PBXVariantGroup section */ 297 | 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { 298 | isa = PBXVariantGroup; 299 | children = ( 300 | 33CC10F52044A3C60003C045 /* Base */, 301 | ); 302 | name = MainMenu.xib; 303 | path = Runner; 304 | sourceTree = ""; 305 | }; 306 | /* End PBXVariantGroup section */ 307 | 308 | /* Begin XCBuildConfiguration section */ 309 | 338D0CE9231458BD00FA5F75 /* Profile */ = { 310 | isa = XCBuildConfiguration; 311 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 312 | buildSettings = { 313 | ALWAYS_SEARCH_USER_PATHS = NO; 314 | CLANG_ANALYZER_NONNULL = YES; 315 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 316 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 317 | CLANG_CXX_LIBRARY = "libc++"; 318 | CLANG_ENABLE_MODULES = YES; 319 | CLANG_ENABLE_OBJC_ARC = YES; 320 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 321 | CLANG_WARN_BOOL_CONVERSION = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 324 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 325 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 326 | CLANG_WARN_EMPTY_BODY = YES; 327 | CLANG_WARN_ENUM_CONVERSION = YES; 328 | CLANG_WARN_INFINITE_RECURSION = YES; 329 | CLANG_WARN_INT_CONVERSION = YES; 330 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 331 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 332 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 333 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 334 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 335 | CODE_SIGN_IDENTITY = "-"; 336 | COPY_PHASE_STRIP = NO; 337 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 338 | ENABLE_NS_ASSERTIONS = NO; 339 | ENABLE_STRICT_OBJC_MSGSEND = YES; 340 | GCC_C_LANGUAGE_STANDARD = gnu11; 341 | GCC_NO_COMMON_BLOCKS = YES; 342 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 343 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 344 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 345 | GCC_WARN_UNUSED_FUNCTION = YES; 346 | GCC_WARN_UNUSED_VARIABLE = YES; 347 | MACOSX_DEPLOYMENT_TARGET = 10.11; 348 | MTL_ENABLE_DEBUG_INFO = NO; 349 | SDKROOT = macosx; 350 | SWIFT_COMPILATION_MODE = wholemodule; 351 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 352 | }; 353 | name = Profile; 354 | }; 355 | 338D0CEA231458BD00FA5F75 /* Profile */ = { 356 | isa = XCBuildConfiguration; 357 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 358 | buildSettings = { 359 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 360 | CLANG_ENABLE_MODULES = YES; 361 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 362 | CODE_SIGN_STYLE = Automatic; 363 | COMBINE_HIDPI_IMAGES = YES; 364 | INFOPLIST_FILE = Runner/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = ( 366 | "$(inherited)", 367 | "@executable_path/../Frameworks", 368 | ); 369 | PROVISIONING_PROFILE_SPECIFIER = ""; 370 | SWIFT_VERSION = 5.0; 371 | }; 372 | name = Profile; 373 | }; 374 | 338D0CEB231458BD00FA5F75 /* Profile */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | CODE_SIGN_STYLE = Manual; 378 | PRODUCT_NAME = "$(TARGET_NAME)"; 379 | }; 380 | name = Profile; 381 | }; 382 | 33CC10F92044A3C60003C045 /* Debug */ = { 383 | isa = XCBuildConfiguration; 384 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 385 | buildSettings = { 386 | ALWAYS_SEARCH_USER_PATHS = NO; 387 | CLANG_ANALYZER_NONNULL = YES; 388 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 389 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 390 | CLANG_CXX_LIBRARY = "libc++"; 391 | CLANG_ENABLE_MODULES = YES; 392 | CLANG_ENABLE_OBJC_ARC = YES; 393 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 394 | CLANG_WARN_BOOL_CONVERSION = YES; 395 | CLANG_WARN_CONSTANT_CONVERSION = YES; 396 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 397 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 398 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 399 | CLANG_WARN_EMPTY_BODY = YES; 400 | CLANG_WARN_ENUM_CONVERSION = YES; 401 | CLANG_WARN_INFINITE_RECURSION = YES; 402 | CLANG_WARN_INT_CONVERSION = YES; 403 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 404 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 405 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 406 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 407 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 408 | CODE_SIGN_IDENTITY = "-"; 409 | COPY_PHASE_STRIP = NO; 410 | DEBUG_INFORMATION_FORMAT = dwarf; 411 | ENABLE_STRICT_OBJC_MSGSEND = YES; 412 | ENABLE_TESTABILITY = YES; 413 | GCC_C_LANGUAGE_STANDARD = gnu11; 414 | GCC_DYNAMIC_NO_PIC = NO; 415 | GCC_NO_COMMON_BLOCKS = YES; 416 | GCC_OPTIMIZATION_LEVEL = 0; 417 | GCC_PREPROCESSOR_DEFINITIONS = ( 418 | "DEBUG=1", 419 | "$(inherited)", 420 | ); 421 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 422 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 423 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 424 | GCC_WARN_UNUSED_FUNCTION = YES; 425 | GCC_WARN_UNUSED_VARIABLE = YES; 426 | MACOSX_DEPLOYMENT_TARGET = 10.11; 427 | MTL_ENABLE_DEBUG_INFO = YES; 428 | ONLY_ACTIVE_ARCH = YES; 429 | SDKROOT = macosx; 430 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 431 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 432 | }; 433 | name = Debug; 434 | }; 435 | 33CC10FA2044A3C60003C045 /* Release */ = { 436 | isa = XCBuildConfiguration; 437 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 438 | buildSettings = { 439 | ALWAYS_SEARCH_USER_PATHS = NO; 440 | CLANG_ANALYZER_NONNULL = YES; 441 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 442 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 443 | CLANG_CXX_LIBRARY = "libc++"; 444 | CLANG_ENABLE_MODULES = YES; 445 | CLANG_ENABLE_OBJC_ARC = YES; 446 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 447 | CLANG_WARN_BOOL_CONVERSION = YES; 448 | CLANG_WARN_CONSTANT_CONVERSION = YES; 449 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 450 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 451 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 452 | CLANG_WARN_EMPTY_BODY = YES; 453 | CLANG_WARN_ENUM_CONVERSION = YES; 454 | CLANG_WARN_INFINITE_RECURSION = YES; 455 | CLANG_WARN_INT_CONVERSION = YES; 456 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 457 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 458 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 459 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 460 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 461 | CODE_SIGN_IDENTITY = "-"; 462 | COPY_PHASE_STRIP = NO; 463 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 464 | ENABLE_NS_ASSERTIONS = NO; 465 | ENABLE_STRICT_OBJC_MSGSEND = YES; 466 | GCC_C_LANGUAGE_STANDARD = gnu11; 467 | GCC_NO_COMMON_BLOCKS = YES; 468 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 469 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 470 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 471 | GCC_WARN_UNUSED_FUNCTION = YES; 472 | GCC_WARN_UNUSED_VARIABLE = YES; 473 | MACOSX_DEPLOYMENT_TARGET = 10.11; 474 | MTL_ENABLE_DEBUG_INFO = NO; 475 | SDKROOT = macosx; 476 | SWIFT_COMPILATION_MODE = wholemodule; 477 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 478 | }; 479 | name = Release; 480 | }; 481 | 33CC10FC2044A3C60003C045 /* Debug */ = { 482 | isa = XCBuildConfiguration; 483 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 484 | buildSettings = { 485 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 486 | CLANG_ENABLE_MODULES = YES; 487 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 488 | CODE_SIGN_STYLE = Automatic; 489 | COMBINE_HIDPI_IMAGES = YES; 490 | INFOPLIST_FILE = Runner/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = ( 492 | "$(inherited)", 493 | "@executable_path/../Frameworks", 494 | ); 495 | PROVISIONING_PROFILE_SPECIFIER = ""; 496 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 497 | SWIFT_VERSION = 5.0; 498 | }; 499 | name = Debug; 500 | }; 501 | 33CC10FD2044A3C60003C045 /* Release */ = { 502 | isa = XCBuildConfiguration; 503 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 504 | buildSettings = { 505 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 506 | CLANG_ENABLE_MODULES = YES; 507 | CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; 508 | CODE_SIGN_STYLE = Automatic; 509 | COMBINE_HIDPI_IMAGES = YES; 510 | INFOPLIST_FILE = Runner/Info.plist; 511 | LD_RUNPATH_SEARCH_PATHS = ( 512 | "$(inherited)", 513 | "@executable_path/../Frameworks", 514 | ); 515 | PROVISIONING_PROFILE_SPECIFIER = ""; 516 | SWIFT_VERSION = 5.0; 517 | }; 518 | name = Release; 519 | }; 520 | 33CC111C2044C6BA0003C045 /* Debug */ = { 521 | isa = XCBuildConfiguration; 522 | buildSettings = { 523 | CODE_SIGN_STYLE = Manual; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | }; 526 | name = Debug; 527 | }; 528 | 33CC111D2044C6BA0003C045 /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | buildSettings = { 531 | CODE_SIGN_STYLE = Automatic; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | }; 534 | name = Release; 535 | }; 536 | /* End XCBuildConfiguration section */ 537 | 538 | /* Begin XCConfigurationList section */ 539 | 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { 540 | isa = XCConfigurationList; 541 | buildConfigurations = ( 542 | 33CC10F92044A3C60003C045 /* Debug */, 543 | 33CC10FA2044A3C60003C045 /* Release */, 544 | 338D0CE9231458BD00FA5F75 /* Profile */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | defaultConfigurationName = Release; 548 | }; 549 | 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | 33CC10FC2044A3C60003C045 /* Debug */, 553 | 33CC10FD2044A3C60003C045 /* Release */, 554 | 338D0CEA231458BD00FA5F75 /* Profile */, 555 | ); 556 | defaultConfigurationIsVisible = 0; 557 | defaultConfigurationName = Release; 558 | }; 559 | 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { 560 | isa = XCConfigurationList; 561 | buildConfigurations = ( 562 | 33CC111C2044C6BA0003C045 /* Debug */, 563 | 33CC111D2044C6BA0003C045 /* Release */, 564 | 338D0CEB231458BD00FA5F75 /* Profile */, 565 | ); 566 | defaultConfigurationIsVisible = 0; 567 | defaultConfigurationName = Release; 568 | }; 569 | /* End XCConfigurationList section */ 570 | }; 571 | rootObject = 33CC10E52044A3C60003C045 /* Project object */; 572 | } 573 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = editor_from_scratch 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.editorFromScratch 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.files.downloads.read-write 10 | 11 | com.apple.security.network.server 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.downloads.read-write 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.16.0" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.0.4" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.3.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_lints: 66 | dependency: "direct dev" 67 | description: 68 | name: flutter_lints 69 | url: "https://pub.dartlang.org" 70 | source: hosted 71 | version: "1.0.4" 72 | flutter_test: 73 | dependency: "direct dev" 74 | description: flutter 75 | source: sdk 76 | version: "0.0.0" 77 | lints: 78 | dependency: transitive 79 | description: 80 | name: lints 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.0.1" 84 | matcher: 85 | dependency: transitive 86 | description: 87 | name: matcher 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "0.12.11" 91 | material_color_utilities: 92 | dependency: transitive 93 | description: 94 | name: material_color_utilities 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "0.1.4" 98 | meta: 99 | dependency: transitive 100 | description: 101 | name: meta 102 | url: "https://pub.dartlang.org" 103 | source: hosted 104 | version: "1.7.0" 105 | nested: 106 | dependency: transitive 107 | description: 108 | name: nested 109 | url: "https://pub.dartlang.org" 110 | source: hosted 111 | version: "1.0.0" 112 | path: 113 | dependency: transitive 114 | description: 115 | name: path 116 | url: "https://pub.dartlang.org" 117 | source: hosted 118 | version: "1.8.1" 119 | provider: 120 | dependency: "direct main" 121 | description: 122 | name: provider 123 | url: "https://pub.dartlang.org" 124 | source: hosted 125 | version: "6.0.2" 126 | sky_engine: 127 | dependency: transitive 128 | description: flutter 129 | source: sdk 130 | version: "0.0.99" 131 | source_span: 132 | dependency: transitive 133 | description: 134 | name: source_span 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.8.2" 138 | stack_trace: 139 | dependency: transitive 140 | description: 141 | name: stack_trace 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.10.0" 145 | stream_channel: 146 | dependency: transitive 147 | description: 148 | name: stream_channel 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "2.1.0" 152 | string_scanner: 153 | dependency: transitive 154 | description: 155 | name: string_scanner 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "1.1.0" 159 | term_glyph: 160 | dependency: transitive 161 | description: 162 | name: term_glyph 163 | url: "https://pub.dartlang.org" 164 | source: hosted 165 | version: "1.2.0" 166 | test_api: 167 | dependency: transitive 168 | description: 169 | name: test_api 170 | url: "https://pub.dartlang.org" 171 | source: hosted 172 | version: "0.4.9" 173 | vector_math: 174 | dependency: transitive 175 | description: 176 | name: vector_math 177 | url: "https://pub.dartlang.org" 178 | source: hosted 179 | version: "2.1.2" 180 | sdks: 181 | dart: ">=2.17.0 <3.0.0" 182 | flutter: ">=1.16.0" 183 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: editor_from_scratch 2 | description: A new Flutter project. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.17.0 <3.0.0" 22 | 23 | # Dependencies specify other packages that your package needs in order to work. 24 | # To automatically upgrade your package dependencies to the latest versions 25 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 26 | # dependencies can be manually updated by changing the version numbers below to 27 | # the latest version available on pub.dev. To see which dependencies have newer 28 | # versions available, run `flutter pub outdated`. 29 | dependencies: 30 | flutter: 31 | sdk: flutter 32 | 33 | 34 | # The following adds the Cupertino Icons font to your application. 35 | # Use with the CupertinoIcons class for iOS style icons. 36 | cupertino_icons: ^1.0.2 37 | provider: ^6.0.2 38 | 39 | dev_dependencies: 40 | flutter_test: 41 | sdk: flutter 42 | 43 | # The "flutter_lints" package below contains a set of recommended lints to 44 | # encourage good coding practices. The lint set provided by the package is 45 | # activated in the `analysis_options.yaml` file located at the root of your 46 | # package. See that file for information about deactivating specific lint 47 | # rules and activating additional ones. 48 | flutter_lints: ^1.0.0 49 | 50 | # For information on the generic Dart part of this file, see the 51 | # following page: https://dart.dev/tools/pub/pubspec 52 | 53 | # The following section is specific to Flutter. 54 | flutter: 55 | 56 | # The following line ensures that the Material Icons font is 57 | # included with your application, so that you can use the icons in 58 | # the material Icons class. 59 | uses-material-design: true 60 | 61 | fonts: 62 | - family: FiraCode 63 | fonts: 64 | - asset: fonts/FiraCode-Regular.ttf 65 | - family: SourceCodePro 66 | fonts: 67 | - asset: fonts/Source Code Pro for Powerline.otf 68 | - family: DejaVuSansMono 69 | fonts: 70 | - asset: fonts/DejaVu Sans Mono for Powerline.ttf 71 | 72 | # To add assets to your application, add an assets section, like this: 73 | # assets: 74 | # - images/a_dot_burr.jpeg 75 | # - images/a_dot_ham.jpeg 76 | 77 | # An image asset can refer to one or more resolution-specific "variants", see 78 | # https://flutter.dev/assets-and-images/#resolution-aware. 79 | 80 | # For details regarding adding assets from package dependencies, see 81 | # https://flutter.dev/assets-and-images/#from-packages 82 | 83 | # To add custom fonts to your application, add a fonts section here, 84 | # in this "flutter" section. Each entry in this list should have a 85 | # "family" key with the font family name, and a "fonts" key with a 86 | # list giving the asset and other descriptors for the font. For 87 | # example: 88 | # fonts: 89 | # - family: Schyler 90 | # fonts: 91 | # - asset: fonts/Schyler-Regular.ttf 92 | # - asset: fonts/Schyler-Italic.ttf 93 | # style: italic 94 | # - family: Trajan Pro 95 | # fonts: 96 | # - asset: fonts/TrajanPro.ttf 97 | # - asset: fonts/TrajanPro_Bold.ttf 98 | # weight: 700 99 | # 100 | # For details regarding fonts from package dependencies, 101 | # see https://flutter.dev/custom-fonts/#from-packages 102 | -------------------------------------------------------------------------------- /screenshots/basic-editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icedman/editor_from_scratch/2d632497ae75c34872b0443785026ebdf689a70b/screenshots/basic-editor.png -------------------------------------------------------------------------------- /test/doc_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:editor_from_scratch/document.dart'; 2 | 3 | Document docTestRun() { 4 | Document d = Document(); 5 | d.insertText('hello '); 6 | d.insertText('world'); 7 | d.moveCursorLeft(count: 5); 8 | d.insertText('flutter'); 9 | d.deleteText(numberOfCharacters: 5); 10 | d.insertText('\n'); 11 | d.insertText('another line'); 12 | d.insertText('\n'); 13 | d.insertText('and another line'); 14 | d.moveCursorUp(); 15 | d.moveCursorToStartOfLine(); 16 | d.deleteText(numberOfCharacters: 'another line'.length); 17 | d.moveCursorDown(count: 1); 18 | d.insertNewLine(); 19 | d.insertText('and yet another line'); 20 | d.moveCursorUp(count: 2); 21 | d.moveCursorToStartOfLine(); 22 | d.moveCursorRight(count: 4); 23 | d.moveCursorDown(count: 2, keepAnchor: true); 24 | d.moveCursorRight(count: 4, keepAnchor: true); 25 | // d.output(); 26 | //d.moveCursorToEndOfLine(keepAnchor: true); 27 | d.deleteSelectedText(); 28 | // d.output(); 29 | //d.deleteLine(); 30 | //d.output(); 31 | //d.moveCursorRight(count: 2); 32 | //d.moveCursorRight(count: 5, keepAnchor: true); 33 | //d.output(); 34 | //d.deleteSelectedText(); 35 | //d.output(); 36 | return d; 37 | } 38 | 39 | void main() { 40 | docTestRun(); 41 | } 42 | -------------------------------------------------------------------------------- /tests/tinywl.c: -------------------------------------------------------------------------------- 1 | #define _POSIX_C_SOURCE 200112 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | /* For brevity's sake, struct members are annotated where they are used. */ 27 | enum tinywl_cursor_mode { 28 | TINYWL_CURSOR_PASSTHROUGH, 29 | TINYWL_CURSOR_MOVE, 30 | TINYWL_CURSOR_RESIZE, 31 | }; 32 | 33 | struct tinywl_server { 34 | struct wl_display* wl_display; 35 | struct wlr_backend* backend; 36 | struct wlr_renderer* renderer; 37 | 38 | struct wlr_xdg_shell* xdg_shell; 39 | struct wl_listener new_xdg_surface; 40 | struct wl_list views; 41 | 42 | struct wlr_cursor* cursor; 43 | struct wlr_xcursor_manager* cursor_mgr; 44 | struct wl_listener cursor_motion; 45 | struct wl_listener cursor_motion_absolute; 46 | struct wl_listener cursor_button; 47 | struct wl_listener cursor_axis; 48 | struct wl_listener cursor_frame; 49 | 50 | struct wlr_seat* seat; 51 | struct wl_listener new_input; 52 | struct wl_listener request_cursor; 53 | struct wl_listener request_set_selection; 54 | struct wl_list keyboards; 55 | enum tinywl_cursor_mode cursor_mode; 56 | struct tinywl_view* grabbed_view; 57 | double grab_x, grab_y; 58 | struct wlr_box grab_geobox; 59 | uint32_t resize_edges; 60 | 61 | struct wlr_output_layout* output_layout; 62 | struct wl_list outputs; 63 | struct wl_listener new_output; 64 | }; 65 | 66 | struct tinywl_output { 67 | struct wl_list link; 68 | struct tinywl_server* server; 69 | struct wlr_output* wlr_output; 70 | struct wl_listener frame; 71 | }; 72 | 73 | struct tinywl_view { 74 | struct wl_list link; 75 | struct tinywl_server* server; 76 | struct wlr_xdg_surface* xdg_surface; 77 | struct wl_listener map; 78 | struct wl_listener unmap; 79 | struct wl_listener destroy; 80 | struct wl_listener request_move; 81 | struct wl_listener request_resize; 82 | bool mapped; 83 | int x, y; 84 | }; 85 | 86 | struct tinywl_keyboard { 87 | struct wl_list link; 88 | struct tinywl_server* server; 89 | struct wlr_input_device* device; 90 | 91 | struct wl_listener modifiers; 92 | struct wl_listener key; 93 | }; 94 | 95 | static void focus_view(struct tinywl_view* view, struct wlr_surface* surface) 96 | { 97 | /* Note: this function only deals with keyboard focus. */ 98 | if (view == NULL) { 99 | return; 100 | } 101 | struct tinywl_server* server = view->server; 102 | struct wlr_seat* seat = server->seat; 103 | struct wlr_surface* prev_surface = seat->keyboard_state.focused_surface; 104 | if (prev_surface == surface) { 105 | /* Don't re-focus an already focused surface. */ 106 | return; 107 | } 108 | if (prev_surface) { 109 | /* 110 | * Deactivate the previously focused surface. This lets the client know 111 | * it no longer has focus and the client will repaint accordingly, e.g. 112 | * stop displaying a caret. 113 | */ 114 | struct wlr_xdg_surface* previous = wlr_xdg_surface_from_wlr_surface(seat->keyboard_state.focused_surface); 115 | wlr_xdg_toplevel_set_activated(previous, false); 116 | } 117 | struct wlr_keyboard* keyboard = wlr_seat_get_keyboard(seat); 118 | /* Move the view to the front */ 119 | wl_list_remove(&view->link); 120 | wl_list_insert(&server->views, &view->link); 121 | /* Activate the new surface */ 122 | wlr_xdg_toplevel_set_activated(view->xdg_surface, true); 123 | /* 124 | * Tell the seat to have the keyboard enter this surface. wlroots will keep 125 | * track of this and automatically send key events to the appropriate 126 | * clients without additional work on your part. 127 | */ 128 | wlr_seat_keyboard_notify_enter(seat, view->xdg_surface->surface, 129 | keyboard->keycodes, keyboard->num_keycodes, 130 | &keyboard->modifiers); 131 | } 132 | 133 | static void keyboard_handle_modifiers(struct wl_listener* listener, 134 | void* data) 135 | { 136 | /* This event is raised when a modifier key, such as shift or alt, is 137 | * pressed. We simply communicate this to the client. */ 138 | struct tinywl_keyboard* keyboard = wl_container_of(listener, keyboard, modifiers); 139 | /* 140 | * A seat can only have one keyboard, but this is a limitation of the 141 | * Wayland protocol - not wlroots. We assign all connected keyboards to the 142 | * same seat. You can swap out the underlying wlr_keyboard like this and 143 | * wlr_seat handles this transparently. 144 | */ 145 | wlr_seat_set_keyboard(keyboard->server->seat, keyboard->device); 146 | /* Send modifiers to the client. */ 147 | wlr_seat_keyboard_notify_modifiers(keyboard->server->seat, 148 | &keyboard->device->keyboard->modifiers); 149 | } 150 | 151 | static bool handle_keybinding(struct tinywl_server* server, xkb_keysym_t sym) 152 | { 153 | /* 154 | * Here we handle compositor keybindings. This is when the compositor is 155 | * processing keys, rather than passing them on to the client for its own 156 | * processing. 157 | * 158 | * This function assumes Alt is held down. 159 | */ 160 | switch (sym) { 161 | case XKB_KEY_Escape: 162 | wl_display_terminate(server->wl_display); 163 | break; 164 | case XKB_KEY_F1: 165 | /* Cycle to the next view */ 166 | if (wl_list_length(&server->views) < 2) { 167 | break; 168 | } 169 | struct tinywl_view* current_view = wl_container_of(server->views.next, current_view, link); 170 | struct tinywl_view* next_view = wl_container_of(current_view->link.next, next_view, link); 171 | focus_view(next_view, next_view->xdg_surface->surface); 172 | /* Move the previous view to the end of the list */ 173 | wl_list_remove(¤t_view->link); 174 | wl_list_insert(server->views.prev, ¤t_view->link); 175 | break; 176 | default: 177 | return false; 178 | } 179 | return true; 180 | } 181 | 182 | static void keyboard_handle_key(struct wl_listener* listener, void* data) 183 | { 184 | /* This event is raised when a key is pressed or released. */ 185 | struct tinywl_keyboard* keyboard = wl_container_of(listener, keyboard, key); 186 | struct tinywl_server* server = keyboard->server; 187 | struct wlr_event_keyboard_key* event = data; 188 | struct wlr_seat* seat = server->seat; 189 | 190 | /* Translate libinput keycode -> xkbcommon */ 191 | uint32_t keycode = event->keycode + 8; 192 | /* Get a list of keysyms based on the keymap for this keyboard */ 193 | const xkb_keysym_t* syms; 194 | int nsyms = xkb_state_key_get_syms(keyboard->device->keyboard->xkb_state, 195 | keycode, &syms); 196 | 197 | bool handled = false; 198 | uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard); 199 | if ((modifiers & WLR_MODIFIER_ALT) && event->state == WLR_KEY_PRESSED) { 200 | /* If alt is held down and this button was _pressed_, we attempt to 201 | * process it as a compositor keybinding. */ 202 | for (int i = 0; i < nsyms; i++) { 203 | handled = handle_keybinding(server, syms[i]); 204 | } 205 | } 206 | 207 | if (!handled) { 208 | /* Otherwise, we pass it along to the client. */ 209 | wlr_seat_set_keyboard(seat, keyboard->device); 210 | wlr_seat_keyboard_notify_key(seat, event->time_msec, event->keycode, 211 | event->state); 212 | } 213 | } 214 | 215 | static void server_new_keyboard(struct tinywl_server* server, 216 | struct wlr_input_device* device) 217 | { 218 | struct tinywl_keyboard* keyboard = calloc(1, sizeof(struct tinywl_keyboard)); 219 | keyboard->server = server; 220 | keyboard->device = device; 221 | 222 | /* We need to prepare an XKB keymap and assign it to the keyboard. This 223 | * assumes the defaults (e.g. layout = "us"). */ 224 | struct xkb_rule_names rules = { 0 }; 225 | struct xkb_context* context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); 226 | struct xkb_keymap* keymap = xkb_map_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); 227 | 228 | wlr_keyboard_set_keymap(device->keyboard, keymap); 229 | xkb_keymap_unref(keymap); 230 | xkb_context_unref(context); 231 | wlr_keyboard_set_repeat_info(device->keyboard, 25, 600); 232 | 233 | /* Here we set up listeners for keyboard events. */ 234 | keyboard->modifiers.notify = keyboard_handle_modifiers; 235 | wl_signal_add(&device->keyboard->events.modifiers, &keyboard->modifiers); 236 | keyboard->key.notify = keyboard_handle_key; 237 | wl_signal_add(&device->keyboard->events.key, &keyboard->key); 238 | 239 | wlr_seat_set_keyboard(server->seat, device); 240 | 241 | /* And add the keyboard to our list of keyboards */ 242 | wl_list_insert(&server->keyboards, &keyboard->link); 243 | } 244 | 245 | static void server_new_pointer(struct tinywl_server* server, 246 | struct wlr_input_device* device) 247 | { 248 | /* We don't do anything special with pointers. All of our pointer handling 249 | * is proxied through wlr_cursor. On another compositor, you might take this 250 | * opportunity to do libinput configuration on the device to set 251 | * acceleration, etc. */ 252 | wlr_cursor_attach_input_device(server->cursor, device); 253 | } 254 | 255 | static void server_new_input(struct wl_listener* listener, void* data) 256 | { 257 | /* This event is raised by the backend when a new input device becomes 258 | * available. */ 259 | struct tinywl_server* server = wl_container_of(listener, server, new_input); 260 | struct wlr_input_device* device = data; 261 | switch (device->type) { 262 | case WLR_INPUT_DEVICE_KEYBOARD: 263 | server_new_keyboard(server, device); 264 | break; 265 | case WLR_INPUT_DEVICE_POINTER: 266 | server_new_pointer(server, device); 267 | break; 268 | default: 269 | break; 270 | } 271 | /* We need to let the wlr_seat know what our capabilities are, which is 272 | * communiciated to the client. In TinyWL we always have a cursor, even if 273 | * there are no pointer devices, so we always include that capability. */ 274 | uint32_t caps = WL_SEAT_CAPABILITY_POINTER; 275 | if (!wl_list_empty(&server->keyboards)) { 276 | caps |= WL_SEAT_CAPABILITY_KEYBOARD; 277 | } 278 | wlr_seat_set_capabilities(server->seat, caps); 279 | } 280 | 281 | static void seat_request_cursor(struct wl_listener* listener, void* data) 282 | { 283 | struct tinywl_server* server = wl_container_of(listener, server, request_cursor); 284 | /* This event is rasied by the seat when a client provides a cursor image */ 285 | struct wlr_seat_pointer_request_set_cursor_event* event = data; 286 | struct wlr_seat_client* focused_client = server->seat->pointer_state.focused_client; 287 | /* This can be sent by any client, so we check to make sure this one is 288 | * actually has pointer focus first. */ 289 | if (focused_client == event->seat_client) { 290 | /* Once we've vetted the client, we can tell the cursor to use the 291 | * provided surface as the cursor image. It will set the hardware cursor 292 | * on the output that it's currently on and continue to do so as the 293 | * cursor moves between outputs. */ 294 | wlr_cursor_set_surface(server->cursor, event->surface, event->hotspot_x, 295 | event->hotspot_y); 296 | } 297 | } 298 | 299 | static void seat_request_set_selection(struct wl_listener* listener, 300 | void* data) 301 | { 302 | /* This event is raised by the seat when a client wants to set the selection, 303 | * usually when the user copies something. wlroots allows compositors to 304 | * ignore such requests if they so choose, but in tinywl we always honor 305 | */ 306 | struct tinywl_server* server = wl_container_of(listener, server, request_set_selection); 307 | struct wlr_seat_request_set_selection_event* event = data; 308 | wlr_seat_set_selection(server->seat, event->source, event->serial); 309 | } 310 | 311 | static bool view_at(struct tinywl_view* view, double lx, double ly, 312 | struct wlr_surface** surface, double* sx, double* sy) 313 | { 314 | /* 315 | * XDG toplevels may have nested surfaces, such as popup windows for context 316 | * menus or tooltips. This function tests if any of those are underneath the 317 | * coordinates lx and ly (in output Layout Coordinates). If so, it sets the 318 | * surface pointer to that wlr_surface and the sx and sy coordinates to the 319 | * coordinates relative to that surface's top-left corner. 320 | */ 321 | double view_sx = lx - view->x; 322 | double view_sy = ly - view->y; 323 | 324 | double _sx, _sy; 325 | struct wlr_surface* _surface = NULL; 326 | _surface = wlr_xdg_surface_surface_at(view->xdg_surface, view_sx, view_sy, 327 | &_sx, &_sy); 328 | 329 | if (_surface != NULL) { 330 | *sx = _sx; 331 | *sy = _sy; 332 | *surface = _surface; 333 | return true; 334 | } 335 | 336 | return false; 337 | } 338 | 339 | static struct tinywl_view* desktop_view_at(struct tinywl_server* server, 340 | double lx, double ly, 341 | struct wlr_surface** surface, 342 | double* sx, double* sy) 343 | { 344 | /* This iterates over all of our surfaces and attempts to find one under the 345 | * cursor. This relies on server->views being ordered from top-to-bottom. */ 346 | struct tinywl_view* view; 347 | wl_list_for_each(view, &server->views, link) 348 | { 349 | if (view_at(view, lx, ly, surface, sx, sy)) { 350 | return view; 351 | } 352 | } 353 | return NULL; 354 | } 355 | 356 | static void process_cursor_move(struct tinywl_server* server, uint32_t time) 357 | { 358 | /* Move the grabbed view to the new position. */ 359 | server->grabbed_view->x = server->cursor->x - server->grab_x; 360 | server->grabbed_view->y = server->cursor->y - server->grab_y; 361 | } 362 | 363 | static void process_cursor_resize(struct tinywl_server* server, uint32_t time) 364 | { 365 | /* 366 | * Resizing the grabbed view can be a little bit complicated, because we 367 | * could be resizing from any corner or edge. This not only resizes the view 368 | * on one or two axes, but can also move the view if you resize from the top 369 | * or left edges (or top-left corner). 370 | * 371 | * Note that I took some shortcuts here. In a more fleshed-out compositor, 372 | * you'd wait for the client to prepare a buffer at the new size, then 373 | * commit any movement that was prepared. 374 | */ 375 | struct tinywl_view* view = server->grabbed_view; 376 | double border_x = server->cursor->x - server->grab_x; 377 | double border_y = server->cursor->y - server->grab_y; 378 | int new_left = server->grab_geobox.x; 379 | int new_right = server->grab_geobox.x + server->grab_geobox.width; 380 | int new_top = server->grab_geobox.y; 381 | int new_bottom = server->grab_geobox.y + server->grab_geobox.height; 382 | 383 | if (server->resize_edges & WLR_EDGE_TOP) { 384 | new_top = border_y; 385 | if (new_top >= new_bottom) { 386 | new_top = new_bottom - 1; 387 | } 388 | } else if (server->resize_edges & WLR_EDGE_BOTTOM) { 389 | new_bottom = border_y; 390 | if (new_bottom <= new_top) { 391 | new_bottom = new_top + 1; 392 | } 393 | } 394 | if (server->resize_edges & WLR_EDGE_LEFT) { 395 | new_left = border_x; 396 | if (new_left >= new_right) { 397 | new_left = new_right - 1; 398 | } 399 | } else if (server->resize_edges & WLR_EDGE_RIGHT) { 400 | new_right = border_x; 401 | if (new_right <= new_left) { 402 | new_right = new_left + 1; 403 | } 404 | } 405 | 406 | struct wlr_box geo_box; 407 | wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box); 408 | view->x = new_left - geo_box.x; 409 | view->y = new_top - geo_box.y; 410 | 411 | int new_width = new_right - new_left; 412 | int new_height = new_bottom - new_top; 413 | wlr_xdg_toplevel_set_size(view->xdg_surface, new_width, new_height); 414 | } 415 | 416 | static void process_cursor_motion(struct tinywl_server* server, uint32_t time) 417 | { 418 | /* If the mode is non-passthrough, delegate to those functions. */ 419 | if (server->cursor_mode == TINYWL_CURSOR_MOVE) { 420 | process_cursor_move(server, time); 421 | return; 422 | } else if (server->cursor_mode == TINYWL_CURSOR_RESIZE) { 423 | process_cursor_resize(server, time); 424 | return; 425 | } 426 | 427 | /* Otherwise, find the view under the pointer and send the event along. */ 428 | double sx, sy; 429 | struct wlr_seat* seat = server->seat; 430 | struct wlr_surface* surface = NULL; 431 | struct tinywl_view* view = desktop_view_at( 432 | server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); 433 | if (!view) { 434 | /* If there's no view under the cursor, set the cursor image to a 435 | * default. This is what makes the cursor image appear when you move it 436 | * around the screen, not over any views. */ 437 | wlr_xcursor_manager_set_cursor_image(server->cursor_mgr, "left_ptr", 438 | server->cursor); 439 | } 440 | if (surface) { 441 | bool focus_changed = seat->pointer_state.focused_surface != surface; 442 | /* 443 | * "Enter" the surface if necessary. This lets the client know that the 444 | * cursor has entered one of its surfaces. 445 | * 446 | * Note that this gives the surface "pointer focus", which is distinct 447 | * from keyboard focus. You get pointer focus by moving the pointer over 448 | * a window. 449 | */ 450 | wlr_seat_pointer_notify_enter(seat, surface, sx, sy); 451 | if (!focus_changed) { 452 | /* The enter event contains coordinates, so we only need to notify 453 | * on motion if the focus did not change. */ 454 | wlr_seat_pointer_notify_motion(seat, time, sx, sy); 455 | } 456 | } else { 457 | /* Clear pointer focus so future button events and such are not sent to 458 | * the last client to have the cursor over it. */ 459 | wlr_seat_pointer_clear_focus(seat); 460 | } 461 | } 462 | 463 | static void server_cursor_motion(struct wl_listener* listener, void* data) 464 | { 465 | /* This event is forwarded by the cursor when a pointer emits a _relative_ 466 | * pointer motion event (i.e. a delta) */ 467 | struct tinywl_server* server = wl_container_of(listener, server, cursor_motion); 468 | struct wlr_event_pointer_motion* event = data; 469 | /* The cursor doesn't move unless we tell it to. The cursor automatically 470 | * handles constraining the motion to the output layout, as well as any 471 | * special configuration applied for the specific input device which 472 | * generated the event. You can pass NULL for the device if you want to move 473 | * the cursor around without any input. */ 474 | wlr_cursor_move(server->cursor, event->device, event->delta_x, 475 | event->delta_y); 476 | process_cursor_motion(server, event->time_msec); 477 | } 478 | 479 | static void server_cursor_motion_absolute(struct wl_listener* listener, 480 | void* data) 481 | { 482 | /* This event is forwarded by the cursor when a pointer emits an _absolute_ 483 | * motion event, from 0..1 on each axis. This happens, for example, when 484 | * wlroots is running under a Wayland window rather than KMS+DRM, and you 485 | * move the mouse over the window. You could enter the window from any edge, 486 | * so we have to warp the mouse there. There is also some hardware which 487 | * emits these events. */ 488 | struct tinywl_server* server = wl_container_of(listener, server, cursor_motion_absolute); 489 | struct wlr_event_pointer_motion_absolute* event = data; 490 | wlr_cursor_warp_absolute(server->cursor, event->device, event->x, event->y); 491 | process_cursor_motion(server, event->time_msec); 492 | } 493 | 494 | static void server_cursor_button(struct wl_listener* listener, void* data) 495 | { 496 | /* This event is forwarded by the cursor when a pointer emits a button 497 | * event. */ 498 | struct tinywl_server* server = wl_container_of(listener, server, cursor_button); 499 | struct wlr_event_pointer_button* event = data; 500 | /* Notify the client with pointer focus that a button press has occurred */ 501 | wlr_seat_pointer_notify_button(server->seat, event->time_msec, event->button, 502 | event->state); 503 | 504 | double sx, sy; 505 | struct wlr_surface* surface; 506 | 507 | struct tinywl_view* view = desktop_view_at( 508 | server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); 509 | 510 | if (event->state == WLR_BUTTON_RELEASED) { 511 | /* If you released any buttons, we exit interactive move/resize mode. */ 512 | server->cursor_mode = TINYWL_CURSOR_PASSTHROUGH; 513 | } else { 514 | /* Focus that client if the button was _pressed_ */ 515 | focus_view(view, surface); 516 | } 517 | } 518 | 519 | static void server_cursor_axis(struct wl_listener* listener, void* data) 520 | { 521 | /* This event is forwarded by the cursor when a pointer emits an axis event, 522 | * for example when you move the scroll wheel. */ 523 | struct tinywl_server* server = wl_container_of(listener, server, cursor_axis); 524 | struct wlr_event_pointer_axis* event = data; 525 | /* Notify the client with pointer focus of the axis event. */ 526 | wlr_seat_pointer_notify_axis(server->seat, event->time_msec, 527 | event->orientation, event->delta, 528 | event->delta_discrete, event->source); 529 | } 530 | 531 | static void server_cursor_frame(struct wl_listener* listener, void* data) 532 | { 533 | /* This event is forwarded by the cursor when a pointer emits an frame 534 | * event. Frame events are sent after regular pointer events to group 535 | * multiple events together. For instance, two axis events may happen at the 536 | * same time, in which case a frame event won't be sent in between. */ 537 | struct tinywl_server* server = wl_container_of(listener, server, cursor_frame); 538 | /* Notify the client with pointer focus of the frame event. */ 539 | wlr_seat_pointer_notify_frame(server->seat); 540 | } 541 | 542 | /* Used to move all of the data necessary to render a surface from the top-level 543 | * frame handler to the per-surface render function. */ 544 | struct render_data { 545 | struct wlr_output* output; 546 | struct wlr_renderer* renderer; 547 | struct tinywl_view* view; 548 | struct timespec* when; 549 | }; 550 | 551 | static void render_surface(struct wlr_surface* surface, int sx, int sy, 552 | void* data) 553 | { 554 | /* This function is called for every surface that needs to be rendered. */ 555 | struct render_data* rdata = data; 556 | struct tinywl_view* view = rdata->view; 557 | struct wlr_output* output = rdata->output; 558 | 559 | /* We first obtain a wlr_texture, which is a GPU resource. wlroots 560 | * automatically handles negotiating these with the client. The underlying 561 | * resource could be an opaque handle passed from the client, or the client 562 | * could have sent a pixel buffer which we copied to the GPU, or a few other 563 | * means. You don't have to worry about this, wlroots takes care of it. */ 564 | struct wlr_texture* texture = wlr_surface_get_texture(surface); 565 | if (texture == NULL) { 566 | return; 567 | } 568 | 569 | /* The view has a position in layout coordinates. If you have two displays, 570 | * one next to the other, both 1080p, a view on the rightmost display might 571 | * have layout coordinates of 2000,100. We need to translate that to 572 | * output-local coordinates, or (2000 - 1920). */ 573 | double ox = 0, oy = 0; 574 | wlr_output_layout_output_coords(view->server->output_layout, output, &ox, 575 | &oy); 576 | ox += view->x + sx, oy += view->y + sy; 577 | 578 | /* We also have to apply the scale factor for HiDPI outputs. This is only 579 | * part of the puzzle, TinyWL does not fully support HiDPI. */ 580 | struct wlr_box box = { 581 | .x = ox * output->scale, 582 | .y = oy * output->scale, 583 | .width = surface->current.width * output->scale, 584 | .height = surface->current.height * output->scale, 585 | }; 586 | 587 | /* 588 | * Those familiar with OpenGL are also familiar with the role of matricies 589 | * in graphics programming. We need to prepare a matrix to render the view 590 | * with. wlr_matrix_project_box is a helper which takes a box with a desired 591 | * x, y coordinates, width and height, and an output geometry, then 592 | * prepares an orthographic projection and multiplies the necessary 593 | * transforms to produce a model-view-projection matrix. 594 | * 595 | * Naturally you can do this any way you like, for example to make a 3D 596 | * compositor. 597 | */ 598 | float matrix[9]; 599 | enum wl_output_transform transform = wlr_output_transform_invert(surface->current.transform); 600 | wlr_matrix_project_box(matrix, &box, transform, 0, output->transform_matrix); 601 | 602 | /* This takes our matrix, the texture, and an alpha, and performs the actual 603 | * rendering on the GPU. */ 604 | wlr_render_texture_with_matrix(rdata->renderer, texture, matrix, 1); 605 | 606 | /* This lets the client know that we've displayed that frame and it can 607 | * prepare another one now if it likes. */ 608 | wlr_surface_send_frame_done(surface, rdata->when); 609 | } 610 | 611 | static void output_frame(struct wl_listener* listener, void* data) 612 | { 613 | /* This function is called every time an output is ready to display a frame, 614 | * generally at the output's refresh rate (e.g. 60Hz). */ 615 | struct tinywl_output* output = wl_container_of(listener, output, frame); 616 | struct wlr_renderer* renderer = output->server->renderer; 617 | 618 | struct timespec now; 619 | clock_gettime(CLOCK_MONOTONIC, &now); 620 | 621 | /* wlr_output_attach_render makes the OpenGL context current. */ 622 | if (!wlr_output_attach_render(output->wlr_output, NULL)) { 623 | return; 624 | } 625 | /* The "effective" resolution can change if you rotate your outputs. */ 626 | int width, height; 627 | wlr_output_effective_resolution(output->wlr_output, &width, &height); 628 | /* Begin the renderer (calls glViewport and some other GL sanity checks) */ 629 | wlr_renderer_begin(renderer, width, height); 630 | 631 | float color[4] = { 0.3, 0.3, 0.3, 1.0 }; 632 | wlr_renderer_clear(renderer, color); 633 | 634 | /* Each subsequent window we render is rendered on top of the last. Because 635 | * our view list is ordered front-to-back, we iterate over it backwards. */ 636 | struct tinywl_view* view; 637 | wl_list_for_each_reverse(view, &output->server->views, link) 638 | { 639 | if (!view->mapped) { 640 | /* An unmapped view should not be rendered. */ 641 | continue; 642 | } 643 | struct render_data rdata = { 644 | .output = output->wlr_output, 645 | .view = view, 646 | .renderer = renderer, 647 | .when = &now, 648 | }; 649 | /* This calls our render_surface function for each surface among the 650 | * xdg_surface's toplevel and popups. */ 651 | wlr_xdg_surface_for_each_surface(view->xdg_surface, render_surface, &rdata); 652 | } 653 | 654 | /* Hardware cursors are rendered by the GPU on a separate plane, and can be 655 | * moved around without re-rendering what's beneath them - which is more 656 | * efficient. However, not all hardware supports hardware cursors. For this 657 | * reason, wlroots provides a software fallback, which we ask it to render 658 | * here. wlr_cursor handles configuring hardware vs software cursors for you, 659 | * and this function is a no-op when hardware cursors are in use. */ 660 | wlr_output_render_software_cursors(output->wlr_output, NULL); 661 | 662 | /* Conclude rendering and swap the buffers, showing the final frame 663 | * on-screen. */ 664 | wlr_renderer_end(renderer); 665 | wlr_output_commit(output->wlr_output); 666 | } 667 | 668 | static void server_new_output(struct wl_listener* listener, void* data) 669 | { 670 | /* This event is rasied by the backend when a new output (aka a display or 671 | * monitor) becomes available. */ 672 | struct tinywl_server* server = wl_container_of(listener, server, new_output); 673 | struct wlr_output* wlr_output = data; 674 | 675 | /* Some backends don't have modes. DRM+KMS does, and we need to set a mode 676 | * before we can use the output. The mode is a tuple of (width, height, 677 | * refresh rate), and each monitor supports only a specific set of modes. We 678 | * just pick the monitor's preferred mode, a more sophisticated compositor 679 | * would let the user configure it. */ 680 | if (!wl_list_empty(&wlr_output->modes)) { 681 | struct wlr_output_mode* mode = wlr_output_preferred_mode(wlr_output); 682 | wlr_output_set_mode(wlr_output, mode); 683 | wlr_output_enable(wlr_output, true); 684 | if (!wlr_output_commit(wlr_output)) { 685 | return; 686 | } 687 | } 688 | 689 | /* Allocates and configures our state for this output */ 690 | struct tinywl_output* output = calloc(1, sizeof(struct tinywl_output)); 691 | output->wlr_output = wlr_output; 692 | output->server = server; 693 | /* Sets up a listener for the frame notify event. */ 694 | output->frame.notify = output_frame; 695 | wl_signal_add(&wlr_output->events.frame, &output->frame); 696 | wl_list_insert(&server->outputs, &output->link); 697 | 698 | /* Adds this to the output layout. The add_auto function arranges outputs 699 | * from left-to-right in the order they appear. A more sophisticated 700 | * compositor would let the user configure the arrangement of outputs in the 701 | * layout. 702 | * 703 | * The output layout utility automatically adds a wl_output global to the 704 | * display, which Wayland clients can see to find out information about the 705 | * output (such as DPI, scale factor, manufacturer, etc). 706 | */ 707 | wlr_output_layout_add_auto(server->output_layout, wlr_output); 708 | } 709 | 710 | static void xdg_surface_map(struct wl_listener* listener, void* data) 711 | { 712 | /* Called when the surface is mapped, or ready to display on-screen. */ 713 | struct tinywl_view* view = wl_container_of(listener, view, map); 714 | view->mapped = true; 715 | focus_view(view, view->xdg_surface->surface); 716 | } 717 | 718 | static void xdg_surface_unmap(struct wl_listener* listener, void* data) 719 | { 720 | /* Called when the surface is unmapped, and should no longer be shown. */ 721 | struct tinywl_view* view = wl_container_of(listener, view, unmap); 722 | view->mapped = false; 723 | } 724 | 725 | static void xdg_surface_destroy(struct wl_listener* listener, void* data) 726 | { 727 | /* Called when the surface is destroyed and should never be shown again. */ 728 | struct tinywl_view* view = wl_container_of(listener, view, destroy); 729 | wl_list_remove(&view->link); 730 | free(view); 731 | } 732 | 733 | static void begin_interactive(struct tinywl_view* view, 734 | enum tinywl_cursor_mode mode, uint32_t edges) 735 | { 736 | /* This function sets up an interactive move or resize operation, where the 737 | * compositor stops propegating pointer events to clients and instead 738 | * consumes them itself, to move or resize windows. */ 739 | struct tinywl_server* server = view->server; 740 | struct wlr_surface* focused_surface = server->seat->pointer_state.focused_surface; 741 | if (view->xdg_surface->surface != focused_surface) { 742 | /* Deny move/resize requests from unfocused clients. */ 743 | return; 744 | } 745 | server->grabbed_view = view; 746 | server->cursor_mode = mode; 747 | 748 | if (mode == TINYWL_CURSOR_MOVE) { 749 | server->grab_x = server->cursor->x - view->x; 750 | server->grab_y = server->cursor->y - view->y; 751 | } else { 752 | struct wlr_box geo_box; 753 | wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box); 754 | 755 | double border_x = (view->x + geo_box.x) + ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0); 756 | double border_y = (view->y + geo_box.y) + ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0); 757 | server->grab_x = server->cursor->x - border_x; 758 | server->grab_y = server->cursor->y - border_y; 759 | 760 | server->grab_geobox = geo_box; 761 | server->grab_geobox.x += view->x; 762 | server->grab_geobox.y += view->y; 763 | 764 | server->resize_edges = edges; 765 | } 766 | } 767 | 768 | static void xdg_toplevel_request_move(struct wl_listener* listener, 769 | void* data) 770 | { 771 | /* This event is raised when a client would like to begin an interactive 772 | * move, typically because the user clicked on their client-side 773 | * decorations. Note that a more sophisticated compositor should check the 774 | * provied serial against a list of button press serials sent to this 775 | * client, to prevent the client from requesting this whenever they want. */ 776 | struct tinywl_view* view = wl_container_of(listener, view, request_move); 777 | begin_interactive(view, TINYWL_CURSOR_MOVE, 0); 778 | } 779 | 780 | static void xdg_toplevel_request_resize(struct wl_listener* listener, 781 | void* data) 782 | { 783 | /* This event is raised when a client would like to begin an interactive 784 | * resize, typically because the user clicked on their client-side 785 | * decorations. Note that a more sophisticated compositor should check the 786 | * provied serial against a list of button press serials sent to this 787 | * client, to prevent the client from requesting this whenever they want. */ 788 | struct wlr_xdg_toplevel_resize_event* event = data; 789 | struct tinywl_view* view = wl_container_of(listener, view, request_resize); 790 | begin_interactive(view, TINYWL_CURSOR_RESIZE, event->edges); 791 | } 792 | 793 | static void server_new_xdg_surface(struct wl_listener* listener, void* data) 794 | { 795 | /* This event is raised when wlr_xdg_shell receives a new xdg surface from a 796 | * client, either a toplevel (application window) or popup. */ 797 | struct tinywl_server* server = wl_container_of(listener, server, new_xdg_surface); 798 | struct wlr_xdg_surface* xdg_surface = data; 799 | if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) { 800 | return; 801 | } 802 | 803 | /* Allocate a tinywl_view for this surface */ 804 | struct tinywl_view* view = calloc(1, sizeof(struct tinywl_view)); 805 | view->server = server; 806 | view->xdg_surface = xdg_surface; 807 | 808 | /* Listen to the various events it can emit */ 809 | view->map.notify = xdg_surface_map; 810 | wl_signal_add(&xdg_surface->events.map, &view->map); 811 | view->unmap.notify = xdg_surface_unmap; 812 | wl_signal_add(&xdg_surface->events.unmap, &view->unmap); 813 | view->destroy.notify = xdg_surface_destroy; 814 | wl_signal_add(&xdg_surface->events.destroy, &view->destroy); 815 | 816 | /* cotd */ 817 | struct wlr_xdg_toplevel* toplevel = xdg_surface->toplevel; 818 | view->request_move.notify = xdg_toplevel_request_move; 819 | wl_signal_add(&toplevel->events.request_move, &view->request_move); 820 | view->request_resize.notify = xdg_toplevel_request_resize; 821 | wl_signal_add(&toplevel->events.request_resize, &view->request_resize); 822 | 823 | /* Add it to the list of views. */ 824 | wl_list_insert(&server->views, &view->link); 825 | } 826 | 827 | int main(int argc, char* argv[]) 828 | { 829 | wlr_log_init(WLR_DEBUG, NULL); 830 | char* startup_cmd = NULL; 831 | 832 | int c; 833 | while ((c = getopt(argc, argv, "s:h")) != -1) { 834 | switch (c) { 835 | case 's': 836 | startup_cmd = optarg; 837 | break; 838 | default: 839 | printf("Usage: %s [-s startup command]\n", argv[0]); 840 | return 0; 841 | } 842 | } 843 | if (optind < argc) { 844 | printf("Usage: %s [-s startup command]\n", argv[0]); 845 | return 0; 846 | } 847 | 848 | struct tinywl_server server; 849 | /* The Wayland display is managed by libwayland. It handles accepting 850 | * clients from the Unix socket, manging Wayland globals, and so on. */ 851 | server.wl_display = wl_display_create(); 852 | /* The backend is a wlroots feature which abstracts the underlying input and 853 | * output hardware. The autocreate option will choose the most suitable 854 | * backend based on the current environment, such as opening an X11 window 855 | * if an X11 server is running. The NULL argument here optionally allows you 856 | * to pass in a custom renderer if wlr_renderer doesn't meet your needs. The 857 | * backend uses the renderer, for example, to fall back to software cursors 858 | * if the backend does not support hardware cursors (some older GPUs 859 | * don't). */ 860 | server.backend = wlr_backend_autocreate(server.wl_display, NULL); 861 | 862 | /* If we don't provide a renderer, autocreate makes a GLES2 renderer for us. 863 | * The renderer is responsible for defining the various pixel formats it 864 | * supports for shared memory, this configures that for clients. */ 865 | server.renderer = wlr_backend_get_renderer(server.backend); 866 | wlr_renderer_init_wl_display(server.renderer, server.wl_display); 867 | 868 | /* This creates some hands-off wlroots interfaces. The compositor is 869 | * necessary for clients to allocate surfaces and the data device manager 870 | * handles the clipboard. Each of these wlroots interfaces has room for you 871 | * to dig your fingers in and play with their behavior if you want. Note that 872 | * the clients cannot set the selection directly without compositor approval, 873 | * see the handling of the request_set_selection event below.*/ 874 | wlr_compositor_create(server.wl_display, server.renderer); 875 | wlr_data_device_manager_create(server.wl_display); 876 | 877 | /* Creates an output layout, which a wlroots utility for working with an 878 | * arrangement of screens in a physical layout. */ 879 | server.output_layout = wlr_output_layout_create(); 880 | 881 | /* Configure a listener to be notified when new outputs are available on the 882 | * backend. */ 883 | wl_list_init(&server.outputs); 884 | server.new_output.notify = server_new_output; 885 | wl_signal_add(&server.backend->events.new_output, &server.new_output); 886 | 887 | /* Set up our list of views and the xdg-shell. The xdg-shell is a Wayland 888 | * protocol which is used for application windows. For more detail on 889 | * shells, refer to my article: 890 | * 891 | * https://drewdevault.com/2018/07/29/Wayland-shells.html 892 | */ 893 | wl_list_init(&server.views); 894 | server.xdg_shell = wlr_xdg_shell_create(server.wl_display); 895 | server.new_xdg_surface.notify = server_new_xdg_surface; 896 | wl_signal_add(&server.xdg_shell->events.new_surface, &server.new_xdg_surface); 897 | 898 | /* 899 | * Creates a cursor, which is a wlroots utility for tracking the cursor 900 | * image shown on screen. 901 | */ 902 | server.cursor = wlr_cursor_create(); 903 | wlr_cursor_attach_output_layout(server.cursor, server.output_layout); 904 | 905 | /* Creates an xcursor manager, another wlroots utility which loads up 906 | * Xcursor themes to source cursor images from and makes sure that cursor 907 | * images are available at all scale factors on the screen (necessary for 908 | * HiDPI support). We add a cursor theme at scale factor 1 to begin with. */ 909 | server.cursor_mgr = wlr_xcursor_manager_create(NULL, 24); 910 | wlr_xcursor_manager_load(server.cursor_mgr, 1); 911 | 912 | /* 913 | * wlr_cursor *only* displays an image on screen. It does not move around 914 | * when the pointer moves. However, we can attach input devices to it, and 915 | * it will generate aggregate events for all of them. In these events, we 916 | * can choose how we want to process them, forwarding them to clients and 917 | * moving the cursor around. More detail on this process is described in my 918 | * input handling blog post: 919 | * 920 | * https://drewdevault.com/2018/07/17/Input-handling-in-wlroots.html 921 | * 922 | * And more comments are sprinkled throughout the notify functions above. 923 | */ 924 | server.cursor_motion.notify = server_cursor_motion; 925 | wl_signal_add(&server.cursor->events.motion, &server.cursor_motion); 926 | server.cursor_motion_absolute.notify = server_cursor_motion_absolute; 927 | wl_signal_add(&server.cursor->events.motion_absolute, 928 | &server.cursor_motion_absolute); 929 | server.cursor_button.notify = server_cursor_button; 930 | wl_signal_add(&server.cursor->events.button, &server.cursor_button); 931 | server.cursor_axis.notify = server_cursor_axis; 932 | wl_signal_add(&server.cursor->events.axis, &server.cursor_axis); 933 | server.cursor_frame.notify = server_cursor_frame; 934 | wl_signal_add(&server.cursor->events.frame, &server.cursor_frame); 935 | 936 | /* 937 | * Configures a seat, which is a single "seat" at which a user sits and 938 | * operates the computer. This conceptually includes up to one keyboard, 939 | * pointer, touch, and drawing tablet device. We also rig up a listener to 940 | * let us know when new input devices are available on the backend. 941 | */ 942 | wl_list_init(&server.keyboards); 943 | server.new_input.notify = server_new_input; 944 | wl_signal_add(&server.backend->events.new_input, &server.new_input); 945 | server.seat = wlr_seat_create(server.wl_display, "seat0"); 946 | server.request_cursor.notify = seat_request_cursor; 947 | wl_signal_add(&server.seat->events.request_set_cursor, 948 | &server.request_cursor); 949 | server.request_set_selection.notify = seat_request_set_selection; 950 | wl_signal_add(&server.seat->events.request_set_selection, 951 | &server.request_set_selection); 952 | 953 | /* Add a Unix socket to the Wayland display. */ 954 | const char* socket = wl_display_add_socket_auto(server.wl_display); 955 | if (!socket) { 956 | wlr_backend_destroy(server.backend); 957 | return 1; 958 | } 959 | 960 | /* Start the backend. This will enumerate outputs and inputs, become the DRM 961 | * master, etc */ 962 | if (!wlr_backend_start(server.backend)) { 963 | wlr_backend_destroy(server.backend); 964 | wl_display_destroy(server.wl_display); 965 | return 1; 966 | } 967 | 968 | /* Set the WAYLAND_DISPLAY environment variable to our socket and run the 969 | * startup command if requested. */ 970 | setenv("WAYLAND_DISPLAY", socket, true); 971 | if (startup_cmd) { 972 | if (fork() == 0) { 973 | execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (void*)NULL); 974 | } 975 | } 976 | /* Run the Wayland event loop. This does not return until you exit the 977 | * compositor. Starting the backend rigged up all of the necessary event 978 | * loop configuration to listen to libinput events, DRM events, generate 979 | * frame events at the refresh rate, and so on. */ 980 | wlr_log(WLR_INFO, "Running Wayland compositor on WAYLAND_DISPLAY=%s", socket); 981 | wl_display_run(server.wl_display); 982 | 983 | /* Once wl_display_run returns, we shut down the server. */ 984 | wl_display_destroy_clients(server.wl_display); 985 | wl_display_destroy(server.wl_display); 986 | return 0; 987 | } 988 | --------------------------------------------------------------------------------