fixing warnings and depracated legacy things

This commit is contained in:
Priec
2025-08-18 17:19:21 +02:00
parent 03808a8b3b
commit 61e439a1d4
4 changed files with 2 additions and 90 deletions

View File

@@ -233,17 +233,6 @@ fn render_canvas_with_highlight_and_options<T: CanvasTheme, D: DataProvider>(
let current_field_idx = ui_state.current_field(); let current_field_idx = ui_state.current_field();
let is_edit_mode = matches!(ui_state.mode(), crate::canvas::modes::AppMode::Edit); let is_edit_mode = matches!(ui_state.mode(), crate::canvas::modes::AppMode::Edit);
#[cfg(feature = "suggestions")]
let active_completion = if ui_state.is_suggestions_active()
&& ui_state.suggestions.active_field == Some(current_field_idx)
{
ui_state.suggestions.completion_text.clone()
} else {
None
};
#[cfg(not(feature = "suggestions"))]
let active_completion: Option<String> = None;
render_canvas_fields_with_options( render_canvas_fields_with_options(
f, f,
area, area,
@@ -270,13 +259,6 @@ fn render_canvas_with_highlight_and_options<T: CanvasTheme, D: DataProvider>(
}, },
#[cfg(not(feature = "validation"))] #[cfg(not(feature = "validation"))]
|_field_idx| false, |_field_idx| false,
|field_idx| {
if field_idx == current_field_idx {
active_completion.clone()
} else {
None
}
},
opts, opts,
) )
} }
@@ -302,7 +284,7 @@ fn convert_selection_to_highlight(
/// Core canvas field rendering with options /// Core canvas field rendering with options
#[cfg(feature = "gui")] #[cfg(feature = "gui")]
fn render_canvas_fields_with_options<T: CanvasTheme, F1, F2, F3>( fn render_canvas_fields_with_options<T: CanvasTheme, F1, F2>(
f: &mut Frame, f: &mut Frame,
area: Rect, area: Rect,
fields: &[&str], fields: &[&str],
@@ -315,13 +297,11 @@ fn render_canvas_fields_with_options<T: CanvasTheme, F1, F2, F3>(
has_unsaved_changes: bool, has_unsaved_changes: bool,
get_display_value: F1, get_display_value: F1,
has_display_override: F2, has_display_override: F2,
get_completion: F3,
opts: CanvasDisplayOptions, opts: CanvasDisplayOptions,
) -> Option<Rect> ) -> Option<Rect>
where where
F1: Fn(usize) -> String, F1: Fn(usize) -> String,
F2: Fn(usize) -> bool, F2: Fn(usize) -> bool,
F3: Fn(usize) -> Option<String>,
{ {
let columns = Layout::default() let columns = Layout::default()
.direction(Direction::Horizontal) .direction(Direction::Horizontal)

View File

@@ -5,9 +5,6 @@ pub mod state;
#[cfg(feature = "gui")] #[cfg(feature = "gui")]
pub mod widget; pub mod widget;
#[cfg(feature = "keymaps")]
pub mod commands_impl;
pub use provider::TextAreaProvider; pub use provider::TextAreaProvider;
pub use state::{TextAreaEditor, TextAreaState, TextOverflowMode}; pub use state::{TextAreaEditor, TextAreaState, TextOverflowMode};

View File

@@ -1,7 +1,6 @@
// src/textarea/state.rs // src/textarea/state.rs
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use anyhow::Result;
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use crate::editor::FormEditor; use crate::editor::FormEditor;
@@ -14,45 +13,6 @@ use ratatui::{layout::Rect, widgets::Block};
#[cfg(feature = "gui")] #[cfg(feature = "gui")]
use unicode_width::UnicodeWidthChar; use unicode_width::UnicodeWidthChar;
#[cfg(feature = "gui")]
pub(crate) fn wrapped_rows(s: &str, width: u16) -> u16 {
if width == 0 {
return 1;
}
let mut rows: u16 = 1;
let mut cols: u16 = 0;
for ch in s.chars() {
let w = UnicodeWidthChar::width(ch).unwrap_or(0) as u16;
if cols.saturating_add(w) > width {
rows = rows.saturating_add(1);
cols = 0;
}
cols = cols.saturating_add(w);
}
rows
}
#[cfg(feature = "gui")]
pub(crate) fn wrapped_rows_to_cursor(s: &str, width: u16, cursor_chars: usize) -> (u16, u16) {
if width == 0 {
return (0, 0);
}
let mut row: u16 = 0;
let mut cols: u16 = 0;
for (i, ch) in s.chars().enumerate() {
if i >= cursor_chars {
break;
}
let w = UnicodeWidthChar::width(ch).unwrap_or(0) as u16;
if cols.saturating_add(w) > width {
row = row.saturating_add(1);
cols = 0;
}
cols = cols.saturating_add(w);
}
(row, cols)
}
#[cfg(feature = "gui")] #[cfg(feature = "gui")]
pub(crate) const RIGHT_PAD: u16 = 3; pub(crate) const RIGHT_PAD: u16 = 3;

View File

@@ -6,7 +6,7 @@ use ratatui::{
style::Style, style::Style,
text::{Line, Span}, text::{Line, Span},
widgets::{ widgets::{
Block, BorderType, Borders, Paragraph, StatefulWidget, Widget, Wrap, Block, BorderType, Borders, Paragraph, StatefulWidget, Widget,
}, },
}; };
@@ -87,31 +87,6 @@ fn display_cols_up_to(s: &str, char_count: usize) -> u16 {
cols cols
} }
#[cfg(feature = "gui")]
fn clip_with_indicator(s: &str, width: u16, indicator: char) -> Line<'static> {
if width == 0 {
return Line::from("");
}
if display_width(s) <= width {
return Line::from(Span::raw(s.to_string()));
}
let budget = width.saturating_sub(1);
let mut out = String::new();
let mut used: u16 = 0;
for ch in s.chars() {
let w = UnicodeWidthChar::width(ch).unwrap_or(0) as u16;
if used + w > budget {
break;
}
out.push(ch);
used = used.saturating_add(w);
}
Line::from(vec![Span::raw(out), Span::raw(indicator.to_string())])
}
#[cfg(feature = "gui")] #[cfg(feature = "gui")]
fn slice_by_display_cols(s: &str, start_cols: u16, max_cols: u16) -> String { fn slice_by_display_cols(s: &str, start_cols: u16, max_cols: u16) -> String {
if max_cols == 0 { if max_cols == 0 {