kvirc / KVIrc

The KVIrc IRC Client
http://www.kvirc.net/
GNU General Public License v2.0
232 stars 76 forks source link

KVIInputEditor/KviTopicWidget: Can not edit end of a string where control codes applied (text width calculated incorrectly) #1881

Closed un1versal closed 8 years ago

un1versal commented 8 years ago

Originally reported by @VFiber over at IRC. 4 days ago.

If a really long block of text exists with formatting (colors/bold etc) and you want to edit it by double clicking it inn topic bar or write into input line, no matter how much you press → on keyboard You wont be able to reach the end.

Requirements to duplicate: A really long sentence with colors/bold

Maye this will work. the color codes/bold wouldnt paste in here but the topic below even on the input line you couldnt see the end when pasting the topic in input line.

e.g. FAILS due to the kvirc color/formatiing codes


9~~Welcome to blablabla - Some other funky words- __ Because we can write a really long topic - TO SCREW THIS UP!!!__ | Visit the IRC Channel __ 15Try this - Crazy List <ITAM A> - THIS OTHER - ITEM B ~~ 9 /j #SOMECRAZYIRC-CHAN for Chat, Help, and BANANA MUESLY!!! __ All INFORMATION On this really long topic can be found at https://wwwthisisatopicthatwonwork.com
KVIrc 4.9.1 'Aria'

Runtime Info:
System name: Linux 3.13.0-76-generic
System version: #120-Ubuntu SMP Mon Jan 18 15:59:10 UTC 2016
Architecture: x86_64
Qt version: 5.2.1
Qt theme: fusion

Build Info:
Build date: 2016-02-21 21:25:48 UTC
Sources date: 20160102
Revision number: git-6240-gaedefa9
System name: Linux-3.13.0-76-generic
CPU name: x86_64
Build command: /usr/bin/cmake
Build flags: 
   MANDIR=man
   CMAKE_INSTALL_PREFIX=/usr
   LIB_SUFFIX=/x86_64-linux-gnu
   Threads=POSIX
Compiler name: /usr/bin/c++
Compiler flags: N/A
Qt version: 5.2.1
VFiber commented 8 years ago

It seems it affects every input field where control codes are allowed (topic and chan single line input as well).

Investigated a bit but couldn't find a solution (however I think I was able to isolate the problem).

If the text is wider than the displayed editor any control code char pushes the width wider than it can be scrolled if we are at the end of the text (does not scroll to the end of the string correctly, characters and the cursor "slips" under the control buttons).

A wild guess: probably the text bounding rect doesn't count with the invisible control chars (CC), but since the draw itself is overridden with https://github.com/kvirc/KVIrc/blob/master/src/kvirc/ui/KviInputEditor.cpp#L835 and the CC's are painted directly into the widget, the bounding rect calculated incorrectly. Solution could be overriding the correct QWidget method that handles this kind of calculations, but I am not that familiar with Qt to figure out which one.

un1versal commented 8 years ago

It seems it affects every input field where control codes are allowed (topic and chan single line input as well).

Confirmed

No idea what solution is, but this is basic functionality that must be fixed before any final release is made.

Heufneutje commented 8 years ago

Probably the same issue as https://github.com/kvirc/KVIrc/issues/1849

un1versal commented 8 years ago

it is, but the issue also applies to the main single input line (and where formating can be added). So this is indeed a duplicate.

Thx @Heufneutje will correct shortly as need to edit your report.


Closing Duplicate of #1849