diff options
| author | Lars Ingebrigtsen | 2021-11-26 14:17:10 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-11-26 14:19:24 +0100 |
| commit | 3f843b25dc96867043feebb1d928bde4a7a777a3 (patch) | |
| tree | 8570a05d137e92966e755fb43006ebc9cc9d6272 /src | |
| parent | 5d6e1c749a669d33db2936b106ae41ce59473ea1 (diff) | |
| download | emacs-3f843b25dc96867043feebb1d928bde4a7a777a3.tar.gz emacs-3f843b25dc96867043feebb1d928bde4a7a777a3.zip | |
Add an intermediary face for mode lines: `mode-line-active'
* doc/emacs/display.texi (Standard Faces): Document the new face.
* lisp/faces.el (mode-line-active): New face.
(mode-line): Don't inherit from vaiable-pitch.
* src/xfaces.c (lookup_basic_face, realize_basic_faces)
(syms_of_xfaces):
* src/xdisp.c (window_box_height, window_text_pixel_size)
(display_mode_lines, Fformat_mode_line):
* src/dispextern.h (CURRENT_MODE_LINE_ACTIVE_FACE_ID_3)
(CURRENT_MODE_LINE_ACTIVE_FACE_ID, enum face_id): Rename from
*MODE_LINE_FACE_ID to *MODE_LINE_ACTIVE_FACE_ID.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispextern.h | 18 | ||||
| -rw-r--r-- | src/xdisp.c | 31 | ||||
| -rw-r--r-- | src/xfaces.c | 4 |
3 files changed, 30 insertions, 23 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 088297157ac..ff4e7293d85 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1477,21 +1477,23 @@ struct glyph_string | |||
| 1477 | compared against minibuf_window (if SELW doesn't match), and SCRW | 1477 | compared against minibuf_window (if SELW doesn't match), and SCRW |
| 1478 | which is compared against minibuf_selected_window (if MBW matches). */ | 1478 | which is compared against minibuf_selected_window (if MBW matches). */ |
| 1479 | 1479 | ||
| 1480 | #define CURRENT_MODE_LINE_FACE_ID_3(SELW, MBW, SCRW) \ | 1480 | #define CURRENT_MODE_LINE_ACTIVE_FACE_ID_3(SELW, MBW, SCRW) \ |
| 1481 | ((!mode_line_in_non_selected_windows \ | 1481 | ((!mode_line_in_non_selected_windows \ |
| 1482 | || (SELW) == XWINDOW (selected_window) \ | 1482 | || (SELW) == XWINDOW (selected_window) \ |
| 1483 | || (minibuf_level > 0 \ | 1483 | || (minibuf_level > 0 \ |
| 1484 | && !NILP (minibuf_selected_window) \ | 1484 | && !NILP (minibuf_selected_window) \ |
| 1485 | && (MBW) == XWINDOW (minibuf_window) \ | 1485 | && (MBW) == XWINDOW (minibuf_window) \ |
| 1486 | && (SCRW) == XWINDOW (minibuf_selected_window))) \ | 1486 | && (SCRW) == XWINDOW (minibuf_selected_window))) \ |
| 1487 | ? MODE_LINE_FACE_ID \ | 1487 | ? MODE_LINE_ACTIVE_FACE_ID \ |
| 1488 | : MODE_LINE_INACTIVE_FACE_ID) | 1488 | : MODE_LINE_INACTIVE_FACE_ID) |
| 1489 | 1489 | ||
| 1490 | 1490 | ||
| 1491 | /* Return the desired face id for the mode line of window W. */ | 1491 | /* Return the desired face id for the mode line of window W. */ |
| 1492 | 1492 | ||
| 1493 | #define CURRENT_MODE_LINE_FACE_ID(W) \ | 1493 | #define CURRENT_MODE_LINE_ACTIVE_FACE_ID(W) \ |
| 1494 | (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W))) | 1494 | (CURRENT_MODE_LINE_ACTIVE_FACE_ID_3((W), \ |
| 1495 | XWINDOW (selected_window), \ | ||
| 1496 | (W))) | ||
| 1495 | 1497 | ||
| 1496 | /* Return the current height of the mode line of window W. If not known | 1498 | /* Return the current height of the mode line of window W. If not known |
| 1497 | from W->mode_line_height, look at W's current glyph matrix, or return | 1499 | from W->mode_line_height, look at W's current glyph matrix, or return |
| @@ -1504,7 +1506,7 @@ struct glyph_string | |||
| 1504 | = (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ | 1506 | = (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ |
| 1505 | ? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ | 1507 | ? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ |
| 1506 | : estimate_mode_line_height \ | 1508 | : estimate_mode_line_height \ |
| 1507 | (XFRAME ((W)->frame), CURRENT_MODE_LINE_FACE_ID (W))))) | 1509 | (XFRAME ((W)->frame), CURRENT_MODE_LINE_ACTIVE_FACE_ID (W))))) |
| 1508 | 1510 | ||
| 1509 | /* Return the current height of the header line of window W. If not known | 1511 | /* Return the current height of the header line of window W. If not known |
| 1510 | from W->header_line_height, look at W's current glyph matrix, or return | 1512 | from W->header_line_height, look at W's current glyph matrix, or return |
| @@ -1818,7 +1820,7 @@ face_tty_specified_color (unsigned long color) | |||
| 1818 | enum face_id | 1820 | enum face_id |
| 1819 | { | 1821 | { |
| 1820 | DEFAULT_FACE_ID, | 1822 | DEFAULT_FACE_ID, |
| 1821 | MODE_LINE_FACE_ID, | 1823 | MODE_LINE_ACTIVE_FACE_ID, |
| 1822 | MODE_LINE_INACTIVE_FACE_ID, | 1824 | MODE_LINE_INACTIVE_FACE_ID, |
| 1823 | TOOL_BAR_FACE_ID, | 1825 | TOOL_BAR_FACE_ID, |
| 1824 | FRINGE_FACE_ID, | 1826 | FRINGE_FACE_ID, |
| @@ -1836,6 +1838,7 @@ enum face_id | |||
| 1836 | CHILD_FRAME_BORDER_FACE_ID, | 1838 | CHILD_FRAME_BORDER_FACE_ID, |
| 1837 | TAB_BAR_FACE_ID, | 1839 | TAB_BAR_FACE_ID, |
| 1838 | TAB_LINE_FACE_ID, | 1840 | TAB_LINE_FACE_ID, |
| 1841 | MODE_LINE_FACE_ID, | ||
| 1839 | BASIC_FACE_ID_SENTINEL | 1842 | BASIC_FACE_ID_SENTINEL |
| 1840 | }; | 1843 | }; |
| 1841 | 1844 | ||
| @@ -2545,7 +2548,8 @@ struct it | |||
| 2545 | enum line_wrap_method line_wrap; | 2548 | enum line_wrap_method line_wrap; |
| 2546 | 2549 | ||
| 2547 | /* The ID of the default face to use. One of DEFAULT_FACE_ID, | 2550 | /* The ID of the default face to use. One of DEFAULT_FACE_ID, |
| 2548 | MODE_LINE_FACE_ID, etc, depending on what we are displaying. */ | 2551 | MODE_LINE_ACTIVE_FACE_ID, etc, depending on what we are |
| 2552 | displaying. */ | ||
| 2549 | int base_face_id; | 2553 | int base_face_id; |
| 2550 | 2554 | ||
| 2551 | /* If `what' == IT_CHARACTER, the character and the length in bytes | 2555 | /* If `what' == IT_CHARACTER, the character and the length in bytes |
diff --git a/src/xdisp.c b/src/xdisp.c index d6b53eacea1..24049ab4e33 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -1285,8 +1285,8 @@ window_box_height (struct window *w) | |||
| 1285 | if (ml_row && ml_row->mode_line_p) | 1285 | if (ml_row && ml_row->mode_line_p) |
| 1286 | height -= ml_row->height; | 1286 | height -= ml_row->height; |
| 1287 | else | 1287 | else |
| 1288 | height -= estimate_mode_line_height (f, | 1288 | height -= estimate_mode_line_height |
| 1289 | CURRENT_MODE_LINE_FACE_ID (w)); | 1289 | (f, CURRENT_MODE_LINE_ACTIVE_FACE_ID (w)); |
| 1290 | } | 1290 | } |
| 1291 | } | 1291 | } |
| 1292 | 1292 | ||
| @@ -1691,7 +1691,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1691 | = window_parameter (w, Qmode_line_format); | 1691 | = window_parameter (w, Qmode_line_format); |
| 1692 | 1692 | ||
| 1693 | w->mode_line_height | 1693 | w->mode_line_height |
| 1694 | = display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w), | 1694 | = display_mode_line (w, CURRENT_MODE_LINE_ACTIVE_FACE_ID (w), |
| 1695 | NILP (window_mode_line_format) | 1695 | NILP (window_mode_line_format) |
| 1696 | ? BVAR (current_buffer, mode_line_format) | 1696 | ? BVAR (current_buffer, mode_line_format) |
| 1697 | : window_mode_line_format); | 1697 | : window_mode_line_format); |
| @@ -3146,11 +3146,11 @@ CHECK_WINDOW_END (struct window *w) | |||
| 3146 | will produce glyphs in that row. | 3146 | will produce glyphs in that row. |
| 3147 | 3147 | ||
| 3148 | BASE_FACE_ID is the id of a base face to use. It must be one of | 3148 | BASE_FACE_ID is the id of a base face to use. It must be one of |
| 3149 | DEFAULT_FACE_ID for normal text, MODE_LINE_FACE_ID, | 3149 | DEFAULT_FACE_ID for normal text, MODE_LINE_ACTIVE_FACE_ID, |
| 3150 | MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID for displaying | 3150 | MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID for displaying |
| 3151 | mode lines, or TOOL_BAR_FACE_ID for displaying the tool-bar. | 3151 | mode lines, or TOOL_BAR_FACE_ID for displaying the tool-bar. |
| 3152 | 3152 | ||
| 3153 | If ROW is null and BASE_FACE_ID is equal to MODE_LINE_FACE_ID, | 3153 | If ROW is null and BASE_FACE_ID is equal to MODE_LINE_ACTIVE_FACE_ID, |
| 3154 | MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID, the iterator | 3154 | MODE_LINE_INACTIVE_FACE_ID, or HEADER_LINE_FACE_ID, the iterator |
| 3155 | will be initialized to use the corresponding mode line glyph row of | 3155 | will be initialized to use the corresponding mode line glyph row of |
| 3156 | the desired matrix of W. */ | 3156 | the desired matrix of W. */ |
| @@ -3196,7 +3196,7 @@ init_iterator (struct it *it, struct window *w, | |||
| 3196 | appropriate. */ | 3196 | appropriate. */ |
| 3197 | if (row == NULL) | 3197 | if (row == NULL) |
| 3198 | { | 3198 | { |
| 3199 | if (base_face_id == MODE_LINE_FACE_ID | 3199 | if (base_face_id == MODE_LINE_ACTIVE_FACE_ID |
| 3200 | || base_face_id == MODE_LINE_INACTIVE_FACE_ID) | 3200 | || base_face_id == MODE_LINE_INACTIVE_FACE_ID) |
| 3201 | row = MATRIX_MODE_LINE_ROW (w->desired_matrix); | 3201 | row = MATRIX_MODE_LINE_ROW (w->desired_matrix); |
| 3202 | else if (base_face_id == TAB_LINE_FACE_ID) | 3202 | else if (base_face_id == TAB_LINE_FACE_ID) |
| @@ -11020,7 +11020,7 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, Li | |||
| 11020 | Lisp_Object window_mode_line_format | 11020 | Lisp_Object window_mode_line_format |
| 11021 | = window_parameter (w, Qmode_line_format); | 11021 | = window_parameter (w, Qmode_line_format); |
| 11022 | 11022 | ||
| 11023 | y = y + display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w), | 11023 | y = y + display_mode_line (w, CURRENT_MODE_LINE_ACTIVE_FACE_ID (w), |
| 11024 | NILP (window_mode_line_format) | 11024 | NILP (window_mode_line_format) |
| 11025 | ? BVAR (current_buffer, mode_line_format) | 11025 | ? BVAR (current_buffer, mode_line_format) |
| 11026 | : window_mode_line_format); | 11026 | : window_mode_line_format); |
| @@ -25813,7 +25813,8 @@ display_mode_lines (struct window *w) | |||
| 25813 | struct window *sel_w = XWINDOW (old_selected_window); | 25813 | struct window *sel_w = XWINDOW (old_selected_window); |
| 25814 | 25814 | ||
| 25815 | /* Select mode line face based on the real selected window. */ | 25815 | /* Select mode line face based on the real selected window. */ |
| 25816 | display_mode_line (w, CURRENT_MODE_LINE_FACE_ID_3 (sel_w, sel_w, w), | 25816 | display_mode_line (w, |
| 25817 | CURRENT_MODE_LINE_ACTIVE_FACE_ID_3 (sel_w, sel_w, w), | ||
| 25817 | NILP (window_mode_line_format) | 25818 | NILP (window_mode_line_format) |
| 25818 | ? BVAR (current_buffer, mode_line_format) | 25819 | ? BVAR (current_buffer, mode_line_format) |
| 25819 | : window_mode_line_format); | 25820 | : window_mode_line_format); |
| @@ -25852,11 +25853,11 @@ display_mode_lines (struct window *w) | |||
| 25852 | } | 25853 | } |
| 25853 | 25854 | ||
| 25854 | 25855 | ||
| 25855 | /* Display mode or header/tab line of window W. FACE_ID specifies which | 25856 | /* Display mode or header/tab line of window W. FACE_ID specifies |
| 25856 | line to display; it is either MODE_LINE_FACE_ID, HEADER_LINE_FACE_ID or | 25857 | which line to display; it is either MODE_LINE_ACTIVE_FACE_ID, |
| 25857 | TAB_LINE_FACE_ID. FORMAT is the mode/header/tab line format to | 25858 | HEADER_LINE_FACE_ID or TAB_LINE_FACE_ID. FORMAT is the |
| 25858 | display. Value is the pixel height of the mode/header/tab line | 25859 | mode/header/tab line format to display. Value is the pixel height |
| 25859 | displayed. */ | 25860 | of the mode/header/tab line displayed. */ |
| 25860 | 25861 | ||
| 25861 | static int | 25862 | static int |
| 25862 | display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) | 25863 | display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) |
| @@ -26649,8 +26650,8 @@ are the selected window and the WINDOW's buffer). */) | |||
| 26649 | 26650 | ||
| 26650 | face_id = (NILP (face) || EQ (face, Qdefault)) ? DEFAULT_FACE_ID | 26651 | face_id = (NILP (face) || EQ (face, Qdefault)) ? DEFAULT_FACE_ID |
| 26651 | : EQ (face, Qt) ? (EQ (window, selected_window) | 26652 | : EQ (face, Qt) ? (EQ (window, selected_window) |
| 26652 | ? MODE_LINE_FACE_ID : MODE_LINE_INACTIVE_FACE_ID) | 26653 | ? MODE_LINE_ACTIVE_FACE_ID : MODE_LINE_INACTIVE_FACE_ID) |
| 26653 | : EQ (face, Qmode_line) ? MODE_LINE_FACE_ID | 26654 | : EQ (face, Qmode_line_active) ? MODE_LINE_ACTIVE_FACE_ID |
| 26654 | : EQ (face, Qmode_line_inactive) ? MODE_LINE_INACTIVE_FACE_ID | 26655 | : EQ (face, Qmode_line_inactive) ? MODE_LINE_INACTIVE_FACE_ID |
| 26655 | : EQ (face, Qheader_line) ? HEADER_LINE_FACE_ID | 26656 | : EQ (face, Qheader_line) ? HEADER_LINE_FACE_ID |
| 26656 | : EQ (face, Qtab_line) ? TAB_LINE_FACE_ID | 26657 | : EQ (face, Qtab_line) ? TAB_LINE_FACE_ID |
diff --git a/src/xfaces.c b/src/xfaces.c index 174a1ca47c9..813d89e5a3e 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -4857,7 +4857,7 @@ lookup_basic_face (struct window *w, struct frame *f, int face_id) | |||
| 4857 | switch (face_id) | 4857 | switch (face_id) |
| 4858 | { | 4858 | { |
| 4859 | case DEFAULT_FACE_ID: name = Qdefault; break; | 4859 | case DEFAULT_FACE_ID: name = Qdefault; break; |
| 4860 | case MODE_LINE_FACE_ID: name = Qmode_line; break; | 4860 | case MODE_LINE_ACTIVE_FACE_ID: name = Qmode_line_active; break; |
| 4861 | case MODE_LINE_INACTIVE_FACE_ID: name = Qmode_line_inactive; break; | 4861 | case MODE_LINE_INACTIVE_FACE_ID: name = Qmode_line_inactive; break; |
| 4862 | case HEADER_LINE_FACE_ID: name = Qheader_line; break; | 4862 | case HEADER_LINE_FACE_ID: name = Qheader_line; break; |
| 4863 | case TAB_LINE_FACE_ID: name = Qtab_line; break; | 4863 | case TAB_LINE_FACE_ID: name = Qtab_line; break; |
| @@ -5569,6 +5569,7 @@ realize_basic_faces (struct frame *f) | |||
| 5569 | if (realize_default_face (f)) | 5569 | if (realize_default_face (f)) |
| 5570 | { | 5570 | { |
| 5571 | realize_named_face (f, Qmode_line, MODE_LINE_FACE_ID); | 5571 | realize_named_face (f, Qmode_line, MODE_LINE_FACE_ID); |
| 5572 | realize_named_face (f, Qmode_line_active, MODE_LINE_ACTIVE_FACE_ID); | ||
| 5572 | realize_named_face (f, Qmode_line_inactive, MODE_LINE_INACTIVE_FACE_ID); | 5573 | realize_named_face (f, Qmode_line_inactive, MODE_LINE_INACTIVE_FACE_ID); |
| 5573 | realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID); | 5574 | realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID); |
| 5574 | realize_named_face (f, Qfringe, FRINGE_FACE_ID); | 5575 | realize_named_face (f, Qfringe, FRINGE_FACE_ID); |
| @@ -6945,6 +6946,7 @@ syms_of_xfaces (void) | |||
| 6945 | DEFSYM (Qborder, "border"); | 6946 | DEFSYM (Qborder, "border"); |
| 6946 | DEFSYM (Qmouse, "mouse"); | 6947 | DEFSYM (Qmouse, "mouse"); |
| 6947 | DEFSYM (Qmode_line_inactive, "mode-line-inactive"); | 6948 | DEFSYM (Qmode_line_inactive, "mode-line-inactive"); |
| 6949 | DEFSYM (Qmode_line_active, "mode-line-active"); | ||
| 6948 | DEFSYM (Qvertical_border, "vertical-border"); | 6950 | DEFSYM (Qvertical_border, "vertical-border"); |
| 6949 | DEFSYM (Qwindow_divider, "window-divider"); | 6951 | DEFSYM (Qwindow_divider, "window-divider"); |
| 6950 | DEFSYM (Qwindow_divider_first_pixel, "window-divider-first-pixel"); | 6952 | DEFSYM (Qwindow_divider_first_pixel, "window-divider-first-pixel"); |