Tk Source Code

View Ticket
Login
2018-11-10
09:24 Closed ticket [52923991]: revised_text: default value for -spacemode not backwards compatible plus 5 other changes artifact: 7bc67af1 user: fvogel
2016-10-09
18:31 Closed ticket [1754051f]: Ignore multiple whitespace at end of word-wrapped line plus 5 other changes artifact: b03a7a73 user: fvogel
18:30 Closed ticket [1082213f]: word wrapping should trim excess spaces plus 5 other changes artifact: 7521683e user: fvogel
18:28
Fixed [1082213fff] - word wrapping should trim excess spaces check-in: 54a994d0 user: fvogel tags: trunk
18:23
Fixed [1082213fff] - word wrapping should trim excess spaces check-in: bbce0075 user: fvogel tags: core-8-6-branch
2016-09-30
14:35 Ticket [1082213f] word wrapping should trim excess spaces status still Open with 3 other changes artifact: f61e7c06 user: fvogel
14:35 Ticket [1754051f] Ignore multiple whitespace at end of word-wrapped line status still Open with 7 other changes artifact: c4708cb9 user: fvogel
14:29 Ticket [1082213f] word wrapping should trim excess spaces status still Open with 3 other changes artifact: a4f06c48 user: fvogel
2016-09-28
15:57 Ticket [1082213f]: 3 changes artifact: 18e8c532 user: fvogel
15:57 Ticket [1082213f]: 9 changes artifact: 6d7a0648 user: fvogel
15:54
Fixed [1082213fff] - word wrapping should trim excess spaces check-in: 69686423 user: fvogel tags: bug-1082213fff
2004-12-09
15:49 New ticket [1082213f] word wrapping should trim excess spaces. artifact: acc2f7ec user: vincentdarley

Ticket UUID: 1082213
Title: word wrapping should trim excess spaces
Type: Bug Version: obsolete: 8.5a2
Submitter: vincentdarley Created on: 2004-12-09 15:49:18
Subsystem: 18. [text] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2016-10-09 18:30:30
Resolution: Fixed Closed By: fvogel
    Closed on: 2016-10-09 18:30:30
Description:
pack [text .t -width 12 -height 5 -wrap word -font fixed]
.t insert end "this is not       what is       normally
called       word wrapping"

Would under most norms of word-wrapping produce lines
all left aligned.  However the text widget instead
wraps in the middle of a group of spaces and therefore
starts some lines with empty spaces.

See e.g. 

http://groups-beta.google.com/group/comp.lang.tcl/browse_thread/thread/a00b6e2a2c07086a
User Comments: fvogel added on 2016-10-09 18:30:30:
Merged to core-8-6-branch and trunk.

fvogel added on 2016-09-30 14:35:42:

Note: this ticket is a duplicate of [1754051fff].


fvogel added on 2016-09-30 14:29:28:

All tests changed to become again successful. See branch [bug-1082213fff].

Note that this did not just consist in copy/pasting the new results obtained with the fix to this bug. Instead, each failing test was reviewed and got changed (and/or its expected results) in order to maintain relevance of the test and keep testing what was meant to be tested.

I'm wondering whether this fix can go in 8.6.x or if it should be limited to 8.7. Rendering of word wrapped test is changed.


fvogel added on 2016-09-28 15:57:22:

Fix proposed in [69686423dc].

Obviously, now a lots of tests in textDisp.test are in need of a change in their expected results. Will do.


fvogel added on 2016-09-28 15:57:06:

Another test case from the original thread on c.l.t:

# Here is a demo.  Adjust the window width, and look at the positioning
# of the second line when wrapping.  The label (upper) remians flush-left
# on both lines, but the second line of the text (.text) is indented
# depending on how many spaces are left.

pack req Tk

font create MonoFont   -family fixed -size -12 -weight bold

label .htitles -anchor w -justify left -padx 2 -pady 2 -relief sunken \
                -textvariable data -font MonoFont

text .text -height 10 -highlightthickness 0 \
                -padx 2 -pady 2 -takefocus 0 -width 1 \
                -wrap word -font MonoFont

bind .htitles <Configure> { set_wrap } 


set data [format {%15d %15d %15d %15d} 123 456 789 0]

.text insert end $data
 
proc set_wrap { } {
    set ww [expr { [winfo width .htitles] - 8 }]
    if { $ww > 10 } { # watch for initialization when there's no width yet
        .htitles configure -wraplength $ww
    }
}

grid .htitles -sticky ew
grid .text -sticky nsew

grid columnconfigure . 0 -weight 1
grid rowconfigure . 1 -weight 1