glimmer-dsl-tk 0.0.31 → 0.0.32

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 883bb9d265c58ea872a90069aba8e308ee4688653d2ca200fb5289976850dc1c
4
- data.tar.gz: 34f92aa593f48fbe0edf1b469ebc5ec0b81e2789a8995d1b04cd77748c72c081
3
+ metadata.gz: 84f9643bc9497d251b1b17d52734874c954ce8ff085aee06f5a59bb98a79a1af
4
+ data.tar.gz: 2a1a77e76cfbd54fa463bc8c1ea3cb2e3e175b2996471bb3e80caf588f77f1dc
5
5
  SHA512:
6
- metadata.gz: a8a0d78446483775e82da34e94ede3a1566b2e1201cd5c3bbbfaa1ed27f424bcb1d61826b7f600616550e999bcec117560d52742f3a4779d94dd8aa7adf18661
7
- data.tar.gz: fbc6ad5515dc20099c7e1c1827738f7d2edc133575f030afa69c2256c3e2bc6981986e494ada3498eeda6e4809bc5409dd7a61cc91666898d0dd48d7f1805277
6
+ metadata.gz: 5af953ed2716d179f70b6b844bde3fa67d808406f5796c0cedb06625e04a05945eba0ff00e8f1783603d6f5509b1abb2d31c6e10033bf0caf46e345172abff01
7
+ data.tar.gz: 6f2316a161c55c14acca0da4e6704908617bdec23058245d74352a3eb118bf26bb3671bfa78065aefd5ca23a985a9acbae547fdea7c571dc0ab103f462527d4d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.32
4
+
5
+ - Hello, Text! Find Dialog toolbar button
6
+ - Hello, Text! Find Dialog Windows/Linux CONTROL+F shortcut alternative to Mac CMD+F
7
+
3
8
  ## 0.0.31
4
9
 
5
10
  - Improve Hello, Text! (toolbar buttons: justify left, justify center, justify right)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.30
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.32
2
2
  ## MRI Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
4
4
  [![Ruby](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml/badge.svg)](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml)
@@ -158,7 +158,7 @@ gem install glimmer-dsl-tk
158
158
 
159
159
  Add the following to `Gemfile`:
160
160
  ```
161
- gem 'glimmer-dsl-tk', '~> 0.0.30'
161
+ gem 'glimmer-dsl-tk', '~> 0.0.32'
162
162
  ```
163
163
 
164
164
  And, then run:
@@ -200,7 +200,7 @@ The Glimmer GUI DSL follows these simple concepts in mapping from Tk syntax:
200
200
  - **Widget Keyword**: Any Tk widget (e.g. `Tk::Tile::Label`) or toplevel window (e.g. `TkRoot`) may be declared by its lower-case underscored name without the namespace (e.g. `label` or `root`). This is called a keyword and is represented in the Glimmer GUI DSL by a Ruby method behind the scenes.
201
201
  - **Args**: Any keyword method may optionally take arguments surrounded by parentheses (e.g. a `frame` nested under a `notebook` may receive tab options like `frame(text: 'Users')`, which gets used behind the scenes by Tk code such as `notebook.add tab, text: 'Users'`)
202
202
  - **Content/Options Block**: Any keyword may optionally be followed by a Ruby curly-brace block containing nested widgets (content) and attributes (options). Attributes are simply Tk option keywords followed by arguments and no block (e.g. `title 'Hello, World!'` under a `root`)
203
- - **Event Binding Block**: `on(event) {}` keyword receiving a Tk binding event name (e.g. `KeyPress` or `ComboboxSelected`). No need to surround event by `<>` as [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) takes care of that automatically.
203
+ - **Event Binding Block**: `on(event) {}` keyword receiving a Tk binding event name (e.g. `KeyPress` or `ComboboxSelected`). Surrounding event by `<>` is optional as [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk) can take care of that automatically.
204
204
 
205
205
  Example of an app written in [Tk](https://www.tcl.tk/) imperative syntax:
206
206
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.31
1
+ 0.0.32
Binary file
@@ -99,7 +99,7 @@ class HelloText
99
99
  end
100
100
 
101
101
  def launch
102
- root { |r|
102
+ @root = root {
103
103
  title 'Hello, Text!'
104
104
  width 1280
105
105
  height 800
@@ -273,6 +273,15 @@ class HelloText
273
273
  @text.get_open_file_to_insert_image
274
274
  end
275
275
  }
276
+
277
+ button {
278
+ grid row: 1, column: column_index += 1, column_weight: 0
279
+ image File.expand_path("images/search.png", __dir__), subsample: 32
280
+
281
+ on('command') do
282
+ show_find_dialog
283
+ end
284
+ }
276
285
  }
277
286
 
278
287
  @text = text {
@@ -282,49 +291,52 @@ class HelloText
282
291
  value <=> [self, :document]
283
292
 
284
293
  on('KeyPress') do |event|
285
- if event.state == 8 && event.char == 'f'
286
- toplevel(r) { |tl|
287
- title 'Find'
288
-
289
- label {
290
- text 'Text:'
291
- }
292
- entry { |e|
293
- focus true
294
- text <=> [
295
- self,
296
- :find_text,
297
- after_write: lambda do
298
- text_index = @text.search(/#{find_text}/i, 'insert')
299
- unless text_index.to_s.empty?
300
- @text.tag_remove('sel', '1.0', 'end')
301
- @text.tag_add('sel', text_index, "#{text_index} + #{find_text.size} chars")
302
- end
303
- end
304
- ]
305
-
306
- on('KeyPress') do |event|
307
- if event.keysym == 'Return'
308
- find
309
- elsif event.keysym == 'Escape'
310
- tl.grab_release
311
- tl.destroy
312
- end
313
- end
314
- }
315
- button {
316
- text 'Find'
317
- default 'active'
318
-
319
- on('command') do
320
- find
321
- end
322
- }
323
- }
294
+ show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
295
+ end
296
+ }
297
+ }
298
+ @root.open
299
+ end
300
+
301
+ def show_find_dialog
302
+ toplevel(@root) { |tl|
303
+ title 'Find'
304
+
305
+ label {
306
+ text 'Text:'
307
+ }
308
+ entry { |e|
309
+ focus true
310
+ text <=> [
311
+ self,
312
+ :find_text,
313
+ after_write: lambda do
314
+ text_index = @text.search(/#{find_text}/i, 'insert')
315
+ unless text_index.to_s.empty?
316
+ @text.tag_remove('sel', '1.0', 'end')
317
+ @text.tag_add('sel', text_index, "#{text_index} + #{find_text.size} chars")
318
+ end
324
319
  end
320
+ ]
321
+
322
+ on('KeyPress') do |event|
323
+ if event.keysym == 'Return'
324
+ find
325
+ elsif event.keysym == 'Escape'
326
+ tl.grab_release
327
+ tl.destroy
328
+ end
329
+ end
330
+ }
331
+ button {
332
+ text 'Find'
333
+ default 'active'
334
+
335
+ on('command') do
336
+ find
325
337
  end
326
338
  }
327
- }.open
339
+ }
328
340
  end
329
341
  end
330
342
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer