From 9239d742d6268dccbb1e198e1e562f7913bbea37 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Wed, 6 Sep 2000 15:19:18 +0000
Subject: [PATCH] Use raw mode if _POSIX_VDISABLE isn't available, to allow
 support under cygwin

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@210 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  4 ++++
 nano.c      | 21 +++++++++++++++++++++
 po/nano.pot | 12 ++++++------
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 11637c03..1bbb8bbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@ CVS code -
   do_cut_text()
 	- Don't immediately abort if we're on filebot and the marker is
 	  set (fixes bug #42).
+- nano.c:
+	- main()
+	- Added check for _POSIX_VDISABLE and use raw mode if not
+	  available, allows nano to work with cygwin.
 
 nano-0.9.17 - 09/04/2000
 - General
diff --git a/nano.c b/nano.c
index db6983b9..be2e912c 100644
--- a/nano.c
+++ b/nano.c
@@ -1825,11 +1825,13 @@ int main(int argc, char *argv[])
     /* First back up the old settings so they can be restored, duh */
     tcgetattr(0, &oldterm);
 
+#ifdef _POSIX_VDISABLE
     term = oldterm;
     term.c_cc[VINTR] = _POSIX_VDISABLE;
     term.c_cc[VQUIT] = _POSIX_VDISABLE;
     term.c_lflag &= ~IEXTEN;
     tcsetattr(0, TCSANOW, &term);
+#endif
 
     /* now ncurses init stuff... */
     initscr();
@@ -1886,6 +1888,12 @@ int main(int argc, char *argv[])
     reset_cursor();
 
     while (1) {
+
+#ifndef _POSIX_VDISABLE
+	/* We're going to have to do it the old way, i.e. on cygwin */
+	raw();
+#endif
+
 	kbinput = wgetch(edit);
 	if (kbinput == 27) {	/* Grab Alt-key stuff first */
 	    switch (kbinput = wgetch(edit)) {
@@ -1981,6 +1989,19 @@ int main(int argc, char *argv[])
 		keyhandled = 1;
 	    }
 	}
+#ifndef _POSIX_VDISABLE
+	/* Since we're in raw mode, we have to catch ^Q and ^S */
+	if (kbinput == 17 || kbinput == 19)
+	    keyhandled = 1;
+
+	/* And catch ^Z by hand when triggered */
+	if (kbinput == 26) {
+	    if (ISSET(SUSPEND))
+		do_suspend(0);
+	    keyhandled = 1;
+	}
+#endif
+
 	/* Last gasp, stuff that's not in the main lists */
 	if (!keyhandled)
 	    switch (kbinput) {
diff --git a/po/nano.pot b/po/nano.pot
index 53dd1b38..bcf9d446 100644
--- a/po/nano.pot
+++ b/po/nano.pot
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-09-06 10:16-0400\n"
+"POT-Creation-Date: 2000-09-06 11:26-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -675,24 +675,24 @@ msgstr ""
 msgid "Cannot move bottom win"
 msgstr ""
 
-#: nano.c:1850
+#: nano.c:1852
 msgid "Main: set up windows\n"
 msgstr ""
 
-#: nano.c:1865
+#: nano.c:1867
 msgid "Main: bottom win\n"
 msgstr ""
 
-#: nano.c:1871
+#: nano.c:1873
 msgid "Main: open file\n"
 msgstr ""
 
-#: nano.c:1939
+#: nano.c:1947
 #, c-format
 msgid "I got Alt-[-%c! (%d)\n"
 msgstr ""
 
-#: nano.c:1965
+#: nano.c:1973
 #, c-format
 msgid "I got Alt-%c! (%d)\n"
 msgstr ""
-- 
GitLab