├── .pubignore ├── test └── code_forge_test.dart ├── example ├── linux │ ├── .gitignore │ ├── runner │ │ ├── main.cc │ │ ├── my_application.h │ │ ├── CMakeLists.txt │ │ └── my_application.cc │ ├── flutter │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── ios │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── 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-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── RunnerTests │ │ └── RunnerTests.swift │ └── .gitignore ├── macos │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner │ │ ├── Configs │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ ├── Warnings.xcconfig │ │ │ └── AppInfo.xcconfig │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ ├── app_icon_64.png │ │ │ │ ├── app_icon_1024.png │ │ │ │ └── Contents.json │ │ ├── Release.entitlements │ │ ├── AppDelegate.swift │ │ ├── DebugProfile.entitlements │ │ ├── MainFlutterWindow.swift │ │ └── Info.plist │ ├── .gitignore │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ └── RunnerTests │ │ └── RunnerTests.swift ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── manifest.json │ └── index.html ├── windows │ ├── runner │ │ ├── resources │ │ │ └── app_icon.ico │ │ ├── resource.h │ │ ├── runner.exe.manifest │ │ ├── utils.h │ │ ├── flutter_window.h │ │ ├── main.cpp │ │ ├── CMakeLists.txt │ │ ├── utils.cpp │ │ ├── flutter_window.cpp │ │ ├── Runner.rc │ │ ├── win32_window.h │ │ └── win32_window.cpp │ ├── .gitignore │ ├── flutter │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── 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 │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle.kts │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── build.gradle.kts │ └── settings.gradle.kts ├── pubspec.yaml ├── README.md ├── .gitignore ├── test │ └── widget_test.dart ├── analysis_options.yaml ├── .metadata ├── lib │ └── main.dart └── pubspec.lock ├── gifs ├── cf_ai.gif ├── cf_fold.gif ├── cf_lsp.gif ├── cf_lsp_new.gif ├── cf_themes.gif └── code_forge_100k.gif ├── assets └── icons │ ├── class.ttf │ ├── enum.ttf │ ├── event.ttf │ ├── field.ttf │ ├── keyword.ttf │ ├── method.ttf │ ├── snippet.ttf │ ├── struct.ttf │ ├── constant.ttf │ ├── interface.ttf │ ├── operator.ttf │ ├── parameter.ttf │ ├── reference.ttf │ └── variable.ttf ├── analysis_options.yaml ├── lib ├── code_forge.dart ├── LSP │ ├── lsp_socket.dart │ └── lsp_stdio.dart ├── code_forge │ ├── scroll.dart │ ├── styling.dart │ └── undo_redo.dart └── AI_completion │ └── ai.dart ├── .metadata ├── .gitignore ├── LICENSE ├── pubspec.yaml └── CHANGELOG.md /.pubignore: -------------------------------------------------------------------------------- 1 | gifs/ -------------------------------------------------------------------------------- /test/code_forge_test.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /gifs/cf_ai.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/gifs/cf_ai.gif -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /gifs/cf_fold.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/gifs/cf_fold.gif -------------------------------------------------------------------------------- /gifs/cf_lsp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/gifs/cf_lsp.gif -------------------------------------------------------------------------------- /gifs/cf_lsp_new.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/gifs/cf_lsp_new.gif -------------------------------------------------------------------------------- /gifs/cf_themes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/gifs/cf_themes.gif -------------------------------------------------------------------------------- /assets/icons/class.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/class.ttf -------------------------------------------------------------------------------- /assets/icons/enum.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/enum.ttf -------------------------------------------------------------------------------- /assets/icons/event.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/event.ttf -------------------------------------------------------------------------------- /assets/icons/field.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/field.ttf -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /assets/icons/keyword.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/keyword.ttf -------------------------------------------------------------------------------- /assets/icons/method.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/method.ttf -------------------------------------------------------------------------------- /assets/icons/snippet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/snippet.ttf -------------------------------------------------------------------------------- /assets/icons/struct.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/struct.ttf -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/web/favicon.png -------------------------------------------------------------------------------- /gifs/code_forge_100k.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/gifs/code_forge_100k.gif -------------------------------------------------------------------------------- /assets/icons/constant.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/constant.ttf -------------------------------------------------------------------------------- /assets/icons/interface.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/interface.ttf -------------------------------------------------------------------------------- /assets/icons/operator.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/operator.ttf -------------------------------------------------------------------------------- /assets/icons/parameter.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/parameter.ttf -------------------------------------------------------------------------------- /assets/icons/reference.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/reference.ttf -------------------------------------------------------------------------------- /assets/icons/variable.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/assets/icons/variable.ttf -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity : FlutterActivity() 6 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heckmon/code_forge/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/linux/runner/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 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip 6 | -------------------------------------------------------------------------------- /lib/code_forge.dart: -------------------------------------------------------------------------------- 1 | library; 2 | 3 | export 'code_forge/code_area.dart'; 4 | export 'code_forge/controller.dart'; 5 | export 'code_forge/styling.dart'; 6 | export 'code_forge/scroll.dart'; 7 | export 'code_forge/undo_redo.dart'; 8 | export 'AI_completion/ai.dart'; 9 | export 'LSP/lsp.dart'; 10 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | .cxx/ 9 | 10 | # Remember to never publicly share your keystore. 11 | # See https://flutter.dev/to/reference-keystore 12 | key.properties 13 | **/*.keystore 14 | **/*.jks 15 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.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: "adc901062556672b4138e18a4dc62a4be8f4b3c2" 8 | channel: "stable" 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/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. -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | 10 | override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 11 | return true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/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 RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/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 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | UrlLauncherWindowsRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 14 | } 15 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/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.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | @main 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 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import path_provider_foundation 9 | import url_launcher_macos 10 | 11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 12 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 13 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 14 | } 15 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 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 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: "A new Flutter project." 3 | publish_to: 'none' 4 | 5 | version: 1.0.0+1 6 | 7 | environment: 8 | sdk: ^3.10.1 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | code_forge: { path: ../ } 14 | cupertino_icons: ^1.0.8 15 | re_highlight: ^0.0.3 16 | google_fonts: ^6.3.3 17 | path: ^1.9.1 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | 23 | flutter_lints: ^6.0.0 24 | 25 | flutter: 26 | 27 | uses-material-design: true -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/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 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/linux/runner/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, 7 | my_application, 8 | MY, 9 | APPLICATION, 10 | GtkApplication) 11 | 12 | /** 13 | * my_application_new: 14 | * 15 | * Creates a new Flutter-based application. 16 | * 17 | * Returns: a new #MyApplication. 18 | */ 19 | MyApplication* my_application_new(); 20 | 21 | #endif // FLUTTER_MY_APPLICATION_H_ 22 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | val newBuildDir: Directory = 9 | rootProject.layout.buildDirectory 10 | .dir("../../build") 11 | .get() 12 | rootProject.layout.buildDirectory.value(newBuildDir) 13 | 14 | subprojects { 15 | val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) 16 | project.layout.buildDirectory.value(newSubprojectBuildDir) 17 | } 18 | subprojects { 19 | project.evaluationDependsOn(":app") 20 | } 21 | 22 | tasks.register("clean") { 23 | delete(rootProject.layout.buildDirectory) 24 | } 25 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .flutter-plugins-dependencies 30 | /build/ 31 | /coverage/ 32 | 33 | /example/lib/little_code.dart 34 | /example/lib/big_code.dart -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | val flutterSdkPath = 3 | run { 4 | val properties = java.util.Properties() 5 | file("local.properties").inputStream().use { properties.load(it) } 6 | val flutterSdkPath = properties.getProperty("flutter.sdk") 7 | require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } 8 | flutterSdkPath 9 | } 10 | 11 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 12 | 13 | repositories { 14 | google() 15 | mavenCentral() 16 | gradlePluginPortal() 17 | } 18 | } 19 | 20 | plugins { 21 | id("dev.flutter.flutter-plugin-loader") version "1.0.0" 22 | id("com.android.application") version "8.11.1" apply false 23 | id("org.jetbrains.kotlin.android") version "2.2.20" apply false 24 | } 25 | 26 | include(":app") 27 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins-dependencies 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | /coverage/ 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release -------------------------------------------------------------------------------- /example/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 | 13.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/linux/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} 10 | "main.cc" 11 | "my_application.cc" 12 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 13 | ) 14 | 15 | # Apply the standard set of build settings. This can be removed for applications 16 | # that need different build settings. 17 | apply_standard_settings(${BINARY_NAME}) 18 | 19 | # Add preprocessor definitions for the application ID. 20 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 21 | 22 | # Add dependency libraries. Add any application-specific dependencies here. 23 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 24 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 25 | 26 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Athul A S 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /example/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 https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/android/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id("dev.flutter.flutter-gradle-plugin") 6 | } 7 | 8 | android { 9 | namespace = "com.example.example" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_17 15 | targetCompatibility = JavaVersion.VERSION_17 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_17.toString() 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.example.example" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.getByName("debug") 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 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 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: code_forge 2 | description: "A sophisticated code editor package with AI completion, LSP support, syntax highlighting, and advanced editing capabilities." 3 | version: 1.4.0 4 | homepage: https://github.com/heckmon/code_forge 5 | 6 | environment: 7 | sdk: ^3.10.3 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | http: ^1.6.0 14 | markdown_widget: ^2.3.2+8 15 | meta: ^1.17.0 16 | re_highlight: ^0.0.3 17 | web_socket_channel: ^3.0.3 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | flutter_lints: ^5.0.0 23 | 24 | flutter: 25 | fonts: 26 | - family: Method 27 | fonts: 28 | - asset: assets/icons/method.ttf 29 | - family: Variable 30 | fonts: 31 | - asset: assets/icons/variable.ttf 32 | - family: Class 33 | fonts: 34 | - asset: assets/icons/class.ttf 35 | - family: Enum 36 | fonts: 37 | - asset: assets/icons/enum.ttf 38 | - family: KeyWord 39 | fonts: 40 | - asset: assets/icons/keyword.ttf 41 | - family: Reference 42 | fonts: 43 | - asset: assets/icons/reference.ttf 44 | - family: Constant 45 | fonts: 46 | - asset: assets/icons/constant.ttf 47 | - family: Struct 48 | fonts: 49 | - asset: assets/icons/struct.ttf 50 | - family: Event 51 | fonts: 52 | - asset: assets/icons/event.ttf 53 | - family: Operator 54 | fonts: 55 | - asset: assets/icons/operator.ttf 56 | - family: Parameter 57 | fonts: 58 | - asset: assets/icons/parameter.ttf 59 | - family: Snippet 60 | fonts: 61 | - asset: assets/icons/snippet.ttf 62 | - family: Interface 63 | fonts: 64 | - asset: assets/icons/interface.ttf 65 | - family: Field 66 | fonts: 67 | - asset: assets/icons/field.ttf 68 | -------------------------------------------------------------------------------- /example/.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: "19074d12f7eaf6a8180cd4036a430c1d76de904e" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 17 | base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 18 | - platform: android 19 | create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 20 | base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 21 | - platform: ios 22 | create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 23 | base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 24 | - platform: linux 25 | create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 26 | base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 27 | - platform: macos 28 | create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 29 | base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 30 | - platform: web 31 | create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 32 | base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 33 | - platform: windows 34 | create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 35 | base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'package:path/path.dart' as p; 3 | import 'package:code_forge/code_forge.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:google_fonts/google_fonts.dart'; 6 | import 'package:re_highlight/languages/dart.dart'; 7 | 8 | void main() { 9 | runApp(const MyApp()); 10 | } 11 | 12 | class MyApp extends StatefulWidget { 13 | const MyApp({super.key}); 14 | 15 | @override 16 | State createState() => _MyAppState(); 17 | } 18 | 19 | class _MyAppState extends State { 20 | final _controller = CodeForgeController(); 21 | final undoController = UndoRedoController(); 22 | final absFilePath = p.join(Directory.current.path, "lib/example_code.dart"); 23 | 24 | Future getLsp() async { 25 | final absWorkspacePath = p.join(Directory.current.path, "lib"); 26 | final data = await LspStdioConfig.start( 27 | executable: "dart", 28 | args: ["language-server", "--protocol=lsp"], 29 | workspacePath: absWorkspacePath, 30 | languageId: "dart", 31 | ); 32 | return data; 33 | } 34 | 35 | @override 36 | void initState() { 37 | super.initState(); 38 | } 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return MaterialApp( 43 | home: Scaffold( 44 | body: SafeArea( 45 | child: FutureBuilder( 46 | future: getLsp(), 47 | builder: (context, snapshot) { 48 | if (snapshot.connectionState == ConnectionState.waiting) { 49 | return CircularProgressIndicator(); 50 | } 51 | return CodeForge( 52 | undoController: undoController, 53 | language: langDart, 54 | controller: _controller, 55 | textStyle: GoogleFonts.jetBrainsMono(), 56 | /* aiCompletion: AiCompletion( 57 | model: Gemini(apiKey: "YOUR API KEY"), 58 | ), */ 59 | lspConfig: snapshot.data, 60 | filePath: absFilePath, 61 | ); 62 | }, 63 | ), 64 | ), 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /lib/LSP/lsp_socket.dart: -------------------------------------------------------------------------------- 1 | part of 'lsp.dart'; 2 | 3 | /// A configuration class for Language Server Protocol (LSP) using WebSocket communication. 4 | /// 5 | /// Documenation available [here](https://github.com/heckmon/flutter_code_crafter/blob/main/docs/LSPClient.md). 6 | /// 7 | ///Example: 8 | /// create a [LspSocketConfig] object and pass it to the [CodeForge] widget. 9 | /// 10 | ///```dart 11 | ///final lspConfig = LspSocketConfig( 12 | /// workspacePath: "/home/athul/Projects/lsp", 13 | /// languageId: "python", 14 | /// serverUrl: "ws://localhost:5656" 15 | ///), 16 | ///``` 17 | ///Then pass the `lspConfig` instance to the `CodeForge` widget: 18 | /// 19 | ///```dart 20 | ///CodeForge( 21 | /// controller: controller, 22 | /// theme: anOldHopeTheme, 23 | /// lspConfig: lspConfig, // Pass the LSP config here 24 | ///), 25 | ///``` 26 | class LspSocketConfig extends LspConfig { 27 | /// The URL of the LSP server to connect to via WebSocket. 28 | final String serverUrl; 29 | final WebSocketChannel _channel; 30 | 31 | LspSocketConfig({ 32 | required super.workspacePath, 33 | required super.languageId, 34 | required this.serverUrl, 35 | super.disableWarning, 36 | super.disableError, 37 | }) : _channel = WebSocketChannel.connect(Uri.parse(serverUrl)); 38 | 39 | /// This method is used to initialize the LSP server. and it's used internally by the [CodeCrafter] widget. 40 | /// Calling it directly is not recommended and may crash the LSP server if called multiple times. 41 | Future connect() async { 42 | _channel.stream.listen((data) { 43 | try { 44 | final json = jsonDecode(data as String); 45 | _responseController.add(json); 46 | } catch (e) { 47 | throw FormatException('Invalid JSON response: $data', e); 48 | } 49 | }); 50 | } 51 | 52 | @override 53 | Future> _sendRequest({ 54 | required String method, 55 | required Map params, 56 | }) async { 57 | final id = _nextId++; 58 | final request = { 59 | 'jsonrpc': '2.0', 60 | 'id': id, 61 | 'method': method, 62 | 'params': params, 63 | }; 64 | 65 | _channel.sink.add(jsonEncode(request)); 66 | 67 | return await _responseController.stream.firstWhere( 68 | (response) => response['id'] == id, 69 | orElse: () => throw TimeoutException('No response for request $id'), 70 | ); 71 | } 72 | 73 | @override 74 | Future _sendNotification({ 75 | required String method, 76 | required Map params, 77 | }) async { 78 | _channel.sink.add( 79 | jsonEncode({'jsonrpc': '2.0', 'method': method, 'params': params}), 80 | ); 81 | } 82 | 83 | @override 84 | void dispose() { 85 | _channel.sink.close(); 86 | _responseController.close(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /lib/code_forge/scroll.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | /// A custom two-dimensional viewport for the code editor. 6 | /// 7 | /// This viewport is used internally by [CodeForge] to enable both vertical 8 | /// and horizontal scrolling within the editor. It delegates to a 9 | /// [Render2DCodeField] for layout and painting. 10 | class CustomViewport extends TwoDimensionalViewport { 11 | /// Creates a [CustomViewport] with the required scroll offsets and axes. 12 | const CustomViewport({ 13 | super.key, 14 | required super.verticalOffset, 15 | required super.verticalAxisDirection, 16 | required super.horizontalOffset, 17 | required super.horizontalAxisDirection, 18 | required TwoDimensionalChildBuilderDelegate super.delegate, 19 | required super.mainAxis, 20 | }); 21 | 22 | @override 23 | RenderTwoDimensionalViewport createRenderObject(BuildContext context) { 24 | return Render2DCodeField( 25 | horizontalOffset: horizontalOffset, 26 | horizontalAxisDirection: horizontalAxisDirection, 27 | verticalOffset: verticalOffset, 28 | verticalAxisDirection: verticalAxisDirection, 29 | delegate: delegate, 30 | mainAxis: mainAxis, 31 | childManager: context as TwoDimensionalChildManager, 32 | ); 33 | } 34 | 35 | @override 36 | void updateRenderObject( 37 | BuildContext context, 38 | covariant RenderTwoDimensionalViewport renderObject, 39 | ) { 40 | renderObject 41 | ..horizontalOffset = horizontalOffset 42 | ..horizontalAxisDirection = horizontalAxisDirection 43 | ..verticalOffset = verticalOffset 44 | ..verticalAxisDirection = verticalAxisDirection 45 | ..delegate = delegate 46 | ..mainAxis = mainAxis; 47 | } 48 | } 49 | 50 | /// The render object for the code editor's two-dimensional viewport. 51 | /// 52 | /// This class handles the layout of the code editor content and manages 53 | /// the content dimensions for both vertical and horizontal scrolling. 54 | class Render2DCodeField extends RenderTwoDimensionalViewport { 55 | /// Creates a [Render2DCodeField] with the required scroll configuration. 56 | Render2DCodeField({ 57 | required super.horizontalOffset, 58 | required super.horizontalAxisDirection, 59 | required super.verticalOffset, 60 | required super.verticalAxisDirection, 61 | required super.delegate, 62 | required super.mainAxis, 63 | required super.childManager, 64 | }); 65 | 66 | @override 67 | void layoutChildSequence() { 68 | final child = buildOrObtainChildFor(ChildVicinity(xIndex: 0, yIndex: 0)); 69 | 70 | if (child != null) { 71 | child.layout( 72 | BoxConstraints( 73 | minHeight: 0, 74 | minWidth: 0, 75 | maxWidth: double.infinity, 76 | maxHeight: double.infinity, 77 | ), 78 | 79 | parentUsesSize: true, 80 | ); 81 | parentDataOf(child).layoutOffset = Offset.zero; 82 | 83 | verticalOffset.applyContentDimensions( 84 | 0.0, 85 | math.max(0.0, child.size.height - viewportDimension.height), 86 | ); 87 | horizontalOffset.applyContentDimensions( 88 | 0.0, 89 | math.max(0.0, child.size.width - viewportDimension.width), 90 | ); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 38 | 39 | 40 | 41 | 44 | 50 | 51 | 52 | 53 | 54 | 66 | 68 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /example/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.13) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.example") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | # Application build; see runner/CMakeLists.txt. 58 | add_subdirectory("runner") 59 | 60 | # Run the Flutter tool portions of the build. This must not be removed. 61 | add_dependencies(${BINARY_NAME} flutter_assemble) 62 | 63 | # Only the install-generated bundle's copy of the executable will launch 64 | # correctly, since the resources must in the right relative locations. To avoid 65 | # people trying to run the unbundled copy, put it in a subdirectory instead of 66 | # the default top-level location. 67 | set_target_properties(${BINARY_NAME} 68 | PROPERTIES 69 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 70 | ) 71 | 72 | 73 | # Generated plugin build rules, which manage building the plugins and adding 74 | # them to the application. 75 | include(flutter/generated_plugins.cmake) 76 | 77 | 78 | # === Installation === 79 | # By default, "installing" just makes a relocatable bundle in the build 80 | # directory. 81 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 82 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 83 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 84 | endif() 85 | 86 | # Start with a clean build bundle directory every time. 87 | install(CODE " 88 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 89 | " COMPONENT Runtime) 90 | 91 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 92 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 93 | 94 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 95 | COMPONENT Runtime) 96 | 97 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 98 | COMPONENT Runtime) 99 | 100 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 101 | COMPONENT Runtime) 102 | 103 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 104 | install(FILES "${bundled_library}" 105 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 106 | COMPONENT Runtime) 107 | endforeach(bundled_library) 108 | 109 | # Copy the native assets provided by the build.dart from all packages. 110 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 111 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 112 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 113 | COMPONENT Runtime) 114 | 115 | # Fully re-copy the assets directory on each build to avoid having stale files 116 | # from a previous install. 117 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 118 | install(CODE " 119 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 120 | " COMPONENT Runtime) 121 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 122 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 123 | 124 | # Install the AOT library on non-Debug builds only. 125 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 126 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 127 | COMPONENT Runtime) 128 | endif() 129 | -------------------------------------------------------------------------------- /example/linux/runner/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 | // Called when first Flutter frame received. 18 | static void first_frame_cb(MyApplication* self, FlView* view) { 19 | gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view))); 20 | } 21 | 22 | // Implements GApplication::activate. 23 | static void my_application_activate(GApplication* application) { 24 | MyApplication* self = MY_APPLICATION(application); 25 | GtkWindow* window = 26 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 27 | 28 | // Use a header bar when running in GNOME as this is the common style used 29 | // by applications and is the setup most users will be using (e.g. Ubuntu 30 | // desktop). 31 | // If running on X and not using GNOME then just use a traditional title bar 32 | // in case the window manager does more exotic layout, e.g. tiling. 33 | // If running on Wayland assume the header bar will work (may need changing 34 | // if future cases occur). 35 | gboolean use_header_bar = TRUE; 36 | #ifdef GDK_WINDOWING_X11 37 | GdkScreen* screen = gtk_window_get_screen(window); 38 | if (GDK_IS_X11_SCREEN(screen)) { 39 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 40 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 41 | use_header_bar = FALSE; 42 | } 43 | } 44 | #endif 45 | if (use_header_bar) { 46 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 47 | gtk_widget_show(GTK_WIDGET(header_bar)); 48 | gtk_header_bar_set_title(header_bar, "example"); 49 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 50 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 51 | } else { 52 | gtk_window_set_title(window, "example"); 53 | } 54 | 55 | gtk_window_set_default_size(window, 1280, 720); 56 | 57 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 58 | fl_dart_project_set_dart_entrypoint_arguments( 59 | project, self->dart_entrypoint_arguments); 60 | 61 | FlView* view = fl_view_new(project); 62 | GdkRGBA background_color; 63 | // Background defaults to black, override it here if necessary, e.g. #00000000 64 | // for transparent. 65 | gdk_rgba_parse(&background_color, "#000000"); 66 | fl_view_set_background_color(view, &background_color); 67 | gtk_widget_show(GTK_WIDGET(view)); 68 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 69 | 70 | // Show the window when Flutter renders. 71 | // Requires the view to be realized so we can start rendering. 72 | g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), 73 | self); 74 | gtk_widget_realize(GTK_WIDGET(view)); 75 | 76 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 77 | 78 | gtk_widget_grab_focus(GTK_WIDGET(view)); 79 | } 80 | 81 | // Implements GApplication::local_command_line. 82 | static gboolean my_application_local_command_line(GApplication* application, 83 | gchar*** arguments, 84 | int* exit_status) { 85 | MyApplication* self = MY_APPLICATION(application); 86 | // Strip out the first argument as it is the binary name. 87 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 88 | 89 | g_autoptr(GError) error = nullptr; 90 | if (!g_application_register(application, nullptr, &error)) { 91 | g_warning("Failed to register: %s", error->message); 92 | *exit_status = 1; 93 | return TRUE; 94 | } 95 | 96 | g_application_activate(application); 97 | *exit_status = 0; 98 | 99 | return TRUE; 100 | } 101 | 102 | // Implements GApplication::startup. 103 | static void my_application_startup(GApplication* application) { 104 | // MyApplication* self = MY_APPLICATION(object); 105 | 106 | // Perform any actions required at application startup. 107 | 108 | G_APPLICATION_CLASS(my_application_parent_class)->startup(application); 109 | } 110 | 111 | // Implements GApplication::shutdown. 112 | static void my_application_shutdown(GApplication* application) { 113 | // MyApplication* self = MY_APPLICATION(object); 114 | 115 | // Perform any actions required at application shutdown. 116 | 117 | G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); 118 | } 119 | 120 | // Implements GObject::dispose. 121 | static void my_application_dispose(GObject* object) { 122 | MyApplication* self = MY_APPLICATION(object); 123 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 124 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 125 | } 126 | 127 | static void my_application_class_init(MyApplicationClass* klass) { 128 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 129 | G_APPLICATION_CLASS(klass)->local_command_line = 130 | my_application_local_command_line; 131 | G_APPLICATION_CLASS(klass)->startup = my_application_startup; 132 | G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; 133 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 134 | } 135 | 136 | static void my_application_init(MyApplication* self) {} 137 | 138 | MyApplication* my_application_new() { 139 | // Set the program name to the application ID, which helps various systems 140 | // like GTK and desktop environments map this running application to its 141 | // corresponding .desktop file. This ensures better integration by allowing 142 | // the application to be recognized beyond its binary name. 143 | g_set_prgname(APPLICATION_ID); 144 | 145 | return MY_APPLICATION(g_object_new(my_application_get_type(), 146 | "application-id", APPLICATION_ID, "flags", 147 | G_APPLICATION_NON_UNIQUE, nullptr)); 148 | } 149 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 2 | 3 |
4 |

