This commit is contained in:
Generated
+2
-11
@@ -910,14 +910,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "editor"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"egui",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eframe"
|
name = "eframe"
|
||||||
version = "0.32.0"
|
version = "0.32.0"
|
||||||
@@ -3408,9 +3400,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.140"
|
version = "1.0.141"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -4925,7 +4917,6 @@ name = "worldcoder"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"editor",
|
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
"egui_commonmark",
|
"egui_commonmark",
|
||||||
|
|||||||
+1
-2
@@ -6,7 +6,6 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = "0.32.0"
|
eframe = "0.32.0"
|
||||||
egui = { version = "0.32.0", features = ["serde"] }
|
egui = { version = "0.32.0", features = ["serde"] }
|
||||||
editor = { path = "./editor" }
|
|
||||||
egui_extras = { version = "0.32.0", features = [
|
egui_extras = { version = "0.32.0", features = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"datepicker",
|
"datepicker",
|
||||||
@@ -16,7 +15,7 @@ egui_extras = { version = "0.32.0", features = [
|
|||||||
egui_file = "0.23.0"
|
egui_file = "0.23.0"
|
||||||
image = { version = "0.25.6", features = ["jpeg", "png"] }
|
image = { version = "0.25.6", features = ["jpeg", "png"] }
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.141"
|
||||||
chrono = { version = "0.4.41", features = ["serde"] }
|
chrono = { version = "0.4.41", features = ["serde"] }
|
||||||
thiserror = "2.0.12"
|
thiserror = "2.0.12"
|
||||||
egui_commonmark = { version = "0.21.1", features = ["embedded_image"] }
|
egui_commonmark = { version = "0.21.1", features = ["embedded_image"] }
|
||||||
|
|||||||
Generated
-354
@@ -1,354 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 4
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ab_glyph"
|
|
||||||
version = "0.2.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e0f4f6fbdc5ee39f2ede9f5f3ec79477271a6d6a2baff22310d51736bda6cea"
|
|
||||||
dependencies = [
|
|
||||||
"ab_glyph_rasterizer",
|
|
||||||
"owned_ttf_parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ab_glyph_rasterizer"
|
|
||||||
version = "0.1.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b2187590a23ab1e3df8681afdf0987c48504d80291f002fcdb651f0ef5e25169"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ahash"
|
|
||||||
version = "0.8.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"once_cell",
|
|
||||||
"version_check",
|
|
||||||
"zerocopy",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "autocfg"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "2.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ecolor"
|
|
||||||
version = "0.32.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4a631732d995184114016fab22fc7e3faf73d6841c2d7650395fe251fbcd9285"
|
|
||||||
dependencies = [
|
|
||||||
"emath",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "editor"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"egui",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "egui"
|
|
||||||
version = "0.32.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8470210c95a42cc985d9ffebfd5067eea55bdb1c3f7611484907db9639675e28"
|
|
||||||
dependencies = [
|
|
||||||
"ahash",
|
|
||||||
"bitflags",
|
|
||||||
"emath",
|
|
||||||
"epaint",
|
|
||||||
"nohash-hasher",
|
|
||||||
"profiling",
|
|
||||||
"smallvec",
|
|
||||||
"unicode-segmentation",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "emath"
|
|
||||||
version = "0.32.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "45f057b141e7e46340c321400be74b793543b1b213036f0f989c35d35957c32e"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "epaint"
|
|
||||||
version = "0.32.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "94cca02195f0552c17cabdc02f39aa9ab6fbd815dac60ab1cd3d5b0aa6f9551c"
|
|
||||||
dependencies = [
|
|
||||||
"ab_glyph",
|
|
||||||
"ahash",
|
|
||||||
"ecolor",
|
|
||||||
"emath",
|
|
||||||
"epaint_default_fonts",
|
|
||||||
"nohash-hasher",
|
|
||||||
"parking_lot",
|
|
||||||
"profiling",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "epaint_default_fonts"
|
|
||||||
version = "0.32.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e8495e11ed527dff39663b8c36b6c2b2799d7e4287fb90556e455d72eca0b4d3"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.174"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lock_api"
|
|
||||||
version = "0.4.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"scopeguard",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nohash-hasher"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell"
|
|
||||||
version = "1.21.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "owned_ttf_parser"
|
|
||||||
version = "0.25.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "22ec719bbf3b2a81c109a4e20b1f129b5566b7dce654bc3872f6a05abf82b2c4"
|
|
||||||
dependencies = [
|
|
||||||
"ttf-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parking_lot"
|
|
||||||
version = "0.12.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
|
|
||||||
dependencies = [
|
|
||||||
"lock_api",
|
|
||||||
"parking_lot_core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parking_lot_core"
|
|
||||||
version = "0.9.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"redox_syscall",
|
|
||||||
"smallvec",
|
|
||||||
"windows-targets",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.95"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "profiling"
|
|
||||||
version = "1.0.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.40"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_syscall"
|
|
||||||
version = "0.5.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "scopeguard"
|
|
||||||
version = "1.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde"
|
|
||||||
version = "1.0.219"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
|
||||||
dependencies = [
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.219"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "smallvec"
|
|
||||||
version = "1.15.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "2.0.104"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ttf-parser"
|
|
||||||
version = "0.25.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-ident"
|
|
||||||
version = "1.0.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-segmentation"
|
|
||||||
version = "1.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "version_check"
|
|
||||||
version = "0.9.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-targets"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
|
||||||
dependencies = [
|
|
||||||
"windows_aarch64_gnullvm",
|
|
||||||
"windows_aarch64_msvc",
|
|
||||||
"windows_i686_gnu",
|
|
||||||
"windows_i686_gnullvm",
|
|
||||||
"windows_i686_msvc",
|
|
||||||
"windows_x86_64_gnu",
|
|
||||||
"windows_x86_64_gnullvm",
|
|
||||||
"windows_x86_64_msvc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnu"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnu"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zerocopy"
|
|
||||||
version = "0.8.26"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
|
|
||||||
dependencies = [
|
|
||||||
"zerocopy-derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zerocopy-derive"
|
|
||||||
version = "0.8.26"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "editor"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
description = "a basic text editor widget with line numbers"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
egui = "0.32.0"
|
|
||||||
serde = "1"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "editor"
|
|
||||||
path = "src/lib.rs"
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
use egui::Color32;
|
|
||||||
use egui::TextBuffer;
|
|
||||||
use egui::widgets::text_edit::TextEditOutput;
|
|
||||||
|
|
||||||
use std::hash::{Hash, Hasher};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
|
||||||
/// CodeEditor struct which stores settings for highlighting.
|
|
||||||
pub struct CodeEditor {
|
|
||||||
id: String,
|
|
||||||
numlines: bool,
|
|
||||||
numlines_shift: isize,
|
|
||||||
numlines_only_natural: bool,
|
|
||||||
fontsize: f32,
|
|
||||||
stick_to_bottom: bool,
|
|
||||||
desired_width: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Hash for CodeEditor {
|
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
||||||
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
|
|
||||||
(self.fontsize as u32).hash(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for CodeEditor {
|
|
||||||
fn default() -> CodeEditor {
|
|
||||||
CodeEditor {
|
|
||||||
id: String::from("Code Editor"),
|
|
||||||
numlines: true,
|
|
||||||
numlines_shift: 0,
|
|
||||||
numlines_only_natural: false,
|
|
||||||
fontsize: 10.0,
|
|
||||||
stick_to_bottom: false,
|
|
||||||
desired_width: f32::INFINITY,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CodeEditor {
|
|
||||||
pub fn id_source(self, id_source: impl Into<String>) -> Self {
|
|
||||||
CodeEditor {
|
|
||||||
id: id_source.into(),
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Use custom font size
|
|
||||||
///
|
|
||||||
/// **Default: 10.0**
|
|
||||||
pub fn with_fontsize(self, fontsize: f32) -> Self {
|
|
||||||
CodeEditor { fontsize, ..self }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Use UI font size
|
|
||||||
pub fn with_ui_fontsize(self, ui: &mut egui::Ui) -> Self {
|
|
||||||
CodeEditor {
|
|
||||||
fontsize: egui::TextStyle::Monospace.resolve(ui.style()).size,
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Show or hide lines numbering
|
|
||||||
///
|
|
||||||
/// **Default: true**
|
|
||||||
pub fn with_numlines(self, numlines: bool) -> Self {
|
|
||||||
CodeEditor { numlines, ..self }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Shift lines numbering by this value
|
|
||||||
///
|
|
||||||
/// **Default: 0**
|
|
||||||
pub fn with_numlines_shift(self, numlines_shift: isize) -> Self {
|
|
||||||
CodeEditor {
|
|
||||||
numlines_shift,
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Show lines numbering only above zero, useful for enabling numbering since nth row
|
|
||||||
///
|
|
||||||
/// **Default: false**
|
|
||||||
pub fn with_numlines_only_natural(self, numlines_only_natural: bool) -> Self {
|
|
||||||
CodeEditor {
|
|
||||||
numlines_only_natural,
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Should the containing area shrink if the content is small?
|
|
||||||
///
|
|
||||||
/// **Default: false**
|
|
||||||
pub fn auto_shrink(self, shrink: bool) -> Self {
|
|
||||||
CodeEditor {
|
|
||||||
desired_width: if shrink { 0.0 } else { self.desired_width },
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the desired width of the code editor
|
|
||||||
///
|
|
||||||
/// **Default: `f32::INFINITY`**
|
|
||||||
pub fn desired_width(self, width: f32) -> Self {
|
|
||||||
CodeEditor {
|
|
||||||
desired_width: width,
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stick to bottom
|
|
||||||
/// The scroll handle will stick to the bottom position even while the content size
|
|
||||||
/// changes dynamically. This can be useful to simulate terminal UIs or log/info scrollers.
|
|
||||||
/// The scroll handle remains stuck until user manually changes position. Once "unstuck"
|
|
||||||
/// it will remain focused on whatever content viewport the user left it on. If the scroll
|
|
||||||
/// handle is dragged to the bottom it will again become stuck and remain there until manually
|
|
||||||
/// pulled from the end position.
|
|
||||||
///
|
|
||||||
/// **Default: false**
|
|
||||||
pub fn stick_to_bottom(self, stick_to_bottom: bool) -> Self {
|
|
||||||
CodeEditor {
|
|
||||||
stick_to_bottom,
|
|
||||||
..self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn format(&self, _string: &str) -> egui::text::TextFormat {
|
|
||||||
let font_id = egui::FontId::monospace(self.fontsize);
|
|
||||||
let color = Color32::WHITE;
|
|
||||||
egui::text::TextFormat::simple(font_id, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn numlines_show(&self, ui: &mut egui::Ui, text: &str) {
|
|
||||||
let total = if text.ends_with('\n') || text.is_empty() {
|
|
||||||
text.lines().count() + 1
|
|
||||||
} else {
|
|
||||||
text.lines().count()
|
|
||||||
} as isize;
|
|
||||||
|
|
||||||
let max_indent = total
|
|
||||||
.to_string()
|
|
||||||
.len()
|
|
||||||
.max(!self.numlines_only_natural as usize * self.numlines_shift.to_string().len());
|
|
||||||
let mut counter = (1..=total)
|
|
||||||
.map(|i| {
|
|
||||||
let num = i + self.numlines_shift;
|
|
||||||
if num <= 0 && self.numlines_only_natural {
|
|
||||||
String::new()
|
|
||||||
} else {
|
|
||||||
let label = num.to_string();
|
|
||||||
format!(
|
|
||||||
"{}{label}",
|
|
||||||
" ".repeat(max_indent.saturating_sub(label.len()))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.join("\n");
|
|
||||||
|
|
||||||
#[allow(clippy::cast_precision_loss)]
|
|
||||||
let width = max_indent as f32
|
|
||||||
* self.fontsize
|
|
||||||
* 0.5
|
|
||||||
* !(total + self.numlines_shift <= 0 && self.numlines_only_natural) as u8 as f32;
|
|
||||||
|
|
||||||
let mut layouter = |ui: &egui::Ui, string: &dyn TextBuffer, _wrap_width: f32| {
|
|
||||||
let layout_job = egui::text::LayoutJob::single_section(
|
|
||||||
string.as_str().to_string(), // Convert TextBuffer to String
|
|
||||||
egui::TextFormat::simple(egui::FontId::monospace(self.fontsize), Color32::WHITE),
|
|
||||||
);
|
|
||||||
ui.fonts(|f| f.layout_job(layout_job))
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.add(
|
|
||||||
egui::TextEdit::multiline(&mut counter)
|
|
||||||
.id_source(format!("{}_numlines", self.id))
|
|
||||||
.font(egui::TextStyle::Monospace)
|
|
||||||
.interactive(false)
|
|
||||||
.frame(false)
|
|
||||||
.desired_width(width)
|
|
||||||
.layouter(&mut layouter),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Show Code Editor
|
|
||||||
pub fn show(&mut self, ui: &mut egui::Ui, text: &mut dyn egui::TextBuffer) -> TextEditOutput {
|
|
||||||
let mut text_edit_output: Option<TextEditOutput> = None;
|
|
||||||
let code_editor = |ui: &mut egui::Ui| {
|
|
||||||
ui.horizontal_top(|h| {
|
|
||||||
if self.numlines {
|
|
||||||
self.numlines_show(h, text.as_str());
|
|
||||||
}
|
|
||||||
egui::ScrollArea::horizontal()
|
|
||||||
.hscroll(true)
|
|
||||||
.id_salt(format!("{}_inner_scroll", self.id))
|
|
||||||
.show(h, |ui| {
|
|
||||||
let output = egui::TextEdit::multiline(text)
|
|
||||||
.id_source(&self.id)
|
|
||||||
.lock_focus(true)
|
|
||||||
.frame(false)
|
|
||||||
.desired_width(self.desired_width)
|
|
||||||
.show(ui);
|
|
||||||
text_edit_output = Some(output);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
|
||||||
.id_salt(format!("{}_outer_scroll", self.id))
|
|
||||||
.stick_to_bottom(self.stick_to_bottom)
|
|
||||||
.show(ui, code_editor);
|
|
||||||
|
|
||||||
text_edit_output.expect("TextEditOutput should exist at this point")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
use std::sync::{Arc, Mutex};
|
|
||||||
|
|
||||||
use egui::TextEdit;
|
use egui::TextEdit;
|
||||||
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};
|
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};
|
||||||
use serde::{self, Deserialize, Serialize};
|
use serde::{self, Deserialize, Serialize};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
PROJECT_FOLDER,
|
PROJECT_FOLDER,
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
use std::{
|
|
||||||
cell::OnceCell,
|
|
||||||
io::Read,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
sync::LazyLock,
|
|
||||||
};
|
|
||||||
|
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use egui::TextEdit;
|
use egui::TextEdit;
|
||||||
use egui_extras::DatePickerButton;
|
use egui_extras::DatePickerButton;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::{io::Read, path::PathBuf, sync::LazyLock};
|
||||||
|
|
||||||
use crate::{PROJECT_FOLDER, util::saved_status};
|
use crate::{PROJECT_FOLDER, util::saved_status};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use core::fmt;
|
|
||||||
|
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
|
use core::fmt;
|
||||||
use egui::ScrollArea;
|
use egui::ScrollArea;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -1,3 +1,5 @@
|
|||||||
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
use std::{path::PathBuf, sync::LazyLock};
|
use std::{path::PathBuf, sync::LazyLock};
|
||||||
|
|
||||||
use egui::ScrollArea;
|
use egui::ScrollArea;
|
||||||
@@ -30,7 +32,11 @@ fn main() {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = eframe::run_native("World Coder", options, Box::new(|_cc| Ok(Box::new(app))));
|
if let Err(e) = eframe::run_native("World Coder", options, Box::new(|_cc| Ok(Box::new(app)))) {
|
||||||
|
eprintln!("Failed to run app: {e}");
|
||||||
|
}
|
||||||
|
|
||||||
|
eprintln!("App closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Interface {
|
pub struct Interface {
|
||||||
|
|||||||
Reference in New Issue
Block a user