mirror of
https://github.com/nushell/reedline.git
synced 2024-09-20 20:48:13 +03:00
Fix documentation string formatting and linking (#482)
This commit is contained in:
parent
70118f732c
commit
db646e9ff5
@ -4,7 +4,7 @@ use crate::{core_editor::get_default_clipboard, EditCommand};
|
|||||||
|
|
||||||
/// Stateful editor executing changes to the underlying [`LineBuffer`]
|
/// Stateful editor executing changes to the underlying [`LineBuffer`]
|
||||||
///
|
///
|
||||||
/// In comparison to the state-less [`LineBuffer`] the `Editor` keeps track of
|
/// In comparison to the state-less [`LineBuffer`] the [`Editor`] keeps track of
|
||||||
/// the undo/redo history and has facilities for cut/copy/yank/paste
|
/// the undo/redo history and has facilities for cut/copy/yank/paste
|
||||||
pub struct Editor {
|
pub struct Editor {
|
||||||
line_buffer: LineBuffer,
|
line_buffer: LineBuffer,
|
||||||
@ -26,13 +26,13 @@ impl Default for Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Editor {
|
impl Editor {
|
||||||
/// Get the current LineBuffer
|
/// Get the current [`LineBuffer`]
|
||||||
pub fn line_buffer(&self) -> &LineBuffer {
|
pub fn line_buffer(&self) -> &LineBuffer {
|
||||||
&self.line_buffer
|
&self.line_buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the current LineBuffer.
|
/// Set the current [`LineBuffer`].
|
||||||
/// Undo behavior specifies how this change should be reflected on the undo stack.
|
/// [`UndoBehavior`] specifies how this change should be reflected on the undo stack.
|
||||||
pub(crate) fn set_line_buffer(&mut self, line_buffer: LineBuffer, undo_behavior: UndoBehavior) {
|
pub(crate) fn set_line_buffer(&mut self, line_buffer: LineBuffer, undo_behavior: UndoBehavior) {
|
||||||
self.line_buffer = line_buffer;
|
self.line_buffer = line_buffer;
|
||||||
self.update_undo_state(undo_behavior);
|
self.update_undo_state(undo_behavior);
|
||||||
@ -124,12 +124,12 @@ impl Editor {
|
|||||||
self.update_undo_state(UndoBehavior::MoveCursor);
|
self.update_undo_state(UndoBehavior::MoveCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the text of the current LineBuffer
|
/// Get the text of the current [`LineBuffer`]
|
||||||
pub fn get_buffer(&self) -> &str {
|
pub fn get_buffer(&self) -> &str {
|
||||||
self.line_buffer.get_buffer()
|
self.line_buffer.get_buffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Edit the line buffer in an undo-safe manner.
|
/// Edit the [`LineBuffer`] in an undo-safe manner.
|
||||||
pub fn edit_buffer<F>(&mut self, func: F, undo_behavior: UndoBehavior)
|
pub fn edit_buffer<F>(&mut self, func: F, undo_behavior: UndoBehavior)
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut LineBuffer),
|
F: FnOnce(&mut LineBuffer),
|
||||||
@ -138,7 +138,7 @@ impl Editor {
|
|||||||
func(&mut self.line_buffer);
|
func(&mut self.line_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the text of the current LineBuffer given the specified UndoBehavior
|
/// Set the text of the current [`LineBuffer`] given the specified [`UndoBehavior`]
|
||||||
/// Insertion point update to the end of the buffer.
|
/// Insertion point update to the end of the buffer.
|
||||||
pub(crate) fn set_buffer(&mut self, buffer: String, undo_behavior: UndoBehavior) {
|
pub(crate) fn set_buffer(&mut self, buffer: String, undo_behavior: UndoBehavior) {
|
||||||
self.line_buffer.set_buffer(buffer);
|
self.line_buffer.set_buffer(buffer);
|
||||||
|
@ -328,7 +328,7 @@ pub enum EditType {
|
|||||||
EditText,
|
EditText,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Every line change should come with an UndoBehavior tag, which can be used to
|
/// Every line change should come with an `UndoBehavior` tag, which can be used to
|
||||||
/// calculate how the change should be reflected on the undo stack
|
/// calculate how the change should be reflected on the undo stack
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum UndoBehavior {
|
pub enum UndoBehavior {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
//! To print messages while editing a line
|
//! To print messages while editing a line
|
||||||
|
//!
|
||||||
//! See example:
|
//! See example:
|
||||||
|
//!
|
||||||
|
//! ``` shell
|
||||||
//! cargo run --example external_printer --features=external_printer
|
//! cargo run --example external_printer --features=external_printer
|
||||||
|
//! ```
|
||||||
#[cfg(feature = "external_printer")]
|
#[cfg(feature = "external_printer")]
|
||||||
use {
|
use {
|
||||||
crossbeam::channel::{bounded, Receiver, SendError, Sender},
|
crossbeam::channel::{bounded, Receiver, SendError, Sender},
|
||||||
|
@ -139,7 +139,7 @@ impl SearchQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a history file or database
|
/// Represents a history file or database
|
||||||
/// Data could be stored e.g. in a plain text file, in a JSONL file, in a SQLite database
|
/// Data could be stored e.g. in a plain text file, in a `JSONL` file, in a `SQLite` database
|
||||||
pub trait History: Send {
|
pub trait History: Send {
|
||||||
/// save a history item to the database
|
/// save a history item to the database
|
||||||
/// if given id is None, a new id is created and set in the return value
|
/// if given id is None, a new id is created and set in the return value
|
||||||
|
@ -32,7 +32,7 @@ impl Display for HistorySessionId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This trait represents additional arbitrary context to be added to a history (optional, see [HistoryItem])
|
/// This trait represents additional arbitrary context to be added to a history (optional, see [`HistoryItem`])
|
||||||
pub trait HistoryItemExtraInfo: Serialize + DeserializeOwned + Default + Send {}
|
pub trait HistoryItemExtraInfo: Serialize + DeserializeOwned + Default + Send {}
|
||||||
|
|
||||||
#[derive(Default, Debug, PartialEq, Eq)]
|
#[derive(Default, Debug, PartialEq, Eq)]
|
||||||
|
Loading…
Reference in New Issue
Block a user