update.
[chise/xemacs-chise.git.1] / src / redisplay.c
index c24f20f..ac3416f 100644 (file)
@@ -501,13 +501,13 @@ Lisp_Object Qtop_bottom;
 /***************************************************************************/
 
 static int
-redisplay_text_width_emchar_string (struct window *w, int findex,
-                                   Emchar *str, Charcount len)
+redisplay_text_width_charc_string (struct window *w, int findex,
+                                  Charc *str, Charcount len)
 {
-  unsigned char charsets[NUM_LEADING_BYTES];
+  Charset_ID charsets[NUM_LEADING_BYTES];
   Lisp_Object window;
 
-  find_charsets_in_emchar_string (charsets, str, len);
+  find_charsets_in_charc_string (charsets, str, len);
   XSETWINDOW (window, w);
   ensure_face_cachel_complete (WINDOW_FACE_CACHEL (w, findex), window,
                               charsets);
@@ -516,24 +516,24 @@ redisplay_text_width_emchar_string (struct window *w, int findex,
                               WINDOW_FACE_CACHEL (w, findex), str, len));
 }
 
-static Emchar_dynarr *rtw_emchar_dynarr;
+static Charc_dynarr *rtw_charc_dynarr;
 
 int
 redisplay_text_width_string (struct window *w, int findex,
                             Bufbyte *nonreloc, Lisp_Object reloc,
                             Bytecount offset, Bytecount len)
 {
-  if (!rtw_emchar_dynarr)
-    rtw_emchar_dynarr = Dynarr_new (Emchar);
-  Dynarr_reset (rtw_emchar_dynarr);
+  if (!rtw_charc_dynarr)
+    rtw_charc_dynarr = Dynarr_new (Charc);
+  Dynarr_reset (rtw_charc_dynarr);
 
   fixup_internal_substring (nonreloc, reloc, offset, &len);
   if (STRINGP (reloc))
     nonreloc = XSTRING_DATA (reloc);
-  convert_bufbyte_string_into_emchar_dynarr (nonreloc, len, rtw_emchar_dynarr);
-  return redisplay_text_width_emchar_string
-    (w, findex, Dynarr_atp (rtw_emchar_dynarr, 0),
-     Dynarr_length (rtw_emchar_dynarr));
+  convert_bufbyte_string_into_charc_dynarr (nonreloc, len, rtw_charc_dynarr);
+  return redisplay_text_width_charc_string
+    (w, findex, Dynarr_atp (rtw_charc_dynarr, 0),
+     Dynarr_length (rtw_charc_dynarr));
 }
 
 int
@@ -541,26 +541,26 @@ redisplay_frame_text_width_string (struct frame *f, Lisp_Object face,
                                   Bufbyte *nonreloc, Lisp_Object reloc,
                                   Bytecount offset, Bytecount len)
 {
-  unsigned char charsets[NUM_LEADING_BYTES];
+  Charset_ID charsets[NUM_LEADING_BYTES];
   Lisp_Object frame;
   struct face_cachel cachel;
 
-  if (!rtw_emchar_dynarr)
-    rtw_emchar_dynarr = Dynarr_new (Emchar);
-  Dynarr_reset (rtw_emchar_dynarr);
+  if (!rtw_charc_dynarr)
+    rtw_charc_dynarr = Dynarr_new (Charc);
+  Dynarr_reset (rtw_charc_dynarr);
 
   fixup_internal_substring (nonreloc, reloc, offset, &len);
   if (STRINGP (reloc))
     nonreloc = XSTRING_DATA (reloc);
-  convert_bufbyte_string_into_emchar_dynarr (nonreloc, len, rtw_emchar_dynarr);
+  convert_bufbyte_string_into_charc_dynarr (nonreloc, len, rtw_charc_dynarr);
   find_charsets_in_bufbyte_string (charsets, nonreloc, len);
   reset_face_cachel (&cachel);
   cachel.face = face;
   XSETFRAME (frame, f);
   ensure_face_cachel_complete (&cachel, frame, charsets);
   return DEVMETH (XDEVICE (FRAME_DEVICE (f)),
-                 text_width, (f, &cachel, Dynarr_atp (rtw_emchar_dynarr, 0),
-                              Dynarr_length (rtw_emchar_dynarr)));
+                 text_width, (f, &cachel, Dynarr_atp (rtw_charc_dynarr, 0),
+                              Dynarr_length (rtw_charc_dynarr)));
 }
 
 /* Return the display block from DL of the given TYPE.  A display line
@@ -950,6 +950,7 @@ add_emchar_rune_1 (pos_data *data, int no_contribute_to_line_height)
 {
   struct rune rb, *crb;
   int width, local;
+  Charc char_glyph;
 
   if (data->start_col)
     {
@@ -966,13 +967,17 @@ add_emchar_rune_1 (pos_data *data, int no_contribute_to_line_height)
 
   if (data->ch == '\n')
     {
+      char_glyph = ASCII_TO_CHARC ('\n');
       data->font_is_bogus = 0;
       /* Cheesy end-of-line pseudo-character. */
       width = data->blank_width;
     }
   else
     {
-      Lisp_Object charset = CHAR_CHARSET (data->ch);
+      Lisp_Object charset;
+
+      char_glyph = CHAR_TO_CHARC (data->ch);
+      charset = CHARC_CHARSET (char_glyph);
       if (!EQ (charset, data->last_charset) ||
          data->findex != data->last_findex)
        {
@@ -1013,9 +1018,9 @@ add_emchar_rune_1 (pos_data *data, int no_contribute_to_line_height)
       if (width < 0)
        {
          /* bummer.  Proportional fonts. */
-         width = redisplay_text_width_emchar_string (XWINDOW (data->window),
-                                                     data->findex,
-                                                     &data->ch, 1);
+         width = redisplay_text_width_charc_string (XWINDOW (data->window),
+                                                    data->findex,
+                                                    &char_glyph, 1);
        }
     }
 
@@ -1046,7 +1051,8 @@ add_emchar_rune_1 (pos_data *data, int no_contribute_to_line_height)
                            data->bi_bufpos);
       else
        crb->bufpos =