🎉 Initial Release

5 | 6 | **CodeForge** is a sophisticated, feature-rich code editor widget for Flutter applications, inspired by VS Code and Monaco Editor. This release introduces a comprehensive set of editing capabilities with modern developer experience features. 7 | 8 | ### ✨ Core Features 9 | 10 | #### 📝 Advanced Text Editing 11 | - **Efficient Text Management**: Uses rope data structures for optimal performance with large files 12 | - **Multi-language Syntax Highlighting**: Support for numerous programming languages via `re_highlight` 13 | - **Code Folding**: Visual fold/unfold indicators with automatic range detection 14 | - **Smart Indentation**: Auto-indentation with customizable behavior 15 | - **Bracket Matching**: Automatic bracket highlighting and matching 16 | - **Line Operations**: Move lines up/down, duplicate lines, smart indentation 17 | - **Word Navigation**: Ctrl+arrow key navigation and word-level deletion 18 | 19 | #### 🎨 Customizable UI & Theming 20 | - **Flexible Styling**: Extensive customization options for all UI elements 21 | - **Theme Support**: Built-in VS2015 dark theme with full customization 22 | - **Gutter Customization**: Line numbers, fold icons, error/warning highlighting 23 | - **Selection Styling**: Custom cursor colors, selection highlighting, cursor bubbles 24 | - **Overlay Styling**: Suggestion popups, hover documentation with themes 25 | - **Font Integration**: Custom icon fonts for completion items (auto-loaded) 26 | 27 | #### 🔧 Developer Experience 28 | - **Undo/Redo System**: Sophisticated operation merging with timestamp-based grouping 29 | - **Read-only Mode**: Optional read-only editing for display purposes 30 | - **Auto-focus**: Automatic focus on widget mount 31 | - **Line Wrapping**: Configurable line wrapping vs horizontal scrolling 32 | - **Indentation Guides**: Visual guides for code structure 33 | - **Search Highlighting**: Highlight search results and matches 34 | 35 | ### 🚀 Language Server Protocol (LSP) Integration 36 | 37 | - **Full LSP Support**: Complete Language Server Protocol implementation 38 | - **Semantic Highlighting**: Advanced token-based syntax coloring 39 | - **Intelligent Completions**: Context-aware code completion with custom icons 40 | - **Hover Documentation**: Rich hover information with markdown support 41 | - **Diagnostics Integration**: Real-time error and warning display 42 | - **Multiple Server Types**: Support for stdio and WebSocket LSP servers 43 | - **Document Synchronization**: Bidirectional sync with LSP servers 44 | - **Error Gutter**: Visual error/warning indicators in line numbers 45 | 46 | ### 🤖 AI-Powered Code Completion 47 | 48 | - **Multi-Model Support**: Integration with Gemini and extensible to other AI models 49 | - **Completion Modes**: Auto, manual, and mixed completion triggering 50 | - **Smart Debouncing**: Prevents excessive API calls during typing 51 | - **Response Processing**: Intelligent parsing and code cleaning 52 | - **Custom Instructions**: Configurable AI prompts for different use cases 53 | - **Caching**: Response caching for improved performance 54 | 55 | ### 🎯 Key Capabilities 56 | 57 | #### Performance & Efficiency 58 | - **Optimized Rendering**: Custom viewport with efficient repaint management 59 | - **Large File Support**: Handles files of any size with rope-based operations 60 | - **Debounced Operations**: Semantic token updates and AI requests are debounced 61 | - **Memory Efficient**: Minimal memory footprint with smart caching 62 | 63 | #### Integration & Extensibility 64 | - **Flutter Native**: Seamless integration with Flutter's text input system 65 | - **Custom Controllers**: Flexible controller architecture for advanced use cases 66 | - **Event Streaming**: LSP response streaming for real-time updates 67 | - **Plugin Architecture**: Extensible design for custom features 68 | 69 | #### Accessibility & UX 70 | - **Keyboard Shortcuts**: Full keyboard navigation support 71 | - **Context Menus**: Right-click context menus with copy/paste/select-all 72 | - **Visual Feedback**: Loading states, error handling, and user feedback 73 | - **Mobile Support**: Touch-friendly interactions for mobile platforms 74 | 75 | ### 📚 Documentation & Examples 76 | 77 | - **Comprehensive API Docs**: Fully documented public APIs with examples 78 | - **Example Application**: Complete working example in `/example/` 79 | - **Type Safety**: Strong typing throughout the codebase 80 | - **Error Handling**: Robust error handling with user-friendly messages 81 | 82 | ### 🔧 Technical Highlights 83 | 84 | - **Pure Dart**: No native dependencies, works on all Flutter platforms 85 | - **Widget Architecture**: Built as a proper Flutter widget with state management 86 | - **Custom Rendering**: Optimized rendering pipeline for code editing 87 | - **Test Coverage**: Comprehensive test suite for reliability 88 | - **Linting**: Follows Flutter best practices and linting rules 89 | 90 | ### 🎨 Supported Languages & Features 91 | 92 | **Syntax Highlighting**: Dart, Python, JavaScript, TypeScript, Java, C++, C#, Go, Rust, PHP, Ruby, Swift, Kotlin, Scala, and many more via `re_highlight` 93 | 94 | **LSP Servers**: Compatible with any LSP-compliant language server (Dart Analysis Server, Pyright, TypeScript, etc.) 95 | 96 | **AI Models**: Gemini integration with extensible architecture for other providers 97 | 98 | --- 99 | 100 | This release establishes **CodeForge** as a powerful, production-ready code editor for Flutter applications, offering the same level of sophistication found in professional code editors while maintaining Flutter's declarative UI paradigm. 101 |
102 | 103 | ## 1.0.1 104 | 105 | - Updated README.md 106 | 107 | ## 1.0.2 108 | - Updated README.md 109 | 110 | ## 1.1.0 111 | - Fixed keyboard would not appear in Android. 112 | - Added more public API methods in the controller, such as copy, paste, selectAll, cut, arrow key navigations, etc 113 | 114 | ## 1.2.0 115 | - FEATURE: Added LSP Code Actions. 116 | - FEATURE: Enhanced AI Completion for large files. 117 | - FEATURE: Added more public method APIs in the controller and the LspConfig class. 118 | - FIX: Completion bug in the first line. 119 | 120 | ## 1.2.1 121 | - suggestion/code actions persist on screen. 122 | 123 | ## 1.3.0 124 | - FIX: Editor width had been determined by the width of the longest line, fixed it by using the viewport width. 125 | - FIX: Changed filePath based LSP initialization to workspace based approach to manage multiple files from a single server instance. 126 | - FIX: Tapping the end of the longest line won't focus the editor. 127 | 128 | ## 1.3.1 129 | - Updated README 130 | 131 | ## 1.4.0 132 | - FEATURE: Added LSP `completionItem/resolve` to show documentation for completion items. 133 | - FEATURE: Added LSP auto import. 134 | - FEATURE: Theme based dynamic color for suggestion popup. -------------------------------------------------------------------------------- /lib/LSP/lsp_stdio.dart: -------------------------------------------------------------------------------- 1 | part of 'lsp.dart'; 2 | 3 | /// This class provides a configuration for Language Server Protocol (LSP) using standard input/output communication. 4 | /// Little bit complex compared to [LspSocketConfig]. 5 | /// 6 | /// /// Documenation available [here](https://github.com/heckmon/flutter_code_crafter/blob/main/docs/LSPClient.md). 7 | /// 8 | /// Example: 9 | /// 10 | /// Create an async method to initialize the LSP configuration. 11 | ///```dart 12 | ///Future _initLsp() async { 13 | /// try { 14 | /// final config = await LspStdioConfig.start( 15 | /// executable: '/home/athul/.nvm/versions/node/v20.19.2/bin/pyright-langserver', 16 | /// args: ['--stdio'] 17 | /// workspacePath: '/home/athul/Projects/lsp', 18 | /// languageId: 'python', 19 | /// ); 20 | /// 21 | /// return config; 22 | /// } catch (e) { 23 | /// debugPrint('LSP Initialization failed: $e'); 24 | /// return null; 25 | /// } 26 | /// } 27 | /// ``` 28 | /// Then use a `FutureBuilder` to initialize the LSP configuration and pass it to the `CodeForge` widget: 29 | ///```dart 30 | /// @override 31 | /// Widget build(BuildContext context) { 32 | /// return MaterialApp( 33 | /// home: Scaffold( 34 | /// body: SafeArea( 35 | /// child: FutureBuilder( 36 | /// future: _initLsp(), // Call the async method to get the LSP config 37 | /// builder: (context, snapshot) { 38 | /// if(snapshot.connectionState == ConnectionState.waiting) { 39 | /// return Center(child: CircularProgressIndicator()); 40 | /// } 41 | /// return CodeForge( 42 | /// wrapLines: true, 43 | /// editorTheme: anOldHopeTheme, 44 | /// controller: controller, 45 | /// filePath: '/home/athul/Projects/lsp/example.py', 46 | /// textStyle: TextStyle(fontSize: 15, fontFamily: 'monospace'), 47 | /// lspConfig: snapshot.data, // Pass the LSP config here 48 | /// ); 49 | /// } 50 | /// ), 51 | /// ) 52 | /// ), 53 | /// ); 54 | /// } 55 | class LspStdioConfig extends LspConfig { 56 | /// location of the LSP executable, such as `pyright-langserver`, `rust-analyzer`, etc. 57 | /// 58 | /// To get the `executable` path, you can use the `which` command in the terminal. For example, to get the path of the `pyright-langserver`, you can use the following command: 59 | /// 60 | ///```bash 61 | ///which pyright-langserver 62 | ///``` 63 | final String executable; 64 | 65 | /// Optional arguments for the executable. 66 | final List? args; 67 | 68 | /// Optional environement variables for the executable. 69 | final Map? environment; 70 | 71 | late Process _process; 72 | final _buffer = []; 73 | bool _isSending = false; 74 | 75 | LspStdioConfig._({ 76 | required this.executable, 77 | required super.workspacePath, 78 | required super.languageId, 79 | this.args, 80 | this.environment, 81 | super.disableWarning, 82 | super.disableError, 83 | }); 84 | 85 | static Future start({ 86 | required String executable, 87 | required String workspacePath, 88 | required String languageId, 89 | List? args, 90 | Map? environment, 91 | bool disableWarning = false, 92 | bool disableError = false, 93 | }) async { 94 | final config = LspStdioConfig._( 95 | executable: executable, 96 | languageId: languageId, 97 | workspacePath: workspacePath, 98 | args: args, 99 | environment: environment, 100 | disableWarning: disableWarning, 101 | disableError: disableError, 102 | ); 103 | await config._startProcess(); 104 | return config; 105 | } 106 | 107 | Future _startProcess() async { 108 | _process = await Process.start( 109 | executable, 110 | args ?? [], 111 | environment: environment, 112 | ); 113 | _process.stdout.listen(_handleStdoutData); 114 | _process.stderr.listen((data) => debugPrint(utf8.decode(data))); 115 | } 116 | 117 | int get pid => _process.pid; 118 | Future get exitCode => _process.exitCode; 119 | Process get process => _process; 120 | 121 | void _handleStdoutData(List data) { 122 | _buffer.addAll(data); 123 | while (_buffer.isNotEmpty) { 124 | final headerEnd = _findHeaderEnd(); 125 | if (headerEnd == -1) return; 126 | final header = utf8.decode(_buffer.sublist(0, headerEnd)); 127 | final contentLength = int.parse( 128 | RegExp(r'Content-Length: (\d+)').firstMatch(header)?.group(1) ?? '0', 129 | ); 130 | if (_buffer.length < headerEnd + 4 + contentLength) return; 131 | final messageStart = headerEnd + 4; 132 | final messageEnd = messageStart + contentLength; 133 | final messageBytes = _buffer.sublist(messageStart, messageEnd); 134 | _buffer.removeRange(0, messageEnd); 135 | try { 136 | final json = jsonDecode(utf8.decode(messageBytes)); 137 | _responseController.add(json); 138 | } catch (e) { 139 | throw FormatException( 140 | 'Invalid JSON message $e', 141 | utf8.decode(messageBytes), 142 | ); 143 | } 144 | } 145 | } 146 | 147 | int _findHeaderEnd() { 148 | final endSequence = [13, 10, 13, 10]; 149 | for (var i = 0; i <= _buffer.length - endSequence.length; i++) { 150 | if (List.generate( 151 | endSequence.length, 152 | (j) => _buffer[i + j], 153 | ).every((byte) => endSequence.contains(byte))) { 154 | return i; 155 | } 156 | } 157 | return -1; 158 | } 159 | 160 | @override 161 | Future> _sendRequest({ 162 | required String method, 163 | required Map params, 164 | }) async { 165 | final id = _nextId++; 166 | final request = { 167 | 'jsonrpc': '2.0', 168 | 'id': id, 169 | 'method': method, 170 | 'params': params, 171 | }; 172 | await _sendLspMessage(request); 173 | 174 | return await _responseController.stream.firstWhere( 175 | (response) => response['id'] == id, 176 | orElse: () => throw TimeoutException('No response for request $id'), 177 | ); 178 | } 179 | 180 | @override 181 | Future _sendNotification({ 182 | required String method, 183 | required Map params, 184 | }) async { 185 | await _sendLspMessage({ 186 | 'jsonrpc': '2.0', 187 | 'method': method, 188 | 'params': params, 189 | }); 190 | } 191 | 192 | Future _sendLspMessage(Map message) async { 193 | final completer = Completer(); 194 | Future sendOperation() async { 195 | try { 196 | final body = utf8.encode(jsonEncode(message)); 197 | final header = utf8.encode('Content-Length: ${body.length}\r\n\r\n'); 198 | final combined = [...header, ...body]; 199 | _process.stdin.add(combined); 200 | await _process.stdin.flush(); 201 | completer.complete(); 202 | } catch (e) { 203 | completer.completeError(e); 204 | } 205 | } 206 | 207 | if (!_isSending) { 208 | _isSending = true; 209 | await sendOperation(); 210 | _isSending = false; 211 | } else { 212 | while (_isSending) { 213 | await Future.delayed(const Duration(microseconds: 100)); 214 | } 215 | _isSending = true; 216 | await sendOperation(); 217 | _isSending = false; 218 | } 219 | 220 | return completer.future; 221 | } 222 | 223 | @override 224 | void dispose() { 225 | _process.kill(); 226 | _responseController.close(); 227 | } 228 | } 229 | -------------------------------------------------------------------------------- /lib/code_forge/styling.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// This class provides styling options for code selection in the code editor. 4 | class CodeSelectionStyle { 5 | /// The color of the cursor line, defaults to the highlight theme text color. 6 | final Color? cursorColor; 7 | 8 | /// The color used to highlight selected text in the code editor. 9 | final Color selectionColor; 10 | 11 | /// The color of the cursor bubble that appears when selecting text. 12 | final Color cursorBubbleColor; 13 | 14 | CodeSelectionStyle({ 15 | this.cursorColor, 16 | this.selectionColor = const Color(0x6E2195F3), 17 | this.cursorBubbleColor = Colors.blue, 18 | }); 19 | } 20 | 21 | /// This class provides styling options for the Gutter. 22 | class GutterStyle { 23 | /// The style for line numbers in the gutter. Expected to be a [TextStyle]. 24 | final TextStyle? lineNumberStyle; 25 | 26 | /// The background color of the gutter bar. 27 | final Color? backgroundColor; 28 | 29 | /// The color for the folded line folding indicator icon in the gutter. Defaults to [Colors.grey]. 30 | final Color? foldedIconColor; 31 | 32 | /// The color for the unfolded line folding indicator icon in the gutter. Defaults to [Colors.grey]. 33 | final Color? unfoldedIconColor; 34 | 35 | /// The width of the gutter. Dynamic by default, which means it can adapt best width based on line number. So recommended to leave it null. 36 | final double? gutterWidth; 37 | 38 | /// The size of the folding icon in the gutter. Defaults to (widget?.textStyle?.fontSize ?? 14) * 1.2. 39 | /// 40 | /// /// Recommended to leave it null, because the default value is dynamic based on editor fontSize. 41 | final double? foldingIconSize; 42 | 43 | /// The icon used for the folded line folding indicator in the gutter. 44 | /// 45 | /// Defaults to [Icons.chevron_right_outlined] for folded lines. 46 | final IconData unfoldedIcon; 47 | 48 | /// The icon used for the unfolded line folding indicator in the gutter. 49 | /// 50 | /// Defaults to [Icons.keyboard_arrow_down_outlined] for unfolded lines. 51 | final IconData foldedIcon; 52 | 53 | /// The color used to highlight the current line number in the gutter. 54 | /// If null, the line number will use the default text color. 55 | final Color? activeLineNumberColor; 56 | 57 | /// The color used for non-active line numbers in the gutter. 58 | /// If null, defaults to a dimmed version of the text color. 59 | final Color? inactiveLineNumberColor; 60 | 61 | /// The color used to highlight line numbers with errors (severity 1). 62 | /// Defaults to red. 63 | final Color errorLineNumberColor; 64 | 65 | /// The color used to highlight line numbers with warnings (severity 2). 66 | /// Defaults to yellow/orange. 67 | final Color warningLineNumberColor; 68 | 69 | /// The background color used to highlight folded line start. 70 | /// If null, a low opacity version of the selection color is used. 71 | final Color? foldedLineHighlightColor; 72 | 73 | GutterStyle({ 74 | this.lineNumberStyle, 75 | this.backgroundColor, 76 | this.gutterWidth, 77 | this.foldedIcon = Icons.chevron_right_outlined, 78 | this.unfoldedIcon = Icons.keyboard_arrow_down_outlined, 79 | this.foldingIconSize, 80 | this.foldedIconColor, 81 | this.unfoldedIconColor, 82 | this.activeLineNumberColor, 83 | this.inactiveLineNumberColor, 84 | this.errorLineNumberColor = const Color(0xFFE53935), 85 | this.warningLineNumberColor = const Color(0xFFFFA726), 86 | this.foldedLineHighlightColor, 87 | }); 88 | } 89 | 90 | /// Base class for overlay styling options used in various popup elements. 91 | /// 92 | /// This sealed class provides common styling options for overlays such as 93 | /// suggestion popups and hover details. Extend this class to create specific 94 | /// overlay styles. 95 | sealed class OverlayStyle { 96 | /// The elevation of the overlay, which determines the shadow depth. 97 | /// Defaults to 6. 98 | final double elevation; 99 | 100 | /// The background color of the overlay. 101 | final Color backgroundColor; 102 | 103 | /// The color used when the overlay is focused. 104 | final Color focusColor; 105 | 106 | /// The color used when the overlay is hovered. 107 | final Color hoverColor; 108 | 109 | /// The color used for the splash effect when the overlay is tapped. 110 | final Color splashColor; 111 | 112 | /// The shape of the overlay, which defines its border and corner radius. 113 | /// This can be a [ShapeBorder] such as [RoundedRectangleBorder], [CircleBorder], etc. 114 | final ShapeBorder shape; 115 | 116 | /// The text style used for the text in the overlay. 117 | /// This is typically a [TextStyle] that defines the font size, weight, color, etc. 118 | final TextStyle textStyle; 119 | OverlayStyle({ 120 | this.elevation = 6, 121 | required this.shape, 122 | required this.backgroundColor, 123 | required this.focusColor, 124 | required this.hoverColor, 125 | required this.splashColor, 126 | required this.textStyle, 127 | }); 128 | } 129 | 130 | /// Styling options for the code completion suggestion popup. 131 | /// 132 | /// This class extends [OverlayStyle] to provide specific styling for the 133 | /// autocomplete suggestion list that appears while typing in the editor. 134 | /// 135 | /// Example: 136 | /// ```dart 137 | /// SuggestionStyle( 138 | /// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), 139 | /// backgroundColor: Colors.grey[900]!, 140 | /// focusColor: Colors.blue.withOpacity(0.3), 141 | /// hoverColor: Colors.blue.withOpacity(0.1), 142 | /// splashColor: Colors.blue.withOpacity(0.2), 143 | /// textStyle: TextStyle(color: Colors.white), 144 | /// ) 145 | /// ``` 146 | class SuggestionStyle extends OverlayStyle { 147 | /// Creates a [SuggestionStyle] with the specified options. 148 | SuggestionStyle({ 149 | super.elevation, 150 | required super.shape, 151 | required super.backgroundColor, 152 | required super.focusColor, 153 | required super.hoverColor, 154 | required super.splashColor, 155 | required super.textStyle, 156 | }); 157 | } 158 | 159 | /// Styling options for the hover details popup. 160 | /// 161 | /// This class extends [OverlayStyle] to provide specific styling for the 162 | /// popup that shows documentation or type information when hovering over 163 | /// code elements (requires LSP integration). 164 | /// 165 | /// Example: 166 | /// ```dart 167 | /// HoverDetailsStyle( 168 | /// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), 169 | /// backgroundColor: Colors.grey[850]!, 170 | /// focusColor: Colors.blue.withOpacity(0.3), 171 | /// hoverColor: Colors.blue.withOpacity(0.1), 172 | /// splashColor: Colors.blue.withOpacity(0.2), 173 | /// textStyle: TextStyle(color: Colors.white), 174 | /// ) 175 | /// ``` 176 | class HoverDetailsStyle extends OverlayStyle { 177 | /// Creates a [HoverDetailsStyle] with the specified options. 178 | HoverDetailsStyle({ 179 | super.elevation, 180 | required super.shape, 181 | required super.backgroundColor, 182 | required super.focusColor, 183 | required super.hoverColor, 184 | required super.splashColor, 185 | required super.textStyle, 186 | }); 187 | } 188 | 189 | /// Represents a highlighted search result in the editor 190 | class SearchHighlight { 191 | /// The start offset of the highlighted text 192 | final int start; 193 | 194 | /// The end offset of the highlighted text 195 | final int end; 196 | 197 | /// The text style to apply to the highlighted text 198 | final TextStyle style; 199 | 200 | const SearchHighlight({ 201 | required this.start, 202 | required this.end, 203 | required this.style, 204 | }); 205 | } 206 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "resource.h" 7 | 8 | namespace { 9 | 10 | /// Window attribute that enables dark mode window decorations. 11 | /// 12 | /// Redefined in case the developer's machine has a Windows SDK older than 13 | /// version 10.0.22000.0. 14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute 15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE 16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 17 | #endif 18 | 19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 20 | 21 | /// Registry key for app theme preference. 22 | /// 23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing 24 | /// value indicates apps should use light mode. 25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] = 26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; 27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; 28 | 29 | // The number of Win32Window objects that currently exist. 30 | static int g_active_window_count = 0; 31 | 32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 33 | 34 | // Scale helper to convert logical scaler values to physical using passed in 35 | // scale factor 36 | int Scale(int source, double scale_factor) { 37 | return static_cast(source * scale_factor); 38 | } 39 | 40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 41 | // This API is only needed for PerMonitor V1 awareness mode. 42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 43 | HMODULE user32_module = LoadLibraryA("User32.dll"); 44 | if (!user32_module) { 45 | return; 46 | } 47 | auto enable_non_client_dpi_scaling = 48 | reinterpret_cast( 49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 50 | if (enable_non_client_dpi_scaling != nullptr) { 51 | enable_non_client_dpi_scaling(hwnd); 52 | } 53 | FreeLibrary(user32_module); 54 | } 55 | 56 | } // namespace 57 | 58 | // Manages the Win32Window's window class registration. 59 | class WindowClassRegistrar { 60 | public: 61 | ~WindowClassRegistrar() = default; 62 | 63 | // Returns the singleton registrar instance. 64 | static WindowClassRegistrar* GetInstance() { 65 | if (!instance_) { 66 | instance_ = new WindowClassRegistrar(); 67 | } 68 | return instance_; 69 | } 70 | 71 | // Returns the name of the window class, registering the class if it hasn't 72 | // previously been registered. 73 | const wchar_t* GetWindowClass(); 74 | 75 | // Unregisters the window class. Should only be called if there are no 76 | // instances of the window. 77 | void UnregisterWindowClass(); 78 | 79 | private: 80 | WindowClassRegistrar() = default; 81 | 82 | static WindowClassRegistrar* instance_; 83 | 84 | bool class_registered_ = false; 85 | }; 86 | 87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 88 | 89 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 90 | if (!class_registered_) { 91 | WNDCLASS window_class{}; 92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 93 | window_class.lpszClassName = kWindowClassName; 94 | window_class.style = CS_HREDRAW | CS_VREDRAW; 95 | window_class.cbClsExtra = 0; 96 | window_class.cbWndExtra = 0; 97 | window_class.hInstance = GetModuleHandle(nullptr); 98 | window_class.hIcon = 99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 100 | window_class.hbrBackground = 0; 101 | window_class.lpszMenuName = nullptr; 102 | window_class.lpfnWndProc = Win32Window::WndProc; 103 | RegisterClass(&window_class); 104 | class_registered_ = true; 105 | } 106 | return kWindowClassName; 107 | } 108 | 109 | void WindowClassRegistrar::UnregisterWindowClass() { 110 | UnregisterClass(kWindowClassName, nullptr); 111 | class_registered_ = false; 112 | } 113 | 114 | Win32Window::Win32Window() { 115 | ++g_active_window_count; 116 | } 117 | 118 | Win32Window::~Win32Window() { 119 | --g_active_window_count; 120 | Destroy(); 121 | } 122 | 123 | bool Win32Window::Create(const std::wstring& title, 124 | const Point& origin, 125 | const Size& size) { 126 | Destroy(); 127 | 128 | const wchar_t* window_class = 129 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 130 | 131 | const POINT target_point = {static_cast(origin.x), 132 | static_cast(origin.y)}; 133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 135 | double scale_factor = dpi / 96.0; 136 | 137 | HWND window = CreateWindow( 138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW, 139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 141 | nullptr, nullptr, GetModuleHandle(nullptr), this); 142 | 143 | if (!window) { 144 | return false; 145 | } 146 | 147 | UpdateTheme(window); 148 | 149 | return OnCreate(); 150 | } 151 | 152 | bool Win32Window::Show() { 153 | return ShowWindow(window_handle_, SW_SHOWNORMAL); 154 | } 155 | 156 | // static 157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 158 | UINT const message, 159 | WPARAM const wparam, 160 | LPARAM const lparam) noexcept { 161 | if (message == WM_NCCREATE) { 162 | auto window_struct = reinterpret_cast(lparam); 163 | SetWindowLongPtr(window, GWLP_USERDATA, 164 | reinterpret_cast(window_struct->lpCreateParams)); 165 | 166 | auto that = static_cast(window_struct->lpCreateParams); 167 | EnableFullDpiSupportIfAvailable(window); 168 | that->window_handle_ = window; 169 | } else if (Win32Window* that = GetThisFromHandle(window)) { 170 | return that->MessageHandler(window, message, wparam, lparam); 171 | } 172 | 173 | return DefWindowProc(window, message, wparam, lparam); 174 | } 175 | 176 | LRESULT 177 | Win32Window::MessageHandler(HWND hwnd, 178 | UINT const message, 179 | WPARAM const wparam, 180 | LPARAM const lparam) noexcept { 181 | switch (message) { 182 | case WM_DESTROY: 183 | window_handle_ = nullptr; 184 | Destroy(); 185 | if (quit_on_close_) { 186 | PostQuitMessage(0); 187 | } 188 | return 0; 189 | 190 | case WM_DPICHANGED: { 191 | auto newRectSize = reinterpret_cast(lparam); 192 | LONG newWidth = newRectSize->right - newRectSize->left; 193 | LONG newHeight = newRectSize->bottom - newRectSize->top; 194 | 195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 197 | 198 | return 0; 199 | } 200 | case WM_SIZE: { 201 | RECT rect = GetClientArea(); 202 | if (child_content_ != nullptr) { 203 | // Size and position the child window. 204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 205 | rect.bottom - rect.top, TRUE); 206 | } 207 | return 0; 208 | } 209 | 210 | case WM_ACTIVATE: 211 | if (child_content_ != nullptr) { 212 | SetFocus(child_content_); 213 | } 214 | return 0; 215 | 216 | case WM_DWMCOLORIZATIONCOLORCHANGED: 217 | UpdateTheme(hwnd); 218 | return 0; 219 | } 220 | 221 | return DefWindowProc(window_handle_, message, wparam, lparam); 222 | } 223 | 224 | void Win32Window::Destroy() { 225 | OnDestroy(); 226 | 227 | if (window_handle_) { 228 | DestroyWindow(window_handle_); 229 | window_handle_ = nullptr; 230 | } 231 | if (g_active_window_count == 0) { 232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 233 | } 234 | } 235 | 236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 237 | return reinterpret_cast( 238 | GetWindowLongPtr(window, GWLP_USERDATA)); 239 | } 240 | 241 | void Win32Window::SetChildContent(HWND content) { 242 | child_content_ = content; 243 | SetParent(content, window_handle_); 244 | RECT frame = GetClientArea(); 245 | 246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 247 | frame.bottom - frame.top, true); 248 | 249 | SetFocus(child_content_); 250 | } 251 | 252 | RECT Win32Window::GetClientArea() { 253 | RECT frame; 254 | GetClientRect(window_handle_, &frame); 255 | return frame; 256 | } 257 | 258 | HWND Win32Window::GetHandle() { 259 | return window_handle_; 260 | } 261 | 262 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 263 | quit_on_close_ = quit_on_close; 264 | } 265 | 266 | bool Win32Window::OnCreate() { 267 | // No-op; provided for subclasses. 268 | return true; 269 | } 270 | 271 | void Win32Window::OnDestroy() { 272 | // No-op; provided for subclasses. 273 | } 274 | 275 | void Win32Window::UpdateTheme(HWND const window) { 276 | DWORD light_mode; 277 | DWORD light_mode_size = sizeof(light_mode); 278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, 279 | kGetPreferredBrightnessRegValue, 280 | RRF_RT_REG_DWORD, nullptr, &light_mode, 281 | &light_mode_size); 282 | 283 | if (result == ERROR_SUCCESS) { 284 | BOOL enable_dark_mode = light_mode == 0; 285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, 286 | &enable_dark_mode, sizeof(enable_dark_mode)); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /lib/code_forge/undo_redo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/services.dart'; 3 | 4 | /// Represents a single edit operation that can be undone/redone. 5 | /// Designed to work efficiently with rope data structures. 6 | sealed class EditOperation { 7 | /// The cursor position before this edit 8 | final TextSelection selectionBefore; 9 | 10 | /// The cursor position after this edit 11 | final TextSelection selectionAfter; 12 | 13 | /// Timestamp when this edit was made 14 | final DateTime timestamp; 15 | 16 | EditOperation({ 17 | required this.selectionBefore, 18 | required this.selectionAfter, 19 | DateTime? timestamp, 20 | }) : timestamp = timestamp ?? DateTime.now(); 21 | 22 | /// Create the inverse operation for undo 23 | EditOperation inverse(); 24 | 25 | /// Check if this operation can be merged with another (for grouping rapid edits) 26 | bool canMergeWith(EditOperation other); 27 | 28 | /// Merge this operation with another 29 | EditOperation mergeWith(EditOperation other); 30 | } 31 | 32 | /// An insertion operation 33 | class InsertOperation extends EditOperation { 34 | /// Position where text was inserted 35 | final int offset; 36 | 37 | /// The text that was inserted 38 | final String text; 39 | 40 | InsertOperation({ 41 | required this.offset, 42 | required this.text, 43 | required super.selectionBefore, 44 | required super.selectionAfter, 45 | super.timestamp, 46 | }); 47 | 48 | @override 49 | EditOperation inverse() { 50 | return DeleteOperation( 51 | offset: offset, 52 | text: text, 53 | selectionBefore: selectionAfter, 54 | selectionAfter: selectionBefore, 55 | ); 56 | } 57 | 58 | @override 59 | bool canMergeWith(EditOperation other) { 60 | if (other is! InsertOperation) return false; 61 | 62 | final timeDiff = other.timestamp.difference(timestamp).inMilliseconds.abs(); 63 | if (timeDiff > 500) return false; 64 | 65 | if (other.offset == offset + text.length) { 66 | if (text.contains('\n') || other.text.contains('\n')) return false; 67 | final thisEndsWithSpace = text.endsWith(' ') || text.endsWith('\t'); 68 | final otherStartsWithSpace = 69 | other.text.startsWith(' ') || other.text.startsWith('\t'); 70 | if (thisEndsWithSpace != otherStartsWithSpace && 71 | text.isNotEmpty && 72 | other.text.isNotEmpty) { 73 | return false; 74 | } 75 | return true; 76 | } 77 | return false; 78 | } 79 | 80 | @override 81 | EditOperation mergeWith(EditOperation other) { 82 | if (other is! InsertOperation) return this; 83 | return InsertOperation( 84 | offset: offset, 85 | text: text + other.text, 86 | selectionBefore: selectionBefore, 87 | selectionAfter: other.selectionAfter, 88 | timestamp: other.timestamp, 89 | ); 90 | } 91 | 92 | @override 93 | String toString() => 94 | 'Insert($offset, "${text.length > 20 ? '${text.substring(0, 20)}...' : text}")'; 95 | } 96 | 97 | /// A deletion operation 98 | class DeleteOperation extends EditOperation { 99 | /// Position where deletion started 100 | final int offset; 101 | 102 | /// The text that was deleted 103 | final String text; 104 | 105 | DeleteOperation({ 106 | required this.offset, 107 | required this.text, 108 | required super.selectionBefore, 109 | required super.selectionAfter, 110 | super.timestamp, 111 | }); 112 | 113 | @override 114 | EditOperation inverse() { 115 | return InsertOperation( 116 | offset: offset, 117 | text: text, 118 | selectionBefore: selectionAfter, 119 | selectionAfter: selectionBefore, 120 | ); 121 | } 122 | 123 | @override 124 | bool canMergeWith(EditOperation other) { 125 | if (other is! DeleteOperation) return false; 126 | 127 | final timeDiff = other.timestamp.difference(timestamp).inMilliseconds.abs(); 128 | if (timeDiff > 500) return false; 129 | 130 | if (text.contains('\n') || other.text.contains('\n')) return false; 131 | 132 | if (other.offset == offset - other.text.length) { 133 | return true; 134 | } 135 | 136 | if (other.offset == offset) { 137 | return true; 138 | } 139 | return false; 140 | } 141 | 142 | @override 143 | EditOperation mergeWith(EditOperation other) { 144 | if (other is! DeleteOperation) return this; 145 | 146 | if (other.offset == offset - other.text.length) { 147 | return DeleteOperation( 148 | offset: other.offset, 149 | text: other.text + text, 150 | selectionBefore: selectionBefore, 151 | selectionAfter: other.selectionAfter, 152 | timestamp: other.timestamp, 153 | ); 154 | } 155 | 156 | if (other.offset == offset) { 157 | return DeleteOperation( 158 | offset: offset, 159 | text: text + other.text, 160 | selectionBefore: selectionBefore, 161 | selectionAfter: other.selectionAfter, 162 | timestamp: other.timestamp, 163 | ); 164 | } 165 | return this; 166 | } 167 | 168 | @override 169 | String toString() => 170 | 'Delete($offset, "${text.length > 20 ? '${text.substring(0, 20)}...' : text}")'; 171 | } 172 | 173 | /// A replacement operation (delete + insert at same position) 174 | class ReplaceOperation extends EditOperation { 175 | /// Position where replacement started 176 | final int offset; 177 | 178 | /// The text that was deleted 179 | final String deletedText; 180 | 181 | /// The text that was inserted 182 | final String insertedText; 183 | 184 | ReplaceOperation({ 185 | required this.offset, 186 | required this.deletedText, 187 | required this.insertedText, 188 | required super.selectionBefore, 189 | required super.selectionAfter, 190 | super.timestamp, 191 | }); 192 | 193 | @override 194 | EditOperation inverse() { 195 | return ReplaceOperation( 196 | offset: offset, 197 | deletedText: insertedText, 198 | insertedText: deletedText, 199 | selectionBefore: selectionAfter, 200 | selectionAfter: selectionBefore, 201 | ); 202 | } 203 | 204 | @override 205 | bool canMergeWith(EditOperation other) { 206 | return false; 207 | } 208 | 209 | @override 210 | EditOperation mergeWith(EditOperation other) => this; 211 | 212 | @override 213 | String toString() => 214 | 'Replace($offset, "${deletedText.length > 10 ? '${deletedText.substring(0, 10)}...' : deletedText}" -> "${insertedText.length > 10 ? '${insertedText.substring(0, 10)}...' : insertedText}")'; 215 | } 216 | 217 | /// Controller for managing undo/redo operations. 218 | /// 219 | /// Usage: 220 | /// ```dart 221 | /// final undoController = UndoRedoController(); 222 | /// 223 | /// CodeForge( 224 | /// controller: controller, 225 | /// undoController: undoController, 226 | /// ) 227 | /// 228 | /// // Undo last operation 229 | /// undoController.undo(); 230 | /// 231 | /// // Redo last undone operation 232 | /// undoController.redo(); 233 | /// ``` 234 | class UndoRedoController extends ChangeNotifier { 235 | final List _undoStack = []; 236 | final List _redoStack = []; 237 | 238 | /// Maximum number of operations to keep in the undo stack 239 | final int maxStackSize; 240 | 241 | /// Whether to group rapid sequential edits into single operations 242 | final bool groupEdits; 243 | 244 | /// Callback to apply an edit operation to the text 245 | void Function(EditOperation operation)? _applyEdit; 246 | 247 | /// Whether an undo/redo operation is currently in progress 248 | bool _isUndoRedoInProgress = false; 249 | 250 | UndoRedoController({this.maxStackSize = 1000, this.groupEdits = true}); 251 | 252 | /// Whether undo is available 253 | bool get canUndo => _undoStack.isNotEmpty; 254 | 255 | /// Whether redo is available 256 | bool get canRedo => _redoStack.isNotEmpty; 257 | 258 | /// Number of operations in the undo stack 259 | int get undoStackSize => _undoStack.length; 260 | 261 | /// Number of operations in the redo stack 262 | int get redoStackSize => _redoStack.length; 263 | 264 | /// Check if an undo/redo operation is currently being applied 265 | bool get isUndoRedoInProgress => _isUndoRedoInProgress; 266 | 267 | /// Set the callback to apply edit operations 268 | void setApplyEditCallback(void Function(EditOperation operation) callback) { 269 | _applyEdit = callback; 270 | } 271 | 272 | /// Record an edit operation. Called by the controller when text changes. 273 | void recordEdit(EditOperation operation) { 274 | if (_isUndoRedoInProgress) return; 275 | 276 | if (_redoStack.isNotEmpty) { 277 | _redoStack.clear(); 278 | } 279 | 280 | if (groupEdits && _undoStack.isNotEmpty) { 281 | final last = _undoStack.last; 282 | if (last.canMergeWith(operation)) { 283 | _undoStack[_undoStack.length - 1] = last.mergeWith(operation); 284 | notifyListeners(); 285 | return; 286 | } 287 | } 288 | 289 | _undoStack.add(operation); 290 | 291 | while (_undoStack.length > maxStackSize) { 292 | _undoStack.removeAt(0); 293 | } 294 | 295 | notifyListeners(); 296 | } 297 | 298 | /// Undo the last operation 299 | bool undo() { 300 | if (!canUndo || _applyEdit == null) return false; 301 | 302 | final operation = _undoStack.removeLast(); 303 | final inverse = operation.inverse(); 304 | 305 | _isUndoRedoInProgress = true; 306 | try { 307 | _applyEdit!(inverse); 308 | _redoStack.add(operation); 309 | } finally { 310 | _isUndoRedoInProgress = false; 311 | } 312 | 313 | notifyListeners(); 314 | return true; 315 | } 316 | 317 | /// Redo the last undone operation 318 | bool redo() { 319 | if (!canRedo || _applyEdit == null) return false; 320 | 321 | final operation = _redoStack.removeLast(); 322 | 323 | _isUndoRedoInProgress = true; 324 | try { 325 | _applyEdit!(operation); 326 | _undoStack.add(operation); 327 | } finally { 328 | _isUndoRedoInProgress = false; 329 | } 330 | 331 | notifyListeners(); 332 | return true; 333 | } 334 | 335 | /// Clear all undo/redo history 336 | void clear() { 337 | _undoStack.clear(); 338 | _redoStack.clear(); 339 | notifyListeners(); 340 | } 341 | 342 | /// Begin a compound operation that should be undone as a single unit. 343 | /// Call [endCompoundOperation] when done. 344 | CompoundOperationHandle beginCompoundOperation() { 345 | return CompoundOperationHandle._(this); 346 | } 347 | 348 | /// Internal method for compound operation handle to call notifyListeners 349 | void _notifyListenersPublic() { 350 | notifyListeners(); 351 | } 352 | 353 | @override 354 | void dispose() { 355 | _undoStack.clear(); 356 | _redoStack.clear(); 357 | super.dispose(); 358 | } 359 | } 360 | 361 | /// Handle for grouping multiple edits into a single undo operation. 362 | class CompoundOperationHandle { 363 | final UndoRedoController _controller; 364 | final int _startStackSize; 365 | bool _isActive = true; 366 | 367 | CompoundOperationHandle._(this._controller) 368 | : _startStackSize = _controller._undoStack.length; 369 | 370 | /// End the compound operation, combining all recorded edits into one. 371 | void end() { 372 | if (!_isActive) return; 373 | _isActive = false; 374 | 375 | final newOps = _controller._undoStack.sublist(_startStackSize); 376 | if (newOps.isEmpty) return; 377 | 378 | _controller._undoStack.removeRange( 379 | _startStackSize, 380 | _controller._undoStack.length, 381 | ); 382 | 383 | final compound = CompoundOperation( 384 | operations: newOps, 385 | selectionBefore: newOps.first.selectionBefore, 386 | selectionAfter: newOps.last.selectionAfter, 387 | ); 388 | 389 | _controller._undoStack.add(compound); 390 | _controller._notifyListenersPublic(); 391 | } 392 | } 393 | 394 | /// A compound operation that groups multiple edits into one undo unit. 395 | class CompoundOperation extends EditOperation { 396 | final List operations; 397 | 398 | CompoundOperation({ 399 | required this.operations, 400 | required super.selectionBefore, 401 | required super.selectionAfter, 402 | }); 403 | 404 | @override 405 | EditOperation inverse() { 406 | return CompoundOperation( 407 | operations: operations.reversed.map((op) => op.inverse()).toList(), 408 | selectionBefore: selectionAfter, 409 | selectionAfter: selectionBefore, 410 | ); 411 | } 412 | 413 | @override 414 | bool canMergeWith(EditOperation other) => false; 415 | 416 | @override 417 | EditOperation mergeWith(EditOperation other) => this; 418 | 419 | @override 420 | String toString() => 'Compound(${operations.length} operations)'; 421 | } 422 | -------------------------------------------------------------------------------- /lib/AI_completion/ai.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:meta/meta.dart'; 3 | import 'package:http/http.dart' as http; 4 | 5 | /// A class that provides AI completion functionality. 6 | /// Click here for documentation: [AICompletion](https://github.com/heckmon/flutter_code_crafter/blob/main/docs/AICompletion.md) 7 | /// 8 | /// Example usage: 9 | /// 10 | /// ```dart 11 | ///import 'package:flutter/material.dart'; 12 | ///import 'package:code_forge/code_forge.dart'; 13 | /// 14 | ///final aiCompletion = AiCompletion( 15 | /// model: Gemini( 16 | /// apiKey: "Your API Key", 17 | /// ) 18 | ///) 19 | ///``` 20 | /// 21 | ///Then pass the `aiCompletion` instance to the `CodeForge` widget: 22 | /// 23 | ///```dart 24 | ///CodeForge( 25 | /// controller: controller, 26 | /// theme: anOldHopeTheme, 27 | /// aiCompletion: aiCompletion, // Pass the AI completion instance here 28 | ///), 29 | ///``` 30 | /// 31 | class AiCompletion { 32 | /// The model to use for AI completion. 33 | /// 34 | /// This should be an instance of a class that extends [Models]. 35 | /// Documentation and available models can be found here: [AICompletion](https://github.com/heckmon/flutter_code_crafter/blob/main/docs/AICompletion.md) 36 | Models model; 37 | 38 | /// Whether to enable AI completion. Defaults to true. 39 | bool enableCompletion; 40 | 41 | /// The debounce time in milliseconds for AI completion requests. Defaults to 1000ms. 42 | int debounceTime; 43 | 44 | /// Whether the completion is auto or manual 45 | /// Use [CompletionType.auto] for automatic completion and [CompletionType.manual] to invoke the completion on a callback or [CompletionType.mixed] for both. 46 | /// Defaults to [CompletionType.auto] 47 | CompletionType completionType; 48 | 49 | AiCompletion({ 50 | required this.model, 51 | this.completionType = CompletionType.auto, 52 | this.debounceTime = 1000, 53 | this.enableCompletion = true, 54 | }); 55 | } 56 | 57 | sealed class Models { 58 | /// API Url 59 | String get url; 60 | 61 | /// API key for the AI service, if required. 62 | String? get apiKey; 63 | 64 | /// The model to use for AI completion, if applicable. 65 | String? get model; 66 | 67 | /// Headers to include in the HTTP request. 68 | Map get headers; 69 | 70 | @protected 71 | final String instruction = 72 | "You are a code completion engine. " 73 | "The input contains partial code context split into sections, with the exact insertion point marked by the placeholder '<|CURSOR|>'. " 74 | "Using only the provided context, generate the code that should be inserted at the cursor position. " 75 | "Do not repeat the placeholder, do not include explanations, comments, formatting markers, or surrounding context. " 76 | "Return only the code to insert."; 77 | 78 | Map buildRequest(String code); 79 | 80 | String responseParser(dynamic response); 81 | 82 | Future completionResponse(String code) async { 83 | final uri = Uri.parse(url); 84 | final response = await http.post( 85 | uri, 86 | headers: headers, 87 | body: jsonEncode(buildRequest(code)), 88 | ); 89 | if (response.statusCode == 200) { 90 | return _cleanCode(responseParser(jsonDecode(response.body))); 91 | } 92 | throw Exception( 93 | "Failed to load AI suggestion \nStatus code: ${response.statusCode}\n error: ${response.body}", 94 | ); 95 | } 96 | 97 | @protected 98 | String _cleanCode(String raw) { 99 | final codeBlockRegex = RegExp(r'```(?:\w+)?\n([\s\S]*?)\n```'); 100 | final thinkRegex = RegExp(r'[\s\S]*?<\/think>'); 101 | raw = raw.replaceAll(thinkRegex, '').trim(); 102 | final match = codeBlockRegex.firstMatch(raw); 103 | if (match != null) return match.group(1)!.trim(); 104 | 105 | return raw.trim(); 106 | } 107 | } 108 | 109 | sealed class OpenAiCompatible extends Models { 110 | @protected 111 | String get baseUrl; 112 | @override 113 | String get url => "$baseUrl/chat/completions"; 114 | 115 | @override 116 | Map get headers => { 117 | "Content-Type": "application/json", 118 | "Authorization": "Bearer $apiKey", 119 | }; 120 | 121 | @override 122 | Map buildRequest(String code) { 123 | return { 124 | "model": model, 125 | "messages": [ 126 | {"role": "system", "content": instruction}, 127 | {"role": "user", "content": code}, 128 | ], 129 | }; 130 | } 131 | 132 | @override 133 | String responseParser(dynamic response) { 134 | try { 135 | return response["choices"][0]["message"]["content"]; 136 | } catch (e) { 137 | throw FormatException( 138 | "Failed to parse AI response: $e \nResponse: $response", 139 | ); 140 | } 141 | } 142 | } 143 | 144 | /// Goole Gemini AI model implementation. 145 | class Gemini extends Models { 146 | @override 147 | final String url, apiKey, model; 148 | @override 149 | Map get headers => {'Content-Type': 'application/json'}; 150 | int? temperature, maxOutputTokens, topP, topK, stopSequences; 151 | 152 | Gemini({ 153 | required this.apiKey, 154 | this.model = 'gemini-2.5-flash-lite', 155 | this.temperature, 156 | this.maxOutputTokens, 157 | this.topP, 158 | this.topK, 159 | this.stopSequences, 160 | }) : url = 161 | 'https://generativelanguage.googleapis.com/v1beta/models/$model:generateContent?key=$apiKey'; 162 | 163 | @override 164 | String responseParser(dynamic response) { 165 | try { 166 | if (response == null) return ""; 167 | return response["candidates"]?[0]?["content"]?["parts"]?[0]?["text"] ?? 168 | "AI completion is not available"; 169 | } catch (e) { 170 | throw FormatException( 171 | "Failed to parse AI response: $e \nResponse: $response", 172 | ); 173 | } 174 | } 175 | 176 | @override 177 | Map buildRequest(String code) { 178 | return { 179 | "systemInstruction": { 180 | "parts": [ 181 | {"text": instruction}, 182 | ], 183 | }, 184 | "contents": [ 185 | { 186 | "parts": [ 187 | {"text": code}, 188 | ], 189 | }, 190 | ], 191 | "generationConfig": { 192 | "stopSequences": ["Title"], 193 | "temperature": temperature ?? 1.0, 194 | "maxOutputTokens": maxOutputTokens ?? 800, 195 | "topP": topP ?? 0.8, 196 | "topK": topK ?? 10, 197 | }, 198 | }; 199 | } 200 | } 201 | 202 | /// OpenAI AI model implementation. 203 | class OpenAI extends Models { 204 | @override 205 | final String url = 'https://api.openai.com/v1/responses', apiKey, model; 206 | 207 | OpenAI({required this.apiKey, required this.model}); 208 | 209 | @override 210 | String responseParser(dynamic response) { 211 | try { 212 | return response[0]["content"][0]["text"]; 213 | } catch (e) { 214 | throw FormatException( 215 | "Failed to parse AI response: $e \nResponse: $response", 216 | ); 217 | } 218 | } 219 | 220 | @override 221 | Map get headers => { 222 | 'Content-Type': 'application/json', 223 | 'Authorization': 'Bearer $apiKey', 224 | }; 225 | 226 | @override 227 | Map buildRequest(String code) { 228 | return {"model": model, "instructions": instruction, "input": code}; 229 | } 230 | } 231 | 232 | /// Claude AI model implementation. 233 | class Claude extends Models { 234 | @override 235 | final String url = 'https://api.anthropic.com/v1/messages', apiKey, model; 236 | 237 | Claude({required this.apiKey, required this.model}); 238 | 239 | @override 240 | String responseParser(dynamic response) { 241 | try { 242 | return response["content"][0]["text"]; 243 | } catch (e) { 244 | throw FormatException( 245 | "Failed to parse AI response: $e \nResponse: $response", 246 | ); 247 | } 248 | } 249 | 250 | @override 251 | Map get headers => { 252 | 'Content-Type': 'application/json', 253 | 'x-api-key': apiKey, 254 | }; 255 | 256 | @override 257 | Map buildRequest(String code) { 258 | return { 259 | "model": model, 260 | "max_tokens": 1024, 261 | "system": instruction, 262 | "messages": [ 263 | {"role": "user", "content": code}, 264 | ], 265 | }; 266 | } 267 | } 268 | 269 | /// Grok aka xAI AI model implementation. 270 | class Grok extends OpenAiCompatible { 271 | @override 272 | String get baseUrl => "https://api.x.ai/v1"; 273 | @override 274 | final String apiKey, model; 275 | Grok({required this.apiKey, required this.model}); 276 | } 277 | 278 | /// DeepSeek AI model implementation. 279 | class DeepSeek extends OpenAiCompatible { 280 | @override 281 | String get baseUrl => "https://api.deepseek.com"; 282 | @override 283 | final String apiKey, model; 284 | DeepSeek({required this.apiKey, required this.model}); 285 | } 286 | 287 | /// Groq AI model implementation. 288 | class Gorq extends OpenAiCompatible { 289 | @override 290 | String get baseUrl => "https://api.groq.com/openai/v1"; 291 | @override 292 | final String apiKey, model; 293 | Gorq({required this.apiKey, required this.model}); 294 | } 295 | 296 | /// Together AI model implementation. 297 | class TogetherAi extends OpenAiCompatible { 298 | @override 299 | String get baseUrl => "https://api.together.xyz/v1"; 300 | @override 301 | final String apiKey, model; 302 | TogetherAi({required this.apiKey, required this.model}); 303 | } 304 | 305 | /// Sonar AI model implementation. 306 | class Sonar extends OpenAiCompatible { 307 | @override 308 | String get baseUrl => "https://api.perplexity.ai"; 309 | @override 310 | final String apiKey, model; 311 | Sonar({required this.apiKey, required this.model}); 312 | } 313 | 314 | /// OpenRouter AI model implementation. 315 | class OpenRouter extends OpenAiCompatible { 316 | @override 317 | String get baseUrl => "https://openrouter.ai/api/v1"; 318 | @override 319 | final String apiKey, model; 320 | OpenRouter({required this.apiKey, required this.model}); 321 | } 322 | 323 | /// FireWorks AI model implementation. 324 | class FireWorks extends OpenAiCompatible { 325 | @override 326 | String get baseUrl => "https://api.fireworks.ai/inference/v1"; 327 | @override 328 | final String apiKey, model; 329 | FireWorks({required this.apiKey, required this.model}); 330 | } 331 | 332 | /// Custom AI model implementation that allows for custom API endpoints and request/response handling. 333 | /// 334 | /// Example usage: 335 | /// 336 | /// ```dart 337 | ///late final Models model; 338 | /// 339 | /// @override 340 | /// void initState() { 341 | /// model = CustomModel( 342 | /// url: "https://api.together.xyz/v1/chat/completions", 343 | /// customHeaders: { 344 | /// "Authorization": "Bearer ${your_api_key}", 345 | /// "Content-Type": "application/json" 346 | /// }, 347 | /// requestBuilder: (code, instruction){ 348 | /// return { 349 | /// "model": "deepseek-ai/DeepSeek-V3", 350 | /// "messages": [ 351 | /// { 352 | /// "role": "system", 353 | /// "content": instruction 354 | /// }, 355 | /// { 356 | /// "role": "user", 357 | /// "content": code 358 | /// } 359 | /// ] 360 | /// }; 361 | /// }, 362 | /// customParser: (response) => response['choices'][0]['message']['content'] 363 | /// ); 364 | /// controller = CodeForgeController(); 365 | /// controller.language = python; 366 | /// super.initState(); 367 | /// } 368 | ///``` 369 | ///Then pass the `model` instance to the `AiCompletion` class: 370 | 371 | ///```dart 372 | /// @override 373 | /// Widget build(BuildContext context) { 374 | /// return MaterialApp( 375 | /// home: Scaffold( 376 | /// body: CodeForge( 377 | /// editorTheme: anOldHopeTheme, 378 | /// controller: controller, 379 | /// aiCompletion: AiCompletion( 380 | /// model: model // Pass the custom model here 381 | /// ), 382 | /// ) 383 | /// ), 384 | /// ); 385 | /// } 386 | ///``` 387 | class CustomModel extends Models { 388 | /// The URL for the custom AI service endpoint. 389 | @override 390 | final String url; 391 | @override 392 | String? get apiKey => null; 393 | @override 394 | String? get model => null; 395 | final String httpMethod; 396 | final Map customHeaders; 397 | final Map Function(String code, String instruction)? 398 | requestBuilder; 399 | final String Function(dynamic response) customParser; 400 | 401 | CustomModel({ 402 | required this.url, 403 | required this.customHeaders, 404 | required this.requestBuilder, 405 | required this.customParser, 406 | this.httpMethod = 'POST', 407 | }); 408 | 409 | @override 410 | String responseParser(dynamic response) { 411 | try { 412 | return customParser(response); 413 | } catch (e) { 414 | throw FormatException( 415 | "Failed to parse AI response: $e \nResponse: $response", 416 | ); 417 | } 418 | } 419 | 420 | @override 421 | Map get headers { 422 | final headers = {'Content-Type': 'application/json', ...customHeaders}; 423 | 424 | return headers; 425 | } 426 | 427 | @override 428 | Map buildRequest(String code) { 429 | if (requestBuilder != null) { 430 | return requestBuilder!(code, instruction); 431 | } 432 | return { 433 | if (model != null) 'model': model, 434 | 'code': code, 435 | 'parameters': {'instruction': instruction, 'temperature': 0.2}, 436 | }; 437 | } 438 | 439 | @override 440 | Future completionResponse(String code) async { 441 | try { 442 | final uri = Uri.parse(url); 443 | final response = httpMethod.toUpperCase() == 'GET' 444 | ? await http.get(uri, headers: headers) 445 | : await http.post( 446 | uri, 447 | headers: headers, 448 | body: jsonEncode(buildRequest(code)), 449 | ); 450 | 451 | if (response.statusCode == 200) { 452 | return responseParser(jsonDecode(response.body)); 453 | } else { 454 | throw Exception( 455 | 'Request failed with status ${response.statusCode}\n ${response.body}\n$uri', 456 | ); 457 | } 458 | } catch (e) { 459 | throw Exception('Failed to complete request: $e'); 460 | } 461 | } 462 | } 463 | 464 | /// Enum that defines the type of AI completion behavior. 465 | enum CompletionType { 466 | /// Completion is triggered automatically based on the debounce time. 467 | /// This is the default behavior. 468 | auto, 469 | 470 | /// Completion is triggered manually, typically through the getManualAiCompletion() callback in the [CodeForgeController]. 471 | /// eg: 472 | /// ```dart 473 | /// controller.getManualAiCompletion(); 474 | /// ``` 475 | /// 476 | /// Use this when you have a very limited number of requests to the AI service, or when you want to control when the AI completion is invoked. 477 | manual, 478 | 479 | /// Completion shown automatically, but it can be triggered manually using the callback as well. 480 | mixed, 481 | } 482 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | args: 5 | dependency: transitive 6 | description: 7 | name: args 8 | sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.7.0" 12 | async: 13 | dependency: transitive 14 | description: 15 | name: async 16 | sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.13.0" 20 | boolean_selector: 21 | dependency: transitive 22 | description: 23 | name: boolean_selector 24 | sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "2.1.2" 28 | characters: 29 | dependency: transitive 30 | description: 31 | name: characters 32 | sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.4.0" 36 | clock: 37 | dependency: transitive 38 | description: 39 | name: clock 40 | sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.1.2" 44 | code_forge: 45 | dependency: "direct main" 46 | description: 47 | path: ".." 48 | relative: true 49 | source: path 50 | version: "1.3.1" 51 | collection: 52 | dependency: transitive 53 | description: 54 | name: collection 55 | sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" 56 | url: "https://pub.dev" 57 | source: hosted 58 | version: "1.19.1" 59 | crypto: 60 | dependency: transitive 61 | description: 62 | name: crypto 63 | sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf 64 | url: "https://pub.dev" 65 | source: hosted 66 | version: "3.0.7" 67 | cupertino_icons: 68 | dependency: "direct main" 69 | description: 70 | name: cupertino_icons 71 | sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 72 | url: "https://pub.dev" 73 | source: hosted 74 | version: "1.0.8" 75 | fake_async: 76 | dependency: transitive 77 | description: 78 | name: fake_async 79 | sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" 80 | url: "https://pub.dev" 81 | source: hosted 82 | version: "1.3.3" 83 | ffi: 84 | dependency: transitive 85 | description: 86 | name: ffi 87 | sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" 88 | url: "https://pub.dev" 89 | source: hosted 90 | version: "2.1.4" 91 | flutter: 92 | dependency: "direct main" 93 | description: flutter 94 | source: sdk 95 | version: "0.0.0" 96 | flutter_highlight: 97 | dependency: transitive 98 | description: 99 | name: flutter_highlight 100 | sha256: "7b96333867aa07e122e245c033b8ad622e4e3a42a1a2372cbb098a2541d8782c" 101 | url: "https://pub.dev" 102 | source: hosted 103 | version: "0.7.0" 104 | flutter_lints: 105 | dependency: "direct dev" 106 | description: 107 | name: flutter_lints 108 | sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" 109 | url: "https://pub.dev" 110 | source: hosted 111 | version: "6.0.0" 112 | flutter_markdown_plus: 113 | dependency: transitive 114 | description: 115 | name: flutter_markdown_plus 116 | sha256: "7f349c075157816da399216a4127096108fd08e1ac931e34e72899281db4113c" 117 | url: "https://pub.dev" 118 | source: hosted 119 | version: "1.0.5" 120 | flutter_test: 121 | dependency: "direct dev" 122 | description: flutter 123 | source: sdk 124 | version: "0.0.0" 125 | flutter_web_plugins: 126 | dependency: transitive 127 | description: flutter 128 | source: sdk 129 | version: "0.0.0" 130 | google_fonts: 131 | dependency: "direct main" 132 | description: 133 | name: google_fonts 134 | sha256: ba03d03bcaa2f6cb7bd920e3b5027181db75ab524f8891c8bc3aa603885b8055 135 | url: "https://pub.dev" 136 | source: hosted 137 | version: "6.3.3" 138 | highlight: 139 | dependency: transitive 140 | description: 141 | name: highlight 142 | sha256: "5353a83ffe3e3eca7df0abfb72dcf3fa66cc56b953728e7113ad4ad88497cf21" 143 | url: "https://pub.dev" 144 | source: hosted 145 | version: "0.7.0" 146 | http: 147 | dependency: transitive 148 | description: 149 | name: http 150 | sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" 151 | url: "https://pub.dev" 152 | source: hosted 153 | version: "1.6.0" 154 | http_parser: 155 | dependency: transitive 156 | description: 157 | name: http_parser 158 | sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" 159 | url: "https://pub.dev" 160 | source: hosted 161 | version: "4.1.2" 162 | leak_tracker: 163 | dependency: transitive 164 | description: 165 | name: leak_tracker 166 | sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" 167 | url: "https://pub.dev" 168 | source: hosted 169 | version: "11.0.2" 170 | leak_tracker_flutter_testing: 171 | dependency: transitive 172 | description: 173 | name: leak_tracker_flutter_testing 174 | sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" 175 | url: "https://pub.dev" 176 | source: hosted 177 | version: "3.0.10" 178 | leak_tracker_testing: 179 | dependency: transitive 180 | description: 181 | name: leak_tracker_testing 182 | sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" 183 | url: "https://pub.dev" 184 | source: hosted 185 | version: "3.0.2" 186 | lints: 187 | dependency: transitive 188 | description: 189 | name: lints 190 | sha256: a5e2b223cb7c9c8efdc663ef484fdd95bb243bff242ef5b13e26883547fce9a0 191 | url: "https://pub.dev" 192 | source: hosted 193 | version: "6.0.0" 194 | markdown: 195 | dependency: transitive 196 | description: 197 | name: markdown 198 | sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1" 199 | url: "https://pub.dev" 200 | source: hosted 201 | version: "7.3.0" 202 | markdown_tooltip: 203 | dependency: transitive 204 | description: 205 | name: markdown_tooltip 206 | sha256: a2a47673d24c921be25fc04341bf3a865a1b6c5c6356dff0bee3f1fa122757ca 207 | url: "https://pub.dev" 208 | source: hosted 209 | version: "0.0.10" 210 | markdown_widget: 211 | dependency: transitive 212 | description: 213 | name: markdown_widget 214 | sha256: b52c13d3ee4d0e60c812e15b0593f142a3b8a2003cde1babb271d001a1dbdc1c 215 | url: "https://pub.dev" 216 | source: hosted 217 | version: "2.3.2+8" 218 | matcher: 219 | dependency: transitive 220 | description: 221 | name: matcher 222 | sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 223 | url: "https://pub.dev" 224 | source: hosted 225 | version: "0.12.17" 226 | material_color_utilities: 227 | dependency: transitive 228 | description: 229 | name: material_color_utilities 230 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec 231 | url: "https://pub.dev" 232 | source: hosted 233 | version: "0.11.1" 234 | meta: 235 | dependency: transitive 236 | description: 237 | name: meta 238 | sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" 239 | url: "https://pub.dev" 240 | source: hosted 241 | version: "1.17.0" 242 | path: 243 | dependency: "direct main" 244 | description: 245 | name: path 246 | sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" 247 | url: "https://pub.dev" 248 | source: hosted 249 | version: "1.9.1" 250 | path_provider: 251 | dependency: transitive 252 | description: 253 | name: path_provider 254 | sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" 255 | url: "https://pub.dev" 256 | source: hosted 257 | version: "2.1.5" 258 | path_provider_android: 259 | dependency: transitive 260 | description: 261 | name: path_provider_android 262 | sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e 263 | url: "https://pub.dev" 264 | source: hosted 265 | version: "2.2.22" 266 | path_provider_foundation: 267 | dependency: transitive 268 | description: 269 | name: path_provider_foundation 270 | sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4" 271 | url: "https://pub.dev" 272 | source: hosted 273 | version: "2.5.1" 274 | path_provider_linux: 275 | dependency: transitive 276 | description: 277 | name: path_provider_linux 278 | sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 279 | url: "https://pub.dev" 280 | source: hosted 281 | version: "2.2.1" 282 | path_provider_platform_interface: 283 | dependency: transitive 284 | description: 285 | name: path_provider_platform_interface 286 | sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" 287 | url: "https://pub.dev" 288 | source: hosted 289 | version: "2.1.2" 290 | path_provider_windows: 291 | dependency: transitive 292 | description: 293 | name: path_provider_windows 294 | sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 295 | url: "https://pub.dev" 296 | source: hosted 297 | version: "2.3.0" 298 | platform: 299 | dependency: transitive 300 | description: 301 | name: platform 302 | sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" 303 | url: "https://pub.dev" 304 | source: hosted 305 | version: "3.1.6" 306 | plugin_platform_interface: 307 | dependency: transitive 308 | description: 309 | name: plugin_platform_interface 310 | sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" 311 | url: "https://pub.dev" 312 | source: hosted 313 | version: "2.1.8" 314 | re_highlight: 315 | dependency: "direct main" 316 | description: 317 | name: re_highlight 318 | sha256: "6c4ac3f76f939fb7ca9df013df98526634e17d8f7460e028bd23a035870024f2" 319 | url: "https://pub.dev" 320 | source: hosted 321 | version: "0.0.3" 322 | scroll_to_index: 323 | dependency: transitive 324 | description: 325 | name: scroll_to_index 326 | sha256: b707546e7500d9f070d63e5acf74fd437ec7eeeb68d3412ef7b0afada0b4f176 327 | url: "https://pub.dev" 328 | source: hosted 329 | version: "3.0.1" 330 | sky_engine: 331 | dependency: transitive 332 | description: flutter 333 | source: sdk 334 | version: "0.0.0" 335 | source_span: 336 | dependency: transitive 337 | description: 338 | name: source_span 339 | sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" 340 | url: "https://pub.dev" 341 | source: hosted 342 | version: "1.10.1" 343 | stack_trace: 344 | dependency: transitive 345 | description: 346 | name: stack_trace 347 | sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" 348 | url: "https://pub.dev" 349 | source: hosted 350 | version: "1.12.1" 351 | stream_channel: 352 | dependency: transitive 353 | description: 354 | name: stream_channel 355 | sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" 356 | url: "https://pub.dev" 357 | source: hosted 358 | version: "2.1.4" 359 | string_scanner: 360 | dependency: transitive 361 | description: 362 | name: string_scanner 363 | sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" 364 | url: "https://pub.dev" 365 | source: hosted 366 | version: "1.4.1" 367 | term_glyph: 368 | dependency: transitive 369 | description: 370 | name: term_glyph 371 | sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" 372 | url: "https://pub.dev" 373 | source: hosted 374 | version: "1.2.2" 375 | test_api: 376 | dependency: transitive 377 | description: 378 | name: test_api 379 | sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 380 | url: "https://pub.dev" 381 | source: hosted 382 | version: "0.7.7" 383 | typed_data: 384 | dependency: transitive 385 | description: 386 | name: typed_data 387 | sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 388 | url: "https://pub.dev" 389 | source: hosted 390 | version: "1.4.0" 391 | url_launcher: 392 | dependency: transitive 393 | description: 394 | name: url_launcher 395 | sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 396 | url: "https://pub.dev" 397 | source: hosted 398 | version: "6.3.2" 399 | url_launcher_android: 400 | dependency: transitive 401 | description: 402 | name: url_launcher_android 403 | sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611" 404 | url: "https://pub.dev" 405 | source: hosted 406 | version: "6.3.28" 407 | url_launcher_ios: 408 | dependency: transitive 409 | description: 410 | name: url_launcher_ios 411 | sha256: cfde38aa257dae62ffe79c87fab20165dfdf6988c1d31b58ebf59b9106062aad 412 | url: "https://pub.dev" 413 | source: hosted 414 | version: "6.3.6" 415 | url_launcher_linux: 416 | dependency: transitive 417 | description: 418 | name: url_launcher_linux 419 | sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a 420 | url: "https://pub.dev" 421 | source: hosted 422 | version: "3.2.2" 423 | url_launcher_macos: 424 | dependency: transitive 425 | description: 426 | name: url_launcher_macos 427 | sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18" 428 | url: "https://pub.dev" 429 | source: hosted 430 | version: "3.2.5" 431 | url_launcher_platform_interface: 432 | dependency: transitive 433 | description: 434 | name: url_launcher_platform_interface 435 | sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" 436 | url: "https://pub.dev" 437 | source: hosted 438 | version: "2.3.2" 439 | url_launcher_web: 440 | dependency: transitive 441 | description: 442 | name: url_launcher_web 443 | sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2" 444 | url: "https://pub.dev" 445 | source: hosted 446 | version: "2.4.1" 447 | url_launcher_windows: 448 | dependency: transitive 449 | description: 450 | name: url_launcher_windows 451 | sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f" 452 | url: "https://pub.dev" 453 | source: hosted 454 | version: "3.1.5" 455 | vector_math: 456 | dependency: transitive 457 | description: 458 | name: vector_math 459 | sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b 460 | url: "https://pub.dev" 461 | source: hosted 462 | version: "2.2.0" 463 | visibility_detector: 464 | dependency: transitive 465 | description: 466 | name: visibility_detector 467 | sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 468 | url: "https://pub.dev" 469 | source: hosted 470 | version: "0.4.0+2" 471 | vm_service: 472 | dependency: transitive 473 | description: 474 | name: vm_service 475 | sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" 476 | url: "https://pub.dev" 477 | source: hosted 478 | version: "15.0.2" 479 | web: 480 | dependency: transitive 481 | description: 482 | name: web 483 | sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" 484 | url: "https://pub.dev" 485 | source: hosted 486 | version: "1.1.1" 487 | web_socket: 488 | dependency: transitive 489 | description: 490 | name: web_socket 491 | sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" 492 | url: "https://pub.dev" 493 | source: hosted 494 | version: "1.0.1" 495 | web_socket_channel: 496 | dependency: transitive 497 | description: 498 | name: web_socket_channel 499 | sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 500 | url: "https://pub.dev" 501 | source: hosted 502 | version: "3.0.3" 503 | xdg_directories: 504 | dependency: transitive 505 | description: 506 | name: xdg_directories 507 | sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" 508 | url: "https://pub.dev" 509 | source: hosted 510 | version: "1.1.0" 511 | sdks: 512 | dart: ">=3.10.3 <4.0.0" 513 | flutter: ">=3.35.0" 514 | --------------------------------------------------------------------------------