Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

[SOLVED] ncurses box not rendered properly in st with tmux

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
11 posts • Page 1 of 1
Author
Message
bstaletic
Guru
Guru
Posts: 517
Joined: Sat Apr 05, 2014 5:46 pm

[SOLVED] ncurses box not rendered properly in st with tmux

  • Quote

Post by bstaletic » Thu Oct 17, 2024 7:11 am

Recently I have noticed that ncurses boxes, like in alsamixes or kernel's menuconfig use a wrong character for horizontal lines.

That's the kind of "box" ncurses displays. Everything else is working, so alsamixer is functional.
It's just very distracting.

I say I have noticed recently, but I don't open alsamixer or kernel menuconfig every day...
However, there was one significant change on my machine that I can think of. I've added -flto -fgraphite-identity to my CFLAGS in make.conf
On my machine the simplest ncurses box reproduces the problem:

Code: Select all

#include <ncurses.h>

int main() {
	initscr();
	refresh();
	WINDOW *win = newwin(3, 10, 2, 2);
	box(win, 0 , 0);
	wrefresh(win);
	getch();
	endwin();
}
On my system, the above displays

Code: Select all

  ┌─qqqqqqq┐
  │        │
  └─qqqqqqq┘
I'm running this in x11-terms/st, running a tmux session, with TERM set to xterm-256color.
Any of the following fixes the problem:
  • Changing to a different terminal, including tty2.
  • Changing TERM to st-256color
  • Not using tmux
So only if TERM=xterm-256color, inside st, inside xterm does the problem manifest.
Usually, I'd just change the tmux config to set st-256color, but that feels wrong and not setting it worked for so many years.
Last edited by bstaletic on Thu Oct 17, 2024 3:12 pm, edited 1 time in total.
Top
bstaletic
Guru
Guru
Posts: 517
Joined: Sat Apr 05, 2014 5:46 pm

  • Quote

Post by bstaletic » Thu Oct 17, 2024 8:47 am

I've tried recompiling tmux, ncurses and st without -flto -fgraphite-identity.
Didn't help.

I'm running out of ideas...
Top
logrusx
Advocate
Advocate
User avatar
Posts: 3537
Joined: Thu Feb 22, 2018 2:29 pm

  • Quote

Post by logrusx » Thu Oct 17, 2024 10:01 am

It has something to do with the encoding/font. Do you use it in a FB console, a graphical VT or ssh(possibly in a FB console and graphical VT)?

I've seen it where multi-language support is involved. I've seen it to the extent I wouldn't pay attention to it if it appeared right now.

First thing to check is your locale:

Code: Select all

# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Of course my native language is not English, but I've set it up only in the graphic environment where I'll most likely use it in the browser or while editing documents, but likely not anywhere else. My consoles are natively English. The FB console and the graphical VT. I've tried to add my native language but it's awkward for me to read system messages in my native language.

Leave your CFLAGS alone, they won't help with the above.

Best Regards,
Georgi
Top
bstaletic
Guru
Guru
Posts: 517
Joined: Sat Apr 05, 2014 5:46 pm

  • Quote

Post by bstaletic » Thu Oct 17, 2024 11:19 am

@logrusx
Thanks for the response.

Code: Select all

LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
logrusx wrote:Leave your CFLAGS alone, they won't help with the above.
Deal!
logrusx wrote:Do you use it in a FB console, a graphical VT or ssh(possibly in a FB console and graphical VT)?
Noticed it in a graphical VT first.
By now I've tried switching to tty2 and trying there.
So the constants are: tmux, TERM=xterm-256color and... no, that's it. The x11-term/st was a red herring.

Code: Select all

en_US.UTF-8 UTF-8

Code: Select all

# Vi copypame mode
set-window-option -g mode-keys vi

set-option -g prefix 'C-\'
bind-key 'C-\' last-window

# Keep cwd when creating a new tab
unbind c
bind-key c new-window -c "#{pane_current_path}"

# hjkl pane traversal
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Terminal
#set -g default-terminal "xterm-256color"

# Split
unbind v
bind v split-window -h -c "#{pane_current_path}"
unbind s
unbind b
bind s split-window -v -c "#{pane_current_path}"

# Allows for faster key repetition
set -s escape-time 0

# reload config
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."

# Don't start login shell
set -g default-command "${SHELL}"

# Window resize
bind H resize-pane -L 5
bind L resize-pane -R 5
bind J resize-pane -D 5
bind K resize-pane -U 5

