improved textarea normal editor mode, not just vim
This commit is contained in:
@@ -18,7 +18,7 @@ impl CursorManager {
|
||||
// NORMALMODE: force underscore for every mode
|
||||
#[cfg(feature = "textmode-normal")]
|
||||
{
|
||||
let style = SetCursorStyle::SteadyUnderScore;
|
||||
let style = SetCursorStyle::SteadyBar;
|
||||
return execute!(io::stdout(), style);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,13 +36,22 @@ impl ModeManager {
|
||||
|
||||
/// Transition to new mode with automatic cursor update (when cursor-style feature enabled)
|
||||
pub fn transition_to_mode(current_mode: AppMode, new_mode: AppMode) -> std::io::Result<AppMode> {
|
||||
if current_mode != new_mode {
|
||||
#[cfg(feature = "cursor-style")]
|
||||
{
|
||||
let _ = CursorManager::update_for_mode(new_mode);
|
||||
}
|
||||
#[cfg(feature = "textmode-normal")]
|
||||
{
|
||||
// Always force Edit in normalmode
|
||||
return Ok(AppMode::Edit);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "textmode-normal"))]
|
||||
{
|
||||
if current_mode != new_mode {
|
||||
#[cfg(feature = "cursor-style")]
|
||||
{
|
||||
let _ = CursorManager::update_for_mode(new_mode);
|
||||
}
|
||||
}
|
||||
Ok(new_mode)
|
||||
}
|
||||
Ok(new_mode)
|
||||
}
|
||||
|
||||
/// Enter highlight mode with cursor styling
|
||||
|
||||
@@ -54,7 +54,13 @@ impl EditorState {
|
||||
current_field: 0,
|
||||
cursor_pos: 0,
|
||||
ideal_cursor_column: 0,
|
||||
// NORMALMODE: always start in Edit
|
||||
#[cfg(feature = "textmode-normal")]
|
||||
current_mode: AppMode::Edit,
|
||||
// Default (vim): start in ReadOnly
|
||||
#[cfg(not(feature = "textmode-normal"))]
|
||||
current_mode: AppMode::ReadOnly,
|
||||
|
||||
#[cfg(feature = "suggestions")]
|
||||
suggestions: SuggestionsUIState {
|
||||
is_active: false,
|
||||
|
||||
@@ -53,10 +53,19 @@ impl<D: DataProvider> FormEditor<D> {
|
||||
{
|
||||
let mut editor = editor;
|
||||
editor.initialize_validation();
|
||||
|
||||
#[cfg(feature = "cursor-style")]
|
||||
{
|
||||
let _ = CursorManager::update_for_mode(editor.ui_state.current_mode);
|
||||
}
|
||||
editor
|
||||
}
|
||||
#[cfg(not(feature = "validation"))]
|
||||
{
|
||||
#[cfg(feature = "cursor-style")]
|
||||
{
|
||||
let _ = CursorManager::update_for_mode(editor.ui_state.current_mode);
|
||||
}
|
||||
editor
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@ pub mod validation;
|
||||
#[cfg(feature = "computed")]
|
||||
pub mod computed;
|
||||
|
||||
#[path = "textmode/check.rs"]
|
||||
mod textmode_check;
|
||||
|
||||
#[cfg(feature = "cursor-style")]
|
||||
pub use canvas::CursorManager;
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// src/textmode/check.rs
|
||||
|
||||
#[cfg(all(feature = "textmode-vim", feature = "textmode-normal"))]
|
||||
compile_error!("Enable exactly one of: textmode-vim or textmode-normal.");
|
||||
|
||||
#[cfg(not(any(feature = "textmode-vim", feature = "textmode-normal")))]
|
||||
compile_error!("No textmode selected. Enable one of: textmode-vim or textmode-normal.");
|
||||
Reference in New Issue
Block a user