repline: Make begin and again post-customizable, and once again fall out of sync

This commit is contained in:
John 2025-10-23 06:05:24 -04:00
parent e0eb0d5a02
commit 06ed0eae54
2 changed files with 10 additions and 2 deletions

View File

@ -26,8 +26,8 @@ pub struct Editor<'a> {
tail: VecDeque<char>, tail: VecDeque<char>,
pub color: &'a str, pub color: &'a str,
begin: &'a str, pub begin: &'a str,
again: &'a str, pub again: &'a str,
} }
impl<'a> Editor<'a> { impl<'a> Editor<'a> {

View File

@ -51,6 +51,14 @@ impl<'a, R: Read> Repline<'a, R> {
pub fn set_color(&mut self, color: &'a str) { pub fn set_color(&mut self, color: &'a str) {
self.ed.color = color self.ed.color = color
} }
/// Set the entire terminal prompt sequence
pub fn set_prompt(&mut self, color: &'a str, begin: &'a str, again: &'a str) {
self.ed.color = color;
self.ed.begin = begin;
self.ed.again = again;
}
/// Append line to history and clear it /// Append line to history and clear it
pub fn accept(&mut self) { pub fn accept(&mut self) {
self.history_append(self.ed.to_string()); self.history_append(self.ed.to_string());