This commit is contained in:
LZX committed 2026-09-23 15:32:48 +08:00
1 parent caed1746c4
commit f99d09c7f6
4 files changed
+118 -78

No files matched your search

+8 -18
View File
@@ -41,6 +41,8 @@ desktop.ini
.pub/
/build/
/coverage/
/releases/
*.apk
pubspec-overrides.yaml
# Sensitive & Environment
@@ -65,24 +67,12 @@ android/**/GeneratedPluginRegistrant.java
/android/app/release/
/android/app/build/
# iOS / macOS
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/flutter_assets/
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Pods/
**/ios/.symlinks/
**/ios/profile/
**/ios/debug/
**/ios/release/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral/
**/macos/Pods/
# Windows / Linux ephemeral
windows/flutter/ephemeral/
linux/flutter/ephemeral/
# Other Platforms (Project is Android-only)
/ios/
/windows/
/macos/
/linux/
/web/
# Project Specific (PRoot 构建与临时目录)
proot-source/
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 LZX
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+46 -60
View File
@@ -4,11 +4,11 @@
# LN 代码编辑器 (LN Code Editor)
**专为移动端打造的现代化、轻量级代码编辑器与便携 IDE**
**专为 Android 打造的现代化、轻量级移动端代码编辑器与便携 IDE**
[![Flutter](https://img.shields.io/badge/Flutter-%2302569B.svg?style=flat&logo=Flutter&logoColor=white)](https://flutter.dev)
[![Dart](https://img.shields.io/badge/Dart-%230175C2.svg?style=flat&logo=dart&logoColor=white)](https://dart.dev)
[![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20Windows%20%7C%20macOS%20%7C%20Linux%20%7C%20Web-blue.svg)](https://github.com)
[![Platform](https://img.shields.io/badge/Platform-Android%20(ARM64%20%7C%20ARM32%20%7C%20x86__64)-green.svg)](https://github.com)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com)
@@ -20,42 +20,41 @@
## 📖 简介 (Introduction)
**LN 代码编辑器** 是一款基于 Flutter 与原生技术深度打造的跨平台代码编辑工具与轻量 IDE。针对移动端触摸交互进行了深度体验优化,集成了多语言语法高亮、代码智能补全与语法纠错、可视化 Git 冲突解决,以及**免 Root 的内置 Linux 容器与真实终端环境**,让开发者能够在手机和平板上随时随地阅读、编辑与调试项目源码。
**LN 代码编辑器** 是一款专为 Android 移动平台深度打磨的高性能代码编辑工具与掌上轻量 IDE。针对触控屏幕交互进行了全方位优化,不仅具备多语言高亮、智能补全与语法纠错、可视化 Git 冲突解决器,更内置了**免 Root 的 Linux 容器与真实 Shell 终端环境**,让开发者随时随地在手机与平板上自如阅读、编写与调试代码。
---
## ✨ 核心特性 (Key Features)
### 1. 📝 专业级代码编辑体验
- **多语言语法高亮**:深度集成 `re_editor` 与 `re_highlight`,提供快速且精准的语言着色。
- **多语言语法高亮**:深度集成 `re_editor` 与 `re_highlight`,提供快速精准的语言词法着色。
- **智能补全与实时纠错**:
- 支持函数、变量与关键字的实时自动补全。
- 语法错误实时波浪线提示与行号警示点。
- 提供**总控开关 + 补全/纠错双独立分开关**,由开发者自由定制。
- **自由缩放与排版**:双指自然缩放手势,字体大小自由调节;内置 JetBrains Mono 与 Fira Code 等专业 Nerd Font 等宽字体。
- 变量、函数与关键词的实时自动补全提示。
- 语法错误波浪线实时下划线与行号红黄指示点。
- **总开关 + 补全/纠错双独立分开关**自由切换,满足纯净阅读与极速敲码不同场景。
- **自由缩放与排版**:双指手势自由缩放字体大小;内置 JetBrains Mono 与 Fira Code 等专业 Nerd Font 等宽字体。
### 2. 🌿 可视化 Git 冲突解决器
- **冲突区块智能解析**:自动识别 `<<<<<<<`、`=======`、`>>>>>>>` 冲突标记。
- **差异可视化对比**:行内差异智能高亮显示,当前分支与传入更改一目了然。
- **一键快捷决策**:
- **冲突区块智能识别**:自动检测文件中所有的 `<<<<<<<`、`=======`、`>>>>>>>` 冲突区块。
- **行内差异对比**:当前更改与传入更改高亮对比,一目了然。
- **快捷决策操作栏**:
- *采用当前更改 (Accept Current)*
- *采用传入更改 (Accept Incoming)*
- *保留双方更改 (Accept Both)*
- *无缝切入手动编辑 (Manual Edit)*
- **移动端适配优化**:防溢出横向平滑操作栏,自动智能管理侧边栏与弹窗生命周期。
- **移动端适配优化**:防溢出横向平滑滚动条,操作时智能联动关闭下拉菜单与侧边栏。
### 3. 🐧 免 Root 内置 Linux 容器与终端
- **真实 Shell 环境**:基于 PRoot 技术深度封装轻量 Alpine Linux,无需 Root 即可获得原生 Linux 命令行能力。
- **流畅终端交互**:基于优化版 `xterm.dart` 与 `flutter_pty`,支持手势框选文本、清晰字体排版与快捷键操作。
- **命令行生态**:可在移动端直接体验 `git`、`apk`、`curl`、`python` 等常用命令行生态。
- **流畅终端交互**:基于优化版 `xterm.dart` 与 `flutter_pty`,支持文本长按与手势框选、清晰字体排版与快捷键操作。
- **丰富的命令行生态**:可在安卓设备上直接使用 `git`、`apk`、`curl`、`python` 等命令行工具。
### 4. 🎨 瑞士极简主义设计
- 沉浸式暗黑主题,专注代码本身。
- 极简高对比度品牌标识,完美适配各大系统自适应图标(Adaptive Icon)规范。
- 高对比度瑞士极简设计双色图标,完美适配 Android 8.0+ 自适应图标(Adaptive Icon)规范。
### 5. 🌐 全平台与国际化支持
- **多语言 (i18n / l10n)**:内置简体中文与英文多语言支持,跟随系统语言无缝切换。
- **跨端架构**:主打 Android,同时支持 Windows、macOS、Linux 及 Web 平台。
### 5. 🌐 完整国际化 (l10n)
- 原生支持简体中文(zh)与英文(en),跟随 Android 系统语言无缝切换。
---
@@ -67,57 +66,53 @@
| **核心编辑组件** | `re_editor` / `re_highlight` | 移动端高性能代码编辑与着色器 |
| **终端仿真** | `xterm` / `flutter_pty` | 终端框选优化、PTY 伪终端通信 |
| **容器沙箱** | PRoot + Alpine Linux / Shims | 原生 C/C++ 跨架构兼容层与动态环境 |
| **图标与资源** | `flutter_launcher_icons` | 工业级自适应全平台图标生成方案 |
| **状态与持久化** | `provider` / `shared_preferences` | 响应式状态管理与用户偏好持久化 |
| **图标生成** | `flutter_launcher_icons` | 自动生成 Android 全套 Mipmap 及自适应图标 |
| **状态持久化** | `provider` / `shared_preferences` | 响应式状态管理与用户偏好持久化 |
---
## 🚀 快速上手 (Getting Started)
## 🚀 下载安装与构建 (Installation & Build)
### 方式一:直接安装成品 (Release APK)
前往 [GitHub Releases](https://github.com) 页面,下载最新的 `app-release.apk`,在安卓手机上点击即可直接安装体验。
### 方式一:直接安装 Release APK (推荐)
本项目为不同机型提供了精准分包(已存放于 `releases/` 目录或 GitHub Releases):
### 方式二:从源码构建运行
* **`LN-Code-Editor-v1.0.0-arm64-v8a.apk`**(⭐ **绝大多数手机首选**,体积最小、运行最快)
* **`LN-Code-Editor-v1.0.0-armeabi-v7a.apk`**(适配较早期的 32 位老旧设备)
* **`LN-Code-Editor-v1.0.0-x86_64.apk`**(适配电脑端安卓模拟器、WSA 或 ChromeOS)
* **`LN-Code-Editor-v1.0.0-universal.apk`**(全架构合一通用包)
### 方式二:从源码构建
#### 1. 前置环境要求
- 安装 [Flutter SDK](https://docs.flutter.dev/get-started/install) (推荐 `>= 3.24.0`)
- 安装 Android SDK 与 NDK (`28.2.13676358`)
- JDK 11 / 17
- [Flutter SDK](https://docs.flutter.dev/get-started/install) (`>= 3.24.0`)
- Android SDK (API 34) & NDK (`28.2.13676358`)
- JDK 11 或 17
#### 2. 克隆项目与拉取依赖
#### 2. 拉取依赖并运行
```bash
# 克隆仓库
git clone https://github.com/your-username/code_editor.git
cd code_editor
# 安装 Flutter 依赖包
# 获取依赖
flutter pub get
```
#### 3. 启动调试
```bash
# 启动连接的设备(手机或模拟器)
# 连接安卓手机或模拟器进行调试
flutter run
```
#### 4. 打包 Release 成品
```bash
# 打包通用 Android Release APK
flutter build apk --release
# 或者打包 64 位极简版(体积缩小 50%)
flutter build apk --split-per-abi --release
#### 3. 一键编译全架构 Release APK
工程内提供了一键自动化打包脚本:
```powershell
# Windows PowerShell
.\tools\build\build-release-apks.ps1
```
编译产物位于:`build/app/outputs/flutter-apk/`
打包完成后,产物将自动规范命名并归档至 `releases/v<版本号>/` 目录。
---
## 📁 目录结构简析
## 📁 目录结构
```text
├── android/ # Android 原生配置与 MethodChannel 通道实现
├── android/ # Android 原生配置、JNI 库与 MethodChannel 通道实现
├── assets/ # 内置字体 (JetBrains/Fira)、Linux 镜像、图标等静态资产
│ ├── fonts/ # Nerd Font 编程字体
│ ├── fonts/ # Nerd Font 编程等宽字体
│ ├── icon/ # 1024x1024 高清自适应应用图标
│ └── shims/ # 容器架构兼容层
├── lib/ # Flutter / Dart 核心业务源码
@@ -128,6 +123,7 @@ flutter build apk --split-per-abi --release
│ ├── views/ # 核心视图 (编辑器主界面、补全管理、冲突页等)
│ └── widgets/ # 复用组件 (编辑区、Git 冲突面板、文件树)
├── packages/ # 经过定制与修复的第三方底层库 (re_editor, xterm)
├── tools/ # 构建与检查脚本 (build-release-apks.ps1 等)
└── test/ # 单元测试与 Widget 自动化测试用例
```
@@ -135,23 +131,13 @@ flutter build apk --split-per-abi --release
## 🧪 自动化测试
运行项目的完整单元测试与 Widget 交互测试集:
运行完整测试集:
```bash
flutter test
```
---
## 🤝 参与贡献 (Contributing)
我们非常欢迎社区的 Issue 与 PR!
1. Fork 本仓库并新建分支 (如 `feature/amazing-feature`);
2. 提交您的修改 (`git commit -m 'feat: Add some amazing feature'`);
3. 推送至您的分支 (`git push origin feature/amazing-feature`);
4. 提交 Pull Request。
---
## 📄 开源许可证 (License)
本项目遵循 [MIT License](LICENSE) 协议开源。
@@ -162,4 +148,4 @@ flutter test
## 🌐 English Summary
**LN Code Editor** is a modern, lightweight, mobile-first code editor and portable IDE powered by Flutter. Designed for optimal touchscreen productivity, it brings together syntax highlighting, smart code completion & diagnostics, visual Git conflict resolution, and a **rootless integrated Linux container with a full PTY terminal**. Write, inspect, and run code anywhere, right on your Android phone or tablet.
**LN Code Editor** is a modern, lightweight, mobile-first code editor and portable IDE designed specifically for Android. Powered by Flutter, it delivers syntax highlighting, smart code completion & diagnostics, visual Git conflict resolution, and a **rootless integrated Linux container with a full PTY terminal**. Write, inspect, and run code right on your Android phone or tablet.
+43
View File
@@ -0,0 +1,43 @@
# tools/build/build-release-apks.ps1
# 一键编译全架构 Android Release APK 并按规范重命名
param (
[string]$AppEngName = "LN-Code-Editor",
[string]$Version = ""
)
$ErrorActionPreference = "Stop"
# 如果未指定版本号,自动从 pubspec.yaml 读取
if (-not $Version) {
$pubspec = Get-Content "pubspec.yaml" -Raw
if ($pubspec -match "version:\s*([^\+\r\n]+)") {
$Version = "v" + $matches[1].Trim()
} else {
$Version = "v1.0.0"
}
}
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host " 🚀 正在构建 $AppEngName $Version Android 多架构 Release APK" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
# 1. 执行分架构构建
Write-Host "`n[1/2] 正在编译分架构 APK (arm64-v8a / armeabi-v7a / x86_64)..." -ForegroundColor Yellow
flutter build apk --split-per-abi --release
# 2. 执行全架构通用包构建
Write-Host "`n[2/2] 正在编译全架构通用 APK (Universal)..." -ForegroundColor Yellow
flutter build apk --release
# 3. 规范化重命名并归档至 releases/ 目录
$outputDir = "releases\$Version"
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
Copy-Item "build\app\outputs\flutter-apk\app-arm64-v8a-release.apk" -Destination "$outputDir\$AppEngName-$Version-arm64-v8a.apk" -Force
Copy-Item "build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk" -Destination "$outputDir\$AppEngName-$Version-armeabi-v7a.apk" -Force
Copy-Item "build\app\outputs\flutter-apk\app-x86_64-release.apk" -Destination "$outputDir\$AppEngName-$Version-x86_64.apk" -Force
Copy-Item "build\app\outputs\flutter-apk\app-release.apk" -Destination "$outputDir\$AppEngName-$Version-universal.apk" -Force
Write-Host "`n🎉 构建成功!产物已归档至目录: $outputDir" -ForegroundColor Green
Get-ChildItem -Path $outputDir | Select-Object Name, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB, 2)}}, LastWriteTime | Format-Table -AutoSize