textbringer 15 → 16

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: 5ad5b7d9a5cc2022075f802db23f24781dcb3be366a4ba3ee27015a66ada834d
4
- data.tar.gz: 1933c54c72c4e189b4f0a6ba81d6186d7618c9eaaa3eccbe5b61925d8959c108
3
+ metadata.gz: 0b838b91740f3985ebcdc6987e72ea7fe9daa28ad0b273a6f6e0f309818778a6
4
+ data.tar.gz: 51a55425c1cdaefb69b74451c3c9091f85138549a27a60e8ebb23161b4530847
5
5
  SHA512:
6
- metadata.gz: 44736e20de4174e865ad160107e48461e26d46cd495e74000138c724753dafaae65b5e530902e8f1ad1f38659e301cfe2fbec71208913f85d01af5e23b124bc5
7
- data.tar.gz: b07e7c3533f540b88157c268d498f7ec6bd077db6fce0e3adb154acc02fb9d960cee0bfb23cd91342a6dce12f0c8af1083dac1434fc67c9fddc361bd03623ded
6
+ metadata.gz: 128afb2fe777b9847ace11badce3121391576a98b7caba7f5bdb93faf4383e00b15db4ae23e263e8f1a26fc79ef1b3fa5b12d02e6ae8b590533088c680ef3532
7
+ data.tar.gz: 4e082735768a0d2647abf67ca9c7a5268ba6607fe59462de26dff2e59caca272c68224e061791cad58d6f81648bb17c9031b880361a56ce93912b3e27c487457
data/exe/txtb CHANGED
@@ -29,6 +29,8 @@ begin
29
29
  Window.start do
30
30
  $stdout = DefaultOutput.new
31
31
  begin
32
+ transient_mark_mode(true)
33
+ Window.echo_area.clear_message
32
34
  load_user_config("~/.textbringer/init.rb")
33
35
  Plugin.load_plugins
34
36
  load_user_config("~/.textbringer.rb")
@@ -1300,15 +1300,28 @@ module Textbringer
1300
1300
  Utils.run_hooks(mode_class.hook_name)
1301
1301
  end
1302
1302
 
1303
- def toggle_minor_mode(mode_class)
1303
+ def set_minor_mode(mode_class, arg = nil)
1304
1304
  mode = @minor_modes.find { |mode| mode.instance_of?(mode_class) }
1305
- if mode
1306
- mode.disable
1307
- @minor_modes.delete(mode)
1308
- else
1305
+ enabled = !!mode
1306
+
1307
+ enable =
1308
+ case arg
1309
+ when true, false
1310
+ return if enabled == arg
1311
+ arg
1312
+ when nil
1313
+ !enabled
1314
+ else
1315
+ raise ArgumentError, "wrong argument #{arg.inspect} (expected true, false, or nil)"
1316
+ end
1317
+
1318
+ if enable
1309
1319
  mode = mode_class.new(self)
1310
1320
  @minor_modes.push(mode)
1311
1321
  mode.enable
1322
+ else
1323
+ mode.disable
1324
+ @minor_modes.delete(mode)
1312
1325
  end
1313
1326
  end
1314
1327
 
@@ -35,13 +35,26 @@ module Textbringer
35
35
  child.command_name = command
36
36
 
37
37
  # Define the toggle command
38
- define_command(command) do
39
- if child.enabled?
40
- child.disable
41
- child.enabled = false
42
- else
38
+ define_command(command, doc: "Enable or disable #{command_name}. " \
39
+ "Toggle the mode if arg is nil. " \
40
+ "Enable the mode if arg is true. " \
41
+ "Disable the mode if arg is false") do |arg = nil|
42
+ enable =
43
+ case arg
44
+ when true, false
45
+ return if child.enabled? == arg
46
+ arg
47
+ when nil
48
+ !child.enabled?
49
+ else
50
+ raise ArgumentError, "wrong argument #{arg.inspect} (expected true, false, or nil)"
51
+ end
52
+ if enable
43
53
  child.enable
44
54
  child.enabled = true
55
+ else
56
+ child.disable
57
+ child.enabled = false
45
58
  end
46
59
  end
47
60
  end
@@ -17,8 +17,11 @@ module Textbringer
17
17
  }
18
18
  command = command_name.intern
19
19
  child.command_name = command
20
- define_command(command) do
21
- Buffer.current.toggle_minor_mode(child)
20
+ define_command(command, doc: "Enable or disable #{command_name}. " \
21
+ "Toggle the mode if arg is nil. " \
22
+ "Enable the mode if arg is true. " \
23
+ "Disable the mode if arg is false") do |arg = nil|
24
+ Buffer.current.set_minor_mode(child, arg)
22
25
  end
23
26
  end
24
27
 
@@ -1,3 +1,3 @@
1
1
  module Textbringer
2
- VERSION = "15"
2
+ VERSION = "16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textbringer
3
3
  version: !ruby/object:Gem::Version
4
- version: '15'
4
+ version: '16'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda