Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ objc2 = "0.5"
objc2-app-kit = "0.2"
objc2-foundation = "0.2"

[target.'cfg(windows)'.build-dependencies]
winresource = "0.1"

[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.59", features = [
"Win32_Foundation",
Expand Down Expand Up @@ -86,7 +89,7 @@ byte patterns, data-folds and file tools.
"""
category = "DeveloperTool"
copyright = "Copyright (c) Digital Gangster Enterprises, LLC"
icon = ["assets/icon.png"]
icon = ["assets/icon.png", "assets/icon.ico"]

# Debian package metadata for `cargo install cargo-deb` + `cargo deb`.
[package.metadata.deb]
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# bewitched

<img src="assets/icon.png" alt="bewitched icon" width="128">

A fast, cross-platform, hacker-esque **hex editor** for files, raw disks and RAM,
written in Rust with an immediate-mode (`egui`) GUI. It edits files of any size
(up to 8 EB) with instant opening, unlimited undo, and a streamlined,
Expand Down Expand Up @@ -39,6 +41,13 @@ blocks.
- **Navigation**: arrows, page up/down, home/end, go-to-address (`Ctrl+G`),
nibble stepping (`Ctrl+←/→`), 10 bookmarks (`Ctrl+Shift+0-9` to set,
`Ctrl+0-9` to jump).
- **Vim mode** (Edit ▸ vim keybindings, remembered between launches): modal
NORMAL / VISUAL / INSERT / REPLACE editing with counts. Motions `h j k l`,
`w b e` (byte group, or 8 bytes ungrouped), `0 ^ $`, `gg G` (`nG` = row n),
`Ctrl+F/B/D/U`; edits `i a I A R`, `r<hex><hex>` (or `r<char>` in the text
pane), `x X dd D ~`, `u` / `Ctrl+R`; `yy p P`; `v` visual with `o d y`;
`/ ? n N` search, `:` go to address, `m0-9` / `'0-9` bookmarks; Esc returns
to NORMAL. The current mode shows in the status bar.
- **Search / replace** (`Ctrl+F`) for text, Unicode (UTF-16), hex, integers
(8/16/32/64) and floats (32/64), little/big-endian, forward / backward /
from-start, case-insensitive, streaming (never loads the whole file). Hex
Expand Down
Binary file added assets/icon.ico
Binary file not shown.
Binary file modified assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Embed the application icon into the Windows executable so Explorer, the
// taskbar pin and shortcuts show it (the runtime window icon is set separately
// in `ui::run`).
fn main() {
println!("cargo:rerun-if-changed=assets/icon.ico");
#[cfg(windows)]
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
let mut res = winresource::WindowsResource::new();
res.set_icon("assets/icon.ico");
if let Err(e) = res.compile() {
println!("cargo:warning=could not embed Windows icon: {e}");
}
}
}
14 changes: 14 additions & 0 deletions src/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ pub mod strings;
pub mod template;
pub mod transform;

/// The per-user config directory (`%APPDATA%\bewitched` on Windows,
/// `$XDG_CONFIG_HOME/bewitched` or `~/.config/bewitched` elsewhere).
pub fn config_dir() -> std::path::PathBuf {
#[cfg(windows)]
let base = std::env::var("APPDATA").ok();
#[cfg(not(windows))]
let base = std::env::var("XDG_CONFIG_HOME")
.ok()
.or_else(|| std::env::var("HOME").ok().map(|h| format!("{h}/.config")));
let mut p = std::path::PathBuf::from(base.unwrap_or_else(|| ".".into()));
p.push("bewitched");
p
}

/// Parse a `0x`-prefixed hex or plain decimal unsigned integer — an offset,
/// length or address as typed by the user. Whitespace is trimmed.
pub fn parse_u64(s: &str) -> Option<u64> {
Expand Down
9 changes: 1 addition & 8 deletions src/ops/script_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ pub fn scripts_dir() -> PathBuf {
if let Ok(d) = std::env::var("BEWITCHED_SCRIPT_DIR") {
return PathBuf::from(d);
}
#[cfg(windows)]
let base = std::env::var("APPDATA").ok();
#[cfg(not(windows))]
let base = std::env::var("XDG_CONFIG_HOME")
.ok()
.or_else(|| std::env::var("HOME").ok().map(|h| format!("{h}/.config")));
let mut p = PathBuf::from(base.unwrap_or_else(|| ".".into()));
p.push("bewitched");
let mut p = super::config_dir();
p.push("scripts");
p
}
Expand Down
8 changes: 8 additions & 0 deletions src/ui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use super::charset::Charset;
use super::donate;
use super::hexview::{self, Layout, Pane, ViewMode};
use super::theme;
use super::vim;

#[derive(Clone, Copy, PartialEq, Eq)]
enum EditMode {
Expand Down Expand Up @@ -414,6 +415,10 @@ pub struct App {
regions_open: bool,
about_open: bool,
donate: donate::DonateUi,
/// Vim-style modal keybindings (Edit ▸ vim keybindings), persisted.
vim_enabled: bool,
vim_mode: vim::Mode,
vim: vim::Vim,
}

impl App {
Expand Down Expand Up @@ -498,6 +503,9 @@ impl App {
regions_open: false,
about_open: false,
donate: donate::DonateUi::default(),
vim_enabled: vim::load_enabled(),
vim_mode: vim::Mode::Normal,
vim: vim::Vim::default(),
}
}

Expand Down
Loading