fixing warnings and depracated legacy things
This commit is contained in:
@@ -5,9 +5,6 @@ pub mod state;
|
||||
#[cfg(feature = "gui")]
|
||||
pub mod widget;
|
||||
|
||||
#[cfg(feature = "keymaps")]
|
||||
pub mod commands_impl;
|
||||
|
||||
pub use provider::TextAreaProvider;
|
||||
pub use state::{TextAreaEditor, TextAreaState, TextOverflowMode};
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// src/textarea/state.rs
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use anyhow::Result;
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
|
||||
|
||||
use crate::editor::FormEditor;
|
||||
@@ -14,45 +13,6 @@ use ratatui::{layout::Rect, widgets::Block};
|
||||
#[cfg(feature = "gui")]
|
||||
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")]
|
||||
pub(crate) const RIGHT_PAD: u16 = 3;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use ratatui::{
|
||||
style::Style,
|
||||
text::{Line, Span},
|
||||
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
|
||||
}
|
||||
|
||||
#[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")]
|
||||
fn slice_by_display_cols(s: &str, start_cols: u16, max_cols: u16) -> String {
|
||||
if max_cols == 0 {
|
||||
|
||||
Reference in New Issue
Block a user