23
23
#include < platform/logging/LogV.h>
24
24
25
25
#include < editline.h>
26
+ #include < stdlib.h>
26
27
27
- constexpr char kInteractiveModePrompt [] = " Stop and restart stack: [Ctrl+_] & [Ctrl+^] \n Quit Interactive: 'quit()'\n >>> " ;
28
+ constexpr char kInteractiveModePrompt [] = " Stop and restart stack: [Ctrl+_] & [Ctrl+^]\n "
29
+ " Trigger exit(0): [Ctrl+@]\n "
30
+ " Quit Interactive: 'quit()'\n "
31
+ " >>> " ;
28
32
constexpr char kInteractiveModeHistoryFilePath [] = " /tmp/darwin_framework_tool_history" ;
29
33
constexpr char kInteractiveModeStopCommand [] = " quit()" ;
30
34
constexpr char kCategoryError [] = " Error" ;
@@ -296,6 +300,12 @@ el_status_t StopFunction()
296
300
return CSstay;
297
301
}
298
302
303
+ el_status_t ExitFunction ()
304
+ {
305
+ exit (0 );
306
+ return CSstay;
307
+ }
308
+
299
309
CHIP_ERROR InteractiveStartCommand::RunCommand ()
300
310
{
301
311
read_history (kInteractiveModeHistoryFilePath );
@@ -304,8 +314,13 @@ el_status_t StopFunction()
304
314
// is dumped to stdout while the user is typing a command.
305
315
chip::Logging::SetLogRedirectCallback (LoggingCallback);
306
316
317
+ // The valid keys to bind are listed at
318
+ // https://github.com/troglobit/editline/blob/425584840c09f83bb8fedbf76b599d3a917621ba/src/editline.c#L1941
319
+ // but note that some bindings (like Ctrl+Q) might be captured by terminals
320
+ // and not make their way to this code.
307
321
el_bind_key (CTL (' ^' ), RestartFunction);
308
322
el_bind_key (CTL (' _' ), StopFunction);
323
+ el_bind_key (CTL (' @' ), ExitFunction);
309
324
310
325
char * command = nullptr ;
311
326
int status;
0 commit comments