glimmer-dsl-tk 0.0.32 → 0.0.36

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: 84f9643bc9497d251b1b17d52734874c954ce8ff085aee06f5a59bb98a79a1af
4
- data.tar.gz: 2a1a77e76cfbd54fa463bc8c1ea3cb2e3e175b2996471bb3e80caf588f77f1dc
3
+ metadata.gz: 808f3c088481b9a8feedbccfcab17a2b37046493141bcce5677871f90e28046e
4
+ data.tar.gz: 1f433efd48c50a6b95f61cf8bae8617c44d8bbdfe9ee8b68e4c7d0bc868e5028
5
5
  SHA512:
6
- metadata.gz: 5af953ed2716d179f70b6b844bde3fa67d808406f5796c0cedb06625e04a05945eba0ff00e8f1783603d6f5509b1abb2d31c6e10033bf0caf46e345172abff01
7
- data.tar.gz: 6f2316a161c55c14acca0da4e6704908617bdec23058245d74352a3eb118bf26bb3671bfa78065aefd5ca23a985a9acbae547fdea7c571dc0ab103f462527d4d
6
+ metadata.gz: 9e0e8067624c6493dbd33bd151b885da42e04a443ef702a65abd10578c47ae22fc12f19d114ce2c345aa9bfc57c3332fa90a6ec758b7606ad62a354363b8fa27
7
+ data.tar.gz: c29b2b44399613bd15df154ee9986807ae121fcef57ff37448014ef36cc825fe6aa80e7ae28cee02d77cbdf15893ff82ea06390ca8e46394ccd6abffdeafb21a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.36
4
+
5
+ - Hello, Toplevel! (Custom Window and Custom Dialog)
6
+ - Support `mac_style` attribute under `toplevel`
7
+ - Support registering multiple general event listeners on widgets (previously, later event listener registrations replaced former ones)
8
+ - Support `escapable true` property under `root` and `toplevel` to close on hitting ESCAPE button
9
+
10
+ ## 0.0.35
11
+
12
+ - Improved Meta-Sample by utilizing Ruby from `RbConfig.ruby`
13
+ - Improved girb_runner.rb to be more platform independent
14
+ - Fixed `text` widget binding of standard bind events (e.g. `'KeyPress'` or `'ButtonPress'`)
15
+ - Fixed Hello, Text! issue with not being able to bring up Find Dialog once all text is deleted and new text is entered
16
+ - Fixed undo/redo issue
17
+
18
+ ## 0.0.34
19
+
20
+ - When applying a `text` selection format without having a selection, have it apply to current insert mark word
21
+ - Support registering multiple general event listeners on `text` widget (previously, later event listener registrations replaced former ones)
22
+ - Implement `:no_selection_default` option of `:insert_word`, `insert_letter`, or `none` for `text` selection formatting methods (`add_selection_format`, `remove_selection_format`, `toggle_selection_format`, `add_selection_font_format`, `remove_selection_font_format`, `toggle_selection_font_format`)
23
+ - Make sure to only allow `text` undo/redo when there are changes to be undoed/redoed
24
+ - Fix issue with Hello, Text! Find Dialog not coming up with keyboard shortcut (e.g. CMD+F) anymore
25
+ - Fix issue with Hello, Text! whereby after applying background, and foreground to a selection, you cannot apply bold, italic, or underline for the same selection (or font-size or font-family)
26
+
27
+ ## 0.0.33
28
+
29
+ - Support `text` widget `InsertMarkMoved` listener event to track insert mark movement (or aliases `InsertMarkMove`, `insert_mark_move`, `insert_mark_moved`, all case-insensitive)
30
+ - Support `entry` widget `changed` and `modified` listener event aliases for `change` event
31
+ - Autodiscover format options when moving cursor in `text` widget (auto-derive from applied tags and widget font) and show in top Hello, Text! toolbar comboboxes and buttons
32
+ - Fix issue with encountering error 'NoMethodError: undefined method "size" for' when launching Hello, Text!, performing Select-All (CMD+A or CONTROL+A) and then attempting to Bold all the text.
33
+ - Fix issue in Hello, Text! whereby bolding a small region of text affects the font of the following region of text till the end of the document
34
+ - Fix issue in Hello, Text! where if all text is copied and then pasted multiple times, the `text` widget loses its keyboard/mouse listeners and CMD+F does not work anymore to bring Find dialog
35
+
3
36
  ## 0.0.32
