Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 156 lines (139 sloc) 3.568 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 let _output_channel = stderr
20
21 module Album =
22 struct
23
24 let walker =
25 let walk_anim = [|
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 |] |]
51 in
52 let turn_anim = [|
53 [|
54 " @ ";
55 " | ";
56 " )\\";
57 |] ; [|
58 " @ ";
59 " | ";
60 "/( "
61 |] |]
62 in
63 ConsoleAnim.init ~och:_output_channel ~auto_walking:true walk_anim turn_anim
64
65 let arrow =
66 let walk_anim = [| [| "====>" |] |]
67 in
68 let turn_anim = [|
69 [| " ====" |];
70 [| " ===" |];
71 [| " ==" |];
72 [| " =" |];
73 [| " " |];
74 [| " <" |];
75 [| " <=" |];
76 [| " <==" |];
77 [| " <===" |];
78 [| "<====" |]
79 |]
80 in
81 ConsoleAnim.init ~och:_output_channel ~auto_walking:true walk_anim turn_anim
82
83 let simple =
84 let a = [|
85 [| "...." |];
86 [| " ..." |];
87 [| ". .." |];
88 [| ".. ." |];
89 [| "... " |];
90 |]
91 in
92 ConsoleAnim.init ~och:_output_channel ~auto_walking:false a a
93 let pong =
94 let a = [|
95 [| "| o|" |];
96 [| "| o |" |];
97 [| "| o |" |];
98 [| "|o |" |];
99 [| "| o |" |];
100 [| "| o |" |];
101 |]
102 in
103 ConsoleAnim.init ~och:_output_channel ~auto_walking:false a a
104 let opa =
105 let a = [|
106 [| "OPA " |];
107 [| " OPA " |];
108 [| " OPA " |];
109 [| " OPA " |];
110 [| " OPA" |];
111 [| "A OP" |];
112 [| "PA O" |];
113 |]
114 in
115 ConsoleAnim.init ~och:_output_channel ~auto_walking:false a a
116
117 let all = [|
118 walker ;
119 arrow ;
120 simple ;
121 pong ; opa;
122 |]
123 end
124
125 module Options =
126 struct
127
128 type disp = True | False | ForceExit
129
130 let och = _output_channel
131 let chosen_walker = ref Album.simple (*Album.all.(Random.int (Array.length Album.all))*)
132 let time_interv = ref 0.10
133 let disp = ref False
134
135 let available_walkers = ["grandpa";"arrow";"simple";"pong";"opa";"random"]
136 let set_opa_walker = function
137 | "grandpa" -> chosen_walker := Album.walker
138 | "arrow" -> chosen_walker := Album.arrow
139 | "simple" -> chosen_walker := Album.simple
140 | "pong" -> chosen_walker := Album.pong
141 | "opa" -> chosen_walker := Album.opa
142 | "random" -> chosen_walker := Album.all.(Random.int (Array.length Album.all))
143 | other -> failwith (Printf.sprintf "set_opa_walker: unknown argument %S" other)
144
145 end
146
147 let _ =
148 let do_walker () =
149 while !Options.disp <> Options.ForceExit do
150 Thread.delay !Options.time_interv;
151 if !Options.disp = Options.True then
152 ConsoleAnim.update !Options.chosen_walker
153 done
154 in
155 ignore (Thread.create do_walker ())
Something went wrong with that request. Please try again.