compilator 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/compilator/version.rb +1 -1
- data/lib/compilator.rb +65 -24
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14278249ee5b9a507d40073db9b7a92b392b38fd
|
|
4
|
+
data.tar.gz: 676b006a453d8cb101da7ab58c596823cc28b321
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa1cb7b4ab01c0bac652df2e059e108d65cdfcb692b205177c3145064876b1ddb3b071ec9f15a90d56dc5045ccb0ef87255bfee5b538df574ba77cd3094426ec
|
|
7
|
+
data.tar.gz: 578770a4cd912fabed36009c70d38d878767801dce89841c4cdef7dc744727a240061996eba4a51d3a7dd108c9fcdada125ee41f9fb524525db9e9e3ff5e1f69
|
data/lib/compilator/version.rb
CHANGED
data/lib/compilator.rb
CHANGED
|
@@ -21,10 +21,13 @@ module Compilator
|
|
|
21
21
|
def notify_action(view,action,kwargs={})
|
|
22
22
|
|
|
23
23
|
if action == :key_pressed || action == :button_pressed
|
|
24
|
-
model.last_key_pressed = kwargs[:key]
|
|
24
|
+
@model.last_key_pressed = kwargs[:key]
|
|
25
25
|
|
|
26
26
|
elsif action == :key_enter_pressed
|
|
27
27
|
notify_action(view,:button_equal_pressed,kwargs)
|
|
28
|
+
|
|
29
|
+
elsif action == :key_delete_pressed
|
|
30
|
+
@model.delete = true
|
|
28
31
|
|
|
29
32
|
elsif action == :button_equal_pressed
|
|
30
33
|
numerateur = 0
|
|
@@ -32,10 +35,10 @@ module Compilator
|
|
|
32
35
|
numerateur = numerateur+model.score[c]
|
|
33
36
|
end
|
|
34
37
|
denominateur = kwargs[:value].size*5
|
|
35
|
-
model.result = numerateur.to_s+"/"+denominateur.to_s+" => "+(numerateur*20.to_f/denominateur).round(2).to_s+"/20"
|
|
38
|
+
@model.result = numerateur.to_s+"/"+denominateur.to_s+" => "+(numerateur*20.to_f/denominateur).round(2).to_s+"/20"
|
|
36
39
|
|
|
37
40
|
elsif action == :button_raz_pressed
|
|
38
|
-
model.raz = true
|
|
41
|
+
@model.raz = true
|
|
39
42
|
|
|
40
43
|
elsif action == :close_window
|
|
41
44
|
view.close
|
|
@@ -45,7 +48,7 @@ module Compilator
|
|
|
45
48
|
|
|
46
49
|
class CompilatorModel < Druzy::MVC::Model
|
|
47
50
|
|
|
48
|
-
attr_accessor :score, :last_key_pressed, :result
|
|
51
|
+
attr_accessor :score, :last_key_pressed, :result, :delete
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
def initialize
|
|
@@ -54,6 +57,7 @@ module Compilator
|
|
|
54
57
|
@last_key_pressed = nil
|
|
55
58
|
@result = nil
|
|
56
59
|
@raz = false
|
|
60
|
+
@delete = false
|
|
57
61
|
end
|
|
58
62
|
|
|
59
63
|
def last_key_pressed=(last_key_pressed)
|
|
@@ -70,23 +74,37 @@ module Compilator
|
|
|
70
74
|
old, @raz = @raz, raz
|
|
71
75
|
fire_property_change(Druzy::MVC::PropertyChangeEvent.new(self,"raz",old,@raz))
|
|
72
76
|
end
|
|
77
|
+
|
|
78
|
+
def delete=(delete)
|
|
79
|
+
old, @delete = @delete, delete
|
|
80
|
+
fire_property_change(Druzy::MVC::PropertyChangeEvent.new(self,'delete',old,@delete))
|
|
81
|
+
end
|
|
73
82
|
end
|
|
74
83
|
|
|
75
84
|
class CompilatorView < Druzy::MVC::View
|
|
76
85
|
|
|
77
86
|
def initialize(controller)
|
|
78
87
|
super(controller)
|
|
79
|
-
#Tk::Tile::Style.theme_use "classic"
|
|
80
88
|
|
|
81
89
|
@root = TkRoot.new
|
|
82
90
|
@root.title = 'Compilator'
|
|
83
91
|
@root.bind('Key') do |event|
|
|
84
92
|
val = event.valid_fields['keysym'].downcase
|
|
85
|
-
|
|
86
93
|
if val == 'return'
|
|
87
94
|
Thread.new do
|
|
88
95
|
@controller.notify_action(self, :key_enter_pressed, :value => @entry_variable.value)
|
|
89
96
|
end
|
|
97
|
+
|
|
98
|
+
elsif val == 'escape'
|
|
99
|
+
Thread.new do
|
|
100
|
+
@controller.notify_action(self, :button_raz_pressed)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
elsif val == 'delete'
|
|
104
|
+
Thread.new do
|
|
105
|
+
@controller.notify_action(self, :key_delete_pressed)
|
|
106
|
+
end
|
|
107
|
+
|
|
90
108
|
elsif @controller.model.score.has_key?(val)
|
|
91
109
|
Thread.new do
|
|
92
110
|
@controller.notify_action(self,:key_pressed, :key => val)
|
|
@@ -97,23 +115,22 @@ module Compilator
|
|
|
97
115
|
|
|
98
116
|
@window = Tk::Tile::Frame.new(@root)
|
|
99
117
|
|
|
118
|
+
@font_button = TkFont.new("size" => 24)
|
|
119
|
+
|
|
100
120
|
@entry_variable = TkVariable.new
|
|
101
121
|
@entry = Tk::Tile::Entry.new(@window)
|
|
102
122
|
@entry.justify = 'right'
|
|
103
123
|
@entry.validate = 'key'
|
|
104
|
-
@entry.textvariable = @entry_variable
|
|
124
|
+
@entry.textvariable = @entry_variable
|
|
105
125
|
@entry.validatecommand do |valid|
|
|
106
|
-
|
|
107
|
-
false
|
|
108
|
-
else
|
|
109
|
-
true
|
|
110
|
-
end
|
|
126
|
+
false
|
|
111
127
|
end
|
|
112
128
|
|
|
113
129
|
@button_r = Tk::Tile::Button.new(@window)
|
|
114
130
|
@button_r['text'] = 'R'
|
|
115
|
-
Tk::Tile::Style.configure('Red.TButton', {"foreground" => 'red'
|
|
131
|
+
Tk::Tile::Style.configure('Red.TButton', {"foreground" => 'red', 'font' => @font_button})
|
|
116
132
|
@button_r['style'] = 'Red.TButton'
|
|
133
|
+
@button_r['width'] = 1
|
|
117
134
|
@button_r.bind('ButtonPress') do
|
|
118
135
|
Thread.new do
|
|
119
136
|
@controller.notify_action(self,:button_pressed, :key => 'r')
|
|
@@ -122,8 +139,9 @@ module Compilator
|
|
|
122
139
|
|
|
123
140
|
@button_o = Tk::Tile::Button.new(@window)
|
|
124
141
|
@button_o['text'] = 'O'
|
|
125
|
-
Tk::Tile::Style.configure('Orange.TButton', {"foreground" => 'orange'
|
|
142
|
+
Tk::Tile::Style.configure('Orange.TButton', {"foreground" => 'orange', 'font' => @font_button})
|
|
126
143
|
@button_o['style'] = 'Orange.TButton'
|
|
144
|
+
@button_o['width'] = 1
|
|
127
145
|
@button_o.bind('ButtonPress') do
|
|
128
146
|
Thread.new do
|
|
129
147
|
@controller.notify_action(self,:button_pressed, :key => 'o')
|
|
@@ -132,7 +150,8 @@ module Compilator
|
|
|
132
150
|
|
|
133
151
|
@button_j = Tk::Tile::Button.new(@window)
|
|
134
152
|
@button_j['text'] = 'J'
|
|
135
|
-
|
|
153
|
+
@button_j['width'] = 1
|
|
154
|
+
Tk::Tile::Style.configure('Yellow.TButton', {"foreground" => 'yellow', 'font' => @font_button})
|
|
136
155
|
@button_j['style'] = 'Yellow.TButton'
|
|
137
156
|
@button_j.bind('ButtonPress') do
|
|
138
157
|
Thread.new do
|
|
@@ -142,7 +161,8 @@ module Compilator
|
|
|
142
161
|
|
|
143
162
|
@button_c = Tk::Tile::Button.new(@window)
|
|
144
163
|
@button_c['text'] = 'C'
|
|
145
|
-
|
|
164
|
+
@button_c['width'] = 1
|
|
165
|
+
Tk::Tile::Style.configure('Lime.TButton', {"foreground" => 'lime green', 'font' => @font_button})
|
|
146
166
|
@button_c['style'] = 'Lime.TButton'
|
|
147
167
|
@button_c.bind('ButtonPress') do
|
|
148
168
|
Thread.new do
|
|
@@ -152,7 +172,8 @@ module Compilator
|
|
|
152
172
|
|
|
153
173
|
@button_v = Tk::Tile::Button.new(@window)
|
|
154
174
|
@button_v['text'] = 'V'
|
|
155
|
-
|
|
175
|
+
@button_v['width'] = 1
|
|
176
|
+
Tk::Tile::Style.configure('Green.TButton', {"foreground" => 'green', 'font' => @font_button})
|
|
156
177
|
@button_v['style'] = 'Green.TButton'
|
|
157
178
|
@button_v.bind('ButtonPress') do
|
|
158
179
|
Thread.new do
|
|
@@ -163,7 +184,8 @@ module Compilator
|
|
|
163
184
|
@button_e = Tk::Tile::Button.new(@window)
|
|
164
185
|
@button_e['text'] = 'E'
|
|
165
186
|
@button_e['underline'] = 0
|
|
166
|
-
|
|
187
|
+
@button_e['width'] = 1
|
|
188
|
+
Tk::Tile::Style.configure('Underline.TButton', {"foreground" => 'green', 'font' => @font_button})
|
|
167
189
|
@button_e['style'] = 'Underline.TButton'
|
|
168
190
|
@button_e.bind('ButtonPress') do
|
|
169
191
|
Thread.new do
|
|
@@ -173,6 +195,9 @@ module Compilator
|
|
|
173
195
|
|
|
174
196
|
@button_raz = Tk::Tile::Button.new(@window)
|
|
175
197
|
@button_raz['text'] = 'RàZ'
|
|
198
|
+
@button_raz['width'] = 1
|
|
199
|
+
Tk::Tile::Style.configure('Medium.TButton', {'font' => TkFont.new('size' => 12)})
|
|
200
|
+
@button_raz['style'] = 'Medium.TButton'
|
|
176
201
|
@button_raz.bind('ButtonPress') do
|
|
177
202
|
Thread.new do
|
|
178
203
|
@controller.notify_action(self,:button_raz_pressed)
|
|
@@ -181,6 +206,9 @@ module Compilator
|
|
|
181
206
|
|
|
182
207
|
@button_equal = Tk::Tile::Button.new(@window)
|
|
183
208
|
@button_equal['text'] = '='
|
|
209
|
+
Tk::Tile::Style.configure('Big.TButton', {'font' => TkFont.new('size' => 24)})
|
|
210
|
+
@button_equal['style'] = 'Big.TButton'
|
|
211
|
+
@button_equal['width'] = 1
|
|
184
212
|
@button_equal.bind('ButtonPress') do
|
|
185
213
|
Thread.new do
|
|
186
214
|
@controller.notify_action(self,:button_equal_pressed, :value => @entry_variable.value)
|
|
@@ -188,7 +216,10 @@ module Compilator
|
|
|
188
216
|
end
|
|
189
217
|
|
|
190
218
|
@label_result = Tk::Tile::Label.new(@window)
|
|
191
|
-
@label_result.justify
|
|
219
|
+
@label_result.justify = 'right'
|
|
220
|
+
Tk::Tile::Style.configure('Big.TLabel',{'font' => TkFont.new('size' => 12)})
|
|
221
|
+
@label_result['style'] = 'Big.TLabel'
|
|
222
|
+
|
|
192
223
|
|
|
193
224
|
#ajout
|
|
194
225
|
TkGrid.columnconfigure( @root, 0, :weight => 1 )
|
|
@@ -217,7 +248,7 @@ module Compilator
|
|
|
217
248
|
@button_raz.grid(:column => 0, :row => 3, :sticky => 'ewns')
|
|
218
249
|
@button_equal.grid(:column => 1, :row => 3, :columnspan => 2, :sticky => 'ewns')
|
|
219
250
|
|
|
220
|
-
@label_result.grid(:column => 0, :row => 4, :columnspan => 3, :sticky => '
|
|
251
|
+
@label_result.grid(:column => 0, :row => 4, :columnspan => 3, :sticky => 'ews')
|
|
221
252
|
|
|
222
253
|
end
|
|
223
254
|
|
|
@@ -229,14 +260,24 @@ module Compilator
|
|
|
229
260
|
|
|
230
261
|
def property_change(event)
|
|
231
262
|
if event.property_name == "last_key_pressed"
|
|
232
|
-
|
|
263
|
+
Thread.new do
|
|
264
|
+
@entry_variable.set_value(@entry_variable.value+event.new_value)
|
|
265
|
+
end
|
|
233
266
|
|
|
234
267
|
elsif event.property_name == 'result'
|
|
235
|
-
|
|
236
|
-
|
|
268
|
+
Thread.new do
|
|
269
|
+
@label_result.text = event.new_value.to_s
|
|
270
|
+
end
|
|
237
271
|
|
|
238
272
|
elsif event.property_name == 'raz'
|
|
239
|
-
|
|
273
|
+
Thread.new do
|
|
274
|
+
@entry_variable.set_value('')
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
elsif event.property_name == 'delete'
|
|
278
|
+
Thread.new do
|
|
279
|
+
@entry_variable.set_value(@entry_variable.value[0..-2])
|
|
280
|
+
end
|
|
240
281
|
end
|
|
241
282
|
end
|
|
242
283
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: compilator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Le Greneur
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-09-
|
|
11
|
+
date: 2016-09-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: druzy-mvc
|