* How to set background-color without damaging cut&paste ?
@ 2024-09-03 23:28 Peter
2024-09-04 11:40 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Peter @ 2024-09-03 23:28 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I'm using xterm. I want to set the background to paperwhite.
I tried this, but it makes cut&paste unuseable:
(unless (display-graphic-p)
(if (string-equal (getenv "TERM") "xterm-256color")
(add-to-list 'default-frame-alist '(background-color . "brightwhite"))
(add-to-list 'default-frame-alist '(background-color . "white")))
)
Then, given a file with this content:
First Line
Second Line
Without the color setting, I can move the mouse over the first line,
click thrice and hold to the second line; then middle-click into a
hexdumper gives this:
00000000 46 69 72 73 74 20 4c 69 6e 65 0a 53 65 63 6f 6e |First Line.Secon|
00000010 64 20 4c 69 6e 65 0a |d Line.|
However, after setting the background-color, the result is this:
00000000 46 69 72 73 74 20 4c 69 6e 65 20 20 20 20 20 20 |First Line |
00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000050 0a 53 65 63 6f 6e 64 20 4c 69 6e 65 20 20 20 20 |.Second Line |
00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000070 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000080 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000090 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
000000a0 20 0a | .|
It basically fills the remainder from eol to the window-border
with spaces.
Is there an other means to set the color?
I could send an ansi sequence in advance, but then how do I get the
original color back later?
emacs is 29.4,3, compiled with
ACL : off
GNUTLS : off
JSON : off
KQUEUE : off
MAILUTILS : off
MODULES : on
NATIVECOMP : off
SOURCES : off
SQLITE3 : off
THREADS : off
TREESITTER : on
XML : off
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to set background-color without damaging cut&paste ?
2024-09-03 23:28 How to set background-color without damaging cut&paste ? Peter
@ 2024-09-04 11:40 ` Eli Zaretskii
2024-09-04 12:41 ` Yuri Khan
2024-09-09 13:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2024-09-04 11:40 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 4 Sep 2024 01:28:08 +0200
> From: Peter <pmc@citylink.dinoex.sub.org>
>
> Hi,
>
> I'm using xterm. I want to set the background to paperwhite.
>
> I tried this, but it makes cut&paste unuseable:
>
> (unless (display-graphic-p)
> (if (string-equal (getenv "TERM") "xterm-256color")
> (add-to-list 'default-frame-alist '(background-color . "brightwhite"))
> (add-to-list 'default-frame-alist '(background-color . "white")))
> )
>
> Then, given a file with this content:
>
> First Line
> Second Line
>
> Without the color setting, I can move the mouse over the first line,
> click thrice and hold to the second line; then middle-click into a
> hexdumper gives this:
>
> 00000000 46 69 72 73 74 20 4c 69 6e 65 0a 53 65 63 6f 6e |First Line.Secon|
> 00000010 64 20 4c 69 6e 65 0a |d Line.|
>
> However, after setting the background-color, the result is this:
>
> 00000000 46 69 72 73 74 20 4c 69 6e 65 20 20 20 20 20 20 |First Line |
> 00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000050 0a 53 65 63 6f 6e 64 20 4c 69 6e 65 20 20 20 20 |.Second Line |
> 00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000070 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000080 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000090 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 000000a0 20 0a | .|
>
> It basically fills the remainder from eol to the window-border
> with spaces.
>
> Is there an other means to set the color?
I think it doesn't matter. What you seem to see is xterm's effort to
give you background-colored whitespace when the background is
different from the default colors. The mouse clicks are processed by
xterm in this case, not by Emacs.
IOW, I think this is a question for xterm developers.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to set background-color without damaging cut&paste ?
2024-09-03 23:28 How to set background-color without damaging cut&paste ? Peter
2024-09-04 11:40 ` Eli Zaretskii
@ 2024-09-04 12:41 ` Yuri Khan
2024-09-04 13:51 ` Peter
2024-09-04 14:33 ` Peter
2024-09-09 13:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 2 replies; 7+ messages in thread
From: Yuri Khan @ 2024-09-04 12:41 UTC (permalink / raw)
To: Peter; +Cc: help-gnu-emacs
On Wed, 4 Sept 2024 at 06:37, Peter <pmc@citylink.dinoex.sub.org> wrote:
> However, after setting the background-color, the result is this:
>
> 00000000 46 69 72 73 74 20 4c 69 6e 65 20 20 20 20 20 20 |First Line |
> 00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
> 00000040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
You’re getting the default mouse selection handling by your terminal
emulator, which is not guaranteed to be correct for full-screen
applications.
Example: if you enable ‘toggle-truncate-lines’ and have several
adjacent lines that are too wide for the terminal window, the terminal
emulator will highlight and copy only the displayed parts of the
lines.
Consider enabling xterm-mouse-mode.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to set background-color without damaging cut&paste ?
2024-09-04 12:41 ` Yuri Khan
@ 2024-09-04 13:51 ` Peter
2024-09-04 14:33 ` Peter
1 sibling, 0 replies; 7+ messages in thread
From: Peter @ 2024-09-04 13:51 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs
On Wed, Sep 04, 2024 at 07:41:02PM +0700, Yuri Khan wrote:
! On Wed, 4 Sept 2024 at 06:37, Peter <pmc@citylink.dinoex.sub.org> wrote:
!
! > However, after setting the background-color, the result is this:
! >
! > 00000000 46 69 72 73 74 20 4c 69 6e 65 20 20 20 20 20 20 |First Line |
! > 00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
! > 00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
! > 00000030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
! > 00000040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
!
! You’re getting the default mouse selection handling by your terminal
! emulator, which is not guaranteed to be correct for full-screen
! applications.
This sounds strange - why should the default mouse selection handling
be dependent on the individual text color?
The issue does not only happen with background-color. It does also
happen when using 'conf-mode' (and probably others with syntax
highlighting). In that case it depends on the actual color of the
text: some lines are filled with trailing spaces, some are not.
! Example: if you enable ‘toggle-truncate-lines’ and have several
! adjacent lines that are too wide for the terminal window, the terminal
! emulator will highlight and copy only the displayed parts of the
! lines.
This is known and accepted; overly long lines need manual treatment
with copy/paste. But dangling spaces on correctly formatted lines,
i.e. after a terminating backslash denoting a line continuation,
result in really bad malfunctions and are not easily detected.
! Consider enabling xterm-mouse-mode.
I tried this already. Sadly, either I don't understand it or it does
not work at all.
The usecase here is that I have dozens of nodes in different parts
of the world. All of them can be opened in xterms. So opening them
side by side, one can easily compare config files and copy/paste
snippets from one to another.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to set background-color without damaging cut&paste ?
2024-09-04 12:41 ` Yuri Khan
2024-09-04 13:51 ` Peter
@ 2024-09-04 14:33 ` Peter
2024-09-04 14:43 ` Eli Zaretskii
1 sibling, 1 reply; 7+ messages in thread
From: Peter @ 2024-09-04 14:33 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs
On Wed, Sep 04, 2024 at 07:41:02PM +0700, Yuri Khan wrote:
! You’re getting the default mouse selection handling by your terminal
! emulator, which is not guaranteed to be correct for full-screen
! applications.
I think I figured it out a bit further.
Syntax higlighting in C:
/* bla bla <line is filled with spaces>
* <line is filled with spaces>
*/ <line is correctly terminated!>
main() <line is correctly terminated!>
{ <line is correctly terminated!>
} <line is correctly terminated!>
So what is the difference with the first two lines? They are comments
- and comments do not end until end-of-line!
The third line is different, it is also a comment, but it ends - and
therefore it is copied correctly!
Somebody inside emacs did not bother to tell the curses library
where these comments do actually end. Because it seems irrelevant, as
anything subsequent on these lines will still be a comment.
The curses library, however, is a honest servant and tells the very
same to the X cutbuffer: this line doesn't end.
And the cutbuffer then does what it is supposed to do: collect all
the trailing spaces and add them to the line.
I might assume something similar is done with the background-color
setting: just not telling curses that (and where!) this line has an
end.
So, for now I refrain from setting background-color, and also set
(global-font-lock-mode 0)
which, I assume, should disable the entire color magic and get
us back to the good old times of monochrome screens.
But I would greatly appreciate if we could get this fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to set background-color without damaging cut&paste ?
2024-09-04 14:33 ` Peter
@ 2024-09-04 14:43 ` Eli Zaretskii
0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2024-09-04 14:43 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 4 Sep 2024 16:33:20 +0200
> From: Peter <pmc@citylink.dinoex.sub.org>
> Cc: help-gnu-emacs@gnu.org
>
> I think I figured it out a bit further.
>
> Syntax higlighting in C:
>
>
> /* bla bla <line is filled with spaces>
> * <line is filled with spaces>
> */ <line is correctly terminated!>
> main() <line is correctly terminated!>
> { <line is correctly terminated!>
> } <line is correctly terminated!>
>
>
> So what is the difference with the first two lines? They are comments
> - and comments do not end until end-of-line!
>
> The third line is different, it is also a comment, but it ends - and
> therefore it is copied correctly!
>
> Somebody inside emacs did not bother to tell the curses library
> where these comments do actually end. Because it seems irrelevant, as
> anything subsequent on these lines will still be a comment.
>
> The curses library, however, is a honest servant and tells the very
> same to the X cutbuffer: this line doesn't end.
>
> And the cutbuffer then does what it is supposed to do: collect all
> the trailing spaces and add them to the line.
>
> I might assume something similar is done with the background-color
> setting: just not telling curses that (and where!) this line has an
> end.
>
>
> So, for now I refrain from setting background-color, and also set
> (global-font-lock-mode 0)
> which, I assume, should disable the entire color magic and get
> us back to the good old times of monochrome screens.
>
> But I would greatly appreciate if we could get this fixed.
There's nothing to fix, because this is a feature: many faces have
their colors extended all the way to the edge of the window. This is
what users expect. For example, if the region spans more than one
line, then users expect the empty space at the right of the lines to
have the background color of the region face.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to set background-color without damaging cut&paste ?
2024-09-03 23:28 How to set background-color without damaging cut&paste ? Peter
2024-09-04 11:40 ` Eli Zaretskii
2024-09-04 12:41 ` Yuri Khan
@ 2024-09-09 13:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-09-09 13:24 UTC (permalink / raw)
To: help-gnu-emacs
> I'm using xterm. I want to set the background to paperwhite.
Maybe a simple solution to your problem is to change the background
color for all of your xterms rather than only for those that are
currently displaying an Emacs session.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-09-09 13:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 23:28 How to set background-color without damaging cut&paste ? Peter
2024-09-04 11:40 ` Eli Zaretskii
2024-09-04 12:41 ` Yuri Khan
2024-09-04 13:51 ` Peter
2024-09-04 14:33 ` Peter
2024-09-04 14:43 ` Eli Zaretskii
2024-09-09 13:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
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).