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

@@ -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;