rename to Acord, add SVG icon with rsvg build
|
|
@ -3,13 +3,13 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Swiftly</string>
|
||||
<string>Acord</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.else-if.swiftly</string>
|
||||
<string>org.else-if.acord</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Swiftly</string>
|
||||
<string>Acord</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Swiftly</string>
|
||||
<string>Acord</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<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)"
|
||||
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 ---
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "swiftly-core"
|
||||
name = "acord-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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::eval::{evaluate_document, DocumentResult};
|
||||
|
||||
pub struct SwiftlyDoc {
|
||||
pub struct AcordDoc {
|
||||
pub text: String,
|
||||
pub uuid: String,
|
||||
lines: Vec<ClassifiedLine>,
|
||||
}
|
||||
|
||||
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(),
|
||||
|
|
|
|||
|
|
@ -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)); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<()> {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 = [:]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
language = "C"
|
||||
include_guard = "SWIFTLY_VIEWPORT_H"
|
||||
include_guard = "ACORD_VIEWPORT_H"
|
||||
header = """
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "../../core/include/swiftly.h"
|
||||
#include "../../core/include/acord.h"
|
||||
"""
|
||||
|
||||
[parse]
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#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 <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||