Class: Ruvi::EditorApp::DiffLogger::InsertLineAfterChange

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, #pre_mod_callback, 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.



362
363
364
# File 'lib/timemachine.rb', line 362

def line_num
  @line_num
end

#new_line_dataObject

Returns the value of attribute new_line_data.



362
363
364
# File 'lib/timemachine.rb', line 362

def new_line_data
  @new_line_data
end

Class Method Details

.from_s(buf, str) ⇒ Object



363
364
365
366
367
368
369
370
371
# File 'lib/timemachine.rb', line 363

def InsertLineAfterChange.from_s buf, str
    t = self.new(buf) {
        |t|
        str =~ /^INSERT_AFTER:#{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.new_line_data = $5.to_i, $6
    }
    t 
end

.it_was_me(msg) ⇒ Object



372
373
374
# File 'lib/timemachine.rb', line 372

def InsertLineAfterChange.it_was_me msg
    msg =~ /^INSERT_AFTER:/
end

Instance Method Details

#post_mod_callbackObject



375
376
377
378
# File 'lib/timemachine.rb', line 375

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

#redoObject



383
384
385
386
# File 'lib/timemachine.rb', line 383

def redo
    @buffer.lines.insert_after @line_num, @new_line_data
    super
end

#to_sObject



387
388
389
# File 'lib/timemachine.rb', line 387

def to_s
    "INSERT_AFTER:[#{cursor_transition}]:#{@line_num}:#{@new_line_data}"
end

#undoObject



379
380
381
382
# File 'lib/timemachine.rb', line 379

def undo
    @buffer.lines.delete_at @line_num
    super
end