rename to Acord, add SVG icon with rsvg build
|
|
@ -3,13 +3,13 @@
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>Swiftly</string>
|
<string>Acord</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>org.else-if.swiftly</string>
|
<string>org.else-if.acord</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>Swiftly</string>
|
<string>Acord</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
<string>Swiftly</string>
|
<string>Acord</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
|
|
|
||||||
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 810 B |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 12 KiB |
42
build.sh
|
|
@ -3,7 +3,7 @@ set -euo pipefail
|
||||||
|
|
||||||
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
||||||
BUILD="$ROOT/build"
|
BUILD="$ROOT/build"
|
||||||
APP="$BUILD/bin/Swiftly.app"
|
APP="$BUILD/bin/Acord.app"
|
||||||
CONTENTS="$APP/Contents"
|
CONTENTS="$APP/Contents"
|
||||||
MACOS="$CONTENTS/MacOS"
|
MACOS="$CONTENTS/MacOS"
|
||||||
RESOURCES="$CONTENTS/Resources"
|
RESOURCES="$CONTENTS/Resources"
|
||||||
|
|
@ -14,35 +14,39 @@ RUST_LIB="$ROOT/target/release"
|
||||||
export MACOSX_DEPLOYMENT_TARGET=14.0
|
export MACOSX_DEPLOYMENT_TARGET=14.0
|
||||||
export ZERO_AR_DATE=0
|
export ZERO_AR_DATE=0
|
||||||
echo "Building Rust workspace (release)..."
|
echo "Building Rust workspace (release)..."
|
||||||
cd "$ROOT" && cargo build --release -p swiftly-viewport
|
cd "$ROOT" && cargo build --release -p acord-viewport
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR: Rust build failed"
|
echo "ERROR: Rust build failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$RUST_LIB/libswiftly_viewport.a" ]; then
|
if [ ! -f "$RUST_LIB/libacord_viewport.a" ]; then
|
||||||
echo "ERROR: libswiftly_viewport.a not found at $RUST_LIB"
|
echo "ERROR: libacord_viewport.a not found at $RUST_LIB"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RUST_FLAGS=(-import-objc-header "$ROOT/viewport/include/swiftly.h" -L "$RUST_LIB" -lswiftly_viewport)
|
RUST_FLAGS=(-import-objc-header "$ROOT/viewport/include/acord.h" -L "$RUST_LIB" -lacord_viewport)
|
||||||
|
|
||||||
# --- App icon from pre-rendered PNGs ---
|
# --- App icon from SVG via rsvg-convert ---
|
||||||
ICONS="$ROOT/assets/icon_sources"
|
SVG="$ROOT/assets/Acord.svg"
|
||||||
if [ -d "$ICONS" ]; then
|
if [ -f "$SVG" ]; then
|
||||||
echo "Generating app icon..."
|
echo "Generating app icon..."
|
||||||
ICONSET="$BUILD/AppIcon.iconset"
|
ICONSET="$BUILD/AppIcon.iconset"
|
||||||
mkdir -p "$ICONSET"
|
mkdir -p "$ICONSET"
|
||||||
cp "$ICONS/Swiftly_icons.png" "$ICONSET/icon_16x16.png"
|
for size in 16 32 64 128 256 512 1024; do
|
||||||
cp "$ICONS/Swiftly_icons@2x.png" "$ICONSET/icon_16x16@2x.png"
|
rsvg-convert --width="$size" --height="$size" "$SVG" -o "$ICONSET/icon_${size}.png"
|
||||||
cp "$ICONS/Swiftly_icons@2x.png" "$ICONSET/icon_32x32.png"
|
done
|
||||||
cp "$ICONS/Swiftly_icons@4x.png" "$ICONSET/icon_32x32@2x.png"
|
cp "$ICONSET/icon_16.png" "$ICONSET/icon_16x16.png"
|
||||||
cp "$ICONS/Swiftly_icons@8x.png" "$ICONSET/icon_128x128.png"
|
cp "$ICONSET/icon_32.png" "$ICONSET/icon_16x16@2x.png"
|
||||||
cp "$ICONS/Swiftly_icons@16x.png" "$ICONSET/icon_128x128@2x.png"
|
cp "$ICONSET/icon_32.png" "$ICONSET/icon_32x32.png"
|
||||||
cp "$ICONS/Swiftly_icons@16x.png" "$ICONSET/icon_256x256.png"
|
cp "$ICONSET/icon_64.png" "$ICONSET/icon_32x32@2x.png"
|
||||||
cp "$ICONS/Swiftly_icons@32.png" "$ICONSET/icon_256x256@2x.png"
|
cp "$ICONSET/icon_128.png" "$ICONSET/icon_128x128.png"
|
||||||
cp "$ICONS/Swiftly_icons@32.png" "$ICONSET/icon_512x512.png"
|
cp "$ICONSET/icon_256.png" "$ICONSET/icon_128x128@2x.png"
|
||||||
cp "$ICONS/Swiftly_icons@64.png" "$ICONSET/icon_512x512@2x.png"
|
cp "$ICONSET/icon_256.png" "$ICONSET/icon_256x256.png"
|
||||||
|
cp "$ICONSET/icon_512.png" "$ICONSET/icon_256x256@2x.png"
|
||||||
|
cp "$ICONSET/icon_512.png" "$ICONSET/icon_512x512.png"
|
||||||
|
cp "$ICONSET/icon_1024.png" "$ICONSET/icon_512x512@2x.png"
|
||||||
|
rm -f "$ICONSET"/icon_*.png.tmp "$ICONSET"/icon_16.png "$ICONSET"/icon_32.png "$ICONSET"/icon_64.png "$ICONSET"/icon_128.png "$ICONSET"/icon_256.png "$ICONSET"/icon_512.png "$ICONSET"/icon_1024.png
|
||||||
iconutil -c icns "$ICONSET" -o "$BUILD/AppIcon.icns"
|
iconutil -c icns "$ICONSET" -o "$BUILD/AppIcon.icns"
|
||||||
rm -rf "$ICONSET"
|
rm -rf "$ICONSET"
|
||||||
fi
|
fi
|
||||||
|
|
@ -68,7 +72,7 @@ swiftc \
|
||||||
-framework CoreGraphics \
|
-framework CoreGraphics \
|
||||||
-framework CoreFoundation \
|
-framework CoreFoundation \
|
||||||
-O \
|
-O \
|
||||||
-o "$MACOS/Swiftly" \
|
-o "$MACOS/Acord" \
|
||||||
"$ROOT"/src/*.swift
|
"$ROOT"/src/*.swift
|
||||||
|
|
||||||
# --- Code sign ---
|
# --- Code sign ---
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "swiftly-core"
|
name = "acord-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
.generate()
|
.generate()
|
||||||
{
|
{
|
||||||
Ok(bindings) => {
|
Ok(bindings) => {
|
||||||
let path = format!("{}/include/swiftly.h", crate_dir);
|
let path = format!("{}/include/acord.h", crate_dir);
|
||||||
bindings.write_to_file(&path);
|
bindings.write_to_file(&path);
|
||||||
println!("cargo:warning=cbindgen: wrote {}", path);
|
println!("cargo:warning=cbindgen: wrote {}", path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* Generated by cbindgen — do not edit */
|
||||||
|
|
||||||
|
#ifndef SWIFTLY_H
|
||||||
|
#define SWIFTLY_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct AcordDoc AcordDoc;
|
||||||
|
|
||||||
|
struct AcordDoc *acord_doc_new(void);
|
||||||
|
|
||||||
|
void acord_doc_free(struct AcordDoc *doc);
|
||||||
|
|
||||||
|
void acord_doc_set_text(struct AcordDoc *doc, const char *text);
|
||||||
|
|
||||||
|
char *acord_doc_get_text(const struct AcordDoc *doc);
|
||||||
|
|
||||||
|
char *acord_doc_evaluate(struct AcordDoc *doc);
|
||||||
|
|
||||||
|
char *acord_eval_line(const char *text);
|
||||||
|
|
||||||
|
bool acord_doc_save(const struct AcordDoc *doc, const char *path);
|
||||||
|
|
||||||
|
struct AcordDoc *acord_doc_load(const char *path);
|
||||||
|
|
||||||
|
char *acord_cache_save(const struct AcordDoc *doc);
|
||||||
|
|
||||||
|
struct AcordDoc *acord_cache_load(const char *uuid);
|
||||||
|
|
||||||
|
char *acord_list_notes(void);
|
||||||
|
|
||||||
|
char *acord_highlight(const char *source, const char *lang);
|
||||||
|
|
||||||
|
void acord_free_string(char *s);
|
||||||
|
|
||||||
|
#endif /* SWIFTLY_H */
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/* Generated by cbindgen — do not edit */
|
|
||||||
|
|
||||||
#ifndef SWIFTLY_H
|
|
||||||
#define SWIFTLY_H
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
typedef struct SwiftlyDoc SwiftlyDoc;
|
|
||||||
|
|
||||||
struct SwiftlyDoc *swiftly_doc_new(void);
|
|
||||||
|
|
||||||
void swiftly_doc_free(struct SwiftlyDoc *doc);
|
|
||||||
|
|
||||||
void swiftly_doc_set_text(struct SwiftlyDoc *doc, const char *text);
|
|
||||||
|
|
||||||
char *swiftly_doc_get_text(const struct SwiftlyDoc *doc);
|
|
||||||
|
|
||||||
char *swiftly_doc_evaluate(struct SwiftlyDoc *doc);
|
|
||||||
|
|
||||||
char *swiftly_eval_line(const char *text);
|
|
||||||
|
|
||||||
bool swiftly_doc_save(const struct SwiftlyDoc *doc, const char *path);
|
|
||||||
|
|
||||||
struct SwiftlyDoc *swiftly_doc_load(const char *path);
|
|
||||||
|
|
||||||
char *swiftly_cache_save(const struct SwiftlyDoc *doc);
|
|
||||||
|
|
||||||
struct SwiftlyDoc *swiftly_cache_load(const char *uuid);
|
|
||||||
|
|
||||||
char *swiftly_list_notes(void);
|
|
||||||
|
|
||||||
char *swiftly_highlight(const char *source, const char *lang);
|
|
||||||
|
|
||||||
void swiftly_free_string(char *s);
|
|
||||||
|
|
||||||
#endif /* SWIFTLY_H */
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::doc::{classify_document, ClassifiedLine};
|
use crate::doc::{classify_document, ClassifiedLine};
|
||||||
use crate::eval::{evaluate_document, DocumentResult};
|
use crate::eval::{evaluate_document, DocumentResult};
|
||||||
|
|
||||||
pub struct SwiftlyDoc {
|
pub struct AcordDoc {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
lines: Vec<ClassifiedLine>,
|
lines: Vec<ClassifiedLine>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SwiftlyDoc {
|
impl AcordDoc {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
SwiftlyDoc {
|
AcordDoc {
|
||||||
text: String::new(),
|
text: String::new(),
|
||||||
uuid: uuid::Uuid::new_v4().to_string(),
|
uuid: uuid::Uuid::new_v4().to_string(),
|
||||||
lines: Vec::new(),
|
lines: Vec::new(),
|
||||||
|
|
@ -17,7 +17,7 @@ impl SwiftlyDoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_uuid(uuid: String) -> Self {
|
pub fn with_uuid(uuid: String) -> Self {
|
||||||
SwiftlyDoc {
|
AcordDoc {
|
||||||
text: String::new(),
|
text: String::new(),
|
||||||
uuid,
|
uuid,
|
||||||
lines: Vec::new(),
|
lines: Vec::new(),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::ffi::{CStr, CString};
|
||||||
use std::os::raw::c_char;
|
use std::os::raw::c_char;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::document::SwiftlyDoc;
|
use crate::document::AcordDoc;
|
||||||
use crate::eval;
|
use crate::eval;
|
||||||
use crate::highlight;
|
use crate::highlight;
|
||||||
use crate::persist;
|
use crate::persist;
|
||||||
|
|
@ -17,18 +17,18 @@ fn str_to_cstr(s: &str) -> *mut c_char {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_doc_new() -> *mut SwiftlyDoc {
|
pub extern "C" fn acord_doc_new() -> *mut AcordDoc {
|
||||||
Box::into_raw(Box::new(SwiftlyDoc::new()))
|
Box::into_raw(Box::new(AcordDoc::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_doc_free(doc: *mut SwiftlyDoc) {
|
pub extern "C" fn acord_doc_free(doc: *mut AcordDoc) {
|
||||||
if doc.is_null() { return; }
|
if doc.is_null() { return; }
|
||||||
unsafe { drop(Box::from_raw(doc)); }
|
unsafe { drop(Box::from_raw(doc)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_doc_set_text(doc: *mut SwiftlyDoc, text: *const c_char) {
|
pub extern "C" fn acord_doc_set_text(doc: *mut AcordDoc, text: *const c_char) {
|
||||||
let doc = match unsafe { doc.as_mut() } {
|
let doc = match unsafe { doc.as_mut() } {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => return,
|
None => return,
|
||||||
|
|
@ -41,7 +41,7 @@ pub extern "C" fn swiftly_doc_set_text(doc: *mut SwiftlyDoc, text: *const c_char
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_doc_get_text(doc: *const SwiftlyDoc) -> *mut c_char {
|
pub extern "C" fn acord_doc_get_text(doc: *const AcordDoc) -> *mut c_char {
|
||||||
let doc = match unsafe { doc.as_ref() } {
|
let doc = match unsafe { doc.as_ref() } {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => return std::ptr::null_mut(),
|
None => return std::ptr::null_mut(),
|
||||||
|
|
@ -50,7 +50,7 @@ pub extern "C" fn swiftly_doc_get_text(doc: *const SwiftlyDoc) -> *mut c_char {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_doc_evaluate(doc: *mut SwiftlyDoc) -> *mut c_char {
|
pub extern "C" fn acord_doc_evaluate(doc: *mut AcordDoc) -> *mut c_char {
|
||||||
let doc = match unsafe { doc.as_mut() } {
|
let doc = match unsafe { doc.as_mut() } {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => return str_to_cstr("[]"),
|
None => return str_to_cstr("[]"),
|
||||||
|
|
@ -61,7 +61,7 @@ pub extern "C" fn swiftly_doc_evaluate(doc: *mut SwiftlyDoc) -> *mut c_char {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_eval_line(text: *const c_char) -> *mut c_char {
|
pub extern "C" fn acord_eval_line(text: *const c_char) -> *mut c_char {
|
||||||
let text = match cstr_to_str(text) {
|
let text = match cstr_to_str(text) {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => return str_to_cstr(""),
|
None => return str_to_cstr(""),
|
||||||
|
|
@ -73,7 +73,7 @@ pub extern "C" fn swiftly_eval_line(text: *const c_char) -> *mut c_char {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_doc_save(doc: *const SwiftlyDoc, path: *const c_char) -> bool {
|
pub extern "C" fn acord_doc_save(doc: *const AcordDoc, path: *const c_char) -> bool {
|
||||||
let doc = match unsafe { doc.as_ref() } {
|
let doc = match unsafe { doc.as_ref() } {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => return false,
|
None => return false,
|
||||||
|
|
@ -86,14 +86,14 @@ pub extern "C" fn swiftly_doc_save(doc: *const SwiftlyDoc, path: *const c_char)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_doc_load(path: *const c_char) -> *mut SwiftlyDoc {
|
pub extern "C" fn acord_doc_load(path: *const c_char) -> *mut AcordDoc {
|
||||||
let path = match cstr_to_str(path) {
|
let path = match cstr_to_str(path) {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => return std::ptr::null_mut(),
|
None => return std::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
match persist::load_from_file(Path::new(path)) {
|
match persist::load_from_file(Path::new(path)) {
|
||||||
Ok(text) => {
|
Ok(text) => {
|
||||||
let mut doc = SwiftlyDoc::new();
|
let mut doc = AcordDoc::new();
|
||||||
doc.set_text(&text);
|
doc.set_text(&text);
|
||||||
Box::into_raw(Box::new(doc))
|
Box::into_raw(Box::new(doc))
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +102,7 @@ pub extern "C" fn swiftly_doc_load(path: *const c_char) -> *mut SwiftlyDoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_cache_save(doc: *const SwiftlyDoc) -> *mut c_char {
|
pub extern "C" fn acord_cache_save(doc: *const AcordDoc) -> *mut c_char {
|
||||||
let doc = match unsafe { doc.as_ref() } {
|
let doc = match unsafe { doc.as_ref() } {
|
||||||
Some(d) => d,
|
Some(d) => d,
|
||||||
None => return std::ptr::null_mut(),
|
None => return std::ptr::null_mut(),
|
||||||
|
|
@ -115,14 +115,14 @@ pub extern "C" fn swiftly_cache_save(doc: *const SwiftlyDoc) -> *mut c_char {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_cache_load(uuid: *const c_char) -> *mut SwiftlyDoc {
|
pub extern "C" fn acord_cache_load(uuid: *const c_char) -> *mut AcordDoc {
|
||||||
let uuid = match cstr_to_str(uuid) {
|
let uuid = match cstr_to_str(uuid) {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => return std::ptr::null_mut(),
|
None => return std::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
match persist::cache_load(uuid) {
|
match persist::cache_load(uuid) {
|
||||||
Ok(text) => {
|
Ok(text) => {
|
||||||
let mut doc = SwiftlyDoc::with_uuid(uuid.to_string());
|
let mut doc = AcordDoc::with_uuid(uuid.to_string());
|
||||||
doc.set_text(&text);
|
doc.set_text(&text);
|
||||||
Box::into_raw(Box::new(doc))
|
Box::into_raw(Box::new(doc))
|
||||||
}
|
}
|
||||||
|
|
@ -131,14 +131,14 @@ pub extern "C" fn swiftly_cache_load(uuid: *const c_char) -> *mut SwiftlyDoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_list_notes() -> *mut c_char {
|
pub extern "C" fn acord_list_notes() -> *mut c_char {
|
||||||
let notes = persist::list_notes();
|
let notes = persist::list_notes();
|
||||||
let json = serde_json::to_string(¬es).unwrap_or_else(|_| "[]".into());
|
let json = serde_json::to_string(¬es).unwrap_or_else(|_| "[]".into());
|
||||||
str_to_cstr(&json)
|
str_to_cstr(&json)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_highlight(source: *const c_char, lang: *const c_char) -> *mut c_char {
|
pub extern "C" fn acord_highlight(source: *const c_char, lang: *const c_char) -> *mut c_char {
|
||||||
let source = match cstr_to_str(source) {
|
let source = match cstr_to_str(source) {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => return str_to_cstr("[]"),
|
None => return str_to_cstr("[]"),
|
||||||
|
|
@ -153,7 +153,7 @@ pub extern "C" fn swiftly_highlight(source: *const c_char, lang: *const c_char)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn swiftly_free_string(s: *mut c_char) {
|
pub extern "C" fn acord_free_string(s: *mut c_char) {
|
||||||
if s.is_null() { return; }
|
if s.is_null() { return; }
|
||||||
unsafe { drop(CString::from_raw(s)); }
|
unsafe { drop(CString::from_raw(s)); }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,17 +55,17 @@ impl StateIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn swiftly_dir() -> PathBuf {
|
fn acord_dir() -> PathBuf {
|
||||||
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
|
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
|
||||||
PathBuf::from(home).join(".swiftly")
|
PathBuf::from(home).join(".acord")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cache_dir() -> PathBuf {
|
fn cache_dir() -> PathBuf {
|
||||||
swiftly_dir().join("cache")
|
acord_dir().join("cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn state_path() -> PathBuf {
|
fn state_path() -> PathBuf {
|
||||||
swiftly_dir().join("state.json")
|
acord_dir().join("state.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_dir(dir: &Path) -> io::Result<()> {
|
fn ensure_dir(dir: &Path) -> io::Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
window.titlebarAppearsTransparent = true
|
window.titlebarAppearsTransparent = true
|
||||||
window.titleVisibility = .hidden
|
window.titleVisibility = .hidden
|
||||||
window.backgroundColor = Theme.current.base
|
window.backgroundColor = Theme.current.base
|
||||||
window.title = "Swiftly"
|
window.title = "Acord"
|
||||||
window.contentView = viewport
|
window.contentView = viewport
|
||||||
window.center()
|
window.center()
|
||||||
window.setFrameAutosaveName("SwiftlyMainWindow")
|
window.setFrameAutosaveName("AcordMainWindow")
|
||||||
window.makeKeyAndOrderFront(nil)
|
window.makeKeyAndOrderFront(nil)
|
||||||
|
|
||||||
applyThemeAppearance()
|
applyThemeAppearance()
|
||||||
|
|
@ -114,13 +114,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
private func buildAppMenu() -> NSMenuItem {
|
private func buildAppMenu() -> NSMenuItem {
|
||||||
let item = NSMenuItem()
|
let item = NSMenuItem()
|
||||||
let menu = NSMenu()
|
let menu = NSMenu()
|
||||||
menu.addItem(withTitle: "About Swiftly", action: #selector(NSApplication.orderFrontStandardAboutPanel(_:)), keyEquivalent: "")
|
menu.addItem(withTitle: "About Acord", action: #selector(NSApplication.orderFrontStandardAboutPanel(_:)), keyEquivalent: "")
|
||||||
menu.addItem(.separator())
|
menu.addItem(.separator())
|
||||||
let settingsItem = NSMenuItem(title: "Settings...", action: #selector(openSettings), keyEquivalent: ",")
|
let settingsItem = NSMenuItem(title: "Settings...", action: #selector(openSettings), keyEquivalent: ",")
|
||||||
settingsItem.target = self
|
settingsItem.target = self
|
||||||
menu.addItem(settingsItem)
|
menu.addItem(settingsItem)
|
||||||
menu.addItem(.separator())
|
menu.addItem(.separator())
|
||||||
menu.addItem(withTitle: "Quit Swiftly", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
menu.addItem(withTitle: "Quit Acord", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
||||||
item.submenu = menu
|
item.submenu = menu
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
win.titlebarAppearsTransparent = true
|
win.titlebarAppearsTransparent = true
|
||||||
win.titleVisibility = .hidden
|
win.titleVisibility = .hidden
|
||||||
win.backgroundColor = Theme.current.base
|
win.backgroundColor = Theme.current.base
|
||||||
win.title = "Swiftly"
|
win.title = "Acord"
|
||||||
win.contentView = viewport
|
win.contentView = viewport
|
||||||
win.center()
|
win.center()
|
||||||
win.makeKeyAndOrderFront(nil)
|
win.makeKeyAndOrderFront(nil)
|
||||||
|
|
@ -502,7 +502,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
let clean = firstLine.replacingOccurrences(
|
let clean = firstLine.replacingOccurrences(
|
||||||
of: "^#+\\s*", with: "", options: .regularExpression
|
of: "^#+\\s*", with: "", options: .regularExpression
|
||||||
)
|
)
|
||||||
let displayTitle = clean.isEmpty ? "Swiftly" : String(clean.prefix(60))
|
let displayTitle = clean.isEmpty ? "Acord" : String(clean.prefix(60))
|
||||||
self.window.title = displayTitle
|
self.window.title = displayTitle
|
||||||
self.titleBarView?.title = firstLine
|
self.titleBarView?.title = firstLine
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ class AppState: ObservableObject {
|
||||||
private var autoSaveTimer: DispatchSourceTimer?
|
private var autoSaveTimer: DispatchSourceTimer?
|
||||||
private var autoSaveDirty = false
|
private var autoSaveDirty = false
|
||||||
private var autoSaveCoolingDown = false
|
private var autoSaveCoolingDown = false
|
||||||
private let autoSaveQueue = DispatchQueue(label: "com.swiftly.autosave")
|
private let autoSaveQueue = DispatchQueue(label: "com.acord.autosave")
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
let id = bridge.newDocument()
|
let id = bridge.newDocument()
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class ConfigManager {
|
||||||
|
|
||||||
private init() {
|
private init() {
|
||||||
let home = FileManager.default.homeDirectoryForCurrentUser
|
let home = FileManager.default.homeDirectoryForCurrentUser
|
||||||
configDir = home.appendingPathComponent(".swiftly")
|
configDir = home.appendingPathComponent(".acord")
|
||||||
configFile = configDir.appendingPathComponent("config.json")
|
configFile = configDir.appendingPathComponent("config.json")
|
||||||
defaultNotesDir = configDir.appendingPathComponent("notes")
|
defaultNotesDir = configDir.appendingPathComponent("notes")
|
||||||
config = [:]
|
config = [:]
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class DocumentBrowserController {
|
||||||
window.title = "Documents"
|
window.title = "Documents"
|
||||||
window.backgroundColor = Theme.current.base
|
window.backgroundColor = Theme.current.base
|
||||||
window.contentView = hostingView
|
window.contentView = hostingView
|
||||||
window.setFrameAutosaveName("SwiftlyBrowser")
|
window.setFrameAutosaveName("AcordBrowser")
|
||||||
window.center()
|
window.center()
|
||||||
window.isReleasedWhenClosed = false
|
window.isReleasedWhenClosed = false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class RustBridge {
|
||||||
private init() {}
|
private init() {}
|
||||||
|
|
||||||
func newDocument() -> UUID {
|
func newDocument() -> UUID {
|
||||||
let ptr = swiftly_doc_new()!
|
let ptr = acord_doc_new()!
|
||||||
let uuidStr = cacheSaveRaw(ptr)
|
let uuidStr = cacheSaveRaw(ptr)
|
||||||
let id = UUID(uuidString: uuidStr) ?? UUID()
|
let id = UUID(uuidString: uuidStr) ?? UUID()
|
||||||
docs[id] = ptr
|
docs[id] = ptr
|
||||||
|
|
@ -34,81 +34,81 @@ class RustBridge {
|
||||||
|
|
||||||
func freeDocument(_ id: UUID) {
|
func freeDocument(_ id: UUID) {
|
||||||
guard let ptr = docs.removeValue(forKey: id) else { return }
|
guard let ptr = docs.removeValue(forKey: id) else { return }
|
||||||
swiftly_doc_free(ptr)
|
acord_doc_free(ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setText(_ id: UUID, text: String) {
|
func setText(_ id: UUID, text: String) {
|
||||||
guard let ptr = docs[id] else { return }
|
guard let ptr = docs[id] else { return }
|
||||||
text.withCString { cstr in
|
text.withCString { cstr in
|
||||||
swiftly_doc_set_text(ptr, cstr)
|
acord_doc_set_text(ptr, cstr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getText(_ id: UUID) -> String {
|
func getText(_ id: UUID) -> String {
|
||||||
guard let ptr = docs[id] else { return "" }
|
guard let ptr = docs[id] else { return "" }
|
||||||
guard let cstr = swiftly_doc_get_text(ptr) else { return "" }
|
guard let cstr = acord_doc_get_text(ptr) else { return "" }
|
||||||
let str = String(cString: cstr)
|
let str = String(cString: cstr)
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
func evaluate(_ id: UUID) -> [Int: EvalEntry] {
|
func evaluate(_ id: UUID) -> [Int: EvalEntry] {
|
||||||
guard let ptr = docs[id] else { return [:] }
|
guard let ptr = docs[id] else { return [:] }
|
||||||
guard let cstr = swiftly_doc_evaluate(ptr) else { return [:] }
|
guard let cstr = acord_doc_evaluate(ptr) else { return [:] }
|
||||||
let json = String(cString: cstr)
|
let json = String(cString: cstr)
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return parseEvalJSON(json)
|
return parseEvalJSON(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
func evaluateLine(_ line: String) -> String {
|
func evaluateLine(_ line: String) -> String {
|
||||||
guard let cstr = line.withCString({ swiftly_eval_line($0) }) else { return "" }
|
guard let cstr = line.withCString({ acord_eval_line($0) }) else { return "" }
|
||||||
let str = String(cString: cstr)
|
let str = String(cString: cstr)
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveNote(_ id: UUID, path: String) -> Bool {
|
func saveNote(_ id: UUID, path: String) -> Bool {
|
||||||
guard let ptr = docs[id] else { return false }
|
guard let ptr = docs[id] else { return false }
|
||||||
return path.withCString { cstr in
|
return path.withCString { cstr in
|
||||||
swiftly_doc_save(ptr, cstr)
|
acord_doc_save(ptr, cstr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadNote(path: String) -> (UUID, String)? {
|
func loadNote(path: String) -> (UUID, String)? {
|
||||||
guard let ptr = path.withCString({ swiftly_doc_load($0) }) else { return nil }
|
guard let ptr = path.withCString({ acord_doc_load($0) }) else { return nil }
|
||||||
let uuidStr = cacheSaveRaw(ptr)
|
let uuidStr = cacheSaveRaw(ptr)
|
||||||
guard let id = UUID(uuidString: uuidStr) else {
|
guard let id = UUID(uuidString: uuidStr) else {
|
||||||
swiftly_doc_free(ptr)
|
acord_doc_free(ptr)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if let old = docs[id] { swiftly_doc_free(old) }
|
if let old = docs[id] { acord_doc_free(old) }
|
||||||
docs[id] = ptr
|
docs[id] = ptr
|
||||||
|
|
||||||
guard let cstr = swiftly_doc_get_text(ptr) else { return (id, "") }
|
guard let cstr = acord_doc_get_text(ptr) else { return (id, "") }
|
||||||
let text = String(cString: cstr)
|
let text = String(cString: cstr)
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return (id, text)
|
return (id, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cacheSave(_ id: UUID) -> Bool {
|
func cacheSave(_ id: UUID) -> Bool {
|
||||||
guard let ptr = docs[id] else { return false }
|
guard let ptr = docs[id] else { return false }
|
||||||
guard let cstr = swiftly_cache_save(ptr) else { return false }
|
guard let cstr = acord_cache_save(ptr) else { return false }
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func cacheLoad(_ id: UUID) -> Bool {
|
func cacheLoad(_ id: UUID) -> Bool {
|
||||||
let uuidStr = id.uuidString.lowercased()
|
let uuidStr = id.uuidString.lowercased()
|
||||||
guard let ptr = uuidStr.withCString({ swiftly_cache_load($0) }) else { return false }
|
guard let ptr = uuidStr.withCString({ acord_cache_load($0) }) else { return false }
|
||||||
if let old = docs[id] { swiftly_doc_free(old) }
|
if let old = docs[id] { acord_doc_free(old) }
|
||||||
docs[id] = ptr
|
docs[id] = ptr
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func listNotes() -> [NoteInfo] {
|
func listNotes() -> [NoteInfo] {
|
||||||
guard let cstr = swiftly_list_notes() else { return [] }
|
guard let cstr = acord_list_notes() else { return [] }
|
||||||
let json = String(cString: cstr)
|
let json = String(cString: cstr)
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return parseNoteListJSON(json)
|
return parseNoteListJSON(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,11 +121,11 @@ class RustBridge {
|
||||||
func highlight(source: String, lang: String) -> [HighlightSpan] {
|
func highlight(source: String, lang: String) -> [HighlightSpan] {
|
||||||
guard let cstr = source.withCString({ src in
|
guard let cstr = source.withCString({ src in
|
||||||
lang.withCString({ lng in
|
lang.withCString({ lng in
|
||||||
swiftly_highlight(src, lng)
|
acord_highlight(src, lng)
|
||||||
})
|
})
|
||||||
}) else { return [] }
|
}) else { return [] }
|
||||||
let json = String(cString: cstr)
|
let json = String(cString: cstr)
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return parseHighlightJSON(json)
|
return parseHighlightJSON(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ class RustBridge {
|
||||||
func deleteNote(_ id: UUID) {
|
func deleteNote(_ id: UUID) {
|
||||||
freeDocument(id)
|
freeDocument(id)
|
||||||
let cacheDir = FileManager.default.homeDirectoryForCurrentUser
|
let cacheDir = FileManager.default.homeDirectoryForCurrentUser
|
||||||
.appendingPathComponent(".swiftly/cache")
|
.appendingPathComponent(".acord/cache")
|
||||||
let cacheFile = cacheDir.appendingPathComponent("\(id.uuidString.lowercased()).sw")
|
let cacheFile = cacheDir.appendingPathComponent("\(id.uuidString.lowercased()).sw")
|
||||||
try? FileManager.default.removeItem(at: cacheFile)
|
try? FileManager.default.removeItem(at: cacheFile)
|
||||||
}
|
}
|
||||||
|
|
@ -153,9 +153,9 @@ class RustBridge {
|
||||||
// MARK: - Internal
|
// MARK: - Internal
|
||||||
|
|
||||||
private func cacheSaveRaw(_ ptr: OpaquePointer) -> String {
|
private func cacheSaveRaw(_ ptr: OpaquePointer) -> String {
|
||||||
guard let cstr = swiftly_cache_save(ptr) else { return UUID().uuidString }
|
guard let cstr = acord_cache_save(ptr) else { return UUID().uuidString }
|
||||||
let str = String(cString: cstr)
|
let str = String(cString: cstr)
|
||||||
swiftly_free_string(cstr)
|
acord_free_string(cstr)
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "swiftly-viewport"
|
name = "acord-viewport"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||||
crate-type = ["staticlib", "rlib"]
|
crate-type = ["staticlib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
swiftly-core = { path = "../core" }
|
acord-core = { path = "../core" }
|
||||||
iced_wgpu = "0.14"
|
iced_wgpu = "0.14"
|
||||||
iced_graphics = "0.14"
|
iced_graphics = "0.14"
|
||||||
iced_runtime = "0.14"
|
iced_runtime = "0.14"
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@ fn main() {
|
||||||
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
cbindgen::generate(&crate_dir)
|
cbindgen::generate(&crate_dir)
|
||||||
.expect("cbindgen failed")
|
.expect("cbindgen failed")
|
||||||
.write_to_file(format!("{}/include/swiftly.h", crate_dir));
|
.write_to_file(format!("{}/include/acord.h", crate_dir));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
language = "C"
|
language = "C"
|
||||||
include_guard = "SWIFTLY_VIEWPORT_H"
|
include_guard = "ACORD_VIEWPORT_H"
|
||||||
header = """
|
header = """
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../../core/include/swiftly.h"
|
#include "../../core/include/acord.h"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[parse]
|
[parse]
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../../core/include/swiftly.h"
|
#include "../../core/include/acord.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef SWIFTLY_VIEWPORT_H
|
#ifndef ACORD_VIEWPORT_H
|
||||||
#define SWIFTLY_VIEWPORT_H
|
#define ACORD_VIEWPORT_H
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
@ -49,4 +49,4 @@ char *viewport_get_text(struct ViewportHandle *handle);
|
||||||
|
|
||||||
void viewport_free_string(char *s);
|
void viewport_free_string(char *s);
|
||||||
|
|
||||||
#endif /* SWIFTLY_VIEWPORT_H */
|
#endif /* ACORD_VIEWPORT_H */
|
||||||
|
|
@ -5,7 +5,7 @@ mod editor;
|
||||||
mod handle;
|
mod handle;
|
||||||
mod syntax;
|
mod syntax;
|
||||||
|
|
||||||
pub use swiftly_core::*;
|
pub use acord_core::*;
|
||||||
|
|
||||||
use editor::EditorState;
|
use editor::EditorState;
|
||||||
use iced_graphics::Viewport;
|
use iced_graphics::Viewport;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::ops::Range;
|
||||||
|
|
||||||
use iced_wgpu::core::text::highlighter;
|
use iced_wgpu::core::text::highlighter;
|
||||||
use iced_wgpu::core::Color;
|
use iced_wgpu::core::Color;
|
||||||
use swiftly_core::highlight::{highlight_source, HighlightSpan};
|
use acord_core::highlight::{highlight_source, HighlightSpan};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct SyntaxSettings {
|
pub struct SyntaxSettings {
|
||||||
|
|
|
||||||