Class: Ruvi::EditorApp::DiffLogger::ModifyLineChange

Inherits:
Difference
  • Object
show all
Defined in:
lib/timemachine.rb

Instance Attribute Summary collapse

Attributes inherited from Difference

#new_cursor, #old_cursor

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Difference

#correct_cursor_position, #cursor_transition, #finalize, inherited, #initialize, #notify_of_play, #notify_of_unplay, transition_regexp

Constructor Details

This class inherits a constructor from Ruvi::EditorApp::DiffLogger::Difference

Instance Attribute Details

#line_numObject

Returns the value of attribute line_num.



410
411
412
# File 'lib/timemachine.rb', line 410

def line_num
  @line_num
end

#new_line_dataObject

Returns the value of attribute new_line_data.



410
411
412
# File 'lib/timemachine.rb', line 410

def new_line_data
  @new_line_data
end

#old_line_dataObject

Returns the value of attribute old_line_data.



410
411
412
# File 'lib/timemachine.rb', line 410

def old_line_data
  @old_line_data
end

Class Method Details

.from_s(buf, str) ⇒ Object



411
412
413
414
415
416
417
418
419
# File 'lib/timemachine.rb', line 411

def ModifyLineChange.from_s buf, str
    t = self.new(buf) {
        |t|
        str =~ /^MODIFY:#{transition_regexp}:(.*?):\((.*?)\)=>\((.*?)\)$/
        t.old_cursor, t.new_cursor = Point.new($1.to_i, $2.to_i), Point.new($3.to_i, $4.to_i)
        t.line_num, t.old_line_data, t.new_line_data = $5.to_i, $6, $7
    }
    t
end

.it_was_me(msg) ⇒ Object



420
421
422
# File 'lib/timemachine.rb', line 420

def ModifyLineChange.it_was_me msg
    msg =~ /^MODIFY:/
end

Instance Method Details

#post_mod_callbackObject



427
428
429
430
# File 'lib/timemachine.rb', line 427

def post_mod_callback
    super
    @new_line_data = @buffer.lines[@line_num].dup
end

#pre_mod_callbackObject



423
424
425
426
# File 'lib/timemachine.rb', line 423

def pre_mod_callback
    super
    @old_line_data = @buffer.lines[@line_num].dup
end

#redoObject



435
436
437
438
# File 'lib/timemachine.rb', line 435

def redo
    @buffer.lines[@line_num] = @new_line_data
    super
end

#to_sObject



439
440
441
# File 'lib/timemachine.rb', line 439

def to_s
    "MODIFY:[#{cursor_transition}]:#{@line_num}:(#{@old_line_data})=>(#{@new_line_data})"
end

#undoObject



431
432
433
434
# File 'lib/timemachine.rb', line 431

def undo
    @buffer.lines[@line_num] = @old_line_data
    super
end