0 | module Qutescript.Command
7 | data Key : Type where
14 | Interpolation Key where
15 | interpolate (Chr c) = singleton c
16 | interpolate Tab = "<Tab>"
17 | interpolate Esc = "<Esc>"
18 | interpolate Return = "<Return>"
21 | FromChar Key where fromChar = Chr
30 | data Target : Type where
33 | BackgroundTab : Target
37 | Interpolation Target where
38 | interpolate Normal = ""
39 | interpolate Tab = "--tab"
40 | interpolate BackgroundTab = "--bg"
41 | interpolate Window = "--window"
44 | tgt : Target -> String
45 | tgt Normal = "normal"
47 | tgt BackgroundTab = "tab-bg"
48 | tgt Window = "window"
51 | data Privacy = Private | NotPrivate
54 | Interpolation Privacy where
55 | interpolate Private = "--private"
56 | interpolate NotPrivate = ""
59 | data Security = Secure | NotSecure
62 | Interpolation Security where
63 | interpolate Secure = "--secure"
64 | interpolate NotSecure = ""
67 | data Rel = Related | NotRelated
70 | Interpolation Rel where
71 | interpolate Related = "--related"
72 | interpolate NotRelated = ""
75 | data Globality = Global | NotGlobal
78 | Interpolation Globality where
79 | interpolate Global = "--global"
80 | interpolate NotGlobal = ""
88 | data Command : Type where
89 | Back : Target -> Command
90 | ClickElement : Target -> (filter,value : String) -> Command
92 | FakeKeys : Globality -> List Key -> Command
93 | Forward : Target -> Command
94 | Help : Target -> (topic : String) -> Command
95 | InsertText : String -> Command
96 | Open : Target -> Rel -> Privacy -> Security -> String -> Command
98 | public export %inline
99 | open' : String -> Command
100 | open' = Open Normal NotRelated NotPrivate NotSecure
102 | public export %inline
103 | openIn : Target -> String -> Command
104 | openIn l = Open l NotRelated NotPrivate NotSecure
106 | public export %inline
107 | fakeKeys : List Key -> Command
108 | fakeKeys = FakeKeys NotGlobal
110 | public export %inline
111 | fakeKey : Key -> Command
112 | fakeKey = fakeKeys . pure
115 | Interpolation Command where
116 | interpolate (Back x) = "back \{x}"
117 | interpolate (ClickElement x f v) = "click-element -t \{tgt x} \{f} \{v}"
118 | interpolate Close = "close"
119 | interpolate (FakeKeys g ks) = "fake-key \{g} \{concat $ map interpolate ks}"
120 | interpolate (Forward x) = "forward \{x}"
121 | interpolate (Help x t) = "help \{x} \{t}"
122 | interpolate (InsertText s) = "insert-text \{s}"
123 | interpolate (Open l r p s u) = "open \{l} \{r} \{p} \{s} \{u}"