Ignore:
Timestamp:
Mar 29, 2014, 7:21:58 PM (7 years ago)
Author:
cal@…
Message:

base: Delay displaying notes for installed ports until the end of the current operation

Mostly written by Jeremy Lavergne (snc).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port/port.tcl

    r117702 r118304  
    46404640        }
    46414641
     4642        # Print notifications of just-activated ports.
     4643        portclient::notifications::display
     4644
    46424645        # semaphore to exit
    46434646        if {$action_status == -999} break
     
    51685171}
    51695172
     5173namespace eval portclient::notifications {
     5174    ##
     5175    # Ports whose notifications to display; these were either installed
     5176    # or requested to be installed.
     5177    variable notificationsToPrint
     5178    array set notificationsToPrint {}
     5179
     5180    ##
     5181    # Add a port to the list for printing notifications.
     5182    #
     5183    # @param name
     5184    #        The name of the port.
     5185    # @param note
     5186    #        A list of notes to be stored for the given port.
     5187    proc append {name notes} {
     5188        variable notificationsToPrint
     5189
     5190        set notificationsToPrint($name) $notes
     5191    }
     5192
     5193    ##
     5194    # Print port notifications.
     5195    #
     5196    proc display {} {
     5197        global env
     5198        variable notificationsToPrint
     5199
     5200        # Display notes at the end of the activation phase.
     5201        if {[array size notificationsToPrint] > 0} {
     5202            ui_notice "--->  Some of the ports you installed have notes:"
     5203            foreach {name notes} [array get notificationsToPrint] {
     5204                ui_notice "  $name has the following notes:"
     5205
     5206                # If env(COLUMNS) exists, limit each line's width to this width.
     5207                if {[info exists env(COLUMNS)]} {
     5208                    set maxlen $env(COLUMNS)
     5209
     5210                    foreach note $notes {
     5211                        foreach line [split $note "\n"] {
     5212                            set joiner ""
     5213                            set lines ""
     5214                            set newline "    "
     5215
     5216                            foreach word [split $line " "] {
     5217                                if {[string length $newline] + [string length $word] >= $maxlen} {
     5218                                    lappend lines $newline
     5219                                    set newline "    "
     5220                                    set joiner ""
     5221                                }
     5222                                ::append newline $joiner $word
     5223                                set joiner " "
     5224                            }
     5225                            if {$newline ne {}} {
     5226                                lappend lines $newline
     5227                            }
     5228                            ui_notice [join $lines "\n"]
     5229                        }
     5230                    }
     5231                } else {
     5232                    foreach note $notes {
     5233                        ui_notice $note
     5234                    }
     5235                }
     5236            }
     5237        }
     5238    }
     5239}
     5240
    51705241
    51715242##########################################
     
    52225293    set ui_options(progress_generic)  portclient::progress::generic
    52235294}
     5295
     5296set ui_options(notifications_append) portclient::notifications::append
    52245297
    52255298# Get arguments remaining after option processing
Note: See TracChangeset for help on using the changeset viewer.