Skip to content

Commit 30d61db

Browse files
authored
refactor!: remove deprecated functions and Display impl (#1086)
Those were deprecated in #1052
1 parent c076ee0 commit 30d61db

5 files changed

Lines changed: 4 additions & 235 deletions

File tree

src/enums.rs

Lines changed: 2 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crossterm::event::{Event, KeyEvent, KeyEventKind};
22
use serde::{Deserialize, Serialize};
3-
use std::fmt::{Display, Formatter};
43
use strum::{EnumDiscriminants, EnumIter, EnumString, VariantArray};
54

65
/// Which mouse button was pressed.
@@ -93,7 +92,7 @@ impl Default for TextObject {
9392
///
9493
/// Executed by `Reedline::run_edit_commands()`
9594
#[non_exhaustive]
96-
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, EnumDiscriminants, EnumIter)]
95+
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, EnumDiscriminants)]
9796
#[strum_discriminants(doc = "This is the auto generated discriminant type for [`EditCommand`]")]
9897
#[strum_discriminants(derive(EnumIter, EnumString, VariantArray))]
9998
#[strum_discriminants(strum(ascii_case_insensitive))]
@@ -508,149 +507,6 @@ pub enum EditCommand {
508507
},
509508
}
510509

511-
// FIXME: This implementation makes no sense to be here, and should be removed in a future version
512-
// It was originally added for nushell to show all the available commands and their parameters to
513-
// the users. Hence some are marked `Optional` and some have different parameter names.
514-
// This is also very hard to keep in sync with nushell.
515-
// So, recently its discriminants are exposed using the strum EnumDiscriminants, and downstream is
516-
// expected to use that if they want to display the list of available commands to their users.
517-
impl Display for EditCommand {
518-
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
519-
match self {
520-
EditCommand::MoveToStart { .. } => write!(f, "MoveToStart Optional[select: <bool>]"),
521-
EditCommand::MoveToLineStart { .. } => {
522-
write!(f, "MoveToLineStart Optional[select: <bool>]")
523-
}
524-
EditCommand::MoveToLineNonBlankStart { .. } => {
525-
write!(f, "MoveToLineNonBlankStart Optional[select: <bool>]")
526-
}
527-
EditCommand::MoveToEnd { .. } => write!(f, "MoveToEnd Optional[select: <bool>]"),
528-
EditCommand::MoveToLineEnd { .. } => {
529-
write!(f, "MoveToLineEnd Optional[select: <bool>]")
530-
}
531-
EditCommand::MoveLineUp { .. } => write!(f, "MoveLineUp Optional[select: <bool>]"),
532-
EditCommand::MoveLineDown { .. } => write!(f, "MoveLineDown Optional[select: <bool>]"),
533-
EditCommand::MoveLeft { .. } => write!(f, "MoveLeft Optional[select: <bool>]"),
534-
EditCommand::MoveRight { .. } => write!(f, "MoveRight Optional[select: <bool>]"),
535-
EditCommand::MoveWordLeft { .. } => write!(f, "MoveWordLeft Optional[select: <bool>]"),
536-
EditCommand::MoveBigWordLeft { .. } => {
537-
write!(f, "MoveBigWordLeft Optional[select: <bool>]")
538-
}
539-
EditCommand::MoveWordRight { .. } => {
540-
write!(f, "MoveWordRight Optional[select: <bool>]")
541-
}
542-
EditCommand::MoveWordRightEnd { .. } => {
543-
write!(f, "MoveWordRightEnd Optional[select: <bool>]")
544-
}
545-
EditCommand::MoveBigWordRightEnd { .. } => {
546-
write!(f, "MoveBigWordRightEnd Optional[select: <bool>]")
547-
}
548-
EditCommand::MoveWordRightStart { .. } => {
549-
write!(f, "MoveWordRightStart Optional[select: <bool>]")
550-
}
551-
EditCommand::MoveBigWordRightStart { .. } => {
552-
write!(f, "MoveBigWordRightStart Optional[select: <bool>]")
553-
}
554-
EditCommand::MoveToPosition { .. } => {
555-
write!(f, "MoveToPosition Value: <int>, Optional[select: <bool>]")
556-
}
557-
EditCommand::MoveLeftUntil { .. } => {
558-
write!(f, "MoveLeftUntil Value: <char>, Optional[select: <bool>]")
559-
}
560-
EditCommand::MoveLeftBefore { .. } => {
561-
write!(f, "MoveLeftBefore Value: <char>, Optional[select: <bool>]")
562-
}
563-
EditCommand::InsertChar(_) => write!(f, "InsertChar Value: <char>"),
564-
EditCommand::InsertString(_) => write!(f, "InsertString Value: <string>"),
565-
EditCommand::InsertNewline => write!(f, "InsertNewline"),
566-
EditCommand::InsertNewlineAbove => write!(f, "InsertNewlineAbove"),
567-
EditCommand::InsertNewlineBelow => write!(f, "InsertNewlineBelow"),
568-
EditCommand::ReplaceChar(_) => write!(f, "ReplaceChar <char>"),
569-
EditCommand::ReplaceChars(_, _) => write!(f, "ReplaceChars <int> <string>"),
570-
EditCommand::Backspace => write!(f, "Backspace"),
571-
EditCommand::Delete => write!(f, "Delete"),
572-
EditCommand::CutChar => write!(f, "CutChar"),
573-
EditCommand::BackspaceWord => write!(f, "BackspaceWord"),
574-
EditCommand::DeleteWord => write!(f, "DeleteWord"),
575-
EditCommand::Clear => write!(f, "Clear"),
576-
EditCommand::ClearToLineEnd => write!(f, "ClearToLineEnd"),
577-
EditCommand::Complete => write!(f, "Complete"),
578-
EditCommand::CutCurrentLine => write!(f, "CutCurrentLine"),
579-
EditCommand::CutFromStart => write!(f, "CutFromStart"),
580-
EditCommand::CutFromStartLinewise { .. } => {
581-
write!(f, "CutFromStartLinewise Value: <bool>")
582-
}
583-
EditCommand::CutFromLineStart => write!(f, "CutFromLineStart"),
584-
EditCommand::CutFromLineNonBlankStart => write!(f, "CutFromLineNonBlankStart"),
585-
EditCommand::CutToEnd => write!(f, "CutToEnd"),
586-
EditCommand::CutToEndLinewise { .. } => {
587-
write!(f, "CutToEndLinewise Value: <bool>")
588-
}
589-
EditCommand::CutToLineEnd => write!(f, "CutToLineEnd"),
590-
EditCommand::KillLine => write!(f, "KillLine"),
591-
EditCommand::CutWordLeft => write!(f, "CutWordLeft"),
592-
EditCommand::CutBigWordLeft => write!(f, "CutBigWordLeft"),
593-
EditCommand::CutWordRight => write!(f, "CutWordRight"),
594-
EditCommand::CutBigWordRight => write!(f, "CutBigWordRight"),
595-
EditCommand::CutWordRightToNext => write!(f, "CutWordRightToNext"),
596-
EditCommand::CutBigWordRightToNext => write!(f, "CutBigWordRightToNext"),
597-
EditCommand::PasteCutBufferBefore => write!(f, "PasteCutBufferBefore"),
598-
EditCommand::PasteCutBufferAfter => write!(f, "PasteCutBufferAfter"),
599-
EditCommand::UppercaseWord => write!(f, "UppercaseWord"),
600-
EditCommand::LowercaseWord => write!(f, "LowercaseWord"),
601-
EditCommand::SwitchcaseChar => write!(f, "SwitchcaseChar"),
602-
EditCommand::CapitalizeChar => write!(f, "CapitalizeChar"),
603-
EditCommand::SwapWords => write!(f, "SwapWords"),
604-
EditCommand::SwapGraphemes => write!(f, "SwapGraphemes"),
605-
EditCommand::Undo => write!(f, "Undo"),
606-
EditCommand::Redo => write!(f, "Redo"),
607-
EditCommand::CutRightUntil(_) => write!(f, "CutRightUntil Value: <char>"),
608-
EditCommand::CutRightBefore(_) => write!(f, "CutRightBefore Value: <char>"),
609-
EditCommand::MoveRightUntil { .. } => write!(f, "MoveRightUntil Value: <char>"),
610-
EditCommand::MoveRightBefore { .. } => write!(f, "MoveRightBefore Value: <char>"),
611-
EditCommand::CutLeftUntil(_) => write!(f, "CutLeftUntil Value: <char>"),
612-
EditCommand::CutLeftBefore(_) => write!(f, "CutLeftBefore Value: <char>"),
613-
EditCommand::SelectAll => write!(f, "SelectAll"),
614-
EditCommand::CutSelection => write!(f, "CutSelection"),
615-
EditCommand::CopySelection => write!(f, "CopySelection"),
616-
EditCommand::Paste => write!(f, "Paste"),
617-
EditCommand::CopyFromStart => write!(f, "CopyFromStart"),
618-
EditCommand::CopyFromStartLinewise => write!(f, "CopyFromStartLinewise"),
619-
EditCommand::CopyFromLineStart => write!(f, "CopyFromLineStart"),
620-
EditCommand::CopyFromLineNonBlankStart => write!(f, "CopyFromLineNonBlankStart"),
621-
EditCommand::CopyToEnd => write!(f, "CopyToEnd"),
622-
EditCommand::CopyToEndLinewise => write!(f, "CopyToEndLinewise"),
623-
EditCommand::CopyToLineEnd => write!(f, "CopyToLineEnd"),
624-
EditCommand::CopyCurrentLine => write!(f, "CopyCurrentLine"),
625-
EditCommand::CopyWordLeft => write!(f, "CopyWordLeft"),
626-
EditCommand::CopyBigWordLeft => write!(f, "CopyBigWordLeft"),
627-
EditCommand::CopyWordRight => write!(f, "CopyWordRight"),
628-
EditCommand::CopyBigWordRight => write!(f, "CopyBigWordRight"),
629-
EditCommand::CopyWordRightToNext => write!(f, "CopyWordRightToNext"),
630-
EditCommand::CopyBigWordRightToNext => write!(f, "CopyBigWordRightToNext"),
631-
EditCommand::CopyLeft => write!(f, "CopyLeft"),
632-
EditCommand::CopyRight => write!(f, "CopyRight"),
633-
EditCommand::CopyRightUntil(_) => write!(f, "CopyRightUntil Value: <char>"),
634-
EditCommand::CopyRightBefore(_) => write!(f, "CopyRightBefore Value: <char>"),
635-
EditCommand::CopyLeftUntil(_) => write!(f, "CopyLeftUntil Value: <char>"),
636-
EditCommand::CopyLeftBefore(_) => write!(f, "CopyLeftBefore Value: <char>"),
637-
EditCommand::SwapCursorAndAnchor => write!(f, "SwapCursorAndAnchor"),
638-
#[cfg(feature = "system_clipboard")]
639-
EditCommand::CutSelectionSystem => write!(f, "CutSelectionSystem"),
640-
#[cfg(feature = "system_clipboard")]
641-
EditCommand::CopySelectionSystem => write!(f, "CopySelectionSystem"),
642-
#[cfg(feature = "system_clipboard")]
643-
EditCommand::PasteSystem => write!(f, "PasteSystem"),
644-
EditCommand::CutInsidePair { .. } => write!(f, "CutInsidePair Value: <char> <char>"),
645-
EditCommand::CopyInsidePair { .. } => write!(f, "CopyInsidePair Value: <char> <char>"),
646-
EditCommand::CutAroundPair { .. } => write!(f, "CutAroundPair Value: <char> <char>"),
647-
EditCommand::CopyAroundPair { .. } => write!(f, "CopyAroundPair Value: <char> <char>"),
648-
EditCommand::CutTextObject { .. } => write!(f, "CutTextObject Value: <TextObject>"),
649-
EditCommand::CopyTextObject { .. } => write!(f, "CopyTextObject Value: <TextObject>"),
650-
}
651-
}
652-
}
653-
654510
impl EditCommand {
655511
/// Determine if a certain operation should be undoable
656512
/// or if the operations should be coalesced for undoing
@@ -835,7 +691,7 @@ impl UndoBehavior {
835691
}
836692

837693
/// Reedline supported actions.
838-
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, EnumDiscriminants, EnumIter)]
694+
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug, EnumDiscriminants)]
839695
#[strum_discriminants(doc = "This is the auto generated discriminant type for [`ReedlineEvent`]")]
840696
#[strum_discriminants(derive(EnumIter, EnumString, VariantArray))]
841697
#[strum_discriminants(strum(ascii_case_insensitive))]
@@ -983,64 +839,6 @@ pub enum ReedlineEvent {
983839
ViChangeMode(String),
984840
}
985841

