Files
imeai-aKode/akode-rs/tui/src/bottom_pane/chat_composer/draft_state.rs
andrea.difonzo 7c1c6dfa8d Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
  nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 12:37:52 +01:00

61 lines
2.2 KiB
Rust

//! Editable composer draft state kept separate from composer control flow.
use std::cell::RefCell;
use std::collections::HashMap;
use crate::bottom_pane::MentionBinding;
use crate::bottom_pane::paste_burst::PasteBurst;
use crate::bottom_pane::textarea::TextArea;
use crate::bottom_pane::textarea::TextAreaState;
pub(super) struct DraftState {
pub(super) textarea: TextArea,
pub(super) textarea_state: RefCell<TextAreaState>,
pub(super) is_bash_mode: bool,
pub(super) pending_pastes: Vec<(String, String)>,
pub(super) input_enabled: bool,
pub(super) input_disabled_placeholder: Option<String>,
pub(super) paste_burst: PasteBurst,
pub(super) disable_paste_burst: bool,
/// Byte offset of the space added by the last skill completion, until the next key is resolved.
pub(super) skill_completion_space: Option<usize>,
pub(super) mention_bindings: HashMap<u64, ComposerMentionBinding>,
pub(super) recent_submission_mention_bindings: Vec<MentionBinding>,
}
impl DraftState {
pub(super) fn new() -> Self {
Self {
textarea: TextArea::new(),
textarea_state: RefCell::new(TextAreaState::default()),
is_bash_mode: false,
pending_pastes: Vec::new(),
input_enabled: true,
input_disabled_placeholder: None,
paste_burst: PasteBurst::default(),
disable_paste_burst: false,
skill_completion_space: None,
mention_bindings: HashMap::new(),
recent_submission_mention_bindings: Vec::new(),
}
}
pub(super) fn skill_completion_space_for_char(&self, ch: char) -> Option<usize> {
self.skill_completion_space.filter(|&space| {
",.;:!?)]}。,、!?》".contains(ch)
&& self.textarea.allows_paste_burst()
&& !self.textarea.is_vim_replace_mode()
&& self.textarea.cursor() == space + 1
&& self.textarea.mouse_selection_range().is_none()
&& self.textarea.text().get(space..space + 1) == Some(" ")
})
}
}
#[derive(Clone, Debug)]
pub(super) struct ComposerMentionBinding {
pub(super) sigil: char,
pub(super) mention: String,
pub(super) path: String,
}