comparison src/redisplay.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents fdefd0186b75
children e38acbeb1cae
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
1 /* Display generation from window structure and buffer text. 1 /* Display generation from window structure and buffer text.
2 Copyright (C) 1994, 1995, 1996 Board of Trustees, University of Illinois. 2 Copyright (C) 1994, 1995, 1996 Board of Trustees, University of Illinois.
3 Copyright (C) 1995 Free Software Foundation, Inc. 3 Copyright (C) 1995 Free Software Foundation, Inc.
4 Copyright (C) 1995, 1996 Ben Wing. 4 Copyright (C) 1995, 1996, 2000, 2001, 2002 Ben Wing.
5 Copyright (C) 1995 Sun Microsystems, Inc. 5 Copyright (C) 1995 Sun Microsystems, Inc.
6 Copyright (C) 1996 Chuck Thompson. 6 Copyright (C) 1996 Chuck Thompson.
7 7
8 This file is part of XEmacs. 8 This file is part of XEmacs.
9 9
57 #include "process.h" 57 #include "process.h"
58 #include "redisplay.h" 58 #include "redisplay.h"
59 #include "toolbar.h" 59 #include "toolbar.h"
60 #include "window.h" 60 #include "window.h"
61 #include "line-number.h" 61 #include "line-number.h"
62 #ifdef FILE_CODING
63 #include "file-coding.h" 62 #include "file-coding.h"
64 #endif
65 63
66 #include "sysfile.h" 64 #include "sysfile.h"
67 65
68 #ifdef HAVE_TTY 66 #ifdef HAVE_TTY
69 #include "console-tty.h" 67 #include "console-tty.h"
861 } 859 }
862 else 860 else
863 data->font_is_bogus = 0; 861 data->font_is_bogus = 0;
864 862
865 fi = XFONT_INSTANCE (font_instance); 863 fi = XFONT_INSTANCE (font_instance);
866 if (!fi->proportional_p) 864 if (!fi->proportional_p || data->font_is_bogus)
867 /* sweetness and light. */ 865 {
868 data->last_char_width = fi->width; 866 Emchar ch = data->font_is_bogus ? '~' : data->ch;
867
868 data->last_char_width =
869 redisplay_text_width_emchar_string (XWINDOW (data->window),
870 data->findex, &ch, 1);
871 }
869 else 872 else
870 data->last_char_width = -1; 873 data->last_char_width = -1;
871 data->new_ascent = max (data->new_ascent, (int) fi->ascent); 874 data->new_ascent = max (data->new_ascent, (int) fi->ascent);
872 data->new_descent = max (data->new_descent, (int) fi->descent); 875 data->new_descent = max (data->new_descent, (int) fi->descent);
873 data->last_charset = charset; 876 data->last_charset = charset;
874 data->last_findex = data->findex; 877 data->last_findex = data->findex;
875 } 878 }
876 879
877 width = data->last_char_width; 880 width = data->last_char_width;
878 if (width < 0) 881 if (width < 0) /* proportional fonts */
879 { 882 width = redisplay_text_width_emchar_string (XWINDOW (data->window),
880 /* bummer. Proportional fonts. */ 883 data->findex,
881 width = redisplay_text_width_emchar_string (XWINDOW (data->window), 884 &data->ch, 1);
882 data->findex,
883 &data->ch, 1);
884 }
885 } 885 }
886 886
887 if (data->max_pixpos != -1 && (data->pixpos + width > data->max_pixpos)) 887 if (data->max_pixpos != -1 && (data->pixpos + width > data->max_pixpos))
888 { 888 {
889 return ADD_FAILED; 889 return ADD_FAILED;
909 crb->charbpos = 909 crb->charbpos =
910 bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (XWINDOW (data->window))), 910 bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (XWINDOW (data->window))),
911 data->bi_charbpos); 911 data->bi_charbpos);
912 else 912 else
913 crb->charbpos = 913 crb->charbpos =
914 bytecount_to_charcount (XSTRING_DATA (data->string), data->bi_charbpos); 914 XSTRING_INDEX_BYTE_TO_CHAR (data->string, data->bi_charbpos);
915 } 915 }
916 else if (data->is_modeline) 916 else if (data->is_modeline)
917 crb->charbpos = data->modeline_charpos; 917 crb->charbpos = data->modeline_charpos;
918 else 918 else
919 /* Text but not in buffer */ 919 /* Text but not in buffer */
3542 Intbyte *strdata; 3542 Intbyte *strdata;
3543 struct buffer *buf = XBUFFER (WINDOW_BUFFER (w)); 3543 struct buffer *buf = XBUFFER (WINDOW_BUFFER (w));
3544 3544
3545 in_modeline_generation = 1; 3545 in_modeline_generation = 1;
3546 3546
3547 sledgehammer_check_ascii_begin (result_str);
3547 detach_all_extents (result_str); 3548 detach_all_extents (result_str);
3548 resize_string (XSTRING (result_str), -1, 3549 resize_string (XSTRING (result_str), -1,
3549 data.bytepos - XSTRING_LENGTH (result_str)); 3550 data.bytepos - XSTRING_LENGTH (result_str));
3550 3551
3551 strdata = XSTRING_DATA (result_str); 3552 strdata = XSTRING_DATA (result_str);
3557 len += (set_charptr_emchar 3558 len += (set_charptr_emchar
3558 (strdata + len, Dynarr_atp (db->runes, 3559 (strdata + len, Dynarr_atp (db->runes,
3559 elt)->object.chr.ch)); 3560 elt)->object.chr.ch));
3560 } 3561 }
3561 } 3562 }
3563
3564 init_string_ascii_begin (result_str);
3565 bump_string_modiff (result_str);
3566 sledgehammer_check_ascii_begin (result_str);
3562 3567
3563 for (elt = 0; elt < Dynarr_length (formatted_string_extent_dynarr); 3568 for (elt = 0; elt < Dynarr_length (formatted_string_extent_dynarr);
3564 elt++) 3569 elt++)
3565 { 3570 {
3566 Lisp_Object extent = Qnil; 3571 Lisp_Object extent = Qnil;
3680 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj; 3685 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj;
3681 } 3686 }
3682 3687
3683 static Charcount 3688 static Charcount
3684 add_string_to_fstring_db_runes (pos_data *data, const Intbyte *str, 3689 add_string_to_fstring_db_runes (pos_data *data, const Intbyte *str,
3685 Charcount pos, Charcount min_pos, Charcount max_pos) 3690 Charcount pos, Charcount min_pos,
3691 Charcount max_pos)
3686 { 3692 {
3687 /* This function has been Mule-ized. */ 3693 /* This function has been Mule-ized. */
3688 Charcount end; 3694 Charcount end;
3689 const Intbyte *cur_pos = str; 3695 const Intbyte *cur_pos = str;
3690 struct display_block *db = data->db; 3696 struct display_block *db = data->db;
3970 * - If first element is a string or a cons, process all the elements 3976 * - If first element is a string or a cons, process all the elements
3971 * and effectively concatenate them. 3977 * and effectively concatenate them.
3972 * - If first element is a negative number, truncate displaying cdr to 3978 * - If first element is a negative number, truncate displaying cdr to
3973 * at most that many characters. If positive, pad (with spaces) 3979 * at most that many characters. If positive, pad (with spaces)
3974 * to at least that many characters. 3980 * to at least that many characters.
3975 * - If first element is another symbol, process the cadr or caddr 3981 * - If first element is another symbol or a boolean specifier, process
3976 * recursively according to whether the symbol's value is non-nil or 3982 * the cadr or caddr recursively according to whether the symbol's
3977 * nil. 3983 * value or specifier's instance is non-nil or nil.
3984 * - If first element is , process the cadr or caddr
3985 * recursively according to whether the instance of the specifier in
3986 * the modeline's window is non-nil or nil.
3978 * - If first element is an extent, process the cdr recursively 3987 * - If first element is an extent, process the cdr recursively
3979 * and handle the extent's face. 3988 * and handle the extent's face.
3980 */ 3989 */
3981 3990
3982 Lisp_Object car, tem; 3991 Lisp_Object car, tem;
3983 3992
3984 car = XCAR (elt); 3993 car = XCAR (elt);
3985 if (SYMBOLP (car)) 3994 if (SYMBOLP (car) || BOOLEAN_SPECIFIERP (car))
3986 { 3995 {
3987 elt = XCDR (elt); 3996 elt = XCDR (elt);
3988 if (!CONSP (elt)) 3997 if (!CONSP (elt))
3989 goto invalid; 3998 goto invalid;
3990 3999
3991 tem = symbol_value_in_buffer (car, w->buffer); 4000 if (SYMBOLP (car))
4001 tem = symbol_value_in_buffer (car, w->buffer);
4002 else
4003 tem = specifier_instance_no_quit (car, Qunbound, wrap_window (w),
4004 ERROR_ME_NOT, 0, Qzero);
3992 /* elt is now the cdr, and we know it is a cons cell. 4005 /* elt is now the cdr, and we know it is a cons cell.
3993 Use its car if CAR has a non-nil value. */ 4006 Use its car if CAR has a non-nil value. */
3994 if (!UNBOUNDP (tem)) 4007 if (!UNBOUNDP (tem) && !NILP (tem))
3995 { 4008 {
3996 if (!NILP (tem)) 4009 elt = XCAR (elt);
3997 { 4010 goto tail_recurse;
3998 elt = XCAR (elt);
3999 goto tail_recurse;
4000 }
4001 } 4011 }
4002 /* Symbol's value is nil (or symbol is unbound) 4012 /* Symbol's value or specifier's instance is nil or unbound
4003 * Get the cddr of the original list 4013 * Get the cddr of the original list
4004 * and if possible find the caddr and use that. 4014 * and if possible find the caddr and use that.
4005 */ 4015 */
4006 elt = XCDR (elt); 4016 elt = XCDR (elt);
4007 if (NILP (elt)) 4017 if (NILP (elt))
4280 Lisp_String* s = XSTRING (disp_string); 4290 Lisp_String* s = XSTRING (disp_string);
4281 4291
4282 /* we're working with these a lot so precalculate them */ 4292 /* we're working with these a lot so precalculate them */
4283 Bytecount slen = XSTRING_LENGTH (disp_string); 4293 Bytecount slen = XSTRING_LENGTH (disp_string);
4284 Bytecount bi_string_zv = slen; 4294 Bytecount bi_string_zv = slen;
4285 Bytebpos bi_start_pos = charcount_to_bytecount (string_data (s), start_pos); 4295 Bytebpos bi_start_pos = string_index_char_to_byte (s, start_pos);
4286 4296
4287 pos_data data; 4297 pos_data data;
4288 4298
4289 int truncate_win = b ? window_truncation_on (w) : 0; 4299 int truncate_win = b ? window_truncation_on (w) : 0;
4290 int end_glyph_width = 0; 4300 int end_glyph_width = 0;
4906 it so that regenerate_window will exit properly. This is bogus. 4916 it so that regenerate_window will exit properly. This is bogus.
4907 The main loop should get fixed so that it isn't necessary to call 4917 The main loop should get fixed so that it isn't necessary to call
4908 this function if we are already at EOB. */ 4918 this function if we are already at EOB. */
4909 4919
4910 if (data.bi_charbpos == bi_string_zv && bi_start_pos == bi_string_zv) 4920 if (data.bi_charbpos == bi_string_zv && bi_start_pos == bi_string_zv)
4911 return bytecount_to_charcount (string_data (s), data.bi_charbpos) + 1; /* Yuck! */ 4921 return string_index_byte_to_char (s, data.bi_charbpos) + 1; /* Yuck! */
4912 else 4922 else
4913 return bytecount_to_charcount (string_data (s), data.bi_charbpos); 4923 return string_index_byte_to_char (s, data.bi_charbpos);
4914 } 4924 }
4915 4925
4916 /* Given a display line and a starting position, ensure that the 4926 /* Given a display line and a starting position, ensure that the
4917 contents of the display line accurately represent the visual 4927 contents of the display line accurately represent the visual
4918 representation of the buffer contents starting from the given 4928 representation of the buffer contents starting from the given
6590 size_changed = 0; 6600 size_changed = 0;
6591 6601
6592 reset_buffer_changes (); 6602 reset_buffer_changes ();
6593 6603
6594 done: 6604 done:
6595 unbind_to (count, Qnil); 6605 unbind_to (count);
6596 } 6606 }
6597 6607
6598 void 6608 void
6599 redisplay (void) 6609 redisplay (void)
6600 { 6610 {
6709 6719
6710 goto decode_mode_spec_done; 6720 goto decode_mode_spec_done;
6711 } 6721 }
6712 /* print the file coding system */ 6722 /* print the file coding system */
6713 case 'C': 6723 case 'C':
6714 #ifdef FILE_CODING
6715 { 6724 {
6716 Lisp_Object codesys = b->buffer_file_coding_system; 6725 Lisp_Object codesys = b->buffer_file_coding_system;
6717 /* Be very careful here not to get an error. */ 6726 /* Be very careful here not to get an error. */
6718 if (NILP (codesys) || SYMBOLP (codesys) || CODING_SYSTEMP (codesys)) 6727 if (NILP (codesys) || SYMBOLP (codesys) || CODING_SYSTEMP (codesys))
6719 { 6728 {
6720 codesys = Ffind_coding_system (codesys); 6729 codesys = find_coding_system_for_text_file (codesys, 0);
6721 if (CODING_SYSTEMP (codesys)) 6730 if (CODING_SYSTEMP (codesys))
6722 obj = XCODING_SYSTEM_MNEMONIC (codesys); 6731 obj = XCODING_SYSTEM_MNEMONIC (codesys);
6723 } 6732 }
6724 } 6733 }
6725 #endif /* FILE_CODING */
6726 break; 6734 break;
6727 6735
6728 /* print the current line number */ 6736 /* print the current line number */
6729 case 'l': 6737 case 'l':
6730 str = window_line_number (w, type); 6738 str = window_line_number (w, type);
8844 redisplay_frame (f, 1); 8852 redisplay_frame (f, 1);
8845 8853
8846 /* See the comment in Fredisplay_frame. */ 8854 /* See the comment in Fredisplay_frame. */
8847 RESET_CHANGED_SET_FLAGS; 8855 RESET_CHANGED_SET_FLAGS;
8848 8856
8849 return unbind_to (count, Qnil); 8857 return unbind_to (count);
8850 } 8858 }
8851 8859
8852 DEFUN ("redisplay-frame", Fredisplay_frame, 0, 2, 0, /* 8860 DEFUN ("redisplay-frame", Fredisplay_frame, 0, 2, 0, /*
8853 Ensure that FRAME's contents are correctly displayed. 8861 Ensure that FRAME's contents are correctly displayed.
8854 This differs from `redraw-frame' in that it only redraws what needs to 8862 This differs from `redraw-frame' in that it only redraws what needs to
8880 calling Fredisplay_frame while updating another frame. We assume 8888 calling Fredisplay_frame while updating another frame. We assume
8881 that if you know what you are doing you will not be that 8889 that if you know what you are doing you will not be that
8882 stupid. */ 8890 stupid. */
8883 RESET_CHANGED_SET_FLAGS; 8891 RESET_CHANGED_SET_FLAGS;
8884 8892
8885 return unbind_to (count, Qnil); 8893 return unbind_to (count);
8886 } 8894 }
8887 8895
8888 DEFUN ("redraw-device", Fredraw_device, 0, 2, 0, /* 8896 DEFUN ("redraw-device", Fredraw_device, 0, 2, 0, /*
8889 Clear device DEVICE and output again what is supposed to appear on it. 8897 Clear device DEVICE and output again what is supposed to appear on it.
8890 DEVICE defaults to the selected device if omitted. 8898 DEVICE defaults to the selected device if omitted.
8912 redisplay_device (d, 0); 8920 redisplay_device (d, 0);
8913 8921
8914 /* See the comment in Fredisplay_frame. */ 8922 /* See the comment in Fredisplay_frame. */
8915 RESET_CHANGED_SET_FLAGS; 8923 RESET_CHANGED_SET_FLAGS;
8916 8924
8917 return unbind_to (count, Qnil); 8925 return unbind_to (count);
8918 } 8926 }
8919 8927
8920 DEFUN ("redisplay-device", Fredisplay_device, 0, 2, 0, /* 8928 DEFUN ("redisplay-device", Fredisplay_device, 0, 2, 0, /*
8921 Ensure that DEVICE's contents are correctly displayed. 8929 Ensure that DEVICE's contents are correctly displayed.
8922 This differs from `redraw-device' in that it only redraws what needs to 8930 This differs from `redraw-device' in that it only redraws what needs to
8942 redisplay_device (d, 0); 8950 redisplay_device (d, 0);
8943 8951
8944 /* See the comment in Fredisplay_frame. */ 8952 /* See the comment in Fredisplay_frame. */
8945 RESET_CHANGED_SET_FLAGS; 8953 RESET_CHANGED_SET_FLAGS;
8946 8954
8947 return unbind_to (count, Qnil); 8955 return unbind_to (count);
8948 } 8956 }
8949 8957
8950 /* Big lie. Big lie. This will force all modelines to be updated 8958 /* Big lie. Big lie. This will force all modelines to be updated
8951 regardless if the all flag is set or not. It remains in existence 8959 regardless if the all flag is set or not. It remains in existence
8952 solely for backwards compatibility. */ 8960 solely for backwards compatibility. */
9184 stderr_out ("XEmacs: standard input is not a tty\n"); 9192 stderr_out ("XEmacs: standard input is not a tty\n");
9185 exit (1); 9193 exit (1);
9186 } 9194 }
9187 9195
9188 /* Look at the TERM variable */ 9196 /* Look at the TERM variable */
9189 if (!getenv ("TERM")) 9197 if (!egetenv ("TERM"))
9190 { 9198 {
9191 stderr_out ("Please set the environment variable TERM; see tset(1).\n"); 9199 stderr_out ("Please set the environment variable TERM; see tset(1).\n");
9192 exit (1); 9200 exit (1);
9193 } 9201 }
9194 9202