comparison src/redisplay.c @ 259:11cf20601dec r20-5b28

Import from CVS: tag r20-5b28
author cvs
date Mon, 13 Aug 2007 10:23:02 +0200
parents 65c19d2020f7
children 8efd647ea9ca
comparison
equal deleted inserted replaced
258:58424f6abf56 259:11cf20601dec
55 #include "process.h" 55 #include "process.h"
56 #include "redisplay.h" 56 #include "redisplay.h"
57 #include "toolbar.h" 57 #include "toolbar.h"
58 #include "window.h" 58 #include "window.h"
59 #include "line-number.h" 59 #include "line-number.h"
60 60 #ifdef FILE_CODING
61 #ifdef MULE 61 #include "file-coding.h"
62 #include "mule-coding.h"
63 #endif 62 #endif
64 63
65 #ifdef HAVE_TTY 64 #ifdef HAVE_TTY
66 #include "console-tty.h" 65 #include "console-tty.h"
67 #endif 66 #endif
256 face_index findex, int min_pixpos, 255 face_index findex, int min_pixpos,
257 int max_pixpos, int type, 256 int max_pixpos, int type,
258 int modeline); 257 int modeline);
259 static Charcount generate_fstring_runes (struct window *w, pos_data *data, 258 static Charcount generate_fstring_runes (struct window *w, pos_data *data,
260 Charcount pos, Charcount min_pos, 259 Charcount pos, Charcount min_pos,
261 Charcount max_pos, Lisp_Object elt, 260 Charcount max_pos, int no_limit,
261 Lisp_Object elt,
262 int depth, int max_pixsize, 262 int depth, int max_pixsize,
263 face_index findex, int type); 263 face_index findex, int type);
264 static prop_block_dynarr *add_emchar_rune (pos_data *data); 264 static prop_block_dynarr *add_emchar_rune (pos_data *data);
265 static prop_block_dynarr *add_bufbyte_string_runes (pos_data *data, 265 static prop_block_dynarr *add_bufbyte_string_runes (pos_data *data,
266 Bufbyte *c_string, 266 Bufbyte *c_string,
3611 This recursively builds up the modeline or the title/icon string. 3611 This recursively builds up the modeline or the title/icon string.
3612 In case of a modeline, we use a negative start position to indicate 3612 In case of a modeline, we use a negative start position to indicate
3613 the current modeline horizontal scroll. */ 3613 the current modeline horizontal scroll. */
3614 generate_fstring_runes 3614 generate_fstring_runes
3615 (w, &data, 3615 (w, &data,
3616 (modeline && WINDOW_HAS_MODELINE_P (w)) ? - w->modeline_hscroll : 0, 3616 (modeline && WINDOW_HAS_MODELINE_P (w)) ? - w->modeline_hscroll : 0,
3617 0, -1, format_str, 0, max_pixpos - min_pixpos, findex, type); 3617 (modeline && WINDOW_HAS_MODELINE_P (w)) ? - w->modeline_hscroll : 0,
3618 0, /* no limit */ 1, format_str, 0, max_pixpos - min_pixpos, findex,
3619 type);
3618 3620
3619 if (Dynarr_length (db->runes)) 3621 if (Dynarr_length (db->runes))
3620 { 3622 {
3621 struct rune *rb = 3623 struct rune *rb =
3622 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1); 3624 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1);
3687 3689
3688 /* D. Verna Feb. 1998. Rewrote this function to handle the case of a 3690 /* D. Verna Feb. 1998. Rewrote this function to handle the case of a
3689 scrolled modeline */ 3691 scrolled modeline */
3690 static Charcount 3692 static Charcount
3691 add_string_to_fstring_db_runes (pos_data *data, CONST Bufbyte *str, 3693 add_string_to_fstring_db_runes (pos_data *data, CONST Bufbyte *str,
3692 Charcount pos, Charcount min_pos, Charcount max_pos) 3694 Charcount pos, Charcount min_pos,
3695 Charcount max_pos, int no_limit)
3693 { 3696 {
3694 /* This function has been Mule-ized. */ 3697 /* This function has been Mule-ized. */
3695 Charcount initial_pos = pos; 3698 Charcount initial_pos = pos;
3696 CONST Bufbyte *cur_pos = str; 3699 CONST Bufbyte *cur_pos = str;
3697 struct display_block *db = data->db; 3700 struct display_block *db = data->db;
3698 int add_something; 3701 int add_something;
3699 3702
3700 data->blank_width = space_width (XWINDOW (data->window)); 3703 data->blank_width = space_width (XWINDOW (data->window));
3701 add_something = ((pos < min_pos) 3704 add_something = ((pos < min_pos)
3702 || ((*cur_pos) && (max_pos == -1)) 3705 || ((*cur_pos) && no_limit)
3703 || ((*cur_pos) && (pos < max_pos))); 3706 || ((*cur_pos) && (pos < max_pos)));
3704 while (add_something) 3707 while (add_something)
3705 { 3708 {
3706 if (((initial_pos < 0) && (pos == 1)) || (pos == initial_pos)) 3709 if ((initial_pos >= 0) && (pos == initial_pos))
3707 while (Dynarr_length (db->runes) < pos) 3710 while (Dynarr_length (db->runes) < pos)
3708 add_blank_rune (data, NULL, 0); 3711 add_blank_rune (data, NULL, 0);
3709 3712
3710 if (pos < 0) /* just pretend we're adding something */ 3713 if (pos < 0) /* just pretend we're adding something */
3711 { 3714 {
3740 INC_CHARPTR (cur_pos); 3743 INC_CHARPTR (cur_pos);
3741 pos += 1; 3744 pos += 1;
3742 } 3745 }
3743 } 3746 }
3744 add_something = ((pos < min_pos) 3747 add_something = ((pos < min_pos)
3745 || ((*cur_pos) && (max_pos == -1)) 3748 || ((*cur_pos) && no_limit)
3746 || ((*cur_pos) && (pos < max_pos))); 3749 || ((*cur_pos) && (pos < max_pos)));
3747 } 3750 }
3748 3751
3749 return pos; 3752 return pos;
3750 } 3753 }
3751 3754
3752 /* #### Urk! Should also handle begin-glyphs and end-glyphs in 3755 /* #### Urk! Should also handle begin-glyphs and end-glyphs in
3753 modeline extents. */ 3756 modeline extents. */
3754 static Charcount 3757 static Charcount
3755 add_glyph_to_fstring_db_runes (pos_data *data, Lisp_Object glyph, 3758 add_glyph_to_fstring_db_runes (pos_data *data, Lisp_Object glyph,
3756 Charcount pos, Charcount min_pos, Charcount max_pos) 3759 Charcount pos, Charcount min_pos,
3760 Charcount max_pos, int no_limit)
3757 { 3761 {
3758 /* This function has been Mule-ized. */ 3762 /* This function has been Mule-ized. */
3759 Charcount end; 3763 Charcount end;
3760 struct display_block *db = data->db; 3764 struct display_block *db = data->db;
3761 struct glyph_block gb; 3765 struct glyph_block gb;
3769 data->blank_width = space_width (XWINDOW (data->window)); 3773 data->blank_width = space_width (XWINDOW (data->window));
3770 while (Dynarr_length (db->runes) < pos) 3774 while (Dynarr_length (db->runes) < pos)
3771 add_blank_rune (data, NULL, 0); 3775 add_blank_rune (data, NULL, 0);
3772 3776
3773 end = Dynarr_length (db->runes) + 1; 3777 end = Dynarr_length (db->runes) + 1;
3774 if (max_pos != -1) 3778 if (!no_limit)
3775 end = min (max_pos, end); 3779 end = min (max_pos, end);
3776 3780
3777 gb.glyph = glyph; 3781 gb.glyph = glyph;
3778 gb.extent = Qnil; 3782 gb.extent = Qnil;
3779 add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0); 3783 add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0);
3798 not in terms of columns. This is necessary to make the formatting 3802 not in terms of columns. This is necessary to make the formatting
3799 work correctly when proportional width fonts are used in the 3803 work correctly when proportional width fonts are used in the
3800 modeline. */ 3804 modeline. */
3801 static Charcount 3805 static Charcount
3802 generate_fstring_runes (struct window *w, pos_data *data, Charcount pos, 3806 generate_fstring_runes (struct window *w, pos_data *data, Charcount pos,
3803 Charcount min_pos, Charcount max_pos, 3807 Charcount min_pos, Charcount max_pos, int no_limit,
3804 Lisp_Object elt, int depth, int max_pixsize, 3808 Lisp_Object elt, int depth, int max_pixsize,
3805 face_index findex, int type) 3809 face_index findex, int type)
3806 { 3810 {
3807 /* This function has been Mule-ized. */ 3811 /* This function has been Mule-ized. */
3808 /* #### The other losing things in this function are: 3812 /* #### The other losing things in this function are:
3823 /* A string. Add to the display line and check for %-constructs 3827 /* A string. Add to the display line and check for %-constructs
3824 within it. */ 3828 within it. */
3825 3829
3826 Bufbyte *this = XSTRING_DATA (elt); 3830 Bufbyte *this = XSTRING_DATA (elt);
3827 3831
3828 while ((pos < max_pos || max_pos == -1) && *this) 3832 while ((no_limit || pos < max_pos) && *this)
3829 { 3833 {
3830 Bufbyte *last = this; 3834 Bufbyte *last = this;
3831 3835
3832 while (*this && *this != '%') 3836 while (*this && *this != '%')
3833 this++; 3837 this++;
3835 if (this != last) 3839 if (this != last)
3836 { 3840 {
3837 /* The string is just a string. */ 3841 /* The string is just a string. */
3838 Charcount size = 3842 Charcount size =
3839 bytecount_to_charcount (last, this - last) + pos; 3843 bytecount_to_charcount (last, this - last) + pos;
3840 Charcount tmp_max = (max_pos == -1 ? size : min (size, max_pos)); 3844 Charcount tmp_max = (no_limit ? size : min (size, max_pos));
3841 3845
3842 pos = add_string_to_fstring_db_runes (data, last, pos, pos, 3846 pos = add_string_to_fstring_db_runes (data, last, pos, pos,
3843 tmp_max); 3847 tmp_max, /* limit */0);
3844 } 3848 }
3845 else /* *this == '%' */ 3849 else /* *this == '%' */
3846 { 3850 {
3847 Charcount spec_width = 0; 3851 Charcount spec_width = 0;
3848 3852
3861 spec_width += pos; 3865 spec_width += pos;
3862 3866
3863 if (*this == 'M') 3867 if (*this == 'M')
3864 { 3868 {
3865 pos = generate_fstring_runes (w, data, pos, spec_width, 3869 pos = generate_fstring_runes (w, data, pos, spec_width,
3866 max_pos, Vglobal_mode_string, 3870 max_pos, no_limit,
3871 Vglobal_mode_string,
3867 depth, max_pixsize, findex, 3872 depth, max_pixsize, findex,
3868 type); 3873 type);
3869 } 3874 }
3870 else if (*this == '-') 3875 else if (*this == '-')
3871 { 3876 {
3872 Charcount num_to_add; 3877 Charcount num_to_add;
3873 3878
3874 if (max_pixsize < 0) 3879 if (max_pixsize < 0)
3875 num_to_add = 0; 3880 num_to_add = 0;
3876 else if (max_pos != -1) 3881 else if (! no_limit)
3877 num_to_add = max_pos - pos; 3882 num_to_add = max_pos - pos;
3878 else 3883 else
3879 { 3884 {
3880 int cur_pixsize; 3885 int cur_pixsize;
3881 int dash_pixsize; 3886 int dash_pixsize;
3890 num_to_add++; 3895 num_to_add++;
3891 } 3896 }
3892 3897
3893 while (num_to_add--) 3898 while (num_to_add--)
3894 pos = add_string_to_fstring_db_runes 3899 pos = add_string_to_fstring_db_runes
3895 (data, (CONST Bufbyte *) "-", pos, pos, max_pos); 3900 (data, (CONST Bufbyte *) "-",
3901 pos, pos, max_pos, no_limit);
3896 } 3902 }
3897 else if (*this != 0) 3903 else if (*this != 0)
3898 { 3904 {
3899 Bufbyte *str; 3905 Bufbyte *str;
3900 Emchar ch = charptr_emchar (this); 3906 Emchar ch = charptr_emchar (this);
3901 decode_mode_spec (w, ch, type); 3907 decode_mode_spec (w, ch, type);
3902 3908
3903 str = Dynarr_atp (mode_spec_bufbyte_string, 0); 3909 str = Dynarr_atp (mode_spec_bufbyte_string, 0);
3904 pos = add_string_to_fstring_db_runes (data,str, pos, pos, 3910 pos = add_string_to_fstring_db_runes (data,str, pos, pos,
3905 max_pos); 3911 max_pos, no_limit);
3906 } 3912 }
3907 3913
3908 /* NOT this++. There could be any sort of character at 3914 /* NOT this++. There could be any sort of character at
3909 the current position. */ 3915 the current position. */
3910 INC_CHARPTR (this); 3916 INC_CHARPTR (this);
3932 don't check for % within it. */ 3938 don't check for % within it. */
3933 if (STRINGP (tem)) 3939 if (STRINGP (tem))
3934 { 3940 {
3935 pos = 3941 pos =
3936 add_string_to_fstring_db_runes 3942 add_string_to_fstring_db_runes
3937 (data, XSTRING_DATA (tem), pos, min_pos, max_pos); 3943 (data, XSTRING_DATA (tem), pos, min_pos, max_pos, no_limit);
3938 } 3944 }
3939 /* Give up right away for nil or t. */ 3945 /* Give up right away for nil or t. */
3940 else if (!EQ (tem, elt)) 3946 else if (!EQ (tem, elt))
3941 { 3947 {
3942 elt = tem; 3948 elt = tem;
4002 /* Negative int means reduce maximum width. 4008 /* Negative int means reduce maximum width.
4003 * DO NOT change MIN_PIXPOS here! 4009 * DO NOT change MIN_PIXPOS here!
4004 * (20 -10 . foo) should truncate foo to 10 col 4010 * (20 -10 . foo) should truncate foo to 10 col
4005 * and then pad to 20. 4011 * and then pad to 20.
4006 */ 4012 */
4007 if (max_pos == -1) 4013 if (no_limit)
4008 max_pos = pos - lim; 4014 max_pos = pos - lim;
4009 else 4015 else
4010 max_pos = min (max_pos, pos - lim); 4016 max_pos = min (max_pos, pos - lim);
4011 } 4017 }
4012 else if (lim > 0) 4018 else if (lim > 0)
4013 { 4019 {
4014 /* Padding specified. Don't let it be more than 4020 /* Padding specified. Don't let it be more than
4015 * current maximum. 4021 * current maximum.
4016 */ 4022 */
4017 lim += pos; 4023 lim += pos;
4018 if (max_pos != -1 && lim > max_pos) 4024 if (!no_limit && lim > max_pos)
4019 lim = max_pos; 4025 lim = max_pos;
4020 /* If that's more padding than already wanted, queue it. 4026 /* If that's more padding than already wanted, queue it.
4021 * But don't reduce padding already specified even if 4027 * But don't reduce padding already specified even if
4022 * that is beyond the current truncation point. 4028 * that is beyond the current truncation point.
4023 */ 4029 */
4024 if (lim > min_pos) 4030 if (lim > min_pos)
4025 min_pos = lim; 4031 min_pos = lim;
4026 } 4032 }
4033 no_limit = 0;
4027 goto tail_recurse; 4034 goto tail_recurse;
4028 } 4035 }
4029 else if (STRINGP (car) || CONSP (car)) 4036 else if (STRINGP (car) || CONSP (car))
4030 { 4037 {
4031 int limit = 50; 4038 int limit = 50;
4032 /* LIMIT is to protect against circular lists. */ 4039 /* LIMIT is to protect against circular lists. */
4033 while (CONSP (elt) && --limit > 0 4040 while (CONSP (elt) && --limit > 0 && (no_limit || pos < max_pos))
4034 && (pos < max_pos || max_pos == -1))
4035 { 4041 {
4036 pos = generate_fstring_runes (w, data, pos, pos, max_pos, 4042 pos = generate_fstring_runes (w, data, pos, pos, max_pos,
4043 no_limit,
4037 XCAR (elt), depth, 4044 XCAR (elt), depth,
4038 max_pixsize, findex, type); 4045 max_pixsize, findex, type);
4039 elt = XCDR (elt); 4046 elt = XCDR (elt);
4040 } 4047 }
4041 } 4048 }
4070 } 4077 }
4071 else 4078 else
4072 new_findex = old_findex; 4079 new_findex = old_findex;
4073 4080
4074 data->findex = new_findex; 4081 data->findex = new_findex;
4075 pos = generate_fstring_runes (w, data, pos, pos, max_pos, 4082 pos = generate_fstring_runes (w, data, pos, pos, max_pos,
4083 no_limit,
4076 XCDR (elt), depth - 1, 4084 XCDR (elt), depth - 1,
4077 max_pixsize, new_findex, type); 4085 max_pixsize, new_findex, type);
4078 data->findex = old_findex; 4086 data->findex = old_findex;
4079 Dynarr_add (formatted_string_extent_dynarr, ext); 4087 Dynarr_add (formatted_string_extent_dynarr, ext);
4080 Dynarr_add (formatted_string_extent_start_dynarr, start); 4088 Dynarr_add (formatted_string_extent_start_dynarr, start);
4082 } 4090 }
4083 } 4091 }
4084 } 4092 }
4085 else if (GLYPHP (elt)) 4093 else if (GLYPHP (elt))
4086 { 4094 {
4087 pos = add_glyph_to_fstring_db_runes (data, elt, pos, pos, max_pos); 4095 pos = add_glyph_to_fstring_db_runes
4096 (data, elt, pos, pos, max_pos, no_limit);
4088 } 4097 }
4089 else 4098 else
4090 { 4099 {
4091 invalid: 4100 invalid:
4092 pos = 4101 pos =
4093 add_string_to_fstring_db_runes 4102 add_string_to_fstring_db_runes
4094 (data, (CONST Bufbyte *) GETTEXT ("*invalid*"), pos, min_pos, 4103 (data, (CONST Bufbyte *) GETTEXT ("*invalid*"), pos, min_pos, max_pos,
4095 max_pos); 4104 no_limit);
4096 } 4105 }
4097 4106
4098 if (min_pos > pos) 4107 if (min_pos > pos)
4099 { 4108 {
4100 add_string_to_fstring_db_runes (data, (CONST Bufbyte *) "", pos, min_pos, 4109 add_string_to_fstring_db_runes (data, (CONST Bufbyte *) "", pos, min_pos,
4101 -1); 4110 0, /* no limit */ 1);
4102 } 4111 }
4103 4112
4104 return pos; 4113 return pos;
4105 } 4114 }
4106 4115
5806 Dynarr_add_many (mode_spec_bufbyte_string, 5815 Dynarr_add_many (mode_spec_bufbyte_string,
5807 (CONST Bufbyte *) buf, strlen (buf)); 5816 (CONST Bufbyte *) buf, strlen (buf));
5808 5817
5809 goto decode_mode_spec_done; 5818 goto decode_mode_spec_done;
5810 } 5819 }
5811 5820 #ifdef FILE_CODING
5812 #ifdef MULE
5813 /* print the file coding system */ 5821 /* print the file coding system */
5814 case 'C': 5822 case 'C':
5815 { 5823 {
5816 Lisp_Object codesys = b->buffer_file_coding_system; 5824 Lisp_Object codesys = b->buffer_file_coding_system;
5817 /* Be very careful here not to get an error. */ 5825 /* Be very careful here not to get an error. */
5821 if (CODING_SYSTEMP (codesys)) 5829 if (CODING_SYSTEMP (codesys))
5822 obj = Fcoding_system_property (codesys, Qmnemonic); 5830 obj = Fcoding_system_property (codesys, Qmnemonic);
5823 } 5831 }
5824 } 5832 }
5825 break; 5833 break;
5826 #endif /* MULE */ 5834 #endif
5827 5835
5828 /* print the current line number */ 5836 /* print the current line number */
5829 case 'l': 5837 case 'l':
5830 str = window_line_number (w, type); 5838 str = window_line_number (w, type);
5831 break; 5839 break;