[gitg/wip/patch-stage: 4/11] Allow selecting lines in diff



commit ab3e23883791d9940f50a65b96d359714db610e2
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Dec 28 15:51:39 2013 +0100

    Allow selecting lines in diff

 libgitg/resources/diff-view.css |   13 +++++++++++++
 libgitg/resources/diff-view.js  |   20 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/resources/diff-view.css b/libgitg/resources/diff-view.css
index 2fbedb0..3a44728 100644
--- a/libgitg/resources/diff-view.css
+++ b/libgitg/resources/diff-view.css
@@ -70,6 +70,14 @@ div#diff div.file table tr.added td:last-child {
   background-color: #ddffdd;
 }
 
+div#diff div.file table tr.added.selected td:last-child {
+  background-color: #a8cfd6;
+}
+
+div#diff div.file table tr.removed.selected td:last-child {
+  background-color: #b8bed6;
+}
+
 div#diff div.file table tr.removed td:last-child {
   background-color: #ffdddd;
 }
@@ -152,6 +160,11 @@ div#diff div.file table tr.hunk_header td.hunk_header {
   border-bottom: 1px solid #d3d7cf;
 }
 
+div#diff div.file table tr.hunk_header.selected td.hunk_header {
+  color: #aaa;
+  background-color: #ececff;
+}
+
 div#diff div.file table td {
   vertical-align: top;
 }
diff --git a/libgitg/resources/diff-view.js b/libgitg/resources/diff-view.js
index 0b7054b..bfed8ae 100644
--- a/libgitg/resources/diff-view.js
+++ b/libgitg/resources/diff-view.js
@@ -144,6 +144,24 @@ function expand_collapse()
        expander.closest('tbody').toggleClass("collapsed");
 }
 
+
+function stage_unstage_hunk()
+{
+       var addrm = $(this).nextUntil('tr.file_header, tr.hunk_header').filter('tr.added, tr.removed');
+
+       var unsel = $.grep(addrm, function(e) { return !$(e).hasClass('selected'); });
+       addrm.removeClass('selected');
+
+       if (unsel.length != 0)
+       {
+               addrm.addClass('selected');
+       }
+}
+
+function stage_unstage_line()
+{
+       $(this).toggleClass("selected");
+}
 function update_diff(id, lsettings)
 {
        if (html_builder_worker)
@@ -214,6 +232,8 @@ function update_diff(id, lsettings)
                        content.html(event.data.diff_html);
 
                        $(".expander").click(expand_collapse);
+                       $("tr.hunk_header").click(stage_unstage_hunk);
+                       $("tr.added, tr.removed").click(stage_unstage_line);
                }
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]