mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-08-11 18:18:36 +02:00
Merge (#12) from tomasriveral/jed. Jed: add initial support
Jed: add initial support
This commit is contained in:
@@ -43,6 +43,7 @@ Before building NoteWrapper, you must install the following dependencies:
|
|||||||
You must also have a [supported editor (and their associated plugin if needed)](#editor-support) installed:
|
You must also have a [supported editor (and their associated plugin if needed)](#editor-support) installed:
|
||||||
|
|
||||||
* `helix`
|
* `helix`
|
||||||
|
* `jed`
|
||||||
* `kakoune`
|
* `kakoune`
|
||||||
* `micro`
|
* `micro`
|
||||||
* `nano`
|
* `nano`
|
||||||
@@ -145,6 +146,7 @@ If your editor does not support these features, you can implement a plugin using
|
|||||||
| Editor | Bufferless | Cursor | Jump to end | Aditional requirements |
|
| Editor | Bufferless | Cursor | Jump to end | Aditional requirements |
|
||||||
| --------- | ----------- | ------- | ------------ | ---------------------------------------------------------|
|
| --------- | ----------- | ------- | ------------ | ---------------------------------------------------------|
|
||||||
| Helix | ❌ | ❌ | ✅ | — |
|
| Helix | ❌ | ❌ | ✅ | — |
|
||||||
|
| Jed | ❌ | ❌ | ✅ | — |
|
||||||
| Kakoune | ❌ | ❌ | ✅ | — |
|
| Kakoune | ❌ | ❌ | ✅ | — |
|
||||||
| Micro | ❌ | ✅ | ✅ | [micro-vivify](https://codeberg.org/gibbert/micro-vivify) and [modifications to your `init.lua`](./docs/micro.md)|
|
| Micro | ❌ | ✅ | ✅ | [micro-vivify](https://codeberg.org/gibbert/micro-vivify) and [modifications to your `init.lua`](./docs/micro.md)|
|
||||||
| Nano | ❌ | ❌ | ✅ | — |
|
| Nano | ❌ | ❌ | ✅ | — |
|
||||||
@@ -219,5 +221,5 @@ It is recommended to use a browser different from your main one for rendering.
|
|||||||
|
|
||||||
* [ ] A converter between journal types
|
* [ ] A converter between journal types
|
||||||
* [x] Support multiple vault directories
|
* [x] Support multiple vault directories
|
||||||
* [ ] Port NoteWrapper to other editors (non-exhaustive list of planned ports: `emacs -nw`, `jed`, `ad`, flow-control, `ee`, `amp`, `dte`, `cano`, `mle`, `zee`, `ptext`, `kibi`, `ox`, `ne`, `dit`, `zile`, `moe`, `joe`, `pico`, `vis`)
|
* [ ] Port NoteWrapper to other editors (non-exhaustive list of planned ports: `emacs -nw`, `ad`, flow-control, `ee`, `amp`, `dte`, `cano`, `mle`, `zee`, `ptext`, `kibi`, `ox`, `ne`, `dit`, `zile`, `moe`, `joe`, `pico`, `vis`)
|
||||||
* [x] Default to $EDITOR
|
* [x] Default to $EDITOR
|
||||||
|
|||||||
+45
-6
@@ -1,7 +1,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
const char *supportedEditor[] = {"helix", "kakoune", "micro", "nano", "neovim", "vi", "vim"};
|
const char *supportedEditor[] = {"helix", "jed", "kakoune", "micro", "nano", "neovim", "vi", "vim"};
|
||||||
const int numEditors = 7;
|
const int numEditors = 8;
|
||||||
|
|
||||||
int compareString(const void *a, const void *b) {
|
int compareString(const void *a, const void *b) {
|
||||||
const char *str1 = *(const char **)a;
|
const char *str1 = *(const char **)a;
|
||||||
@@ -425,7 +425,7 @@ if (editor_pid == 0) {
|
|||||||
|
|
||||||
// If render enabled → spawn viv in parallel
|
// If render enabled → spawn viv in parallel
|
||||||
if (render) {
|
if (render) {
|
||||||
debug("Running the editor...");
|
debug("Running Vivify...");
|
||||||
pid_t viv_pid = fork();
|
pid_t viv_pid = fork();
|
||||||
error(viv_pid < 0, "program", "fork() failed.");
|
error(viv_pid < 0, "program", "fork() failed.");
|
||||||
|
|
||||||
@@ -464,7 +464,7 @@ if (editor_pid == 0) {
|
|||||||
|
|
||||||
// If render enabled → spawn viv in parallel
|
// If render enabled → spawn viv in parallel
|
||||||
if (render) {
|
if (render) {
|
||||||
debug("Running the editor...");
|
debug("Running Vivify...");
|
||||||
pid_t viv_pid = fork();
|
pid_t viv_pid = fork();
|
||||||
error(viv_pid < 0, "program", "fork() failed.");
|
error(viv_pid < 0, "program", "fork() failed.");
|
||||||
|
|
||||||
@@ -505,7 +505,7 @@ if (editor_pid == 0) {
|
|||||||
|
|
||||||
// If render enabled → spawn viv in parallel
|
// If render enabled → spawn viv in parallel
|
||||||
if (render) {
|
if (render) {
|
||||||
debug("Running the editor...");
|
debug("Running Vivify...");
|
||||||
pid_t viv_pid = fork();
|
pid_t viv_pid = fork();
|
||||||
error(viv_pid < 0, "program", "fork() failed.");
|
error(viv_pid < 0, "program", "fork() failed.");
|
||||||
|
|
||||||
@@ -544,7 +544,7 @@ if (editor_pid == 0) {
|
|||||||
|
|
||||||
// If render enabled → spawn viv in parallel
|
// If render enabled → spawn viv in parallel
|
||||||
if (render) {
|
if (render) {
|
||||||
debug("Running the editor...");
|
debug("Running Vivify...");
|
||||||
pid_t viv_pid = fork();
|
pid_t viv_pid = fork();
|
||||||
error(viv_pid < 0, "program", "fork() failed.");
|
error(viv_pid < 0, "program", "fork() failed.");
|
||||||
|
|
||||||
@@ -577,6 +577,45 @@ if (editor_pid == 0) {
|
|||||||
execlp("vi", "vi", path, NULL);
|
execlp("vi", "vi", path, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error(1, "program", "execlp() failed.");
|
||||||
|
// ---- Jed ----
|
||||||
|
} else if (strcmp(editor, "jed") == 0) {
|
||||||
|
|
||||||
|
// If render enabled → spawn viv in parallel
|
||||||
|
if (render) {
|
||||||
|
debug("Running Vivify...");
|
||||||
|
pid_t viv_pid = fork();
|
||||||
|
error(viv_pid < 0, "program", "fork() failed.");
|
||||||
|
|
||||||
|
if (viv_pid == 0) {
|
||||||
|
// GRANDCHILD → viv
|
||||||
|
|
||||||
|
|
||||||
|
char viv_path[PATH_MAX];
|
||||||
|
strncpy(viv_path, path, PATH_MAX - 1);
|
||||||
|
viv_path[PATH_MAX - 1] = '\0';
|
||||||
|
|
||||||
|
if (shouldJumpToEndOfFile) {
|
||||||
|
strncat(viv_path, ":99999",
|
||||||
|
PATH_MAX - strlen(viv_path) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("Running viv %s", viv_path);
|
||||||
|
execlp("viv", "viv", viv_path, NULL);
|
||||||
|
error(1, "program", "execlp() failed.");
|
||||||
|
}
|
||||||
|
// IMPORTANT: do NOT wait for viv
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now run jed (this replaces the child process)
|
||||||
|
if (shouldJumpToEndOfFile) {
|
||||||
|
debug("Running jed %s -g 99999999", path);
|
||||||
|
execlp("jed", "jed", path, "-g", "99999999", NULL);
|
||||||
|
} else {
|
||||||
|
debug("Running jed %s", path);
|
||||||
|
execlp("jed", "jed", path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
error(1, "program", "execlp() failed.");
|
error(1, "program", "execlp() failed.");
|
||||||
// ---- UNKNOWN EDITOR ----
|
// ---- UNKNOWN EDITOR ----
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user