dialogbind 0.9.4 → 0.9.4.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dialogbind.rb +20 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15db92bd3bcd2c1f15e7dd00f4f643f0e3cf967e0c4ca6822fd51bba303a9c37
4
- data.tar.gz: 0d7f0743dbd44377eed925c1927eb61d85b99ac8d9677341cb407917759cc979
3
+ metadata.gz: 5b6ae43bbbb3723872dc171fa5fee54053b579cd4c78a63bc72d1cdf05e9ecae
4
+ data.tar.gz: 7c2f954dad2452fe21374eca48e07efd7270e2d88793a74ce7c18629b4bb8556
5
5
  SHA512:
6
- metadata.gz: 3a05bba5157559fe28498d1ea90757f84e21dcf37405331be852d31cb7b9c5f950eaa19ada11ad36a4ad2588af89b1b26e76b6802a13a97b8c8b6069bd0b4ab6
7
- data.tar.gz: 501746e21d415a8e7a9b97677e337e13222631bc9792fc0bbf281394cb4127a4f726f6445671b9410511f03606b7986d9fa903b6f469f689bc68bda20efe9c15
6
+ metadata.gz: c318c17e91699f02fbf2531d25e8fb8c8d2eada0bcd0f0c9f9882ae0995b3f8f30ee4c55ede97f770659668aa78506a360185779c5f95e989a258d8b12195668
7
+ data.tar.gz: 4795b55a9cd36909f618b5454ff686e58114d982fdcbe3746c4f2eb20abcca65e97e4ae789206b834bae24c2b8fbb7e63aebd2c0e7b5501d5cac248b3429558f
data/lib/dialogbind.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  require 'fiddle/import'
9
9
 
10
10
  $dialogbind_macos_script_cmd = ''
11
- $dialogbind_version = '0.9.4'
11
+ $dialogbind_version = '0.9.4.1'
12
12
 
13
13
  # @!visibility private
14
14
  def zenity(arg)
@@ -182,14 +182,14 @@ if $dialogbind_dialog_backend == 'win32' then
182
182
  end
183
183
  File.write(tmpfile_loc, write_out)
184
184
  tmpfile_loc_w = tmpfile_loc.gsub('/', "\\")
185
- cmd_out = `cscript //Nologo "#{tmpfile_loc_w}"`.gsub("\r\n", "")
185
+ cmd_out = `cscript //Nologo "#{tmpfile_loc_w}"`.gsub("\r\n", "\n").gsub("\n", "")
186
186
  File.delete(tmpfile_loc)
187
187
  return cmd_out
188
188
  end
189
189
 
190
190
  # @!visibility private
191
191
  def win32_vbinputbox(text)
192
- write_out = 'a = inputbox("' + text.gsub('"', '') + '")'
192
+ write_out = 'a = inputbox("' + text.gsub('"', '').gsub("\r\n", "\n").gsub("\n", "\" + chr(13) + _ \n \"") + '")'
193
193
  write_out += "\r\nWScript.Echo a"
194
194
  return win32_generatevbs(write_out)
195
195
  end
@@ -346,7 +346,7 @@ end
346
346
 
347
347
  # Shows either a message box with buttons matching the items specified in the array ``entries`` or a list message box.
348
348
  #
349
- # @param entries [Array] an array of strings that should be displayed as list in a message box. More than two items are currently not supported.
349
+ # @param entries [Array] an array of strings that should be displayed as list in a message box.
350
350
  # @param text [String] the text that should be displayed in a message box
351
351
  # @param title [String] an optional parameter specifying the title of the message box. Ignored on macOS.
352
352
  # @return [String] the selected string or nil on cancel
@@ -377,12 +377,28 @@ def guiselect(entries, text='Choose one of the items below:', title='DialogBind'
377
377
  return nil
378
378
  end
379
379
  item_index = File.read('/tmp/kdialog.sock').gsub("\n", "").to_i
380
+ if item_index > entries.length then
381
+ return ''
382
+ end
380
383
  return entries[item_index].clone
381
384
  elsif $dialogbind_dialog_backend == 'macos' then
382
385
  if entries.include? 'false' then
383
386
  raise 'The list of items to present to the user cannot contain the words "true" or "false" without additional punctuation due to limitations of AppleScript that is called from Ruby on macOS to display dialogs.'
384
387
  end
385
388
  return macselect(entries, text)
389
+ elsif $dialogbind_dialog_backend == 'win32' then
390
+ combined_msg = text.clone
391
+ count = 0
392
+ entries.each do |entry_item|
393
+ combined_msg += "\r\n" + count.to_s + '. ' + entry_item.to_s
394
+ count += 1
395
+ end
396
+ combined_msg += "\r\n" + " (To select one of the items above, enter the matching number before the dot)"
397
+ entered_id = win32_vbinputbox(combined_msg).to_i
398
+ if entered_id > entries.length then
399
+ return ''
400
+ end
401
+ return entries[entered_id].clone
386
402
  else
387
403
  raise 'The selected backend does not support license message boxes.'
388
404
  return false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dialogbind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim K