aboutsummaryrefslogtreecommitdiffstats
path: root/src/xdisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c112
1 files changed, 90 insertions, 22 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 31a82fefd78..a7ce6159a01 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -350,6 +350,10 @@ Lisp_Object Qtrailing_whitespace;
350 350
351Lisp_Object Qescape_glyph; 351Lisp_Object Qescape_glyph;
352 352
353/* Name and number of the face used to highlight non-breaking spaces. */
354
355Lisp_Object Qno_break_space;
356
353/* The symbol `image' which is the car of the lists used to represent 357/* The symbol `image' which is the car of the lists used to represent
354 images in Lisp. */ 358 images in Lisp. */
355 359
@@ -1881,7 +1885,7 @@ get_phys_cursor_geometry (w, row, glyph, heightp)
1881 int *heightp; 1885 int *heightp;
1882{ 1886{
1883 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1887 struct frame *f = XFRAME (WINDOW_FRAME (w));
1884 int x, y, wd, h, h0, y0; 1888 int y, wd, h, h0, y0;
1885 1889
1886 /* Compute the width of the rectangle to draw. If on a stretch 1890 /* Compute the width of the rectangle to draw. If on a stretch
1887 glyph, and `x-stretch-block-cursor' is nil, don't draw a 1891 glyph, and `x-stretch-block-cursor' is nil, don't draw a
@@ -5081,8 +5085,10 @@ get_next_display_element (it)
5081 && it->len == 1) 5085 && it->len == 1)
5082 || !CHAR_PRINTABLE_P (it->c) 5086 || !CHAR_PRINTABLE_P (it->c)
5083 || (!NILP (Vshow_nonbreak_escape) 5087 || (!NILP (Vshow_nonbreak_escape)
5084 && (it->c == 0x8ad || it->c == 0x8a0 5088 && (it->c == 0x8a0 || it->c == 0x8ad
5085 || it->c == 0xf2d || it->c == 0xf20))) 5089 || it->c == 0x920 || it->c == 0x92d
5090 || it->c == 0xe20 || it->c == 0xe2d
5091 || it->c == 0xf20 || it->c == 0xf2d)))
5086 : (it->c >= 127 5092 : (it->c >= 127
5087 && (!unibyte_display_via_language_environment 5093 && (!unibyte_display_via_language_environment
5088 || it->c == unibyte_char_to_multibyte (it->c))))) 5094 || it->c == unibyte_char_to_multibyte (it->c)))))
@@ -5097,6 +5103,8 @@ get_next_display_element (it)
5097 int face_id, lface_id = 0 ; 5103 int face_id, lface_id = 0 ;
5098 GLYPH escape_glyph; 5104 GLYPH escape_glyph;
5099 5105
5106 /* Handle control characters with ^. */
5107
5100 if (it->c < 128 && it->ctl_arrow_p) 5108 if (it->c < 128 && it->ctl_arrow_p)
5101 { 5109 {
5102 g = '^'; /* default glyph for Control */ 5110 g = '^'; /* default glyph for Control */
@@ -5128,7 +5136,28 @@ get_next_display_element (it)
5128 goto display_control; 5136 goto display_control;
5129 } 5137 }
5130 5138
5131 escape_glyph = '\\'; /* default for Octal display */ 5139 /* Handle non-break space in the mode where it only gets
5140 highlighting. */
5141
5142 if (! EQ (Vshow_nonbreak_escape, Qt)
5143 && (it->c == 0x8a0 || it->c == 0x920
5144 || it->c == 0xe20 || it->c == 0xf20))
5145 {
5146 /* Merge the no-break-space face into the current face. */
5147 face_id = merge_faces (it->f, Qno_break_space, 0,
5148 it->face_id);
5149
5150 g = it->c = ' ';
5151 XSETINT (it->ctl_chars[0], g);
5152 ctl_len = 1;
5153 goto display_control;
5154 }
5155
5156 /* Handle sequences that start with the "escape glyph". */
5157
5158 /* the default escape glyph is \. */
5159 escape_glyph = '\\';
5160
5132 if (it->dp 5161 if (it->dp
5133 && INTEGERP (DISP_ESCAPE_GLYPH (it->dp)) 5162 && INTEGERP (DISP_ESCAPE_GLYPH (it->dp))
5134 && GLYPH_CHAR_VALID_P (XFASTINT (DISP_ESCAPE_GLYPH (it->dp)))) 5163 && GLYPH_CHAR_VALID_P (XFASTINT (DISP_ESCAPE_GLYPH (it->dp))))
@@ -5138,6 +5167,8 @@ get_next_display_element (it)
5138 } 5167 }
5139 if (lface_id) 5168 if (lface_id)
5140 { 5169 {
5170 /* The display table specified a face.
5171 Merge it into face_id and also into escape_glyph. */
5141 escape_glyph = FAST_GLYPH_CHAR (escape_glyph); 5172 escape_glyph = FAST_GLYPH_CHAR (escape_glyph);
5142 face_id = merge_faces (it->f, Qt, lface_id, 5173 face_id = merge_faces (it->f, Qt, lface_id,
5143 it->face_id); 5174 it->face_id);
@@ -5149,11 +5180,29 @@ get_next_display_element (it)
5149 it->face_id); 5180 it->face_id);
5150 } 5181 }
5151 5182
5183 /* Handle soft hyphens in the mode where they only get
5184 highlighting. */
5185
5186 if (! EQ (Vshow_nonbreak_escape, Qt)
5187 && (it->c == 0x8ad || it->c == 0x92d
5188 || it->c == 0xe2d || it->c == 0xf2d))
5189 {
5190 g = it->c = '-';
5191 XSETINT (it->ctl_chars[0], g);
5192 ctl_len = 1;
5193 goto display_control;
5194 }
5195
5196 /* Handle non-break space and soft hyphen
5197 with the escape glyph. */
5198
5152 if (it->c == 0x8a0 || it->c == 0x8ad 5199 if (it->c == 0x8a0 || it->c == 0x8ad
5200 || it->c == 0x920 || it->c == 0x92d
5201 || it->c == 0xe20 || it->c == 0xe2d
5153 || it->c == 0xf20 || it->c == 0xf2d) 5202 || it->c == 0xf20 || it->c == 0xf2d)
5154 { 5203 {
5155 XSETINT (it->ctl_chars[0], escape_glyph); 5204 XSETINT (it->ctl_chars[0], escape_glyph);
5156 g = it->c; 5205 g = it->c = ((it->c & 0xf) == 0 ? ' ' : '-');
5157 XSETINT (it->ctl_chars[1], g); 5206 XSETINT (it->ctl_chars[1], g);
5158 ctl_len = 2; 5207 ctl_len = 2;
5159 goto display_control; 5208 goto display_control;
@@ -8205,7 +8254,6 @@ static Lisp_Object
8205format_mode_line_unwind_data (obuf) 8254format_mode_line_unwind_data (obuf)
8206 struct buffer *obuf; 8255 struct buffer *obuf;
8207{ 8256{
8208 int i = 0;
8209 Lisp_Object vector; 8257 Lisp_Object vector;
8210 8258
8211 /* Reduce consing by keeping one vector in 8259 /* Reduce consing by keeping one vector in
@@ -8442,7 +8490,7 @@ prepare_menu_bars ()
8442 Lisp_Object tail, frame; 8490 Lisp_Object tail, frame;
8443 int count = SPECPDL_INDEX (); 8491 int count = SPECPDL_INDEX ();
8444 8492
8445 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); 8493 record_unwind_save_match_data ();
8446 8494
8447 FOR_EACH_FRAME (tail, frame) 8495 FOR_EACH_FRAME (tail, frame)
8448 { 8496 {
@@ -8565,7 +8613,7 @@ update_menu_bar (f, save_match_data)
8565 8613
8566 set_buffer_internal_1 (XBUFFER (w->buffer)); 8614 set_buffer_internal_1 (XBUFFER (w->buffer));
8567 if (save_match_data) 8615 if (save_match_data)
8568 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); 8616 record_unwind_save_match_data ();
8569 if (NILP (Voverriding_local_map_menu_flag)) 8617 if (NILP (Voverriding_local_map_menu_flag))
8570 { 8618 {
8571 specbind (Qoverriding_terminal_local_map, Qnil); 8619 specbind (Qoverriding_terminal_local_map, Qnil);
@@ -8756,7 +8804,7 @@ update_tool_bar (f, save_match_data)
8756 8804
8757 /* Save match data, if we must. */ 8805 /* Save match data, if we must. */
8758 if (save_match_data) 8806 if (save_match_data)
8759 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); 8807 record_unwind_save_match_data ();
8760 8808
8761 /* Make sure that we don't accidentally use bogus keymaps. */ 8809 /* Make sure that we don't accidentally use bogus keymaps. */
8762 if (NILP (Voverriding_local_map_menu_flag)) 8810 if (NILP (Voverriding_local_map_menu_flag))
@@ -19160,7 +19208,7 @@ get_line_height_property (it, prop)
19160 struct it *it; 19208 struct it *it;
19161 Lisp_Object prop; 19209 Lisp_Object prop;
19162{ 19210{
19163 Lisp_Object position, val; 19211 Lisp_Object position;
19164 19212
19165 if (STRINGP (it->object)) 19213 if (STRINGP (it->object))
19166 position = make_number (IT_STRING_CHARPOS (*it)); 19214 position = make_number (IT_STRING_CHARPOS (*it));
@@ -19511,7 +19559,6 @@ x_produce_glyphs (it)
19511 else 19559 else
19512 { 19560 {
19513 Lisp_Object spacing; 19561 Lisp_Object spacing;
19514 int total = 0;
19515 19562
19516 it->phys_ascent = it->ascent; 19563 it->phys_ascent = it->ascent;
19517 it->phys_descent = it->descent; 19564 it->phys_descent = it->descent;
@@ -21480,9 +21527,7 @@ note_mode_line_or_margin_highlight (window, x, y, area)
21480 int total_pixel_width; 21527 int total_pixel_width;
21481 int ignore; 21528 int ignore;
21482 21529
21483 21530 int vpos, hpos;
21484 if (clear_mouse_face (dpyinfo))
21485 cursor = No_Cursor;
21486 21531
21487 b = Fprevious_single_property_change (make_number (charpos + 1), 21532 b = Fprevious_single_property_change (make_number (charpos + 1),
21488 Qmouse_face, string, Qnil); 21533 Qmouse_face, string, Qnil);
@@ -21526,15 +21571,30 @@ note_mode_line_or_margin_highlight (window, x, y, area)
21526 for (tmp_glyph = glyph - gpos; tmp_glyph != glyph; tmp_glyph++) 21571 for (tmp_glyph = glyph - gpos; tmp_glyph != glyph; tmp_glyph++)
21527 total_pixel_width += tmp_glyph->pixel_width; 21572 total_pixel_width += tmp_glyph->pixel_width;
21528 21573
21529 dpyinfo->mouse_face_beg_col = (x - gpos); 21574 /* Pre calculation of re-rendering position */
21530 dpyinfo->mouse_face_beg_row = (area == ON_MODE_LINE 21575 vpos = (x - gpos);
21531 ? (w->current_matrix)->nrows - 1 21576 hpos = (area == ON_MODE_LINE
21532 : 0); 21577 ? (w->current_matrix)->nrows - 1
21578 : 0);
21579
21580 /* If the re-rendering position is included in the last
21581 re-rendering area, we should do nothing. */
21582 if ( EQ (window, dpyinfo->mouse_face_window)
21583 && dpyinfo->mouse_face_beg_col <= vpos
21584 && vpos < dpyinfo->mouse_face_end_col
21585 && dpyinfo->mouse_face_beg_row == hpos )
21586 return;
21587
21588 if (clear_mouse_face (dpyinfo))
21589 cursor = No_Cursor;
21590
21591 dpyinfo->mouse_face_beg_col = vpos;
21592 dpyinfo->mouse_face_beg_row = hpos;
21533 21593
21534 dpyinfo->mouse_face_beg_x = original_x_pixel - (total_pixel_width + dx); 21594 dpyinfo->mouse_face_beg_x = original_x_pixel - (total_pixel_width + dx);
21535 dpyinfo->mouse_face_beg_y = 0; 21595 dpyinfo->mouse_face_beg_y = 0;
21536 21596
21537 dpyinfo->mouse_face_end_col = (x - gpos) + gseq_length; 21597 dpyinfo->mouse_face_end_col = vpos + gseq_length;
21538 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row; 21598 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row;
21539 21599
21540 dpyinfo->mouse_face_end_x = 0; 21600 dpyinfo->mouse_face_end_x = 0;
@@ -21552,8 +21612,9 @@ note_mode_line_or_margin_highlight (window, x, y, area)
21552 if (NILP (pointer)) 21612 if (NILP (pointer))
21553 pointer = Qhand; 21613 pointer = Qhand;
21554 } 21614 }
21615 else if ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE))
21616 clear_mouse_face (dpyinfo);
21555 } 21617 }
21556
21557 define_frame_cursor1 (f, cursor, pointer); 21618 define_frame_cursor1 (f, cursor, pointer);
21558} 21619}
21559 21620
@@ -21606,7 +21667,8 @@ note_mouse_highlight (f, x, y)
21606 /* If we were displaying active text in another window, clear that. 21667 /* If we were displaying active text in another window, clear that.
21607 Also clear if we move out of text area in same window. */ 21668 Also clear if we move out of text area in same window. */
21608 if (! EQ (window, dpyinfo->mouse_face_window) 21669 if (! EQ (window, dpyinfo->mouse_face_window)
21609 || (part != ON_TEXT && !NILP (dpyinfo->mouse_face_window))) 21670 || (part != ON_TEXT && part != ON_MODE_LINE && part != ON_HEADER_LINE
21671 && !NILP (dpyinfo->mouse_face_window)))
21610 clear_mouse_face (dpyinfo); 21672 clear_mouse_face (dpyinfo);
21611 21673
21612 /* Not on a window -> return. */ 21674 /* Not on a window -> return. */
@@ -22723,6 +22785,8 @@ syms_of_xdisp ()
22723 staticpro (&Qtrailing_whitespace); 22785 staticpro (&Qtrailing_whitespace);
22724 Qescape_glyph = intern ("escape-glyph"); 22786 Qescape_glyph = intern ("escape-glyph");
22725 staticpro (&Qescape_glyph); 22787 staticpro (&Qescape_glyph);
22788 Qno_break_space = intern ("no-break-space");
22789 staticpro (&Qno_break_space);
22726 Qimage = intern ("image"); 22790 Qimage = intern ("image");
22727 staticpro (&Qimage); 22791 staticpro (&Qimage);
22728 QCmap = intern (":map"); 22792 QCmap = intern (":map");
@@ -22829,7 +22893,11 @@ The face used for trailing whitespace is `trailing-whitespace'. */);
22829 Vshow_trailing_whitespace = Qnil; 22893 Vshow_trailing_whitespace = Qnil;
22830 22894
22831 DEFVAR_LISP ("show-nonbreak-escape", &Vshow_nonbreak_escape, 22895 DEFVAR_LISP ("show-nonbreak-escape", &Vshow_nonbreak_escape,
22832 doc: /* *Non-nil means display escape character before non-break space and hyphen. */); 22896 doc: /* *Control highlighting of non-break space and soft hyphen.
22897t means highlight the character itself (for non-break space,
22898use face `non-break-space'.
22899nil means no highlighting.
22900other values mean display the escape glyph before the character. */);
22833 Vshow_nonbreak_escape = Qt; 22901 Vshow_nonbreak_escape = Qt;
22834 22902
22835 DEFVAR_LISP ("void-text-area-pointer", &Vvoid_text_area_pointer, 22903 DEFVAR_LISP ("void-text-area-pointer", &Vvoid_text_area_pointer,