unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#62265: Underline does not work in Terminal Emacs
@ 2023-03-18 17:40 Mohsin Kaleem
  2023-03-18 17:51 ` Mohsin Kaleem
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Mohsin Kaleem @ 2023-03-18 17:40 UTC (permalink / raw)
  To: 62265

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]


Hi,

Underline support for tty frames was added to Emacs back in the Emacs
28.0.90 release. It hasn't worked for me since. Today I tried
investigating why. I tracked it down ncurses and discovered the tgetstr
function to retrieve the escape sequence for underline support doesn't
fetch the value configured in the terminfo database for my Terminal
(st). I can reproduce this function failing to fetch the entry in a
minimal sample program (code attached).


[-- Attachment #2: Sample program that fails to get smxx --]
[-- Type: text/plain, Size: 390 bytes --]

#include <stdio.h>
#include <curses.h>
#include <term.h>

int main() {
    curses_trace(TRACE_MAXIMUM);

    const char* term = "tmux-24bit";
    char buffer[4096];
    if (tgetent(buffer, term) <= 0) {
        printf("Failed");
        return 1;
    }

    char *area = NULL;
    char **address = &area;
    char * it = tgetstr("smxx", address);
    printf("p: %p\n", it);
    return 0;
}

[-- Attachment #3: Type: text/plain, Size: 734 bytes --]


The cause for this seems to be in ncurses directly. In the definition of
tgetstr in lib_termcap.c there's a check for ValidExt for any
non-standard terminfo entries. This macro fails when fetching an entry
that is longer than 2 characters, meaning tgetstr for "smxx" fails and I
get no underlines. I've managed to fix this by using tigetstr in-place
of tgetstr (this variant is also used for querying the setf24 and setb24
termcaps already in "term.c" so I suspect this is a known issue). I'm
not sure what the termcap library does but I'm guessing it doesn't have
this restriction.

Please fix this by switching to tigetstr instead of tgetstr for this
record when building with terminfo. I've got a sample patch for this
attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: fix-underline.patch --]
[-- Type: text/x-patch, Size: 623 bytes --]

diff --git a/src/term.c b/src/term.c
index d881dee39fe..a2d1743bdad 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4163,7 +4163,11 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
   tty->TS_enter_alt_charset_mode = tgetstr ("as", address);
   tty->TS_exit_alt_charset_mode = tgetstr ("ae", address);
   tty->TS_exit_attribute_mode = tgetstr ("me", address);
+#ifdef TERMINFO
+  tty->TS_enter_strike_through_mode = tigetstr ("smxx");
+#else
   tty->TS_enter_strike_through_mode = tgetstr ("smxx", address);
+#end
 
   MultiUp (tty) = tgetstr ("UP", address);
   MultiDown (tty) = tgetstr ("DO", address);

[-- Attachment #5: Type: text/plain, Size: 19 bytes --]


-- 
Mohsin Kaleem

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-04-16  6:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-18 17:40 bug#62265: Underline does not work in Terminal Emacs Mohsin Kaleem
2023-03-18 17:51 ` Mohsin Kaleem
2023-03-18 17:55 ` Eli Zaretskii
2023-03-18 18:50   ` Jim Porter
2023-03-19 10:07     ` Mohsin Kaleem
2023-03-19 11:37       ` Eli Zaretskii
2023-03-19 11:51         ` Mohsin Kaleem
2023-03-19 12:24           ` Eli Zaretskii
2023-04-16  6:22             ` Eli Zaretskii
2023-03-18 18:01 ` Eli Zaretskii
2023-03-18 18:07   ` Mohsin Kaleem

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).