4
37
 
5
38
  - Hello, Text! Find Dialog toolbar button
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.32
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.36
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)
@@ -55,8 +55,9 @@ NOTE: Glimmer DSL for Tk is currently in early alpha mode (incomplete). Please h
55
55
 
56
56
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
57
57
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
58
- - [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
59
58
  - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
59
+ - [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
60
+ - [glimmer-dsl-gtk](https://github.com/AndyObtiva/glimmer-dsl-gtk): Ruby-GNOME Desktop Development GUI Library
60
61
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
61
62
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
62
63
 
@@ -83,6 +84,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
83
84
  - [Notebook Frame](#notebook-frame)
84
85
  - [Icon Photo](#icon-photo)
85
86
  - [Root Background](#root-background)
87
+ - [Toplevel Mac Style](#toplevel-mac-style)
86
88
  - [Text Defaults](#text-defaults)
87
89
  - [The Grid Geometry Manager](#the-grid-geometry-manager)
88
90
  - [Data-Binding](#data-binding)
@@ -104,6 +106,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
104
106
  - [Hello, Radiobutton!](#hello-radiobutton)
105
107
  - [Hello, Frame!](#hello-frame)
106
108
  - [Hello, Root!](#hello-root)
109
+ - [Hello, Toplevel!](#hello-toplevel)
107
110
  - [Hello, Notebook!](#hello-notebook)
108
111
  - [Hello, Label!](#hello-label)
109
112
  - [Hello, Message Box!](#hello-message-box)
@@ -158,7 +161,7 @@ gem install glimmer-dsl-tk
158
161
 
159
162
  Add the following to `Gemfile`:
160
163
  ```
161
- gem 'glimmer-dsl-tk', '~> 0.0.32'
164
+ gem 'glimmer-dsl-tk', '~> 0.0.36'
162
165
  ```
163
166
 
164
167
  And, then run:
@@ -273,7 +276,7 @@ keyword(args) | attributes | event bindings & callbacks
273
276
  `choose_directory(options = nil)` | None | None
274
277
  `choose_font(options = nil) {|font| ... }` | None | None
275
278
  `combobox` | `state`, `text` | `'ComboboxSelected'`
276
- `entry` | `width`, `text`, `validate`, `show` (`'none', 'focus', 'focusin', 'focusout', 'key', or 'all'`) | `'validate'`, `'invalid'`, `'change'`, `validatecommand {}`, `invalidcommand {}`
279
+ `entry` | `width`, `text`, `validate`, `show` (`'none', 'focus', 'focusin', 'focusout', 'key', or 'all'`) | `'validate'`, `'invalid'`, `'change'` (alias: `'changed'`), `validatecommand {}`, `invalidcommand {}`
277
280
  `get_multiple_open_file(options = nil)` | None | None
278
281
  `get_open_file(options = nil)` | None | None
279
282
  `get_save_file(options = nil)` | None | None
@@ -286,7 +289,7 @@ keyword(args) | attributes | event bindings & callbacks
286
289
  `radiobutton` | `text`, `variable` (Boolean), `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `value` (default: `text`) | `command {}`
287
290
  `root` | `title`, `iconphoto`, `background`, `alpha`, `fullscreen?`, `topmost?`, `transparent?`, `stackorder`, `winfo_screendepth`, `winfo_screenvisual`, `winfo_screenwidth`, `winfo_screenheight`, `winfo_pixels('li')`, `winfo_screen`, `wm_maxsize`, `state` (`'normal', 'iconic', 'withdrawn', 'icon', 'zoomed'`) | `'DELETE_WINDOW'`, `'OPEN_WINDOW'`
288
291
  `separator` | `orient` (`'horizontal' (default) or 'vertical'`) | None
289
- `text` | `value`, [many more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `'modified'`, `'selection'`
292
+ `text` | `value`, [many more attributes](https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M116) | `'modified'`, `'selection'`, `'insert_mark_moved'` (alias: `'insert_mark_move', 'InsertMarkMove', 'InsertMarkMoved'`)
290
293
 
291
294
  Options for `get_open_file` and `get_multiple_open_file` include:
292
295
  - `filetypes`: `Hash` of `'Group Name' => '.ext'` entries (e.g. `filetypes: {'PNG Images' => '.png'}`
@@ -349,15 +352,20 @@ The `text` widget is enhanced by [Glimmer DSL for Tk](https://rubygems.org/gems/
349
352
  - `add_font_format(region_start, region_end, font_option, value)`
350
353
  - `remove_font_format(region_start, region_end, font_option, value)`
351
354
  - `toggle_font_format(region_start, region_end, font_option, value)`
352
- - `add_selection_format(region_start, region_end, option, value)`
353
- - `remove_selection_format(region_start, region_end, option, value)`
354
- - `toggle_selection_format(region_start, region_end, option, value)`
355
- - `add_selection_font_format(region_start, region_end, font_option, value)`
356
- - `remove_selection_font_format(region_start, region_end, font_option, value)`
357
- - `toggle_selection_font_format(region_start, region_end, font_option, value)`
355
+ - `add_selection_format(option, value, no_selection_default: :insert_word)`: adds format to selection. If there is no selection, then applies format to current insert mark word.
356
+ - `remove_selection_format(option, value, no_selection_default: :insert_word)`
357
+ - `toggle_selection_format(option, value, no_selection_default: :insert_word)`: toggles format on selection. If there is no selection, then toggles format on current insert mark word.
358
+ - `add_selection_font_format(font_option, value, no_selection_default: :insert_word)`
359
+ - `remove_selection_font_format(font_option, value, no_selection_default: :insert_word)`
360
+ - `toggle_selection_font_format(font_option, value, no_selection_default: :insert_word)`
358
361
  - `text#insert_image(text_index, *image_args)`: inserts image into `text` `value` content at `text_index` location (e.g. `'insert'`)
359
362
  - `text#get_open_file_to_insert_image(text_index = 'insert')`: opens a file dialog to select one of the available image formats and then inserts image into `text` `value` content
360
363
 
364
+ The `:no_selection_default` keyword arg to `*_selection_*` methods determines what region to cover when no explicit selection is set:
365
+ - `:insert_word`: current word for insert mark
366
+ - `:insert_letter`: current letter for insert mark
367
+ - `:none`: no behavior when no selection is in place
368
+
361
369
  Available options:
362
370
 
363
371
  - `background`
@@ -473,6 +481,20 @@ root {
473
481
 
474
482
  `root` `background` color attribute is automatically set to `'#ececec'` on the Mac to avoid having a non-native-looking light-colored background.
475
483
 
484
+ #### Toplevel Mac Style
485
+
486
+ Mac has special support for mac styles in Tk `toplevel` via the `mac_style` attribute, which can receive 1 to 2 arguments. `mac_style`'s first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page:
487
+
488
+ https://wiki.tcl-lang.org/page/MacWindowStyle
489
+
490
+ Behind the scenes, `mac_style` automatically calls out to:
491
+
492
+ ```ruby
493
+ Tk.tk_call("::tk::unsupported::MacWindowStyle", "style", tk_toplevel_widget, mac_class, mac_attribute_list)
494
+ ```
495
+
496
+ More details can be found at the [Hello, Toplevel!](#hello-toplevel) sample.
497
+
476
498
  #### Text Defaults
477
499
 
478
500
  `text` widget has these defaults:
@@ -1327,7 +1349,7 @@ Glimmer app:
1327
1349
 
1328
1350
  ### Hello, Root!
1329
1351
 
1330
- Glimmer code (from [samples/hello/hello_frame.rb](samples/hello/hello_frame.rb)):
1352
+ Glimmer code (from [samples/hello/hello_root.rb](samples/hello/hello_root.rb)):
1331
1353
 
1332
1354
  ```ruby
1333
1355
  require 'glimmer-dsl-tk'
@@ -1379,6 +1401,208 @@ Glimmer app:
1379
1401
 
1380
1402
  ![glimmer dsl tk screenshot sample hello root bye](images/glimmer-dsl-tk-screenshot-sample-hello-root-bye.png)
1381
1403
 
1404
+ ### Hello, Toplevel!
1405
+
1406
+ `toplevel` widgets represent windows nested under `root`, which can be modeless (custom windows) or modal (dialogs that take the focus away from the owning window behind them until closed).
1407
+
1408
+ Mac has special support for mac styles in Tk `toplevel` via the `mac_style` attribute, which can receive 1 to 2 arguments. `mac_style`'s first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page:
1409
+
1410
+ https://wiki.tcl-lang.org/page/MacWindowStyle
1411
+
1412
+ Glimmer code (from [samples/hello/hello_toplevel.rb](samples/hello/hello_toplevel.rb)):
1413
+
1414
+ ```ruby
1415
+ require 'glimmer-dsl-tk'
1416
+
1417
+ include Glimmer
1418
+
1419
+ def toplevel_content
1420
+ frame {
1421
+ label {
1422
+ text "This is a fully custom toplevel, meaning you can add any widgets here!\nYou can press the ESCAPE button on the keyboard to close."
1423
+ }
1424
+ separator
1425
+ checkbutton {
1426
+ text 'This is a checkbutton'
1427
+ }
1428
+ radiobutton {
1429
+ text 'This is a radiobutton'
1430
+ }
1431
+ }
1432
+ end
1433
+
1434
+ root { |root_window|
1435
+ title 'Hello, Toplevel!'
1436
+
1437
+ button {
1438
+ text 'Nested Window'
1439
+
1440
+ on('command') do
1441
+ toplevel(root_window) {
1442
+ title 'Custom Window'
1443
+ escapable true
1444
+ x 150
1445
+ y 180
1446
+ width 500
1447
+ height 200
1448
+ minsize 500, 100
1449
+ maxsize 1000, 300
1450
+
1451
+ toplevel_content
1452
+ }
1453
+ end
1454
+ }
1455
+
1456
+ button {
1457
+ text 'Transparent Window'
1458
+
1459
+ on('command') do
1460
+ toplevel(root_window) {
1461
+ title 'Transparent Window'
1462
+ escapable true
1463
+ alpha 0.85
1464
+ width 250
1465
+ height 100
1466
+ resizable false, false # not resizable horizontally or vertically
1467
+
1468
+ frame {
1469
+ label {
1470
+ text "This is a transparent window\nYou can hit ESCAPE to close."
1471
+ anchor 'center'
1472
+ }
1473
+ }
1474
+ }
1475
+ end
1476
+ }
1477
+
1478
+ button {
1479
+ text 'Fullscreen Window'
1480
+
1481
+ on('command') do
1482
+ toplevel(root_window) {
1483
+ title 'Fullscreen Window'
1484
+ escapable true
1485
+ fullscreen true
1486
+
1487
+ frame {
1488
+ label {
1489
+ text "This is a fullscreen window\nYou can hit ESCAPE to close."
1490
+ anchor 'center'
1491
+ }
1492
+ }
1493
+ }
1494
+ end
1495
+ }
1496
+
1497
+ if OS.mac?
1498
+ # Mac has special support for mac styles in Tk `toplevel`
1499
+ # `mac_style` first argument (`mac_class`) and second argument (`mac_attribute_list`) can be chosen from this page: https://wiki.tcl-lang.org/page/MacWindowStyle
1500
+
1501
+ button {
1502
+ text 'Mac Plain (No-Button-Modeless) Window'
1503
+
1504
+ on('command') do
1505
+ toplevel(root_window) { |t|
1506
+ title 'Mac Plain (No-Button-Modeless) Window'
1507
+ escapable true
1508
+ mac_style 'plain'
1509
+
1510
+ toplevel_content
1511
+ }
1512
+ end
1513
+ }
1514
+
1515
+ button {
1516
+ text 'Mac Floating (Close-Button-Modeless) Window'
1517
+
1518
+ on('command') do
1519
+ toplevel(root_window) { |t|
1520
+ title 'Mac Floating (Close-Button-Modeless) Window'
1521
+ escapable true
1522
+ mac_style 'floating'
1523
+
1524
+ toplevel_content
1525
+ }
1526
+ end
1527
+ }
1528
+
1529
+ button {
1530
+ text 'Mac Document (All-Button-Modeless) Window'
1531
+
1532
+ on('command') do
1533
+ toplevel(root_window) { |t|
1534
+ title 'Mac Document (All-Button-Modeless) Window'
1535
+ escapable true
1536
+ mac_style 'document'
1537
+
1538
+ toplevel_content
1539
+ }
1540
+ end
1541
+ }
1542
+
1543
+ button {
1544
+ text 'Mac Utility (Close-Button-Modal) Dialog'
1545
+
1546
+ on('command') do
1547
+ toplevel(root_window) { |t|
1548
+ title 'Mac Utility (Close-Button-Modal) Dialog'
1549
+ escapable true
1550
+ mac_style 'utility'
1551
+
1552
+ toplevel_content
1553
+ }
1554
+ end
1555
+ }
1556
+
1557
+ button {
1558
+ text 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
1559
+
1560
+ on('command') do
1561
+ toplevel(root_window) { |t|
1562
+ title 'Mac Utility with Attribute List (All-Button-Modal) Dialog'
1563
+ escapable true
1564
+ mac_style 'utility', 'closeBox collapseBox resizable horizontalZoom verticalZoom sideTitlebar'
1565
+
1566
+ toplevel_content
1567
+ }
1568
+ end
1569
+ }
1570
+ end
1571
+ }.open
1572
+ ```
1573
+
1574
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
1575
+
1576
+ ```
1577
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_toplevel'"
1578
+ ```
1579
+
1580
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
1581
+
1582
+ ```
1583
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_toplevel.rb
1584
+ ```
1585
+
1586
+ Glimmer app:
1587
+
1588
+ ![glimmer dsl tk screenshot sample hello toplevel 1](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel.png)
1589
+
1590
+ ![glimmer dsl tk screenshot sample hello toplevel 2](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-custom-window.png)
1591
+
1592
+ ![glimmer dsl tk screenshot sample hello toplevel 3](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-transparent-window.png)
1593
+
1594
+ ![glimmer dsl tk screenshot sample hello toplevel 4](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-fullscreen-window.png)
1595
+
1596
+ ![glimmer dsl tk screenshot sample hello toplevel 5](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-plain-window.png)
1597
+
1598
+ ![glimmer dsl tk screenshot sample hello toplevel 6](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-floating-window.png)
1599
+
1600
+ ![glimmer dsl tk screenshot sample hello toplevel 7](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-document-window.png)
1601
+
1602
+ ![glimmer dsl tk screenshot sample hello toplevel 8](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-utility-window.png)
1603
+
1604
+ ![glimmer dsl tk screenshot sample hello toplevel 9](images/glimmer-dsl-tk-screenshot-sample-hello-toplevel-mac-utility-with-attribute-list-window.png)
1605
+
1382
1606
  ### Hello, Notebook!
1383
1607
 
1384
1608
  Glimmer code (from [samples/hello/hello_notebook.rb](samples/hello/hello_notebook.rb)):
@@ -1869,7 +2093,7 @@ Glimmer app:
1869
2093
 
1870
2094
  ### Hello, Text!
1871
2095
 
1872
- You may use the META+F shortcut to bring up the Find Dialog.
2096
+ You may press META+F to bring up the Find Dialog on the Mac and CONTROL+F to bring it up on Windows/Linux.
1873
2097
 
1874
2098
  Icons used in this sample were made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>
1875
2099
 
@@ -1921,7 +2145,7 @@ class HelloText
1921
2145
  MULTI_LINE_STRING
1922
2146
  end
1923
2147
 
1924
- attr_accessor :document
2148
+ attr_accessor :document, :find_text
1925
2149
 
1926
2150
  attr_accessor :foreground
1927
2151
 
@@ -1947,8 +2171,16 @@ class HelloText
1947
2171
  [FONT_SIZE_PROMPT] + (9..64).to_a.map(&:to_s)
1948
2172
  end
1949
2173
 
2174
+ def find
2175
+ text_index = @text.search(/#{find_text}/i, @text.tag_ranges('sel')&.first&.last || @text.index('insert'))
2176
+ unless text_index.to_s.empty?
2177
+ @text.tag_remove('sel', '1.0', 'end')
2178
+ @text.tag_add('sel', text_index, "#{text_index} + #{find_text.size} chars")
2179
+ end
2180
+ end
2181
+
1950
2182
  def launch
1951
- root {
2183
+ @root = root {
1952
2184
  title 'Hello, Text!'
1953
2185
  width 1280
1954
2186
  height 800
@@ -1956,11 +2188,6 @@ class HelloText
1956
2188
  frame {
1957
2189
  grid row: 0, column: 0
1958
2190
 
1959
- label {
1960
- grid row: 0, column: 0, columnspan: 17
1961
- text 'Select a region of text and then apply formatting from the toolbar'
1962
- }
1963
-
1964
2191
  column_index = -1
1965
2192
 
1966
2193
  combobox {
@@ -1992,7 +2219,7 @@ class HelloText
1992
2219
  orient 'vertical'
1993
2220
  }
1994
2221
 
1995
- button {
2222
+ @bold_button = button {
1996
2223
  grid row: 1, column: column_index += 1, column_weight: 0
1997
2224
  text 'B'
1998
2225
  style font: {weight: 'bold'}
@@ -2002,7 +2229,7 @@ class HelloText
2002
2229
  end
2003
2230
  }
2004
2231
 
2005
- button {
2232
+ @italic_button = button {
2006
2233
  grid row: 1, column: column_index += 1, column_weight: 0
2007
2234
  text 'I'
2008
2235
  style font: {slant: 'italic'}
@@ -2012,7 +2239,7 @@ class HelloText
2012
2239
  end
2013
2240
  }
2014
2241
 
2015
- button {
2242
+ @underline_button = button {
2016
2243
  grid row: 1, column: column_index += 1, column_weight: 0
2017
2244
  text 'U'
2018
2245
  style font: {underline: true}
@@ -2021,36 +2248,36 @@ class HelloText
2021
2248
  @text.toggle_selection_font_format('underline', true)
2022
2249
  end
2023
2250
  }
2024
-
2251
+
2025
2252
  separator {
2026
2253
  grid row: 1, column: column_index += 1, column_weight: 0
2027
2254
  orient 'vertical'
2028
2255
  }
2029
2256
 
2030
- button {
2257
+ @justify_left_button = button {
2031
2258
  grid row: 1, column: column_index += 1, column_weight: 0
2032
- image File.expand_path("images/cut.png", __dir__), subsample: 32
2259
+ image File.expand_path("images/align-left.png", __dir__), subsample: 32
2033
2260
 
2034
2261
  on('command') do
2035
- @text.text_cut
2262
+ @text.add_selection_format('justify', 'left')
2036
2263
  end
2037
2264
  }
2038
2265
 
2039
- button {
2266
+ @justify_center_button = button {
2040
2267
  grid row: 1, column: column_index += 1, column_weight: 0
2041
- image File.expand_path("images/copy.png", __dir__), subsample: 32
2268
+ image File.expand_path("images/align-center.png", __dir__), subsample: 32
2042
2269
 
2043
2270
  on('command') do
2044
- @text.text_copy
2271
+ @text.add_selection_format('justify', 'center')
2045
2272
  end
2046
2273
  }
2047
2274
 
2048
- button {
2275
+ @justify_right_button = button {
2049
2276
  grid row: 1, column: column_index += 1, column_weight: 0
2050
- image File.expand_path("images/paste.png", __dir__), subsample: 32
2277
+ image File.expand_path("images/align-right.png", __dir__), subsample: 32
2051
2278
 
2052
2279
  on('command') do
2053
- @text.text_paste
2280
+ @text.add_selection_format('justify', 'right')
2054
2281
  end
2055
2282
  }
2056
2283
 
@@ -2061,51 +2288,51 @@ class HelloText
2061
2288
 
2062
2289
  button {
2063
2290
  grid row: 1, column: column_index += 1, column_weight: 0
2064
- image File.expand_path("images/align-left.png", __dir__), subsample: 32
2291
+ image File.expand_path("images/picture.png", __dir__), subsample: 32
2065
2292
 
2066
2293
  on('command') do
2067
- @text.add_selection_format('justify', 'left')
2294
+ @text.get_open_file_to_insert_image
2068
2295
  end
2069
2296
  }
2070
2297
 
2071
2298
  button {
2072
2299
  grid row: 1, column: column_index += 1, column_weight: 0
2073
- image File.expand_path("images/align-center.png", __dir__), subsample: 32
2300
+ image File.expand_path("images/search.png", __dir__), subsample: 32
2074
2301
 
2075
2302
  on('command') do
2076
- @text.add_selection_format('justify', 'center')
2303
+ show_find_dialog
2077
2304
  end
2078
2305
  }
2079
2306
 
2307
+ separator {
2308
+ grid row: 1, column: column_index += 1, column_weight: 0
2309
+ orient 'vertical'
2310
+ }
2311
+
2080
2312
  button {
2081
2313
  grid row: 1, column: column_index += 1, column_weight: 0
2082
- image File.expand_path("images/align-right.png", __dir__), subsample: 32
2314
+ image File.expand_path("images/cut.png", __dir__), subsample: 32
2083
2315
 
2084
2316
  on('command') do
2085
- @text.add_selection_format('justify', 'right')
2317
+ @text.text_cut
2086
2318
  end
2087
2319
  }
2088
2320
 
2089
- separator {
2090
- grid row: 1, column: column_index += 1, column_weight: 0
2091
- orient 'vertical'
2092
- }
2093
-
2094
2321
  button {
2095
2322
  grid row: 1, column: column_index += 1, column_weight: 0
2096
- image File.expand_path("images/undo.png", __dir__), subsample: 32
2323
+ image File.expand_path("images/copy.png", __dir__), subsample: 32
2097
2324
 
2098
2325
  on('command') do
2099
- @text.edit_undo
2326
+ @text.text_copy
2100
2327
  end
2101
2328
  }
2102
2329
 
2103
2330
  button {
2104
2331
  grid row: 1, column: column_index += 1, column_weight: 0
2105
- image File.expand_path("images/redo.png", __dir__), subsample: 32
2332
+ image File.expand_path("images/paste.png", __dir__), subsample: 32
2106
2333
 
2107
2334
  on('command') do
2108
- @text.edit_redo
2335
+ @text.text_paste
2109
2336
  end
2110
2337
  }
2111
2338
 
@@ -2114,12 +2341,22 @@ class HelloText
2114
2341
  orient 'vertical'
2115
2342
  }
2116
2343
 
2344
+
2117
2345
  button {
2118
2346
  grid row: 1, column: column_index += 1, column_weight: 0
2119
- image File.expand_path("images/picture.png", __dir__), subsample: 32
2347
+ image File.expand_path("images/undo.png", __dir__), subsample: 32
2120
2348
 
2121
2349
  on('command') do
2122
- @text.get_open_file_to_insert_image
2350
+ @text.edit_undo
2351
+ end
2352
+ }
2353
+
2354
+ button {
2355
+ grid row: 1, column: column_index += 1, column_weight: 0
2356
+ image File.expand_path("images/redo.png", __dir__), subsample: 32
2357
+
2358
+ on('command') do
2359
+ @text.edit_redo
2123
2360
  end
2124
2361
  }
2125
2362
  }
@@ -2129,8 +2366,67 @@ class HelloText
2129
2366
  wrap 'word'
2130
2367
  undo true
2131
2368
  value <=> [self, :document]
2369
+
2370
+ on('KeyPress') do |event|
2371
+ show_find_dialog if (event.keysym == 'f') && ((OS.mac? && event.state == 8) || (!OS.mac? && event.state == 4))
2372
+ end
2373
+
2374
+ on('InsertMarkMoved') do
2375
+ self.font_family = @text.applied_font_format_value('family')
2376
+ self.font_size = @text.applied_font_format_value('size')
2377
+ @bold_button.default = @text.applied_font_format_value('weight') == 'bold' ? 'active' : 'normal'
2378
+ @italic_button.default = @text.applied_font_format_value('slant') == 'italic' ? 'active' : 'normal'
2379
+ @underline_button.default = @text.applied_font_format_value('underline') == true ? 'active' : 'normal'
2380
+ self.background = @text.applied_format_value('background')
2381
+ self.foreground = @text.applied_format_value('foreground')
2382
+ @justify_left_button.default = @text.applied_format_value('justify') == 'left' ? 'active' : 'normal'
2383
+ @justify_center_button.default = @text.applied_format_value('justify') == 'center' ? 'active' : 'normal'
2384
+ @justify_right_button.default = @text.applied_format_value('justify') == 'right' ? 'active' : 'normal'
2385
+ end
2132
2386
  }
2133
- }.open
2387
+ }
2388
+ @root.open
2389
+ end
2390
+
2391
+ def show_find_dialog
2392
+ toplevel(@root) { |tl|
2393
+ title 'Find'
2394
+
2395
+ label {
2396
+ text 'Text:'
2397
+ }
2398
+ entry { |e|
2399
+ focus true
2400
+ text <=> [
2401
+ self,
2402
+ :find_text,
2403
+ after_write: lambda do
2404
+ text_index = @text.search(/#{find_text}/i, 'insert')
2405
+ unless text_index.to_s.empty?
2406
+ @text.tag_remove('sel', '1.0', 'end')
2407
+ @text.tag_add('sel', text_index, "#{text_index} + #{find_text.size} chars")
2408
+ end
2409
+ end
2410
+ ]
2411
+
2412
+ on('KeyPress') do |event|
2413
+ if event.keysym == 'Return'
2414
+ find
2415
+ elsif event.keysym == 'Escape'
2416
+ tl.grab_release
2417
+ tl.destroy
2418
+ end
2419
+ end
2420
+ }
2421
+ button {
2422
+ text 'Find'
2423
+ default 'active'
2424
+
2425
+ on('command') do
2426
+ find
2427
+ end
2428
+ }
2429
+ }
2134
2430
  end
2135
2431
  end
2136
2432
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.32
1
+ 0.0.36
data/bin/girb_runner.rb CHANGED
@@ -27,7 +27,7 @@ require_relative '../lib/glimmer-dsl-tk'
27
27
 
28
28
  include Glimmer
29
29
 
30
- GIRB_RUNNER_EXIT_FILE = "#{Etc.getpwuid.dir}/.girb_runner_exit"
30
+ GIRB_RUNNER_EXIT_FILE = "#{Dir.home}/.girb_runner_exit"
31
31
  FileUtils.rm_rf GIRB_RUNNER_EXIT_FILE
32
32
 
33
33
  @exit_method = method(:exit)
Binary file
@@ -33,7 +33,7 @@ module Glimmer
33
33
 
34
34
  def can_interpret?(parent, keyword, *args, &block)
35
35
  !EXCLUDED_KEYWORDS.include?(keyword) and
36
- Glimmer::Tk::WidgetProxy.widget_exists?(keyword)
36
+ Glimmer::Tk::WidgetProxy.widget_exists?(keyword) and
37
37
  (parent.respond_to?(:tk) or args.first.respond_to?(:tk))
38
38
  end
39
39