comparison src/input.cc @ 6979:2883ea1c5c18

[project @ 2007-10-08 20:23:48 by dbateman]
author dbateman
date Mon, 08 Oct 2007 20:26:01 +0000
parents 6bbf56a9718a
children f20010b5dcf0
comparison
equal deleted inserted replaced
6978:b75630794a11 6979:2883ea1c5c18
505 retval = name; 505 retval = name;
506 506
507 // FIXME -- looks_like_struct is broken for now, 507 // FIXME -- looks_like_struct is broken for now,
508 // so it always returns false. 508 // so it always returns false.
509 509
510 if (matches == 1 && looks_like_struct (retval)) 510 if (matches == 1 && looks_like_struct (retval))
511 { 511 {
512 // Don't append anything, since we don't know 512 // Don't append anything, since we don't know
513 // whether it should be '(' or '.'. 513 // whether it should be '(' or '.'.
514 514
515 command_editor::set_completion_append_character ('\0'); 515 command_editor::set_completion_append_character ('\0');
524 } 524 }
525 525
526 return retval; 526 return retval;
527 } 527 }
528 528
529 static std::string
530 quoting_filename (const std::string &text, int, char quote)
531 {
532 if (quote)
533 return text;
534 else
535 return (std::string ("'") + text);
536 }
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
529 void 563 void
530 initialize_command_input (void) 564 initialize_command_input (void)
531 { 565 {
532 // If we are using readline, this allows conditional parsing of the 566 // If we are using readline, this allows conditional parsing of the
533 // .inputrc file. 567 // .inputrc file.
543 577
544 command_editor::set_completer_word_break_characters (s); 578 command_editor::set_completer_word_break_characters (s);
545 579
546 command_editor::set_basic_quote_characters ("\""); 580 command_editor::set_basic_quote_characters ("\"");
547 581
582 command_editor::set_filename_quote_characters (" \t\n\\\"'@<>=;|&()#$`?*[!:{");
583 command_editor::set_completer_quote_characters ("'\"");
584
548 command_editor::set_completion_function (generate_completion); 585 command_editor::set_completion_function (generate_completion);
586
587 command_editor::set_quoting_function (quoting_filename);
588
589 command_editor::set_user_accept_line_function (accept_line);
549 } 590 }
550 591
551 static bool 592 static bool
552 match_sans_spaces_semi (const std::string& standard, const std::string& test) 593 match_sans_spaces_semi (const std::string& standard, const std::string& test)
553 { 594 {