Browse code
feat: add some helpful tools to scripting-bridge
Edward Langley authored on 23/05/2023 06:01:30
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -22,6 +22,41 @@ |
22 | 22 |
(defun safari-app () |
23 | 23 |
(app "com.apple.Safari")) |
24 | 24 |
|
25 |
+(defclass sbsafari () |
|
26 |
+ ((%app-ref :reader app-ref :initform (safari-app)))) |
|
27 |
+ |
|
28 |
+(defgeneric windows (object) |
|
29 |
+ (:method ((object sbsafari)) |
|
30 |
+ (mapcar 'safari-window |
|
31 |
+ (objc-runtime.data-extractors:extract-from-objc |
|
32 |
+ [(app-ref object) @(windows)]?)))) |
|
33 |
+ |
|
34 |
+(fw.lu:defclass+ safari-window () |
|
35 |
+ ((%window-ref :reader window-ref :initarg :window-ref))) |
|
36 |
+ |
|
37 |
+(defgeneric name (thing) |
|
38 |
+ (:method ((thing safari-window)) |
|
39 |
+ [(window-ref thing) @(name)]@)) |
|
40 |
+ |
|
41 |
+(defgeneric tabs (object) |
|
42 |
+ (:method ((object safari-window)) |
|
43 |
+ (mapcar 'safari-tab |
|
44 |
+ (objc-runtime.data-extractors:extract-from-objc |
|
45 |
+ [(window-ref object) @(tabs)])))) |
|
46 |
+ |
|
47 |
+(fw.lu:defclass+ safari-tab () |
|
48 |
+ ((%tab-ref :reader tab-ref :initarg :tab-ref))) |
|
49 |
+ |
|
50 |
+(defgeneric source (tab) |
|
51 |
+ (:method ((tab safari-tab)) |
|
52 |
+ [(tab-ref tab) @(source)]@)) |
|
53 |
+(defgeneric text (tab) |
|
54 |
+ (:method ((tab safari-tab)) |
|
55 |
+ [(tab-ref tab) @(text)]@)) |
|
56 |
+(defgeneric url (tab) |
|
57 |
+ (:method ((tab safari-tab)) |
|
58 |
+ [(tab-ref tab) @(URL)]@)) |
|
59 |
+ |
|
25 | 60 |
(defun current-track-info (itunes) |
26 | 61 |
(let* ((current-track [itunes @(currentTrack)])) |
27 | 62 |
(format t "~&Track: ~A (~v,1,0,'⋆<~>)~%Album: ~a (~v,1,0,'*<~>)~%Artist: ~a~%" |
... | ... |
@@ -64,7 +99,6 @@ |
64 | 99 |
(incf count)))) |
65 | 100 |
(apply hof #'nested-lambda hof-args))))) |
66 | 101 |
|
67 |
- |
|
68 | 102 |
(defmacro comment (&body b) |
69 | 103 |
b ()) |
70 | 104 |
|