Class: Ruvi::EditorApp::DiffLogger::Difference
- Inherits:
-
Object
- Object
- Ruvi::EditorApp::DiffLogger::Difference
show all
- Defined in:
- lib/timemachine.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(buffer, line_num = nil) ⇒ Difference
note - line_num.nil? -> generated via *Difference.from_s
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
# File 'lib/timemachine.rb', line 291
def initialize buffer, line_num = nil
@buffer = buffer
@old_cursor, @new_cursor = nil, nil
if line_num.nil?
yield self
@buffer.dlog << self
else
dbg(:ufw) { "a #{self.type.inspect} was new'ed" }
@line_num = line_num
pre_mod_callback
yield post_mod_callback
@buffer.dlog << self
notify_of_play
end
end
|
Instance Attribute Details
#new_cursor ⇒ Object
Returns the value of attribute new_cursor.
289
290
291
|
# File 'lib/timemachine.rb', line 289
def new_cursor
@new_cursor
end
|
#old_cursor ⇒ Object
Returns the value of attribute old_cursor.
289
290
291
|
# File 'lib/timemachine.rb', line 289
def old_cursor
@old_cursor
end
|
Class Method Details
.inherited(sub) ⇒ Object
356
357
358
|
# File 'lib/timemachine.rb', line 356
def Difference.inherited sub
DifferenceTypes::instance.register_change_type sub
end
|
.transition_regexp ⇒ Object
349
350
351
352
|
# File 'lib/timemachine.rb', line 349
def Difference.transition_regexp
point_re = /\((.*?),(.*?)\)/
/\[#{point_re }->#{point_re}]/
end
|
Instance Method Details
#correct_cursor_position ⇒ Object
329
330
331
332
333
334
335
336
337
338
|
# File 'lib/timemachine.rb', line 329
def correct_cursor_position
if @buffer.y > @buffer.last_line_num
@buffer.y = @buffer.last_line_num
end
end
|
#cursor_transition ⇒ Object
353
354
355
|
# File 'lib/timemachine.rb', line 353
def cursor_transition
"(#{@old_cursor.x},#{@old_cursor.y})->(#{@new_cursor.x},#{@new_cursor.y})"
end
|
#finalize ⇒ Object
319
320
321
322
|
# File 'lib/timemachine.rb', line 319
def finalize
@buffer.dlog.finalize
end
|
#notify_of_play ⇒ Object
307
308
309
310
311
312
|
# File 'lib/timemachine.rb', line 307
def notify_of_play
@buffer.app.change_listeners.each {
|listener|
listener.call self, true
}
end
|
#notify_of_unplay ⇒ Object
313
314
315
316
317
318
|
# File 'lib/timemachine.rb', line 313
def notify_of_unplay
@buffer.app.change_listeners.each {
|listener|
listener.call self, false
}
end
|
#post_mod_callback ⇒ Object
326
327
328
|
# File 'lib/timemachine.rb', line 326
def post_mod_callback
@new_cursor = Point.new(@buffer.x, @buffer.y)
end
|
#pre_mod_callback ⇒ Object
323
324
325
|
# File 'lib/timemachine.rb', line 323
def pre_mod_callback
@old_cursor = Point.new(@buffer.x, @buffer.y)
end
|
#redo ⇒ Object
344
345
346
347
348
|
# File 'lib/timemachine.rb', line 344
def redo
notify_of_unplay
@buffer.move_to @new_cursor.x, @new_cursor.y
correct_cursor_position
end
|
#undo ⇒ Object
339
340
341
342
343
|
# File 'lib/timemachine.rb', line 339
def undo
notify_of_play
@buffer.move_to @old_cursor.x, @old_cursor.y
correct_cursor_position
end
|