65 #ifdef OCTAVE_DEFAULT_PAGER
66 if (pager_binary.empty ())
116 std::cerr <<
"warning: connection to external pager lost (pid = "
117 << pid <<
")" << std::endl;
118 std::cerr <<
"warning: flushing pending output (please wait)"
143 do_sync (
const char *msg,
int len,
bool bypass_pager)
149 std::cout.write (msg, len);
154 if (! external_pager)
170 if (external_pager->good ())
172 external_pager->write (msg, len);
174 external_pager->flush ();
178 external_pager->setstate (std::ios::failbit);
191 std::cout.write (msg, len);
211 int chars_this_line = 0;
213 for (
int i = 0; i < len; i++)
217 count += chars_this_line / cols + 1;
224 if (count > available_rows)
239 char *buf = eback ();
241 int len = pptr () - buf;
252 do_sync (buf, len, bypass_pager);
256 seekoff (0, std::ios::beg);
268 size_t len = pptr () - buf;
286 char *buf = eback ();
288 int len = pptr () - buf;
294 seekoff (0, std::ios::beg);
384 ::error (
"unable to create pager_stream object!");
449 ::error (
"unable to create diary_stream object!");
515 DEFUN (diary, args, ,
517 @deftypefn {Command} {} diary\n\
518 @deftypefnx {Command} {} diary on\n\
519 @deftypefnx {Command} {} diary off\n\
520 @deftypefnx {Command} {} diary @var{filename}\n\
521 Record a list of all commands @emph{and} the output they produce, mixed\n\
522 together just as they appear on the terminal.\n\
524 Valid options are:\n\
528 Start recording a session in a file called @file{diary} in the\n\
529 current working directory.\n\
532 Stop recording the session in the diary file.\n\
534 @item @var{filename}\n\
535 Record the session in the file named @var{filename}.\n\
538 With no arguments, @code{diary} toggles the current diary state.\n\
544 int argc = args.
length () + 1;
563 std::string
arg = argv[1];
570 else if (arg ==
"off")
592 DEFUN (__diaryfile__, , ,
594 @deftypefn {Built-in Function} {@var{fname} =} __diaryfile__ ()\n\
595 Undocumented internal function\n\
601 DEFUN (__diarystate__, , ,
603 @deftypefn {Built-in Function} {@var{state} =} __diarystate__ ()\n\
604 Undocumented internal function\n\
612 @deftypefn {Command} {} more\n\
613 @deftypefnx {Command} {} more on\n\
614 @deftypefnx {Command} {} more off\n\
615 Turn output pagination on or off.\n\
617 Without an argument, @code{more} toggles the current state.\n\
619 The current state can be determined via @code{page_screen_output}.\n\
620 @seealso{page_screen_output, page_output_immediately, PAGER, PAGER_FLAGS}\n\
625 int argc = args.
length () + 1;
634 std::string
arg = argv[1];
638 else if (arg ==
"off")
641 error (
"more: unrecognized argument '%s'", arg.c_str ());
651 DEFUN (terminal_size, , ,
653 @deftypefn {Built-in Function} {} terminal_size ()\n\
654 Return a two-element row vector containing the current size of the terminal\n\
655 window in characters (rows and columns).\n\
656 @seealso{list_in_columns}\n\
667 DEFUN (page_output_immediately, args, nargout,
669 @deftypefn {Built-in Function} {@var{val} =} page_output_immediately ()\n\
670 @deftypefnx {Built-in Function} {@var{old_val} =} page_output_immediately (@var{new_val})\n\
671 @deftypefnx {Built-in Function} {} page_output_immediately (@var{new_val}, \"local\")\n\
672 Query or set the internal variable that controls whether Octave sends\n\
673 output to the pager as soon as it is available.\n\
675 Otherwise, Octave buffers its output and waits until just before the prompt\n\
676 is printed to flush it to the pager.\n\
678 When called from inside a function with the @qcode{\"local\"} option, the\n\
679 variable is changed locally for the function and any subroutines it calls.\n\
680 The original variable value is restored when exiting the function.\n\
681 @seealso{page_screen_output, more, PAGER, PAGER_FLAGS}\n\
687 DEFUN (page_screen_output, args, nargout,
689 @deftypefn {Built-in Function} {@var{val} =} page_screen_output ()\n\
690 @deftypefnx {Built-in Function} {@var{old_val} =} page_screen_output (@var{new_val})\n\
691 @deftypefnx {Built-in Function} {} page_screen_output (@var{new_val}, \"local\")\n\
692 Query or set the internal variable that controls whether output intended\n\
693 for the terminal window that is longer than one page is sent through a\n\
696 This allows you to view one screenful at a time. Some pagers\n\
697 (such as @code{less}---see @ref{Installation}) are also capable of moving\n\
698 backward on the output.\n\
700 When called from inside a function with the @qcode{\"local\"} option, the\n\
701 variable is changed locally for the function and any subroutines it calls.\n\
702 The original variable value is restored when exiting the function.\n\
703 @seealso{more, page_output_immediately, PAGER, PAGER_FLAGS}\n\
709 DEFUN (PAGER, args, nargout,
711 @deftypefn {Built-in Function} {@var{val} =} PAGER ()\n\
712 @deftypefnx {Built-in Function} {@var{old_val} =} PAGER (@var{new_val})\n\
713 @deftypefnx {Built-in Function} {} PAGER (@var{new_val}, \"local\")\n\
714 Query or set the internal variable that specifies the program to use\n\
715 to display terminal output on your system.\n\
717 The default value is normally @qcode{\"less\"}, @qcode{\"more\"}, or\n\
718 @qcode{\"pg\"}, depending on what programs are installed on your system.\n\
719 @xref{Installation}.\n\
721 When called from inside a function with the @qcode{\"local\"} option, the\n\
722 variable is changed locally for the function and any subroutines it calls.\n\
723 The original variable value is restored when exiting the function.\n\
724 @seealso{PAGER_FLAGS, page_output_immediately, more, page_screen_output}\n\
730 DEFUN (PAGER_FLAGS, args, nargout,
732 @deftypefn {Built-in Function} {@var{val} =} PAGER_FLAGS ()\n\
733 @deftypefnx {Built-in Function} {@var{old_val} =} PAGER_FLAGS (@var{new_val})\n\
734 @deftypefnx {Built-in Function} {} PAGER_FLAGS (@var{new_val}, \"local\")\n\
735 Query or set the internal variable that specifies the options to pass\n\
738 When called from inside a function with the @qcode{\"local\"} option, the\n\
739 variable is changed locally for the function and any subroutines it calls.\n\
740 The original variable value is restored when exiting the function.\n\
741 @seealso{PAGER, more, page_screen_output, page_output_immediately}\n\
static int terminal_cols(void)
static hash_table_type db
OCTINTERP_API void print_usage(void)
octave_idx_type length(void) const
static bool ifexited(int status)
static bool instance_ok(void)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
#define SET_INTERNAL_VARIABLE(NM)
static void cleanup_instance(void)
static int terminal_rows(void)
static octave_diary_stream * instance
#define OCTAVE_DEFAULT_PAGER
~octave_diary_stream(void)
static std::string getenv(const std::string &name)
static void insert(pid_t pid, octave_child::child_event_handler f)
static void remove(pid_t pid)
size_t size(T const (&)[z])
#define SET_NONEMPTY_INTERNAL_STRING_VARIABLE(NM)
octave_value_list ovl(const octave_value &a0)
static bool ifsignaled(int status)
static std::ostream & stream(void)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
octave_diary_stream(void)