Skip to content
Merged
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
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
components: rustfmt
Expand All @@ -84,7 +84,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-audit@0.22.1
# Acknowledged advisories live in .cargo/audit.toml (see docs/AUDIT.md), so
Expand All @@ -101,12 +101,12 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
components: clippy
- run: sudo apt-get update && sudo apt-get install --yes libfuse3-dev pkg-config
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
# `--features bench` is required for the tui bench target: its
Expand All @@ -130,11 +130,11 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
- run: sudo apt-get update && sudo apt-get install --yes gnome-keyring dbus-bin
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo build -p notema-storage --tests --locked
Expand All @@ -158,12 +158,12 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
- run: brew install pkg-config
- run: brew install --cask fuse-t
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo check --workspace --all-targets --locked
Expand All @@ -182,10 +182,10 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
# FUSE doesn't exist on Windows (notema-fuse needs libfuse) and the Windows
Expand Down Expand Up @@ -246,11 +246,11 @@ jobs:
with:
persist-credentials: false
- run: sudo apt-get update && sudo apt-get install --yes ${{ matrix.packages }}
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
key: ${{ matrix.target }}
save-if: ${{ github.ref == 'refs/heads/main' }}
Expand Down Expand Up @@ -285,7 +285,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: aarch64-linux-android
Expand All @@ -297,7 +297,7 @@ jobs:
echo "CC_aarch64_linux_android=$TOOLCHAIN/aarch64-linux-android24-clang"
echo "AR_aarch64_linux_android=$TOOLCHAIN/llvm-ar"
} >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo check -p notema --target aarch64-linux-android --locked
36 changes: 18 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: ${{ matrix.target }}
Expand All @@ -170,7 +170,7 @@ jobs:
with:
version: 0.16.0
cache-key: ${{ matrix.target }}
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: ${{ matrix.zigbuild && 'cargo-about@0.9.1,cargo-zigbuild@0.23.0' || 'cargo-about@0.9.1' }}
# The glibc_floor suffix pins the glibc floor; the binary still lands in
Expand Down Expand Up @@ -267,11 +267,11 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-about@0.9.1
- run: cargo build --release -p notema --locked --target ${{ matrix.target }} --features fuse
Expand Down Expand Up @@ -315,7 +315,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: i586-unknown-linux-musl
Expand All @@ -342,7 +342,7 @@ jobs:
# name for the x86_64 *host* linker (used by build scripts); on this
# runner the host toolchain is plain gcc, so bridge that name too.
sudo ln -sf "$(command -v gcc)" /usr/local/bin/x86_64-unknown-linux-gnu-gcc
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-make@0.37.24,cargo-about@0.9.1
# setup-cross-toolchain-action sets CARGO_BUILD_TARGET to i686-musl; the
Expand Down Expand Up @@ -389,7 +389,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: aarch64-linux-android
Expand All @@ -401,7 +401,7 @@ jobs:
echo "CC_aarch64_linux_android=$TOOLCHAIN/aarch64-linux-android24-clang"
echo "AR_aarch64_linux_android=$TOOLCHAIN/llvm-ar"
} >> "$GITHUB_ENV"
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-about@0.9.1
- run: cargo build --release -p notema --target aarch64-linux-android --locked
Expand Down Expand Up @@ -463,7 +463,7 @@ jobs:
with:
persist-credentials: false
# Tier 3 has no rustup target to add; build-std needs rust-src instead.
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.build_std && '' || matrix.target }}
Expand All @@ -473,7 +473,7 @@ jobs:
with:
version: 0.16.0
cache-key: ${{ matrix.target }}
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-about@0.9.1,cargo-zigbuild@0.23.0
- if: ${{ !matrix.build_std }}
Expand Down Expand Up @@ -542,11 +542,11 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-about@0.9.1
- run: cargo build --release -p notema --target ${{ matrix.target }} --locked
Expand Down Expand Up @@ -589,7 +589,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: ${{ matrix.target }}
Expand All @@ -614,7 +614,7 @@ jobs:
TEAM_ID="$(printf '%s' "$APPLE_DEVELOPER_ID" | sed -n 's/.*(\(.*\)).*/\1/p')"
xcrun notarytool store-credentials notema-notary \
--apple-id "$APPLE_USERNAME" --password "$APPLE_PASSWORD" --team-id "$TEAM_ID" >/dev/null
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-make@0.37.24,cargo-about@0.9.1
- run: cargo make ${{ matrix.task }}
Expand Down Expand Up @@ -677,7 +677,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # master
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
with:
toolchain: 1.96.0
targets: ${{ matrix.target }}
Expand All @@ -704,7 +704,7 @@ jobs:
TEAM_ID="$(printf '%s' "$APPLE_DEVELOPER_ID" | sed -n 's/.*(\(.*\)).*/\1/p')"
xcrun notarytool store-credentials notema-notary \
--apple-id "$APPLE_USERNAME" --password "$APPLE_PASSWORD" --team-id "$TEAM_ID" >/dev/null
- uses: taiki-e/install-action@1beb33eee6d086258184383af9a538940be190ed # v2
- uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2
with:
tool: cargo-make@0.37.24,cargo-about@0.9.1
- run: cargo make ${{ matrix.task }}
Expand Down Expand Up @@ -803,13 +803,13 @@ jobs:
# Provenance links each zip to this workflow run; verify with
# `gh attestation verify <zip> --repo <owner>/<repo>`.
- name: Attest build provenance
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: |
assets/*.zip
assets/SHA256SUMS
- name: Publish
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
tag_name: ${{ github.ref_name }}
fail_on_unmatched_files: true
Expand Down
13 changes: 11 additions & 2 deletions Cargo.lock

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

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ pkg-config = "0.3"
rand = "0.10"
ratatui = "0.30"
ratatui-image = { version = "11", default-features = false, features = ["crossterm"] }
# Fork of ratatui-textarea 0.9.2 the editor depends on: public accessors
# (scroll_offset, horizontal_scroll_offset, screen_line_count, cursor_at_screen)
# for its scrollbar, scroll-aware mouse mapping, and native-cursor placement in
# horizontally-scrolling single-line fields, plus set_syntax_spans for the markdown
# highlighter's base styling layer. Upstream keeps these pub(crate). Also
# set_top_padding and layout_for, so the editor can frame the body like the viewer,
# and set_glyph_substitutions for the search field's chips.
ratatui-textarea = { package = "notema-textarea", git = "https://github.com/paviro/notema-textarea", rev = "cbf1b84", features = ["crossterm"] }
# Fork of ratatui-textarea 0.9.3, pinned to a tested commit. Upstream supplies
# scroll_offset and screen_to_data; the fork adds padding-aware mouse mapping,
# screen-line counts, pre-render layout, syntax spans, glyph substitutions,
# Unicode wrapping, and grapheme cursor geometry.
ratatui-textarea = { package = "notema-textarea", git = "https://github.com/paviro/notema-textarea", rev = "6e7fa5139d1d306b3043880e926394351dfcd13b", features = ["crossterm"] }
pulldown-cmark = { version = "0.13.4", default-features = false }
rayon = "1"
regex = "1"
Expand Down Expand Up @@ -90,6 +87,8 @@ tree-sitter-toml-ng = "0.7"
tree-sitter-typescript = "0.23"
tree-sitter-yaml = "0.7"
tzf-rs = { version = "1", default-features = false, features = ["bundled"] }
unicode-linebreak = "0.1.5"
unicode-segmentation = "1.13.3"
unicode-width = "0.2"
ureq = { version = "3", default-features = false }
zbus = "5"
Expand Down Expand Up @@ -181,6 +180,8 @@ tree-sitter-swift.workspace = true
tree-sitter-toml-ng.workspace = true
tree-sitter-typescript.workspace = true
tree-sitter-yaml.workspace = true
unicode-linebreak.workspace = true
unicode-segmentation.workspace = true
unicode-width.workspace = true
zeroize.workspace = true
terminal-colorsaurus.workspace = true
Expand Down
41 changes: 38 additions & 3 deletions src/tui/editor_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ impl EntryEditor {
{
return None;
}
let screen_row = self.textarea.scroll_offset() as usize + (row - rect.y) as usize;
let screen_row = self.textarea.scroll_offset().0 as usize + (row - rect.y) as usize;
let screen_col = (col - rect.x) as usize;
let DataCursor(line, column) = self.textarea.cursor_at_screen(screen_row, screen_col);
let DataCursor(line, column) = self.textarea.screen_to_data(screen_row, screen_col);
Some((line as u16, column as u16))
}

Expand All @@ -197,7 +197,7 @@ impl EntryEditor {
pub(crate) fn scroll_lines(&mut self, delta: i16) {
let height = self.text_rect.height as usize;
let max_top = self.textarea.screen_line_count().saturating_sub(height) as i64;
let cur = self.textarea.scroll_offset() as i64;
let cur = self.textarea.scroll_offset().0 as i64;
let target = (cur + delta as i64).clamp(0, max_top);
if target != cur {
self.textarea.scroll(((target - cur) as i16, 0));
Expand Down Expand Up @@ -267,6 +267,41 @@ fn new_textarea(body: &str, placeholder: Option<&str>) -> TextArea<'static> {
#[cfg(test)]
mod tests {
use super::*;
use ratatui::{buffer::Buffer, widgets::Widget as _};
use ratatui_textarea::CursorMove;

#[test]
fn padded_editor_clicks_follow_wrapping_scrolling_and_resize() {
let body = "e\u{301}日👩🏽‍💻\tend\nsecond line\nlast";
let mut editor = EntryEditor::for_new("work".to_string());
editor.textarea.insert_str(body);
editor.textarea.set_top_padding(2);
for rect in [Rect::new(4, 3, 12, 6), Rect::new(4, 3, 5, 3)] {
editor.text_rect = rect;
editor.textarea.layout_for(rect);
editor.textarea.move_cursor(CursorMove::Top);
editor.textarea.render(rect, &mut Buffer::empty(rect));
assert_eq!(editor.text_pos_at(rect.x, rect.y), Some((0, 0)));
assert_eq!(
editor.text_pos_at(rect.x + 2, rect.y + editor.textarea.top_padding()),
Some((0, 2))
);
assert_eq!(editor.text_pos_at(rect.x - 1, rect.y), None);
assert_eq!(editor.text_pos_at(rect.x, rect.bottom()), None);

editor.textarea.move_cursor(CursorMove::Bottom);
editor.textarea.move_cursor(CursorMove::End);
editor.textarea.render(rect, &mut Buffer::empty(rect));
let screen = editor.textarea.screen_cursor();
let y = rect.y + screen.row as u16 + editor.textarea.top_padding()
- editor.textarea.scroll_offset().0;
assert_eq!(
editor.text_pos_at(rect.x + screen.col as u16, y),
Some((2, 4))
);
assert_eq!(editor.text(), body);
}
}

/// A false positive here means the editor keeps painting a stale highlight,
/// so the in-place comparison has to agree with `lines.join("\n")` exactly.
Expand Down
Loading
Loading