Mercurial > hg > octave-lyh
changeset 6144:e8868fde0fc5
[project @ 2006-11-07 20:52:18 by jwe]
author | jwe |
---|---|
date | Tue, 07 Nov 2006 20:52:19 +0000 |
parents | 47f0cab13a02 |
children | 14906c2745e3 |
files | scripts/ChangeLog scripts/startup/main-rcfile src/ChangeLog src/pager.cc src/utils.cc |
diffstat | 5 files changed, 47 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2006-11-07 John W. Eaton <jwe@octave.org> + + * startup/main-rcfile: Conditionally set PAGER_FLAGS. + 2006-11-06 Søren Hauberg <soren@hauberg.org> * pkg/pkg.m (extract_pkg): No need to pass "dotexceptnewline"
--- a/scripts/startup/main-rcfile +++ b/scripts/startup/main-rcfile @@ -9,3 +9,7 @@ read_readline_init_file (sprintf ("%s%s%s", octave_config_info ("startupfiledir"), filesep, "inputrc")); + +if (strcmp (PAGER (), "less") && isempty (getenv ("LESS"))) + PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"'); +endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2006-11-07 John W. Eaton <jwe@octave.org> + + * utils.cc (file_in_path): Don't unconditionally return "". + + * pager.cc (default_pager): Don't append options here. + (pager_command): New function. + (do_sync): Use it. + (VPAGER_FLAGS): New variable. + (FPAGER_FLAGS): New function. + 2006-11-06 John W. Eaton <jwe@octave.org> * oct-hist.cc (default_history_file): If env_file is not empty,
--- a/src/pager.cc +++ b/src/pager.cc @@ -64,19 +64,7 @@ #ifdef OCTAVE_DEFAULT_PAGER if (pager_binary.empty ()) - { - pager_binary = std::string (OCTAVE_DEFAULT_PAGER); - - if (pager_binary == "less") - { - pager_binary.append (" -e"); - - std::string lessflags = octave_env::getenv ("LESS"); - if (lessflags.empty ()) - pager_binary.append - (" -X -P'-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$'"); - } - } + pager_binary = OCTAVE_DEFAULT_PAGER; #endif return pager_binary; @@ -85,6 +73,9 @@ // The shell command to run as the pager. static std::string VPAGER = default_pager (); +// The options to pass to the pager. +static std::string VPAGER_FLAGS; + // TRUE means that if output is going to the pager, it is sent as soon // as it is available. Otherwise, it is buffered and only sent to the // pager when it is time to print another prompt. @@ -137,6 +128,17 @@ return retval; } +static std::string +pager_command (void) +{ + std::string cmd = VPAGER; + + if (! (cmd.empty () || VPAGER_FLAGS.empty ())) + cmd += " " + VPAGER_FLAGS; + + return cmd; +} + static void do_sync (const char *msg, int len, bool bypass_pager) { @@ -151,7 +153,7 @@ { if (! external_pager) { - std::string pgr = VPAGER; + std::string pgr = pager_command (); if (! pgr.empty ()) { @@ -576,12 +578,24 @@ normally @code{\"less\"}, @code{\"more\"}, or\n\ @code{\"pg\"}, depending on what programs are installed on your system.\n\ @xref{Installation}.\n\ -@seealso{page_screen_output, page_output_immediately}\n\ +@seealso{more, page_screen_output, page_output_immediately, PAGER_FLAGS}\n\ @end deftypefn") { return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (PAGER); } +DEFUN (PAGER_FLAGS, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {@var{val} =} PAGER_FLAGS ()\n\ +@deftypefnx {Built-in Function} {@var{old_val} =} PAGER_FLAGS (@var{new_val})\n\ +Query or set the internal variable that specifies the options to pass\n\ +to the pager.\n\ +@seealso{PAGER}\n\ +@end deftypefn") +{ + return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (PAGER_FLAGS); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***