diff options
| author | Eli Zaretskii | 2017-07-08 10:49:36 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-07-08 10:49:36 +0300 |
| commit | 5df239fc6ffbbb16ea6e5546fbec1508bf2cb4b7 (patch) | |
| tree | 9b1b8baff1c3ca9c9c560460b34a7951723f621c /src/dispextern.h | |
| parent | b8ead34f5df92b771520f4d090ff6cde49ca5705 (diff) | |
| parent | 13786d5e7d0aa0a37d7f81d1a1b82eddd3472796 (diff) | |
| download | emacs-5df239fc6ffbbb16ea6e5546fbec1508bf2cb4b7.tar.gz emacs-5df239fc6ffbbb16ea6e5546fbec1508bf2cb4b7.zip | |
Support display of line numbers natively
This merges branch 'line-numbers'.
* src/buffer.c (disable_line_numbers_overlay_at_eob): New
function.
* src/lisp.h (disable_line_numbers_overlay_at_eob): Add prototype.
* src/dispextern.h (struct it): New members pt_lnum, lnum,
lnum_bytepos, lnum_width, and lnum_pixel_width.
* src/indent.c (line_number_display_width): New function,
refactored from line-number width calculations in vertical-motion.
(Fvertical_motion): Call line_number_display_width when the width
of line-number display is needed.
(Fline_number_display_width): New defun.
(syms_of_indent): Defsubr it.
* src/indent.c (Fvertical_motion): Help C-n/C-p estimate correctly
the width used up by line numbers by looking near the window-start
point. If window-start is outside of the accessible portion,
temporarily widen the buffer.
* src/term.c (produce_glyphs): Adjust tab stops for the horizontal
space taken by the line-number display.
* src/xdisp.c (display_count_lines_logically)
(display_count_lines_visually, maybe_produce_line_number)
(should_produce_line_number, row_text_area_empty): New functions.
(try_window_reusing_current_matrix): Don't use this method when
display-line-numbers is in effect.
(try_window_id, try_cursor_movement): Disable these optimizations
when the line-number-current-line face is different from
line-number face and for relative line numbers.
(try_window_id, redisplay_window, try_cursor_movement): For
visual line-number display, disable the same redisplay
optimizations as for relative.
(x_produce_glyphs): Adjust tab stops for the horizontal
space taken by the line-number display.
(hscroll_window_tree): Adjust hscroll calculations to line-number
display.
(DISP_INFINITY): Renamed from INFINITY to avoid clashes with
math.h; all users changed.
(set_cursor_from_row): Fix calculation of cursor X coordinate in
R2L rows with display-produced glyphs at the beginning.
(display_line): Use should_produce_line_number to determine
whether a line number should be produced for each glyph row, and
maybe_produce_line_number to produce line numbers.
Don't display line numbers in the minibuffer and in tooltip
frames.
Call row_text_area_empty to verify that a glyph
row's text area is devoid of any glyphs that came from a buffer or
a string. This fixes a bug with empty-lines indication
disappearing when line numbers or line-prefix are displayed.
(syms_of_xdisp) <display-line-numbers, display-line-numbers-widen>
<display-line-number-width>: New buffer-local variables.
<display-line-numbers-current-absolute>: New variable.
* lisp/cus-start.el (standard): Provide customization forms for
display-line-numbers and its sub-features.
* lisp/faces.el (line-number, line-number-current-line): New faces.
* lisp/frame.el: Add display-line-numbers, display-line-numbers-widen,
display-line-numbers-current-absolute, and
display-line-number-width to the list of variables that should
trigger redisplay of the current buffer.
* lisp/menu-bar.el (menu-bar-showhide-menu): Add menu-bar item to
turn display-line-numbers on and off.
(toggle-display-line-numbers): New function.
* lisp/simple.el (last--line-number-width): New internal variable.
(line-move-visual): Use it to adjust temporary-goal-column when
line-number display changes its width.
* doc/emacs/basic.texi (Position Info): Add cross-reference to
"Display Custom", for line-number display.
* doc/emacs/custom.texi (Init Rebinding):
* doc/emacs/modes.texi (Minor Modes): Remove references to
linum-mode.
* doc/emacs/display.texi (Display Custom): Describe the
line-number display.
* doc/lispref/display.texi (Size of Displayed Text): Document
line-number-display-width.
* etc/NEWS: Document display-line-numbers and its customizations.
Diffstat (limited to 'src/dispextern.h')
| -rw-r--r-- | src/dispextern.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 8644ce26d13..1df769a8f99 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -384,6 +384,7 @@ struct glyph | |||
| 384 | glyph standing for newline at end of line 0 | 384 | glyph standing for newline at end of line 0 |
| 385 | empty space after the end of the line -1 | 385 | empty space after the end of the line -1 |
| 386 | overlay arrow on a TTY -1 | 386 | overlay arrow on a TTY -1 |
| 387 | glyph displaying line number -1 | ||
| 387 | glyph at EOB that ends in a newline -1 | 388 | glyph at EOB that ends in a newline -1 |
| 388 | left truncation glyphs: -1 | 389 | left truncation glyphs: -1 |
| 389 | right truncation/continuation glyphs next buffer position | 390 | right truncation/continuation glyphs next buffer position |
| @@ -2537,7 +2538,12 @@ struct it | |||
| 2537 | Do NOT use !BUFFERP (it.object) as a test whether we are | 2538 | Do NOT use !BUFFERP (it.object) as a test whether we are |
| 2538 | iterating over a string; use STRINGP (it.string) instead. | 2539 | iterating over a string; use STRINGP (it.string) instead. |
| 2539 | 2540 | ||
| 2540 | Position is the current iterator position in object. */ | 2541 | Position is the current iterator position in object. |
| 2542 | |||
| 2543 | The 'position's CHARPOS is copied to glyph->charpos of the glyph | ||
| 2544 | produced by PRODUCE_GLYPHS, so any artificial value documented | ||
| 2545 | under 'struct glyph's 'charpos' member can also be found in the | ||
| 2546 | 'position' member here. */ | ||
| 2541 | Lisp_Object object; | 2547 | Lisp_Object object; |
| 2542 | struct text_pos position; | 2548 | struct text_pos position; |
| 2543 | 2549 | ||
| @@ -2621,6 +2627,20 @@ struct it | |||
| 2621 | coordinate is past first_visible_x. */ | 2627 | coordinate is past first_visible_x. */ |
| 2622 | int hpos; | 2628 | int hpos; |
| 2623 | 2629 | ||
| 2630 | /* Current line number, zero-based. */ | ||
| 2631 | ptrdiff_t lnum; | ||
| 2632 | |||
| 2633 | /* The byte position corresponding to lnum. */ | ||
| 2634 | ptrdiff_t lnum_bytepos; | ||
| 2635 | |||
| 2636 | /* The width, in columns and in pixels, needed for display of the | ||
| 2637 | line numbers, or zero if not computed. */ | ||
| 2638 | int lnum_width; | ||
| 2639 | int lnum_pixel_width; | ||
| 2640 | |||
| 2641 | /* The line number of point's line, or zero if not computed yet. */ | ||
| 2642 | ptrdiff_t pt_lnum; | ||
| 2643 | |||
| 2624 | /* Left fringe bitmap number (enum fringe_bitmap_type). */ | 2644 | /* Left fringe bitmap number (enum fringe_bitmap_type). */ |
| 2625 | unsigned left_user_fringe_bitmap : FRINGE_ID_BITS; | 2645 | unsigned left_user_fringe_bitmap : FRINGE_ID_BITS; |
| 2626 | 2646 | ||