# No confirm on kill-pane
unbind x
bind x kill-pane

# Status
#set -g status-bg black
set -g status-bg '#262626'
set -g status-fg '#87875f'
set -g status-justify centre # center align window list
set -g status-interval 1
set -g status-left '#H'
set -g status-right '%R'

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h"  "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j"  "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k"  "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l"  "select-pane -R"
#bind-key -n C-\ if-shell "$is_vim" "send-keys C-\" "select-pane -l"
logrusx wrote:I've tried to add my native language but it's awkward for me to read system messages in my native language.
Yeah, tell me about it. Especially if, like mine, your native language does not necessarily use the latin script.
Top
logrusx
Advocate
Advocate
User avatar
Posts: 3537
Joined: Thu Feb 22, 2018 2:29 pm

  • Quote

Post by logrusx » Thu Oct 17, 2024 12:41 pm

I have en_US ISO-8859-1 as well in my locale.gen. It works fine under Gnome Terminal as well as in FB console. Xterm-256color here too. I can't comment the tmux config as I don't understand it...

But I'm pretty certain it boils down to some kind of localization/multi-language support. If my memory serves me right, I've seen this kind of behavior in PuTTY and remote logins.

Actually I took your tmux.conf and I still see no problem.

Best Regards,
Georgi
Top
bstaletic
Guru
Guru
Posts: 517
Joined: Sat Apr 05, 2014 5:46 pm

  • Quote

Post by bstaletic » Thu Oct 17, 2024 1:02 pm

logrusx wrote:I have en_US ISO-8859-1 as well in my locale.gen.
I have just tried adding it.
No change in behaviour.

I have not touched locale config in years. Like I said, the only major change recently was enabling LTO everywhere...
Top
logrusx
Advocate
Advocate
User avatar
Posts: 3537
Joined: Thu Feb 22, 2018 2:29 pm

  • Quote

Post by logrusx » Thu Oct 17, 2024 1:07 pm

bstaletic wrote:
logrusx wrote:I have en_US ISO-8859-1 as well in my locale.gen.
I have just tried adding it.
No change in behaviour.

I have not touched locale config in years. Like I said, the only major change recently was enabling LTO everywhere...
Well, maybe something got rebuilt in relationship to that. Try looking for something relevant in emerge -pve ncurses output. That's the best I can do about your issue, sorry.

Until now I excluded the font problem route, because I didn't believe that it could be the problem, but it might be worth exploring in that direction too.

Best Regards,
Georgi
Top
Goverp
Advocate
Advocate
User avatar
Posts: 2404
Joined: Wed Mar 07, 2007 6:41 pm

  • Quote

Post by Goverp » Thu Oct 17, 2024 1:36 pm

This problem seems to be common:
https://stackoverflow.com/questions/848 ... d-of-lines
Greybeard
Top
bstaletic
Guru
Guru
Posts: 517
Joined: Sat Apr 05, 2014 5:46 pm

  • Quote

Post by bstaletic » Thu Oct 17, 2024 1:58 pm

I am not sure what solved it, but these things happened:
  • Recompiled tmux and ncurses without -flto -fgraphite-identity
  • Added en_US.iso88591 to locale.gen and selected... en_US
  • Restarted the machine
I'm not marking this as SOLVED just yet. There aren't many steps taken. Surely I can figure out what went not quite right.

EDIT: Forgot the most important thing that changed on my system - I stopped setting TERM to xterm-256color and just let tmux figure it out.
It sets screen-256color which works fine.
Top
bstaletic
Guru
Guru
Posts: 517
Joined: Sat Apr 05, 2014 5:46 pm

  • Quote

Post by bstaletic » Thu Oct 17, 2024 3:44 pm

I know this is a double post, but I do think this should be more visible than a simple edit.

Here's the actual problem:
https://github.com/tmux/tmux/issues/4182

So tmux v3.5 with TERM set to xterm has a problem since commit de6bbce0.
This was fixed in this commit: https://github.com/tmux/tmux/commit/934 ... 78e9c8756d
I will be making a gentoo bug report to possibly backport the commit.
Top
logrusx
Advocate
Advocate
User avatar
Posts: 3537
Joined: Thu Feb 22, 2018 2:29 pm

  • Quote

Post by logrusx » Thu Oct 17, 2024 3:51 pm

It's good that you were able to find the root cause of the problem.

It would be good if you file a bug, yes.

Best Regards,
Georgi
Top
Post Reply

11 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic