(fix_submap_inheritance, get_keyelt, store_in_keymap,
[bpt/emacs.git] / src / term.c
index 2d8123f..64f78cc 100644 (file)
@@ -198,7 +198,7 @@ void (*judge_scroll_bars_hook)( /* FRAME_PTR *FRAME */ );
 
 /* Strings, numbers and flags taken from the termcap entry.  */
 
-char *TS_end_italic_mode;      /* termcal "ae" */
+char *TS_end_italic_mode;      /* termcap "ae" */
 char *TS_ins_line;             /* "al" */
 char *TS_italic_mode;          /* "as" */
 char *TS_ins_multi_lines;      /* "AL" (one parameter, # lines to insert) */
@@ -788,9 +788,14 @@ encode_terminal_code (src, dst, src_len, dst_len, consumed)
   register GLYPH g;
   unsigned int c;
   unsigned char workbuf[4], *buf;
-  int len, produced, processed;
+  int len;
   register int tlen = GLYPH_TABLE_LENGTH;
   register Lisp_Object *tbase = GLYPH_TABLE_BASE;
+  struct coding_system *coding;
+
+  coding = (CODING_REQUIRE_ENCODING (&terminal_coding)
+           ? &terminal_coding
+           : &safe_terminal_coding);
 
   while (src < src_end)
     {
@@ -822,18 +827,20 @@ encode_terminal_code (src, dst, src_len, dst_len, consumed)
            /* We set the multi-byte form of C at BUF.  */
            len = CHAR_STRING (c, workbuf, buf);
          else
-           /* We have a string in Vglyph_table.  */
-           len = GLYPH_LENGTH (tbase, g), buf = GLYPH_STRING (tbase, g);
+           {
+             /* We have a string in Vglyph_table.  */
+             len = GLYPH_LENGTH (tbase, g);
+             buf = GLYPH_STRING (tbase, g);
+           }
          
-         produced = encode_coding (&terminal_coding, buf, dst,
-                                    len, dst_end - dst, &processed);
-         if (processed < len)
+         encode_coding (coding, buf, dst, len, dst_end - dst);
+         if (coding->consumed < len)
            /* We get a carryover because the remaining output
               buffer is too short.  We must break the loop here
               without increasing SRC so that the next call of
               this function start from the same glyph.  */
            break;
-         dst += produced;
+         dst += coding->produced;
        }
       src++;
     }
@@ -873,8 +880,9 @@ write_glyphs (string, len)
     return;
 
   cmplus (len);
-  /* The field `last_block' should be set to 1 only at the tail.  */
-  terminal_coding.last_block = 0;
+  /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
+     the tail.  */
+  terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK;
   while (len > 0)
     {
       /* We use shared conversion buffer of the current size (1024
@@ -894,17 +902,20 @@ write_glyphs (string, len)
       string += consumed;
     }
   /* We may have to output some codes to terminate the writing.  */
-  terminal_coding.last_block = 1;
-  produced = encode_coding (&terminal_coding, (char *)0, conversion_buffer,
-                           0, conversion_buffer_size,
-                           &consumed);
-  if (produced > 0)
+  if (CODING_REQUIRE_FLUSHING (&terminal_coding))
     {
-      fwrite (conversion_buffer, 1, produced, stdout);
-      if (ferror (stdout))
-       clearerr (stdout);
-      if (termscript)
-       fwrite (conversion_buffer, 1, produced, termscript);
+      terminal_coding.mode |= CODING_MODE_LAST_BLOCK;
+      encode_coding (&terminal_coding, (char *)0, conversion_buffer,
+                    0, conversion_buffer_size);
+      if (terminal_coding.produced > 0)
+       {
+         fwrite (conversion_buffer, 1, terminal_coding.produced, stdout);
+         if (ferror (stdout))
+           clearerr (stdout);
+         if (termscript)
+           fwrite (conversion_buffer, 1, terminal_coding.produced,
+                   termscript);
+       }
     }
   cmcheckmagic ();
 }
@@ -942,8 +953,8 @@ insert_glyphs (start, len)
 
   turn_on_insert ();
   cmplus (len);
-  /* The field `last_block' should be set to 1 only at the tail.  */
-  terminal_coding.last_block = 0;
+  /* The bit CODING_MODE_LAST_BLOCK should be set to 1 only at the tail.  */
+  terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK;
   while (len-- > 0)
     {
       int produced, consumed;
@@ -956,7 +967,7 @@ insert_glyphs (start, len)
          g = *start++;
          /* We must open sufficient space for a character which
             occupies more than one column.  */
-         while (*start && GLYPH_MASK_PADDING)
+         while (*start & GLYPH_MASK_PADDING)
            {
              OUTPUT1_IF (TS_ins_char);
              start++, len--;
@@ -965,7 +976,7 @@ insert_glyphs (start, len)
 
       if (len <= 0)
        /* This is the last glyph.  */
-       terminal_coding.last_block = 1;
+       terminal_coding.mode |= CODING_MODE_LAST_BLOCK;
 
       /* We use shared conversion buffer of the current size (1024
         bytes at least).  It is surely sufficient for just one glyph.  */
@@ -1504,6 +1515,8 @@ term_get_fkeys_1 ()
       CONDITIONAL_REASSIGN ("%8", "kP", "prior");
       /* if there's no key_dc keycap, map key_ic to `insert' keysym */
       CONDITIONAL_REASSIGN ("kD", "kI", "insert");
+      /* if there's no key_end keycap, map key_ll to 'end' keysym */
+      CONDITIONAL_REASSIGN ("@7", "kH", "end");
 
       /* IBM has their own non-standard dialect of terminfo.
         If the standard name isn't found, try the IBM name.  */