textbringer 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e327730f3f4d3b64bf57ce835400f4a44475c600
4
- data.tar.gz: 3b9adf68d12de90e5d6106e4aa2f9e4cfd0a5599
3
+ metadata.gz: 0d269dfb51f840ae1bc3e23835cc9615a1a6680e
4
+ data.tar.gz: ccf2eebae9ea22d693dcc824a5a5b10634f9a68f
5
5
  SHA512:
6
- metadata.gz: aef52effa70699fbc3a32d80354027caf1d606ecb31331c8adfb83a5649e66a444244c73985206249046da68c2c00cf0c753ffcb974e4ff157418d7a188c9a82
7
- data.tar.gz: 65cfd1a1cdf62888061a3b40e0e9b7620b56374927c4e2844efba890707b567badfa5586205bc1d07cc3b596c5e31e058fb7a78bc1aed3503ce0f792431f5a33
6
+ metadata.gz: 2a77d400ed5c0ba9d00b694267c873b5c2059f47ade24db38fa6c6413e957d9ef392febbc3702810cbc72c4a2a631ec7e130098372bc4742a2017532d8080d87
7
+ data.tar.gz: f4487bdee4fd6c71a171991dd4b1ddb0bbb8ee38594502c8e37edac9dd09e1929c10cac9bef09c28658168b4f6f0a18f73ffc46fdbffa3fdde1bb71dfe815694
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.4
2
+
3
+ * Remove Buffer#on_modified and add Buffer#on instead.
4
+
1
5
  ## 0.2.3
2
6
 
3
7
  * Add the on_modified callback to Buffer.
@@ -225,7 +225,7 @@ module Textbringer
225
225
  @match_offsets = []
226
226
  @visible_mark = nil
227
227
  @read_only = read_only
228
- @on_modified_callbacks = []
228
+ @callbacks = {}
229
229
  end
230
230
 
231
231
  def inspect
@@ -301,16 +301,26 @@ module Textbringer
301
301
  @marks.each do |mark|
302
302
  mark.detach
303
303
  end
304
+ fire_callbacks(:killed)
305
+ end
306
+
307
+ def on_killed(&callback)
308
+ add_callback(:killed, callback)
304
309
  end
305
310
 
306
311
  def current?
307
312
  @@current == self
308
313
  end
309
314
 
315
+ def on(name, &callback)
316
+ @callbacks[name] ||= []
317
+ @callbacks[name].push(callback)
318
+ end
319
+
310
320
  def modified=(modified)
311
321
  @modified = modified
312
322
  if @composite_edit_level == 0 && modified
313
- fire_on_modified_callbacks
323
+ fire_callbacks(:modified)
314
324
  end
315
325
  end
316
326
 
@@ -319,7 +329,7 @@ module Textbringer
319
329
  end
320
330
 
321
331
  def on_modified(&callback)
322
- @on_modified_callbacks.push(callback)
332
+ add_callback(:modified, callback)
323
333
  end
324
334
 
325
335
  def [](name)
@@ -1213,7 +1223,7 @@ module Textbringer
1213
1223
  @composite_edit_actions.clear
1214
1224
  end
1215
1225
  end
1216
- fire_on_modified_callbacks
1226
+ fire_callbacks(:modified)
1217
1227
  end
1218
1228
 
1219
1229
  def apply_mode(mode_class)
@@ -1503,8 +1513,8 @@ module Textbringer
1503
1513
  end
1504
1514
  end
1505
1515
 
1506
- def fire_on_modified_callbacks
1507
- @on_modified_callbacks.each do |callback|
1516
+ def fire_callbacks(name)
1517
+ @callbacks[name]&.each do |callback|
1508
1518
  callback.call(self)
1509
1519
  end
1510
1520
  end
@@ -8,7 +8,7 @@ module Textbringer
8
8
 
9
9
  def message(msg, log: true, sit_for: nil, sleep_for: nil)
10
10
  str = msg.to_s
11
- if log && Buffer.current.name != "*Messages*"
11
+ if log && Buffer.current&.name != "*Messages*"
12
12
  buffer = Buffer["*Messages*"] ||
13
13
  Buffer.new_buffer("*Messages*", undo_limit: 0).tap { |b|
14
14
  b[:top_of_window] = b.new_mark
@@ -85,7 +85,7 @@ module Textbringer
85
85
  if e.is_a?(SystemExit)
86
86
  raise
87
87
  end
88
- if Buffer.current.name != "*Backtrace*"
88
+ if Buffer.current&.name != "*Backtrace*"
89
89
  buffer = Buffer.find_or_new("*Backtrace*", undo_limit: 0)
90
90
  if !buffer.mode.is_a?(BacktraceMode)
91
91
  buffer.apply_mode(BacktraceMode)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Textbringer
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textbringer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses