├── linux ├── .gitignore ├── main.cc ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugins.cmake │ ├── generated_plugin_registrant.cc │ └── CMakeLists.txt ├── my_application.h ├── packaging │ └── deb │ │ └── make_config.yaml └── my_application.cc ├── doc ├── issues.txt └── resources.txt ├── ios ├── 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-50x50@1x.png │ │ │ ├── Icon-App-50x50@2x.png │ │ │ ├── Icon-App-57x57@1x.png │ │ │ ├── Icon-App-57x57@2x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-72x72@1x.png │ │ │ ├── Icon-App-72x72@2x.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 ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.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 ├── .gitignore └── Podfile ├── assets ├── icon.png └── icon_macos.png ├── media └── demo.png ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── manifest.json └── index.html ├── snap └── gui │ ├── app_icon.png │ └── app_icon.desktop ├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── ic_launcher-playstore.png │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── studio │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── macos ├── Runner │ ├── Configs │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ ├── Warnings.xcconfig │ │ └── AppInfo.xcconfig │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_64.png │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_512.png │ │ │ └── Contents.json │ ├── Release.entitlements │ ├── AppDelegate.swift │ ├── DebugProfile.entitlements │ ├── MainFlutterWindow.swift │ └── Info.plist ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── packaging │ └── dmg │ │ └── make_config.yaml ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Podfile └── Podfile.lock ├── lib ├── src │ ├── util │ │ ├── uuid.dart │ │ ├── target_platform.dart │ │ ├── tabs_extension.dart │ │ ├── validators.dart │ │ ├── provider_logger.dart │ │ └── single_activator.dart │ ├── ui │ │ ├── shortcut │ │ │ ├── intents.dart │ │ │ ├── global_shortcuts.dart │ │ │ └── global_actions.dart │ │ ├── shared │ │ │ ├── fluent_navigator.dart │ │ │ ├── fluent_back_button.dart │ │ │ ├── fluent_form.dart │ │ │ ├── macos_titlebar.dart │ │ │ ├── fluent_menu_card.dart │ │ │ └── macos_form.dart │ │ ├── tabs │ │ │ ├── playground.dart │ │ │ ├── settings_tab │ │ │ │ ├── settings_tab.dart │ │ │ │ └── settings_tab_hosts.dart │ │ │ ├── plugin_tab.dart │ │ │ ├── devtools_tab.dart │ │ │ ├── code_editor_tab.dart │ │ │ └── add_host_tab.dart │ │ ├── shortcuts.dart │ │ └── context_menu.dart │ ├── core │ │ ├── state │ │ │ ├── tabs.dart │ │ │ ├── host.dart │ │ │ ├── plugin.dart │ │ │ └── database.dart │ │ ├── service │ │ │ ├── window_service.dart │ │ │ ├── active_tab_service.dart │ │ │ └── tabs_service.dart │ │ ├── record │ │ │ ├── ssh_key_record.dart │ │ │ ├── ssh_host_record.dart │ │ │ ├── ssh_host_record.g.dart │ │ │ └── ssh_key_record.g.dart │ │ ├── host.dart │ │ ├── conn.dart │ │ └── plugin.dart │ ├── hosts │ │ ├── local_spec.dart │ │ ├── local_conn.dart │ │ ├── ssh_conn.dart │ │ ├── local_host.dart │ │ └── ssh_host.dart │ └── plugins │ │ ├── file_manager │ │ ├── navigation_stack.dart │ │ └── navigation_breadcrumbs.dart │ │ ├── starter │ │ └── starter_plugin.dart │ │ └── terminal │ │ ├── terminal_plugin.dart │ │ └── terminal_menu.dart └── main.dart ├── windows ├── packaging │ └── msix │ │ └── make_config.yaml ├── runner │ ├── resources │ │ └── app_icon.ico │ ├── resource.h │ ├── utils.h │ ├── runner.exe.manifest │ ├── flutter_window.h │ ├── CMakeLists.txt │ ├── main.cpp │ ├── utils.cpp │ ├── flutter_window.cpp │ ├── Runner.rc │ └── win32_window.h ├── .gitignore ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt └── CMakeLists.txt ├── icons_launcher.yaml ├── README.md ├── .github └── workflows │ ├── autotag.yml │ └── build.yml ├── .gitignore ├── test └── widget_test.dart ├── analysis_options.yaml ├── .metadata └── pubspec.yaml /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /doc/issues.txt: -------------------------------------------------------------------------------- 1 | https://github.com/flutter/flutter/issues/30735 -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/assets/icon.png -------------------------------------------------------------------------------- /doc/resources.txt: -------------------------------------------------------------------------------- 1 | https://sudonull.com/post/12229-Meet-the-Windows-pseudo-console-ConPTY -------------------------------------------------------------------------------- /media/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/media/demo.png -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/web/favicon.png -------------------------------------------------------------------------------- /assets/icon_macos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/assets/icon_macos.png -------------------------------------------------------------------------------- /snap/gui/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/snap/gui/app_icon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/web/icons/Icon-512.png -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /lib/src/util/uuid.dart: -------------------------------------------------------------------------------- 1 | import 'package:uuid/uuid.dart'; 2 | 3 | const _uuid = Uuid(); 4 | 5 | String uuidV4() => _uuid.v4(); 6 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /windows/packaging/msix/make_config.yaml: -------------------------------------------------------------------------------- 1 | display_name: TerminalStudio 2 | # sign_msix: "false" 3 | install_certificate: "false" 4 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /android/app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/src/ui/shortcut/intents.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | class NewWindowIntent extends Intent { 4 | const NewWindowIntent(); 5 | } 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-hdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-mdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TerminalStudio/studio/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/studio/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.studio 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /snap/gui/app_icon.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Flutter Linux App 3 | Comment=Flutter Linux launcher icon 4 | Exec=app_icon 5 | Icon=app_icon.png 6 | Terminal=false 7 | Type=Application 8 | Categories=Entertainment; 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/src/core/state/tabs.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | 4 | final tabsProvider = Provider((ref) { 5 | return TabsDocument(); 6 | }); 7 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /macos/packaging/dmg/make_config.yaml: -------------------------------------------------------------------------------- 1 | title: TerminalStudio 2 | contents: 3 | - x: 448 4 | y: 344 5 | type: link 6 | path: "/Applications" 7 | - x: 192 8 | y: 344 9 | type: file 10 | path: TerminalStudio.app 11 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.cs.allow-jit 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/hosts/local_spec.dart: -------------------------------------------------------------------------------- 1 | import 'package:terminal_studio/src/core/conn.dart'; 2 | import 'package:terminal_studio/src/hosts/local_conn.dart'; 3 | 4 | class LocalHostSpec implements HostSpec { 5 | @override 6 | final name = 'Local'; 7 | 8 | @override 9 | HostConnector createConnector() => LocalConnector(); 10 | } 11 | -------------------------------------------------------------------------------- /icons_launcher.yaml: -------------------------------------------------------------------------------- 1 | icons_launcher: 2 | image_path: "assets/icon.png" 3 | platforms: 4 | android: 5 | enable: true 6 | ios: 7 | enable: true 8 | macos: 9 | enable: true 10 | image_path: "assets/icon_macos.png" 11 | windows: 12 | enable: true 13 | linux: 14 | enable: true 15 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## TerminalStudio 2 | 3 | Terminal emulator written in **Flutter**. 4 | 5 | *Comming soon.* 6 | 7 | 8 | 9 | ## Build 10 | ``` 11 | git submodule update --init 12 | ``` 13 | 14 | ``` 15 | git pull --recurse-submodules 16 | ``` -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/hosts/local_conn.dart: -------------------------------------------------------------------------------- 1 | import 'package:terminal_studio/src/core/conn.dart'; 2 | import 'package:terminal_studio/src/hosts/local_host.dart'; 3 | 4 | class LocalConnector extends HostConnector { 5 | LocalConnector(); 6 | 7 | @override 8 | Future createHost() async { 9 | return LocalHost(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /lib/src/util/target_platform.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | extension TargetPlatformExtension on TargetPlatform { 4 | bool get isApple => 5 | this == TargetPlatform.iOS || this == TargetPlatform.macOS; 6 | 7 | bool get isDesktop => 8 | this == TargetPlatform.linux || 9 | this == TargetPlatform.macOS || 10 | this == TargetPlatform.windows; 11 | } 12 | -------------------------------------------------------------------------------- /.github/workflows/autotag.yml: -------------------------------------------------------------------------------- 1 | name: Create Tag 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: jacopocarlini/action-autotag@3.0.0 14 | env: 15 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 16 | with: 17 | tag_prefix: "v" 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/ui/shortcut/global_shortcuts.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:terminal_studio/src/ui/shortcut/intents.dart'; 3 | import 'package:terminal_studio/src/ui/shortcuts.dart' as shortcuts; 4 | 5 | class GlobalShortcuts extends StatelessWidget { 6 | const GlobalShortcuts({super.key, required this.child}); 7 | 8 | final Widget child; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Shortcuts( 13 | shortcuts: { 14 | shortcuts.openNewWindow: const NewWindowIntent(), 15 | }, 16 | child: child, 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/core/service/window_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:window_manager/window_manager.dart'; 3 | 4 | class WindowService { 5 | Future createWindow() async { 6 | // final executable = Platform.resolvedExecutable; 7 | // await Process.start(executable, [], mode: ProcessStartMode.detached); 8 | } 9 | 10 | Future setTitle(String title) async { 11 | await windowManager.setTitle(title); 12 | } 13 | } 14 | 15 | final windowServiceProvider = Provider( 16 | name: 'WindowService', 17 | (ref) => WindowService(), 18 | ); 19 | -------------------------------------------------------------------------------- /lib/src/ui/shared/fluent_navigator.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | class FluentNavigatorCommandBar extends StatelessWidget { 4 | const FluentNavigatorCommandBar({super.key, required this.primaryItems}); 5 | 6 | final List primaryItems; 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Container( 11 | padding: const EdgeInsets.only(right: 8), 12 | child: CommandBar( 13 | mainAxisAlignment: MainAxisAlignment.end, 14 | crossAxisAlignment: CrossAxisAlignment.center, 15 | primaryItems: primaryItems, 16 | ), 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/core/service/active_tab_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:terminal_studio/src/core/state/tabs.dart'; 4 | 5 | class ActiveTabService { 6 | final Ref ref; 7 | 8 | ActiveTabService(this.ref); 9 | 10 | Tabs? getActiveTabGroup() { 11 | return getActiveTab()?.parent; 12 | } 13 | 14 | TabItem? getActiveTab() { 15 | return ref.read(tabsProvider).activeTab.value; 16 | } 17 | } 18 | 19 | final activeTabServiceProvider = Provider( 20 | name: 'activeTabServiceProvider', 21 | (ref) => ActiveTabService(ref), 22 | ); 23 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/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 = TerminalStudio 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.dartssh.terminalstudio 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 xuty. All rights reserved. 15 | -------------------------------------------------------------------------------- /lib/src/util/tabs_extension.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:terminal_studio/src/core/state/tabs.dart'; 4 | 5 | extension RefTabsExtension on WidgetRef { 6 | void openTab(TabItem tab) { 7 | final document = read(tabsProvider); 8 | document.root?.add(tab); 9 | tab.activate(); 10 | } 11 | } 12 | 13 | extension TabItemExtension on TabItem { 14 | void addToSide(TabItem item) { 15 | final parent = this.parent; 16 | 17 | if (parent == null) { 18 | return; 19 | } 20 | 21 | parent.insert(parent.indexOf(this) + 1, item); 22 | 23 | parent.activate(item); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/core/record/ssh_key_record.dart: -------------------------------------------------------------------------------- 1 | import 'package:hive_flutter/hive_flutter.dart'; 2 | import 'package:terminal_studio/src/util/uuid.dart'; 3 | 4 | part 'ssh_key_record.g.dart'; 5 | 6 | @HiveType(typeId: 1) 7 | class SSHKeyRecord extends HiveObject { 8 | @HiveField(0) 9 | String uuid; 10 | 11 | @HiveField(1) 12 | String name; 13 | 14 | @HiveField(2) 15 | String? comment; 16 | 17 | @HiveField(3) 18 | String? passphrase; 19 | 20 | @HiveField(4) 21 | String? privateKey; 22 | 23 | @HiveField(5) 24 | String? publicKey; 25 | 26 | SSHKeyRecord({ 27 | String? uuid, 28 | required this.name, 29 | this.comment, 30 | this.passphrase, 31 | this.privateKey, 32 | this.publicKey, 33 | }) : uuid = uuid ?? uuidV4(); 34 | } 35 | -------------------------------------------------------------------------------- /lib/src/ui/shared/fluent_back_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | class FluentBackButton extends StatelessWidget { 4 | const FluentBackButton({super.key, this.onPressed}); 5 | 6 | final VoidCallback? onPressed; 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return PaneItem( 11 | icon: const Icon(FluentIcons.back, size: 14.0), 12 | body: const SizedBox.shrink(), 13 | ).build( 14 | context, 15 | false, 16 | () => _onPressed(context), 17 | displayMode: PaneDisplayMode.compact, 18 | ); 19 | } 20 | 21 | void _onPressed(BuildContext context) { 22 | if (onPressed != null) { 23 | onPressed!(); 24 | } else { 25 | Navigator.of(context).maybePop(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/src/core/state/host.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:terminal_studio/src/core/conn.dart'; 3 | import 'package:terminal_studio/src/core/host.dart'; 4 | 5 | final connectorProvider = Provider.family( 6 | name: 'connectorProvider', 7 | (ref, HostSpec config) => config.createConnector(), 8 | ); 9 | 10 | final connectorStatusProvider = 11 | StateNotifierProvider.family( 12 | name: 'connectorStatusProvider', 13 | (ref, HostSpec config) => ref.watch(connectorProvider(config)), 14 | ); 15 | 16 | final hostProvider = Provider.family( 17 | name: 'hostProvider', 18 | (ref, spec) { 19 | ref.watch(connectorStatusProvider(spec)); 20 | return ref.watch(connectorProvider(spec)).host; 21 | }, 22 | ); 23 | -------------------------------------------------------------------------------- /lib/src/ui/shortcut/global_actions.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:terminal_studio/src/core/service/window_service.dart'; 4 | import 'package:terminal_studio/src/ui/shortcut/intents.dart'; 5 | 6 | class GlobalActions extends ConsumerWidget { 7 | const GlobalActions({super.key, required this.child}); 8 | 9 | final Widget child; 10 | 11 | @override 12 | Widget build(BuildContext context, WidgetRef ref) { 13 | return Actions( 14 | actions: { 15 | NewWindowIntent: CallbackAction( 16 | onInvoke: (NewWindowIntent intent) async { 17 | await ref.read(windowServiceProvider).createWindow(); 18 | return null; 19 | }, 20 | ), 21 | }, 22 | child: child, 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/src/ui/tabs/playground.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:fluent_ui/fluent_ui.dart'; 3 | 4 | class PlaygroundTab extends TabItem { 5 | PlaygroundTab() { 6 | title.value = const Text('Playground'); 7 | content.value = const PlaygroundView(); 8 | } 9 | } 10 | 11 | class PlaygroundView extends StatefulWidget { 12 | const PlaygroundView({super.key}); 13 | 14 | @override 15 | State createState() => _PlaygroundViewState(); 16 | } 17 | 18 | class _PlaygroundViewState extends State { 19 | var topIndex = 0; 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | return Stack( 24 | children: const [ 25 | SizedBox( 26 | width: 300, 27 | height: 300, 28 | child: Text('Hello'), 29 | ), 30 | Acrylic(), 31 | ], 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /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 | #include 11 | #include 12 | #include 13 | 14 | void RegisterPlugins(flutter::PluginRegistry* registry) { 15 | FlutterAcrylicPluginRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("FlutterAcrylicPlugin")); 17 | ScreenRetrieverPluginRegisterWithRegistrar( 18 | registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); 19 | UrlLauncherWindowsRegisterWithRegistrar( 20 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 21 | WindowManagerPluginRegisterWithRegistrar( 22 | registry->GetRegistrarForPlugin("WindowManagerPlugin")); 23 | } 24 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import flutter_acrylic 9 | import macos_ui 10 | import path_provider_macos 11 | import screen_retriever 12 | import url_launcher_macos 13 | import window_manager 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | FlutterAcrylicPlugin.register(with: registry.registrar(forPlugin: "FlutterAcrylicPlugin")) 17 | MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin")) 18 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 19 | ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) 20 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 21 | WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | 48 | .vscode 49 | 50 | dist/ -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_acrylic 7 | screen_retriever 8 | url_launcher_linux 9 | window_manager 10 | ) 11 | 12 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 13 | flutter_pty 14 | ) 15 | 16 | set(PLUGIN_BUNDLED_LIBRARIES) 17 | 18 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 19 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 20 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 21 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 23 | endforeach(plugin) 24 | 25 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 26 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 27 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 28 | endforeach(ffi_plugin) 29 | -------------------------------------------------------------------------------- /lib/src/util/validators.dart: -------------------------------------------------------------------------------- 1 | import 'package:terminal_studio/src/util/internet_address.dart'; 2 | 3 | bool isIPv4(String address) { 4 | try { 5 | InternetAddress(address, type: InternetAddressType.ipv4); 6 | return true; 7 | } catch (e) { 8 | return false; 9 | } 10 | } 11 | 12 | bool isIPv6(String address) { 13 | try { 14 | InternetAddress(address, type: InternetAddressType.ipv6); 15 | return true; 16 | } catch (e) { 17 | return false; 18 | } 19 | } 20 | 21 | bool isDomain(String address) { 22 | const pattern = 23 | r'^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])*$'; 24 | return RegExp(pattern).hasMatch(address); 25 | } 26 | 27 | bool isHostOrIP(String value) { 28 | return isIPv4(value) || isIPv6(value) || isDomain(value); 29 | } 30 | 31 | bool isPort(String input) { 32 | final value = int.tryParse(input); 33 | if (value == null) return false; 34 | return value >= 0 && value <= 65535; 35 | } 36 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_acrylic 7 | screen_retriever 8 | url_launcher_windows 9 | window_manager 10 | ) 11 | 12 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 13 | flutter_pty 14 | ) 15 | 16 | set(PLUGIN_BUNDLED_LIBRARIES) 17 | 18 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 19 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 20 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 21 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 23 | endforeach(plugin) 24 | 25 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 26 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 27 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 28 | endforeach(ffi_plugin) 29 | -------------------------------------------------------------------------------- /lib/src/ui/shared/fluent_form.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | class FluentFormDivider extends StatelessWidget { 4 | const FluentFormDivider({super.key}); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Column( 9 | children: const [ 10 | SizedBox(height: 8), 11 | Divider(), 12 | SizedBox(height: 8), 13 | ], 14 | ); 15 | } 16 | } 17 | 18 | class FluentFormHeader extends StatelessWidget { 19 | const FluentFormHeader(this.header, {super.key}); 20 | 21 | final String header; 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return Column( 26 | children: [ 27 | Text(header), 28 | const SizedBox(height: 8), 29 | ], 30 | ); 31 | } 32 | } 33 | 34 | class FluentFormSeparator extends StatelessWidget { 35 | const FluentFormSeparator({super.key}); 36 | 37 | @override 38 | Widget build(BuildContext context) { 39 | return const SizedBox(height: 8); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/src/core/state/plugin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:terminal_studio/src/core/conn.dart'; 3 | import 'package:terminal_studio/src/core/plugin.dart'; 4 | import 'package:terminal_studio/src/core/state/host.dart'; 5 | 6 | final pluginManagerProvider = Provider.family( 7 | name: 'pluginManagerProvider', 8 | (ref, spec) { 9 | final manager = PluginManager(spec); 10 | 11 | ref.listen( 12 | hostProvider(spec), 13 | (last, current) { 14 | if (last == null && current != null) { 15 | manager.didConnected(current); 16 | } 17 | 18 | if (last != null && current == null) { 19 | manager.didDisconnected(); 20 | } 21 | }, 22 | fireImmediately: true, 23 | ); 24 | 25 | ref.listen( 26 | connectorStatusProvider(spec), 27 | (last, current) { 28 | manager.didConnectionStatusChanged(current); 29 | }, 30 | ); 31 | 32 | return manager; 33 | }, 34 | ); 35 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "studio", 3 | "short_name": "studio", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /lib/src/core/record/ssh_host_record.dart: -------------------------------------------------------------------------------- 1 | import 'package:hive_flutter/hive_flutter.dart'; 2 | import 'package:terminal_studio/src/core/conn.dart'; 3 | import 'package:terminal_studio/src/hosts/ssh_conn.dart'; 4 | import 'package:terminal_studio/src/util/uuid.dart'; 5 | 6 | part 'ssh_host_record.g.dart'; 7 | 8 | @HiveType(typeId: 0) 9 | class SSHHostRecord extends HiveObject implements HostSpec { 10 | @HiveField(0) 11 | String uuid; 12 | 13 | @override 14 | @HiveField(1) 15 | String name; 16 | 17 | @HiveField(2) 18 | String host; 19 | 20 | @HiveField(3) 21 | int port; 22 | 23 | @HiveField(4) 24 | String? username; 25 | 26 | @HiveField(5) 27 | String? password; 28 | 29 | SSHHostRecord({ 30 | String? uuid, 31 | required this.name, 32 | required this.host, 33 | required this.port, 34 | this.username, 35 | this.password, 36 | }) : uuid = uuid ?? uuidV4(); 37 | 38 | SSHHostRecord.uninitialized() 39 | : this( 40 | name: '', 41 | host: '', 42 | port: 22, 43 | ); 44 | 45 | @override 46 | HostConnector createConnector() => SSHConnector(this); 47 | } 48 | -------------------------------------------------------------------------------- /lib/src/core/host.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:terminal_studio/src/core/fs.dart'; 4 | 5 | abstract class Host { 6 | Future connectFileSystem(); 7 | 8 | Future execute( 9 | String executable, { 10 | List args = const [], 11 | bool root = false, 12 | Map? environment, 13 | }); 14 | 15 | Future shell({ 16 | int width = 80, 17 | int height = 25, 18 | Map? environment, 19 | }); 20 | 21 | Future disconnect(); 22 | 23 | Future get done; 24 | } 25 | 26 | /// Result of command execution. 27 | abstract class ExecutionResult { 28 | /// Exit code of the command. 29 | int get exitCode; 30 | 31 | /// Standard output of the command. 32 | String get stdout; 33 | 34 | /// Standard error of the command. 35 | String get stderr; 36 | } 37 | 38 | abstract class ExecutionSession { 39 | Future write(Uint8List data); 40 | 41 | Future resize(int width, int height); 42 | 43 | Future close(); 44 | 45 | Stream get output; 46 | 47 | Future get exitCode; 48 | } 49 | -------------------------------------------------------------------------------- /lib/src/util/provider_logger.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | 3 | class ProviderLogger implements ProviderObserver { 4 | const ProviderLogger(); 5 | 6 | @override 7 | void didAddProvider( 8 | ProviderBase provider, 9 | Object? value, 10 | ProviderContainer container, 11 | ) { 12 | print('Provider+: ${provider.describe}'); 13 | } 14 | 15 | @override 16 | void didDisposeProvider( 17 | ProviderBase provider, 18 | ProviderContainer container, 19 | ) { 20 | print('Provider-: ${provider.describe}'); 21 | } 22 | 23 | @override 24 | void didUpdateProvider( 25 | ProviderBase provider, 26 | Object? previousValue, 27 | Object? newValue, 28 | ProviderContainer container, 29 | ) { 30 | print('Provider*: ${provider.describe}'); 31 | } 32 | 33 | @override 34 | void providerDidFail( 35 | ProviderBase provider, 36 | Object error, 37 | StackTrace stackTrace, 38 | ProviderContainer container, 39 | ) { 40 | print('Provider!: ${provider.describe}'); 41 | } 42 | } 43 | 44 | extension _ProviderName on ProviderBase { 45 | String get describe => name ?? toString(); 46 | } 47 | -------------------------------------------------------------------------------- /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:terminal_studio/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/core/state/database.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | import 'package:hive_flutter/hive_flutter.dart'; 3 | import 'package:terminal_studio/src/core/record/ssh_host_record.dart'; 4 | import 'package:terminal_studio/src/core/record/ssh_key_record.dart'; 5 | 6 | final hiveProvider = FutureProvider((ref) async { 7 | await Hive.initFlutter('.TerminalStudio'); 8 | return Hive; 9 | }); 10 | 11 | // typeId: 0 12 | final sshHostBoxProvider = FutureProvider>((ref) async { 13 | final hive = await ref.watch(hiveProvider.future); 14 | hive.registerAdapter(SSHHostRecordAdapter()); 15 | return hive.openBox('ssh_hosts'); 16 | }); 17 | 18 | final sshHostsProvider = FutureProvider>((ref) async { 19 | final box = await ref.watch(sshHostBoxProvider.future); 20 | box.watch().listen((event) => ref.invalidateSelf()); 21 | return box.values.toList(); 22 | }); 23 | 24 | // typeId: 1 25 | final sshKeyBoxProvider = FutureProvider>((ref) async { 26 | final hive = await ref.watch(hiveProvider.future); 27 | hive.registerAdapter(SSHKeyRecordAdapter()); 28 | return hive.openBox('ssh_keys'); 29 | }); 30 | -------------------------------------------------------------------------------- /lib/src/util/single_activator.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:terminal_studio/src/util/target_platform.dart'; 4 | 5 | extension SingleActivatorExtension on SingleActivator { 6 | String get platformLabel { 7 | return defaultTargetPlatform.isApple ? appleLabel : windowsLabel; 8 | } 9 | 10 | String get windowsLabel { 11 | final StringBuffer buffer = StringBuffer(); 12 | 13 | if (control) { 14 | buffer.write('Ctrl+'); 15 | } 16 | if (meta) { 17 | buffer.write('Meta+'); 18 | } 19 | if (shift) { 20 | buffer.write('Shift+'); 21 | } 22 | if (alt) { 23 | buffer.write('Alt+'); 24 | } 25 | buffer.write(trigger.keyLabel); 26 | 27 | return buffer.toString(); 28 | } 29 | 30 | String get appleLabel { 31 | final StringBuffer buffer = StringBuffer(); 32 | 33 | if (control) { 34 | buffer.write('⌃'); 35 | } 36 | if (alt) { 37 | buffer.write('⌥'); 38 | } 39 | if (shift) { 40 | buffer.write('⇧'); 41 | } 42 | if (meta) { 43 | buffer.write('⌘'); 44 | } 45 | buffer.write(trigger.keyLabel); 46 | 47 | return buffer.toString(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/src/hosts/ssh_conn.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartssh2/dartssh2.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:terminal_studio/src/core/conn.dart'; 4 | import 'package:terminal_studio/src/hosts/ssh_host.dart'; 5 | import 'package:terminal_studio/src/core/record/ssh_host_record.dart'; 6 | 7 | class SSHConnector extends HostConnector { 8 | final SSHHostRecord record; 9 | 10 | SSHConnector(this.record); 11 | 12 | @override 13 | Future createHost() async { 14 | final socket = await AsyncValue.guard( 15 | () => SSHSocket.connect( 16 | record.host, 17 | record.port, 18 | ), 19 | ); 20 | 21 | if (socket.hasError) { 22 | final error = socket.error!; 23 | throw 'Failed to connect: $error'; 24 | } 25 | 26 | final client = SSHClient( 27 | socket.value!, 28 | username: record.username!, 29 | onPasswordRequest: () => record.password, 30 | ); 31 | 32 | final authenticated = await AsyncValue.guard(() => client.authenticated); 33 | 34 | if (authenticated.hasError) { 35 | final error = authenticated.error!; 36 | throw 'Failed to authenticate: $error'; 37 | } 38 | 39 | return SSHHost(client); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/src/ui/shared/macos_titlebar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:window_manager/window_manager.dart'; 3 | 4 | const kMacosTitlebarHeight = 28.0; 5 | 6 | class MacosTitlebar extends StatefulWidget { 7 | const MacosTitlebar({super.key, required this.color}); 8 | 9 | final Color color; 10 | 11 | @override 12 | State createState() => _MacosTitlebarState(); 13 | } 14 | 15 | class _MacosTitlebarState extends State with WindowListener { 16 | var fullScreen = false; 17 | 18 | @override 19 | void onWindowEnterFullScreen() { 20 | setState(() => fullScreen = true); 21 | super.onWindowEnterFullScreen(); 22 | } 23 | 24 | @override 25 | void onWindowLeaveFullScreen() { 26 | setState(() => fullScreen = false); 27 | super.onWindowLeaveFullScreen(); 28 | } 29 | 30 | @override 31 | void initState() { 32 | windowManager.addListener(this); 33 | super.initState(); 34 | } 35 | 36 | @override 37 | void dispose() { 38 | windowManager.removeListener(this); 39 | super.dispose(); 40 | } 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | return Container( 45 | height: fullScreen ? 0 : kMacosTitlebarHeight, 46 | color: widget.color, 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /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 | # Disable Windows macros that collide with C++ standard library functions. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 25 | 26 | # Add dependency libraries and include directories. Add any application-specific 27 | # dependencies here. 28 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 29 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 30 | 31 | # Run the Flutter tool portions of the build. This must not be removed. 32 | add_dependencies(${BINARY_NAME} flutter_assemble) 33 | -------------------------------------------------------------------------------- /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 | #include 11 | #include 12 | #include 13 | 14 | void fl_register_plugins(FlPluginRegistry* registry) { 15 | g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar = 16 | fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin"); 17 | flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar); 18 | g_autoptr(FlPluginRegistrar) screen_retriever_registrar = 19 | fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); 20 | screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); 21 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 22 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 23 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 24 | g_autoptr(FlPluginRegistrar) window_manager_registrar = 25 | fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); 26 | window_manager_plugin_register_with_registrar(window_manager_registrar); 27 | } 28 | -------------------------------------------------------------------------------- /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.CreateAndShow(L"studio", 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 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /lib/src/plugins/file_manager/navigation_stack.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | class NavigationStack with ChangeNotifier { 4 | final void Function(T item)? onNavigate; 5 | 6 | NavigationStack({this.onNavigate}); 7 | 8 | final List _stack = []; 9 | 10 | /// Pointer to the current position in the stack. -1 if the stack is empty. 11 | var _current = -1; 12 | 13 | /// The current path in the stack. 14 | T? get current => _current >= 0 ? _stack[_current] : null; 15 | 16 | /// Weather calling [back] will have any effect. 17 | bool get canGoBack => _current > 0; 18 | 19 | /// Weather calling [forward] will have any effect. 20 | bool get canGoForward => _current < _stack.length - 1; 21 | 22 | /// Pushes a new path to the stack at the current position, clears the stack 23 | /// after the current position. 24 | void push(T path) { 25 | if (_current < _stack.length - 1) { 26 | _stack.removeRange(_current + 1, _stack.length); 27 | } 28 | 29 | _stack.add(path); 30 | _current = _stack.length - 1; 31 | 32 | onNavigate?.call(path); 33 | notifyListeners(); 34 | } 35 | 36 | /// Navigates back in the stack. 37 | void back() { 38 | if (_current > 0) { 39 | _current--; 40 | 41 | onNavigate?.call(_stack[_current]); 42 | notifyListeners(); 43 | } 44 | } 45 | 46 | /// Navigates forward in the stack. 47 | void forward() { 48 | if (_current < _stack.length - 1) { 49 | _current++; 50 | 51 | onNavigate?.call(_stack[_current]); 52 | notifyListeners(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "filename": "app_icon_16.png", 5 | "idiom": "mac", 6 | "scale": "1x", 7 | "size": "16x16" 8 | }, 9 | { 10 | "filename": "app_icon_32.png", 11 | "idiom": "mac", 12 | "scale": "2x", 13 | "size": "16x16" 14 | }, 15 | { 16 | "filename": "app_icon_32.png", 17 | "idiom": "mac", 18 | "scale": "1x", 19 | "size": "32x32" 20 | }, 21 | { 22 | "filename": "app_icon_64.png", 23 | "idiom": "mac", 24 | "scale": "2x", 25 | "size": "32x32" 26 | }, 27 | { 28 | "filename": "app_icon_128.png", 29 | "idiom": "mac", 30 | "scale": "1x", 31 | "size": "128x128" 32 | }, 33 | { 34 | "filename": "app_icon_256.png", 35 | "idiom": "mac", 36 | "scale": "2x", 37 | "size": "128x128" 38 | }, 39 | { 40 | "filename": "app_icon_256.png", 41 | "idiom": "mac", 42 | "scale": "1x", 43 | "size": "256x256" 44 | }, 45 | { 46 | "filename": "app_icon_512.png", 47 | "idiom": "mac", 48 | "scale": "2x", 49 | "size": "256x256" 50 | }, 51 | { 52 | "filename": "app_icon_512.png", 53 | "idiom": "mac", 54 | "scale": "1x", 55 | "size": "512x512" 56 | }, 57 | { 58 | "filename": "app_icon_1024.png", 59 | "idiom": "mac", 60 | "scale": "2x", 61 | "size": "512x512" 62 | } 63 | ], 64 | "info": { 65 | "author": "icons_launcher", 66 | "version": 1 67 | } 68 | } -------------------------------------------------------------------------------- /lib/src/core/conn.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:terminal_studio/src/core/host.dart'; 4 | 5 | abstract class HostSpec { 6 | String get name; 7 | 8 | HostConnector createConnector(); 9 | } 10 | 11 | enum HostConnectorStatus { 12 | initialized, 13 | connecting, 14 | connected, 15 | disconnected, 16 | aborted, 17 | } 18 | 19 | abstract class HostConnector 20 | extends StateNotifier { 21 | HostConnector() : super(HostConnectorStatus.initialized); 22 | 23 | T? _host; 24 | 25 | T? get host => _host; 26 | 27 | @protected 28 | Future createHost(); 29 | 30 | Future connect() async { 31 | if (state == HostConnectorStatus.connected || 32 | state == HostConnectorStatus.connecting) { 33 | return; 34 | } 35 | 36 | state = HostConnectorStatus.connecting; 37 | 38 | try { 39 | _host = await createHost(); 40 | _host!.done.then((_) => _onDone(), onError: _onError); 41 | 42 | state = HostConnectorStatus.connected; 43 | } catch (e) { 44 | state = HostConnectorStatus.disconnected; 45 | } 46 | } 47 | 48 | Future disconnect() async { 49 | await _host?.disconnect(); 50 | _host = null; 51 | state = HostConnectorStatus.disconnected; 52 | } 53 | 54 | void _onDone() { 55 | _host = null; 56 | state = HostConnectorStatus.disconnected; 57 | } 58 | 59 | void _onError(Object error) { 60 | _host = null; 61 | state = HostConnectorStatus.aborted; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/core/record/ssh_host_record.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'ssh_host_record.dart'; 4 | 5 | // ************************************************************************** 6 | // TypeAdapterGenerator 7 | // ************************************************************************** 8 | 9 | class SSHHostRecordAdapter extends TypeAdapter { 10 | @override 11 | final int typeId = 0; 12 | 13 | @override 14 | SSHHostRecord read(BinaryReader reader) { 15 | final numOfFields = reader.readByte(); 16 | final fields = { 17 | for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), 18 | }; 19 | return SSHHostRecord( 20 | uuid: fields[0] as String?, 21 | name: fields[1] as String, 22 | host: fields[2] as String, 23 | port: fields[3] as int, 24 | username: fields[4] as String?, 25 | password: fields[5] as String?, 26 | ); 27 | } 28 | 29 | @override 30 | void write(BinaryWriter writer, SSHHostRecord obj) { 31 | writer 32 | ..writeByte(6) 33 | ..writeByte(0) 34 | ..write(obj.uuid) 35 | ..writeByte(1) 36 | ..write(obj.name) 37 | ..writeByte(2) 38 | ..write(obj.host) 39 | ..writeByte(3) 40 | ..write(obj.port) 41 | ..writeByte(4) 42 | ..write(obj.username) 43 | ..writeByte(5) 44 | ..write(obj.password); 45 | } 46 | 47 | @override 48 | int get hashCode => typeId.hashCode; 49 | 50 | @override 51 | bool operator ==(Object other) => 52 | identical(this, other) || 53 | other is SSHHostRecordAdapter && 54 | runtimeType == other.runtimeType && 55 | typeId == other.typeId; 56 | } 57 | -------------------------------------------------------------------------------- /lib/src/core/record/ssh_key_record.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'ssh_key_record.dart'; 4 | 5 | // ************************************************************************** 6 | // TypeAdapterGenerator 7 | // ************************************************************************** 8 | 9 | class SSHKeyRecordAdapter extends TypeAdapter { 10 | @override 11 | final int typeId = 1; 12 | 13 | @override 14 | SSHKeyRecord read(BinaryReader reader) { 15 | final numOfFields = reader.readByte(); 16 | final fields = { 17 | for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), 18 | }; 19 | return SSHKeyRecord( 20 | uuid: fields[0] as String?, 21 | name: fields[1] as String, 22 | comment: fields[2] as String?, 23 | passphrase: fields[3] as String?, 24 | privateKey: fields[4] as String?, 25 | publicKey: fields[5] as String?, 26 | ); 27 | } 28 | 29 | @override 30 | void write(BinaryWriter writer, SSHKeyRecord obj) { 31 | writer 32 | ..writeByte(6) 33 | ..writeByte(0) 34 | ..write(obj.uuid) 35 | ..writeByte(1) 36 | ..write(obj.name) 37 | ..writeByte(2) 38 | ..write(obj.comment) 39 | ..writeByte(3) 40 | ..write(obj.passphrase) 41 | ..writeByte(4) 42 | ..write(obj.privateKey) 43 | ..writeByte(5) 44 | ..write(obj.publicKey); 45 | } 46 | 47 | @override 48 | int get hashCode => typeId.hashCode; 49 | 50 | @override 51 | bool operator ==(Object other) => 52 | identical(this, other) || 53 | other is SSHKeyRecordAdapter && 54 | runtimeType == other.runtimeType && 55 | typeId == other.typeId; 56 | } 57 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.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. 5 | 6 | version: 7 | revision: f1875d570e39de09040c8f79aa13cc56baab8db1 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: f1875d570e39de09040c8f79aa13cc56baab8db1 17 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 18 | - platform: android 19 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 20 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 21 | - platform: ios 22 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 23 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 24 | - platform: linux 25 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 26 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 27 | - platform: macos 28 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 29 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 30 | - platform: web 31 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 32 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 33 | - platform: windows 34 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 35 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 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 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Studio 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | TerminalStudio 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /lib/src/core/service/tabs_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:terminal_studio/src/core/conn.dart'; 4 | import 'package:terminal_studio/src/core/fs.dart'; 5 | import 'package:terminal_studio/src/core/plugin.dart'; 6 | import 'package:terminal_studio/src/core/service/active_tab_service.dart'; 7 | import 'package:terminal_studio/src/core/state/plugin.dart'; 8 | import 'package:terminal_studio/src/plugins/terminal/terminal_plugin.dart'; 9 | import 'package:terminal_studio/src/ui/tabs/code_editor_tab.dart'; 10 | import 'package:terminal_studio/src/ui/tabs/plugin_tab.dart'; 11 | 12 | class TabsService { 13 | final Ref ref; 14 | 15 | TabsService(this.ref); 16 | 17 | void openTerminal(HostSpec hostSpec, {Tabs? tabs, bool activate = true}) { 18 | return openPlugin(hostSpec, TerminalPlugin(), 19 | tabs: tabs, activate: activate); 20 | } 21 | 22 | void openPlugin( 23 | HostSpec host, 24 | Plugin plugin, { 25 | Tabs? tabs, 26 | bool activate = true, 27 | }) { 28 | openTab( 29 | PluginTab(plugin, ref.read(pluginManagerProvider(host))), 30 | tabs: tabs, 31 | activate: activate, 32 | ); 33 | } 34 | 35 | void openFile(File file, {Tabs? tabs, bool activate = true}) { 36 | openTab(CodeEditorTab(file), tabs: tabs, activate: activate); 37 | } 38 | 39 | void openTab(TabItem tab, {Tabs? tabs, bool activate = true}) { 40 | final targetTabGroup = 41 | tabs ?? ref.read(activeTabServiceProvider).getActiveTabGroup(); 42 | 43 | if (targetTabGroup == null) { 44 | return; 45 | } 46 | 47 | targetTabGroup.add(tab); 48 | 49 | if (activate) { 50 | tab.activate(); 51 | } 52 | } 53 | } 54 | 55 | final tabsServiceProvider = Provider( 56 | name: 'tabsServiceProvider', 57 | (ref) => TabsService(ref), 58 | ); 59 | -------------------------------------------------------------------------------- /lib/src/ui/tabs/settings_tab/settings_tab.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:fluent_ui/fluent_ui.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:terminal_studio/src/ui/tabs/settings_tab/settings_tab_hosts.dart'; 6 | 7 | class SettingsTab extends TabItem { 8 | SettingsTab() { 9 | title.value = const Text('Settings'); 10 | content.value = const SettingsView(); 11 | } 12 | } 13 | 14 | class SettingsView extends ConsumerStatefulWidget { 15 | const SettingsView({Key? key}) : super(key: key); 16 | 17 | @override 18 | ConsumerState createState() => _SettingsViewState(); 19 | } 20 | 21 | class _SettingsViewState extends ConsumerState { 22 | var _selectedIndex = 0; 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return CupertinoTabView( 27 | builder: (context) => NavigationView( 28 | pane: NavigationPane( 29 | selected: _selectedIndex, 30 | onChanged: (index) { 31 | setState(() => _selectedIndex = index); 32 | }, 33 | displayMode: PaneDisplayMode.open, 34 | size: const NavigationPaneSize( 35 | openWidth: 200, 36 | openMinWidth: 200, 37 | ), 38 | items: [ 39 | PaneItemHeader(header: const Text('Settings')), 40 | PaneItemSeparator(), 41 | PaneItem( 42 | icon: const Icon(FluentIcons.server), 43 | title: const Text('Hosts'), 44 | body: const HostsSettingView(), 45 | ), 46 | PaneItem( 47 | icon: const Icon(FluentIcons.key_phrase_extraction), 48 | title: const Text('SSH keys'), 49 | body: const SizedBox.expand(), 50 | ), 51 | ], 52 | ), 53 | ), 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/src/plugins/file_manager/navigation_breadcrumbs.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | class NavigationBreadcrumbs extends StatelessWidget { 4 | const NavigationBreadcrumbs({ 5 | super.key, 6 | required this.breadcrumbs, 7 | this.onTap, 8 | }); 9 | 10 | final List breadcrumbs; 11 | 12 | final void Function(List breadcrumbs)? onTap; 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | final widgets = []; 17 | 18 | for (var i = 0; i < breadcrumbs.length; i++) { 19 | final breadcrumb = breadcrumbs[i]; 20 | 21 | widgets.add( 22 | BreadcrumbButton( 23 | breadcrumb: breadcrumb, 24 | onPressed: () => onTap?.call(breadcrumbs.sublist(0, i + 1)), 25 | ), 26 | ); 27 | } 28 | 29 | return SingleChildScrollView( 30 | scrollDirection: Axis.horizontal, 31 | child: Padding( 32 | padding: const EdgeInsets.symmetric(horizontal: 8), 33 | child: Row( 34 | children: widgets, 35 | ), 36 | ), 37 | ); 38 | } 39 | } 40 | 41 | class BreadcrumbButton extends StatelessWidget { 42 | const BreadcrumbButton({ 43 | super.key, 44 | this.onPressed, 45 | required this.breadcrumb, 46 | this.isPrimary = false, 47 | }); 48 | 49 | final String breadcrumb; 50 | 51 | final bool isPrimary; 52 | 53 | final void Function()? onPressed; 54 | 55 | @override 56 | Widget build(BuildContext context) { 57 | return TextButton( 58 | onPressed: onPressed, 59 | child: Text(breadcrumb), 60 | ); 61 | } 62 | } 63 | 64 | class BreadcrumbSeprator extends StatelessWidget { 65 | const BreadcrumbSeprator({super.key}); 66 | 67 | @override 68 | Widget build(BuildContext context) { 69 | return const Icon( 70 | FluentIcons.chevron_right, 71 | size: 8, 72 | // color: CupertinoColors.secondaryLabel, 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/src/plugins/starter/starter_plugin.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:fluent_ui/fluent_ui.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:terminal_studio/src/core/plugin.dart'; 6 | 7 | class StarterPlugin extends Plugin { 8 | final _uptime = ValueNotifier(null); 9 | 10 | Future _updateUptime() async { 11 | final result = await AsyncValue.guard(() => host.execute('uptime')); 12 | 13 | result.when( 14 | data: (data) => _uptime.value = data.stdout, 15 | loading: () => _uptime.value = 'Loading...', 16 | error: (error, stackTrace) => _uptime.value = 'Error: $error', 17 | ); 18 | } 19 | 20 | Future _startUpdate() async { 21 | while (connected) { 22 | await _updateUptime(); 23 | await Future.delayed(const Duration(seconds: 1)); 24 | } 25 | } 26 | 27 | @override 28 | void didMounted() { 29 | title.value = 'Uptime'; 30 | super.didMounted(); 31 | } 32 | 33 | @override 34 | void didConnected() { 35 | _startUpdate(); 36 | super.didConnected(); 37 | } 38 | 39 | @override 40 | void didDisconnected() { 41 | _uptime.value = 'Disconnected'; 42 | super.didDisconnected(); 43 | } 44 | 45 | @override 46 | Widget build(BuildContext context) { 47 | return NavigationView( 48 | pane: NavigationPane( 49 | displayMode: PaneDisplayMode.top, 50 | selected: 0, 51 | items: [ 52 | PaneItem( 53 | icon: const Icon(FluentIcons.server), 54 | title: const Text('Uptime'), 55 | body: Center( 56 | child: ValueListenableBuilder( 57 | valueListenable: _uptime, 58 | builder: (context, value, child) { 59 | return Text(value ?? 'Waiting...'); 60 | }, 61 | ), 62 | ), 63 | ), 64 | ], 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /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 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /lib/src/ui/shared/fluent_menu_card.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | class FluentMenuCard extends StatelessWidget { 4 | const FluentMenuCard({ 5 | Key? key, 6 | required this.children, 7 | this.borderRadius, 8 | this.bgColor, 9 | this.border, 10 | this.shadows, 11 | this.padding, 12 | }) : super(key: key); 13 | 14 | final List children; 15 | final Border? border; 16 | final BorderRadius? borderRadius; 17 | final Color? bgColor; 18 | final List? shadows; 19 | final EdgeInsets? padding; 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | final shadowColor = FluentTheme.of(context).shadowColor; 24 | final radius = borderRadius ?? BorderRadius.circular(4); 25 | return ConstrainedBox( 26 | constraints: const BoxConstraints(minWidth: 250), 27 | child: ClipRRect( 28 | borderRadius: radius, 29 | child: Container( 30 | padding: padding ?? const EdgeInsets.symmetric(vertical: 5), 31 | decoration: BoxDecoration( 32 | color: bgColor ?? FluentTheme.of(context).menuColor, 33 | border: border ?? Border.all(color: Colors.grey[100]), 34 | borderRadius: radius, 35 | boxShadow: shadows ?? 36 | [ 37 | BoxShadow( 38 | color: shadowColor.withOpacity(.05), 39 | blurRadius: 4, 40 | offset: const Offset(2, 2), 41 | ), 42 | BoxShadow( 43 | color: shadowColor.withOpacity(.02), 44 | blurRadius: 2, 45 | offset: const Offset(2, 2), 46 | ), 47 | ], 48 | ), 49 | child: Column( 50 | mainAxisSize: MainAxisSize.min, 51 | crossAxisAlignment: CrossAxisAlignment.start, 52 | children: children, 53 | ), 54 | ), 55 | ), 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | TerminalStudio 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /lib/src/ui/shared/macos_form.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:macos_ui/macos_ui.dart'; 4 | 5 | class MacosFormRow extends StatelessWidget { 6 | static const labelWidth = 100.0; 7 | 8 | final Widget? label; 9 | 10 | final Widget child; 11 | 12 | final double spaceBetween; 13 | 14 | const MacosFormRow({ 15 | super.key, 16 | this.label, 17 | required this.child, 18 | this.spaceBetween = 8.0, 19 | }); 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | return Padding( 24 | padding: const EdgeInsets.all(4.0), 25 | child: Row( 26 | children: [ 27 | if (label != null) 28 | Container( 29 | width: labelWidth, 30 | alignment: Alignment.centerRight, 31 | child: label, 32 | ), 33 | if (label != null) 34 | SizedBox( 35 | width: spaceBetween, 36 | ), 37 | Expanded( 38 | child: child, 39 | ), 40 | ], 41 | ), 42 | ); 43 | } 44 | } 45 | 46 | class MacosTextFormRow extends ConsumerWidget { 47 | final Widget? label; 48 | 49 | final String? placeholder; 50 | 51 | final bool obscureText; 52 | 53 | final void Function(String)? onChanged; 54 | 55 | final TextEditingController? controller; 56 | 57 | const MacosTextFormRow({ 58 | super.key, 59 | this.label, 60 | this.placeholder, 61 | this.obscureText = false, 62 | this.onChanged, 63 | this.controller, 64 | }); 65 | 66 | @override 67 | Widget build(BuildContext context, WidgetRef ref) { 68 | return MacosFormRow( 69 | label: label, 70 | spaceBetween: 6.0, 71 | child: MacosTextField( 72 | placeholder: placeholder, 73 | obscureText: obscureText, 74 | decoration: kDefaultRoundedBorderDecoration.copyWith( 75 | borderRadius: BorderRadius.circular(2), 76 | ), 77 | focusedDecoration: kDefaultFocusedBorderDecoration.copyWith( 78 | borderRadius: BorderRadius.circular(5), 79 | ), 80 | onChanged: onChanged, 81 | controller: controller, 82 | ), 83 | ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /lib/src/ui/shortcuts.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:terminal_studio/src/util/target_platform.dart'; 5 | 6 | SingleActivator get openSettings { 7 | return defaultTargetPlatform.isApple 8 | ? const SingleActivator( 9 | LogicalKeyboardKey.comma, 10 | meta: true, 11 | ) 12 | : const SingleActivator( 13 | LogicalKeyboardKey.comma, 14 | control: true, 15 | ); 16 | } 17 | 18 | SingleActivator get openDevTools { 19 | return const SingleActivator( 20 | LogicalKeyboardKey.f12, 21 | ); 22 | } 23 | 24 | SingleActivator get openNewWindow { 25 | return defaultTargetPlatform.isApple 26 | ? const SingleActivator( 27 | LogicalKeyboardKey.keyN, 28 | meta: true, 29 | ) 30 | : const SingleActivator( 31 | LogicalKeyboardKey.keyN, 32 | control: true, 33 | ); 34 | } 35 | 36 | SingleActivator get tabClose { 37 | return defaultTargetPlatform.isApple 38 | ? const SingleActivator( 39 | LogicalKeyboardKey.keyW, 40 | meta: true, 41 | ) 42 | : const SingleActivator( 43 | LogicalKeyboardKey.keyW, 44 | meta: true, 45 | shift: true, 46 | ); 47 | } 48 | 49 | SingleActivator get terminalCopy { 50 | return defaultTargetPlatform.isApple 51 | ? const SingleActivator( 52 | LogicalKeyboardKey.keyC, 53 | meta: true, 54 | ) 55 | : const SingleActivator( 56 | LogicalKeyboardKey.keyC, 57 | control: true, 58 | shift: true, 59 | ); 60 | } 61 | 62 | SingleActivator get terminalPaste { 63 | return defaultTargetPlatform.isApple 64 | ? const SingleActivator( 65 | LogicalKeyboardKey.keyV, 66 | meta: true, 67 | ) 68 | : const SingleActivator( 69 | LogicalKeyboardKey.keyV, 70 | control: true, 71 | shift: true, 72 | ); 73 | } 74 | 75 | SingleActivator get terminalSelectAll { 76 | return defaultTargetPlatform.isApple 77 | ? const SingleActivator( 78 | LogicalKeyboardKey.keyA, 79 | meta: true, 80 | ) 81 | : const SingleActivator( 82 | LogicalKeyboardKey.keyA, 83 | control: true, 84 | shift: true, 85 | ); 86 | } 87 | -------------------------------------------------------------------------------- /macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - flutter_acrylic (0.1.0): 3 | - FlutterMacOS 4 | - flutter_pty (0.0.1): 5 | - FlutterMacOS 6 | - FlutterMacOS (1.0.0) 7 | - macos_ui (0.1.0): 8 | - FlutterMacOS 9 | - path_provider_macos (0.0.1): 10 | - FlutterMacOS 11 | - screen_retriever (0.0.1): 12 | - FlutterMacOS 13 | - url_launcher_macos (0.0.1): 14 | - FlutterMacOS 15 | - window_manager (0.2.0): 16 | - FlutterMacOS 17 | 18 | DEPENDENCIES: 19 | - flutter_acrylic (from `Flutter/ephemeral/.symlinks/plugins/flutter_acrylic/macos`) 20 | - flutter_pty (from `Flutter/ephemeral/.symlinks/plugins/flutter_pty/macos`) 21 | - FlutterMacOS (from `Flutter/ephemeral`) 22 | - macos_ui (from `Flutter/ephemeral/.symlinks/plugins/macos_ui/macos`) 23 | - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) 24 | - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) 25 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) 26 | - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) 27 | 28 | EXTERNAL SOURCES: 29 | flutter_acrylic: 30 | :path: Flutter/ephemeral/.symlinks/plugins/flutter_acrylic/macos 31 | flutter_pty: 32 | :path: Flutter/ephemeral/.symlinks/plugins/flutter_pty/macos 33 | FlutterMacOS: 34 | :path: Flutter/ephemeral 35 | macos_ui: 36 | :path: Flutter/ephemeral/.symlinks/plugins/macos_ui/macos 37 | path_provider_macos: 38 | :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos 39 | screen_retriever: 40 | :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos 41 | url_launcher_macos: 42 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos 43 | window_manager: 44 | :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos 45 | 46 | SPEC CHECKSUMS: 47 | flutter_acrylic: c3df24ae52ab6597197837ce59ef2a8542640c17 48 | flutter_pty: 41b6f848ade294be726a6b94cdd4a67c3bc52f59 49 | FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811 50 | macos_ui: 125c911559d646194386d84c017ad6819122e2db 51 | path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19 52 | screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 53 | url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3 54 | window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 55 | 56 | PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c 57 | 58 | COCOAPODS: 1.11.3 59 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.dartssh.terminalstudio" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /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/src/ui/tabs/plugin_tab.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/scheduler.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:terminal_studio/src/core/plugin.dart'; 6 | import 'package:terminal_studio/src/core/state/host.dart'; 7 | 8 | class PluginTab extends TabItem { 9 | final Plugin plugin; 10 | 11 | final PluginManager manager; 12 | 13 | PluginTab(this.plugin, this.manager) { 14 | manager.add(plugin); 15 | 16 | _updateTitle(); 17 | 18 | plugin.title.addListener(_updateTitle); 19 | 20 | manager.addListener(_onPluginManagerChanged); 21 | 22 | content.value = PluginTabView( 23 | key: ValueKey(plugin), 24 | plugin, 25 | ); 26 | } 27 | 28 | @override 29 | void didDispose() { 30 | if (plugin.mounted) { 31 | manager.remove(plugin); 32 | } 33 | plugin.title.removeListener(_updateTitle); 34 | manager.removeListener(_onPluginManagerChanged); 35 | super.didDispose(); 36 | } 37 | 38 | void _updateTitle() { 39 | final titleWidget = plugin.title.value; 40 | title.value = Row( 41 | mainAxisSize: MainAxisSize.min, 42 | children: [ 43 | if (titleWidget != null) 44 | Flexible( 45 | child: Text( 46 | titleWidget, 47 | softWrap: false, 48 | ), 49 | ), 50 | if (titleWidget != null) const SizedBox(width: 4), 51 | Text( 52 | manager.hostSpec.name, 53 | style: const TextStyle( 54 | fontSize: 10, 55 | color: CupertinoColors.systemGrey, 56 | ), 57 | ), 58 | ], 59 | ); 60 | } 61 | 62 | void _onPluginManagerChanged() { 63 | if (!plugin.mounted) { 64 | detach(); 65 | } 66 | } 67 | } 68 | 69 | class PluginTabView extends ConsumerStatefulWidget { 70 | const PluginTabView(this.plugin, {super.key}); 71 | 72 | final Plugin plugin; 73 | 74 | @override 75 | ConsumerState createState() => _PluginTabViewState(); 76 | } 77 | 78 | class _PluginTabViewState extends ConsumerState { 79 | Plugin get plugin => widget.plugin; 80 | 81 | @override 82 | void initState() { 83 | SchedulerBinding.instance!.addPostFrameCallback((_) { 84 | ref.read(connectorProvider(plugin.hostSpec)).connect(); 85 | }); 86 | super.initState(); 87 | } 88 | 89 | @override 90 | Widget build(BuildContext context) { 91 | return plugin.build(context); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /lib/src/ui/tabs/settings_tab/settings_tab_hosts.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 4 | import 'package:terminal_studio/src/core/state/database.dart'; 5 | import 'package:terminal_studio/src/ui/pages/host_edit_page.dart'; 6 | 7 | class HostsSettingView extends ConsumerStatefulWidget { 8 | const HostsSettingView({Key? key}) : super(key: key); 9 | 10 | @override 11 | ConsumerState createState() => 12 | _HostsSettingViewState(); 13 | } 14 | 15 | class _HostsSettingViewState extends ConsumerState { 16 | @override 17 | Widget build(BuildContext context) { 18 | return ScaffoldPage.scrollable( 19 | header: PageHeader( 20 | title: const Text('Hosts'), 21 | commandBar: Expanded( 22 | child: _buildCommandBar(context), 23 | ), 24 | ), 25 | children: [ 26 | _buildSSHHosts(), 27 | ], 28 | ); 29 | } 30 | 31 | Widget _buildCommandBar(BuildContext context) { 32 | return CommandBar( 33 | mainAxisAlignment: MainAxisAlignment.end, 34 | primaryItems: [ 35 | CommandBarButton( 36 | icon: const Icon(FontAwesomeIcons.plus), 37 | label: const Text('Add'), 38 | onPressed: () { 39 | Navigator.of(context).push( 40 | FluentPageRoute( 41 | builder: (context) => const HostEditPage(), 42 | ), 43 | ); 44 | }, 45 | ), 46 | ], 47 | ); 48 | } 49 | 50 | Widget _buildSSHHosts() { 51 | final hosts = ref.watch(sshHostsProvider); 52 | 53 | return hosts.when( 54 | loading: () => const Center(child: ProgressRing()), 55 | error: (e, st) => Text('Error: $e'), 56 | data: (box) => ListView.builder( 57 | shrinkWrap: true, 58 | itemCount: box.length, 59 | itemBuilder: (context, index) { 60 | final record = box[index]; 61 | return ListTile( 62 | title: Text(record.name), 63 | subtitle: Text('${record.host}:${record.port}'), 64 | leading: const FaIcon(FontAwesomeIcons.computer), 65 | onPressed: () { 66 | Navigator.of(context).push( 67 | FluentPageRoute( 68 | builder: (context) => HostEditPage(record: record), 69 | ), 70 | ); 71 | }, 72 | ); 73 | }, 74 | ), 75 | ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [created] 7 | 8 | jobs: 9 | build_macos: 10 | runs-on: macos-latest 11 | steps: 12 | # Setup 13 | - uses: actions/checkout@v3 14 | 15 | - uses: subosito/flutter-action@v2 16 | with: 17 | channel: "stable" 18 | architecture: x64 19 | 20 | - uses: actions/setup-node@v2 21 | 22 | # Install packaging tools 23 | - name: Install flutter_distributor 24 | run: dart pub global activate flutter_distributor 25 | 26 | - name: Install appdmg 27 | run: npm install -g appdmg 28 | 29 | # Build and package 30 | - name: Packaging .dmg .zip 31 | run: flutter_distributor package --platform macos --targets dmg,zip --artifact-name "TerminalStudio-${{github.ref_name}}-macos.{{ext}}" 32 | 33 | # Publish 34 | - name: Publish to GitHub Release 35 | uses: softprops/action-gh-release@v1 36 | env: 37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 38 | with: 39 | files: dist/*/* 40 | 41 | build_windows: 42 | runs-on: windows-latest 43 | steps: 44 | # Setup 45 | - uses: actions/checkout@v3 46 | - uses: subosito/flutter-action@v2 47 | with: 48 | channel: "stable" 49 | architecture: x64 50 | 51 | # Install packaging tools 52 | - name: Install flutter_distributor 53 | run: dart pub global activate flutter_distributor 54 | 55 | # Build and package 56 | - name: Packaging .msix .zip 57 | run: flutter_distributor package --platform windows --targets msix,zip --artifact-name "TerminalStudio-${{github.ref_name}}-windows.{{ext}}" 58 | 59 | # Publish 60 | - name: Publish to GitHub Release 61 | uses: softprops/action-gh-release@v1 62 | env: 63 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 64 | with: 65 | files: dist/*/* 66 | 67 | build_linux: 68 | runs-on: ubuntu-latest 69 | steps: 70 | # Setup 71 | - uses: actions/checkout@v3 72 | - uses: subosito/flutter-action@v2 73 | with: 74 | channel: "stable" 75 | architecture: x64 76 | 77 | - run: | 78 | sudo apt-get update -y 79 | sudo apt-get install -y ninja-build libgtk-3-dev 80 | 81 | # Install packaging tools 82 | - name: Install flutter_distributor 83 | run: dart pub global activate flutter_distributor 84 | 85 | # Build and package 86 | - name: Packaging .deb .zip 87 | run: flutter_distributor package --platform linux --targets deb,zip --artifact-name "TerminalStudio-${{github.ref_name}}-linux.{{ext}}" 88 | 89 | # Publish 90 | - name: Publish to GitHub Release 91 | uses: softprops/action-gh-release@v1 92 | env: 93 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 94 | with: 95 | files: dist/*/* 96 | -------------------------------------------------------------------------------- /lib/src/ui/tabs/devtools_tab.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 4 | import 'package:macos_ui/macos_ui.dart'; 5 | import 'package:terminal_studio/src/core/state/database.dart'; 6 | import 'package:terminal_studio/src/ui/tabs/playground.dart'; 7 | import 'package:xterm/xterm.dart'; 8 | 9 | class DevToolsTab extends TabItem { 10 | DevToolsTab() { 11 | title.value = const Text('DevTools'); 12 | content.value = DevToolsTabView(this); 13 | } 14 | 15 | final terminal = Terminal(); 16 | } 17 | 18 | class DevToolsTabView extends ConsumerStatefulWidget { 19 | const DevToolsTabView(this.tab, {super.key}); 20 | 21 | final DevToolsTab tab; 22 | 23 | @override 24 | ConsumerState createState() => 25 | _DevToolsTabViewState(); 26 | } 27 | 28 | class _DevToolsTabViewState extends ConsumerState { 29 | DevToolsTab get tab => widget.tab; 30 | 31 | @override 32 | Widget build(BuildContext context) { 33 | return CupertinoPageScaffold( 34 | child: Container( 35 | constraints: const BoxConstraints.expand(), 36 | padding: const EdgeInsets.all(16), 37 | child: Column( 38 | crossAxisAlignment: CrossAxisAlignment.start, 39 | children: [ 40 | Wrap( 41 | spacing: 8, 42 | children: [ 43 | PushButton( 44 | buttonSize: ButtonSize.large, 45 | onPressed: _openAddHostTab, 46 | child: const Text('Add SSH host'), 47 | ), 48 | PushButton( 49 | buttonSize: ButtonSize.large, 50 | onPressed: _clearHosts, 51 | child: const Text('Clear SSH hosts'), 52 | ), 53 | PushButton( 54 | buttonSize: ButtonSize.large, 55 | onPressed: () => tab.replace(PlaygroundTab()), 56 | child: const Text('Playground'), 57 | ), 58 | ], 59 | ), 60 | 61 | const SizedBox(height: 16), 62 | Expanded( 63 | child: TerminalView(tab.terminal), 64 | ), 65 | // const PlayGround(), 66 | ], 67 | ), 68 | ), 69 | ); 70 | } 71 | 72 | void _openAddHostTab() { 73 | // ref.openTab(AddHostTab()); 74 | } 75 | 76 | void _clearHosts() async { 77 | final sshHosts = await ref.read(sshHostBoxProvider.future); 78 | await sshHosts.clear(); 79 | tab.terminal.write('Cleared SSH hosts\r\n'); 80 | } 81 | } 82 | 83 | class PlayGround extends ConsumerWidget { 84 | const PlayGround({Key? key}) : super(key: key); 85 | 86 | @override 87 | Widget build(BuildContext context, WidgetRef ref) { 88 | return Container( 89 | constraints: const BoxConstraints(maxWidth: 500), 90 | padding: const EdgeInsets.all(16), 91 | color: const Color.fromARGB(255, 251, 251, 251), 92 | // child: 93 | ); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "filename": "Icon-App-20x20@2x.png", 5 | "idiom": "iphone", 6 | "scale": "2x", 7 | "size": "20x20" 8 | }, 9 | { 10 | "filename": "Icon-App-20x20@3x.png", 11 | "idiom": "iphone", 12 | "scale": "3x", 13 | "size": "20x20" 14 | }, 15 | { 16 | "filename": "Icon-App-29x29@1x.png", 17 | "idiom": "iphone", 18 | "scale": "1x", 19 | "size": "29x29" 20 | }, 21 | { 22 | "filename": "Icon-App-29x29@2x.png", 23 | "idiom": "iphone", 24 | "scale": "2x", 25 | "size": "29x29" 26 | }, 27 | { 28 | "filename": "Icon-App-29x29@3x.png", 29 | "idiom": "iphone", 30 | "scale": "3x", 31 | "size": "29x29" 32 | }, 33 | { 34 | "filename": "Icon-App-40x40@2x.png", 35 | "idiom": "iphone", 36 | "scale": "2x", 37 | "size": "40x40" 38 | }, 39 | { 40 | "filename": "Icon-App-40x40@3x.png", 41 | "idiom": "iphone", 42 | "scale": "3x", 43 | "size": "40x40" 44 | }, 45 | { 46 | "filename": "Icon-App-60x60@2x.png", 47 | "idiom": "iphone", 48 | "scale": "2x", 49 | "size": "60x60" 50 | }, 51 | { 52 | "filename": "Icon-App-60x60@3x.png", 53 | "idiom": "iphone", 54 | "scale": "3x", 55 | "size": "60x60" 56 | }, 57 | { 58 | "filename": "Icon-App-20x20@1x.png", 59 | "idiom": "ipad", 60 | "scale": "1x", 61 | "size": "20x20" 62 | }, 63 | { 64 | "filename": "Icon-App-20x20@2x.png", 65 | "idiom": "ipad", 66 | "scale": "2x", 67 | "size": "20x20" 68 | }, 69 | { 70 | "filename": "Icon-App-29x29@1x.png", 71 | "idiom": "ipad", 72 | "scale": "1x", 73 | "size": "29x29" 74 | }, 75 | { 76 | "filename": "Icon-App-29x29@2x.png", 77 | "idiom": "ipad", 78 | "scale": "2x", 79 | "size": "29x29" 80 | }, 81 | { 82 | "filename": "Icon-App-40x40@1x.png", 83 | "idiom": "ipad", 84 | "scale": "1x", 85 | "size": "40x40" 86 | }, 87 | { 88 | "filename": "Icon-App-40x40@2x.png", 89 | "idiom": "ipad", 90 | "scale": "2x", 91 | "size": "40x40" 92 | }, 93 | { 94 | "filename": "Icon-App-76x76@1x.png", 95 | "idiom": "ipad", 96 | "scale": "1x", 97 | "size": "76x76" 98 | }, 99 | { 100 | "filename": "Icon-App-76x76@2x.png", 101 | "idiom": "ipad", 102 | "scale": "2x", 103 | "size": "76x76" 104 | }, 105 | { 106 | "filename": "Icon-App-83.5x83.5@2x.png", 107 | "idiom": "ipad", 108 | "scale": "2x", 109 | "size": "83.5x83.5" 110 | }, 111 | { 112 | "filename": "Icon-App-1024x1024@1x.png", 113 | "idiom": "ios-marketing", 114 | "scale": "1x", 115 | "size": "1024x1024" 116 | } 117 | ], 118 | "info": { 119 | "author": "icons_launcher", 120 | "version": 1 121 | } 122 | } -------------------------------------------------------------------------------- /lib/src/ui/context_menu.dart: -------------------------------------------------------------------------------- 1 | import 'package:context_menus/context_menus.dart'; 2 | import 'package:flex_tabs/flex_tabs.dart'; 3 | import 'package:fluent_ui/fluent_ui.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:terminal_studio/src/hosts/local_spec.dart'; 6 | import 'package:terminal_studio/src/core/service/tabs_service.dart'; 7 | import 'package:terminal_studio/src/core/state/database.dart'; 8 | import 'package:terminal_studio/src/ui/tabs/add_host_tab.dart'; 9 | import 'package:terminal_studio/src/ui/tabs/settings_tab/settings_tab.dart'; 10 | import 'package:terminal_studio/src/util/tabs_extension.dart'; 11 | 12 | class DropdownContextMenu extends ConsumerStatefulWidget { 13 | const DropdownContextMenu(this.tabs, {super.key}); 14 | 15 | final Tabs tabs; 16 | 17 | @override 18 | DropdownContextMenuState createState() => DropdownContextMenuState(); 19 | } 20 | 21 | class DropdownContextMenuState extends ConsumerState 22 | with ContextMenuStateMixin { 23 | Tabs get tabs => widget.tabs; 24 | 25 | @override 26 | Widget build(BuildContext context) { 27 | return cardBuilder( 28 | context, 29 | [ 30 | buttonBuilder( 31 | context, 32 | ContextMenuButtonConfig( 33 | 'Local', 34 | icon: const Icon(FluentIcons.tablet), 35 | onPressed: () => handlePressed(context, () { 36 | final tabsService = ref.read(tabsServiceProvider); 37 | tabsService.openTerminal(LocalHostSpec()); 38 | }), 39 | ), 40 | ), 41 | ...buildHosts(), 42 | buttonBuilder( 43 | context, 44 | ContextMenuButtonConfig( 45 | 'Add New', 46 | icon: const Icon(FluentIcons.add), 47 | onPressed: () => handlePressed( 48 | context, 49 | () => ref.openTab(AddHostTab()), 50 | ), 51 | ), 52 | ), 53 | buildDivider(), 54 | buttonBuilder( 55 | context, 56 | ContextMenuButtonConfig( 57 | 'Settings', 58 | icon: const Icon(FluentIcons.settings), 59 | onPressed: () => handlePressed( 60 | context, 61 | () => ref.openTab(SettingsTab()), 62 | ), 63 | ), 64 | ), 65 | ], 66 | ); 67 | } 68 | 69 | List buildHosts() { 70 | final sshHosts = ref.watch(sshHostBoxProvider).asData; 71 | 72 | if (sshHosts == null || sshHosts.value.isEmpty) { 73 | return []; 74 | } 75 | 76 | final items = []; 77 | 78 | for (final host in sshHosts.value.values) { 79 | items.add( 80 | buttonBuilder( 81 | context, 82 | ContextMenuButtonConfig( 83 | host.name, 84 | icon: const Icon(FluentIcons.cloud), 85 | onPressed: () => handlePressed(context, () async { 86 | final tabsService = ref.read(tabsServiceProvider); 87 | tabsService.openTerminal(host, tabs: tabs); 88 | }), 89 | ), 90 | ), 91 | ); 92 | } 93 | 94 | return items; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/hosts/local_host.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | import 'dart:typed_data'; 4 | 5 | import 'package:flutter_pty/flutter_pty.dart'; 6 | import 'package:terminal_studio/src/core/fs.dart'; 7 | import 'package:terminal_studio/src/core/host.dart'; 8 | import 'package:terminal_studio/src/hosts/local_fs.dart'; 9 | 10 | class LocalHost implements Host { 11 | @override 12 | Future execute( 13 | String executable, { 14 | List args = const [], 15 | bool root = false, 16 | Map? environment, 17 | }) async { 18 | final result = 19 | await Process.run(executable, args, environment: environment); 20 | return LocalExecutionResult(result); 21 | } 22 | 23 | @override 24 | Future connectFileSystem() async { 25 | return LocalFileSystem(); 26 | } 27 | 28 | @override 29 | Future shell({ 30 | int width = 80, 31 | int height = 25, 32 | Map? environment, 33 | }) async { 34 | final shell = _platformShell; 35 | final pty = Pty.start( 36 | shell.command, 37 | arguments: shell.args, 38 | environment: {...Platform.environment, ...environment ?? {}}, 39 | rows: height, 40 | columns: width, 41 | ); 42 | return LocalExecutionSession(pty); 43 | } 44 | 45 | final _doneCompleter = Completer(); 46 | 47 | @override 48 | Future disconnect() async { 49 | _doneCompleter.complete(); 50 | } 51 | 52 | @override 53 | Future get done => _doneCompleter.future; 54 | } 55 | 56 | class LocalExecutionResult implements ExecutionResult { 57 | final ProcessResult _result; 58 | 59 | LocalExecutionResult(this._result); 60 | 61 | @override 62 | int get exitCode => _result.exitCode; 63 | 64 | @override 65 | String get stderr => _result.stderr; 66 | 67 | @override 68 | String get stdout => _result.stdout; 69 | } 70 | 71 | class LocalExecutionSession implements ExecutionSession { 72 | final Pty _pty; 73 | 74 | LocalExecutionSession(this._pty); 75 | 76 | @override 77 | Future get exitCode => _pty.exitCode; 78 | 79 | @override 80 | Stream get output => _pty.output; 81 | 82 | @override 83 | Future close() async { 84 | _pty.kill(); 85 | } 86 | 87 | @override 88 | Future resize(int width, int height) async { 89 | _pty.resize(height, width); 90 | } 91 | 92 | @override 93 | Future write(Uint8List data) async { 94 | _pty.write(data); 95 | } 96 | } 97 | 98 | class _ShellCommand { 99 | final String command; 100 | 101 | final List args; 102 | 103 | _ShellCommand(this.command, this.args); 104 | } 105 | 106 | _ShellCommand get _platformShell { 107 | if (Platform.isMacOS) { 108 | final user = Platform.environment['USER']; 109 | return _ShellCommand('login', ['-fp', user!]); 110 | } 111 | 112 | if (Platform.isWindows) { 113 | return _ShellCommand('powershell.exe', []); 114 | } 115 | 116 | final shell = Platform.environment['SHELL'] ?? 'sh'; 117 | return _ShellCommand(shell, []); 118 | } 119 | -------------------------------------------------------------------------------- /lib/src/hosts/ssh_host.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:dartssh2/dartssh2.dart'; 4 | import 'package:terminal_studio/src/core/fs.dart'; 5 | import 'package:terminal_studio/src/core/host.dart'; 6 | import 'package:terminal_studio/src/hosts/ssh_fs.dart'; 7 | 8 | class SSHHost implements Host { 9 | SSHHost(this.client); 10 | 11 | final SSHClient client; 12 | 13 | @override 14 | Future execute( 15 | String executable, { 16 | List args = const [], 17 | bool root = false, 18 | Map? environment, 19 | }) async { 20 | final command = [executable, ...args].join(' '); 21 | final result = await client.execute(command, environment: environment); 22 | return _collectResult(result); 23 | } 24 | 25 | @override 26 | Future connectFileSystem() async { 27 | final sftp = await client.sftp(); 28 | final currentDirectory = await sftp.absolute('.'); 29 | return SSHFileSystem(sftp, currentDirectory); 30 | } 31 | 32 | @override 33 | Future shell({ 34 | int width = 80, 35 | int height = 25, 36 | Map? environment, 37 | }) async { 38 | final session = await client.shell( 39 | environment: environment, 40 | pty: SSHPtyConfig( 41 | height: height, 42 | width: width, 43 | ), 44 | ); 45 | return _SSHExecutionSession(session); 46 | } 47 | 48 | @override 49 | Future disconnect() async { 50 | client.close(); 51 | } 52 | 53 | @override 54 | Future get done => client.done; 55 | } 56 | 57 | Future<_SSHExecutionResult> _collectResult(SSHSession session) async { 58 | final stdout = StringBuffer(); 59 | final stderr = StringBuffer(); 60 | 61 | final stdoutStream = session.stdout.listen( 62 | (data) => stdout.write(String.fromCharCodes(data)), 63 | ); 64 | 65 | final stderrStream = session.stderr.listen( 66 | (data) => stderr.write(String.fromCharCodes(data)), 67 | ); 68 | 69 | await session.done; 70 | await stdoutStream.asFuture(); 71 | await stderrStream.asFuture(); 72 | 73 | return _SSHExecutionResult( 74 | exitCode: session.exitCode ?? 0, 75 | stdout: stdout.toString(), 76 | stderr: stderr.toString(), 77 | ); 78 | } 79 | 80 | class _SSHExecutionResult implements ExecutionResult { 81 | _SSHExecutionResult({ 82 | required this.exitCode, 83 | required this.stdout, 84 | required this.stderr, 85 | }); 86 | 87 | @override 88 | final int exitCode; 89 | 90 | @override 91 | final String stderr; 92 | 93 | @override 94 | final String stdout; 95 | } 96 | 97 | class _SSHExecutionSession implements ExecutionSession { 98 | _SSHExecutionSession(this.session); 99 | 100 | final SSHSession session; 101 | 102 | @override 103 | Future close() async { 104 | session.close(); 105 | } 106 | 107 | @override 108 | Future resize(int width, int height) async { 109 | session.resizeTerminal(width, height); 110 | } 111 | 112 | @override 113 | Stream get output => session.stdout; 114 | 115 | @override 116 | Future write(Uint8List data) async { 117 | session.stdin.add(data); 118 | } 119 | 120 | @override 121 | Future get exitCode async { 122 | await session.done; 123 | return session.exitCode ?? 0; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /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 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 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", "studio" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "studio" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "studio.exe" "\0" 98 | VALUE "ProductName", "studio" "\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 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /lib/src/ui/tabs/code_editor_tab.dart: -------------------------------------------------------------------------------- 1 | // Import the language & theme 2 | import 'package:fluent_ui/fluent_ui.dart'; 3 | import 'package:flutter_highlight/themes/github.dart'; 4 | import 'package:highlight/highlight.dart'; 5 | import 'package:code_text_field/code_text_field.dart'; 6 | import 'package:flex_tabs/flex_tabs.dart'; 7 | import 'package:highlight/languages/all.dart'; 8 | import 'package:terminal_studio/src/core/fs.dart'; 9 | 10 | class CodeEditorTab extends TabItem { 11 | final File file; 12 | 13 | CodeEditorTab(this.file) { 14 | title.value = Text(file.basename); 15 | content.value = CodeEditorView(this); 16 | loadContent(); 17 | } 18 | 19 | final codeController = ValueNotifier(null); 20 | 21 | Future loadContent() async { 22 | final content = await file.readAsString(); 23 | codeController.value = CodeController( 24 | text: content, 25 | language: _detectLanguage(content), 26 | theme: githubTheme, 27 | ); 28 | } 29 | } 30 | 31 | class CodeEditorView extends StatelessWidget { 32 | const CodeEditorView(this.tab, {super.key}); 33 | 34 | final CodeEditorTab tab; 35 | 36 | static const fontFamily = 'SourceCode'; 37 | 38 | static const fontFamilyFallback = [ 39 | 'Menlo', // macos 40 | 'Consolas', // windows 41 | 'monospace', 42 | ]; 43 | 44 | @override 45 | Widget build(BuildContext context) { 46 | return NavigationView( 47 | content: Column( 48 | children: [ 49 | _buildToolbar(), 50 | const Divider(), 51 | Expanded(child: _buildEditor()), 52 | ], 53 | ), 54 | ); 55 | } 56 | 57 | Widget _buildToolbar() { 58 | return Padding( 59 | padding: const EdgeInsets.all(8), 60 | child: CommandBar( 61 | mainAxisAlignment: MainAxisAlignment.end, 62 | primaryItems: [ 63 | // CommandBarButton( 64 | // icon: const Icon(FluentIcons.back), 65 | // label: const Text('Back'), 66 | // onPressed: () {}, 67 | // ), 68 | CommandBarButton( 69 | icon: const Icon(FluentIcons.save), 70 | label: const Text('Save'), 71 | onPressed: () async { 72 | final controller = tab.codeController.value; 73 | if (controller == null) return; 74 | await tab.file.writeAsString(controller.value.text); 75 | }, 76 | ), 77 | ], 78 | ), 79 | ); 80 | } 81 | 82 | Widget _buildEditor() { 83 | return ValueListenableBuilder( 84 | valueListenable: tab.codeController, 85 | builder: (context, codeController, child) { 86 | if (codeController == null) { 87 | return const Center( 88 | child: ProgressRing(), 89 | ); 90 | } 91 | 92 | return SingleChildScrollView( 93 | child: CodeField( 94 | controller: codeController, 95 | lineNumberStyle: const LineNumberStyle( 96 | textStyle: TextStyle( 97 | fontFamily: fontFamily, 98 | fontFamilyFallback: fontFamilyFallback, 99 | ), 100 | ), 101 | textStyle: const TextStyle( 102 | fontFamily: fontFamily, 103 | fontSize: 12, 104 | fontFamilyFallback: fontFamilyFallback, 105 | ), 106 | ), 107 | ); 108 | }, 109 | ); 110 | } 111 | } 112 | 113 | Mode _detectLanguage(String source) { 114 | final result = highlight.parse(source, autoDetection: true); 115 | return allLanguages[result.language]!; 116 | } 117 | -------------------------------------------------------------------------------- /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 and shows a win32 window with |title| and position and size 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 to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /lib/src/plugins/terminal/terminal_plugin.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:context_menus/context_menus.dart'; 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:flutter/material.dart' show Colors; 6 | import 'package:flutter/scheduler.dart'; 7 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 8 | import 'package:terminal_studio/src/core/conn.dart'; 9 | import 'package:terminal_studio/src/core/host.dart'; 10 | import 'package:terminal_studio/src/core/plugin.dart'; 11 | import 'package:terminal_studio/src/plugins/terminal/terminal_menu.dart'; 12 | import 'package:xterm/xterm.dart'; 13 | 14 | class TerminalPlugin extends Plugin { 15 | final terminal = Terminal(maxLines: 10000); 16 | 17 | final terminalController = TerminalController(); 18 | 19 | var terminalTitle = ''; 20 | 21 | ExecutionSession? session; 22 | 23 | void _updateTitle() { 24 | if (session != null) { 25 | title.value = 26 | '$terminalTitle — ${terminal.viewWidth}x${terminal.viewHeight}'; 27 | } 28 | } 29 | 30 | @override 31 | void didMounted() { 32 | title.value = 'Connecting'; 33 | 34 | terminal.onTitleChange = (title) { 35 | terminalTitle = title; 36 | _updateTitle(); 37 | }; 38 | 39 | terminal.onOutput = (data) { 40 | session?.write(const Utf8Encoder().convert(data)); 41 | }; 42 | 43 | terminal.onResize = (w, h, pw, ph) { 44 | session?.resize(w, h); 45 | SchedulerBinding.instance.addPostFrameCallback((_) { 46 | _updateTitle(); 47 | }); 48 | }; 49 | 50 | super.didMounted(); 51 | } 52 | 53 | @override 54 | void didConnected() async { 55 | title.value = 'Terminal'; 56 | 57 | session = await host.shell( 58 | width: terminal.viewWidth, 59 | height: terminal.viewHeight, 60 | ); 61 | 62 | session!.output 63 | .cast>() 64 | .transform(const Utf8Decoder()) 65 | .listen(terminal.write); 66 | 67 | session!.exitCode.then((code) { 68 | session = null; 69 | if (mounted) { 70 | manager.remove(this); 71 | } 72 | }); 73 | } 74 | 75 | @override 76 | void didDisconnected() { 77 | session = null; 78 | title.value = 'Disconnected'; 79 | } 80 | 81 | @override 82 | void onConnectionStatus(HostConnectorStatus status) { 83 | switch (status) { 84 | case HostConnectorStatus.connecting: 85 | title.value = 'Connecting'; 86 | break; 87 | case HostConnectorStatus.connected: 88 | title.value = 'Terminal'; 89 | break; 90 | case HostConnectorStatus.disconnected: 91 | title.value = 'Disconnected'; 92 | break; 93 | default: 94 | } 95 | } 96 | 97 | @override 98 | Widget build(BuildContext context) { 99 | return TerminalTabView(this); 100 | } 101 | } 102 | 103 | class TerminalTabView extends ConsumerStatefulWidget { 104 | const TerminalTabView(this.plugin, {super.key}); 105 | 106 | final TerminalPlugin plugin; 107 | 108 | @override 109 | ConsumerState createState() => 110 | _TerminalTabViewState(); 111 | } 112 | 113 | class _TerminalTabViewState extends ConsumerState { 114 | @override 115 | Widget build(BuildContext context) { 116 | return CupertinoPageScaffold( 117 | key: ValueKey(widget.plugin), 118 | backgroundColor: Colors.transparent, 119 | child: SafeArea( 120 | child: ClipRect( 121 | child: TerminalView( 122 | widget.plugin.terminal, 123 | controller: widget.plugin.terminalController, 124 | onSecondaryTapDown: (_, __) => showMenu(), 125 | backgroundOpacity: 0.8, 126 | autofocus: true, 127 | ), 128 | ), 129 | ), 130 | ); 131 | } 132 | 133 | void showMenu() { 134 | final menu = TerminalContextMenu(plugin: widget.plugin); 135 | context.contextMenuOverlay.show(menu); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /linux/packaging/deb/make_config.yaml: -------------------------------------------------------------------------------- 1 | # the name used to display in the OS. Specifically desktop 2 | # entry name 3 | display_name: TerminalStudio 4 | 5 | # package name for debian/apt repository 6 | # the name should be all lowercase with -+. 7 | package_name: terminalstudio 8 | 9 | maintainer: 10 | name: xuty 11 | email: xty50337@hotmail.com 12 | 13 | co_authors: 14 | - name: Michael Lamers 15 | email: info@devmil.de 16 | 17 | # enum options -> required, important, standard, optional, extra 18 | # refer: https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities 19 | priority: optional 20 | 21 | # enum options: admin, cli-mono, comm, database, debug, devel, doc, editors, education, electronics, embedded, fonts, games, gnome, gnu-r, gnustep, graphics, hamradio, haskell, httpd, interpreters, introspection, java, javascript, kde, kernel, libdevel, libs, lisp, localization, mail, math, metapackages, misc, net, news, ocaml, oldlibs, otherosfs, perl, php, python, ruby, rust, science, shells, sound, tasks, tex, text, utils, vcs, video, web, x11, xfce, zope 22 | # refer: https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections 23 | section: x11 24 | 25 | # the size of binary in kilobyte 26 | installed_size: 24400 27 | 28 | # direct dependencies required by the application 29 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html 30 | # dependencies: 31 | # - libkeybinder-3.0-0 (>= 0.3.2) 32 | 33 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html 34 | # build_dependencies_indep: 35 | # - texinfo 36 | 37 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html 38 | # build_dependencies: 39 | # - kernel-headers-2.2.10 [!hurd-i386] 40 | # - gnumach-dev [hurd-i386] 41 | # - libluajit5.1-dev [i386 amd64 kfreebsd-i386 armel armhf powerpc mips] 42 | 43 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html 44 | # recommended_dependencies: 45 | # - neofetch 46 | 47 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html 48 | # suggested_dependencies: 49 | # - libkeybinder-3.0-0 (>= 0.3.2) 50 | 51 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html 52 | # enhances: 53 | # - spotube 54 | 55 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html 56 | # pre_dependencies: 57 | # - libc6 58 | 59 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html#packages-which-break-other-packages-breaks 60 | # breaks: 61 | # - libspotify (<< 3.0.0) 62 | 63 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html#conflicting-binary-packages-conflicts 64 | # conflicts: 65 | # - spotify 66 | 67 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html#virtual-packages-provides 68 | # provides: 69 | # - libx11 70 | 71 | # refer: https://www.debian.org/doc/debian-policy/ch-relationships.html#overwriting-files-and-replacing-packages-replaces 72 | # replaces: 73 | # - spotify 74 | 75 | essential: false 76 | 77 | # postinstall_scripts: 78 | # - echo `Installed my awesome app` 79 | 80 | # postuninstall_scripts: 81 | # - echo `Surprised Pickachu face` 82 | # application icon path relative to project url 83 | icon: assets/icon.png 84 | 85 | keywords: 86 | - Terminal 87 | - Shell 88 | - SSH 89 | 90 | # a name to categorize the app into a section of application 91 | # generic_name: Hobby Application 92 | 93 | # supported mime types that can be opened using this application 94 | # supported_mime_type: 95 | # - audio/mpeg 96 | 97 | # shown when right clicked the desktop entry icons 98 | # actions: 99 | # - Gallery 100 | # - Create 101 | 102 | # the categories the application belong to 103 | # refer: https://specifications.freedesktop.org/menu-spec/latest/ 104 | # categories: 105 | # - Music 106 | # - Media 107 | 108 | # let OS know if the application can be run on start_up. If it's false 109 | # the application will deny to the OS if it was added as a start_up 110 | # application 111 | startup_notify: true 112 | -------------------------------------------------------------------------------- /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 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "studio"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "studio"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(studio 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 "studio") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 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 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: terminal_studio 2 | description: The Flutter based terminal emulator and more! 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: "none" # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 0.0.1 19 | 20 | environment: 21 | sdk: ">=2.18.0 <3.0.0" 22 | 23 | # Dependencies specify other packages that your package needs in order to work. 24 | # To automatically upgrade your package dependencies to the latest versions 25 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 26 | # dependencies can be manually updated by changing the version numbers below to 27 | # the latest version available on pub.dev. To see which dependencies have newer 28 | # versions available, run `flutter pub outdated`. 29 | dependencies: 30 | flutter: 31 | sdk: flutter 32 | 33 | # The following adds the Cupertino Icons font to your application. 34 | # Use with the CupertinoIcons class for iOS style icons. 35 | cupertino_icons: ^1.0.2 36 | 37 | dartssh2: ^2.7.2+3 38 | 39 | # xterm: ^3.2.7 40 | xterm: 41 | git: https://github.com/TerminalStudio/xterm.dart.git 42 | 43 | flutter_riverpod: ^2.0.0 44 | 45 | flutter_pty: ^0.3.1 46 | 47 | window_manager: ^0.2.7 48 | 49 | flutter_acrylic: ^1.0.0+2 50 | 51 | context_menus: ^1.0.2 52 | 53 | flex_tabs: ^0.2.0-pre 54 | 55 | file: ^6.1.4 56 | 57 | path: ^1.8.2 58 | 59 | hive_flutter: ^1.1.0 60 | 61 | uuid: ^3.0.6 62 | 63 | macos_ui: ^1.7.5 64 | 65 | syncfusion_flutter_datagrid: ^20.3.47 66 | 67 | code_text_field: ^1.0.2 68 | 69 | highlight: ^0.7.0 70 | 71 | flutter_highlight: ^0.7.0 72 | 73 | fluent_ui: ^4.0.1 74 | 75 | font_awesome_flutter: ^10.2.1 76 | 77 | collection: ^1.16.0 78 | 79 | dev_dependencies: 80 | flutter_test: 81 | sdk: flutter 82 | 83 | # The "flutter_lints" package below contains a set of recommended lints to 84 | # encourage good coding practices. The lint set provided by the package is 85 | # activated in the `analysis_options.yaml` file located at the root of your 86 | # package. See that file for information about deactivating specific lint 87 | # rules and activating additional ones. 88 | flutter_lints: ^2.0.0 89 | 90 | hive_generator: ^1.1.3 91 | 92 | build_runner: ^2.2.1 93 | 94 | icons_launcher: ^2.0.5 95 | 96 | msix: ^3.6.6 97 | 98 | # For information on the generic Dart part of this file, see the 99 | # following page: https://dart.dev/tools/pub/pubspec 100 | 101 | # The following section is specific to Flutter packages. 102 | flutter: 103 | # The following line ensures that the Material Icons font is 104 | # included with your application, so that you can use the icons in 105 | # the material Icons class. 106 | uses-material-design: true 107 | 108 | # To add assets to your application, add an assets section, like this: 109 | # assets: 110 | # - images/a_dot_burr.jpeg 111 | # - images/a_dot_ham.jpeg 112 | 113 | # An image asset can refer to one or more resolution-specific "variants", see 114 | # https://flutter.dev/assets-and-images/#resolution-aware 115 | 116 | # For details regarding adding assets from package dependencies, see 117 | # https://flutter.dev/assets-and-images/#from-packages 118 | 119 | # To add custom fonts to your application, add a fonts section here, 120 | # in this "flutter" section. Each entry in this list should have a 121 | # "family" key with the font family name, and a "fonts" key with a 122 | # list giving the asset and other descriptors for the font. For 123 | # example: 124 | # fonts: 125 | # - family: Schyler 126 | # fonts: 127 | # - asset: fonts/Schyler-Regular.ttf 128 | # - asset: fonts/Schyler-Italic.ttf 129 | # style: italic 130 | # - family: Trajan Pro 131 | # fonts: 132 | # - asset: fonts/TrajanPro.ttf 133 | # - asset: fonts/TrajanPro_Bold.ttf 134 | # weight: 700 135 | # 136 | # For details regarding fonts from package dependencies, 137 | # see https://flutter.dev/custom-fonts/#from-packages 138 | -------------------------------------------------------------------------------- /lib/src/core/plugin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:terminal_studio/src/core/conn.dart'; 3 | import 'package:terminal_studio/src/core/host.dart'; 4 | 5 | abstract class Plugin { 6 | PluginManager? _manager; 7 | 8 | /// The plugin manager that manages the lifecycle of this plugin. 9 | PluginManager get manager { 10 | if (_manager == null) { 11 | throw StateError('Plugin is not attached to a manager'); 12 | } 13 | 14 | return _manager!; 15 | } 16 | 17 | HostSpec? _hostSpec; 18 | 19 | /// The interface through which the plugin can read information about the host. 20 | /// This is available after [didMounted] is called. 21 | HostSpec get hostSpec { 22 | if (_hostSpec == null) { 23 | throw Exception('Plugin has not been mounted'); 24 | } 25 | return _hostSpec!; 26 | } 27 | 28 | Host? _host; 29 | 30 | /// The interface through which the plugin can interact with the host. Access 31 | /// to this property will throw an exception if the host has not been connected. 32 | Host get host { 33 | if (_host == null) { 34 | throw Exception('Plugin has not been connected to a host.'); 35 | } 36 | return _host!; 37 | } 38 | 39 | /// Whether the plugin is currently mounted. 40 | bool get mounted => _manager != null; 41 | 42 | /// Whether the plugin is connected to a host. 43 | bool get connected => _host != null; 44 | 45 | /// The title of the plugin. Usually displayed as the tab title. 46 | final title = ValueNotifier(null); 47 | 48 | /// Called when the plugin is mounted to a host. After this method is called, 49 | /// the [hostSpec] property will be available. 50 | void didMounted() {} 51 | 52 | /// Called when the plugin is unmounted from a host. After this method is 53 | /// called, the [hostSpec] property will no longer be available. 54 | void didUnmounted() {} 55 | 56 | /// Called when the host that this plugin is mounted to is connected. This 57 | /// method may be called multiple times if the host is disconnected and 58 | /// reconnected. 59 | void didConnected() {} 60 | 61 | /// Called when the host that this plugin is mounted to is disconnected. This 62 | /// method may be called multiple times if the host is disconnected and 63 | /// reconnected. 64 | void didDisconnected() {} 65 | 66 | /// Called when the state of the host that this plugin is mounted to changes. 67 | void onConnectionStatus(HostConnectorStatus status) {} 68 | 69 | // void onConnectionMessage(String message) {} 70 | 71 | // void onConnectionError(Object error, StackTrace stackTrace) {} 72 | 73 | /// Builds the UI for this plugin. This may be called multiple times during 74 | /// the lifetime of the plugin, for example when the plugin is moved to a new 75 | /// tab group. 76 | Widget build(BuildContext context); 77 | } 78 | 79 | class PluginManager with ChangeNotifier { 80 | final HostSpec hostSpec; 81 | 82 | PluginManager(this.hostSpec); 83 | 84 | final _plugins = []; 85 | 86 | List get plugins => List.unmodifiable(_plugins); 87 | 88 | Host? _host; 89 | 90 | void add(Plugin plugin) { 91 | if (plugin._manager != null) { 92 | throw Exception('Plugin is already mounted'); 93 | } 94 | _plugins.add(plugin); 95 | 96 | plugin._manager = this; 97 | plugin._hostSpec = hostSpec; 98 | plugin.didMounted(); 99 | 100 | if (_host != null) { 101 | plugin._host = _host; 102 | plugin.didConnected(); 103 | } 104 | 105 | notifyListeners(); 106 | } 107 | 108 | void remove(Plugin plugin) { 109 | if (plugin._manager != this) { 110 | throw Exception('Plugin is not mounted'); 111 | } 112 | _plugins.remove(plugin); 113 | 114 | plugin.didUnmounted(); 115 | plugin._manager = null; 116 | plugin._hostSpec = null; 117 | plugin._host = null; 118 | 119 | notifyListeners(); 120 | } 121 | 122 | void didConnected(Host host) { 123 | if (_host != null) { 124 | throw Exception('plugin manager is already connected to $_host'); 125 | } 126 | 127 | _host = host; 128 | 129 | for (final plugin in _plugins) { 130 | plugin._host = host; 131 | plugin.didConnected(); 132 | } 133 | } 134 | 135 | void didDisconnected() { 136 | if (_host == null) { 137 | throw Exception('plugin manager is not connected'); 138 | } 139 | 140 | _host = null; 141 | 142 | for (final plugin in _plugins) { 143 | plugin._host = null; 144 | plugin.didDisconnected(); 145 | } 146 | } 147 | 148 | void didConnectionStatusChanged(HostConnectorStatus status) { 149 | for (final plugin in _plugins) { 150 | plugin.onConnectionStatus(status); 151 | } 152 | } 153 | 154 | // void didConnectionMessageChanged(String message) { 155 | // for (final plugin in _plugins) { 156 | // plugin.onConnectionMessage(message); 157 | // } 158 | // } 159 | 160 | // void didConnectionError(Object error, StackTrace stackTrace) { 161 | // for (final plugin in _plugins) { 162 | // plugin.onConnectionError(error, stackTrace); 163 | // } 164 | // } 165 | } 166 | -------------------------------------------------------------------------------- /lib/src/ui/tabs/add_host_tab.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_tabs/flex_tabs.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 4 | import 'package:terminal_studio/src/ui/pages/host_edit_page.dart'; 5 | 6 | class AddHostTab extends TabItem { 7 | AddHostTab() { 8 | title.value = const Text('Connect'); 9 | content.value = const AddHostTabView(); 10 | } 11 | } 12 | 13 | class AddHostTabView extends ConsumerStatefulWidget { 14 | const AddHostTabView({super.key}); 15 | 16 | @override 17 | ConsumerState createState() => _AddHostTabViewState(); 18 | } 19 | 20 | class _AddHostTabViewState extends ConsumerState { 21 | @override 22 | Widget build(BuildContext context) { 23 | return const HostEditPage(); 24 | // return Container( 25 | // constraints: const BoxConstraints.expand(), 26 | // color: const Color.fromARGB(255, 245, 245, 245), 27 | // alignment: Alignment.center, 28 | // child: Container( 29 | // constraints: const BoxConstraints.tightFor(width: 550), 30 | // child: const AddHostForm(), 31 | // ), 32 | // ); 33 | } 34 | } 35 | 36 | // class AddHostForm extends ConsumerStatefulWidget { 37 | // const AddHostForm({Key? key}) : super(key: key); 38 | 39 | // @override 40 | // ConsumerState createState() => _AddHostFormState(); 41 | // } 42 | 43 | // class _AddHostFormState extends ConsumerState { 44 | // final formLabel = TextEditingController(); 45 | // final formHost = TextEditingController(); 46 | // final formPort = TextEditingController(); 47 | // final formUsername = TextEditingController(); 48 | // final formPassword = TextEditingController(); 49 | 50 | // @override 51 | // Widget build(BuildContext context) { 52 | // return ListView( 53 | // padding: const EdgeInsets.all(32), 54 | // children: [ 55 | // MacosFormRow( 56 | // label: const Text('Protocol'), 57 | // child: Container( 58 | // constraints: const BoxConstraints.tightFor(width: 200), 59 | // alignment: Alignment.centerLeft, 60 | // child: const MacosPulldownButton( 61 | // title: 'SSH', 62 | // items: [ 63 | // MacosPulldownMenuItem(title: Text('SSH')), 64 | // ], 65 | // ), 66 | // ), 67 | // ), 68 | // MacosTextFormRow( 69 | // label: const Text('Label:'), 70 | // placeholder: 'Optional', 71 | // controller: formLabel, 72 | // ), 73 | // MacosTextFormRow( 74 | // label: const Text('Host:'), 75 | // placeholder: 'example.com / 1.2.3.4', 76 | // controller: formHost, 77 | // ), 78 | // MacosTextFormRow( 79 | // label: const Text('Port:'), 80 | // placeholder: '22', 81 | // controller: formPort, 82 | // ), 83 | // MacosTextFormRow( 84 | // label: const Text('User:'), 85 | // placeholder: 'root', 86 | // controller: formUsername, 87 | // ), 88 | // MacosTextFormRow( 89 | // label: const Text('Password:'), 90 | // obscureText: true, 91 | // placeholder: '', 92 | // controller: formPassword, 93 | // ), 94 | // const SizedBox(height: 8), 95 | // MacosFormRow( 96 | // child: Row( 97 | // mainAxisAlignment: MainAxisAlignment.end, 98 | // children: [ 99 | // PushButton( 100 | // buttonSize: ButtonSize.small, 101 | // onPressed: submit, 102 | // child: const Text('Connect'), 103 | // ) 104 | // ], 105 | // ), 106 | // ), 107 | // ], 108 | // ); 109 | // } 110 | 111 | // Future submit() async { 112 | // final sshHosts = await ref.read(sshHostBoxProvider.future); 113 | // await sshHosts.add( 114 | // SSHHostRecord( 115 | // name: formLabel.text, 116 | // host: formHost.text, 117 | // port: int.parse(formPort.text), 118 | // username: formUsername.text, 119 | // password: formPassword.text, 120 | // ), 121 | // ); 122 | 123 | // await alert('Success', 'Host added successfully'); 124 | 125 | // closeTab(); 126 | // } 127 | 128 | // Future alert(String title, String message) async { 129 | // await showMacosAlertDialog( 130 | // context: context, 131 | // builder: (context) { 132 | // return MacosAlertDialog( 133 | // appIcon: const FlutterLogo(), 134 | // title: Text(title), 135 | // message: Text(message), 136 | // primaryButton: PushButton( 137 | // buttonSize: ButtonSize.small, 138 | // onPressed: () { 139 | // Navigator.of(context).pop(); 140 | // }, 141 | // child: const Text('OK'), 142 | // ), 143 | // ); 144 | // }, 145 | // ); 146 | // } 147 | 148 | // void closeTab() { 149 | // TabScope.of(context)?.dispose(); 150 | // } 151 | // } 152 | -------------------------------------------------------------------------------- /lib/src/plugins/terminal/terminal_menu.dart: -------------------------------------------------------------------------------- 1 | import 'package:context_menus/context_menus.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:terminal_studio/src/core/service/tabs_service.dart'; 6 | import 'package:terminal_studio/src/plugins/file_manager/file_manager_plugin.dart'; 7 | import 'package:terminal_studio/src/plugins/starter/starter_plugin.dart'; 8 | import 'package:terminal_studio/src/plugins/terminal/terminal_plugin.dart'; 9 | import 'package:xterm/xterm.dart'; 10 | 11 | class TerminalContextMenu extends ConsumerStatefulWidget { 12 | const TerminalContextMenu({ 13 | super.key, 14 | required this.plugin, 15 | }); 16 | 17 | final TerminalPlugin plugin; 18 | 19 | @override 20 | TerminalContextMenuState createState() => TerminalContextMenuState(); 21 | } 22 | 23 | class TerminalContextMenuState extends ConsumerState 24 | with ContextMenuStateMixin { 25 | TerminalPlugin get plugin => widget.plugin; 26 | 27 | Terminal get terminal => plugin.terminal; 28 | 29 | TerminalController get terminalController => plugin.terminalController; 30 | 31 | @override 32 | void initState() { 33 | terminalController.addListener(_onSelectionChanged); 34 | super.initState(); 35 | } 36 | 37 | @override 38 | void dispose() { 39 | terminalController.removeListener(_onSelectionChanged); 40 | super.dispose(); 41 | } 42 | 43 | @override 44 | void didUpdateWidget(covariant TerminalContextMenu oldWidget) { 45 | if (oldWidget.plugin.terminalController != 46 | widget.plugin.terminalController) { 47 | oldWidget.plugin.terminalController.removeListener(_onSelectionChanged); 48 | widget.plugin.terminalController.addListener(_onSelectionChanged); 49 | } 50 | super.didUpdateWidget(oldWidget); 51 | } 52 | 53 | void _onSelectionChanged() { 54 | setState(() {}); 55 | } 56 | 57 | @override 58 | Widget build(BuildContext context) { 59 | return cardBuilder( 60 | context, 61 | [ 62 | buttonBuilder( 63 | context, 64 | ContextMenuButtonConfig( 65 | "Copy", 66 | icon: const Icon(Icons.copy), 67 | shortcutLabel: 'Ctrl+C', 68 | onPressed: terminalController.selection != null 69 | ? () => handlePressed(context, _handleCopy) 70 | : null, 71 | ), 72 | ), 73 | buttonBuilder( 74 | context, 75 | ContextMenuButtonConfig( 76 | "Paste", 77 | icon: const Icon(Icons.paste), 78 | shortcutLabel: 'Ctrl+V', 79 | onPressed: () => handlePressed(context, _handlePaste), 80 | ), 81 | ), 82 | buttonBuilder( 83 | context, 84 | ContextMenuButtonConfig( 85 | "Select All", 86 | icon: const Icon(Icons.select_all), 87 | shortcutLabel: 'Ctrl+A', 88 | onPressed: () => handlePressed(context, _handleSelectAll), 89 | ), 90 | ), 91 | buildDivider(), 92 | buttonBuilder( 93 | context, 94 | ContextMenuButtonConfig( 95 | "File Manager", 96 | icon: const Icon(Icons.folder_open), 97 | shortcutLabel: 'Ctrl+Shift+F', 98 | onPressed: () => handlePressed(context, _handleOpenFileManager), 99 | ), 100 | ), 101 | buttonBuilder( 102 | context, 103 | ContextMenuButtonConfig( 104 | "Uptime", 105 | icon: const Icon(Icons.keyboard_double_arrow_up_outlined), 106 | // shortcutLabel: 'Ctrl+Shift+F', 107 | onPressed: () => handlePressed(context, _handleStarterPlugin), 108 | ), 109 | ), 110 | ], 111 | ); 112 | } 113 | 114 | Future _handleCopy() async { 115 | final selection = terminalController.selection; 116 | 117 | if (selection == null) { 118 | return; 119 | } 120 | 121 | final text = terminal.buffer.getText(selection); 122 | 123 | await Clipboard.setData(ClipboardData(text: text)); 124 | } 125 | 126 | Future _handlePaste() async { 127 | final data = await Clipboard.getData(Clipboard.kTextPlain); 128 | 129 | if (data == null) { 130 | return; 131 | } 132 | 133 | final text = data.text; 134 | 135 | if (text == null) { 136 | return; 137 | } 138 | 139 | terminal.paste(text); 140 | } 141 | 142 | Future _handleSelectAll() async { 143 | terminalController.setSelection( 144 | BufferRangeLine( 145 | CellOffset(0, terminal.buffer.height - terminal.viewHeight), 146 | CellOffset(terminal.viewWidth, terminal.buffer.height - 1), 147 | ), 148 | ); 149 | } 150 | 151 | Future _handleOpenFileManager() async { 152 | ref.read(tabsServiceProvider).openPlugin( 153 | plugin.hostSpec, 154 | FileManagerPlugin(), 155 | ); 156 | } 157 | 158 | Future _handleStarterPlugin() async { 159 | ref.read(tabsServiceProvider).openPlugin( 160 | plugin.hostSpec, 161 | StarterPlugin(), 162 | ); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | 4 | import 'package:context_menus/context_menus.dart'; 5 | import 'package:flex_tabs/flex_tabs.dart'; 6 | import 'package:fluent_ui/fluent_ui.dart'; 7 | import 'package:flutter/cupertino.dart'; 8 | import 'package:flutter/foundation.dart'; 9 | import 'package:flutter/scheduler.dart'; 10 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 11 | import 'package:terminal_studio/src/hosts/local_spec.dart'; 12 | import 'package:terminal_studio/src/core/service/tabs_service.dart'; 13 | import 'package:terminal_studio/src/core/state/tabs.dart'; 14 | import 'package:terminal_studio/src/ui/context_menu.dart'; 15 | import 'package:terminal_studio/src/ui/platform_menu.dart'; 16 | import 'package:terminal_studio/src/ui/shared/fluent_menu_card.dart'; 17 | import 'package:terminal_studio/src/ui/shared/macos_titlebar.dart'; 18 | import 'package:terminal_studio/src/ui/shortcut/global_actions.dart'; 19 | import 'package:terminal_studio/src/ui/shortcut/global_shortcuts.dart'; 20 | import 'package:terminal_studio/src/util/provider_logger.dart'; 21 | import 'package:window_manager/window_manager.dart'; 22 | 23 | Future main() async { 24 | WidgetsFlutterBinding.ensureInitialized(); 25 | 26 | initWindow(); 27 | 28 | runApp( 29 | const ProviderScope( 30 | observers: [ProviderLogger()], 31 | child: MyApp(), 32 | ), 33 | ); 34 | } 35 | 36 | Future initWindow() async { 37 | await windowManager.ensureInitialized(); 38 | await windowManager.setBackgroundColor(const Color(0x00000000)); 39 | await windowManager.setTitle('TerminalStudio'); 40 | 41 | if (defaultTargetPlatform != TargetPlatform.macOS) { 42 | await windowManager.setTitleBarStyle(TitleBarStyle.hidden); 43 | } 44 | 45 | windowManager.waitUntilReadyToShow(null, () async { 46 | await windowManager.show(); 47 | await windowManager.focus(); 48 | }); 49 | } 50 | 51 | class MyApp extends StatelessWidget { 52 | const MyApp({Key? key}) : super(key: key); 53 | 54 | @override 55 | Widget build(BuildContext context) { 56 | Widget widget = const GlobalShortcuts( 57 | child: GlobalActions( 58 | child: Home(), 59 | ), 60 | ); 61 | 62 | if (defaultTargetPlatform == TargetPlatform.macOS) { 63 | widget = GlobalPlatformMenu( 64 | child: widget, 65 | ); 66 | } 67 | 68 | widget = ContextMenuOverlay( 69 | child: widget, 70 | cardBuilder: (context, children) => FluentMenuCard(children: children), 71 | ); 72 | 73 | return FluentApp( 74 | title: 'TerminalStudio', 75 | debugShowCheckedModeBanner: false, 76 | home: widget, 77 | ); 78 | } 79 | } 80 | 81 | class Home extends ConsumerStatefulWidget { 82 | const Home({super.key}); 83 | 84 | @override 85 | ConsumerState createState() => _HomeState(); 86 | } 87 | 88 | class _HomeState extends ConsumerState { 89 | final tabsTheme = const TabsViewThemeData(); 90 | 91 | @override 92 | void initState() { 93 | SchedulerBinding.instance.addPostFrameCallback((_) async { 94 | await initTabs(); 95 | }); 96 | super.initState(); 97 | } 98 | 99 | Future initTabs() async { 100 | final root = Tabs(); 101 | 102 | ref.read(tabsServiceProvider).openTerminal(LocalHostSpec(), tabs: root); 103 | 104 | final document = ref.watch(tabsProvider); 105 | 106 | document.addListener(_onDocumentChanged); 107 | 108 | document.setRoot(root); 109 | } 110 | 111 | void _onDocumentChanged() { 112 | final document = ref.read(tabsProvider); 113 | 114 | document.root?.addListener(_onRootChanged); 115 | } 116 | 117 | void _onRootChanged() { 118 | final document = ref.read(tabsProvider); 119 | 120 | if (document.root == null || document.root!.children.isEmpty) { 121 | exit(0); 122 | } 123 | } 124 | 125 | @override 126 | Widget build(BuildContext context) { 127 | Widget widget = Column( 128 | children: [ 129 | _buildTitlebar(context), 130 | Expanded( 131 | child: TabsView( 132 | ref.watch(tabsProvider), 133 | theme: tabsTheme, 134 | actionBuilder: buildTabActions, 135 | ), 136 | ), 137 | ], 138 | ); 139 | 140 | // if (defaultTargetPlatform == TargetPlatform.windows) { 141 | // widget = VirtualWindowFrame(child: widget); 142 | // } 143 | 144 | return widget; 145 | } 146 | 147 | Widget _buildTitlebar(BuildContext context) { 148 | if (defaultTargetPlatform == TargetPlatform.macOS) { 149 | return MacosTitlebar( 150 | color: tabsTheme.selectedBackgroundColor, 151 | ); 152 | } 153 | 154 | return SizedBox( 155 | height: kWindowCaptionHeight, 156 | child: WindowCaption( 157 | backgroundColor: tabsTheme.selectedBackgroundColor, 158 | brightness: Brightness.light, 159 | title: const Text('TerminalStudio'), 160 | ), 161 | ); 162 | } 163 | 164 | List buildTabActions(Tabs tabs) { 165 | return [ 166 | TabsViewAction( 167 | icon: CupertinoIcons.chevron_down, 168 | onPressed: () { 169 | context.contextMenuOverlay.show( 170 | DropdownContextMenu(tabs), 171 | ); 172 | }, 173 | ), 174 | TabsViewAction( 175 | icon: CupertinoIcons.add, 176 | onPressed: () { 177 | ref 178 | .watch(tabsServiceProvider) 179 | .openTerminal(LocalHostSpec(), tabs: tabs); 180 | }, 181 | ), 182 | ]; 183 | } 184 | } 185 | --------------------------------------------------------------------------------