Compare commits
4 Commits
7eaf6913cb
...
V2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d253e51ef | |||
| 42f82e2e0d | |||
| fa32f4b177 | |||
| 65f997e964 |
@@ -8,13 +8,17 @@ It's abviously only working for **Linux**.
|
|||||||
You will only need **meson** and a **C compiler** to compile the editor.
|
You will only need **meson** and a **C compiler** to compile the editor.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
### From source
|
||||||
Here is the installation line for development version:
|
Here is the installation line for development version:
|
||||||
|
|
||||||
```git clone https://homelinuxserver.ddns.net/git/arthur/beluga.git ~/.beluga && cd ~/.beluga && meson setup --reconfigure build && meson compile -C build```
|
```git clone https://homelinuxserver.ddns.net/git/arthur/beluga.git ~/.beluga && cd ~/.beluga && meson setup build && meson compile -C build```
|
||||||
|
|
||||||
The executable file will be `build/beluga`. Feel free to add it to your path.
|
The executable file will be `build/beluga`. Feel free to add it to your path.
|
||||||
|
|
||||||
|
### From installation script ( prefered )
|
||||||
|
|
||||||
|
Just clone the repo and execute the script `install.sh`. It will automatically add beluga to your path.
|
||||||
|
|
||||||
## Getting start
|
## Getting start
|
||||||
|
|
||||||
To open an existing file just type :
|
To open an existing file just type :
|
||||||
|
|||||||
@@ -29,4 +29,6 @@ Lisp editorOpenFile(Lisp args, LispError *e, LispContext ctx);
|
|||||||
|
|
||||||
Lisp editorPrintC(Lisp args, LispError *e, LispContext ctx);
|
Lisp editorPrintC(Lisp args, LispError *e, LispContext ctx);
|
||||||
|
|
||||||
|
Lisp addPackage(Lisp args, LispError *e, LispContext ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+11
-3
@@ -17,13 +17,21 @@ fi
|
|||||||
echo "Create config files ..."
|
echo "Create config files ..."
|
||||||
mkdir -pv ~/.beluga/
|
mkdir -pv ~/.beluga/
|
||||||
cp -rv ./assets/ ~/.beluga/
|
cp -rv ./assets/ ~/.beluga/
|
||||||
cp -rv ./config/ ~/.beluga/
|
mkdir -pv ~/.beluga/packages/
|
||||||
|
|
||||||
|
read -p "Do you want to replace your config file or keep it (init.lisp.bak) / (init.lisp.new) ? (Y/n)" confirm
|
||||||
|
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||||
|
mv ~/.beluga/config/init.lisp ~/.beluga/config/init.lisp.bak
|
||||||
|
cp -rv ./config/init.lisp ~/.beluga/config/
|
||||||
|
else
|
||||||
|
cp -rv ./config/init.lisp ~/.beluga/config/init.lisp.new
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Compile the project
|
# Compile the project
|
||||||
|
|
||||||
|
|
||||||
echo "Start compilation ..."
|
echo "Start compilation ..."
|
||||||
meson setup --reconfigure build/
|
meson setup build/
|
||||||
meson compile -C build/
|
meson compile -C build/
|
||||||
|
|
||||||
# Add to path
|
# Add to path
|
||||||
|
|||||||
+18
-2
@@ -27,7 +27,6 @@ Lisp mapKey(Lisp args, LispError *e, LispContext ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Lisp moveCursor(Lisp args, LispError *e, LispContext ctx) {
|
Lisp moveCursor(Lisp args, LispError *e, LispContext ctx) {
|
||||||
fprintf(stderr, "Cursor is moving\n");
|
|
||||||
const char *direction = lisp_string(lisp_car(args));
|
const char *direction = lisp_string(lisp_car(args));
|
||||||
switch (direction[0]) {
|
switch (direction[0]) {
|
||||||
case 'u':
|
case 'u':
|
||||||
@@ -134,8 +133,25 @@ Lisp editorOpenFile(Lisp args, LispError *e, LispContext ctx) {
|
|||||||
|
|
||||||
|
|
||||||
Lisp editorPrintC(Lisp args, LispError *e, LispContext ctx) {
|
Lisp editorPrintC(Lisp args, LispError *e, LispContext ctx) {
|
||||||
char c = lisp_char(lisp_car(args));
|
char c = lisp_string(lisp_car(args))[0];
|
||||||
editorInsertChar(c);
|
editorInsertChar(c);
|
||||||
return lisp_null();
|
return lisp_null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Lisp addPackage(Lisp args, LispError *e, LispContext ctx) {
|
||||||
|
const char *package_name = lisp_string(lisp_car(args));
|
||||||
|
char *package_dir = (char *) calloc(256, sizeof(char));
|
||||||
|
FILE *fd_package = NULL;
|
||||||
|
strcat(package_dir, getenv("HOME"));
|
||||||
|
strcat(package_dir, "/.beluga/packages/");
|
||||||
|
strcat(package_dir, package_name);
|
||||||
|
strcat(package_dir, "/init.lisp");
|
||||||
|
fd_package = fopen(package_dir, "r");
|
||||||
|
lisp_eval(lisp_read_file(fd_package, &E.ctx_error, E.ctx), &E.ctx_error,
|
||||||
|
E.ctx);
|
||||||
|
fclose(fd_package);
|
||||||
|
free(package_dir);
|
||||||
|
|
||||||
|
return lisp_null();
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+3
-1
@@ -31,10 +31,11 @@ void initBuiltins() {
|
|||||||
registerBuiltin("MOVE-CURSOR-PAGE-DOWN", editorMoveCursorPageDown);
|
registerBuiltin("MOVE-CURSOR-PAGE-DOWN", editorMoveCursorPageDown);
|
||||||
registerBuiltin("EDITOR-OPEN-FILE", editorOpenFile);
|
registerBuiltin("EDITOR-OPEN-FILE", editorOpenFile);
|
||||||
registerBuiltin("EDITOR-INSERT-CHAR", editorPrintC);
|
registerBuiltin("EDITOR-INSERT-CHAR", editorPrintC);
|
||||||
|
registerBuiltin("ADD-PACKAGE", addPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initEditor() {
|
void initEditor() {
|
||||||
char init_file_path[256];
|
char * init_file_path = (char *) calloc(256, sizeof(char));
|
||||||
E.cursor_x = 0;
|
E.cursor_x = 0;
|
||||||
E.cursor_y = 0;
|
E.cursor_y = 0;
|
||||||
E.rx = 0;
|
E.rx = 0;
|
||||||
@@ -66,6 +67,7 @@ void initEditor() {
|
|||||||
|
|
||||||
// Read config file
|
// Read config file
|
||||||
E.ctx_data = lisp_read_file(E.fd_init_file, &E.ctx_error, E.ctx);
|
E.ctx_data = lisp_read_file(E.fd_init_file, &E.ctx_error, E.ctx);
|
||||||
|
free(init_file_path);
|
||||||
if (E.ctx_error != LISP_ERROR_NONE) {
|
if (E.ctx_error != LISP_ERROR_NONE) {
|
||||||
die("init failed");
|
die("init failed");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user