use std::fmt;
pub enum CopyModeCommand {
AppendSelection,
AppendSelectionAndCancel,
BackToIndentation,
BeginSelection,
BottomLine,
Cancel,
ClearSelection,
CopyEndOfLine(Option<String>),
CopyLine(Option<String>),
CopyPipe(String, Option<String>),
CopyPipeNoClear(String, Option<String>),
CopyPipeAndCancel(String, Option<String>),
CopySelection(Option<String>),
CopySelectionNoClear(Option<String>),
CopySelectionAndCancel(Option<String>),
CursorDown,
CursorDownAndCancel,
CursorLeft,
CursorRight,
CursorUp,
EndOfLine,
GotoLine(String),
HalfpageDown,
HalfpageDownAndCancel,
HalfpageUp,
HistoryBottom,
HistoryTop,
JumpAgain,
JumpBackward(String),
JumpForward(String),
JumpReverse,
JumpToBackward(String),
JumpToForward(String),
JumpToMark,
MiddleLine,
NextMatchingBracket,
NextParagraph,
NextSpace,
NextSpaceEnd,
NextWord,
NextWordEnd,
OtherEnd,
PageDown,
PageDownAndCancel,
PageUp,
Pipe(String, Option<String>),
PipeNoClear(String, Option<String>),
PipeAndCancel(String, Option<String>),
PreviousMatchingBracket,
PreviousParagraph,
PreviousSpace,
PreviousWord,
RectangleOn,
RectangleOff,
RectangleToggle,
RefreshFromPane,
ScrollDown,
ScrollDownAndCancel,
ScrollUp,
SearchAgain,
SearchBackward(String),
SearchBackwardIncremental(String),
SearchBackwardText(String),
SearchForward(String),
SearchForwardIncremental(String),
SearchForwardText(String),
SearchReverse,
SelectLine,
SelectWord,
SetMark,
StartOfLine,
StopSelection,
TopLine,
}
pub const APPEND_SELECTION: &str = "append-selection";
pub const APPEND_SELECTION_AND_CANCEL: &str = "append-selection-and-cancel";
pub const BACK_TO_INDENTATION: &str = "back-to-indentation";
pub const BEGIN_SELECTION: &str = "begin-selection";
pub const BOTTOM_LINE: &str = "bottom-line";
pub const CANCEL: &str = "cancel";
pub const CLEAR_SELECTION: &str = "clear-selection";
pub const COPY_END_OF_LINE: &str = "copy-end-of-line";
pub const COPY_LINE: &str = "copy-line";
pub const COPY_PIPE: &str = "copy-pipe";
pub const COPY_PIPE_NO_CLEAR: &str = "copy-pipe-no-clear";
pub const COPY_PIPE_AND_CANCEL: &str = "copy-pipe-and-cancel";
pub const COPY_SELECTION: &str = "copy-selection";
pub const COPY_SELECTION_NO_CLEAR: &str = "copy-selection-no-clear";
pub const COPY_SELECTION_AND_CANCEL: &str = "copy-selection-and-cancel";
pub const CURSOR_DOWN: &str = "cursor-down";
pub const CURSOR_DOWN_AND_CANCEL: &str = "cursor-down-and-cancel";
pub const CURSOR_LEFT: &str = "cursor-left";
pub const CURSOR_RIGHT: &str = "cursor-right";
pub const CURSOR_UP: &str = "cursor-up";
pub const END_OF_LINE: &str = "end-of-line";
pub const GOTO_LINE: &str = "goto-line";
pub const HALFPAGE_DOWN: &str = "halfpage-down";
pub const HALFPAGE_DOWN_AND_CANCEL: &str = "halfpage-down-and-cancel";
pub const HALFPAGE_UP: &str = "halfpage-up";
pub const HISTORY_BOTTOM: &str = "history-bottom";
pub const HISTORY_TOP: &str = "history-top";
pub const JUMP_AGAIN: &str = "jump-again";
pub const JUMP_BACKWARD: &str = "jump-backward";
pub const JUMP_FORWARD: &str = "jump-forward";
pub const JUMP_REVERSE: &str = "jump-reverse";
pub const JUMP_TO_BACKWARD: &str = "jump-to-backward";
pub const JUMP_TO_FORWARD: &str = "jump-to-forward";
pub const JUMP_TO_MARK: &str = "jump-to-mark";
pub const MIDDLE_LINE: &str = "middle-line";
pub const NEXT_MATCHING_BRACKET: &str = "next-matching-bracket";
pub const NEXT_PARAGRAPH: &str = "next-paragraph";
pub const NEXT_SPACE: &str = "next-space";
pub const NEXT_SPACE_END: &str = "next-space-end";
pub const NEXT_WORD: &str = "next-word";
pub const NEXT_WORD_END: &str = "next-word-end";
pub const OTHER_END: &str = "other-end";
pub const PAGE_DOWN: &str = "page-down";
pub const PAGE_DOWN_AND_CANCEL: &str = "page-down-and-cancel";
pub const PAGE_UP: &str = "page-up";
pub const PIPE: &str = "pipe";
pub const PIPE_NO_CLEAR: &str = "pipe-no-clear";
pub const PIPE_AND_CANCEL: &str = "pipe-and-cancel";
pub const PREVIOUS_MATCHING_BRACKET: &str = "previous-matching-bracket";
pub const PREVIOUS_PARAGRAPH: &str = "previous-paragraph";
pub const PREVIOUS_SPACE: &str = "previous-space";
pub const PREVIOUS_WORD: &str = "previous-word";
pub const RECTANGLE_ON: &str = "rectangle-on";
pub const RECTANGLE_OFF: &str = "rectangle-off";
pub const RECTANGLE_TOGGLE: &str = "rectangle-toggle";
pub const REFRESH_FROM_PANE: &str = "refresh-from-pane";
pub const SCROLL_DOWN: &str = "scroll-down";
pub const SCROLL_DOWN_AND_CANCEL: &str = "scroll-down-and-cancel";
pub const SCROLL_UP: &str = "scroll-up";
pub const SEARCH_AGAIN: &str = "search-again";
pub const SEARCH_BACKWARD: &str = "search-backward";
pub const SEARCH_BACKWARD_INCREMENTAL: &str = "search-backward-incremental";
pub const SEARCH_BACKWARD_TEXT: &str = "search-backward-text";
pub const SEARCH_FORWARD: &str = "search-forward";
pub const SEARCH_FORWARD_INCREMENTAL: &str = "search-forward-incremental";
pub const SEARCH_FORWARD_TEXT: &str = "search-forward-text";
pub const SEARCH_REVERSE: &str = "search-reverse";
pub const SELECT_LINE: &str = "select-line";
pub const SELECT_WORD: &str = "select-word";
pub const SET_MARK: &str = "set-mark";
pub const START_OF_LINE: &str = "start-of-line";
pub const STOP_SELECTION: &str = "stop-selection";
pub const TOP_LINE: &str = "top-line";
impl fmt::Display for CopyModeCommand {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = match self {
Self::AppendSelection => APPEND_SELECTION.to_string(),
Self::AppendSelectionAndCancel => APPEND_SELECTION_AND_CANCEL.to_string(),
Self::BackToIndentation => BACK_TO_INDENTATION.to_string(),
Self::BeginSelection => BEGIN_SELECTION.to_string(),
Self::BottomLine => BOTTOM_LINE.to_string(),
Self::Cancel => CANCEL.to_string(),
Self::ClearSelection => CLEAR_SELECTION.to_string(),
Self::CopyEndOfLine(prefix) => {
if let Some(prefix) = prefix {
format!("{} {}", COPY_END_OF_LINE, prefix)
} else {
COPY_END_OF_LINE.to_string()
}
}
Self::CopyLine(prefix) => {
if let Some(prefix) = prefix {
format!("{} {}", COPY_LINE, prefix)
} else {
COPY_LINE.to_string()
}
}
Self::CopyPipe(command, prefix) => {
if let Some(prefix) = prefix {
format!("{} {} {}", COPY_PIPE, command, prefix)
} else {
format!("{} {}", COPY_PIPE, command)
}
}
Self::CopyPipeNoClear(command, prefix) => {
if let Some(prefix) = prefix {
format!("{} {} {}", COPY_PIPE_NO_CLEAR, command, prefix)
} else {
format!("{} {}", COPY_PIPE_NO_CLEAR, command)
}
}
Self::CopyPipeAndCancel(command, prefix) => {
if let Some(prefix) = prefix {
format!("{} {} {}", COPY_PIPE_AND_CANCEL, command, prefix)
} else {
format!("{} {}", COPY_PIPE_AND_CANCEL, command)
}
}
Self::CopySelection(prefix) => {
if let Some(prefix) = prefix {
format!("{} {}", COPY_SELECTION, prefix)
} else {
COPY_SELECTION.to_string()
}
}
Self::CopySelectionNoClear(prefix) => {
if let Some(prefix) = prefix {
format!("{} {}", COPY_SELECTION_NO_CLEAR, prefix)
} else {
COPY_SELECTION_NO_CLEAR.to_string()
}
}
Self::CopySelectionAndCancel(prefix) => {
if let Some(prefix) = prefix {
format!("{} {}", COPY_SELECTION_AND_CANCEL, prefix)
} else {
COPY_SELECTION_AND_CANCEL.to_string()
}
}
Self::CursorDown => CURSOR_DOWN.to_string(),
Self::CursorDownAndCancel => CURSOR_DOWN_AND_CANCEL.to_string(),
Self::CursorLeft => CURSOR_LEFT.to_string(),
Self::CursorRight => CURSOR_RIGHT.to_string(),
Self::CursorUp => CURSOR_UP.to_string(),
Self::EndOfLine => END_OF_LINE.to_string(),
Self::GotoLine(line) => format!("{} {}", GOTO_LINE, line),
Self::HalfpageDown => HALFPAGE_DOWN.to_string(),
Self::HalfpageDownAndCancel => HALFPAGE_DOWN_AND_CANCEL.to_string(),
Self::HalfpageUp => HALFPAGE_UP.to_string(),
Self::HistoryBottom => HISTORY_BOTTOM.to_string(),
Self::HistoryTop => HISTORY_TOP.to_string(),
Self::JumpAgain => JUMP_AGAIN.to_string(),
Self::JumpBackward(to) => format!("{} {}", JUMP_BACKWARD, to),
Self::JumpForward(to) => format!("{} {}", JUMP_FORWARD, to),
Self::JumpReverse => JUMP_REVERSE.to_string(),
Self::JumpToBackward(to) => format!("{} {}", JUMP_TO_BACKWARD, to),
Self::JumpToForward(to) => format!("{} {}", JUMP_TO_FORWARD, to),
Self::JumpToMark => JUMP_TO_MARK.to_string(),
Self::MiddleLine => MIDDLE_LINE.to_string(),
Self::NextMatchingBracket => NEXT_MATCHING_BRACKET.to_string(),
Self::NextParagraph => NEXT_PARAGRAPH.to_string(),
Self::NextSpace => NEXT_SPACE.to_string(),
Self::NextSpaceEnd => NEXT_SPACE_END.to_string(),
Self::NextWord => NEXT_WORD.to_string(),
Self::NextWordEnd => NEXT_WORD_END.to_string(),
Self::OtherEnd => OTHER_END.to_string(),
Self::PageDown => PAGE_DOWN.to_string(),
Self::PageDownAndCancel => PAGE_DOWN_AND_CANCEL.to_string(),
Self::PageUp => PAGE_UP.to_string(),
Self::Pipe(command, prefix) => {
if let Some(prefix) = prefix {
format!("{} {} {}", PIPE, command, prefix)
} else {
format!("{} {}", PIPE, command)
}
}
Self::PipeNoClear(command, prefix) => {
if let Some(prefix) = prefix {
format!("{} {} {}", PIPE_NO_CLEAR, command, prefix)
} else {
format!("{} {}", PIPE_NO_CLEAR, command)
}
}
Self::PipeAndCancel(command, prefix) => {
if let Some(prefix) = prefix {
format!("{} {} {}", PIPE_AND_CANCEL, command, prefix)
} else {
format!("{} {}", PIPE_AND_CANCEL, command)
}
}
Self::PreviousMatchingBracket => PREVIOUS_MATCHING_BRACKET.to_string(),
Self::PreviousParagraph => PREVIOUS_PARAGRAPH.to_string(),
Self::PreviousSpace => PREVIOUS_SPACE.to_string(),
Self::PreviousWord => PREVIOUS_WORD.to_string(),
Self::RectangleOn => RECTANGLE_ON.to_string(),
Self::RectangleOff => RECTANGLE_OFF.to_string(),
Self::RectangleToggle => RECTANGLE_TOGGLE.to_string(),
Self::RefreshFromPane => REFRESH_FROM_PANE.to_string(),
Self::ScrollDown => SCROLL_DOWN.to_string(),
Self::ScrollDownAndCancel => SCROLL_DOWN_AND_CANCEL.to_string(),
Self::ScrollUp => SCROLL_UP.to_string(),
Self::SearchAgain => SEARCH_AGAIN.to_string(),
Self::SearchBackward(for_) => format!("{} {}", SEARCH_BACKWARD, for_),
Self::SearchBackwardIncremental(for_) => {
format!("{} {}", SEARCH_BACKWARD_INCREMENTAL, for_)
}
Self::SearchBackwardText(for_) => format!("{} {}", SEARCH_BACKWARD_TEXT, for_),
Self::SearchForward(for_) => format!("{} {}", SEARCH_FORWARD, for_),
Self::SearchForwardIncremental(for_) => {
format!("{} {}", SEARCH_FORWARD_INCREMENTAL, for_)
}
Self::SearchForwardText(for_) => format!("{} {}", SEARCH_FORWARD_TEXT, for_),
Self::SearchReverse => SEARCH_REVERSE.to_string(),
Self::SelectLine => SELECT_LINE.to_string(),
Self::SelectWord => SELECT_WORD.to_string(),
Self::SetMark => SET_MARK.to_string(),
Self::StartOfLine => START_OF_LINE.to_string(),
Self::StopSelection => STOP_SELECTION.to_string(),
Self::TopLine => TOP_LINE.to_string(),
};
write!(f, "{}", s)
}
}