comparison src/input.cc @ 6991:f20010b5dcf0

[project @ 2007-10-09 21:22:57 by dbateman]
author dbateman
date Tue, 09 Oct 2007 21:22:57 +0000
parents 2883ea1c5c18
children 6304d9ea0a30
comparison
equal deleted inserted replaced
6990:9dc99ab00c86 6991:f20010b5dcf0
533 return text; 533 return text;
534 else 534 else
535 return (std::string ("'") + text); 535 return (std::string ("'") + text);
536 } 536 }
537 537
538 static void
539 accept_line (const std::string &text)
540 {
541 // Close open strings if needed
542 bool sq = false;
543 bool dq = false;
544 bool pass_next = false;
545
546 for (std::string::const_iterator it = text.begin(); it < text.end(); it++)
547 {
548 if (pass_next)
549 pass_next = false;
550 else if (*it == '\\')
551 pass_next = true;
552 else if (*it == '\'' && ! dq)
553 sq = !sq;
554 else if (*it == '"' && ! sq)
555 dq = !dq;
556 }
557 if (sq)
558 command_editor::insert_text("'");
559 if (dq)
560 command_editor::insert_text("\"");
561 }
562
563 void 538 void
564 initialize_command_input (void) 539 initialize_command_input (void)
565 { 540 {
566 // If we are using readline, this allows conditional parsing of the 541 // If we are using readline, this allows conditional parsing of the
567 // .inputrc file. 542 // .inputrc file.
583 command_editor::set_completer_quote_characters ("'\""); 558 command_editor::set_completer_quote_characters ("'\"");
584 559
585 command_editor::set_completion_function (generate_completion); 560 command_editor::set_completion_function (generate_completion);
586 561
587 command_editor::set_quoting_function (quoting_filename); 562 command_editor::set_quoting_function (quoting_filename);
588
589 command_editor::set_user_accept_line_function (accept_line);
590 } 563 }
591 564
592 static bool 565 static bool
593 match_sans_spaces_semi (const std::string& standard, const std::string& test) 566 match_sans_spaces_semi (const std::string& standard, const std::string& test)
594 { 567 {