Bug 169013 - xterm256 color palette not compatible with standard xterm
Summary: xterm256 color palette not compatible with standard xterm
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-13 05:16 UTC by pan shi zhu
Modified: 2009-01-12 03:29 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
tested patch for konsole in kde 3.5.10 (702 bytes, patch)
2008-11-14 03:58 UTC, pan shi zhu
Details
patch for konsole in kde 4.1.2, also works for 4.2 series (712 bytes, patch)
2008-11-14 03:59 UTC, pan shi zhu
Details
use this to check the 256color output vs other terminal (18.34 KB, text/plain)
2008-11-14 04:03 UTC, pan shi zhu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pan shi zhu 2008-08-13 05:16:46 UTC
Version:            (using KDE 4.1.0)
Installed from:    Compiled From Sources
OS:                Linux

from KDE3.5.6 the konsole adds xterm256 support, however, it is using a different palette from the stardard xterm. In my opinion this is a bug rather than a feature.

Rationale 1: konsole report itself as TERM=xterm, so the palette should behave like the standard xterm.
Rationale 2: the xterm256 color palette actually represent more natural colors in visible color space.
Rationale 3: xterm, gnome-terminal, xfce4-terminal and putty all use the same palette, konsole seems to be the only exception.

I had done the patch for both KDE3 and KDE4, the patched konsole works great since the xterm256 is much more useful with the standard xterm palette.
Comment 1 pan shi zhu 2008-08-13 05:21:39 UTC
my patch for KDE3.5.6:
diff -c TECommon.h.orig TECommon.h
*** TECommon.h.orig     2008-08-13 11:18:32.000000000 +0800
--- TECommon.h  2008-08-13 11:18:14.000000000 +0800
***************
*** 153,161 ****
    if (u <   8) return base[u+2+BASE_COLORS].color; u -= 8;

    //  16..231: 6x6x6 rgb color cube
!   if (u < 216) return QColor(255*((u/36)%6)/5,
!                              255*((u/ 6)%6)/5,
!                              255*((u/ 1)%6)/5); u -= 216;

    // 232..255: gray, leaving out black and white
    int gray = u*10+8; return QColor(gray,gray,gray);
--- 153,161 ----
    if (u <   8) return base[u+2+BASE_COLORS].color; u -= 8;

    //  16..231: 6x6x6 rgb color cube
!   if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,
!                              ((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,
!                              ((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0); u -= 216;

    // 232..255: gray, leaving out black and white
    int gray = u*10+8; return QColor(gray,gray,gray);
Comment 2 pan shi zhu 2008-08-13 05:28:31 UTC
my patch for KDE 4.1.0:
diff -c CharacterColor.h.orig CharacterColor.h
*** CharacterColor.h.orig       2008-08-13 11:25:19.000000000 +0800
--- CharacterColor.h    2008-08-13 11:26:24.000000000 +0800
***************
*** 244,253 ****
    if (u <   8) return base[u+2+BASE_COLORS].color; u -= 8;

    //  16..231: 6x6x6 rgb color cube
!   if (u < 216) return QColor(255*((u/36)%6)/5,
!                              255*((u/ 6)%6)/5,
!                              255*((u/ 1)%6)/5); u -= 216;
!
    // 232..255: gray, leaving out black and white
    int gray = u*10+8; return QColor(gray,gray,gray);
  }
--- 244,253 ----
    if (u <   8) return base[u+2+BASE_COLORS].color; u -= 8;

    //  16..231: 6x6x6 rgb color cube
!   if (u < 216) return QColor(((u/36)%6) ? (40*((u/36)%6)+55) : 0,
!                              ((u/ 6)%6) ? (40*((u/ 6)%6)+55) : 0,
!                              ((u/ 1)%6) ? (40*((u/ 1)%6)+55) : 0); u -= 216;
!
    // 232..255: gray, leaving out black and white
    int gray = u*10+8; return QColor(gray,gray,gray);
  }
Comment 3 Robert Knight 2008-09-19 13:42:44 UTC
Hi Pan,

Thank-you for the patch.  I'm sorry I haven't reviewed it yet.  Please keep pinging me if I forget.
Comment 4 pan shi zhu 2008-11-13 06:39:00 UTC
What is the preferred format of patch here? I'll test my patch in the newest version of KDE and (if necessary) upload patches as attachment here.

I hope the patch could get into KDE 4.2, will it get reviewed soon?

Comment 5 Robert Knight 2008-11-13 08:23:29 UTC
> What is the preferred format of patch here?

Unified diff (as in 'diff -u') please.
Comment 6 pan shi zhu 2008-11-14 03:58:19 UTC
Created attachment 28560 [details]
tested patch for konsole in kde 3.5.10
Comment 7 pan shi zhu 2008-11-14 03:59:21 UTC
Created attachment 28561 [details]
patch for konsole in kde 4.1.2, also works for 4.2 series
Comment 8 pan shi zhu 2008-11-14 04:03:22 UTC
Created attachment 28562 [details]
use this to check the 256color output vs other terminal


I had tested the patch and generated the patch in diff -u format.

This python program can help for test, the output should pixel-to-pixel match the output from terminals others than konsole.
Comment 9 Nick Shaforostoff 2009-01-12 00:59:36 UTC
@Konsole Developers: any reaction?
Comment 10 pan shi zhu 2009-01-12 03:14:11 UTC
@Nick Shaforostoff
Robert Knight saids that "Keep pinging me", so let's just keep pinging him.

If you want the patch just use mine, I have be using my patch for more than 6 months and it works great so far.

My patch works for the 3.5.x, 4.1.x and 4.2 snapshot.

Comment 11 Robert Knight 2009-01-12 03:25:22 UTC
SVN commit 909719 by knight:


Use the same palette as xterm for 256-color mode.
Patch by pan.shizhu@gmail.com

BUG: 169013



 M  +3 -3      CharacterColor.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=909719
Comment 12 Robert Knight 2009-01-12 03:25:53 UTC
Thanks pan - sorry for the delay.
Comment 13 Robert Knight 2009-01-12 03:29:06 UTC
SVN commit 909720 by knight:

Backport.  Use the same palette as xterm for 256-color mode. 

Patch by pan.shizhu@gmail.com 

CCBUG: 169013



 M  +3 -3      CharacterColor.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=909720