PortAuthority

Check-in [e1107d8e3c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update AppleScript implementation
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e1107d8e3cb3abe2c87c7ddd49df3dfaad288c2e
User & Date: kevin 2019-01-04 03:02:30
Context
2019-01-05
15:41
Update unit tests check-in: 36d5371956 user: kevin tags: trunk
2019-01-04
03:02
Update AppleScript implementation check-in: e1107d8e3c user: kevin tags: trunk
2019-01-03
02:56
Re-set auxiliary windows in utility style check-in: 72fa7fed11 user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Deleted libs/aem1.0/libaem1.0.dylib.

cannot compute difference between binary files

Deleted libs/aem1.0/pkgIndex.tcl.

1
2
3
4
5
6
7
#
# Tcl package index file
#
package ifneeded aem 1.0 "
    package require Tk 8.5-
    if {\"AppKit\" ni \[winfo server .\]} {error {TkAqua Cocoa required}}
        load [list [file join $dir libaem1.0.dylib]] aem"
<
<
<
<
<
<
<














Changes to libs/machelp/help.txt.

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176


177
178
179
180
181
182
183

The window menu manages the various display windows of PortAuthority. It can minimize the selected window, or bring all application windows to the front.

-------------------
title: Scriptability and Services
alias: Scriptability

PortAuthority offers extensive AppleScript support, including the following commands:

 * search_all_ports(searchterm) -- search all ports for a specific item
 * list_installed_ports -- list all installed ports
 * get_port_info(port) -- get information about a specific port
 * list_all_ports -- list all ports
 * get_search_term -- returns the current search term for a port search
 * get_info_term -- returns the currently selected port for requesting information
 * set_search_term -- sets the term to search for a specific port
 * run_update -- update the MacPorts infrastructure
 * dump_ports -- export a list of all ports to a file



These commands allow the user to automate PortAuthority and the MacPorts installation.
PortAuthority can also be called from the Mac's Services menu. To call PortAuthority from the services menu, highlight a domain name in a Services-aware application (such as Safari, Mail or TextEdit) and select "PortAuthority: Search Ports" from the Services menu. That search term will be passed to PortAuthority and and search output of the ports will be displayed.

PortAuthority also supports the ability to call other Mac applications from the Services menu. To call another application's service--for instance, to display a domain in Safari--simply highlight the text in PortAuthority and then select the appropriate item from the Services menu.

-------------------







|










>
>







159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

The window menu manages the various display windows of PortAuthority. It can minimize the selected window, or bring all application windows to the front.

-------------------
title: Scriptability and Services
alias: Scriptability

PortAuthority offers extensive AppleScript support. The following commands can be called via AppleScript's "do script" command:

 * search_all_ports(searchterm) -- search all ports for a specific item
 * list_installed_ports -- list all installed ports
 * get_port_info(port) -- get information about a specific port
 * list_all_ports -- list all ports
 * get_search_term -- returns the current search term for a port search
 * get_info_term -- returns the currently selected port for requesting information
 * set_search_term -- sets the term to search for a specific port
 * run_update -- update the MacPorts infrastructure
 * dump_ports -- export a list of all ports to a file

As an example: tell app "PortAuthority" to do script "list_all_ports"

These commands allow the user to automate PortAuthority and the MacPorts installation.
PortAuthority can also be called from the Mac's Services menu. To call PortAuthority from the services menu, highlight a domain name in a Services-aware application (such as Safari, Mail or TextEdit) and select "PortAuthority: Search Ports" from the Services menu. That search term will be passed to PortAuthority and and search output of the ports will be displayed.

PortAuthority also supports the ability to call other Mac applications from the Services menu. To call another application's service--for instance, to display a domain in Safari--simply highlight the text in PortAuthority and then select the appropriate item from the Services menu.

-------------------

Changes to libs/portauthority/portauthority-main.tcl.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package require mojavehig
package require appname
package require urltext
 package require tclservices
package require cocoaprint
package require Tclapplescript
package require tclgrowl
package require aem

package require xplat

#handle errors in Tk
proc bgerror {args} {
    exec syslog -s -l Error "PortAuthority: An error occurred: $args"
}

#install AppleScript event handlers
aem::installeventhandler CoKv sPrt searchAllPorts
aem::installeventhandler CoKv iPrt listInstalledPorts
aem::installeventhandler CoKv aPrt listAllPorts
aem::installeventhandler CoKv dPrt getInfoAboutPort
aem::installeventhandler CoKv pTrm getSearchTerm
aem::installeventhandler CoKv iTrm getInfoTerm
aem::installeventhandler CoKv ssTm setSearchTerm
aem::installeventhandler CoKv rUpd runUpdate
aem::installeventhandler CoKv dmPt dumpPorts


proc dumpPorts {outputpath} {

    global status  
    global category 
    global portpath 
    global verboselevel 
    global portlist 
    global packages 







|
<







<
<
<
<
<
<
<
<
<
<
|

|







15
16
17
18
19
20
21
22

23
24
25
26
27
28
29










30
31
32
33
34
35
36
37
38
39
package require mojavehig
package require appname
package require urltext
 package require tclservices
package require cocoaprint
package require Tclapplescript
package require tclgrowl
#package require aem

package require xplat

#handle errors in Tk
proc bgerror {args} {
    exec syslog -s -l Error "PortAuthority: An error occurred: $args"
}











#Commands called via AppleScript "do script" command

proc dump_ports {outputpath} {

    global status  
    global category 
    global portpath 
    global verboselevel 
    global portlist 
    global packages 
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

    close $resultfile

}


#set search term from AppleScript
proc setSearchTerm {term} {
    
    global searchterm

    set searchterm $term
    
}


#searches MacPorts for a specific port, returns to AppleScript
proc searchAllPorts {term} {
    
    global category 
    global status 
    global searchterm 
    global portpath 
    global verboselevel 
    global searchlist 







|









|







81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

    close $resultfile

}


#set search term from AppleScript
proc set_search_term {term} {
    
    global searchterm

    set searchterm $term
    
}


#searches MacPorts for a specific port, returns to AppleScript
proc search_all_ports {term} {
    
    global category 
    global status 
    global searchterm 
    global portpath 
    global verboselevel 
    global searchlist 
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
    foreach item $parsesearch {
	set program [lindex $item 1]
	set version [lindex $item 2]
	set mycategory [lindex $item 3]
	lappend searcharray [list $program $version $mycategory]
    }

    set resultfile [open $::env(TMPDIR)/resultfile.txt w]
    
    foreach item $searcharray {
	puts $resultfile $item
    }

    close $resultfile


    set readfile [open $::env(TMPDIR)/resultfile.txt r]
    set resultlist [read $readfile]
    close $readfile

    return $resultlist
}

#run self-update
proc runUpdate {} {

    updateBase

}


#list all MacPorts ports, return to AppleScript
proc listAllPorts {} {
    global status  
    global category 
    global portpath 
    global verboselevel 
    global portlist 
    global packages 
    global log







<
<
|
<
|
|
<
<
<
<
<
<
<
<



|







|







121
122
123
124
125
126
127


128

129
130








131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
    foreach item $parsesearch {
	set program [lindex $item 1]
	set version [lindex $item 2]
	set mycategory [lindex $item 3]
	lappend searcharray [list $program $version $mycategory]
    }



    return $searcharray


 








}

#run self-update
proc run_update {} {

    updateBase

}


#list all MacPorts ports, return to AppleScript
proc list_all_ports {} {
    global status  
    global category 
    global portpath 
    global verboselevel 
    global portlist 
    global packages 
    global log
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
		set myinstalled ""
	    }
	}
	
	lappend portarray [list $program $version $searchcategory]
    }

    set resultfile [open $::env(TMPDIR)/resultfile.txt w]
    
    foreach item $portarray {
	puts $resultfile $item
    }

    close $resultfile

    set readfile [open $::env(TMPDIR)/resultfile.txt r]
    set resultlist [read $readfile]
    close $readfile

    return $resultlist
}

