Tk Source Code

View Ticket
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: a34b49f8c63aeb7736f48eba24b256158aaff022
Title: Revised [text]: (textDisp-2.26 and 24.24) tag -tabs does not work properly
Type: Bug Version: 8.6.6, revised_text
Submitter: bll Created on: 2017-06-25 18:44:49
Subsystem: 18. [text] Assigned To: gcramer
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2021-07-14 15:44:28
Resolution: None Closed By: nobody
    Closed on: 2017-08-09 16:47:58
Description:
Linux:
Fails in 8.6.6.
This is related to test textDisp-2.26.

% package require Tk
8.6.6
% text .z -height 5
.z
% .z configure -font "{Courier New} -12"
% pack .z
% .z insert end "a\tb\tc\td\te"
% .z insert end "\n"
% .z insert end 1234567890123456789012345678901234567890
% .z insert end "\n"
% .z insert end "a\tb\tc\td\te"
% .z tag configure x -tabs [list 4 8 12 16 20 24]
% .z tag add x 1.0 end
% # picture X -- tabs are one space long.
% .z tag delete x 1.0 end
% .z tag configure y -tabs [list 4 8 12 16 20 24] -justify right
% .z tag add y 1.0 end
% # picture Y  -- this is not at all what I would expect
% .z tag delete y 1.0 end
% # after this, re-adding tag x or y no longer works.

a) Tabs are not properly set using tag -tabs
b) tag -tabs -justify right display arrow characters
c) After removal of a tag with -tabs, it cannot be re-applied.
User Comments: jan.nijtmans added on 2021-04-26 09:22:57:

Those 2 testcases are marked as "knownBug" now. That doesn't mean it's fixed, it just makes github actions a little less red!


bll added on 2017-08-09 19:16:19:
Can you use the new fixed tests?

fvogel added on 2017-08-09 18:58:52:

> Francois: can we close this item?

I don't think so.

It is true the script provided by Brad on 2017-07-04 15:57:30 looks OK now on Windows and Linux Debian 8 (can't check on OS X right now, connection is way too slow), but I still get failures in the test suite.

To be exhaustive, here is what I get today with [342aab73]:

WINDOWS:

==== textDisp-2.26 LayoutDLine, tabs, breaking chunks at tabs FAILED
==== Contents of test case:

    .t delete 1.0 end
    .t tag delete x
    .t tag configure x -tabs [list 30 60 90 120] -justify right
    .t insert 1.0 "a\tb\tc\td\te"
    .t mark set dummy1 1.1
    .t mark set dummy2 1.2
    .t tag add x 1.0 end
    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0]  [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]

---- Result was:
48 78 108 138
---- Result should have been (exact matching):
117 124 131 138
==== textDisp-2.26 FAILED


==== textDisp-24.24 TkTextCharLayoutProc, justification and tabs FAILED
==== Contents of test case:

    .t delete 1.0 end
    .t tag configure x -justify center
    .t insert 1.0 aa\tbb\tcc\tdd\t
    .t tag add x 1.0 end
    list [.t bbox 1.0] [.t bbox 1.10]

---- Result was:
{10 3 7 15} {52 18 7 15}
---- Result should have been (exact matching):
{45 3 7 15} {94 3 7 15}
==== textDisp-24.24 FAILED

LINUX DEBIAN 8 and OS X:

No test failure at all, but textDisp-2.26 and textDisp-24.24 are skipped due to 'textfonts' constraint.

So neither textDisp-2.26 nor textDisp-24.24 do pass on any platform.


bll added on 2017-08-09 16:47:58:
Note that tablelist-5.18 still does not display correctly.
New tickets are needed to resolve the revised_text tab issues.

bll added on 2017-08-09 16:24:43:
Closing.
This ticket is too general and is replaced with other tickets.

(b) may or may not be resolved -- seems to be ok for me at the moment on MX Linux with gcc.  If it shows up again, a new ticket can be opened.  As this particular bug seems to be system/compiler/library dependent, it could be hard to track down.

gcramer added on 2017-08-09 12:00:19:
The script above now works.

Francois: can we close this item?

