Git Product home page Git Product logo

edit's Introduction

edit

crates.io docs.rs

edit is a Rust library that lets you open and edit something in a text editor, regardless of platform. (Think git commit.)

It works on Windows, Mac, and Linux, and knows about lots of different text editors to fall back upon in case standard environment variables such as VISUAL and EDITOR aren't set.

let template = "Fill in the blank: Hello, _____!";
let edited = edit::edit(template)?;
println!("after editing: '{}'", edited);
// after editing: 'Fill in the blank: Hello, world!'

edit's People

Contributors

ammkrn avatar gottox avatar jwodder avatar milkey-mouse avatar nikitalita avatar timvisee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

edit's Issues

Remove src/bin.rs when releasing to cargo

Releasing the example file to cargo create additionnal un-necessary steps when one want to package the library for a linux distribution. It also increase the size of the crate for no reason.

Way to specify file extension of temporary file

Hi ๐Ÿ‘‹ thanks for creating this crate. I'm planning on using it in a project of mine. I would love if there was a way to specify the extension (or suffix) of the temporary file that is created when you call edit::edit. This would be useful because then syntax highlighting would work on the opened file.

I was imagining a basic API like

edit::edit_with_suffix(text, "toml")

or

edit::edit_with_extension(text, "toml")

Graphical editor issue on Mac

Hi, thanks for this library. I've been trying it on a Mac and I've noticed that it works perfectly for terminal editors like vim, nano, or pico, but not for graphical editors like Sublime Text or VS Code.

For graphical editors, I find it opens the correct editor but the opened file is blank. Also, it returns the original, unaltered text to the terminal immediately without waiting for the editor to close.

I've seen this same behaviour with Sublime Text, VS Code, and Atom.

(Running the edit 0.1.2 test binary on macOS Catalina.)

Thanks.

Support async API

The nature of this crate is basicly just spawning and waiting, an optional async API would be a benefit for some usecases here^^

Allow limiting selection to only GUI/CLI options

I'm working on a GUI application, and was hoping to be able to use this crate to allow users to edit some files. However, it seems to be attempting to launch my CLI editor (nvim) despite being launched from a GUI, which unfortunately makes this crate unusable as it is now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.