comparison src/input.cc @ 10315:57a59eae83cc

untabify src C++ source files
author John W. Eaton <jwe@octave.org>
date Thu, 11 Feb 2010 12:41:46 -0500
parents 095a1e670e68
children 479cc8a0a846
comparison
equal deleted inserted replaced
10314:07ebe522dac2 10315:57a59eae83cc
170 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive; 170 : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive;
171 171
172 if (do_echo) 172 if (do_echo)
173 { 173 {
174 if (forced_interactive) 174 if (forced_interactive)
175 { 175 {
176 if (promptflag > 0) 176 if (promptflag > 0)
177 octave_stdout << command_editor::decode_prompt_string (VPS1); 177 octave_stdout << command_editor::decode_prompt_string (VPS1);
178 else 178 else
179 octave_stdout << command_editor::decode_prompt_string (VPS2); 179 octave_stdout << command_editor::decode_prompt_string (VPS2);
180 } 180 }
181 else 181 else
182 octave_stdout << command_editor::decode_prompt_string (VPS4); 182 octave_stdout << command_editor::decode_prompt_string (VPS4);
183 183
184 if (! input_string.empty ()) 184 if (! input_string.empty ())
185 { 185 {
186 octave_stdout << input_string; 186 octave_stdout << input_string;
187 187
188 if (input_string[input_string.length () - 1] != '\n') 188 if (input_string[input_string.length () - 1] != '\n')
189 octave_stdout << "\n"; 189 octave_stdout << "\n";
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 std::string 194 std::string
195 gnu_readline (const std::string& s, bool force_readline) 195 gnu_readline (const std::string& s, bool force_readline)
203 bool eof; 203 bool eof;
204 204
205 retval = command_editor::readline (s, eof); 205 retval = command_editor::readline (s, eof);
206 206
207 if (! eof && retval.empty ()) 207 if (! eof && retval.empty ())
208 retval = "\n"; 208 retval = "\n";
209 } 209 }
210 else 210 else
211 { 211 {
212 if (! s.empty () && (interactive || forced_interactive)) 212 if (! s.empty () && (interactive || forced_interactive))
213 { 213 {
214 FILE *stream = command_editor::get_output_stream (); 214 FILE *stream = command_editor::get_output_stream ();
215 215
216 fputs (s.c_str (), stream); 216 fputs (s.c_str (), stream);
217 fflush (stream); 217 fflush (stream);
218 } 218 }
219 219
220 FILE *curr_stream = command_editor::get_input_stream (); 220 FILE *curr_stream = command_editor::get_input_stream ();
221 221
222 if (reading_fcn_file || reading_script_file || reading_classdef_file) 222 if (reading_fcn_file || reading_script_file || reading_classdef_file)
223 curr_stream = ff_instream; 223 curr_stream = ff_instream;
224 224
225 retval = octave_fgets (curr_stream); 225 retval = octave_fgets (curr_stream);
226 } 226 }
227 227
228 return retval; 228 return retval;
243 // in drawnow so that the error doesn't reappear at every prompt. 243 // in drawnow so that the error doesn't reappear at every prompt.
244 244
245 Vdrawnow_requested = false; 245 Vdrawnow_requested = false;
246 246
247 if (error_state) 247 if (error_state)
248 return "\n"; 248 return "\n";
249 } 249 }
250 250
251 return gnu_readline (s, force_readline); 251 return gnu_readline (s, force_readline);
252 } 252 }
253 253
260 260
261 bool history_skip_auto_repeated_debugging_command = false; 261 bool history_skip_auto_repeated_debugging_command = false;
262 262
263 if ((interactive || forced_interactive) 263 if ((interactive || forced_interactive)
264 && (! (reading_fcn_file 264 && (! (reading_fcn_file
265 || reading_classdef_file 265 || reading_classdef_file
266 || reading_script_file 266 || reading_script_file
267 || get_input_from_eval_string 267 || get_input_from_eval_string
268 || input_from_startup_file 268 || input_from_startup_file
269 || input_from_command_line_file))) 269 || input_from_command_line_file)))
270 { 270 {
271 std::string ps = (promptflag > 0) ? VPS1 : VPS2; 271 std::string ps = (promptflag > 0) ? VPS1 : VPS2;
272 272
273 std::string prompt = command_editor::decode_prompt_string (ps); 273 std::string prompt = command_editor::decode_prompt_string (ps);
274 274
281 retval = interactive_input (prompt); 281 retval = interactive_input (prompt);
282 282
283 // There is no need to update the load_path cache if there is no 283 // There is no need to update the load_path cache if there is no
284 // user input. 284 // user input.
285 if (! retval.empty () 285 if (! retval.empty ()
286 && retval.find_first_not_of (" \t\n\r") != std::string::npos) 286 && retval.find_first_not_of (" \t\n\r") != std::string::npos)
287 { 287 {
288 load_path::update (); 288 load_path::update ();
289 289
290 if (Vdebugging) 290 if (Vdebugging)
291 last_debugging_command = retval; 291 last_debugging_command = retval;
292 else 292 else
293 last_debugging_command = std::string (); 293 last_debugging_command = std::string ();
294 } 294 }
295 else if (Vdebugging) 295 else if (Vdebugging)
296 { 296 {
297 retval = last_debugging_command; 297 retval = last_debugging_command;
298 history_skip_auto_repeated_debugging_command = true; 298 history_skip_auto_repeated_debugging_command = true;
299 } 299 }
300 } 300 }
301 else 301 else
302 retval = gnu_readline (""); 302 retval = gnu_readline ("");
303 303
304 current_input_line = retval; 304 current_input_line = retval;
305 305
306 if (! current_input_line.empty ()) 306 if (! current_input_line.empty ())
307 { 307 {
308 if (! (input_from_startup_file || input_from_command_line_file 308 if (! (input_from_startup_file || input_from_command_line_file
309 || history_skip_auto_repeated_debugging_command)) 309 || history_skip_auto_repeated_debugging_command))
310 command_history::add (current_input_line); 310 command_history::add (current_input_line);
311 311
312 if (! (reading_fcn_file || reading_script_file || reading_classdef_file)) 312 if (! (reading_fcn_file || reading_script_file || reading_classdef_file))
313 { 313 {
314 octave_diary << current_input_line; 314 octave_diary << current_input_line;
315 315
316 if (current_input_line[current_input_line.length () - 1] != '\n') 316 if (current_input_line[current_input_line.length () - 1] != '\n')
317 octave_diary << "\n"; 317 octave_diary << "\n";
318 } 318 }
319 319
320 do_input_echo (current_input_line); 320 do_input_echo (current_input_line);
321 } 321 }
322 else if (! (reading_fcn_file || reading_script_file || reading_classdef_file)) 322 else if (! (reading_fcn_file || reading_script_file || reading_classdef_file))
323 octave_diary << "\n"; 323 octave_diary << "\n";
335 std::string retval; 335 std::string retval;
336 336
337 if (get_input_from_eval_string) 337 if (get_input_from_eval_string)
338 { 338 {
339 if (input_from_eval_string_pending) 339 if (input_from_eval_string_pending)
340 { 340 {
341 input_from_eval_string_pending = false; 341 input_from_eval_string_pending = false;
342 342
343 retval = current_eval_string; 343 retval = current_eval_string;
344 344
345 size_t len = retval.length (); 345 size_t len = retval.length ();
346 346
347 if (len > 0 && retval[len-1] != '\n') 347 if (len > 0 && retval[len-1] != '\n')
348 retval.append ("\n"); 348 retval.append ("\n");
349 } 349 }
350 } 350 }
351 else 351 else
352 retval = octave_gets (); 352 retval = octave_gets ();
353 353
354 current_input_line = retval; 354 current_input_line = retval;
388 chars_left -= len; 388 chars_left -= len;
389 pos += len; 389 pos += len;
390 390
391 // Make sure input ends with a new line character. 391 // Make sure input ends with a new line character.
392 if (chars_left == 0 && buf[len-1] != '\n') 392 if (chars_left == 0 && buf[len-1] != '\n')
393 { 393 {
394 if (len < max_size) 394 if (len < max_size)
395 { 395 {
396 // There is enough room to plug the newline character in 396 // There is enough room to plug the newline character in
397 // the buffer. 397 // the buffer.
398 buf[len++] = '\n'; 398 buf[len++] = '\n';
399 } 399 }
400 else 400 else
401 { 401 {
402 // There isn't enough room to plug the newline character 402 // There isn't enough room to plug the newline character
403 // in the buffer so make sure it is returned on the next 403 // in the buffer so make sure it is returned on the next
404 // octave_read call. 404 // octave_read call.
405 pos = eol; 405 pos = eol;
406 chars_left = 1; 406 chars_left = 1;
407 } 407 }
408 } 408 }
409 409
410 status = len; 410 status = len;
411 411
412 } 412 }
413 else if (chars_left == 0) 413 else if (chars_left == 0)
455 455
456 // FIXME -- make this generate file names when appropriate. 456 // FIXME -- make this generate file names when appropriate.
457 457
458 static string_vector 458 static string_vector
459 generate_possible_completions (const std::string& text, std::string& prefix, 459 generate_possible_completions (const std::string& text, std::string& prefix,
460 std::string& hint) 460 std::string& hint)
461 { 461 {
462 string_vector names; 462 string_vector names;
463 463
464 prefix = ""; 464 prefix = "";
465 465
488 for (size_t i = 0; i < dirfns_commands_length; i++) 488 for (size_t i = 0; i < dirfns_commands_length; i++)
489 { 489 {
490 int index = line.find (dirfns_commands[i] + " "); 490 int index = line.find (dirfns_commands[i] + " ");
491 491
492 if (index == 0) 492 if (index == 0)
493 { 493 {
494 retval = true; 494 retval = true;
495 break; 495 break;
496 } 496 }
497 } 497 }
498 498
499 return retval; 499 return retval;
500 } 500 }
501 501
527 527
528 // No reason to display symbols while completing a 528 // No reason to display symbols while completing a
529 // file/directory operation. 529 // file/directory operation.
530 530
531 if (is_completing_dirfns ()) 531 if (is_completing_dirfns ())
532 name_list = string_vector (); 532 name_list = string_vector ();
533 else 533 else
534 name_list = generate_possible_completions (text, prefix, hint); 534 name_list = generate_possible_completions (text, prefix, hint);
535 535
536 name_list_len = name_list.length (); 536 name_list_len = name_list.length ();
537 537
544 hint_len = hint.length (); 544 hint_len = hint.length ();
545 545
546 matches = 0; 546 matches = 0;
547 547
548 for (int i = 0; i < name_list_len; i++) 548 for (int i = 0; i < name_list_len; i++)
549 if (hint == name_list[i].substr (0, hint_len)) 549 if (hint == name_list[i].substr (0, hint_len))
550 matches++; 550 matches++;
551 } 551 }
552 552
553 if (name_list_total_len > 0 && matches > 0) 553 if (name_list_total_len > 0 && matches > 0)
554 { 554 {
555 while (list_index < name_list_total_len) 555 while (list_index < name_list_total_len)
556 { 556 {
557 std::string name = name_list[list_index]; 557 std::string name = name_list[list_index];
558 558
559 list_index++; 559 list_index++;
560 560
561 if (hint == name.substr (0, hint_len)) 561 if (hint == name.substr (0, hint_len))
562 { 562 {
563 if (list_index <= name_list_len && ! prefix.empty ()) 563 if (list_index <= name_list_len && ! prefix.empty ())
564 retval = prefix + "." + name; 564 retval = prefix + "." + name;
565 else 565 else
566 retval = name; 566 retval = name;
567 567
568 // FIXME -- looks_like_struct is broken for now, 568 // FIXME -- looks_like_struct is broken for now,
569 // so it always returns false. 569 // so it always returns false.
570 570
571 if (matches == 1 && looks_like_struct (retval)) 571 if (matches == 1 && looks_like_struct (retval))
572 { 572 {
573 // Don't append anything, since we don't know 573 // Don't append anything, since we don't know
574 // whether it should be '(' or '.'. 574 // whether it should be '(' or '.'.
575 575
576 command_editor::set_completion_append_character ('\0'); 576 command_editor::set_completion_append_character ('\0');
577 } 577 }
578 else 578 else
579 command_editor::set_completion_append_character 579 command_editor::set_completion_append_character
580 (Vcompletion_append_char); 580 (Vcompletion_append_char);
581 581
582 break; 582 break;
583 } 583 }
584 } 584 }
585 } 585 }
586 586
587 return retval; 587 return retval;
588 } 588 }
589 589
636 if (caller) 636 if (caller)
637 { 637 {
638 nm = caller->fcn_file_name (); 638 nm = caller->fcn_file_name ();
639 639
640 if (nm.empty ()) 640 if (nm.empty ())
641 nm = caller->name (); 641 nm = caller->name ();
642 else 642 else
643 have_file = true; 643 have_file = true;
644 } 644 }
645 else 645 else
646 curr_debug_line = -1; 646 curr_debug_line = -1;
647 647
648 std::ostringstream buf; 648 std::ostringstream buf;
649 649
650 if (! nm.empty ()) 650 if (! nm.empty ())
651 { 651 {
652 if (Vgud_mode) 652 if (Vgud_mode)
653 { 653 {
654 static char ctrl_z = 'Z' & 0x1f; 654 static char ctrl_z = 'Z' & 0x1f;
655 655
656 buf << ctrl_z << ctrl_z << nm << ":" << curr_debug_line; 656 buf << ctrl_z << ctrl_z << nm << ":" << curr_debug_line;
657 } 657 }
658 else 658 else
659 { 659 {
660 // FIXME -- we should come up with a clean way to detect 660 // FIXME -- we should come up with a clean way to detect
661 // that we are stopped on the no-op command that marks the 661 // that we are stopped on the no-op command that marks the
662 // end of a function or script. 662 // end of a function or script.
663 663
664 buf << "stopped in " << nm; 664 buf << "stopped in " << nm;
665 665
666 if (curr_debug_line > 0) 666 if (curr_debug_line > 0)
667 buf << " at line " << curr_debug_line; 667 buf << " at line " << curr_debug_line;
668 668
669 if (have_file) 669 if (have_file)
670 { 670 {
671 std::string line_buf 671 std::string line_buf
672 = get_file_line (nm, curr_debug_line); 672 = get_file_line (nm, curr_debug_line);
673 673
674 if (! line_buf.empty ()) 674 if (! line_buf.empty ())
675 buf << "\n" << curr_debug_line << ": " << line_buf; 675 buf << "\n" << curr_debug_line << ": " << line_buf;
676 } 676 }
677 } 677 }
678 } 678 }
679 679
680 std::string msg = buf.str (); 680 std::string msg = buf.str ();
681 681
682 if (! msg.empty ()) 682 if (! msg.empty ())
803 std::string input_buf = interactive_input (prompt.c_str (), true); 803 std::string input_buf = interactive_input (prompt.c_str (), true);
804 804
805 if (! (error_state || input_buf.empty ())) 805 if (! (error_state || input_buf.empty ()))
806 { 806 {
807 if (! input_from_startup_file) 807 if (! input_from_startup_file)
808 command_history::add (input_buf); 808 command_history::add (input_buf);
809 809
810 size_t len = input_buf.length (); 810 size_t len = input_buf.length ();
811 811
812 octave_diary << input_buf; 812 octave_diary << input_buf;
813 813
814 if (input_buf[len - 1] != '\n') 814 if (input_buf[len - 1] != '\n')
815 octave_diary << "\n"; 815 octave_diary << "\n";
816 816
817 if (len < 1) 817 if (len < 1)
818 return read_as_string ? octave_value ("") : octave_value (Matrix ()); 818 return read_as_string ? octave_value ("") : octave_value (Matrix ());
819 819
820 if (read_as_string) 820 if (read_as_string)
821 { 821 {
822 // FIXME -- fix gnu_readline and octave_gets instead! 822 // FIXME -- fix gnu_readline and octave_gets instead!
823 if (input_buf.length () == 1 && input_buf[0] == '\n') 823 if (input_buf.length () == 1 && input_buf[0] == '\n')
824 retval(0) = ""; 824 retval(0) = "";
825 else 825 else
826 retval(0) = input_buf; 826 retval(0) = input_buf;
827 } 827 }
828 else 828 else
829 { 829 {
830 int parse_status = 0; 830 int parse_status = 0;
831 831
832 retval = eval_string (input_buf, true, parse_status, nargout); 832 retval = eval_string (input_buf, true, parse_status, nargout);
833 833
834 if (! Vdebugging && retval.length () == 0) 834 if (! Vdebugging && retval.length () == 0)
835 retval(0) = Matrix (); 835 retval(0) = Matrix ();
836 } 836 }
837 } 837 }
838 else 838 else
839 error ("input: reading user-input failed!"); 839 error ("input: reading user-input failed!");
840 840
841 return retval; 841 return retval;
897 while (1) 897 while (1)
898 { 898 {
899 std::string input_buf = interactive_input (prompt_string, true); 899 std::string input_buf = interactive_input (prompt_string, true);
900 900
901 if (input_buf == "yes") 901 if (input_buf == "yes")
902 return true; 902 return true;
903 else if (input_buf == "no") 903 else if (input_buf == "no")
904 return false; 904 return false;
905 else 905 else
906 message (0, "Please answer yes or no."); 906 message (0, "Please answer yes or no.");
907 } 907 }
908 } 908 }
909 909
910 DEFUN (yes_or_no, args, , 910 DEFUN (yes_or_no, args, ,
911 "-*- texinfo -*-\n\ 911 "-*- texinfo -*-\n\
924 if (nargin == 0 || nargin == 1) 924 if (nargin == 0 || nargin == 1)
925 { 925 {
926 std::string prompt; 926 std::string prompt;
927 927
928 if (nargin == 1) 928 if (nargin == 1)
929 { 929 {
930 prompt = args(0).string_value (); 930 prompt = args(0).string_value ();
931 931
932 if (error_state) 932 if (error_state)
933 { 933 {
934 error ("yes_or_no: expecting argument to be character string"); 934 error ("yes_or_no: expecting argument to be character string");
935 return retval; 935 return retval;
936 } 936 }
937 } 937 }
938 938
939 retval = octave_yes_or_no (prompt); 939 retval = octave_yes_or_no (prompt);
940 } 940 }
941 else 941 else
942 print_usage (); 942 print_usage ();
1067 1067
1068 switch (argc) 1068 switch (argc)
1069 { 1069 {
1070 case 1: 1070 case 1:
1071 { 1071 {
1072 if ((Vecho_executing_commands & ECHO_SCRIPTS) 1072 if ((Vecho_executing_commands & ECHO_SCRIPTS)
1073 || (Vecho_executing_commands & ECHO_FUNCTIONS)) 1073 || (Vecho_executing_commands & ECHO_FUNCTIONS))
1074 Vecho_executing_commands = ECHO_OFF; 1074 Vecho_executing_commands = ECHO_OFF;
1075 else 1075 else
1076 Vecho_executing_commands = ECHO_SCRIPTS; 1076 Vecho_executing_commands = ECHO_SCRIPTS;
1077 } 1077 }
1078 break; 1078 break;
1079 1079
1080 case 2: 1080 case 2:
1081 { 1081 {
1082 std::string arg = argv[1]; 1082 std::string arg = argv[1];
1083 1083
1084 if (arg == "on") 1084 if (arg == "on")
1085 Vecho_executing_commands = ECHO_SCRIPTS; 1085 Vecho_executing_commands = ECHO_SCRIPTS;
1086 else if (arg == "off") 1086 else if (arg == "off")
1087 Vecho_executing_commands = ECHO_OFF; 1087 Vecho_executing_commands = ECHO_OFF;
1088 else 1088 else
1089 print_usage (); 1089 print_usage ();
1090 } 1090 }
1091 break; 1091 break;
1092 1092
1093 case 3: 1093 case 3:
1094 { 1094 {
1095 std::string arg = argv[1]; 1095 std::string arg = argv[1];
1096 1096
1097 if (arg == "on" && argv[2] == "all") 1097 if (arg == "on" && argv[2] == "all")
1098 { 1098 {
1099 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS); 1099 int tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS);
1100 Vecho_executing_commands = tmp; 1100 Vecho_executing_commands = tmp;
1101 } 1101 }
1102 else if (arg == "off" && argv[2] == "all") 1102 else if (arg == "off" && argv[2] == "all")
1103 Vecho_executing_commands = ECHO_OFF; 1103 Vecho_executing_commands = ECHO_OFF;
1104 else 1104 else
1105 print_usage (); 1105 print_usage ();
1106 } 1106 }
1107 break; 1107 break;
1108 1108
1109 default: 1109 default:
1110 print_usage (); 1110 print_usage ();
1132 if (nargin == 1) 1132 if (nargin == 1)
1133 { 1133 {
1134 std::string hint = args(0).string_value (); 1134 std::string hint = args(0).string_value ();
1135 1135
1136 if (! error_state) 1136 if (! error_state)
1137 { 1137 {
1138 int n = 32; 1138 int n = 32;
1139 1139
1140 string_vector list (n); 1140 string_vector list (n);
1141 1141
1142 int k = 0; 1142 int k = 0;
1143 1143
1144 for (;;) 1144 for (;;)
1145 { 1145 {
1146 std::string cmd = generate_completion (hint, k); 1146 std::string cmd = generate_completion (hint, k);
1147 1147
1148 if (! cmd.empty ()) 1148 if (! cmd.empty ())
1149 { 1149 {
1150 if (k == n) 1150 if (k == n)
1151 { 1151 {
1152 n *= 2; 1152 n *= 2;
1153 list.resize (n); 1153 list.resize (n);
1154 } 1154 }
1155 1155
1156 list[k++] = cmd; 1156 list[k++] = cmd;
1157 } 1157 }
1158 else 1158 else
1159 { 1159 {
1160 list.resize (k); 1160 list.resize (k);
1161 break; 1161 break;
1162 } 1162 }
1163 } 1163 }
1164 1164
1165 if (nargout > 0) 1165 if (nargout > 0)
1166 { 1166 {
1167 if (! list.empty ()) 1167 if (! list.empty ())
1168 retval = list; 1168 retval = list;
1169 else 1169 else
1170 retval = ""; 1170 retval = "";
1171 } 1171 }
1172 else 1172 else
1173 { 1173 {
1174 // We don't use string_vector::list_in_columns here 1174 // We don't use string_vector::list_in_columns here
1175 // because it will be easier for Emacs if the names 1175 // because it will be easier for Emacs if the names
1176 // appear in a single column. 1176 // appear in a single column.
1177 1177
1178 int len = list.length (); 1178 int len = list.length ();
1179 1179
1180 for (int i = 0; i < len; i++) 1180 for (int i = 0; i < len; i++)
1181 octave_stdout << list[i] << "\n"; 1181 octave_stdout << list[i] << "\n";
1182 } 1182 }
1183 1183
1184 octave_completion_matches_called = true; 1184 octave_completion_matches_called = true;
1185 } 1185 }
1186 } 1186 }
1187 else 1187 else
1188 print_usage (); 1188 print_usage ();
1189 1189
1190 return retval; 1190 return retval;
1210 else if (nargin == 1) 1210 else if (nargin == 1)
1211 { 1211 {
1212 std::string file = args(0).string_value (); 1212 std::string file = args(0).string_value ();
1213 1213
1214 if (! error_state) 1214 if (! error_state)
1215 command_editor::read_init_file (file); 1215 command_editor::read_init_file (file);
1216 } 1216 }
1217 else 1217 else
1218 print_usage (); 1218 print_usage ();
1219 1219
1220 return retval; 1220 return retval;
1253 octave_value user_data = p->second; 1253 octave_value user_data = p->second;
1254 1254
1255 p++; 1255 p++;
1256 1256
1257 if (is_valid_function (hook_fcn)) 1257 if (is_valid_function (hook_fcn))
1258 { 1258 {
1259 if (user_data.is_defined ()) 1259 if (user_data.is_defined ())
1260 feval (hook_fcn, user_data, 0); 1260 feval (hook_fcn, user_data, 0);
1261 else 1261 else
1262 feval (hook_fcn, octave_value_list (), 0); 1262 feval (hook_fcn, octave_value_list (), 0);
1263 } 1263 }
1264 else 1264 else
1265 hook_fcn_map.erase (p); 1265 hook_fcn_map.erase (p);
1266 } 1266 }
1267 1267
1268 if (hook_fcn_map.empty ()) 1268 if (hook_fcn_map.empty ())
1269 command_editor::remove_event_hook (input_event_hook); 1269 command_editor::remove_event_hook (input_event_hook);
1270 1270
1293 if (nargin == 1 || nargin == 2) 1293 if (nargin == 1 || nargin == 2)
1294 { 1294 {
1295 octave_value user_data; 1295 octave_value user_data;
1296 1296
1297 if (nargin == 2) 1297 if (nargin == 2)
1298 user_data = args(1); 1298 user_data = args(1);
1299 1299
1300 std::string hook_fcn = args(0).string_value (); 1300 std::string hook_fcn = args(0).string_value ();
1301 1301
1302 if (! error_state) 1302 if (! error_state)
1303 { 1303 {
1304 if (hook_fcn_map.empty ()) 1304 if (hook_fcn_map.empty ())
1305 command_editor::add_event_hook (input_event_hook); 1305 command_editor::add_event_hook (input_event_hook);
1306 1306
1307 hook_fcn_map[hook_fcn] = user_data; 1307 hook_fcn_map[hook_fcn] = user_data;
1308 } 1308 }
1309 else 1309 else
1310 error ("add_input_event_hook: expecting string as first arg"); 1310 error ("add_input_event_hook: expecting string as first arg");
1311 } 1311 }
1312 else 1312 else
1313 print_usage (); 1313 print_usage ();
1314 1314
1315 return retval; 1315 return retval;
1330 if (nargin == 1) 1330 if (nargin == 1)
1331 { 1331 {
1332 std::string hook_fcn = args(0).string_value (); 1332 std::string hook_fcn = args(0).string_value ();
1333 1333
1334 if (! error_state) 1334 if (! error_state)
1335 { 1335 {
1336 hook_fcn_map_type::iterator p = hook_fcn_map.find (hook_fcn); 1336 hook_fcn_map_type::iterator p = hook_fcn_map.find (hook_fcn);
1337 1337
1338 if (p != hook_fcn_map.end ()) 1338 if (p != hook_fcn_map.end ())
1339 hook_fcn_map.erase (p); 1339 hook_fcn_map.erase (p);
1340 else 1340 else
1341 error ("remove_input_event_hook: %s not found in list", 1341 error ("remove_input_event_hook: %s not found in list",
1342 hook_fcn.c_str ()); 1342 hook_fcn.c_str ());
1343 1343
1344 if (hook_fcn_map.empty ()) 1344 if (hook_fcn_map.empty ())
1345 command_editor::remove_event_hook (input_event_hook); 1345 command_editor::remove_event_hook (input_event_hook);
1346 } 1346 }
1347 else 1347 else
1348 error ("remove_input_event_hook: expecting string as first arg"); 1348 error ("remove_input_event_hook: expecting string as first arg");
1349 } 1349 }
1350 else 1350 else
1351 print_usage (); 1351 print_usage ();
1352 1352
1353 return retval; 1353 return retval;