refactor: split every monolithic module into focused submodules
Each source file that had grown beyond a single concern is replaced by an identically-named directory containing focused submodules. `src/event_loop/mod.rs` (878 lines) becomes a directory with clipboard, context_menu, cursor_shape, drag, focus, handlers, invalidation, overlays_reconcile, repeat, run, surface, text_editing, and tooltip. Every widget, input handler, and theme component follows the same split. Public interfaces are unchanged — only the internal file layout moves. image bumped from 0.25.2 to 0.25.9.
This commit is contained in:
48
src/event_loop/clipboard.rs
Normal file
48
src/event_loop/clipboard.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-only
|
||||
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>
|
||||
|
||||
use super::app_data::AppData;
|
||||
use super::surface::SurfaceFocus;
|
||||
use crate::app::App;
|
||||
use crate::tree::find_handlers;
|
||||
|
||||
impl<A: App> AppData<A>
|
||||
{
|
||||
/// Copy the currently-selected text into the process-local
|
||||
/// clipboard. No-op when there is no selection.
|
||||
pub( crate ) fn handle_copy( &mut self, focus: SurfaceFocus )
|
||||
{
|
||||
if let Some( text ) = self.focused_selection_text( focus )
|
||||
{
|
||||
self.clipboard = text;
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy + delete: the selected text lands in the clipboard, then
|
||||
/// the range is removed from the value.
|
||||
pub( crate ) fn handle_cut( &mut self, focus: SurfaceFocus )
|
||||
{
|
||||
let idx = match self.surface( focus ).focused_idx { Some( i ) => i, None => return };
|
||||
if let Some( text ) = self.focused_selection_text( focus )
|
||||
{
|
||||
self.clipboard = text;
|
||||
}
|
||||
if let Some( new_value ) = self.delete_selection( focus )
|
||||
{
|
||||
let msg = find_handlers( &self.surface( focus ).widget_rects, idx )
|
||||
.and_then( |h| h.text_change_msg( &new_value ) );
|
||||
if let Some( m ) = msg { self.pending_msgs.push( m ); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Insert the clipboard contents at the cursor (replacing the
|
||||
/// selection if there is one). No-op when the clipboard is empty.
|
||||
pub( crate ) fn handle_paste( &mut self, focus: SurfaceFocus )
|
||||
{
|
||||
if self.clipboard.is_empty() { return; }
|
||||
// Carbon-copy of the clipboard to break the borrow on `self`
|
||||
// before `handle_text_insert` runs.
|
||||
let text = self.clipboard.clone();
|
||||
self.handle_text_insert( focus, &text );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user