EdisonWangB / pcmanx-gtk2

Automatically exported from code.google.com/p/pcmanx-gtk2
GNU General Public License v2.0
0 stars 0 forks source link

Using AttrType (short) to cast CTernCharAttr will cause a problem in copy-text-with-color with DBCS words #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Select one section or line including colored DBCS words.
2. Right-click and choose "Copy (With ANSI color)"
3. Paste and you'll find that each color will just decorate the first byte of 
the same-color section, and there are many "\033[m" between each DBCS word's 
first byte and second byte.

What is the expected output? What do you see instead?
see here: http://ppt.cc/flKd (screenshot)
http://ppt.cc/Bn;u (screenshot)

What version of the product are you using? On what operating system?
0.3.9
the current version on the svn, but early versions have the same problem.
I use ubuntu 10.04. (amd64)

Please provide any additional information below.
The problem was caused by CTermCharAttr::IsSameAttr() (in termdata.cpp/h)
For DBCS words, the attribute m_CharSets was different in the first-byte DBCS 
word and second-byte DBCS word (which is 1, 2). IsSameAttr() tried to make the 
two CTermCharAttr's m_CharSet and m_NeedUpdate the same before comparing their 
"short value", but I found that the "short value" of the two would not be equal 
even if the two word just were different in "m_CharSet" and IsSameAttr() did 
the preparing work to make that same.

It might be that the actual byte order in the class caused this problem. So 
using another way (e.g. directly compare data members of the two) to check if 
charcters' attributes are the same will be a better idea.

By the way, if didn't #define USE_IPLOOKUP, there are actually "7 bits" in the 
second bytes in class CTermCharAttr. (However, I added 1-bit padding manually 
but can't resolve this problem)

In the patch, I removed the old IsSameAttr and use operator == to implement the 
same-attribute check. Although it looks more stupid to compare almost every 
members but it's more safe to work on different systems. 

Original issue reported on code.google.com by hrs113...@gmail.com on 23 Oct 2010 at 4:31

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by fourdollars on 25 Oct 2010 at 8:36

GoogleCodeExporter commented 8 years ago

Original comment by fourdollars on 25 Oct 2010 at 8:39

GoogleCodeExporter commented 8 years ago
This patch is merged into https://pcmanx-gtk2.googlecode.com/svn/trunk@526
Thanks for your effort.

Original comment by fourdollars on 25 Oct 2010 at 8:43