Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release

on:
push:
tags:
- 'v*'

env:
CARGO_TERM_COLOR: always

jobs:
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

build-release:
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: edit
asset_name: edit-x86_64-linux.tar.gz
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: edit
asset_name: edit-x86_64-linux-musl.tar.gz
# macOS
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: edit
asset_name: edit-x86_64-macos.tar.gz
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: edit
asset_name: edit-aarch64-macos.tar.gz
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: edit.exe
asset_name: edit-x86_64-windows.zip
- os: windows-latest
target: aarch64-pc-windows-msvc
artifact_name: edit.exe
asset_name: edit-aarch64-windows.zip

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true

- name: Install cross-compilation tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}

- name: Create archive (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czf ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }}

- name: Create archive (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }}

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ matrix.asset_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ version = "1.2.1"
edition = "2024"
rust-version = "1.87"
readme = "README.md"
repository = "https://github.com/microsoft/edit"
homepage = "https://github.com/microsoft/edit"
repository = "https://github.com/sichy/edit"
homepage = "https://github.com/sichy/edit"
license = "MIT"
categories = ["text-editors"]
description = "Fast and efficient text editor CLI tool"
keywords = ["text-editor", "cli", "editor"]
categories = ["text-editors", "command-line-utilities"]
exclude = ["npm/", "Formula/", ".github/", "target/", "*.log"]

[[bench]]
name = "lib"
Expand All @@ -34,6 +37,7 @@ codegen-units = 16 # Make compiling criterion faster (16 is the default
lto = "thin" # Similarly, speed up linking by a ton

[dependencies]
regex = "1.0"

[target.'cfg(unix)'.dependencies]
libc = "0.2"
Expand Down
22 changes: 22 additions & 0 deletions Formula/edit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Edit < Formula
desc "MS-DOS style modern CLI editor"
homepage "https://github.com/sichy/edit"
version "1.2.1"

if Hardware::CPU.intel?
url "https://github.com/microsoft/edit/releases/download/v#{version}/edit-x86_64-macos.tar.gz"
sha256 "REPLACE_WITH_ACTUAL_SHA256_FOR_X86_64" # Will be calculated after first release
elsif Hardware::CPU.arm?
url "https://github.com/microsoft/edit/releases/download/v#{version}/edit-aarch64-macos.tar.gz"
sha256 "REPLACE_WITH_ACTUAL_SHA256_FOR_ARM64" # Will be calculated after first release
end

def install
bin.install "edit"
end

test do
# Test that the binary runs and shows help
system "#{bin}/edit", "--help"
end
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ![Application Icon for Edit](./assets/edit.svg) Edit

A simple editor for simple needs.
A simple editor for simple needs. With my slight changes to add syntax highlighting and multifile edit. Old school MS-DOS TUI and nice dark theme. Work in progress and good relax in Rust.

This editor pays homage to the classic [MS-DOS Editor](https://en.wikipedia.org/wiki/MS-DOS_Editor), but with a modern interface and input controls similar to VS Code. The goal is to provide an accessible editor that even users largely unfamiliar with terminals can easily use.

Expand Down
Binary file modified assets/edit_hero_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: edit
Version: 1.2.1
Section: editors
Priority: optional
Architecture: amd64
Depends: libc6 (>= 2.17)
Maintainer: Microsoft <[email protected]>
Description: Fast and efficient text editor CLI tool
A modern, fast, and efficient command-line text editor
built with Rust. Provides MS-DOS style editing capabilities
with modern performance and cross-platform support.
52 changes: 52 additions & 0 deletions src/bin/edit/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ impl Document {
fn update_file_mode(&mut self) {
let mut tb = self.buffer.borrow_mut();
tb.set_ruler(if self.filename == "COMMIT_EDITMSG" { 72 } else { 0 });

// Set syntax highlighting based on file extension
if let Some(path) = &self.path {
if let Some(extension) = path.extension().and_then(|e| e.to_str()) {
tb.set_syntax_from_extension(extension);
}
}
}
}

Expand Down Expand Up @@ -112,6 +119,46 @@ impl DocumentManager {
self.list.pop_front();
}

/// Get the index of the currently active document
pub fn active_index(&self) -> usize {
0 // The active document is always at the front (index 0)
}

/// Set the active document by index
pub fn set_active_index(&mut self, index: usize) {
if index >= self.list.len() {
return;
}

let mut cursor = self.list.cursor_front_mut();
for _ in 0..index {
cursor.move_next();
}

if let Some(list) = cursor.remove_current_as_list() {
self.list.cursor_front_mut().splice_before(list);
}
}

/// Remove document at specific index
pub fn remove_at_index(&mut self, index: usize) {
if index >= self.list.len() {
return;
}

let mut cursor = self.list.cursor_front_mut();
for _ in 0..index {
cursor.move_next();
}

cursor.remove_current();
}

/// Get an iterator over all documents
pub fn iter(&self) -> impl Iterator<Item = &Document> {
self.list.iter()
}

pub fn add_untitled(&mut self) -> apperr::Result<&mut Document> {
let buffer = Self::create_buffer()?;
let mut doc = Document {
Expand Down Expand Up @@ -166,6 +213,11 @@ impl DocumentManager {
let mut tb = buffer.borrow_mut();
tb.read_file(file, None)?;

// Set syntax highlighting based on file extension
if let Some(extension) = path.extension().and_then(|e| e.to_str()) {
tb.set_syntax_from_extension(extension);
}

if let Some(goto) = goto
&& goto != Default::default()
{
Expand Down
Loading