| Crates.io | editor-server |
| lib.rs | editor-server |
| version | 0.0.1 |
| created_at | 2021-04-01 06:45:28.429142+00 |
| updated_at | 2021-04-01 06:45:28.429142+00 |
| description | A server for interfacing file edition. |
| homepage | https://github.com/JonathanxD/editor-server |
| repository | https://github.com/JonathanxD/editor-server |
| max_upload_size | |
| id | 376487 |
| size | 45,089 |
editor-server is a HTTP server which interfaces with a specified file. editor-server could be used for integration with applications which uses $EDITOR or $VISUAL for file editing.
It is important to understand that editor-server is not an editor in fact, it does simulate a text editor with four basic functionalities:
Currently editor-server is being developed to be used by Dracon IntelliJ Plugin to integrate IntelliJ editor with
pijul recordcommand, but could be used in any kind of project to simulate a basic file editor.
editor-server -p [port] [file]
For example, to start an editor-server listening on port 7070 to read and write to a file named example.json:
editor-server -p 7070 example.json
editor-server caches file contents in memory, to read the cached contents, send a GET request to /read endpoint.
GET http://localhost:7070/read
It does respond with entire file contents stored in memory.
editor-server caches file contents in memory, to write contents to cache, send a POST request to /write endpoint with the contents in the body of request.
POST http://localhost:7070/read
{"name": "editor-server"}
It writes the content to buffer in memory and respond with the amount of bytes written.
As pointed before, editor-server caches file contents in memory, to save the contents to file you must call /save endpoint.
GET http://localhost:7070/save
It does resets the contents of the file (all changes made directly to file are discarded) and writes the contents from the buffer, responding with the amount of bytes written.
To reload file contents stored in the buffer (in other words, to load the file contents into the buffer), call /reload endpoint.
GET http://localhost:7070/reload
It does read file contents into the buffer and respond with the amount of bytes read.
To close the editor, call the /close endpoint, it does flushes all contents stored in buffer to the file, if this is not the desired behavior, just call /reload to discard buffer changes, before closing the editor.
GET http://localhost:7070/close
editor-server supports port specification through $EDITOR_SERVER_PORT environment variable.
editor-server will be used in Dracon IntelliJ Plugin as replacement for copie. An editor-server will be launched with a random port and file contents will be read and written through REST API when file is changed in the IntelliJ Editor.