mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 05:37:04 +00:00
owed by ribbon-w5: the pass-local editor record step 16 reads (note_editor_facts, S-L168)
This commit is contained in:
@@ -13,7 +13,7 @@ mod measure;
|
||||
mod paint;
|
||||
mod parts;
|
||||
mod place;
|
||||
mod report;
|
||||
pub(crate) mod report;
|
||||
pub(crate) mod scroll_owner;
|
||||
mod sense;
|
||||
mod settle;
|
||||
|
||||
@@ -10,6 +10,7 @@ use crate::runtime::commands::{self, ResolvedCommand};
|
||||
use crate::runtime::env::{Label, Message};
|
||||
use crate::runtime::focus::{self};
|
||||
use crate::runtime::keys;
|
||||
use crate::runtime::pass_state;
|
||||
use crate::style::Flags;
|
||||
use craft_behavior::Sense;
|
||||
use egui::Id;
|
||||
@@ -174,7 +175,11 @@ fn report_access(p: &dyn ErasedPass<'_>, facts: &TypeFacts, input: &ReportIn<'_>
|
||||
if let Some(folded) = &folded {
|
||||
keys::register_node(ctx, id, folded.inner, None, focusable);
|
||||
}
|
||||
if let Some(facts) = core.text_access.take() {
|
||||
let editor_record = || {
|
||||
let widget = core.editor.as_ref()?.widget;
|
||||
pass_state::with::<EditorRecords, _>(ctx, |records| records.0.remove(&widget))
|
||||
};
|
||||
if let Some(facts) = core.text_access.take().or_else(editor_record) {
|
||||
crate::runtime::access::text::report_text(ctx, id, &facts);
|
||||
}
|
||||
if core.member_of.is_some() && flags.contains(Flags::FOCUSED) {
|
||||
@@ -280,3 +285,15 @@ pub(crate) fn report_inert(core: &CxCore<'_>, facts: &TypeFacts) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// The text facts an editor body reported through its `EditorHandle` in the running pass, by editor widget: the
|
||||
/// owning component's report step reads its own (owed by ribbon-w5, S-L168). Pass-local, so nothing outlives the pass.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct EditorRecords(std::collections::HashMap<egui::Id, crate::runtime::access::text::TextFacts>);
|
||||
|
||||
/// Puts `facts` in the running pass's record for the editor part `widget`.
|
||||
pub(crate) fn note_editor_facts(ctx: &egui::Context, widget: egui::Id, facts: crate::runtime::access::text::TextFacts) {
|
||||
pass_state::with::<EditorRecords, _>(ctx, |records| {
|
||||
records.0.insert(widget, facts);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ pass_state! {
|
||||
gestures: crate::runtime::edit::Gestures,
|
||||
reveals: crate::contract::steps::scroll_owner::Reveals,
|
||||
scroll_moves: crate::contract::steps::scroll_owner::ScrollMoves,
|
||||
editor_records: crate::contract::steps::report::EditorRecords,
|
||||
jumps: crate::contract::body::scroll::Jumps,
|
||||
shrink_reports: crate::layout::body::ShrinkReports,
|
||||
least_reports: crate::layout::body::LeastReports,
|
||||
|
||||
Reference in New Issue
Block a user