diff options
| author | Paul Eggert | 2015-09-09 02:21:16 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-09-09 02:22:24 -0700 |
| commit | 6e5d81ff4536ed117dfac269357c46dbdc1890c9 (patch) | |
| tree | ce637dad553f16c3dab02720bee505c938416beb /src | |
| parent | 39dca94701de81d02c75316e32d67e3677bd685d (diff) | |
| download | emacs-6e5d81ff4536ed117dfac269357c46dbdc1890c9.tar.gz emacs-6e5d81ff4536ed117dfac269357c46dbdc1890c9.zip | |
Improvements for curved quotes on Linux consule
This should help Emacs work better out-of-the-box on Linux consoles,
which have only limited support for displaying Unicode characters.
Also, undo the recent change that caused text-quoting-style to
affect quote display on terminals, so that the two features are
independent. See Alan Mackenzie in:
http://lists.gnu.org/archive/html/emacs-devel/2015-09/msg00244.html
Finally, add a style parameter to startup--setup-quote-display,
so that this function can also be invoked after startup, with
different styles depending on user preference at the time.
* configure.ac: Check for linux/kd.h header.
* doc/emacs/display.texi (Text Display): Document quote display.
* doc/lispref/display.texi (Active Display Table):
* etc/NEWS:
* lisp/startup.el (startup--setup-quote-display, command-line):
text-quoting-style no longer affects quote display.
* doc/lispref/frames.texi (Terminal Parameters): Fix typo.
* lisp/international/mule-util.el (char-displayable-p):
* lisp/startup.el (startup--setup-quote-display):
On a text terminal supporting glyph codes, use the reported
glyph codes instead of the terminal coding system, as this
is more accurate on the Linux console.
* lisp/startup.el (startup--setup-quote-display):
New optional arg STYLE.
* src/fontset.c (Finternal_char_font):
Report glyph codes for a text terminal, if they are available.
Currently this is supported only for the Linux console.
* src/termhooks.h (struct terminal): New member glyph-code-table.
* src/terminal.c [HAVE_LINUX_KD_H]: Include <errno.h>, <linux/kd.h>.
(calculate_glyph_code_table) [HAVE_LINUX_KD_H]: New function.
(terminal_glyph_code): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 21 | ||||
| -rw-r--r-- | src/termhooks.h | 6 | ||||
| -rw-r--r-- | src/terminal.c | 66 |
3 files changed, 85 insertions, 8 deletions
diff --git a/src/fontset.c b/src/fontset.c index 50fcc648548..f8334f16e55 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -1786,18 +1786,23 @@ update_auto_fontset_alist (Lisp_Object font_object, Lisp_Object fontset) | |||
| 1786 | } | 1786 | } |
| 1787 | } | 1787 | } |
| 1788 | 1788 | ||
| 1789 | /* Return a description of the font at POSITION in the current buffer. | ||
| 1790 | If the 2nd optional arg CH is non-nil, it is a character to check | ||
| 1791 | the font instead of the character at POSITION. | ||
| 1789 | 1792 | ||
| 1790 | /* Return a cons (FONT-OBJECT . GLYPH-CODE). | 1793 | For a graphical display, return a cons (FONT-OBJECT . GLYPH-CODE). |
| 1791 | FONT-OBJECT is the font for the character at POSITION in the current | 1794 | FONT-OBJECT is the font for the character at POSITION in the current |
| 1792 | buffer. This is computed from all the text properties and overlays | 1795 | buffer. This is computed from all the text properties and overlays |
| 1793 | that apply to POSITION. POSITION may be nil, in which case, | 1796 | that apply to POSITION. POSITION may be nil, in which case, |
| 1794 | FONT-SPEC is the font for displaying the character CH with the | 1797 | FONT-SPEC is the font for displaying the character CH with the |
| 1795 | default face. | 1798 | default face. GLYPH-CODE is the glyph code in the font to use for |
| 1799 | the character. | ||
| 1796 | 1800 | ||
| 1797 | GLYPH-CODE is the glyph code in the font to use for the character. | 1801 | For a text terminal, return a nonnegative integer glyph code for |
| 1798 | 1802 | the character, or a negative integer if the character is not | |
| 1799 | If the 2nd optional arg CH is non-nil, it is a character to check | 1803 | displayable. Terminal glyph codes are system-dependent integers |
| 1800 | the font instead of the character at POSITION. | 1804 | that represent displayable characters: for example, on a Linux x86 |
| 1805 | console they represent VGA code points. | ||
| 1801 | 1806 | ||
| 1802 | It returns nil in the following cases: | 1807 | It returns nil in the following cases: |
| 1803 | 1808 | ||
| @@ -1809,6 +1814,8 @@ update_auto_fontset_alist (Lisp_Object font_object, Lisp_Object fontset) | |||
| 1809 | (3) If POSITION is not nil, and the current buffer is not displayed | 1814 | (3) If POSITION is not nil, and the current buffer is not displayed |
| 1810 | in any window. | 1815 | in any window. |
| 1811 | 1816 | ||
| 1817 | (4) For a text terminal, the terminal does not report glyph codes. | ||
| 1818 | |||
| 1812 | In addition, the returned font name may not take into account of | 1819 | In addition, the returned font name may not take into account of |
| 1813 | such redisplay engine hooks as what used in jit-lock-mode if | 1820 | such redisplay engine hooks as what used in jit-lock-mode if |
| 1814 | POSITION is currently not visible. */ | 1821 | POSITION is currently not visible. */ |
| @@ -1860,7 +1867,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, | |||
| 1860 | if (! CHAR_VALID_P (c)) | 1867 | if (! CHAR_VALID_P (c)) |
| 1861 | return Qnil; | 1868 | return Qnil; |
| 1862 | if (!FRAME_WINDOW_P (f)) | 1869 | if (!FRAME_WINDOW_P (f)) |
| 1863 | return Qnil; | 1870 | return terminal_glyph_code (FRAME_TERMINAL (f), c); |
| 1864 | /* We need the basic faces to be valid below, so recompute them if | 1871 | /* We need the basic faces to be valid below, so recompute them if |
| 1865 | some code just happened to clear the face cache. */ | 1872 | some code just happened to clear the face cache. */ |
| 1866 | if (FRAME_FACE_CACHE (f)->used == 0) | 1873 | if (FRAME_FACE_CACHE (f)->used == 0) |
diff --git a/src/termhooks.h b/src/termhooks.h index 168bc3510fa..88c62df7205 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -383,6 +383,11 @@ struct terminal | |||
| 383 | the selection-values. */ | 383 | the selection-values. */ |
| 384 | Lisp_Object Vselection_alist; | 384 | Lisp_Object Vselection_alist; |
| 385 | 385 | ||
| 386 | /* If a char-table, this maps characters to terminal glyph codes. | ||
| 387 | If t, the mapping is not available. If nil, it is not known | ||
| 388 | whether the mapping is available. */ | ||
| 389 | Lisp_Object glyph_code_table; | ||
| 390 | |||
| 386 | /* All fields before `next_terminal' should be Lisp_Object and are traced | 391 | /* All fields before `next_terminal' should be Lisp_Object and are traced |
| 387 | by the GC. All fields afterwards are ignored by the GC. */ | 392 | by the GC. All fields afterwards are ignored by the GC. */ |
| 388 | 393 | ||
| @@ -690,6 +695,7 @@ extern struct terminal *get_named_terminal (const char *); | |||
| 690 | extern struct terminal *create_terminal (enum output_method, | 695 | extern struct terminal *create_terminal (enum output_method, |
| 691 | struct redisplay_interface *); | 696 | struct redisplay_interface *); |
| 692 | extern void delete_terminal (struct terminal *); | 697 | extern void delete_terminal (struct terminal *); |
| 698 | extern Lisp_Object terminal_glyph_code (struct terminal *, int); | ||
| 693 | 699 | ||
| 694 | /* The initial terminal device, created by initial_term_init. */ | 700 | /* The initial terminal device, created by initial_term_init. */ |
| 695 | extern struct terminal *initial_terminal; | 701 | extern struct terminal *initial_terminal; |
diff --git a/src/terminal.c b/src/terminal.c index b48d0623e12..15d74f4e812 100644 --- a/src/terminal.c +++ b/src/terminal.c | |||
| @@ -28,6 +28,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 28 | #include "coding.h" | 28 | #include "coding.h" |
| 29 | #include "keyboard.h" | 29 | #include "keyboard.h" |
| 30 | 30 | ||
| 31 | #ifdef HAVE_LINUX_KD_H | ||
| 32 | # include <errno.h> | ||
| 33 | # include <linux/kd.h> | ||
| 34 | #endif | ||
| 35 | |||
| 31 | /* Chain of all terminals currently in use. */ | 36 | /* Chain of all terminals currently in use. */ |
| 32 | struct terminal *terminal_list; | 37 | struct terminal *terminal_list; |
| 33 | 38 | ||
| @@ -193,7 +198,7 @@ ins_del_lines (struct frame *f, int vpos, int n) | |||
| 193 | } | 198 | } |
| 194 | 199 | ||
| 195 | /* Return the terminal object specified by TERMINAL. TERMINAL may | 200 | /* Return the terminal object specified by TERMINAL. TERMINAL may |
| 196 | be a terminal object, a frame, or nil for the terminal device of | 201 | ” be a terminal object, a frame, or nil for the terminal device of |
| 197 | the current frame. If TERMINAL is neither from the above or the | 202 | the current frame. If TERMINAL is neither from the above or the |
| 198 | resulting terminal object is deleted, return NULL. */ | 203 | resulting terminal object is deleted, return NULL. */ |
| 199 | 204 | ||
| @@ -526,6 +531,65 @@ selected frame's terminal). */) | |||
| 526 | return store_terminal_param (decode_live_terminal (terminal), parameter, value); | 531 | return store_terminal_param (decode_live_terminal (terminal), parameter, value); |
| 527 | } | 532 | } |
| 528 | 533 | ||
| 534 | #if HAVE_LINUX_KD_H | ||
| 535 | |||
| 536 | /* Compute the glyph code table for T. */ | ||
| 537 | |||
| 538 | static void | ||
| 539 | calculate_glyph_code_table (struct terminal *t) | ||
| 540 | { | ||
| 541 | Lisp_Object glyphtab = Qt; | ||
| 542 | enum { initial_unipairs = 1000 }; | ||
| 543 | int entry_ct = initial_unipairs; | ||
| 544 | struct unipair unipair_buffer[initial_unipairs]; | ||
| 545 | struct unipair *entries = unipair_buffer; | ||
| 546 | struct unipair *alloced = 0; | ||
| 547 | |||
| 548 | while (true) | ||
| 549 | { | ||
| 550 | int fd = fileno (t->display_info.tty->output); | ||
| 551 | struct unimapdesc unimapdesc = { entry_ct, entries }; | ||
| 552 | if (ioctl (fd, GIO_UNIMAP, &unimapdesc) == 0) | ||
| 553 | { | ||
| 554 | glyphtab = Fmake_char_table (Qnil, make_number (-1)); | ||
| 555 | for (int i = 0; i < unimapdesc.entry_ct; i++) | ||
| 556 | char_table_set (glyphtab, entries[i].unicode, | ||
| 557 | make_number (entries[i].fontpos)); | ||
| 558 | break; | ||
| 559 | } | ||
| 560 | if (errno != ENOMEM) | ||
| 561 | break; | ||
| 562 | entry_ct = unimapdesc.entry_ct; | ||
| 563 | entries = alloced = xrealloc (alloced, entry_ct * sizeof *alloced); | ||
| 564 | } | ||
| 565 | |||
| 566 | xfree (alloced); | ||
| 567 | t->glyph_code_table = glyphtab; | ||
| 568 | } | ||
| 569 | #endif | ||
| 570 | |||
| 571 | /* Return the glyph code in T of character CH, or -1 if CH does not | ||
| 572 | have a font position in T, or nil if T does not report glyph codes. */ | ||
| 573 | |||
| 574 | Lisp_Object | ||
| 575 | terminal_glyph_code (struct terminal *t, int ch) | ||
| 576 | { | ||
| 577 | #if HAVE_LINUX_KD_H | ||
| 578 | if (t->type == output_termcap) | ||
| 579 | { | ||
| 580 | /* As a hack, recompute the table when CH is the maximum | ||
| 581 | character. */ | ||
| 582 | if (NILP (t->glyph_code_table) || ch == MAX_CHAR) | ||
| 583 | calculate_glyph_code_table (t); | ||
| 584 | |||
| 585 | if (! EQ (t->glyph_code_table, Qt)) | ||
| 586 | return char_table_ref (t->glyph_code_table, ch); | ||
| 587 | } | ||
| 588 | #endif | ||
| 589 | |||
| 590 | return Qnil; | ||
| 591 | } | ||
| 592 | |||
| 529 | /* Initial frame has no device-dependent output data, but has | 593 | /* Initial frame has no device-dependent output data, but has |
| 530 | face cache which should be freed when the frame is deleted. */ | 594 | face cache which should be freed when the frame is deleted. */ |
| 531 | 595 | ||