diff --git a/Info.plist b/Info.plist index a23af44..87174e8 100644 --- a/Info.plist +++ b/Info.plist @@ -3,13 +3,13 @@ CFBundleExecutable - Swiftly + Acord CFBundleIdentifier - org.else-if.swiftly + org.else-if.acord CFBundleName - Swiftly + Acord CFBundleDisplayName - Swiftly + Acord CFBundlePackageType APPL CFBundleVersion diff --git a/assets/Acord.svg b/assets/Acord.svg new file mode 100644 index 0000000..1c57e74 --- /dev/null +++ b/assets/Acord.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/assets/icon_sources/Swiftly_icons.png b/assets/icon_sources/Swiftly_icons.png deleted file mode 100644 index a9c18af..0000000 Binary files a/assets/icon_sources/Swiftly_icons.png and /dev/null differ diff --git a/assets/icon_sources/Swiftly_icons@16x.png b/assets/icon_sources/Swiftly_icons@16x.png deleted file mode 100644 index a8ac66c..0000000 Binary files a/assets/icon_sources/Swiftly_icons@16x.png and /dev/null differ diff --git a/assets/icon_sources/Swiftly_icons@2x.png b/assets/icon_sources/Swiftly_icons@2x.png deleted file mode 100644 index 330b2f3..0000000 Binary files a/assets/icon_sources/Swiftly_icons@2x.png and /dev/null differ diff --git a/assets/icon_sources/Swiftly_icons@32.png b/assets/icon_sources/Swiftly_icons@32.png deleted file mode 100644 index 09060b1..0000000 Binary files a/assets/icon_sources/Swiftly_icons@32.png and /dev/null differ diff --git a/assets/icon_sources/Swiftly_icons@4x.png b/assets/icon_sources/Swiftly_icons@4x.png deleted file mode 100644 index 5e2c72f..0000000 Binary files a/assets/icon_sources/Swiftly_icons@4x.png and /dev/null differ diff --git a/assets/icon_sources/Swiftly_icons@64.png b/assets/icon_sources/Swiftly_icons@64.png deleted file mode 100644 index 67da30e..0000000 Binary files a/assets/icon_sources/Swiftly_icons@64.png and /dev/null differ diff --git a/assets/icon_sources/Swiftly_icons@6x.png b/assets/icon_sources/Swiftly_icons@6x.png deleted file mode 100644 index f8bdf47..0000000 Binary files a/assets/icon_sources/Swiftly_icons@6x.png and /dev/null differ diff --git a/assets/icon_sources/Swiftly_icons@8x.png b/assets/icon_sources/Swiftly_icons@8x.png deleted file mode 100644 index cc0e3aa..0000000 Binary files a/assets/icon_sources/Swiftly_icons@8x.png and /dev/null differ diff --git a/build.sh b/build.sh index 779660e..62a94b0 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")" && pwd)" BUILD="$ROOT/build" -APP="$BUILD/bin/Swiftly.app" +APP="$BUILD/bin/Acord.app" CONTENTS="$APP/Contents" MACOS="$CONTENTS/MacOS" RESOURCES="$CONTENTS/Resources" @@ -14,35 +14,39 @@ RUST_LIB="$ROOT/target/release" export MACOSX_DEPLOYMENT_TARGET=14.0 export ZERO_AR_DATE=0 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 echo "ERROR: Rust build failed" exit 1 fi -if [ ! -f "$RUST_LIB/libswiftly_viewport.a" ]; then - echo "ERROR: libswiftly_viewport.a not found at $RUST_LIB" +if [ ! -f "$RUST_LIB/libacord_viewport.a" ]; then + echo "ERROR: libacord_viewport.a not found at $RUST_LIB" exit 1 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 --- -ICONS="$ROOT/assets/icon_sources" -if [ -d "$ICONS" ]; then +# --- App icon from SVG via rsvg-convert --- +SVG="$ROOT/assets/Acord.svg" +if [ -f "$SVG" ]; then echo "Generating app icon..." ICONSET="$BUILD/AppIcon.iconset" mkdir -p "$ICONSET" - cp "$ICONS/Swiftly_icons.png" "$ICONSET/icon_16x16.png" - cp "$ICONS/Swiftly_icons@2x.png" "$ICONSET/icon_16x16@2x.png" - cp "$ICONS/Swiftly_icons@2x.png" "$ICONSET/icon_32x32.png" - cp "$ICONS/Swiftly_icons@4x.png" "$ICONSET/icon_32x32@2x.png" - cp "$ICONS/Swiftly_icons@8x.png" "$ICONSET/icon_128x128.png" - cp "$ICONS/Swiftly_icons@16x.png" "$ICONSET/icon_128x128@2x.png" - cp "$ICONS/Swiftly_icons@16x.png" "$ICONSET/icon_256x256.png" - cp "$ICONS/Swiftly_icons@32.png" "$ICONSET/icon_256x256@2x.png" - cp "$ICONS/Swiftly_icons@32.png" "$ICONSET/icon_512x512.png" - cp "$ICONS/Swiftly_icons@64.png" "$ICONSET/icon_512x512@2x.png" + for size in 16 32 64 128 256 512 1024; do + rsvg-convert --width="$size" --height="$size" "$SVG" -o "$ICONSET/icon_${size}.png" + done + cp "$ICONSET/icon_16.png" "$ICONSET/icon_16x16.png" + cp "$ICONSET/icon_32.png" "$ICONSET/icon_16x16@2x.png" + cp "$ICONSET/icon_32.png" "$ICONSET/icon_32x32.png" + cp "$ICONSET/icon_64.png" "$ICONSET/icon_32x32@2x.png" + cp "$ICONSET/icon_128.png" "$ICONSET/icon_128x128.png" + cp "$ICONSET/icon_256.png" "$ICONSET/icon_128x128@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" rm -rf "$ICONSET" fi @@ -68,7 +72,7 @@ swiftc \ -framework CoreGraphics \ -framework CoreFoundation \ -O \ - -o "$MACOS/Swiftly" \ + -o "$MACOS/Acord" \ "$ROOT"/src/*.swift # --- Code sign --- diff --git a/core/Cargo.toml b/core/Cargo.toml index 582e3d6..b13e069 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "swiftly-core" +name = "acord-core" version = "0.1.0" edition = "2021" diff --git a/core/build.rs b/core/build.rs index baf8f64..eb72532 100644 --- a/core/build.rs +++ b/core/build.rs @@ -10,7 +10,7 @@ fn main() { .generate() { Ok(bindings) => { - let path = format!("{}/include/swiftly.h", crate_dir); + let path = format!("{}/include/acord.h", crate_dir); bindings.write_to_file(&path); println!("cargo:warning=cbindgen: wrote {}", path); } diff --git a/core/include/acord.h b/core/include/acord.h new file mode 100644 index 0000000..f2645ef --- /dev/null +++ b/core/include/acord.h @@ -0,0 +1,39 @@ +/* Generated by cbindgen — do not edit */ + +#ifndef SWIFTLY_H +#define SWIFTLY_H + +#include +#include +#include +#include + +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 */ diff --git a/core/include/swiftly.h b/core/include/swiftly.h deleted file mode 100644 index 391552f..0000000 --- a/core/include/swiftly.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Generated by cbindgen — do not edit */ - -#ifndef SWIFTLY_H -#define SWIFTLY_H - -#include -#include -#include -#include - -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 */ diff --git a/core/src/document.rs b/core/src/document.rs index 99d22ab..6c3f616 100644 --- a/core/src/document.rs +++ b/core/src/document.rs @@ -1,15 +1,15 @@ use crate::doc::{classify_document, ClassifiedLine}; use crate::eval::{evaluate_document, DocumentResult}; -pub struct SwiftlyDoc { +pub struct AcordDoc { pub text: String, pub uuid: String, lines: Vec, } -impl SwiftlyDoc { +impl AcordDoc { pub fn new() -> Self { - SwiftlyDoc { + AcordDoc { text: String::new(), uuid: uuid::Uuid::new_v4().to_string(), lines: Vec::new(), @@ -17,7 +17,7 @@ impl SwiftlyDoc { } pub fn with_uuid(uuid: String) -> Self { - SwiftlyDoc { + AcordDoc { text: String::new(), uuid, lines: Vec::new(), diff --git a/core/src/ffi.rs b/core/src/ffi.rs index bf49c5c..e8d9f4b 100644 --- a/core/src/ffi.rs +++ b/core/src/ffi.rs @@ -2,7 +2,7 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::path::Path; -use crate::document::SwiftlyDoc; +use crate::document::AcordDoc; use crate::eval; use crate::highlight; use crate::persist; @@ -17,18 +17,18 @@ fn str_to_cstr(s: &str) -> *mut c_char { } #[no_mangle] -pub extern "C" fn swiftly_doc_new() -> *mut SwiftlyDoc { - Box::into_raw(Box::new(SwiftlyDoc::new())) +pub extern "C" fn acord_doc_new() -> *mut AcordDoc { + Box::into_raw(Box::new(AcordDoc::new())) } #[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; } unsafe { drop(Box::from_raw(doc)); } } #[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() } { Some(d) => d, None => return, @@ -41,7 +41,7 @@ pub extern "C" fn swiftly_doc_set_text(doc: *mut SwiftlyDoc, text: *const c_char } #[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() } { Some(d) => d, 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] -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() } { Some(d) => d, None => return str_to_cstr("[]"), @@ -61,7 +61,7 @@ pub extern "C" fn swiftly_doc_evaluate(doc: *mut SwiftlyDoc) -> *mut c_char { } #[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) { Some(s) => s, 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] -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() } { Some(d) => d, None => return false, @@ -86,14 +86,14 @@ pub extern "C" fn swiftly_doc_save(doc: *const SwiftlyDoc, path: *const c_char) } #[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) { Some(s) => s, None => return std::ptr::null_mut(), }; match persist::load_from_file(Path::new(path)) { Ok(text) => { - let mut doc = SwiftlyDoc::new(); + let mut doc = AcordDoc::new(); doc.set_text(&text); 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] -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() } { Some(d) => d, 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] -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) { Some(s) => s, None => return std::ptr::null_mut(), }; match persist::cache_load(uuid) { Ok(text) => { - let mut doc = SwiftlyDoc::with_uuid(uuid.to_string()); + let mut doc = AcordDoc::with_uuid(uuid.to_string()); doc.set_text(&text); 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] -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 json = serde_json::to_string(¬es).unwrap_or_else(|_| "[]".into()); str_to_cstr(&json) } #[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) { Some(s) => s, 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] -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; } unsafe { drop(CString::from_raw(s)); } } diff --git a/core/src/persist.rs b/core/src/persist.rs index 3642a0c..0e82cab 100644 --- a/core/src/persist.rs +++ b/core/src/persist.rs @@ -55,17 +55,17 @@ impl StateIndex { } } -fn swiftly_dir() -> PathBuf { +fn acord_dir() -> PathBuf { let home = std::env::var("HOME").unwrap_or_else(|_| ".".into()); - PathBuf::from(home).join(".swiftly") + PathBuf::from(home).join(".acord") } fn cache_dir() -> PathBuf { - swiftly_dir().join("cache") + acord_dir().join("cache") } fn state_path() -> PathBuf { - swiftly_dir().join("state.json") + acord_dir().join("state.json") } fn ensure_dir(dir: &Path) -> io::Result<()> { diff --git a/src/AppDelegate.swift b/src/AppDelegate.swift index 90b634a..570bfc2 100644 --- a/src/AppDelegate.swift +++ b/src/AppDelegate.swift @@ -51,10 +51,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { window.titlebarAppearsTransparent = true window.titleVisibility = .hidden window.backgroundColor = Theme.current.base - window.title = "Swiftly" + window.title = "Acord" window.contentView = viewport window.center() - window.setFrameAutosaveName("SwiftlyMainWindow") + window.setFrameAutosaveName("AcordMainWindow") window.makeKeyAndOrderFront(nil) applyThemeAppearance() @@ -114,13 +114,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { private func buildAppMenu() -> NSMenuItem { let item = NSMenuItem() 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()) let settingsItem = NSMenuItem(title: "Settings...", action: #selector(openSettings), keyEquivalent: ",") settingsItem.target = self menu.addItem(settingsItem) 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 return item } @@ -265,7 +265,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { win.titlebarAppearsTransparent = true win.titleVisibility = .hidden win.backgroundColor = Theme.current.base - win.title = "Swiftly" + win.title = "Acord" win.contentView = viewport win.center() win.makeKeyAndOrderFront(nil) @@ -502,7 +502,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let clean = firstLine.replacingOccurrences( 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.titleBarView?.title = firstLine } diff --git a/src/AppState.swift b/src/AppState.swift index 0765ae6..b4db5bd 100644 --- a/src/AppState.swift +++ b/src/AppState.swift @@ -131,7 +131,7 @@ class AppState: ObservableObject { private var autoSaveTimer: DispatchSourceTimer? private var autoSaveDirty = false private var autoSaveCoolingDown = false - private let autoSaveQueue = DispatchQueue(label: "com.swiftly.autosave") + private let autoSaveQueue = DispatchQueue(label: "com.acord.autosave") init() { let id = bridge.newDocument() diff --git a/src/ConfigManager.swift b/src/ConfigManager.swift index 5905b79..d23fd3e 100644 --- a/src/ConfigManager.swift +++ b/src/ConfigManager.swift @@ -10,7 +10,7 @@ class ConfigManager { private init() { let home = FileManager.default.homeDirectoryForCurrentUser - configDir = home.appendingPathComponent(".swiftly") + configDir = home.appendingPathComponent(".acord") configFile = configDir.appendingPathComponent("config.json") defaultNotesDir = configDir.appendingPathComponent("notes") config = [:] diff --git a/src/DocumentBrowserWindow.swift b/src/DocumentBrowserWindow.swift index 246a89b..1fa5679 100644 --- a/src/DocumentBrowserWindow.swift +++ b/src/DocumentBrowserWindow.swift @@ -50,7 +50,7 @@ class DocumentBrowserController { window.title = "Documents" window.backgroundColor = Theme.current.base window.contentView = hostingView - window.setFrameAutosaveName("SwiftlyBrowser") + window.setFrameAutosaveName("AcordBrowser") window.center() window.isReleasedWhenClosed = false } diff --git a/src/RustBridge.swift b/src/RustBridge.swift index 7eff7da..544b1bf 100644 --- a/src/RustBridge.swift +++ b/src/RustBridge.swift @@ -25,7 +25,7 @@ class RustBridge { private init() {} func newDocument() -> UUID { - let ptr = swiftly_doc_new()! + let ptr = acord_doc_new()! let uuidStr = cacheSaveRaw(ptr) let id = UUID(uuidString: uuidStr) ?? UUID() docs[id] = ptr @@ -34,81 +34,81 @@ class RustBridge { func freeDocument(_ id: UUID) { guard let ptr = docs.removeValue(forKey: id) else { return } - swiftly_doc_free(ptr) + acord_doc_free(ptr) } func setText(_ id: UUID, text: String) { guard let ptr = docs[id] else { return } text.withCString { cstr in - swiftly_doc_set_text(ptr, cstr) + acord_doc_set_text(ptr, cstr) } } func getText(_ id: UUID) -> String { 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) - swiftly_free_string(cstr) + acord_free_string(cstr) return str } func evaluate(_ id: UUID) -> [Int: EvalEntry] { 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) - swiftly_free_string(cstr) + acord_free_string(cstr) return parseEvalJSON(json) } 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) - swiftly_free_string(cstr) + acord_free_string(cstr) return str } func saveNote(_ id: UUID, path: String) -> Bool { guard let ptr = docs[id] else { return false } return path.withCString { cstr in - swiftly_doc_save(ptr, cstr) + acord_doc_save(ptr, cstr) } } 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) guard let id = UUID(uuidString: uuidStr) else { - swiftly_doc_free(ptr) + acord_doc_free(ptr) return nil } - if let old = docs[id] { swiftly_doc_free(old) } + if let old = docs[id] { acord_doc_free(old) } 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) - swiftly_free_string(cstr) + acord_free_string(cstr) return (id, text) } func cacheSave(_ id: UUID) -> Bool { guard let ptr = docs[id] else { return false } - guard let cstr = swiftly_cache_save(ptr) else { return false } - swiftly_free_string(cstr) + guard let cstr = acord_cache_save(ptr) else { return false } + acord_free_string(cstr) return true } func cacheLoad(_ id: UUID) -> Bool { let uuidStr = id.uuidString.lowercased() - guard let ptr = uuidStr.withCString({ swiftly_cache_load($0) }) else { return false } - if let old = docs[id] { swiftly_doc_free(old) } + guard let ptr = uuidStr.withCString({ acord_cache_load($0) }) else { return false } + if let old = docs[id] { acord_doc_free(old) } docs[id] = ptr return true } func listNotes() -> [NoteInfo] { - guard let cstr = swiftly_list_notes() else { return [] } + guard let cstr = acord_list_notes() else { return [] } let json = String(cString: cstr) - swiftly_free_string(cstr) + acord_free_string(cstr) return parseNoteListJSON(json) } @@ -121,11 +121,11 @@ class RustBridge { func highlight(source: String, lang: String) -> [HighlightSpan] { guard let cstr = source.withCString({ src in lang.withCString({ lng in - swiftly_highlight(src, lng) + acord_highlight(src, lng) }) }) else { return [] } let json = String(cString: cstr) - swiftly_free_string(cstr) + acord_free_string(cstr) return parseHighlightJSON(json) } @@ -145,7 +145,7 @@ class RustBridge { func deleteNote(_ id: UUID) { freeDocument(id) let cacheDir = FileManager.default.homeDirectoryForCurrentUser - .appendingPathComponent(".swiftly/cache") + .appendingPathComponent(".acord/cache") let cacheFile = cacheDir.appendingPathComponent("\(id.uuidString.lowercased()).sw") try? FileManager.default.removeItem(at: cacheFile) } @@ -153,9 +153,9 @@ class RustBridge { // MARK: - Internal 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) - swiftly_free_string(cstr) + acord_free_string(cstr) return str } diff --git a/viewport/Cargo.toml b/viewport/Cargo.toml index d673648..4f0235e 100644 --- a/viewport/Cargo.toml +++ b/viewport/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "swiftly-viewport" +name = "acord-viewport" version = "0.1.0" edition = "2021" @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["staticlib", "rlib"] [dependencies] -swiftly-core = { path = "../core" } +acord-core = { path = "../core" } iced_wgpu = "0.14" iced_graphics = "0.14" iced_runtime = "0.14" diff --git a/viewport/build.rs b/viewport/build.rs index 5bd5125..43745ae 100644 --- a/viewport/build.rs +++ b/viewport/build.rs @@ -2,5 +2,5 @@ fn main() { let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); cbindgen::generate(&crate_dir) .expect("cbindgen failed") - .write_to_file(format!("{}/include/swiftly.h", crate_dir)); + .write_to_file(format!("{}/include/acord.h", crate_dir)); } diff --git a/viewport/cbindgen.toml b/viewport/cbindgen.toml index 9289213..81362a3 100644 --- a/viewport/cbindgen.toml +++ b/viewport/cbindgen.toml @@ -1,11 +1,11 @@ language = "C" -include_guard = "SWIFTLY_VIEWPORT_H" +include_guard = "ACORD_VIEWPORT_H" header = """ #include #include #include #include -#include "../../core/include/swiftly.h" +#include "../../core/include/acord.h" """ [parse] diff --git a/viewport/include/swiftly.h b/viewport/include/acord.h similarity index 91% rename from viewport/include/swiftly.h rename to viewport/include/acord.h index 9c0a654..3f4e2f2 100644 --- a/viewport/include/swiftly.h +++ b/viewport/include/acord.h @@ -2,11 +2,11 @@ #include #include #include -#include "../../core/include/swiftly.h" +#include "../../core/include/acord.h" -#ifndef SWIFTLY_VIEWPORT_H -#define SWIFTLY_VIEWPORT_H +#ifndef ACORD_VIEWPORT_H +#define ACORD_VIEWPORT_H #include #include @@ -49,4 +49,4 @@ char *viewport_get_text(struct ViewportHandle *handle); void viewport_free_string(char *s); -#endif /* SWIFTLY_VIEWPORT_H */ +#endif /* ACORD_VIEWPORT_H */ diff --git a/viewport/src/lib.rs b/viewport/src/lib.rs index 15b44f8..b8fea4b 100644 --- a/viewport/src/lib.rs +++ b/viewport/src/lib.rs @@ -5,7 +5,7 @@ mod editor; mod handle; mod syntax; -pub use swiftly_core::*; +pub use acord_core::*; use editor::EditorState; use iced_graphics::Viewport; diff --git a/viewport/src/syntax.rs b/viewport/src/syntax.rs index 69fb975..23cf0be 100644 --- a/viewport/src/syntax.rs +++ b/viewport/src/syntax.rs @@ -2,7 +2,7 @@ use std::ops::Range; use iced_wgpu::core::text::highlighter; use iced_wgpu::core::Color; -use swiftly_core::highlight::{highlight_source, HighlightSpan}; +use acord_core::highlight::{highlight_source, HighlightSpan}; #[derive(Clone, PartialEq)] pub struct SyntaxSettings {