[patch]:change, which allows to work with selections.
- From: Oleg LARIN <oleg larin st com>
- To: "meld-list gnome org" <meld-list gnome org>
- Subject: [patch]:change, which allows to work with selections.
- Date: Thu, 28 Apr 2011 03:31:14 +0200
From 91c89e5fb36f4f316e9e162c532b94198c614db6 Mon Sep 17 00:00:00 2001
From: oleg larin <oleg larin st com>
Date: Wed, 27 Apr 2011 18:28:14 -0700
Subject: [PATCH] change, which allows to work with selections.
simple change, which allows to "copy up/down", "replace", "delete"
selected part of a pane the same way as if it is a "file diff chunk".
---
meld/filediff.py | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/meld/filediff.py b/meld/filediff.py
index 430b621..efa66b1 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1480,10 +1480,17 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
b0, b1 = self.textbuffer[src], self.textbuffer[dst]
start = get_iter_at_line_or_eof(b0, chunk[1])
end = get_iter_at_line_or_eof(b0, chunk[2])
- t0 = unicode(b0.get_text(start, end, False), 'utf8')
+ bounds = b0.get_selection_bounds()
+ if bounds:
+ t0 = unicode(b0.get_text(bounds[0], bounds[1], False), 'utf8') + "\n"
+ # set de-select selection used
+ b0.place_cursor(b0.get_iter_at_mark(b0.get_insert()))
+ else:
+ t0 = unicode(b0.get_text(start, end, False), 'utf8')
if copy_up:
if chunk[2] >= b0.get_line_count() and \
- chunk[3] < b1.get_line_count():
+ chunk[3] < b1.get_line_count() and \
+ bounds == False:
# TODO: We need to insert a linebreak here, but there is no
# way to be certain what kind of linebreak to use.
t0 = t0 + "\n"
@@ -1497,7 +1504,13 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
src_end = get_iter_at_line_or_eof(b0, chunk[2])
dst_start = get_iter_at_line_or_eof(b1, chunk[3])
dst_end = get_iter_at_line_or_eof(b1, chunk[4])
- t0 = unicode(b0.get_text(src_start, src_end, False), 'utf8')
+ bounds = b0.get_selection_bounds()
+ if bounds:
+ t0 = unicode(b0.get_text(bounds[0], bounds[1], False), 'utf8') + "\n"
+ # set de-select selection used
+ b0.place_cursor(b0.get_iter_at_mark(b0.get_insert()))
+ else:
+ t0 = unicode(b0.get_text(src_start, src_end, False), 'utf8')
self.on_textbuffer__begin_user_action()
b1.delete(dst_start, dst_end)
insert_with_tags_by_name(b1, chunk[3], t0, "edited line")
@@ -1505,10 +1518,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
def delete_chunk(self, src, chunk):
b0 = self.textbuffer[src]
- it = get_iter_at_line_or_eof(b0, chunk[1])
- if chunk[2] >= b0.get_line_count():
- it.backward_char()
- b0.delete(it, get_iter_at_line_or_eof(b0, chunk[2]))
+ bounds = b0.get_selection_bounds()
+ if bounds:
+ b0.delete(bounds[0], bounds[1])
+ else:
+ it = get_iter_at_line_or_eof(b0, chunk[1])
+ if chunk[2] >= b0.get_line_count():
+ it.backward_char()
+ b0.delete(it, get_iter_at_line_or_eof(b0, chunk[2]))
################################################################################
#
--
1.7.3.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]