comparison src/redisplay.c @ 257:65c19d2020f7 r20-5b27

Import from CVS: tag r20-5b27
author cvs
date Mon, 13 Aug 2007 10:22:03 +0200
parents 677f6a0ee643
children 11cf20601dec
comparison
equal deleted inserted replaced
256:19076a51efde 257:65c19d2020f7
252 Lisp_Object result_str, 252 Lisp_Object result_str,
253 struct window *w, 253 struct window *w,
254 struct display_line *dl, 254 struct display_line *dl,
255 struct display_block *db, 255 struct display_block *db,
256 face_index findex, int min_pixpos, 256 face_index findex, int min_pixpos,
257 int max_pixpos, int type); 257 int max_pixpos, int type,
258 int modeline);
258 static Charcount generate_fstring_runes (struct window *w, pos_data *data, 259 static Charcount generate_fstring_runes (struct window *w, pos_data *data,
259 Charcount pos, Charcount min_pos, 260 Charcount pos, Charcount min_pos,
260 Charcount max_pos, Lisp_Object elt, 261 Charcount max_pos, Lisp_Object elt,
261 int depth, int max_pixsize, 262 int depth, int max_pixsize,
262 face_index findex, int type); 263 face_index findex, int type);
3564 else 3565 else
3565 ypos_adj = 0; 3566 ypos_adj = 0;
3566 3567
3567 generate_formatted_string_db (b->modeline_format, 3568 generate_formatted_string_db (b->modeline_format,
3568 b->generated_modeline_string, w, dl, db, 3569 b->generated_modeline_string, w, dl, db,
3569 MODELINE_INDEX, min_pixpos, max_pixpos, type); 3570 MODELINE_INDEX, min_pixpos, max_pixpos, type,
3570 3571 1 /* generate a modeline */);
3572
3571 /* The modeline is at the bottom of the gutters. We have to wait to 3573 /* The modeline is at the bottom of the gutters. We have to wait to
3572 set this until we've generated teh modeline in order to account 3574 set this until we've generated teh modeline in order to account
3573 for any embedded faces. */ 3575 for any embedded faces. */
3574 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj; 3576 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj;
3575 } 3577 }
3576 3578
3577 static void 3579 static void
3578 generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str, 3580 generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str,
3579 struct window *w, struct display_line *dl, 3581 struct window *w, struct display_line *dl,
3580 struct display_block *db, face_index findex, 3582 struct display_block *db, face_index findex,
3581 int min_pixpos, int max_pixpos, int type) 3583 int min_pixpos, int max_pixpos, int type,
3584 int modeline)
3582 { 3585 {
3583 struct frame *f = XFRAME (w->frame); 3586 struct frame *f = XFRAME (w->frame);
3584 struct device *d = XDEVICE (f->device); 3587 struct device *d = XDEVICE (f->device);
3585 3588
3586 pos_data data; 3589 pos_data data;
3602 3605
3603 Dynarr_reset (formatted_string_extent_dynarr); 3606 Dynarr_reset (formatted_string_extent_dynarr);
3604 Dynarr_reset (formatted_string_extent_start_dynarr); 3607 Dynarr_reset (formatted_string_extent_start_dynarr);
3605 Dynarr_reset (formatted_string_extent_end_dynarr); 3608 Dynarr_reset (formatted_string_extent_end_dynarr);
3606 3609
3607 /* This recursively builds up the modeline. */ 3610 /* D. Verna Feb. 1998.
3608 generate_fstring_runes (w, &data, 0, 0, -1, format_str, 0, 3611 This recursively builds up the modeline or the title/icon string.
3609 max_pixpos - min_pixpos, findex, type); 3612 In case of a modeline, we use a negative start position to indicate
3610 3613 the current modeline horizontal scroll. */
3614 generate_fstring_runes
3615 (w, &data,
3616 (modeline && WINDOW_HAS_MODELINE_P (w)) ? - w->modeline_hscroll : 0,
3617 0, -1, format_str, 0, max_pixpos - min_pixpos, findex, type);
3618
3611 if (Dynarr_length (db->runes)) 3619 if (Dynarr_length (db->runes))
3612 { 3620 {
3613 struct rune *rb = 3621 struct rune *rb =
3614 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1); 3622 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1);
3615 c_pixpos = rb->xpos + rb->width; 3623 c_pixpos = rb->xpos + rb->width;
3675 result_str); 3683 result_str);
3676 } 3684 }
3677 } 3685 }
3678 } 3686 }
3679 3687
3688 /* D. Verna Feb. 1998. Rewrote this function to handle the case of a
3689 scrolled modeline */
3680 static Charcount 3690 static Charcount
3681 add_string_to_fstring_db_runes (pos_data *data, CONST Bufbyte *str, 3691 add_string_to_fstring_db_runes (pos_data *data, CONST Bufbyte *str,
3682 Charcount pos, Charcount min_pos, Charcount max_pos) 3692 Charcount pos, Charcount min_pos, Charcount max_pos)
3683 { 3693 {
3684 /* This function has been Mule-ized. */ 3694 /* This function has been Mule-ized. */
3685 Charcount end; 3695 Charcount initial_pos = pos;
3686 CONST Bufbyte *cur_pos = str; 3696 CONST Bufbyte *cur_pos = str;
3687 struct display_block *db = data->db; 3697 struct display_block *db = data->db;
3688 3698 int add_something;
3699
3689 data->blank_width = space_width (XWINDOW (data->window)); 3700 data->blank_width = space_width (XWINDOW (data->window));
3690 while (Dynarr_length (db->runes) < pos) 3701 add_something = ((pos < min_pos)
3691 add_blank_rune (data, NULL, 0); 3702 || ((*cur_pos) && (max_pos == -1))
3692 3703 || ((*cur_pos) && (pos < max_pos)));
3693 end = (Dynarr_length (db->runes) + 3704 while (add_something)
3694 bytecount_to_charcount (str, strlen ((CONST char *) str))); 3705 {
3695 if (max_pos != -1) 3706 if (((initial_pos < 0) && (pos == 1)) || (pos == initial_pos))
3696 end = min (max_pos, end); 3707 while (Dynarr_length (db->runes) < pos)
3697 3708 add_blank_rune (data, NULL, 0);
3698 while (pos < end && *cur_pos) 3709
3699 { 3710 if (pos < 0) /* just pretend we're adding something */
3700 CONST Bufbyte *old_cur_pos = cur_pos; 3711 {
3701 int succeeded; 3712 if (*cur_pos)
3702 3713 INC_CHARPTR (cur_pos);
3703 data->ch = charptr_emchar (cur_pos); 3714 pos += 1;
3704 succeeded = (add_emchar_rune (data) != ADD_FAILED); 3715 }
3705 INC_CHARPTR (cur_pos); 3716 else /* Maybe add something */
3706 if (succeeded) 3717 {
3707 { 3718 if (*cur_pos)
3708 pos++; 3719 {
3709 data->modeline_charpos++; 3720 CONST Bufbyte *old_cur_pos = cur_pos;
3710 data->bytepos += cur_pos - old_cur_pos; 3721 int succeeded;
3711 } 3722
3712 } 3723 data->ch = charptr_emchar (cur_pos);
3713 3724 succeeded = (add_emchar_rune (data) != ADD_FAILED);
3714 while (Dynarr_length (db->runes) < min_pos && 3725 INC_CHARPTR (cur_pos);
3715 (data->pixpos + data->blank_width <= data->max_pixpos)) 3726 if (succeeded)
3716 add_blank_rune (data, NULL, 0); 3727 {
3717 3728 pos += 1;
3718 return Dynarr_length (db->runes); 3729 data->modeline_charpos++;
3730 data->bytepos += cur_pos - old_cur_pos;
3731 }
3732 }
3733 else if (data->pixpos + data->blank_width <= data->max_pixpos)
3734 {
3735 add_blank_rune (data, NULL, 0);
3736 }
3737 else /* pretend to add something */
3738 {
3739 if (*cur_pos)
3740 INC_CHARPTR (cur_pos);
3741 pos += 1;
3742 }
3743 }
3744 add_something = ((pos < min_pos)
3745 || ((*cur_pos) && (max_pos == -1))
3746 || ((*cur_pos) && (pos < max_pos)));
3747 }
3748
3749 return pos;
3719 } 3750 }
3720 3751
3721 /* #### Urk! Should also handle begin-glyphs and end-glyphs in 3752 /* #### Urk! Should also handle begin-glyphs and end-glyphs in
3722 modeline extents. */ 3753 modeline extents. */
3723 static Charcount 3754 static Charcount
3727 /* This function has been Mule-ized. */ 3758 /* This function has been Mule-ized. */
3728 Charcount end; 3759 Charcount end;
3729 struct display_block *db = data->db; 3760 struct display_block *db = data->db;
3730 struct glyph_block gb; 3761 struct glyph_block gb;
3731 3762
3763 /* D. Verna Feb. 1998.
3764 If pos < 0, we're building a scrolled modeline.
3765 The glyph should be hidden. So just skip it. */
3766 if (pos < 0)
3767 return (pos + 1);
3768
3732 data->blank_width = space_width (XWINDOW (data->window)); 3769 data->blank_width = space_width (XWINDOW (data->window));
3733 while (Dynarr_length (db->runes) < pos) 3770 while (Dynarr_length (db->runes) < pos)
3734 add_blank_rune (data, NULL, 0); 3771 add_blank_rune (data, NULL, 0);
3735 3772
3736 end = Dynarr_length (db->runes) + 1; 3773 end = Dynarr_length (db->runes) + 1;
3737 if (max_pos != -1) 3774 if (max_pos != -1)
3738 end = min (max_pos, end); 3775 end = min (max_pos, end);
3739 3776
3740 gb.glyph = glyph; 3777 gb.glyph = glyph;
3741 gb.extent = Qnil; 3778 gb.extent = Qnil;
3742 add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0); 3779 add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0);
3743 pos++; 3780 pos++;
3744 3781
3783 3820
3784 if (STRINGP (elt)) 3821 if (STRINGP (elt))
3785 { 3822 {
3786 /* A string. Add to the display line and check for %-constructs 3823 /* A string. Add to the display line and check for %-constructs
3787 within it. */ 3824 within it. */
3788 3825
3789 Bufbyte *this = XSTRING_DATA (elt); 3826 Bufbyte *this = XSTRING_DATA (elt);
3790 3827
3791 while ((pos < max_pos || max_pos == -1) && *this) 3828 while ((pos < max_pos || max_pos == -1) && *this)
3792 { 3829 {
3793 Bufbyte *last = this; 3830 Bufbyte *last = this;
3794 3831
3795 while (*this && *this != '%') 3832 while (*this && *this != '%')
3796 this++; 3833 this++;
3797 3834
3798 if (this != last) 3835 if (this != last)
3799 { 3836 {
3800 /* The string is just a string. */ 3837 /* The string is just a string. */
3801 Charcount size = 3838 Charcount size =
3802 bytecount_to_charcount (last, this - last) + pos; 3839 bytecount_to_charcount (last, this - last) + pos;
3803 Charcount tmp_max = (max_pos == -1 ? size : min (size, max_pos)); 3840 Charcount tmp_max = (max_pos == -1 ? size : min (size, max_pos));
3804 3841
3805 pos = add_string_to_fstring_db_runes (data, last, pos, pos, 3842 pos = add_string_to_fstring_db_runes (data, last, pos, pos,
3806 tmp_max); 3843 tmp_max);
3807 } 3844 }
3808 else /* *this == '%' */ 3845 else /* *this == '%' */
3809 { 3846 {
4078 4115
4079 dl = &formatted_string_display_line; 4116 dl = &formatted_string_display_line;
4080 db = get_display_block_from_line (dl, TEXT); 4117 db = get_display_block_from_line (dl, TEXT);
4081 Dynarr_reset (db->runes); 4118 Dynarr_reset (db->runes);
4082 4119
4120 /* D. Verna Feb. 1998.
4121 Currently, only update_frame_title can make us come here. This is not
4122 to build a modeline */
4083 generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0, 4123 generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0,
4084 -1, type); 4124 -1, type, 0 /* not a modeline */);
4085 4125
4086 Dynarr_reset (formatted_string_emchar_dynarr); 4126 Dynarr_reset (formatted_string_emchar_dynarr);
4087 while (elt < Dynarr_length (db->runes)) 4127 while (elt < Dynarr_length (db->runes))
4088 { 4128 {
4089 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) 4129 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR)