From: Jesse Medeiros <jessenzr@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Cc: Stefan Kangas <stefan@marxist.se>
Subject: Re: Patch to vertically center line content when using line-spacing variable
Date: Sun, 8 Sep 2019 20:24:50 -0300 [thread overview]
Message-ID: <CABDXFDnXYBqDUTZGbh65__ZFCveET-XgTB-MgeO3kJ77mZx6tw@mail.gmail.com> (raw)
In-Reply-To: <83ftl85tbn.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 233 bytes --]
I made these changes and wrote entries in the NEWS and in the manual.
I wasn't sure where I should place it in the NEWS, so I put it at the
end of the 'Changes in Emacs 27.1' section. If there still something
amiss just let me know.
[-- Attachment #2: 0001-Center-lines-vertically-with-line-spacing-vertical-c.patch --]
[-- Type: text/x-patch, Size: 5444 bytes --]
From 873c4f2f778478ef22b91e5000cba72970602d26 Mon Sep 17 00:00:00 2001
From: Jesse Nazario <jessenzr@gmail.com>
Date: Sun, 8 Sep 2019 20:06:15 -0300
Subject: [PATCH] Center lines vertically with line-spacing-vertical-center
When using line-spacing, the new variable line-spacing-vertical-center
can be set to non-nil to center the line content vertically.
---
doc/lispref/frames.texi | 5 +++++
etc/NEWS | 4 ++++
src/buffer.c | 14 ++++++++++++++
src/buffer.h | 4 ++++
src/xdisp.c | 9 ++++++++-
5 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 618ea16fcf..75a6725f03 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -1857,6 +1857,11 @@ Layout Parameters
Additional space to leave below each text line, in pixels (a positive
integer). @xref{Line Height}, for more information.
+@vindex line-spacing-vertical-center@r{, a frame parameter}
+@item line-spacing-vertical-center
+If non-nil, centers the line content vertically when using
+using the @code{line-spacing} variable.
+
@vindex no-special-glyphs@r{, a frame parameter}
@item no-special-glyphs
If this is non-@code{nil}, it suppresses the display of any truncation
diff --git a/etc/NEWS b/etc/NEWS
index 87666740df..aa61c23252 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -443,6 +443,10 @@ RGB triplets with a single hexadecimal digit per component.
---
** The toolbar now shows the equivalent key binding in its tooltips.
+** New variable line-spacing-vertical-center.
+This variable, if non-nil, centers the line content vertically when
+using the 'line-spacing' variable.
+
\f
* Editing Changes in Emacs 27.1
diff --git a/src/buffer.c b/src/buffer.c
index 77e8b6bb77..854b3924c0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -219,6 +219,11 @@ bset_extra_line_spacing (struct buffer *b, Lisp_Object val)
b->extra_line_spacing_ = val;
}
static void
+bset_line_spacing_vertical_center (struct buffer *b, Lisp_Object val)
+{
+ b->line_spacing_vertical_center_ = val;
+}
+static void
bset_file_format (struct buffer *b, Lisp_Object val)
{
b->file_format_ = val;
@@ -962,6 +967,8 @@ reset_buffer (register struct buffer *b)
(b, BVAR (&buffer_defaults, enable_multibyte_characters));
bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type));
bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing));
+ bset_line_spacing_vertical_center (b, BVAR (&buffer_defaults,
+ line_spacing_vertical_center));
b->display_error_modiff = 0;
}
@@ -5196,6 +5203,7 @@ init_buffer_once (void)
XSETFASTINT (BVAR (&buffer_local_flags, header_line_format), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx;
+ XSETFASTINT (BVAR (&buffer_local_flags, line_spacing_vertical_center), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx;
/* buffer_local_flags contains no pointers, so it's safe to treat it
@@ -5265,6 +5273,7 @@ init_buffer_once (void)
bset_bidi_paragraph_separate_re (&buffer_defaults, Qnil);
bset_cursor_type (&buffer_defaults, Qt);
bset_extra_line_spacing (&buffer_defaults, Qnil);
+ bset_line_spacing_vertical_center (&buffer_defaults, Qnil);
bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
bset_enable_multibyte_characters (&buffer_defaults, Qt);
@@ -6254,6 +6263,11 @@ from (abs POSITION). If POSITION is positive, point was at the front
If value is a floating point number, it specifies the spacing relative
to the default frame line height. A value of nil means add no extra space. */);
+ DEFVAR_PER_BUFFER ("line-spacing-vertical-center",
+ &BVAR (current_buffer, line_spacing_vertical_center), Qnil,
+ doc: /* Non-nil means center the line content vertically
+when using `line-spacing' variable. */);
+
DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
&BVAR (current_buffer, cursor_in_non_selected_windows), Qnil,
doc: /* Non-nil means show a cursor in non-selected windows.
diff --git a/src/buffer.h b/src/buffer.h
index 82d9350bfc..e4a6b8d4d7 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -549,6 +549,10 @@ #define BVAR(buf, field) ((buf)->field ## _)
in the display of this buffer. */
Lisp_Object extra_line_spacing_;
+ /* Non-nil means center the line content vertically. To be used
+ along with `line-spacing'. */
+ Lisp_Object line_spacing_vertical_center_;
+
/* Cursor type to display in non-selected windows.
t means to use hollow box cursor.
See `cursor-type' for other values. */
diff --git a/src/xdisp.c b/src/xdisp.c
index 94f969f37c..bdd6d65994 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -29295,7 +29295,14 @@ gui_produce_glyphs (struct it *it)
if (extra_line_spacing > 0)
{
- it->descent += extra_line_spacing;
+ if (! BVAR (XBUFFER (it->w->contents), line_spacing_vertical_center))
+ it->descent += extra_line_spacing;
+ else
+ {
+ int spacing = extra_line_spacing / 2;
+ it->ascent += spacing;
+ it->descent += spacing;
+ }
if (extra_line_spacing > it->max_extra_line_spacing)
it->max_extra_line_spacing = extra_line_spacing;
}
--
2.23.0
next prev parent reply other threads:[~2019-09-08 23:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-31 21:53 Patch to vertically center line content when using line-spacing variable Jesse Medeiros
2019-08-31 22:36 ` Stefan Kangas
2019-09-01 0:01 ` Jesse Medeiros
2019-09-03 0:01 ` Jesse Medeiros
2019-09-07 9:50 ` Eli Zaretskii
2019-09-08 23:24 ` Jesse Medeiros [this message]
2019-09-09 7:39 ` martin rudalics
2019-09-09 8:40 ` Robert Pluim
2019-09-12 12:08 ` Jesse Medeiros
2019-09-12 14:26 ` Robert Pluim
2019-09-12 20:49 ` Jesse Medeiros
2019-09-13 9:35 ` Robert Pluim
2019-09-29 23:54 ` Jesse Medeiros
2019-09-30 7:07 ` Robert Pluim
-- strict thread matches above, loose matches on Subject: below --
2020-01-23 16:32 조성빈
2020-01-23 19:22 ` Eli Zaretskii
2020-02-07 17:06 ` Jesse Medeiros
2020-02-07 18:26 ` Eli Zaretskii
2020-04-05 18:55 ` 조성빈 via "Emacs development discussions.
2020-04-06 21:13 ` Jesse Medeiros
2020-04-07 14:17 ` Eli Zaretskii
2021-04-12 20:24 email
2021-04-25 19:41 ` Lars Ingebrigtsen
2021-04-25 20:15 ` john muhl
2021-04-25 20:21 ` Eli Zaretskii
2021-04-25 23:25 ` Fu Yuan
2021-04-25 23:28 ` Stefan Kangas
2021-04-25 23:56 ` Clément Pit-Claudel
2021-04-26 1:00 ` Stefan Kangas
2021-04-26 14:00 ` Clément Pit-Claudel
2021-04-25 23:56 ` Clément Pit-Claudel
2021-04-26 12:35 ` Eli Zaretskii
2021-04-26 20:04 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABDXFDnXYBqDUTZGbh65__ZFCveET-XgTB-MgeO3kJ77mZx6tw@mail.gmail.com \
--to=jessenzr@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=stefan@marxist.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).