fvogel added on 2017-07-09 09:28:56:

> textDisp-24.24, textDisp-2.26: > > Should we adjust these text cases? Fact is that the behaviour before is erroneous.

The results I get on Linux Debian 8 are the same as on Win for textDisp-2.26. However on Linux with textDisp-24.24 I do not get the same result as on Win. here is the Debian result:

---- Result was:
{10 3 7 13} {52 16 7 13}
---- Result should have been (exact matching):
{45 3 7 13} {94 3 7 13}
==== textDisp-24.24 FAILED


bll added on 2017-07-04 22:57:00:
There is no particular definition of what happens when -tabs is combined
with -justify right.

I think the implementation as is is correct as that should be what a
right-to-left language would expect.

There will be people that expect -tabs and -justify right to act like:
   -tabs [list 4 right 8 right 12 right] -justify left
but that is incorrect.

I have the rewritten test 2.26 working on Linux and Mac OS X.

For 24.24:
I have no idea how the combination of -tabs and -justify center is supposed
to act (where is the first tab's anchor and what is a first tab in this case?),
so all I can do is match the implementation.

In general, for left-to-right languages, these combinations are not
that useful.  It is more important to make sure that the:
 -justify left -tabs [4 center 8 numeric 12 left 16 left 20 right] 
style works properly.

A right-to-left language should be able to use -justify right and tabs should work exactly backwards.

bll added on 2017-07-04 20:37:41:
I am in the process of redoing the test cases in textDisp.test to be font agnostic.
I have not started on the tests that use tabs as yet.
I will fix those.

gcramer added on 2017-07-04 20:22:14:
textDisp-24.24, textDisp-2.26:

Should we adjust these text cases? Fact is that the behaviour before is erroneous.

bll added on 2017-07-04 19:26:37:
Version 8.6.1 on Ubuntu 15.02 
and version 8.6.6 on Ubuntu 17.04
display box characters.

I tried another window manager on my machine and same issue.  

The display problem is looking like a (hard to find) tk bug to me.

Hah!  Compiled with clang (3.5.0) and the display bug has gone away.
Was using gcc 4.9.2.

fvogel added on 2017-07-04 19:24:34:

> Francois: is the Windows version working?

No arrows for me on Windows 7.

Here is what I get (I had zero failures before [a69ad2fd]) when running the test suite however:

==== textDisp-2.26 LayoutDLine, tabs, breaking chunks at tabs FAILED
==== Contents of test case:

    .t delete 1.0 end
    .t tag delete x
    .t tag configure x -tabs [list 30 60 90 120] -justify right
    .t insert 1.0 "a\tb\tc\td\te"
    .t mark set dummy1 1.1
    .t mark set dummy2 1.2
    .t tag add x 1.0 end
    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0]  [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]

---- Result was:
48 78 108 138
---- Result should have been (exact matching):
117 124 131 138
==== textDisp-2.26 FAILED



==== textDisp-24.24 TkTextCharLayoutProc, justification and tabs FAILED
==== Contents of test case:

    .t delete 1.0 end
    .t tag configure x -justify center
    .t insert 1.0 aa\tbb\tcc\tdd\t
    .t tag add x 1.0 end
    list [.t bbox 1.0] [.t bbox 1.10]

---- Result was:
{10 3 7 15} {52 18 7 15}
---- Result should have been (exact matching):
{45 3 7 15} {94 3 7 15}
==== textDisp-24.24 FAILED


bll added on 2017-07-04 17:20:33:
Works on Fedora 25, Debian 8, LinuxMint 17, Unbuntu 15.02.

I have to suspect xfce4 is doing something to my display.
I am running MX Linux 16.1 (based on Debian 8).
It's a new install, I know exactly what I have configured in it.
xfce4 is new to me.

I will try a different window manager.

gcramer added on 2017-07-04 16:52:35:
I did another test, and traced the displayed content. It's not possible anymore that arrows will be displayed, only letters and digits (a...z,0...9) will be displayed. So I'm sure that anything in your Linux test environment has been going wrong.

bll added on 2017-07-04 16:14:44:
I will test on other versions of Linux.
I did try an alternate fixed font already.

