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")
594 @deftypefn {Command} {} more\n\
595 @deftypefnx {Command} {} more on\n\
596 @deftypefnx {Command} {} more off\n\
597 Turn output pagination on or off. Without an argument, @code{more}\n\
598 toggles the current state.\n\
599 The current state can be determined via @code{page_screen_output}.\n\
600 @seealso{page_screen_output, page_output_immediately, PAGER, PAGER_FLAGS}\n\
605 int argc = args.
length () + 1;
614 std::string
arg = argv[1];
618 else if (arg ==
"off")
621 error (
"more: unrecognized argument '%s'", arg.c_str ());
631 DEFUN (terminal_size, , ,
633 @deftypefn {Built-in Function} {} terminal_size ()\n\
634 Return a two-element row vector containing the current size of the\n\
635 terminal window in characters (rows and columns).\n\
636 @seealso{list_in_columns}\n\
647 DEFUN (page_output_immediately, args, nargout,
649 @deftypefn {Built-in Function} {@var{val} =} page_output_immediately ()\n\
650 @deftypefnx {Built-in Function} {@var{old_val} =} page_output_immediately (@var{new_val})\n\
651 @deftypefnx {Built-in Function} {} page_output_immediately (@var{new_val}, \"local\")\n\
652 Query or set the internal variable that controls whether Octave sends\n\
653 output to the pager as soon as it is available. Otherwise, Octave\n\
654 buffers its output and waits until just before the prompt is printed to\n\
655 flush it to the pager.\n\
657 When called from inside a function with the @qcode{\"local\"} option, the\n\
658 variable is changed locally for the function and any subroutines it calls. \n\
659 The original variable value is restored when exiting the function.\n\
660 @seealso{page_screen_output, more, PAGER, PAGER_FLAGS}\n\
666 DEFUN (page_screen_output, args, nargout,
668 @deftypefn {Built-in Function} {@var{val} =} page_screen_output ()\n\
669 @deftypefnx {Built-in Function} {@var{old_val} =} page_screen_output (@var{new_val})\n\
670 @deftypefnx {Built-in Function} {} page_screen_output (@var{new_val}, \"local\")\n\
671 Query or set the internal variable that controls whether output intended\n\
672 for the terminal window that is longer than one page is sent through a\n\
673 pager. This allows you to view one screenful at a time. Some pagers\n\
674 (such as @code{less}---see @ref{Installation}) are also capable of moving\n\
675 backward on the output.\n\
677 When called from inside a function with the @qcode{\"local\"} option, the\n\
678 variable is changed locally for the function and any subroutines it calls. \n\
679 The original variable value is restored when exiting the function.\n\
680 @seealso{more, page_output_immediately, PAGER, PAGER_FLAGS}\n\
686 DEFUN (PAGER, args, nargout,
688 @deftypefn {Built-in Function} {@var{val} =} PAGER ()\n\
689 @deftypefnx {Built-in Function} {@var{old_val} =} PAGER (@var{new_val})\n\
690 @deftypefnx {Built-in Function} {} PAGER (@var{new_val}, \"local\")\n\
691 Query or set the internal variable that specifies the program to use\n\
692 to display terminal output on your system. The default value is\n\
693 normally @qcode{\"less\"}, @qcode{\"more\"}, or\n\
694 @qcode{\"pg\"}, depending on what programs are installed on your system.\n\
695 @xref{Installation}.\n\
697 When called from inside a function with the @qcode{\"local\"} option, the\n\
698 variable is changed locally for the function and any subroutines it calls. \n\
699 The original variable value is restored when exiting the function.\n\
700 @seealso{PAGER_FLAGS, page_output_immediately, more, page_screen_output}\n\
706 DEFUN (PAGER_FLAGS, args, nargout,
708 @deftypefn {Built-in Function} {@var{val} =} PAGER_FLAGS ()\n\
709 @deftypefnx {Built-in Function} {@var{old_val} =} PAGER_FLAGS (@var{new_val})\n\
710 @deftypefnx {Built-in Function} {} PAGER_FLAGS (@var{new_val}, \"local\")\n\
711 Query or set the internal variable that specifies the options to pass\n\
714 When called from inside a function with the @qcode{\"local\"} option, the\n\
715 variable is changed locally for the function and any subroutines it calls. \n\
716 The original variable value is restored when exiting the function.\n\
717 @seealso{PAGER, more, page_screen_output, page_output_immediately}\n\