Undo previous change.
[bpt/emacs.git] / src / cm.c
index da09ac2..7362822 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -1,12 +1,12 @@
 /* Cursor motion subroutines for GNU Emacs.
-   Copyright (C) 1985 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1995 Free Software Foundation, Inc.
     based primarily on public domain code written by Chris Torek
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -16,7 +16,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 
 #include <config.h>
@@ -38,15 +39,16 @@ evalcost (c)
      char c;
 {
   cost++;
+  return c;
 }
 
-void
 cmputc (c)
      char c;
 {
   if (termscript)
     fputc (c & 0177, termscript);
   putchar (c & 0177);
+  return c;
 }
 
 /* NEXT TWO ARE DONE WITH MACROS */
@@ -98,6 +100,35 @@ addcol (n) {
 }
 #endif
 
+/*
+ * Terminals with magicwrap (xn) don't all behave identically.
+ * The VT100 leaves the cursor in the last column but will wrap before
+ * printing the next character.  I hear that the Concept terminal does
+ * the wrap immediately but ignores the next newline it sees.  And some
+ * terminals just have buggy firmware, and think that the cursor is still
+ * in limbo if we use direct cursor addressing from the phantom column.
+ * The only guaranteed safe thing to do is to emit a CRLF immediately
+ * after we reach the last column; this takes us to a known state.
+ */
+void
+cmcheckmagic ()
+{
+  if (curX == FrameCols)
+    {
+      if (!MagicWrap || curY >= FrameRows - 1)
+       abort ();
+      if (termscript)
+       putc ('\r', termscript);
+      putchar ('\r');
+      if (termscript)
+       putc ('\n', termscript);
+      putchar ('\n');
+      curX = 0;
+      curY++;
+    }
+}
+
+
 /*
  * (Re)Initialize the cost factors, given the output speed of the terminal
  * in the variable ospeed.  (Note: this holds B300, B9600, etc -- ie stuff