@@ -276,12 +276,21 @@ where
276276    /// Add a byte to the menu runner's buffer. If this byte is a 
277277     /// carriage-return, the buffer is scanned and the appropriate action 
278278     /// performed. 
279+      /// By default, an echo feature is enabled to display commands on the terminal. 
279280     pub  fn  input_byte ( & mut  self ,  input :  u8 )  { 
280281        // Strip carriage returns 
281282        if  input == 0x0A  { 
282283            return ; 
283284        } 
284285        let  outcome = if  input == 0x0D  { 
286+             #[ cfg( not( feature = "echo" ) ) ]  
287+             { 
288+                 // Echo the command 
289+                 write ! ( self . context,  "\r " ) . unwrap ( ) ; 
290+                 if  let  Ok ( s)  = core:: str:: from_utf8 ( & self . buffer [ 0 ..self . used ] )  { 
291+                     write ! ( self . context,  "{}" ,  s) . unwrap ( ) ; 
292+                 } 
293+             } 
285294            // Handle the command 
286295            self . process_command ( ) ; 
287296            Outcome :: CommandProcessed 
@@ -296,19 +305,22 @@ where
296305            self . buffer [ self . used ]  = input; 
297306            self . used  += 1 ; 
298307
299-             // We have to do this song and dance because `self.prompt()` needs 
300-             // a mutable reference to self, and we can't have that while 
301-             // holding a reference to the buffer at the same time. 
302-             // This line grabs the buffer, checks it's OK, then releases it again 
303-             let  valid = core:: str:: from_utf8 ( & self . buffer [ 0 ..self . used ] ) . is_ok ( ) ; 
304-             // Now we've released the buffer, we can draw the prompt 
305-             if  valid { 
306-                 write ! ( self . context,  "\r " ) . unwrap ( ) ; 
307-                 self . prompt ( false ) ; 
308-             } 
309-             // Grab the buffer again to render it to the screen 
310-             if  let  Ok ( s)  = core:: str:: from_utf8 ( & self . buffer [ 0 ..self . used ] )  { 
311-                 write ! ( self . context,  "{}" ,  s) . unwrap ( ) ; 
308+             #[ cfg( feature = "echo" ) ]  
309+             { 
310+                 // We have to do this song and dance because `self.prompt()` needs 
311+                 // a mutable reference to self, and we can't have that while 
312+                 // holding a reference to the buffer at the same time. 
313+                 // This line grabs the buffer, checks it's OK, then releases it again 
314+                 let  valid = core:: str:: from_utf8 ( & self . buffer [ 0 ..self . used ] ) . is_ok ( ) ; 
315+                 // Now we've released the buffer, we can draw the prompt 
316+                 if  valid { 
317+                     write ! ( self . context,  "\r " ) . unwrap ( ) ; 
318+                     self . prompt ( false ) ; 
319+                 } 
320+                 // Grab the buffer again to render it to the screen 
321+                 if  let  Ok ( s)  = core:: str:: from_utf8 ( & self . buffer [ 0 ..self . used ] )  { 
322+                     write ! ( self . context,  "{}" ,  s) . unwrap ( ) ; 
323+                 } 
312324            } 
313325            Outcome :: NeedMore 
314326        }  else  { 
0 commit comments