Eskil

Diff
Login

Differences From Artifact [d100cd6397]:

To Artifact [e2bda98fe9]:


1
2
3
4
5
6
7
8
9
10
11
12









13
14
15
16
17
18
19
20
#----------------------------------------------------------------------
#
#  psballoon.tcl,
#   Procedures to create help message balloons or display balloons for
#   listboxes and labels that can't display all of their contents.
#
#  Copyright (c) 2003, Peter Spjuth  (peter.spjuth@gmail.com)
#
#  Permission is granted to use this code under the same terms as
#  for the Tcl core code.
#
#----------------------------------------------------------------------









# $Revision: 1.1 $
#----------------------------------------------------------------------

package provide psballoon 1.2

namespace eval psballoon {
    variable balloon
    variable config
|





|





>
>
>
>
>
>
>
>
>
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#---------------------------------------------------------*-tcl-*------
#
#  psballoon.tcl,
#   Procedures to create help message balloons or display balloons for
#   listboxes and labels that can't display all of their contents.
#
#  Copyright (c) 2003-2024, Peter Spjuth  (peter.spjuth@gmail.com)
#
#  Permission is granted to use this code under the same terms as
#  for the Tcl core code.
#
#----------------------------------------------------------------------
#  This is used as a Tcl Module. Use it like this:
#  ::tcl::tm::path add <path-to-dir-with-module>
#  package require psballoon
#  namespace import psballoon::*
#
#  addBalloon .l .b "My help text"
#  addBalloon .f -fmt {
#     Write help more freely.\n
#     New lines need to be explicit like above.
#  }
#----------------------------------------------------------------------

package provide psballoon 1.2

namespace eval psballoon {
    variable balloon
    variable config
40
41
42
43
44
45
46


47
48
49
50
51
52
53
    # Remove any newlines.
    set msg [regsub -all "\n" $msg " "]
    # Remove multiple whitespace
    set msg [regsub -all {\s+} $msg " "]
    set msg [string trim $msg]
    # Any explicitly requested newlines?
    set msg [regsub -all {\\n\s*} $msg "\n"]


    # Further line breaks by length?
    set lines {}
    foreach line [split $msg \n] {
        while {[string length $line] > 80} {
            # There should be no path through this loop that does not
            # shorten $line
            set ix [string last " " $line 80]







>
>







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    # Remove any newlines.
    set msg [regsub -all "\n" $msg " "]
    # Remove multiple whitespace
    set msg [regsub -all {\s+} $msg " "]
    set msg [string trim $msg]
    # Any explicitly requested newlines?
    set msg [regsub -all {\\n\s*} $msg "\n"]
    # Any remaining substs like tabs?
    set msg [subst -nocommand -novariable $msg]
    # Further line breaks by length?
    set lines {}
    foreach line [split $msg \n] {
        while {[string length $line] > 80} {
            # There should be no path through this loop that does not
            # shorten $line
            set ix [string last " " $line 80]