-         bytecount_to_charcount (XSTRING_DATA (data->string), data->bi_bufpos);
+         bytecount_to_charcount (XSTRING_DATA (data->string),
+                                 data->bi_bufpos);
     }
   else if (data->is_modeline)
     crb->bufpos = data->modeline_charpos;
@@ -1054,7 +1060,9 @@ add_emchar_rune_1 (pos_data *data, int no_contribute_to_line_height)
     /* Text but not in buffer */
     crb->bufpos = 0;
   crb->type = RUNE_CHAR;
-  crb->object.chr.ch = data->font_is_bogus ? '~' : data->ch;
+  crb->object.cglyph = data->font_is_bogus
+    ? ASCII_TO_CHARC ('~')
+    : char_glyph;
   crb->endpos = 0;
 
   if (data->cursor_type == CURSOR_ON)
@@ -1635,7 +1643,7 @@ add_propagation_runes (prop_block_dynarr **prop, pos_data *data)
          }
          break;
        default:
-         abort ();
+         ABORT ();
        }
     }
 
@@ -1830,7 +1838,7 @@ add_glyph_rune (pos_data *data, struct glyph_block *gb, int pos_type,
 
          /* Otherwise something is screwed up. */
          else
-           abort ();
+           ABORT ();
        }
 
       face = glyph_face (gb->glyph, data->window);
@@ -1938,7 +1946,7 @@ add_glyph_rune (pos_data *data, struct glyph_block *gb, int pos_type,
          return NULL;
        }
       else
-       abort ();       /* there are no unknown types */
+       ABORT ();       /* there are no unknown types */
     }
 
   return NULL;
