GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cmd-edit.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <cstdlib>
28 #include <cstring>
29 
30 #include <string>
31 
32 #include "cmd-edit.h"
33 #include "cmd-hist.h"
34 #include "file-ops.h"
35 #include "file-stat.h"
36 #include "lo-error.h"
37 #include "lo-utils.h"
38 #include "oct-env.h"
39 #include "oct-mutex.h"
40 #include "oct-time.h"
41 #include "quit.h"
42 #include "singleton-cleanup.h"
43 #include "strdup-wrapper.h"
44 #include "unistd-wrappers.h"
45 
46 #if defined (USE_READLINE)
47 #include <cstdio>
48 
49 #include "oct-rl-edit.h"
50 #endif
51 
52 namespace octave
53 {
55 
56  command_editor *command_editor::instance = 0;
57 
58  std::set<command_editor::startup_hook_fcn> command_editor::startup_hook_set;
59 
60  std::set<command_editor::pre_input_hook_fcn> command_editor::pre_input_hook_set;
61 
62  std::set<command_editor::event_hook_fcn> command_editor::event_hook_set;
63 
65 
66 #if defined (USE_READLINE)
67 
68  class
70  {
71  public:
72 
73  typedef command_editor::startup_hook_fcn startup_hook_fcn;
74 
75  typedef command_editor::pre_input_hook_fcn pre_input_hook_fcn;
76 
77  typedef command_editor::event_hook_fcn event_hook_fcn;
78 
79  typedef command_editor::completion_fcn completion_fcn;
80 
81  gnu_readline (void);
82 
83  ~gnu_readline (void) { }
84 
85  void do_set_name (const std::string& n);
86 
87  std::string do_readline (const std::string& prompt, bool& eof);
88 
89  void do_set_input_stream (FILE *f);
90 
91  FILE *do_get_input_stream (void);
92 
93  void do_set_output_stream (FILE *f);
94 
95  FILE *do_get_output_stream (void);
96 
97  void do_redisplay (void);
98 
99  int do_terminal_rows (void);
100 
101  int do_terminal_cols (void);
102 
103  void do_clear_screen (bool skip_redisplay);
104 
105  void do_resize_terminal (void);
106 
107  void do_set_screen_size (int ht, int wd);
108 
109  std::string newline_chars (void);
110 
111  void do_restore_terminal_state (void);
112 
113  void do_blink_matching_paren (bool flag);
114 
115  bool do_erase_empty_line (bool flag);
116 
117  void do_set_basic_word_break_characters (const std::string& s);
118 
119  void do_set_completer_word_break_characters (const std::string& s);
120 
121  void do_set_basic_quote_characters (const std::string& s);
122 
123  void do_set_filename_quote_characters (const std::string& s);
124 
125  void do_set_completer_quote_characters (const std::string& s);
126 
127  void do_set_completion_append_character (char c);
128 
129  void do_set_completion_function (completion_fcn f);
130 
131  void do_set_quoting_function (quoting_fcn f);
132 
133  void do_set_dequoting_function (dequoting_fcn f);
134 
135  void do_set_char_is_quoted_function (char_is_quoted_fcn f);
136 
137  void do_set_user_accept_line_function (user_accept_line_fcn f);
138 
139  completion_fcn do_get_completion_function (void) const;
140 
141  quoting_fcn do_get_quoting_function (void) const;
142 
143  dequoting_fcn do_get_dequoting_function (void) const;
144 
145  char_is_quoted_fcn do_get_char_is_quoted_function (void) const;
146 
147  user_accept_line_fcn do_get_user_accept_line_function (void) const;
148 
150  do_generate_filename_completions (const std::string& text);
151 
152  std::string do_get_line_buffer (void) const;
153 
154  std::string do_get_current_line (void) const;
155 
156  char do_get_prev_char (int) const;
157 
158  void do_replace_line (const std::string& text, bool clear_undo);
159 
160  void do_kill_full_line (void);
161 
162  void do_insert_text (const std::string& text);
163 
164  void do_newline (void);
165 
166  void do_accept_line (void);
167 
168  bool do_undo (void);
169 
170  void do_clear_undo_list (void);
171 
172  void set_startup_hook (startup_hook_fcn f);
173 
174  void restore_startup_hook (void);
175 
176  void set_pre_input_hook (pre_input_hook_fcn f);
177 
178  void restore_pre_input_hook (void);
179 
180  void set_event_hook (event_hook_fcn f);
181 
182  void restore_event_hook (void);
183 
184  void do_restore_event_hook (void);
185 
186  void do_read_init_file (const std::string& file);
187 
188  void do_re_read_init_file (void);
189 
190  bool do_filename_completion_desired (bool);
191 
192  bool do_filename_quoting_desired (bool);
193 
194  bool do_prefer_env_winsize (bool);
195 
196  void do_interrupt (bool);
197 
198  static int operate_and_get_next (int, int);
199 
200  static int history_search_backward (int, int);
201 
202  static int history_search_forward (int, int);
203 
204  private:
205 
206  startup_hook_fcn previous_startup_hook;
207 
208  pre_input_hook_fcn previous_pre_input_hook;
209 
210  event_hook_fcn previous_event_hook;
211 
212  completion_fcn completion_function;
213 
214  quoting_fcn quoting_function;
215 
216  dequoting_fcn dequoting_function;
217 
218  char_is_quoted_fcn char_is_quoted_function;
219 
220  user_accept_line_fcn user_accept_line_function;
221 
222  static std::string completer_quote_characters;
223 
224  static char *command_generator (const char *text, int state);
225 
226  static char *command_quoter (char *text, int match_type, char *quote_pointer);
227  static char *command_dequoter (char *text, int match_type);
228 
229  static int command_char_is_quoted (char *text, int index);
230 
231  static int command_accept_line (int count, int key);
232 
233  static char **command_completer (const char *text, int start, int end);
234 
235  static char *do_completer_word_break_hook ();
236  };
237 
238  std::string gnu_readline::completer_quote_characters = "";
239 
241  : command_editor (), previous_startup_hook (0),
242  previous_pre_input_hook (0),
243  previous_event_hook (0), completion_function (0),
244  quoting_function (0), dequoting_function (0),
245  char_is_quoted_function (0), user_accept_line_function (0)
246  {
247  // FIXME: need interface to rl_add_defun, rl_initialize, and
248  // a function to set rl_terminal_name
249 
250  std::string term = octave::sys::env::getenv ("TERM");
251 
252  octave_rl_set_terminal_name (term.c_str ());
253 
255 
256  do_blink_matching_paren (true);
257 
258  // Bind operate-and-get-next.
259 
260  octave_rl_add_defun ("operate-and-get-next",
261  gnu_readline::operate_and_get_next,
262  octave_rl_ctrl ('O'));
263 
264  // And the history search functions.
265 
266  octave_rl_add_defun ("history-search-backward",
267  gnu_readline::history_search_backward,
268  octave_rl_meta ('P'));
269 
270  octave_rl_add_defun ("history-search-forward",
271  gnu_readline::history_search_forward,
272  octave_rl_meta ('N'));
273  }
274 
275  void
276  gnu_readline::do_set_name (const std::string& nm)
277  {
278  ::octave_rl_set_name (nm.c_str ());
279  }
280 
282  gnu_readline::do_readline (const std::string& prompt, bool& eof)
283  {
285 
286  eof = false;
287 
288  const char *p = prompt.c_str ();
289 
291 
292  char *line = ::octave_rl_readline (p);
293 
294  if (line)
295  {
296  retval = line;
297 
298  free (line);
299  }
300  else
301  eof = true;
302 
304 
305  return retval;
306  }
307 
308  void
309  gnu_readline::do_set_input_stream (FILE *f)
310  {
312  }
313 
314  FILE *
315  gnu_readline::do_get_input_stream (void)
316  {
318  }
319 
320  void
321  gnu_readline::do_set_output_stream (FILE *f)
322  {
324  }
325 
326  FILE *
327  gnu_readline::do_get_output_stream (void)
328  {
330  }
331 
332  void
333  gnu_readline::do_redisplay (void)
334  {
336  }
337 
338  // GNU readline handles SIGWINCH, so these values have a good chance
339  // of being correct even if the window changes size (they may be
340  // wrong if, for example, the luser changes the window size while the
341  // pager is running, and the signal is handled by the pager instead of
342  // us.
343 
344  int
345  gnu_readline::do_terminal_rows (void)
346  {
347  int sh = ::octave_rl_screen_height ();
348 
349  return sh > 0 ? sh : 24;
350  }
351 
352  int
353  gnu_readline::do_terminal_cols (void)
354  {
355  int sw = ::octave_rl_screen_width ();
356 
357  return sw > 0 ? sw : 80;
358  }
359 
360  void
361  gnu_readline::do_clear_screen (bool skip_redisplay)
362  {
363  ::octave_rl_clear_screen (skip_redisplay);
364  }
365 
366  void
367  gnu_readline::do_resize_terminal (void)
368  {
370  }
371 
372  void
373  gnu_readline::do_set_screen_size (int ht, int wd)
374  {
376  }
377 
379  gnu_readline::newline_chars (void)
380  {
381  return "\r\n";
382  }
383 
384  void
385  gnu_readline::do_restore_terminal_state (void)
386  {
388  }
389 
390  void
391  gnu_readline::do_blink_matching_paren (bool flag)
392  {
393  ::octave_rl_enable_paren_matching (flag ? 1 : 0);
394  }
395 
396  bool
397  gnu_readline::do_erase_empty_line (bool flag)
398  {
400  }
401 
402  void
403  gnu_readline::do_set_basic_word_break_characters (const std::string& s)
404  {
406  }
407 
408  void
409  gnu_readline::do_set_completer_word_break_characters (const std::string& s)
410  {
412 
415 
416  }
417 
418  void
419  gnu_readline::do_set_basic_quote_characters (const std::string& s)
420  {
422  }
423 
424  void
425  gnu_readline::do_set_filename_quote_characters (const std::string& s)
426  {
428  }
429 
430  void
431  gnu_readline::do_set_completer_quote_characters (const std::string& s)
432  {
433  completer_quote_characters = s;
434  }
435 
436  void
437  gnu_readline::do_set_completion_append_character (char c)
438  {
440  }
441 
442  void
443  gnu_readline::do_set_completion_function (completion_fcn f)
444  {
445  completion_function = f;
446 
448  = f ? gnu_readline::command_completer : 0;
449 
451  }
452 
453  void
454  gnu_readline::do_set_quoting_function (quoting_fcn f)
455  {
456  quoting_function = f;
457 
459  = f ? gnu_readline::command_quoter : 0;
460 
462  }
463 
464  void
465  gnu_readline::do_set_dequoting_function (dequoting_fcn f)
466  {
467  dequoting_function = f;
468 
470  = f ? gnu_readline::command_dequoter : 0;
471 
473  }
474 
475  void
476  gnu_readline::do_set_char_is_quoted_function (char_is_quoted_fcn f)
477  {
478  char_is_quoted_function = f;
479 
481  = f ? gnu_readline::command_char_is_quoted : 0;
482 
484  }
485 
486  void
487  gnu_readline::do_set_user_accept_line_function (user_accept_line_fcn f)
488  {
489  user_accept_line_function = f;
490 
491  if (f)
492  octave_rl_add_defun ("accept-line", gnu_readline::command_accept_line,
493  ::octave_rl_ctrl ('M'));
494  else
495  octave_rl_add_defun ("accept-line", ::octave_rl_newline,
496  ::octave_rl_ctrl ('M'));
497  }
498 
499  gnu_readline::completion_fcn
500  gnu_readline::do_get_completion_function (void) const
501  {
502  return completion_function;
503  }
504 
505  gnu_readline::quoting_fcn
506  gnu_readline::do_get_quoting_function (void) const
507  {
508  return quoting_function;
509  }
510 
511  gnu_readline::dequoting_fcn
512  gnu_readline::do_get_dequoting_function (void) const
513  {
514  return dequoting_function;
515  }
516 
517  gnu_readline::char_is_quoted_fcn
518  gnu_readline::do_get_char_is_quoted_function (void) const
519  {
520  return char_is_quoted_function;
521  }
522 
523  gnu_readline::user_accept_line_fcn
524  gnu_readline::do_get_user_accept_line_function (void) const
525  {
526  return user_accept_line_function;
527  }
528 
529  // True if the last "word" of the string line (delimited by delim) is
530  // an existing directory. Used by do_completer_word_break_hook.
531 
532  static bool
533  looks_like_filename (const char *line, char delim)
534  {
535  bool retval = false;
536 
537  const char *s = strrchr (line, delim);
538 
539  if (s)
540  {
541  // Remove incomplete component.
542  const char *f = strrchr (line, octave::sys::file_ops::dir_sep_char ());
543 
544  if (s[1] == '~' || (f && f != s))
545  {
546  // For something like "A /b", f==s; don't assume a file.
547 
548  std::string candidate_filename = s+1;
549 
550  candidate_filename = candidate_filename.substr (0, f - s);
551 
552  // Handles any complete ~<username>, but doesn't expand usernames.
553 
554  if (candidate_filename[0] == '~')
555  candidate_filename
556  = octave::sys::file_ops::tilde_expand (candidate_filename);
557 
558  octave::sys::file_stat fs (candidate_filename);
559 
560  retval = fs.is_dir ();
561  }
562  }
563 
564  return retval;
565  }
566 
567  // Decide whether to interpret partial commands like "abc/def" as a
568  // filename or division. Return the set of delimiters appropriate for
569  // the decision.
570 
571  char *
573  {
574  static char *dir_sep = octave_strdup_wrapper (" '\"");
575 
576  std::string word;
577  std::string line = get_line_buffer ();
578 
579  // For now, assume space or quote delimiter for file names.
580  const char *l = line.c_str ();
581 
582  if (looks_like_filename (l, ' ') || looks_like_filename (l, '\'')
583  || looks_like_filename (l, '"'))
584  {
586  completer_quote_characters.c_str ());
587 
588  return dir_sep;
589  }
590  else
591  {
593 
595  }
596  }
597 
599  gnu_readline::do_generate_filename_completions (const std::string& text)
600  {
602 
603  int n = 0;
604  int count = 0;
605 
606  char *fn = 0;
607 
608  while (1)
609  {
610  fn = ::octave_rl_filename_completion_function (text.c_str (), count);
611 
612  if (fn)
613  {
614  if (count == n)
615  {
616  // Famous last words: Most large directories will not
617  // have more than a few hundred files, so we should not
618  // resize too many times even if the growth is linear...
619 
620  n += 100;
621  retval.resize (n);
622  }
623 
624  retval[count++] = fn;
625 
626  free (fn);
627  }
628  else
629  break;
630  }
631 
632  retval.resize (count);
633 
634  return retval;
635  }
636 
638  gnu_readline::do_get_line_buffer (void) const
639  {
641  }
642 
644  gnu_readline::do_get_current_line (void) const
645  {
647  char *buf = ::octave_rl_copy_line ();
648  retval = buf;
649  free (buf);
650  return retval;
651  }
652 
653  // Return the character (offset+1) to the left of the cursor,
654  // or '\0' if the cursor is at the start of the line.
655  char
656  gnu_readline::do_get_prev_char (int offset) const
657  {
658  const char *buf = ::octave_rl_line_buffer ();
659  int p = ::octave_rl_point ();
660 
661  return p > offset ? buf[p - offset - 1] : '\0';
662  }
663 
664  void
665  gnu_readline::do_replace_line (const std::string& text, bool clear_undo)
666  {
667  ::octave_rl_replace_line (text.c_str (), clear_undo);
668  }
669 
670  void
671  gnu_readline::do_kill_full_line (void)
672  {
674  }
675 
676  void
677  gnu_readline::do_insert_text (const std::string& text)
678  {
679  ::octave_rl_insert_text (text.c_str ());
680  }
681 
682  void
683  gnu_readline::do_newline (void)
684  {
685  ::octave_rl_newline (1, '\n');
686  }
687 
688  void
689  gnu_readline::do_accept_line (void)
690  {
691  command_accept_line (1, '\n');
692  }
693 
694  bool
695  gnu_readline::do_undo (void)
696  {
698  }
699 
700  void
701  gnu_readline::do_clear_undo_list ()
702  {
704  }
705 
706  void
707  gnu_readline::set_startup_hook (startup_hook_fcn f)
708  {
709  previous_startup_hook = ::octave_rl_get_startup_hook ();
710 
711  if (f != previous_startup_hook)
713  }
714 
715  void
716  gnu_readline::restore_startup_hook (void)
717  {
718  ::octave_rl_set_startup_hook (previous_startup_hook);
719  }
720 
721  void
722  gnu_readline::set_pre_input_hook (pre_input_hook_fcn f)
723  {
724  previous_pre_input_hook = ::octave_rl_get_pre_input_hook ();
725 
726  if (f != previous_pre_input_hook)
728  }
729 
730  void
731  gnu_readline::restore_pre_input_hook (void)
732  {
733  ::octave_rl_set_pre_input_hook (previous_pre_input_hook);
734  }
735 
736  void
737  gnu_readline::set_event_hook (event_hook_fcn f)
738  {
739  previous_event_hook = octave_rl_get_event_hook ();
740 
742  }
743 
744  void
745  gnu_readline::restore_event_hook (void)
746  {
747  ::octave_rl_set_event_hook (previous_event_hook);
748  }
749 
750  void
751  gnu_readline::do_read_init_file (const std::string& file)
752  {
753  ::octave_rl_read_init_file (file.c_str ());
754  }
755 
756  void
757  gnu_readline::do_re_read_init_file (void)
758  {
760  }
761 
762  bool
763  gnu_readline::do_filename_completion_desired (bool arg)
764  {
766  }
767 
768  bool
769  gnu_readline::do_filename_quoting_desired (bool arg)
770  {
772  }
773 
774  bool
775  gnu_readline::do_prefer_env_winsize (bool arg)
776  {
778  }
779 
780  void
781  gnu_readline::do_interrupt (bool arg)
782  {
783  ::octave_rl_done (arg);
784  }
785 
786  int
787  gnu_readline::operate_and_get_next (int /* count */, int /* c */)
788  {
789  // Accept the current line.
790 
791  command_editor::accept_line ();
792 
793  // Find the current line, and find the next line to use.
794 
795  int x_where = command_history::where ();
796 
797  int x_length = command_history::length ();
798 
799  if ((command_history::is_stifled ()
800  && (x_length >= command_history::max_input_history ()))
801  || (x_where >= x_length - 1))
802  command_history::set_mark (x_where);
803  else
804  command_history::set_mark (x_where + 1);
805 
806  command_editor::add_startup_hook (command_history::goto_mark);
807 
808  return 0;
809  }
810 
811  int
812  gnu_readline::history_search_backward (int count, int c)
813  {
814  return octave_rl_history_search_backward (count, c);
815  }
816 
817  int
818  gnu_readline::history_search_forward (int count, int c)
819  {
820  return octave_rl_history_search_forward (count, c);
821  }
822 
823  char *
824  gnu_readline::command_generator (const char *text, int state)
825  {
826  char *retval = 0;
827 
828  completion_fcn f = command_editor::get_completion_function ();
829 
830  std::string tmp = f (text, state);
831 
832  size_t len = tmp.length ();
833 
834  if (len > 0)
835  {
836  retval = static_cast<char *> (std::malloc (len+1));
837 
838  strcpy (retval, tmp.c_str ());
839  }
840 
841  return retval;
842  }
843 
844  char *
845  gnu_readline::command_quoter (char *text, int matches, char *qcp)
846  {
847  char *retval = 0;
848 
849  quoting_fcn f = command_editor::get_quoting_function ();
850 
851  std::string tmp = f (text, matches, *qcp);
852 
853  size_t len = tmp.length ();
854 
855  if (len > 0)
856  {
857  retval = static_cast<char *> (std::malloc (len+1));
858 
859  strcpy (retval, tmp.c_str ());
860  }
861 
862  return retval;
863  }
864 
865  char *
866  gnu_readline::command_dequoter (char *text, int quote)
867  {
868  char *retval = 0;
869 
870  dequoting_fcn f = command_editor::get_dequoting_function ();
871 
872  std::string tmp = f (text, quote);
873 
874  size_t len = tmp.length ();
875 
876  if (len > 0)
877  {
878  retval = static_cast<char *> (std::malloc (len+1));
879 
880  strcpy (retval, tmp.c_str ());
881  }
882 
883  return retval;
884  }
885 
886  int
887  gnu_readline::command_char_is_quoted (char *text, int quote)
888  {
889  char_is_quoted_fcn f = command_editor::get_char_is_quoted_function ();
890 
891  return f (text, quote);
892  }
893 
894  int
895  gnu_readline::command_accept_line (int count, int key)
896  {
897  user_accept_line_fcn f = command_editor::get_user_accept_line_function ();
898 
899  if (f)
900  f (::octave_rl_line_buffer ());
901 
903 
904  return ::octave_rl_newline (count, key);
905  }
906 
907  char **
908  gnu_readline::command_completer (const char *text, int, int)
909  {
910  char **matches = 0;
911  matches
912  = ::octave_rl_completion_matches (text, gnu_readline::command_generator);
913  return matches;
914  }
915 
916 #endif
917 
918  class
920  {
921  public:
922 
924  : command_editor (), input_stream (stdin), output_stream (stdout) { }
925 
927 
928  std::string do_readline (const std::string& prompt, bool& eof);
929 
930  void do_set_input_stream (FILE *f);
931 
932  FILE *do_get_input_stream (void);
933 
934  void do_set_output_stream (FILE *f);
935 
936  FILE *do_get_output_stream (void);
937 
938  string_vector do_generate_filename_completions (const std::string& text);
939 
940  std::string do_get_line_buffer (void) const;
941 
942  std::string do_get_current_line (void) const;
943 
944  char do_get_prev_char (int) const;
945 
946  void do_replace_line (const std::string& text, bool clear_undo);
947 
948  void do_kill_full_line (void);
949 
950  void do_insert_text (const std::string& text);
951 
952  void do_newline (void);
953 
954  void do_accept_line (void);
955 
956  private:
957 
959 
961 
962  // No copying!
963 
965 
966  default_command_editor& operator = (const default_command_editor&);
967  };
968 
970  default_command_editor::do_readline (const std::string& prompt, bool& eof)
971  {
972  std::fputs (prompt.c_str (), output_stream);
973  std::fflush (output_stream);
974 
975  return octave_fgetl (input_stream, eof);
976  }
977 
978  void
979  default_command_editor::do_set_input_stream (FILE *f)
980  {
981  input_stream = f;
982  }
983 
984  FILE *
985  default_command_editor::do_get_input_stream (void)
986  {
987  return input_stream;
988  }
989 
990  void
991  default_command_editor::do_set_output_stream (FILE *f)
992  {
993  output_stream = f;
994  }
995 
996  FILE *
997  default_command_editor::do_get_output_stream (void)
998  {
999  return output_stream;
1000  }
1001 
1003  default_command_editor::do_generate_filename_completions (const std::string&)
1004  {
1005  // FIXME
1006  return string_vector ();
1007  }
1008 
1009  std::string
1010  default_command_editor::do_get_line_buffer (void) const
1011  {
1012  return "";
1013  }
1014 
1015  std::string
1016  default_command_editor::do_get_current_line (void) const
1017  {
1018  // FIXME
1019  return "";
1020  }
1021 
1022  char
1023  default_command_editor::do_get_prev_char (int) const
1024  {
1025  return '\0';
1026  }
1027 
1028  void
1029  default_command_editor::do_replace_line (const std::string&, bool)
1030  {
1031  // FIXME
1032  }
1033 
1034  void
1035  default_command_editor::do_kill_full_line (void)
1036  {
1037  // FIXME
1038  }
1039 
1040  void
1041  default_command_editor::do_insert_text (const std::string&)
1042  {
1043  // FIXME
1044  }
1045 
1046  void
1047  default_command_editor::do_newline (void)
1048  {
1049  // FIXME
1050  }
1051 
1052  void
1053  default_command_editor::do_accept_line (void)
1054  {
1055  // FIXME
1056  }
1057 
1058  bool
1059  command_editor::instance_ok (void)
1060  {
1061  bool retval = true;
1062 
1063  if (! instance)
1064  {
1065  make_command_editor ();
1066 
1067  if (instance)
1068  singleton_cleanup_list::add (cleanup_instance);
1069  }
1070 
1071  if (! instance)
1072  (*current_liboctave_error_handler)
1073  ("unable to create command history object!");
1074 
1075  return retval;
1076  }
1077 
1078  void
1079  command_editor::make_command_editor (void)
1080  {
1081 #if defined (USE_READLINE)
1082  instance = new gnu_readline ();
1083 #else
1084  instance = new default_command_editor ();
1085 #endif
1086  }
1087 
1088  void
1089  command_editor::force_default_editor (void)
1090  {
1091  delete instance;
1092  instance = new default_command_editor ();
1093  }
1094 
1095  void
1096  command_editor::set_initial_input (const std::string& text)
1097  {
1098  if (instance_ok ())
1099  instance->initial_input = text;
1100  }
1101 
1102  int
1103  command_editor::insert_initial_input (void)
1104  {
1105  return instance_ok () ? instance->do_insert_initial_input () : 0;
1106  }
1107 
1108  int
1109  command_editor::startup_handler (void)
1110  {
1111  for (auto& fcnptr : startup_hook_set)
1112  {
1113  startup_hook_fcn f = *fcnptr;
1114 
1115  if (f)
1116  f ();
1117  }
1118 
1119  return 0;
1120  }
1121 
1122  int
1123  command_editor::pre_input_handler (void)
1124  {
1125  for (auto& fcnptr : pre_input_hook_set)
1126  {
1127  pre_input_hook_fcn f = *fcnptr;
1128 
1129  if (f)
1130  f ();
1131  }
1132 
1133  return 0;
1134  }
1135 
1136  int
1137  command_editor::event_handler (void)
1138  {
1139  event_hook_lock.lock ();
1140 
1141  std::set<event_hook_fcn> hook_set (event_hook_set);
1142 
1143  event_hook_lock.unlock ();
1144 
1145  for (auto& fcnptr : hook_set)
1146  {
1147  event_hook_fcn f = *fcnptr;
1148 
1149  if (f)
1150  f ();
1151  }
1152 
1153  return 0;
1154  }
1155 
1156  void
1157  command_editor::set_name (const std::string& n)
1158  {
1159  if (instance_ok ())
1160  instance->do_set_name (n);
1161  }
1162 
1163  std::string
1164  command_editor::readline (const std::string& prompt)
1165  {
1166  bool eof;
1167 
1168  return readline (prompt, eof);
1169  }
1170 
1171  std::string
1172  command_editor::readline (const std::string& prompt, bool& eof)
1173  {
1175 
1176  if (instance_ok ())
1177  {
1178  if (! instance->initial_input.empty ())
1179  add_pre_input_hook (command_editor::insert_initial_input);
1180 
1181  retval = instance->do_readline (prompt, eof);
1182  }
1183 
1184  return retval;
1185  }
1186 
1187  void
1188  command_editor::set_input_stream (FILE *f)
1189  {
1190  if (instance_ok ())
1191  instance->do_set_input_stream (f);
1192  }
1193 
1194  FILE *
1195  command_editor::get_input_stream (void)
1196  {
1197  return (instance_ok ())
1198  ? instance->do_get_input_stream () : 0;
1199  }
1200 
1201  void
1202  command_editor::set_output_stream (FILE *f)
1203  {
1204  if (instance_ok ())
1205  instance->do_set_output_stream (f);
1206  }
1207 
1208  FILE *
1209  command_editor::get_output_stream (void)
1210  {
1211  return (instance_ok ())
1212  ? instance->do_get_output_stream () : 0;
1213  }
1214 
1215  void
1216  command_editor::redisplay (void)
1217  {
1218  if (instance_ok ())
1219  instance->do_redisplay ();
1220  }
1221 
1222  int
1223  command_editor::terminal_rows (void)
1224  {
1225  return (instance_ok ())
1226  ? instance->do_terminal_rows () : -1;
1227  }
1228 
1229  int
1230  command_editor::terminal_cols (void)
1231  {
1232  return (instance_ok ())
1233  ? instance->do_terminal_cols () : -1;
1234  }
1235 
1236  void
1237  command_editor::clear_screen (bool skip_redisplay)
1238  {
1239  if (instance_ok ())
1240  instance->do_clear_screen (skip_redisplay);
1241  }
1242 
1243  void
1244  command_editor::resize_terminal (void)
1245  {
1246  if (instance_ok ())
1247  instance->do_resize_terminal ();
1248  }
1249 
1250  void
1251  command_editor::set_screen_size (int ht, int wd)
1252  {
1253  if (instance_ok ())
1254  instance->do_set_screen_size (ht, wd);
1255  }
1256 
1257  std::string
1258  command_editor::decode_prompt_string (const std::string& s)
1259  {
1260  return (instance_ok ())
1261  ? instance->do_decode_prompt_string (s) : "";
1262  }
1263 
1264  int
1265  command_editor::current_command_number (void)
1266  {
1267  return (instance_ok ())
1268  ? instance->command_number : 0;
1269  }
1270 
1271  void
1272  command_editor::reset_current_command_number (int n)
1273  {
1274  if (instance_ok ())
1275  instance->command_number = n;
1276  }
1277 
1278  void
1279  command_editor::increment_current_command_number (void)
1280  {
1281  if (instance_ok ())
1282  instance->command_number++;
1283  }
1284 
1285  void
1286  command_editor::restore_terminal_state (void)
1287  {
1288  if (instance_ok ())
1289  instance->do_restore_terminal_state ();
1290  }
1291 
1292  void
1293  command_editor::blink_matching_paren (bool flag)
1294  {
1295  if (instance_ok ())
1296  instance->do_blink_matching_paren (flag);
1297  }
1298 
1299  bool
1300  command_editor::erase_empty_line (bool flag)
1301  {
1302  return instance_ok () ? instance->do_erase_empty_line (flag) : false;
1303  }
1304 
1305  void
1306  command_editor::set_basic_word_break_characters (const std::string& s)
1307  {
1308  if (instance_ok ())
1309  instance->do_set_basic_word_break_characters (s);
1310  }
1311 
1312  void
1313  command_editor::set_completer_word_break_characters (const std::string& s)
1314  {
1315  if (instance_ok ())
1316  instance->do_set_completer_word_break_characters (s);
1317  }
1318 
1319  void
1320  command_editor::set_basic_quote_characters (const std::string& s)
1321  {
1322  if (instance_ok ())
1323  instance->do_set_basic_quote_characters (s);
1324  }
1325 
1326  void
1327  command_editor::set_filename_quote_characters (const std::string& s)
1328  {
1329  if (instance_ok ())
1330  instance->do_set_filename_quote_characters (s);
1331  }
1332 
1333  void
1334  command_editor::set_completer_quote_characters (const std::string& s)
1335  {
1336  if (instance_ok ())
1337  instance->do_set_completer_quote_characters (s);
1338  }
1339 
1340  void
1341  command_editor::set_completion_append_character (char c)
1342  {
1343  if (instance_ok ())
1344  instance->do_set_completion_append_character (c);
1345  }
1346 
1347  void
1348  command_editor::set_completion_function (completion_fcn f)
1349  {
1350  if (instance_ok ())
1351  instance->do_set_completion_function (f);
1352  }
1353 
1354  void
1355  command_editor::set_quoting_function (quoting_fcn f)
1356  {
1357  if (instance_ok ())
1358  instance->do_set_quoting_function (f);
1359  }
1360 
1361  void
1362  command_editor::set_dequoting_function (dequoting_fcn f)
1363  {
1364  if (instance_ok ())
1365  instance->do_set_dequoting_function (f);
1366  }
1367 
1368  void
1369  command_editor::set_char_is_quoted_function (char_is_quoted_fcn f)
1370  {
1371  if (instance_ok ())
1372  instance->do_set_char_is_quoted_function (f);
1373  }
1374 
1375  void
1376  command_editor::set_user_accept_line_function (user_accept_line_fcn f)
1377  {
1378  if (instance_ok ())
1379  instance->do_set_user_accept_line_function (f);
1380  }
1381 
1382  command_editor::completion_fcn
1383  command_editor::get_completion_function (void)
1384  {
1385  return (instance_ok ())
1386  ? instance->do_get_completion_function () : 0;
1387  }
1388 
1389  command_editor::quoting_fcn
1390  command_editor::get_quoting_function (void)
1391  {
1392  return (instance_ok ())
1393  ? instance->do_get_quoting_function () : 0;
1394  }
1395 
1396  command_editor::dequoting_fcn
1397  command_editor::get_dequoting_function (void)
1398  {
1399  return (instance_ok ())
1400  ? instance->do_get_dequoting_function () : 0;
1401  }
1402 
1403  command_editor::char_is_quoted_fcn
1404  command_editor::get_char_is_quoted_function (void)
1405  {
1406  return (instance_ok ())
1407  ? instance->do_get_char_is_quoted_function () : 0;
1408  }
1409 
1410  command_editor::user_accept_line_fcn
1411  command_editor::get_user_accept_line_function (void)
1412  {
1413  return (instance_ok ())
1414  ? instance->do_get_user_accept_line_function () : 0;
1415  }
1416 
1418  command_editor::generate_filename_completions (const std::string& text)
1419  {
1420  return (instance_ok ())
1421  ? instance->do_generate_filename_completions (text) : string_vector ();
1422  }
1423 
1424  std::string
1425  command_editor::get_line_buffer (void)
1426  {
1427  return (instance_ok ()) ? instance->do_get_line_buffer () : "";
1428  }
1429 
1430  std::string
1431  command_editor::get_current_line (void)
1432  {
1433  return (instance_ok ()) ? instance->do_get_current_line () : "";
1434  }
1435 
1436  // Return the character (offset+1) to the left of the cursor,
1437  // or '\0' if the cursor is at the start of the line.
1438  char
1439  command_editor::get_prev_char (int offset)
1440  {
1441  return (instance_ok ()) ? instance->do_get_prev_char (offset) : '\0';
1442  }
1443 
1444  void
1445  command_editor::replace_line (const std::string& text, bool clear_undo)
1446  {
1447  if (instance_ok ())
1448  instance->do_replace_line (text, clear_undo);
1449  }
1450 
1451  void
1452  command_editor::kill_full_line (void)
1453  {
1454  if (instance_ok ())
1455  instance->do_kill_full_line ();
1456  }
1457 
1458  void
1459  command_editor::insert_text (const std::string& text)
1460  {
1461  if (instance_ok ())
1462  instance->do_insert_text (text);
1463  }
1464 
1465  void
1466  command_editor::newline (void)
1467  {
1468  if (instance_ok ())
1469  instance->do_newline ();
1470  }
1471 
1472  void
1473  command_editor::accept_line (void)
1474  {
1475  if (instance_ok ())
1476  instance->do_accept_line ();
1477  }
1478 
1479  bool
1480  command_editor::undo (void)
1481  {
1482  return instance_ok () ? instance->do_undo () : false;
1483  }
1484 
1485  void
1486  command_editor::clear_undo_list (void)
1487  {
1488  if (instance_ok ())
1489  instance->do_clear_undo_list ();
1490  }
1491 
1492  void
1493  command_editor::add_startup_hook (startup_hook_fcn f)
1494  {
1495  if (instance_ok ())
1496  {
1497  startup_hook_set.insert (f);
1498 
1499  instance->set_startup_hook (startup_handler);
1500  }
1501  }
1502 
1503  void
1504  command_editor::remove_startup_hook (startup_hook_fcn f)
1505  {
1506  if (instance_ok ())
1507  {
1508  auto p = startup_hook_set.find (f);
1509 
1510  if (p != startup_hook_set.end ())
1511  startup_hook_set.erase (p);
1512 
1513  if (startup_hook_set.empty ())
1514  instance->restore_startup_hook ();
1515  }
1516  }
1517 
1518  void
1519  command_editor::add_pre_input_hook (pre_input_hook_fcn f)
1520  {
1521  if (instance_ok ())
1522  {
1523  pre_input_hook_set.insert (f);
1524 
1525  instance->set_pre_input_hook (pre_input_handler);
1526  }
1527  }
1528 
1529  void
1530  command_editor::remove_pre_input_hook (pre_input_hook_fcn f)
1531  {
1532  if (instance_ok ())
1533  {
1534  auto p = pre_input_hook_set.find (f);
1535 
1536  if (p != pre_input_hook_set.end ())
1537  pre_input_hook_set.erase (p);
1538 
1539  if (pre_input_hook_set.empty ())
1540  instance->restore_pre_input_hook ();
1541  }
1542  }
1543 
1544  void
1545  command_editor::add_event_hook (event_hook_fcn f)
1546  {
1547  octave_autolock guard (event_hook_lock);
1548 
1549  if (instance_ok ())
1550  {
1551  event_hook_set.insert (f);
1552 
1553  instance->set_event_hook (event_handler);
1554  }
1555  }
1556 
1557  void
1558  command_editor::remove_event_hook (event_hook_fcn f)
1559  {
1560  octave_autolock guard (event_hook_lock);
1561 
1562  if (instance_ok ())
1563  {
1564  auto p = event_hook_set.find (f);
1565 
1566  if (p != event_hook_set.end ())
1567  event_hook_set.erase (p);
1568 
1569  if (event_hook_set.empty ())
1570  instance->restore_event_hook ();
1571  }
1572  }
1573 
1574  void
1575  command_editor::run_event_hooks (void)
1576  {
1577  event_handler ();
1578  }
1579 
1580  void
1581  command_editor::read_init_file (const std::string& file_arg)
1582  {
1583  if (instance_ok ())
1584  {
1586 
1587  instance->do_read_init_file (file);
1588  }
1589  }
1590 
1591  void
1592  command_editor::re_read_init_file (void)
1593  {
1594  if (instance_ok ())
1595  instance->do_re_read_init_file ();
1596  }
1597 
1598  bool
1599  command_editor::filename_completion_desired (bool arg)
1600  {
1601  return (instance_ok ())
1602  ? instance->do_filename_completion_desired (arg) : false;
1603  }
1604 
1605  bool
1606  command_editor::filename_quoting_desired (bool arg)
1607  {
1608  return (instance_ok ())
1609  ? instance->do_filename_quoting_desired (arg) : false;
1610  }
1611 
1612  bool
1613  command_editor::prefer_env_winsize (bool arg)
1614  {
1615  return (instance_ok ())
1616  ? instance->do_prefer_env_winsize (arg) : false;
1617  }
1618 
1619  bool
1620  command_editor::interrupt (bool arg)
1621  {
1622  bool retval;
1623 
1624  if (instance_ok ())
1625  {
1626  // Return the current interrupt state.
1627  retval = instance->interrupted;
1628 
1629  instance->do_interrupt (arg);
1630 
1631  instance->interrupted = arg;
1632  }
1633  else
1634  retval = false;
1635 
1636  return retval;
1637  }
1638 
1639  // Return a string which will be printed as a prompt. The string may
1640  // contain special characters which are decoded as follows:
1641  //
1642  // \a bell (ascii 07)
1643  // \d the date
1644  // \e escape (ascii 033)
1645  // \h the hostname up to the first '.'
1646  // \H the hostname
1647  // \n CRLF
1648  // \r CR
1649  // \s the name of the shell (program)
1650  // \t the time
1651  // \T the time in 12-hour hh:mm:ss format
1652  // \@ the time in 12-hour hh:mm am/pm format
1653  // \A the time in 24-hour hh:mm format
1654  // \u your username
1655  // \w the current working directory
1656  // \W the last element of PWD
1657  // \! the history number of this command
1658  // \# the command number of this command
1659  // \$ a $ or a # if you are root
1660  // \nnn character code nnn in octal
1661  // \\ a backslash
1662  // \[ begin a sequence of non-printing chars
1663  // \] end a sequence of non-printing chars
1664 
1665  std::string
1666  command_editor::do_decode_prompt_string (const std::string& s)
1667  {
1669  std::string tmpstr;
1670  size_t i = 0;
1671  size_t slen = s.length ();
1672  int c;
1673 
1674  while (i < slen)
1675  {
1676  c = s[i];
1677 
1678  i++;
1679 
1680  if (c == '\\')
1681  {
1682  c = s[i];
1683 
1684  switch (c)
1685  {
1686  case '0':
1687  case '1':
1688  case '2':
1689  case '3':
1690  case '4':
1691  case '5':
1692  case '6':
1693  case '7':
1694  // Maybe convert an octal number.
1695  {
1696  int n = read_octal (s.substr (i, 3));
1697 
1698  tmpstr = "\\";
1699 
1700  if (n != -1)
1701  {
1702  tmpstr[0] = n;
1703  i += 2; // i++ makes this += 3 later
1704  }
1705 
1706  break;
1707  }
1708 
1709  case 'a':
1710  {
1711  tmpstr = '\a';
1712 
1713  break;
1714  }
1715 
1716  case 'd':
1717  case 't':
1718  case 'T':
1719  case '@':
1720  case 'A':
1721  // Make the current time/date into a string.
1722  {
1724 
1725  if (c == 'd')
1726  tmpstr = now.strftime ("%a %b %d");
1727  else if (c == 't')
1728  tmpstr = now.strftime ("%H:%M:%S");
1729  else if (c == 'T')
1730  tmpstr = now.strftime ("%I:%M:%S");
1731  else if (c == '@')
1732  tmpstr = now.strftime ("%I:%M %p");
1733  else if (c == 'A')
1734  tmpstr = now.strftime ("%H:%M");
1735 
1736  break;
1737  }
1738 
1739  case 'e':
1740  {
1741  tmpstr = '\033';
1742 
1743  break;
1744  }
1745 
1746  case 'h':
1747  {
1748  tmpstr = octave::sys::env::get_host_name ();
1749 
1750  size_t pos = tmpstr.find ('.');
1751 
1752  if (pos != std::string::npos)
1753  tmpstr.resize (pos);
1754 
1755  break;
1756  }
1757 
1758  case 'H':
1759  {
1760  tmpstr = octave::sys::env::get_host_name ();
1761 
1762  break;
1763  }
1764 
1765  case 'n':
1766  {
1767  tmpstr = newline_chars ();
1768 
1769  break;
1770  }
1771 
1772  case 'r':
1773  {
1774  tmpstr = '\r';
1775 
1776  break;
1777  }
1778 
1779  case 's':
1780  {
1782  tmpstr = octave::sys::env::base_pathname (tmpstr);
1783 
1784  break;
1785  }
1786 
1787  case 'u':
1788  {
1789  tmpstr = octave::sys::env::get_user_name ();
1790 
1791  break;
1792  }
1793 
1794  case 'w':
1795  case 'W':
1796  {
1797  try
1798  {
1800  }
1801  catch (const octave::execution_exception&)
1802  {
1803  tmpstr = "";
1804  }
1805 
1807 
1808  if (c == 'W' && (home_dir.empty () || tmpstr != home_dir))
1809  {
1810  if (tmpstr != "/" && tmpstr != "//")
1811  {
1812  size_t pos = tmpstr.rfind ('/');
1813 
1814  if (pos != std::string::npos && pos != 0)
1815  tmpstr = tmpstr.substr (pos + 1);
1816  }
1817  }
1818  else
1820 
1821  break;
1822  }
1823 
1824  case '!':
1825  {
1826  char number_buffer[32];
1827  int num = command_history::current_number ();
1828  if (num > 0)
1829  sprintf (number_buffer, "%d", num);
1830  else
1831  strcpy (number_buffer, "!");
1832  tmpstr = number_buffer;
1833 
1834  break;
1835  }
1836 
1837  case '#':
1838  {
1839  char number_buffer[32];
1840  sprintf (number_buffer, "%d", command_number);
1841  tmpstr = number_buffer;
1842 
1843  break;
1844  }
1845 
1846  case '$':
1847  {
1848  tmpstr = (octave_geteuid_wrapper () == 0 ? '#' : '$');
1849  break;
1850  }
1851 
1852 #if defined (USE_READLINE)
1853  case '[':
1854  case ']':
1855  {
1856  tmpstr.resize (1);
1857 
1858  tmpstr[0] = ((c == '[')
1861 
1862  break;
1863  }
1864 #endif
1865 
1866  case '\\':
1867  {
1868  tmpstr = "\\";
1869 
1870  break;
1871  }
1872 
1873  default:
1874  {
1875  tmpstr = "\\ ";
1876  tmpstr[1] = c;
1877 
1878  break;
1879  }
1880  }
1881 
1882  retval.append (tmpstr);
1883  i++; // Move past processed escape character
1884  }
1885  else
1886  retval += c;
1887  }
1888 
1889  return retval;
1890  }
1891 
1892  int
1893  command_editor::do_insert_initial_input (void)
1894  {
1895  std::string input = initial_input;
1896 
1897  initial_input = "";
1898 
1899  do_insert_text (input);
1900 
1901  // Is it really right to redisplay here?
1902  do_redisplay ();
1903 
1904  return 0;
1905  }
1906 
1907  // Return the octal number parsed from STRING, or -1 to indicate that
1908  // the string contained a bad number.
1909 
1910  int
1911  command_editor::read_octal (const std::string& s)
1912  {
1913  int result = 0;
1914  int digits = 0;
1915 
1916  size_t i = 0;
1917  size_t slen = s.length ();
1918 
1919  while (i < slen && s[i] >= '0' && s[i] < '8')
1920  {
1921  digits++;
1922  result = (result * 8) + s[i] - '0';
1923  i++;
1924  }
1925 
1926  if (! digits || result > 0777 || i < slen)
1927  result = -1;
1928 
1929  return result;
1930  }
1931 
1932  void
1934  {
1935  (*current_liboctave_error_handler) ("%s", std::strerror (err_num));
1936  }
1937 
1938  void
1940  {
1941  (*current_liboctave_error_handler) ("%s", s.c_str ());
1942  }
1943 }
int octave_rl_do_undo(void)
int octave_rl_newline(int, int)
void octave_rl_set_dequoting_function(rl_dequoting_fcn_ptr)
fputs(in,"these\nare\nsome\nstrings\n")
uid_t octave_geteuid_wrapper(void)
char * octave_rl_readline(const char *)
static std::string get_current_directory(void)
Definition: oct-env.cc:136
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
char * do_completer_word_break_hook()
void octave_rl_set_terminal_name(const char *)
void octave_rl_set_completion_word_break_hook(rl_completion_hook_fcn_ptr)
void octave_rl_redisplay(void)
int octave_rl_filename_quoting_desired(int)
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
int octave_rl_screen_width(void)
octave::sys::time now
Definition: data.cc:6299
void octave_rl_set_event_hook(rl_event_hook_fcn_ptr f)
int octave_rl_ctrl(char)
void error(const char *fmt,...)
Definition: error.cc:570
void octave_rl_clear_undo_list(void)
int(* startup_hook_fcn)(void)
Definition: cmd-edit.h:48
void octave_rl_set_completion_function(rl_attempted_completion_fcn_ptr)
int octave_rl_erase_empty_line(int)
void octave_rl_set_basic_word_break_characters(const char *)
char * octave_rl_get_completer_word_break_characters(void)
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup calculate Y_a and Y _d item Given calculate Y nd enumerate In either initial values for the given components are input
Definition: DASPK-opts.cc:739
s
Definition: file-io.cc:2682
void octave_rl_set_basic_quote_characters(const char *)
char octave_rl_prompt_end_ignore(void)
void octave_rl_set_completer_quote_characters(const char *)
static std::string tilde_expand(const std::string &)
Definition: file-ops.cc:301
char *(* rl_quoting_fcn_ptr)(char *, int, char *)
Definition: oct-rl-edit.h:42
void octave_rl_resize_terminal(void)
void resize(octave_idx_type n, const std::string &rfv="")
Definition: str-vec.h:97
octave_value arg
Definition: pr-output.cc:3440
static std::string getenv(const std::string &name)
Definition: oct-env.cc:235
char octave_rl_prompt_start_ignore(void)
int octave_rl_point(void)
void octave_rl_restore_terminal_state(void)
int(* pre_input_hook_fcn)(void)
Definition: cmd-edit.h:50
int octave_rl_filename_completion_desired(int)
bool is_dir(void) const
Definition: file-stat.cc:57
int(* event_hook_fcn)(void)
Definition: cmd-edit.h:52
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
void octave_rl_clear_screen(int skip_redisplay)
int octave_rl_history_search_forward(int, int)
void octave_rl_read_init_file(const char *)
static std::string get_home_directory(void)
Definition: oct-env.cc:143
char *(* rl_dequoting_fcn_ptr)(char *, int)
Definition: oct-rl-edit.h:44
static void add(fptr f)
static std::string gnu_readline(const std::string &s, bool &eof)
Definition: input.cc:180
void octave_rl_set_completer_word_break_characters(const char *)
static std::string get_host_name(void)
Definition: oct-env.cc:185
static char dir_sep_char(void)
Definition: file-ops.h:75
static std::string get_user_name(void)
Definition: oct-env.cc:178
void octave_rl_done(int)
double tmp
Definition: data.cc:6300
static std::set< pre_input_hook_fcn > pre_input_hook_set
Definition: cmd-edit.h:214
octave_value retval
Definition: data.cc:6294
void octave_rl_set_filename_quote_characters(const char *)
void octave_rl_initialize(void)
void octave_rl_set_pre_input_hook(rl_startup_hook_fcn_ptr)
void octave_rl_enable_paren_matching(int)
static std::string base_pathname(const std::string &s)
Definition: oct-env.cc:122
char ** octave_rl_completion_matches(const char *, rl_completer_fcn_ptr)
void octave_rl_set_completion_append_character(char)
void octave_rl_set_screen_size(int ht, int wd)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
char * octave_rl_filename_completion_function(const char *, int)
static std::set< event_hook_fcn > event_hook_set
Definition: cmd-edit.h:216
void octave_rl_set_name(const char *)
With real return the complex result
Definition: data.cc:3375
void octave_rl_insert_text(const char *)
static uint32_t state[624]
Definition: randmtzig.cc:184
char **(* rl_attempted_completion_fcn_ptr)(const char *, int, int)
Definition: oct-rl-edit.h:36
static octave_mutex event_hook_lock
Definition: cmd-edit.cc:64
int octave_rl_prefer_env_winsize(int)
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
Definition: dlmread.cc:191
char * octave_rl_copy_line(void)
octave::sys::time start
Definition: graphics.cc:11731
#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
Definition: quit.h:262
void free(void *)
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
p
Definition: lu.cc:138
void octave_rl_set_startup_hook(rl_startup_hook_fcn_ptr)
int(* rl_char_is_quoted_fcn_ptr)(char *, int)
Definition: oct-rl-edit.h:46
char * octave_strdup_wrapper(const char *str)
rl_event_hook_fcn_ptr octave_rl_get_event_hook(void)
int octave_rl_meta(char)
octave::sys::file_stat fs(filename)
void octave_rl_kill_full_line(void)
rl_pre_input_hook_fcn_ptr octave_rl_get_pre_input_hook(void)
void octave_rl_re_read_init_file(void)
const char * octave_rl_line_buffer(void)
FILE * octave_rl_get_input_stream(void)
int octave_rl_screen_height(void)
#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
Definition: quit.h:240
void octave_rl_add_defun(const char *, rl_fcn_ptr, int)
void * malloc(size_t)
static std::string get_program_name(void)
Definition: oct-env.cc:157
void octave_rl_replace_line(const char *s, int clear_undo)
static command_editor * instance
Definition: cmd-edit.h:219
FILE * octave_rl_get_output_stream(void)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
rl_startup_hook_fcn_ptr octave_rl_get_startup_hook(void)
void lock(void)
Definition: oct-mutex.h:85
void octave_rl_set_char_is_quoted_function(rl_char_is_quoted_fcn_ptr)
void octave_rl_set_quoting_function(rl_quoting_fcn_ptr)
int octave_rl_history_search_backward(int, int)
std::string strftime(const std::string &fmt) const
Definition: oct-time.cc:147
static std::set< startup_hook_fcn > startup_hook_set
Definition: cmd-edit.h:212
std::string(* completion_fcn)(const std::string &, int)
Definition: cmd-edit.h:54
enum echo_state fflush
std::string octave_fgetl(FILE *f)
Definition: lo-utils.cc:188
static std::string polite_directory_format(const std::string &name)
Definition: oct-env.cc:101
void octave_rl_set_input_stream(FILE *)
void unlock(void)
Definition: oct-mutex.h:90
void octave_rl_set_output_stream(FILE *)