Debian Codegraph @

etc/config/FreeFem++.scrpt-txt.in

raw
1 # Author F. hecht with the help of Vincent Bernardi
2 # [email protected]
3 # this is a free software with no garanty at all.
4 #---------------
5
6 # take from the web (thank to Alec Web log).
7 # http://www.alecjacobson.com/weblog/
8 on last_offset(the_text, char)
9 try
10 set len to count of the_text
11 set reversed to reverse of characters of the_text as string
12 set last_occurrence to len - (offset of char in reversed) + 1
13 if last_occurrence > len then
14 return 0
15 end if
16 on error
17 return 0
18 end try
19 return last_occurrence
20 end last_offset
21
22
23
24 on dirname(the_path)
25 set last_occurrence to last_offset(the_path, "/")
26 if last_occurrence is equal to 0 then
27 return "."
28 end if
29 if last_occurrence is equal to 1 then
30 return "/"
31 end if
32 if last_occurrence is equal to (count of the_path) then
33 set the_path to items 1 thru (last_occurrence - 1) of the_path as string
34 return dirname(the_path)
35 end if
36 return items 1 thru (last_occurrence - 1) of the_path as string
37 end dirname
38
39 # end of web part ...
40
41
42 # the freefem++ action
43 # -------------------
44 on freefem(edpfile)
45 set edppath to POSIX path of edpfile
46 set edpdir to dirname(edppath)
47 tell application "Terminal"
48 if not (exists window 1) then reopen
49 activate
50 try
51 do shell script "/usr/bin/env bash -c 'export PATH=\"$PATH:$(cat /etc/paths.d/FreeFem++)\";cd \"" & edpdir & "\";FreeFem++-CoCoa \"" & edppath & "\"'"
52 end try
53 end tell
54 end freefem
55
56 # to do on drag and drop
57 # -------------------
58 on open filelist
59 repeat with edpfile in filelist
60 freefem(edpfile)
61 end repeat
62 return
63 end open
64
65 # other default case ….
66 # -------------------
67 set edpfile to choose file with prompt "Choose a edp script:"
68 freefem(edpfile)
69