@@ -2511,7 +2519,7 @@ create_text_block (struct window *w, struct display_line *dl,
 
              /* This had better be a newline but doing it this way
                  we'll see obvious incorrect results if it isn't.  No
-                 need to abort here. */
+                 need to ABORT here. */
              data.ch = BI_BUF_FETCH_CHAR (b, data.bi_bufpos);
 
              goto done;
@@ -2768,7 +2776,7 @@ done:
       {
        struct rune *rb = Dynarr_atp (db->runes, elt);
 
-       if ((rb->type == RUNE_CHAR && rb->object.chr.ch == ' ')
+       if ((rb->type == RUNE_CHAR && CHARC_ASCII_EQ (rb->object.cglyph, ' '))
            || rb->type == RUNE_BLANK)
          {
            dl->bounds.left_white += rb->width;
@@ -2788,8 +2796,7 @@ done:
       {
        struct rune *rb = Dynarr_atp (db->runes, elt);
 
-       if (!(rb->type == RUNE_CHAR && rb->object.chr.ch < 0x100
-           && isspace (rb->object.chr.ch))
+       if (!(rb->type == RUNE_CHAR && CHARC_IS_SPACE (rb->object.cglyph))
            && !rb->type == RUNE_BLANK)
          {
            dl->bounds.right_white = rb->xpos + rb->width;
@@ -2989,7 +2996,7 @@ add_margin_runes (struct display_line *dl, struct display_block *db, int start,
       struct glyph_block *gb = Dynarr_atp (gbd, elt);
 
       if (NILP (gb->extent))
-       abort ();       /* these should have been handled in add_glyph_rune */
+       ABORT ();       /* these should have been handled in add_glyph_rune */
 
       if (gb->active &&
          ((side == LEFT_GLYPHS &&
@@ -3074,7 +3081,7 @@ create_left_glyph_block (struct window *w, struct display_line *dl,
       struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
 
       if (NILP (gb->extent))
-       abort ();       /* these should have been handled in add_glyph_rune */
+       ABORT ();       /* these should have been handled in add_glyph_rune */
 
       if (extent_begin_glyph_layout (XEXTENT (gb->extent)) == GL_WHITESPACE)
        {
@@ -3126,7 +3133,7 @@ create_left_glyph_block (struct window *w, struct display_line *dl,
        struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
 
        if (NILP (gb->extent))
-         abort ();     /* these should have been handled in add_glyph_rune */
+         ABORT ();     /* these should have been handled in add_glyph_rune */
 
        if (extent_begin_glyph_layout (XEXTENT (gb->extent)) ==
            GL_INSIDE_MARGIN)
@@ -3195,7 +3202,7 @@ create_left_glyph_block (struct window *w, struct display_line *dl,
        struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
 
        if (NILP (gb->extent))
-         abort ();     /* these should have been handled in add_glyph_rune */
+         ABORT ();     /* these should have been handled in add_glyph_rune */
 
        if (extent_begin_glyph_layout (XEXTENT (gb->extent)) ==
            GL_INSIDE_MARGIN)
@@ -3237,7 +3244,7 @@ create_left_glyph_block (struct window *w, struct display_line *dl,
       struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
 
       if (NILP (gb->extent))
-       abort ();       /* these should have been handled in add_glyph_rune */
+       ABORT ();       /* these should have been handled in add_glyph_rune */
 
       if (extent_begin_glyph_layout (XEXTENT (gb->extent)) ==
          GL_OUTSIDE_MARGIN)
@@ -3395,7 +3402,7 @@ create_right_glyph_block (struct window *w, struct display_line *dl)
       struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
 
       if (NILP (gb->extent))
-       abort ();       /* these should have been handled in add_glyph_rune */
+       ABORT ();       /* these should have been handled in add_glyph_rune */
 
       if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_WHITESPACE)
        {
@@ -3445,7 +3452,7 @@ create_right_glyph_block (struct window *w, struct display_line *dl)
        struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
 
        if (NILP (gb->extent))
-         abort ();     /* these should have been handled in add_glyph_rune */
+         ABORT ();     /* these should have been handled in add_glyph_rune */
 
        if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_INSIDE_MARGIN)
          {
@@ -3509,7 +3516,7 @@ create_right_glyph_block (struct window *w, struct display_line *dl)
        struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
 
        if (NILP (gb->extent))
-         abort ();     /* these should have been handled in add_glyph_rune */
+         ABORT ();     /* these should have been handled in add_glyph_rune */
 
        if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_INSIDE_MARGIN)
          {
@@ -3550,7 +3557,7 @@ create_right_glyph_block (struct window *w, struct display_line *dl)
       struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
 
       if (NILP (gb->extent))
-       abort ();       /* these should have been handled in add_glyph_rune */
+       ABORT ();       /* these should have been handled in add_glyph_rune */
 
       if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_OUTSIDE_MARGIN)
        {
@@ -3755,8 +3762,9 @@ generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str,
           if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR)
             {
               len += (set_charptr_emchar
-                      (strdata + len, Dynarr_atp (db->runes,
-                                                  elt)->object.chr.ch));
+                     (strdata + len,
+                      CHARC_TO_CHAR (Dynarr_atp (db->runes,
+                                                 elt)->object.cglyph)));
             }
         }
 
@@ -4740,7 +4748,7 @@ create_string_text_block (struct window *w, Lisp_Object disp_string,
          else if (data.bi_bufpos == bi_string_zv)
            goto done;
          else if (data.bi_bufpos < 0)
-           /* #### urk urk urk! Aborts are not very fun! Fix this please! */
+           /* #### urk urk urk! ABORTs are not very fun! Fix this please! */
            data.bi_bufpos = 0;
          else
            INC_CHARBYTIND (string_data (s), data.bi_bufpos);
@@ -4992,7 +5000,7 @@ create_string_text_block (struct window *w, Lisp_Object disp_string,
       {
        struct rune *rb = Dynarr_atp (db->runes, elt);
 
-       if ((rb->type == RUNE_CHAR && rb->object.chr.ch == ' ')
+       if ((rb->type == RUNE_CHAR && CHARC_ASCII_EQ (rb->object.cglyph, ' '))
            || rb->type == RUNE_BLANK)
          {
            dl->bounds.left_white += rb->width;
@@ -5012,8 +5020,7 @@ create_string_text_block (struct window *w, Lisp_Object disp_string,
       {
        struct rune *rb = Dynarr_atp (db->runes, elt);
 
-       if (!(rb->type == RUNE_CHAR && rb->object.chr.ch < 0x100
-           && isspace (rb->object.chr.ch))
+       if (!(rb->type == RUNE_CHAR && CHARC_IS_SPACE (rb->object.cglyph))
            && !rb->type == RUNE_BLANK)
          {
            dl->bounds.right_white = rb->xpos + rb->width;
@@ -5291,7 +5298,7 @@ regenerate_window (struct window *w, Bufpos start_pos, Bufpos point, int type)
 
   /* The lines had better exist by this point. */
   if (!(dla = window_display_lines (w, type)))
-    abort ();
+    ABORT ();
   Dynarr_reset (dla);
   w->max_line_len = 0;
 
@@ -5483,7 +5490,7 @@ regenerate_window (struct window *w, Bufpos start_pos, Bufpos point, int type)
            dla_start = 0;                      \
          }                                     \
        else                                    \
-         abort ();     /* structs differ */    \
+         ABORT ();     /* structs differ */    \
                                                \
        dla_end = Dynarr_length (cdla) - 1;     \
       }                                                \
@@ -6505,7 +6512,7 @@ redisplay_frame (struct frame *f, int preemption_check)
   /* The menubar, toolbar, and icon updates must be done before
      hold_frame_size_changes is called and we are officially
      'in_display'.  They may eval lisp code which may call Fsignal.
-     If in_display is set Fsignal will abort. */
+     If in_display is set Fsignal will ABORT. */
 
 #ifdef HAVE_MENUBARS
   /* Update the menubar.  It is done first since it could change
@@ -6565,10 +6572,10 @@ redisplay_frame (struct frame *f, int preemption_check)
      We need to remove them.
 
      If Fsignal() is called during this critical section, we
-     will abort().
+     will ABORT().
 
      If garbage collection is called during this critical section,
-     we simply return. #### We should abort instead.
+     we simply return. #### We should ABORT instead.
 
      #### If a frame-size change does occur we should probably
      actually be preempting redisplay. */
@@ -7493,7 +7500,7 @@ point_in_line_start_cache (struct window *w, Bufpos point, int min_past)
       int win_char_height = window_char_height (w, 1);
 
       /* Occasionally we get here with a 0 height
-         window. find_next_newline_no_quit will abort if we pass it a
+         window. find_next_newline_no_quit will ABORT if we pass it a
          count of 0 so handle that case. */
       if (!win_char_height)
        win_char_height = 1;
@@ -7603,7 +7610,7 @@ find_point_loop:
 
   while (1)
     {
-      unsigned int new_pos;
+      EMACS_INT new_pos;
       Bufpos start, end;
 
       pos = (bottom + top + 1) >> 1;
@@ -7645,7 +7652,7 @@ find_point_loop:
       else if (point < start)
        top = pos - 1;
       else
-       abort ();
+       ABORT ();
 
       new_pos = (bottom + top + 1) >> 1;
       if (pos == new_pos)
@@ -8914,7 +8921,7 @@ pixel_to_glyph_translation (struct frame *f, int x_coord, int y_coord,
                    }
                  else if (past_end
                           || (rb->type == RUNE_CHAR
-                              && rb->object.chr.ch == '\n'))
+                              && CHARC_ASCII_EQ (rb->object.cglyph, '\n')))
                    {
                      (*row)--;
                      /* At this point we may have glyphs in the right