626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
# File 'lib/textbringer/buffer.rb', line 626
def delete_char(n = 1)
check_read_only_flag
adjust_gap
s = @point
pos = get_pos(@point, n)
if n > 0
str = substring(s, pos)
@contents.bytesplice(@gap_end...user_to_gap(pos), "\0" * (pos - @point))
@gap_end += pos - @point
@marks.each do |m|
if m.location > pos
m.location -= pos - @point
elsif m.location > @point
m.location = @point
end
end
push_undo(DeleteAction.new(self, s, s, str))
self.modified = true
elsif n < 0
str = substring(pos, s)
update_line_and_column(@point, pos)
@contents.bytesplice(user_to_gap(pos)...@gap_start, "\0" * (@point - pos))
@marks.each do |m|
if m.location >= @point
m.location -= @point - pos
elsif m.location > pos
m.location = pos
end
end
@point = @gap_start = pos
push_undo(DeleteAction.new(self, s, pos, str))
self.modified = true
end
@goal_column = nil
end
|