From 06ed0eae548d249b4a4d0eb65a05fe2dbb2ecc61 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 23 Oct 2025 06:05:24 -0400 Subject: [PATCH] repline: Make begin and again post-customizable, and once again fall out of sync --- repline/src/editor.rs | 4 ++-- repline/src/repline.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/repline/src/editor.rs b/repline/src/editor.rs index 903028b..0bbc1bf 100644 --- a/repline/src/editor.rs +++ b/repline/src/editor.rs @@ -26,8 +26,8 @@ pub struct Editor<'a> { tail: VecDeque, pub color: &'a str, - begin: &'a str, - again: &'a str, + pub begin: &'a str, + pub again: &'a str, } impl<'a> Editor<'a> { diff --git a/repline/src/repline.rs b/repline/src/repline.rs index dbfc714..49102a9 100644 --- a/repline/src/repline.rs +++ b/repline/src/repline.rs @@ -51,6 +51,14 @@ impl<'a, R: Read> Repline<'a, R> { pub fn set_color(&mut self, color: &'a str) { 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 pub fn accept(&mut self) { self.history_append(self.ed.to_string());