Mercurial > hg > xemacs-beta
comparison src/redisplay.c @ 284:558f606b08ae r21-0b40
Import from CVS: tag r21-0b40
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:34:13 +0200 |
parents | c42ec1d1cded |
children | 4b85ae5eabfb |
comparison
equal
deleted
inserted
replaced
283:fa3d41851a08 | 284:558f606b08ae |
---|---|
241 Lisp_Object result_str, | 241 Lisp_Object result_str, |
242 struct window *w, | 242 struct window *w, |
243 struct display_line *dl, | 243 struct display_line *dl, |
244 struct display_block *db, | 244 struct display_block *db, |
245 face_index findex, int min_pixpos, | 245 face_index findex, int min_pixpos, |
246 int max_pixpos, int type | 246 int max_pixpos, int type); |
247 #ifdef MODELINE_IS_SCROLLABLE | |
248 ,int modeline | |
249 #endif | |
250 ); | |
251 static Charcount generate_fstring_runes (struct window *w, pos_data *data, | 247 static Charcount generate_fstring_runes (struct window *w, pos_data *data, |
252 Charcount pos, Charcount min_pos, | 248 Charcount pos, Charcount min_pos, |
253 Charcount max_pos, | 249 Charcount max_pos, Lisp_Object elt, |
254 #ifdef MODELINE_IS_SCROLLABLE | |
255 int no_limit, | |
256 #endif | |
257 Lisp_Object elt, | |
258 int depth, int max_pixsize, | 250 int depth, int max_pixsize, |
259 face_index findex, int type); | 251 face_index findex, int type); |
260 static prop_block_dynarr *add_glyph_rune (pos_data *data, | 252 static prop_block_dynarr *add_glyph_rune (pos_data *data, |
261 struct glyph_block *gb, | 253 struct glyph_block *gb, |
262 int pos_type, int allow_cursor, | 254 int pos_type, int allow_cursor, |
3527 else | 3519 else |
3528 ypos_adj = 0; | 3520 ypos_adj = 0; |
3529 | 3521 |
3530 generate_formatted_string_db (b->modeline_format, | 3522 generate_formatted_string_db (b->modeline_format, |
3531 b->generated_modeline_string, w, dl, db, | 3523 b->generated_modeline_string, w, dl, db, |
3532 MODELINE_INDEX, min_pixpos, max_pixpos, type | 3524 MODELINE_INDEX, min_pixpos, max_pixpos, type); |
3533 #ifdef MODELINE_IS_SCROLLABLE | |
3534 , 1 /* generate a modeline */ | |
3535 #endif /* not MODELINE_IS_SCROLLABLE */ | |
3536 ); | |
3537 | 3525 |
3538 /* The modeline is at the bottom of the gutters. We have to wait to | 3526 /* The modeline is at the bottom of the gutters. We have to wait to |
3539 set this until we've generated teh modeline in order to account | 3527 set this until we've generated teh modeline in order to account |
3540 for any embedded faces. */ | 3528 for any embedded faces. */ |
3541 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj; | 3529 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj; |
3542 } | 3530 } |
3543 | 3531 |
3544 /* This define is for the experimental horizontal modeline scrolling. It's not | |
3545 functional for 21.0, but might be for 21.1 */ | |
3546 #ifdef MODELINE_IS_SCROLLABLE | |
3547 static void | |
3548 generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str, | |
3549 struct window *w, struct display_line *dl, | |
3550 struct display_block *db, face_index findex, | |
3551 int min_pixpos, int max_pixpos, int type, | |
3552 int modeline) | |
3553 { | |
3554 struct frame *f = XFRAME (w->frame); | |
3555 struct device *d = XDEVICE (f->device); | |
3556 | |
3557 pos_data data; | |
3558 int c_pixpos; | |
3559 | |
3560 xzero (data); | |
3561 data.d = d; | |
3562 data.db = db; | |
3563 data.dl = dl; | |
3564 data.findex = findex; | |
3565 data.pixpos = min_pixpos; | |
3566 data.max_pixpos = max_pixpos; | |
3567 data.cursor_type = NO_CURSOR; | |
3568 data.last_charset = Qunbound; | |
3569 data.last_findex = DEFAULT_INDEX; | |
3570 data.result_str = result_str; | |
3571 data.is_modeline = 1; | |
3572 XSETWINDOW (data.window, w); | |
3573 | |
3574 Dynarr_reset (formatted_string_extent_dynarr); | |
3575 Dynarr_reset (formatted_string_extent_start_dynarr); | |
3576 Dynarr_reset (formatted_string_extent_end_dynarr); | |
3577 | |
3578 /* D. Verna Feb. 1998. | |
3579 This recursively builds up the modeline or the title/icon string. | |
3580 In case of a modeline, we use a negative start position to indicate | |
3581 the current modeline horizontal scroll. */ | |
3582 generate_fstring_runes | |
3583 (w, &data, | |
3584 (modeline && WINDOW_HAS_MODELINE_P (w)) ? - w->modeline_hscroll : 0, | |
3585 (modeline && WINDOW_HAS_MODELINE_P (w)) ? - w->modeline_hscroll : 0, | |
3586 0, /* no limit */ 1, format_str, 0, max_pixpos - min_pixpos, findex, | |
3587 type); | |
3588 | |
3589 if (Dynarr_length (db->runes)) | |
3590 { | |
3591 struct rune *rb = | |
3592 Dynarr_atp (db->runes, Dynarr_length (db->runes) - 1); | |
3593 c_pixpos = rb->xpos + rb->width; | |
3594 } | |
3595 else | |
3596 c_pixpos = min_pixpos; | |
3597 | |
3598 /* If we don't reach the right side of the window, add a blank rune | |
3599 to make up the difference. This usually only occurs if the | |
3600 modeline face is using a proportional width font or a fixed width | |
3601 font of a different size from the default face font. */ | |
3602 | |
3603 if (c_pixpos < max_pixpos) | |
3604 { | |
3605 data.pixpos = c_pixpos; | |
3606 data.blank_width = max_pixpos - data.pixpos; | |
3607 | |
3608 add_blank_rune (&data, NULL, 0); | |
3609 } | |
3610 | |
3611 /* Now create the result string and frob the extents into it. */ | |
3612 if (!NILP (result_str)) | |
3613 { | |
3614 int elt; | |
3615 Bytecount len; | |
3616 Bufbyte *strdata; | |
3617 struct buffer *buf = XBUFFER (WINDOW_BUFFER (w)); | |
3618 | |
3619 detach_all_extents (result_str); | |
3620 resize_string (XSTRING (result_str), -1, | |
3621 data.bytepos - XSTRING_LENGTH (result_str)); | |
3622 | |
3623 strdata = XSTRING_DATA (result_str); | |
3624 | |
3625 for (elt = 0, len = 0; elt < Dynarr_length (db->runes); elt++) | |
3626 { | |
3627 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) | |
3628 { | |
3629 len += (set_charptr_emchar | |
3630 (strdata + len, Dynarr_atp (db->runes, | |
3631 elt)->object.chr.ch)); | |
3632 } | |
3633 } | |
3634 | |
3635 for (elt = 0; elt < Dynarr_length (formatted_string_extent_dynarr); | |
3636 elt++) | |
3637 { | |
3638 Lisp_Object extent; | |
3639 Lisp_Object child; | |
3640 | |
3641 XSETEXTENT (extent, Dynarr_at (formatted_string_extent_dynarr, elt)); | |
3642 child = Fgethash (extent, buf->modeline_extent_table, Qnil); | |
3643 if (NILP (child)) | |
3644 { | |
3645 child = Fmake_extent (Qnil, Qnil, result_str); | |
3646 Fputhash (extent, child, buf->modeline_extent_table); | |
3647 } | |
3648 Fset_extent_parent (child, extent); | |
3649 set_extent_endpoints | |
3650 (XEXTENT (child), | |
3651 Dynarr_at (formatted_string_extent_start_dynarr, elt), | |
3652 Dynarr_at (formatted_string_extent_end_dynarr, elt), | |
3653 result_str); | |
3654 } | |
3655 } | |
3656 } | |
3657 | |
3658 /* D. Verna Feb. 1998. Rewrote this function to handle the case of a | |
3659 scrolled modeline */ | |
3660 static Charcount | |
3661 add_string_to_fstring_db_runes (pos_data *data, CONST Bufbyte *str, | |
3662 Charcount pos, Charcount min_pos, | |
3663 Charcount max_pos, int no_limit) | |
3664 { | |
3665 /* This function has been Mule-ized. */ | |
3666 Charcount initial_pos = pos; | |
3667 CONST Bufbyte *cur_pos = str; | |
3668 struct display_block *db = data->db; | |
3669 int add_something; | |
3670 | |
3671 data->blank_width = space_width (XWINDOW (data->window)); | |
3672 add_something = ((pos < min_pos) | |
3673 || ((*cur_pos) && no_limit) | |
3674 || ((*cur_pos) && (pos < max_pos))); | |
3675 while (add_something) | |
3676 { | |
3677 if ((initial_pos >= 0) && (pos == initial_pos)) | |
3678 while (Dynarr_length (db->runes) < pos) | |
3679 add_blank_rune (data, NULL, 0); | |
3680 | |
3681 if (pos < 0) /* just pretend we're adding something */ | |
3682 { | |
3683 if (*cur_pos) | |
3684 INC_CHARPTR (cur_pos); | |
3685 pos += 1; | |
3686 } | |
3687 else /* pos > 0, things will be visible */ | |
3688 { | |
3689 if (*cur_pos) /* some stuff to add */ | |
3690 { | |
3691 CONST Bufbyte *old_cur_pos = cur_pos; | |
3692 int succeeded; | |
3693 | |
3694 data->ch = charptr_emchar (cur_pos); | |
3695 succeeded = (add_emchar_rune (data) != ADD_FAILED); | |
3696 INC_CHARPTR (cur_pos); | |
3697 if (succeeded) | |
3698 { | |
3699 pos += 1; | |
3700 data->modeline_charpos++; | |
3701 data->bytepos += cur_pos - old_cur_pos; | |
3702 } | |
3703 } | |
3704 /* no characters to add */ | |
3705 /* If there 's room enough, add space */ | |
3706 else if (data->pixpos + data->blank_width <= data->max_pixpos) | |
3707 { | |
3708 add_blank_rune (data, NULL, 0); | |
3709 pos += 1; | |
3710 } | |
3711 /* otherwise, just pretend we added something */ | |
3712 else | |
3713 { | |
3714 if (*cur_pos) | |
3715 INC_CHARPTR (cur_pos); | |
3716 pos += 1; | |
3717 } | |
3718 } | |
3719 add_something = ((pos < min_pos) | |
3720 || ((*cur_pos) && no_limit) | |
3721 || ((*cur_pos) && (pos < max_pos))); | |
3722 } | |
3723 | |
3724 return pos; | |
3725 } | |
3726 | |
3727 /* #### Urk! Should also handle begin-glyphs and end-glyphs in | |
3728 modeline extents. */ | |
3729 static Charcount | |
3730 add_glyph_to_fstring_db_runes (pos_data *data, Lisp_Object glyph, | |
3731 Charcount pos, Charcount min_pos, | |
3732 Charcount max_pos, int no_limit) | |
3733 { | |
3734 /* This function has been Mule-ized. */ | |
3735 Charcount end; | |
3736 struct display_block *db = data->db; | |
3737 struct glyph_block gb; | |
3738 | |
3739 /* D. Verna Feb. 1998. | |
3740 If pos < 0, we're building a scrolled modeline. | |
3741 The glyph should be hidden. So just skip it. */ | |
3742 if (pos < 0) | |
3743 return (pos + 1); | |
3744 | |
3745 data->blank_width = space_width (XWINDOW (data->window)); | |
3746 while (Dynarr_length (db->runes) < pos) | |
3747 add_blank_rune (data, NULL, 0); | |
3748 | |
3749 end = Dynarr_length (db->runes) + 1; | |
3750 if (!no_limit) | |
3751 end = min (max_pos, end); | |
3752 | |
3753 gb.glyph = glyph; | |
3754 gb.extent = Qnil; | |
3755 add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0); | |
3756 pos++; | |
3757 | |
3758 while (Dynarr_length (db->runes) < pos && | |
3759 (data->pixpos + data->blank_width <= data->max_pixpos)) | |
3760 add_blank_rune (data, NULL, 0); | |
3761 | |
3762 return Dynarr_length (db->runes); | |
3763 } | |
3764 | |
3765 /* If max_pos is == -1, it is considered to be infinite. The same is | |
3766 true of max_pixsize. */ | |
3767 #define SET_CURRENT_MODE_CHARS_PIXSIZE \ | |
3768 if (Dynarr_length (data->db->runes)) \ | |
3769 cur_pixsize = data->pixpos - Dynarr_atp (data->db->runes, 0)->xpos; \ | |
3770 else \ | |
3771 cur_pixsize = 0; | |
3772 | |
3773 /* Note that this function does "positions" in terms of characters and | |
3774 not in terms of columns. This is necessary to make the formatting | |
3775 work correctly when proportional width fonts are used in the | |
3776 modeline. */ | |
3777 static Charcount | |
3778 generate_fstring_runes (struct window *w, pos_data *data, Charcount pos, | |
3779 Charcount min_pos, Charcount max_pos, int no_limit, | |
3780 Lisp_Object elt, int depth, int max_pixsize, | |
3781 face_index findex, int type) | |
3782 { | |
3783 /* This function has been Mule-ized. */ | |
3784 /* #### The other losing things in this function are: | |
3785 | |
3786 -- C zero-terminated-string lossage. | |
3787 -- Non-printable characters should be converted into something | |
3788 appropriate (e.g. ^F) instead of blindly being printed anyway. | |
3789 */ | |
3790 | |
3791 tail_recurse: | |
3792 if (depth > 10) | |
3793 goto invalid; | |
3794 | |
3795 depth++; | |
3796 | |
3797 if (STRINGP (elt)) | |
3798 { | |
3799 /* A string. Add to the display line and check for %-constructs | |
3800 within it. */ | |
3801 | |
3802 Bufbyte *this = XSTRING_DATA (elt); | |
3803 | |
3804 while ((no_limit || pos < max_pos) && *this) | |
3805 { | |
3806 Bufbyte *last = this; | |
3807 | |
3808 while (*this && *this != '%') | |
3809 this++; | |
3810 | |
3811 if (this != last) | |
3812 { | |
3813 /* The string is just a string. */ | |
3814 Charcount size = | |
3815 bytecount_to_charcount (last, this - last) + pos; | |
3816 Charcount tmp_max = (no_limit ? size : min (size, max_pos)); | |
3817 | |
3818 pos = add_string_to_fstring_db_runes (data, last, pos, pos, | |
3819 tmp_max, /* limit */0); | |
3820 } | |
3821 else /* *this == '%' */ | |
3822 { | |
3823 Charcount spec_width = 0; | |
3824 | |
3825 this++; /* skip over '%' */ | |
3826 | |
3827 /* We can't allow -ve args due to the "%-" construct. | |
3828 * Argument specifies minwidth but not maxwidth | |
3829 * (maxwidth can be specified by | |
3830 * (<negative-number> . <stuff>) modeline elements) | |
3831 */ | |
3832 while (isdigit (*this)) | |
3833 { | |
3834 spec_width = spec_width * 10 + (*this - '0'); | |
3835 this++; | |
3836 } | |
3837 spec_width += pos; | |
3838 | |
3839 if (*this == 'M') | |
3840 { | |
3841 pos = generate_fstring_runes (w, data, pos, spec_width, | |
3842 max_pos, no_limit, | |
3843 Vglobal_mode_string, | |
3844 depth, max_pixsize, findex, | |
3845 type); | |
3846 } | |
3847 else if (*this == '-') | |
3848 { | |
3849 Charcount num_to_add; | |
3850 | |
3851 if (max_pixsize < 0) | |
3852 num_to_add = 0; | |
3853 else if (! no_limit) | |
3854 num_to_add = max_pos - pos; | |
3855 else | |
3856 { | |
3857 int cur_pixsize; | |
3858 int dash_pixsize; | |
3859 Bufbyte ch = '-'; | |
3860 SET_CURRENT_MODE_CHARS_PIXSIZE; | |
3861 | |
3862 dash_pixsize = | |
3863 redisplay_text_width_string (w, findex, &ch, Qnil, 0, | |
3864 1); | |
3865 | |
3866 num_to_add = (max_pixsize - cur_pixsize) / dash_pixsize; | |
3867 num_to_add++; | |
3868 } | |
3869 | |
3870 while (num_to_add--) | |
3871 pos = add_string_to_fstring_db_runes | |
3872 (data, (CONST Bufbyte *) "-", | |
3873 pos, pos, max_pos, no_limit); | |
3874 } | |
3875 else if (*this != 0) | |
3876 { | |
3877 Bufbyte *str; | |
3878 Emchar ch = charptr_emchar (this); | |
3879 decode_mode_spec (w, ch, type); | |
3880 | |
3881 str = Dynarr_atp (mode_spec_bufbyte_string, 0); | |
3882 pos = add_string_to_fstring_db_runes (data,str, pos, pos, | |
3883 max_pos, no_limit); | |
3884 } | |
3885 | |
3886 /* NOT this++. There could be any sort of character at | |
3887 the current position. */ | |
3888 INC_CHARPTR (this); | |
3889 } | |
3890 | |
3891 if (max_pixsize > 0) | |
3892 { | |
3893 int cur_pixsize; | |
3894 SET_CURRENT_MODE_CHARS_PIXSIZE; | |
3895 | |
3896 if (cur_pixsize >= max_pixsize) | |
3897 break; | |
3898 } | |
3899 } | |
3900 } | |
3901 else if (SYMBOLP (elt)) | |
3902 { | |
3903 /* A symbol: process the value of the symbol recursively | |
3904 as if it appeared here directly. */ | |
3905 Lisp_Object tem = symbol_value_in_buffer (elt, w->buffer); | |
3906 | |
3907 if (!UNBOUNDP (tem)) | |
3908 { | |
3909 /* If value is a string, output that string literally: | |
3910 don't check for % within it. */ | |
3911 if (STRINGP (tem)) | |
3912 { | |
3913 pos = | |
3914 add_string_to_fstring_db_runes | |
3915 (data, XSTRING_DATA (tem), pos, min_pos, max_pos, no_limit); | |
3916 } | |
3917 /* Give up right away for nil or t. */ | |
3918 else if (!EQ (tem, elt)) | |
3919 { | |
3920 elt = tem; | |
3921 goto tail_recurse; | |
3922 } | |
3923 } | |
3924 } | |
3925 else if (GENERIC_SPECIFIERP (elt)) | |
3926 { | |
3927 Lisp_Object window, tem; | |
3928 XSETWINDOW (window, w); | |
3929 tem = specifier_instance_no_quit (elt, Qunbound, window, | |
3930 ERROR_ME_NOT, 0, Qzero); | |
3931 if (!UNBOUNDP (tem)) | |
3932 { | |
3933 elt = tem; | |
3934 goto tail_recurse; | |
3935 } | |
3936 } | |
3937 else if (CONSP (elt)) | |
3938 { | |
3939 /* A cons cell: four distinct cases. | |
3940 * If first element is a string or a cons, process all the elements | |
3941 * and effectively concatenate them. | |
3942 * If first element is a negative number, truncate displaying cdr to | |
3943 * at most that many characters. If positive, pad (with spaces) | |
3944 * to at least that many characters. | |
3945 * If first element is a symbol, process the cadr or caddr recursively | |
3946 * according to whether the symbol's value is non-nil or nil. | |
3947 * If first element is a face, process the cdr recursively | |
3948 * without altering the depth. | |
3949 */ | |
3950 Lisp_Object car, tem; | |
3951 | |
3952 car = XCAR (elt); | |
3953 if (SYMBOLP (car)) | |
3954 { | |
3955 elt = XCDR (elt); | |
3956 if (!CONSP (elt)) | |
3957 goto invalid; | |
3958 tem = symbol_value_in_buffer (car, w->buffer); | |
3959 /* elt is now the cdr, and we know it is a cons cell. | |
3960 Use its car if CAR has a non-nil value. */ | |
3961 if (!UNBOUNDP (tem)) | |
3962 { | |
3963 if (!NILP (tem)) | |
3964 { | |
3965 elt = XCAR (elt); | |
3966 goto tail_recurse; | |
3967 } | |
3968 } | |
3969 /* Symbol's value is nil (or symbol is unbound) | |
3970 * Get the cddr of the original list | |
3971 * and if possible find the caddr and use that. | |
3972 */ | |
3973 elt = XCDR (elt); | |
3974 if (NILP (elt)) | |
3975 ; | |
3976 else if (!CONSP (elt)) | |
3977 goto invalid; | |
3978 else | |
3979 { | |
3980 elt = XCAR (elt); | |
3981 goto tail_recurse; | |
3982 } | |
3983 } | |
3984 else if (INTP (car)) | |
3985 { | |
3986 Charcount lim = XINT (car); | |
3987 | |
3988 elt = XCDR (elt); | |
3989 | |
3990 if (lim < 0) | |
3991 { | |
3992 /* Negative int means reduce maximum width. | |
3993 * DO NOT change MIN_PIXPOS here! | |
3994 * (20 -10 . foo) should truncate foo to 10 col | |
3995 * and then pad to 20. | |
3996 */ | |
3997 if (no_limit) | |
3998 max_pos = pos - lim; | |
3999 else | |
4000 max_pos = min (max_pos, pos - lim); | |
4001 no_limit = 0; | |
4002 } | |
4003 else if (lim > 0) | |
4004 { | |
4005 /* Padding specified. Don't let it be more than | |
4006 * current maximum. | |
4007 */ | |
4008 lim += pos; | |
4009 if (!no_limit && lim > max_pos) | |
4010 lim = max_pos; | |
4011 /* If that's more padding than already wanted, queue it. | |
4012 * But don't reduce padding already specified even if | |
4013 * that is beyond the current truncation point. | |
4014 */ | |
4015 if (lim > min_pos) | |
4016 min_pos = lim; | |
4017 } | |
4018 goto tail_recurse; | |
4019 } | |
4020 else if (STRINGP (car) || CONSP (car)) | |
4021 { | |
4022 int limit = 50; | |
4023 /* LIMIT is to protect against circular lists. */ | |
4024 while (CONSP (elt) && --limit > 0 && (no_limit || pos < max_pos)) | |
4025 { | |
4026 pos = generate_fstring_runes (w, data, pos, pos, max_pos, | |
4027 no_limit, | |
4028 XCAR (elt), depth, | |
4029 max_pixsize, findex, type); | |
4030 elt = XCDR (elt); | |
4031 } | |
4032 } | |
4033 else if (EXTENTP (car)) | |
4034 { | |
4035 struct extent *ext = XEXTENT (car); | |
4036 | |
4037 if (EXTENT_LIVE_P (ext)) | |
4038 { | |
4039 face_index old_findex = data->findex; | |
4040 Lisp_Object face; | |
4041 Lisp_Object font_inst; | |
4042 face_index new_findex; | |
4043 Bytecount start = data->bytepos; | |
4044 | |
4045 face = extent_face (ext); | |
4046 if (FACEP (face)) | |
4047 { | |
4048 /* #### needs to merge faces, sigh */ | |
4049 /* #### needs to handle list of faces */ | |
4050 new_findex = get_builtin_face_cache_index (w, face); | |
4051 /* !!#### not right; needs to compute the max height of | |
4052 all the charsets */ | |
4053 font_inst = WINDOW_FACE_CACHEL_FONT (w, new_findex, | |
4054 Vcharset_ascii); | |
4055 | |
4056 data->dl->ascent = max (data->dl->ascent, | |
4057 XFONT_INSTANCE (font_inst)->ascent); | |
4058 data->dl->descent = max (data->dl->descent, | |
4059 XFONT_INSTANCE (font_inst)-> | |
4060 descent); | |
4061 } | |
4062 else | |
4063 new_findex = old_findex; | |
4064 | |
4065 data->findex = new_findex; | |
4066 pos = generate_fstring_runes (w, data, pos, pos, max_pos, | |
4067 no_limit, | |
4068 XCDR (elt), depth - 1, | |
4069 max_pixsize, new_findex, type); | |
4070 data->findex = old_findex; | |
4071 Dynarr_add (formatted_string_extent_dynarr, ext); | |
4072 Dynarr_add (formatted_string_extent_start_dynarr, start); | |
4073 Dynarr_add (formatted_string_extent_end_dynarr, data->bytepos); | |
4074 } | |
4075 } | |
4076 } | |
4077 else if (GLYPHP (elt)) | |
4078 { | |
4079 pos = add_glyph_to_fstring_db_runes | |
4080 (data, elt, pos, pos, max_pos, no_limit); | |
4081 } | |
4082 else | |
4083 { | |
4084 invalid: | |
4085 pos = | |
4086 add_string_to_fstring_db_runes | |
4087 (data, (CONST Bufbyte *) GETTEXT ("*invalid*"), pos, min_pos, max_pos, | |
4088 no_limit); | |
4089 } | |
4090 | |
4091 if (min_pos > pos) | |
4092 { | |
4093 add_string_to_fstring_db_runes (data, (CONST Bufbyte *) "", pos, min_pos, | |
4094 0, /* no limit */ 1); | |
4095 } | |
4096 | |
4097 return pos; | |
4098 } | |
4099 #else /* not MODELINE_IS_SCROLLABLE */ | |
4100 static void | 3532 static void |
4101 generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str, | 3533 generate_formatted_string_db (Lisp_Object format_str, Lisp_Object result_str, |
4102 struct window *w, struct display_line *dl, | 3534 struct window *w, struct display_line *dl, |
4103 struct display_block *db, face_index findex, | 3535 struct display_block *db, face_index findex, |
4104 int min_pixpos, int max_pixpos, int type) | 3536 int min_pixpos, int max_pixpos, int type) |
4599 -1); | 4031 -1); |
4600 } | 4032 } |
4601 | 4033 |
4602 return pos; | 4034 return pos; |
4603 } | 4035 } |
4604 #endif /* not MODELINE_IS_SCROLLABLE */ | |
4605 | 4036 |
4606 /* The caller is responsible for freeing the returned string. */ | 4037 /* The caller is responsible for freeing the returned string. */ |
4607 Bufbyte * | 4038 Bufbyte * |
4608 generate_formatted_string (struct window *w, Lisp_Object format_str, | 4039 generate_formatted_string (struct window *w, Lisp_Object format_str, |
4609 Lisp_Object result_str, face_index findex, int type) | 4040 Lisp_Object result_str, face_index findex, int type) |
4614 | 4045 |
4615 dl = &formatted_string_display_line; | 4046 dl = &formatted_string_display_line; |
4616 db = get_display_block_from_line (dl, TEXT); | 4047 db = get_display_block_from_line (dl, TEXT); |
4617 Dynarr_reset (db->runes); | 4048 Dynarr_reset (db->runes); |
4618 | 4049 |
4619 #ifdef MODELINE_IS_SCROLLABLE | |
4620 /* D. Verna Feb. 1998. | |
4621 Currently, only update_frame_title can make us come here. This is not | |
4622 to build a modeline */ | |
4623 generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0, | |
4624 -1, type, 0 /* not a modeline */); | |
4625 #else /* not MODELINE_IS_SCROLLABLE */ | |
4626 generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0, | 4050 generate_formatted_string_db (format_str, result_str, w, dl, db, findex, 0, |
4627 -1, type); | 4051 -1, type); |
4628 #endif /* not MODELINE_IS_SCROLLABLE */ | |
4629 | 4052 |
4630 Dynarr_reset (formatted_string_emchar_dynarr); | 4053 Dynarr_reset (formatted_string_emchar_dynarr); |
4631 while (elt < Dynarr_length (db->runes)) | 4054 while (elt < Dynarr_length (db->runes)) |
4632 { | 4055 { |
4633 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) | 4056 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) |
6332 | 5755 |
6333 /* print the current column */ | 5756 /* print the current column */ |
6334 case 'c': | 5757 case 'c': |
6335 { | 5758 { |
6336 int col = current_column (b) + !!column_number_start_at_one; | 5759 int col = current_column (b) + !!column_number_start_at_one; |
6337 int temp = col; | |
6338 int size = 2; | |
6339 char buf[32]; | 5760 char buf[32]; |
6340 | 5761 |
6341 long_to_string (buf, col); | 5762 long_to_string (buf, col); |
6342 | 5763 |
6343 Dynarr_add_many (mode_spec_bufbyte_string, | 5764 Dynarr_add_many (mode_spec_bufbyte_string, |
6344 (CONST Bufbyte *) buf, strlen (buf)); | 5765 (CONST Bufbyte *) buf, strlen (buf)); |
6345 | 5766 |
6346 goto decode_mode_spec_done; | 5767 goto decode_mode_spec_done; |
6347 } | 5768 } |
6348 #ifdef FILE_CODING | |
6349 /* print the file coding system */ | 5769 /* print the file coding system */ |
6350 case 'C': | 5770 case 'C': |
5771 #ifdef FILE_CODING | |
6351 { | 5772 { |
6352 Lisp_Object codesys = b->buffer_file_coding_system; | 5773 Lisp_Object codesys = b->buffer_file_coding_system; |
6353 /* Be very careful here not to get an error. */ | 5774 /* Be very careful here not to get an error. */ |
6354 if (NILP (codesys) || SYMBOLP (codesys) || CODING_SYSTEMP (codesys)) | 5775 if (NILP (codesys) || SYMBOLP (codesys) || CODING_SYSTEMP (codesys)) |
6355 { | 5776 { |
6356 codesys = Ffind_coding_system (codesys); | 5777 codesys = Ffind_coding_system (codesys); |
6357 if (CODING_SYSTEMP (codesys)) | 5778 if (CODING_SYSTEMP (codesys)) |
6358 obj = Fcoding_system_property (codesys, Qmnemonic); | 5779 obj = XCODING_SYSTEM_MNEMONIC (codesys); |
6359 } | 5780 } |
6360 } | 5781 } |
5782 #endif /* FILE_CODING */ | |
6361 break; | 5783 break; |
6362 #endif | |
6363 | 5784 |
6364 /* print the current line number */ | 5785 /* print the current line number */ |
6365 case 'l': | 5786 case 'l': |
6366 str = window_line_number (w, type); | 5787 str = window_line_number (w, type); |
6367 break; | 5788 break; |
8125 { | 7546 { |
8126 /* Must reset the window value since some callers will ignore | 7547 /* Must reset the window value since some callers will ignore |
8127 the return value if it is set. */ | 7548 the return value if it is set. */ |
8128 *w = 0; | 7549 *w = 0; |
8129 UPDATE_CACHE_RETURN; | 7550 UPDATE_CACHE_RETURN; |
7551 } | |
7552 | |
7553 /* See if the point is over window vertical divider */ | |
7554 if (window_needs_vertical_divider (*w)) | |
7555 { | |
7556 int div_x_high = WINDOW_RIGHT (*w); | |
7557 int div_x_low = div_x_high - window_divider_width (*w); | |
7558 int div_y_high = WINDOW_BOTTOM (*w); | |
7559 int div_y_low = WINDOW_TOP (*w); | |
7560 | |
7561 if (div_x_low < x_coord && x_coord <= div_x_high && | |
7562 div_y_low < y_coord && y_coord <= div_y_high) | |
7563 { | |
7564 low_x_coord = div_x_low; | |
7565 high_x_coord = div_x_high; | |
7566 low_y_coord = div_y_low; | |
7567 high_y_coord = div_y_high; | |
7568 position = OVER_V_DIVIDER; | |
7569 UPDATE_CACHE_RETURN; | |
7570 } | |
8130 } | 7571 } |
8131 | 7572 |
8132 dla = window_display_lines (*w, CURRENT_DISP); | 7573 dla = window_display_lines (*w, CURRENT_DISP); |
8133 | 7574 |
8134 for (*row = 0; *row < Dynarr_length (dla); (*row)++) | 7575 for (*row = 0; *row < Dynarr_length (dla); (*row)++) |