feat: add scramble flag for development text scrambling

This commit introduces a new scramble option to help reduce distractions
during development by scrambling text using rot13. When enabled via the
new `--scramble` flag, text displayed in various views is transformed,
making it easier to focus on layout and behavior without reading the
actual content.

App & Args Updates

  - Added a `scramble: bool` field to the main application state (in `app.rs`).

  - Extended argument parsing (in `args.rs`) to recognize the `--scramble` flag.

NoteOptions Enhancement

  - Introduced a new bit flag `scramble_text` in `NoteOptions` with
    corresponding setter/getter methods.

UI Adjustments

  - Propagated the scramble flag through note rendering functions across
    navigation, timeline, and note view modules.

  - Updated several UI components (e.g., in `nav.rs`, `route.rs`, and
    `contents.rs`) to accept and apply the new note options.

Rot13 Implementation

  - Implemented a helper function (`rot13`) to scramble text
    conditionally when the scramble option is enabled.

This feature is intended for development builds only, offering a way to
obscure text content during UI tweaks and testing.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-02-22 14:25:46 -08:00
parent 32c7f83bd7
commit bd352f76d4
13 changed files with 125 additions and 43 deletions

View File

@@ -4,7 +4,7 @@ use crate::media_upload::{nostrbuild_nip96_upload, MediaPath};
use crate::post::{downcast_post_buffer, MentionType, NewPost};
use crate::profile::get_display_name;
use crate::ui::search_results::SearchResultsView;
use crate::ui::{self, Preview, PreviewConfig};
use crate::ui::{self, note::NoteOptions, Preview, PreviewConfig};
use crate::Result;
use egui::text::{CCursorRange, LayoutJob};
use egui::text_edit::TextEditOutput;
@@ -27,6 +27,7 @@ pub struct PostView<'a> {
poster: FilledKeypair<'a>,
id_source: Option<egui::Id>,
inner_rect: egui::Rect,
note_options: NoteOptions,
}
#[derive(Clone)]
@@ -82,6 +83,7 @@ pub struct PostResponse {
}
impl<'a> PostView<'a> {
#[allow(clippy::too_many_arguments)]
pub fn new(
ndb: &'a Ndb,
draft: &'a mut Draft,
@@ -90,6 +92,7 @@ impl<'a> PostView<'a> {
note_cache: &'a mut NoteCache,
poster: FilledKeypair<'a>,
inner_rect: egui::Rect,
note_options: NoteOptions,
) -> Self {
let id_source: Option<egui::Id> = None;
PostView {
@@ -101,6 +104,7 @@ impl<'a> PostView<'a> {
id_source,
post_type,
inner_rect,
note_options,
}
}
@@ -302,6 +306,7 @@ impl<'a> PostView<'a> {
txn,
id.bytes(),
nostrdb::NoteKey::new(0),
self.note_options,
);
});
});
@@ -686,6 +691,7 @@ mod preview {
app.note_cache,
self.poster.to_filled(),
ui.available_rect_before_wrap(),
NoteOptions::default(),
)
.ui(&txn, ui);
}