#list installed ports, return to AppleScript
proc listInstalledPorts {} {

    global status  
    global category 
    global portpath 
    global verboselevel 
    global portlist 
    global packages 







<
<
|
<
<
<
<
<
<
<
<
<
<



|







177
178
179
180
181
182
183


184










185
186
187
188
189
190
191
192
193
194
195
		set myinstalled ""
	    }
	}
	
	lappend portarray [list $program $version $searchcategory]
    }



   return $portarray










}

#list installed ports, return to AppleScript
proc list_installed_ports {} {

    global status  
    global category 
    global portpath 
    global verboselevel 
    global portlist 
    global packages 
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
	set program [lindex $item 0]
	set version [string map -nocase {@ {} } [lindex $item 1]]
	set searchcategory [lindex [split [lindex $item 2] /] 0]
	lappend installedarray [list $program $version $searchcategory]
    }


    set resultfile [open $::env(TMPDIR)/resultfile.txt w]
    
    foreach item $installedarray {
	puts $resultfile $item
    }

    close $resultfile

    set readfile [open $::env(TMPDIR)/resultfile.txt r]
    set resultlist [read $readfile]
    close $readfile

    return $resultlist

    
}

#get search term from AppleScript
proc getSearchTerm {} {
    
    global searchterm

    return $searchterm
    
}


proc getInfoTerm {} {

    set item [lindex [.t.right.upper.frame.listbox get [.t.right.upper.frame.listbox curselection]] 1]
    set new [lindex [split $item] 0]
    return $new

}


#get info about port, pass to AppleScript
proc getInfoAboutPort {term} {

    global portpath

    set infoterm $term

    exec $portpath info $infoterm > $::env(TMPDIR)/portinfo.txt  2>$::env(TMPDIR)/infoerrors.txt

    set readfile [open $::env(TMPDIR)/portinfo.txt r]
    set myinfo [read $readfile]
    close $readfile
    return $myinfo

}

#display user help
proc tk::mac::ShowHelp {} {
    machelp::userhelp







<
<
|
<
<
<
<
<
<
<
<
<
<





|








|









|





|

<
<
<







205
206
207
208
209
210
211


212










213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244



245
246
247
248
249
250
251
	set program [lindex $item 0]
	set version [string map -nocase {@ {} } [lindex $item 1]]
	set searchcategory [lindex [split [lindex $item 2] /] 0]
	lappend installedarray [list $program $version $searchcategory]
    }




   return $installedarray











    
}

#get search term from AppleScript
proc get_search_term {} {
    
    global searchterm

    return $searchterm
    
}


proc get_info_term {} {

    set item [lindex [.t.right.upper.frame.listbox get [.t.right.upper.frame.listbox curselection]] 1]
    set new [lindex [split $item] 0]
    return $new

}


#get info about port, pass to AppleScript
proc get_port_info {term} {

    global portpath

    set infoterm $term

    set myinfo [exec $portpath info $infoterm]  




    return $myinfo

}

#display user help
proc tk::mac::ShowHelp {} {
    machelp::userhelp