gcramer added on 2017-07-04 16:07:21:
I've only fixed the revised version.

> Right justified does not work on Linux.
> I still get the arrow symbols as in the picture.

I cannot replicate your problem, works perfectly for me. Due to program logic it seems to be impossible that arrows will be displayed with fixed version.

> I did remember to pull, update, make.

Probably anything else has been going wrong with your test?

Francois: is the Windows version working?

bll added on 2017-07-04 15:57:30:
Works on Mac OS X.

Right justified does not work on Linux.
I still get the arrow symbols as in the picture.
This bug is present in both 8.6.6 and revised_text.

I did remember to pull, update, make.

Updated test script.

package require Tk
text .z -height 5
set f "{Courier New} -12"
.z configure -font $f
pack .z

set tsize [expr {[font measure $f m]*4}]

.z insert end "a\tb\tc\td\te"
.z insert end "\n"
.z insert end 1234567890123456789012345678901234567890
.z insert end "\n"
.z insert end "a\tb\tc\td\te"
.z tag configure x -tabs $tsize -justify right
.z tag add x 1.0 end
set ::x 0
after 5000 [list set ::x 1]
vwait ::x
.z tag remove x 1.0 end
.z tag configure y -tabs $tsize -justify left
.z tag add y 1.0 end
set ::x 0
after 5000 [list set ::x 1]
vwait ::x
.z tag remove y 1.0 end

gcramer added on 2017-07-04 09:49:10:
I've committed [a69ad2fd43], the forgotten cases with justifying "right" and "center" has been added.

> c) After removal of a tag with -tabs, it cannot be re-applied.

This is a little bug in your test script, you have to use "remove" instead of "delete" for removing tags from text. Unfortunately it's not easy to detect this kind of bug, because "delete" also excepts any number of arguments, and does not complain about unknown tags.

bll added on 2017-06-26 17:52:53:
Happened to be poking around tablelist-5.18.

As it uses a text widget, it may be possible to uncover more bugs.

This widget is used extensively by a lot of people, so we should
make sure it works.  Perhaps Dr. Nemethi has some tablelist tests
stored away that we can run.

tablelist-5.18 uses a text widget with tag...-tabs.
Pictures attached (Linux).

To run his dirViewer demo, do:
   cd tablelist-5.18
   export TCLLIBPATH=$(pwd)
   wish8.7 demos/dirViewer.tcl

bll added on 2017-06-25 22:15:11:
I see this issue in both 8.6.6 and revised_text
(2c4bcae2e346bb33f2a7ec0a00847178f27bcf65 with edits to make it compile) 
on Linux.
See attached pictures.

I don't know what right justified tabs are supposed to do exactly, but I don't think it is supposed to display arrows.  Are you getting arrows on your Linux systems?

On Windows 8.6.6, I don't get arrows, but the characters are all together on the right side, no sign of any tabs.

Re-including a test script...

package require Tk
text .z -height 5
.z configure -font "{Courier New} -12"
pack .z
.z insert end "a\tb\tc\td\te"
.z insert end "\n"
.z insert end 1234567890123456789012345678901234567890
.z insert end "\n"
.z insert end "a\tb\tc\td\te"
.z tag configure x -tabs [list 4 8 12 16 20 24]
.z tag add x 1.0 end
set ::x 0
after 5000 [list set ::x 1]
vwait ::x
# picture X -- tabs are one space long.
.z tag delete x 1.0 end
.z tag configure y -tabs [list 4 8 12 16 20 24] -justify right
.z tag add y 1.0 end
set ::x 0
after 5000 [list set ::x 1]
vwait ::x
# picture Y  -- this is not at all what I would expect
.z tag delete y 1.0 end
# after this, re-adding tag x or y no longer works.

gcramer added on 2017-06-25 20:43:24:
I already fixed a problem concerning tabs related to context drawing in revised version, this is tested with an emulation under Linux. But I don't know about the behaviour under Mac.

fvogel added on 2017-06-25 20:16:42:
This report mentions 8.6.6.

Is it working correctly with revised_text branch or do you see the same issue?

Attachments: