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 +4 -4
- data/exe/txtb +2 -0
- data/lib/textbringer/buffer.rb +18 -5
- data/lib/textbringer/global_minor_mode.rb +18 -5
- data/lib/textbringer/minor_mode.rb +5 -2
- data/lib/textbringer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b838b91740f3985ebcdc6987e72ea7fe9daa28ad0b273a6f6e0f309818778a6
|
|
4
|
+
data.tar.gz: 51a55425c1cdaefb69b74451c3c9091f85138549a27a60e8ebb23161b4530847
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 128afb2fe777b9847ace11badce3121391576a98b7caba7f5bdb93faf4383e00b15db4ae23e263e8f1a26fc79ef1b3fa5b12d02e6ae8b590533088c680ef3532
|
|
7
|
+
data.tar.gz: 4e082735768a0d2647abf67ca9c7a5268ba6607fe59462de26dff2e59caca272c68224e061791cad58d6f81648bb17c9031b880361a56ce93912b3e27c487457
|
data/exe/txtb
CHANGED
data/lib/textbringer/buffer.rb
CHANGED
|
@@ -1300,15 +1300,28 @@ module Textbringer
|
|
|
1300
1300
|
Utils.run_hooks(mode_class.hook_name)
|
|
1301
1301
|
end
|
|
1302
1302
|
|
|
1303
|
-
def
|
|
1303
|
+
def set_minor_mode(mode_class, arg = nil)
|
|
1304
1304
|
mode = @minor_modes.find { |mode| mode.instance_of?(mode_class) }
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
21
|
-
|
|
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
|
|
data/lib/textbringer/version.rb
CHANGED