From: Chris Allegretta Date: Fri, 30 Jan 2009 08:34:27 +0000 (+0000) Subject: 2009-01-29 Chris Allegretta X-Git-Tag: v2.1.8~13 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=25d459aa64c137f40f45d935d6b235fb6d82b435;p=nano.git 2009-01-29 Chris Allegretta * nano.c (main): Add support for nano acting like a pager when invoked with - as first file argument. Not yet perfect (garbles screen state on exit) but it's something. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4356 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index b787dae3..191ad58a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-01-29 Chris Allegretta + * nano.c (main): Add support for nano acting like a pager when invoked with - as first + file argument. Not yet perfect (garbles screen state on exit) but it's something. + 2009-01-28 Davide Pesavento * doc/syntax/gentoo.nanorc: Updates from David and Mike Frysinger. diff --git a/src/color.c b/src/color.c index d59c3d5d..4babe482 100644 --- a/src/color.c +++ b/src/color.c @@ -260,6 +260,9 @@ void reset_multis(filestruct *fileptr) int i; filestruct *oof; + if (!openfile->syntax) + return; + for (i = 0; i < openfile->syntax->nmultis; i++) { for (oof = fileptr->next; oof != NULL; oof = oof->next) { if (oof->multiswatching == NULL) diff --git a/src/nano.c b/src/nano.c index e7a1978d..f1812697 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2239,6 +2239,30 @@ int main(int argc, char **argv) optind++; } + if (optind < argc && !strcmp(argv[optind], "-")) { + FILE *f; + int ttystdin; + struct termios term; + + enable_signals(); + open_buffer("", FALSE); + endwin(); + + f = fopen("/dev/stdin", "rb"); + if (f == NULL) + nperror("fopen"); + + read_file(f, "stdin", TRUE); + ttystdin = open("/dev/tty", O_RDONLY); + if (!ttystdin) + die(_("Couldn't reopen stdin from keyboard, sorry\n")); + + dup2(ttystdin,0); + close(ttystdin); + set_modified(); + optind++; + } + #ifdef ENABLE_MULTIBUFFER old_multibuffer = ISSET(MULTIBUFFER); SET(MULTIBUFFER);