986-
// FIXME: This implementation makes no sense to be here, and should be removed in a future version
987-
// It was originally added for nushell to show all the available commands and their parameters to
988-
// the users.
989-
// This is also very hard to keep in sync with nushell.
990-
// So, recently its discriminants are exposed using the strum EnumDiscriminants, and downstream is
991-
// expected to use that if they want to display the list of available commands to their users.
992-
impl Display for ReedlineEvent {
993-
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
994-
match self {
995-
ReedlineEvent::None => write!(f, "None"),
996-
ReedlineEvent::HistoryHintComplete => write!(f, "HistoryHintComplete"),
997-
ReedlineEvent::HistoryHintWordComplete => write!(f, "HistoryHintWordComplete"),
998-
ReedlineEvent::CtrlD => write!(f, "CtrlD"),
999-
ReedlineEvent::CtrlC => write!(f, "CtrlC"),
1000-
ReedlineEvent::ClearScreen => write!(f, "ClearScreen"),
1001-
ReedlineEvent::ClearScrollback => write!(f, "ClearScrollback"),
1002-
ReedlineEvent::Enter => write!(f, "Enter"),
1003-
ReedlineEvent::Submit => write!(f, "Submit"),
1004-
ReedlineEvent::SubmitOrNewline => write!(f, "SubmitOrNewline"),
1005-
ReedlineEvent::Esc => write!(f, "Esc"),
1006-
ReedlineEvent::Mouse {
1007-
column,
1008-
row,
1009-
button,
1010-
} => write!(f, "Mouse({}, {}, {:?})", column, row, button),
1011-
ReedlineEvent::Resize(_, _) => write!(f, "Resize <int> <int>"),
1012-
ReedlineEvent::Edit(_) => write!(
1013-
f,
1014-
"Edit: <EditCommand> or Edit: <EditCommand> value: <string>"
1015-
),
1016-
ReedlineEvent::Repaint => write!(f, "Repaint"),
1017-
ReedlineEvent::PreviousHistory => write!(f, "PreviousHistory"),
1018-
ReedlineEvent::Up => write!(f, "Up"),
1019-
ReedlineEvent::Down => write!(f, "Down"),
1020-
ReedlineEvent::ToStart => write!(f, "ToStart"),
1021-
ReedlineEvent::ToEnd => write!(f, "ToEnd"),
1022-
ReedlineEvent::Right => write!(f, "Right"),
1023-
ReedlineEvent::Left => write!(f, "Left"),
1024-
ReedlineEvent::NextHistory => write!(f, "NextHistory"),
1025-
ReedlineEvent::SearchHistory => write!(f, "SearchHistory"),
1026-
ReedlineEvent::Multiple(_) => write!(f, "Multiple[ {{ ReedLineEvents, }} ]"),
1027-
ReedlineEvent::UntilFound(_) => write!(f, "UntilFound [ {{ ReedLineEvents, }} ]"),
1028-
ReedlineEvent::Menu(_) => write!(f, "Menu Name: <string>"),
1029-
ReedlineEvent::MenuNext => write!(f, "MenuNext"),
1030-
ReedlineEvent::MenuPrevious => write!(f, "MenuPrevious"),
1031-
ReedlineEvent::MenuUp => write!(f, "MenuUp"),
1032-
ReedlineEvent::MenuDown => write!(f, "MenuDown"),
1033-
ReedlineEvent::MenuLeft => write!(f, "MenuLeft"),
1034-
ReedlineEvent::MenuRight => write!(f, "MenuRight"),
1035-
ReedlineEvent::MenuPageNext => write!(f, "MenuPageNext"),
1036-
ReedlineEvent::MenuPagePrevious => write!(f, "MenuPagePrevious"),
1037-
ReedlineEvent::ExecuteHostCommand(_) => write!(f, "ExecuteHostCommand"),
1038-
ReedlineEvent::OpenEditor => write!(f, "OpenEditor"),
1039-
ReedlineEvent::ViChangeMode(_) => write!(f, "ViChangeMode mode: <string>"),
1040-
}
1041-
}
1042-
}
1043-
1044842
pub enum EventStatus {
1045843
Handled,
1046844
Inapplicable,

src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,6 @@ pub use utils::{
308308
get_reedline_default_keybindings, get_reedline_keybinding_modifiers, get_reedline_keycodes,
309309
};
310310

311-
#[expect(deprecated)]
312-
pub use utils::{
313-
get_reedline_edit_commands, get_reedline_prompt_edit_modes, get_reedline_reedline_events,
314-
};
315-
316311
// Reexport the key types to be independent from an explicit crossterm dependency.
317312
pub use crossterm::{
318313
event::{KeyCode, KeyModifiers},

src/prompt/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl PromptHistorySearch {
4343
}
4444

4545
/// Modes that the prompt can be in
46-
#[derive(Serialize, Deserialize, Clone, Debug, EnumIter, Default)]
46+
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
4747
pub enum PromptEditMode {
4848
/// The default mode
4949
#[default]

src/utils/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@ pub(crate) mod text_manipulation;
44
pub use query::{
55
get_reedline_default_keybindings, get_reedline_keybinding_modifiers, get_reedline_keycodes,
66
};
7-
8-
#[expect(deprecated)]
9-
pub use query::{
10-
get_reedline_edit_commands, get_reedline_prompt_edit_modes, get_reedline_reedline_events,
11-
};

src/utils/query.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use crate::{
22
default_emacs_keybindings, default_vi_insert_keybindings, default_vi_normal_keybindings,
3-
EditCommand, Keybindings, PromptEditMode, ReedlineEvent,
3+
Keybindings,
44
};
55
use crossterm::event::KeyCode;
66
use std::fmt::{Display, Formatter};
7-
use strum::IntoEnumIterator;
87

98
struct ReedLineCrossTermKeyCode(crossterm::event::KeyCode);
109
impl ReedLineCrossTermKeyCode {
@@ -89,31 +88,13 @@ pub fn get_reedline_keybinding_modifiers() -> Vec<String> {
8988
]
9089
}
9190

92-
/// Return a `Vec<String>` of the Reedline [`PromptEditMode`]s
93-
#[deprecated = "use PromptEditModeDiscriminants::iter() to display them"]
94-
pub fn get_reedline_prompt_edit_modes() -> Vec<String> {
95-
PromptEditMode::iter().map(|em| em.to_string()).collect()
96-
}
97-
9891
/// Return a `Vec<String>` of the Reedline `KeyCode`s
9992
pub fn get_reedline_keycodes() -> Vec<String> {
10093
ReedLineCrossTermKeyCode::iterator()
10194
.map(|kc| format!("{kc}"))
10295
.collect()
10396
}
10497

105-
/// Return a `Vec<String>` of the Reedline [`ReedlineEvent`]s
106-
#[deprecated = "use ReedlineEventDiscriminants::iter() to display them"]
107-
pub fn get_reedline_reedline_events() -> Vec<String> {
108-
ReedlineEvent::iter().map(|rle| rle.to_string()).collect()
109-
}
110-
111-
/// Return a `Vec<String>` of the Reedline [`EditCommand`]s
112-
#[deprecated = "use EditCommandDiscriminants::iter() to display them"]
113-
pub fn get_reedline_edit_commands() -> Vec<String> {
114-
EditCommand::iter().map(|edit| edit.to_string()).collect()
115-
}
116-
11798
/// Get the default keybindings and return a `Vec<(String, String, String, String)>`
11899
/// where String 1 is `mode`, String 2 is `key_modifiers`, String 3 is `key_code`, and
119100
/// Sting 4 is `event`

0 commit comments

Comments
 (0)