mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-07-04 17:09:30 +00:00
Implement hunk select/deselect
This commit is contained in:
parent
4a8c1fa02c
commit
36d63f1889
|
@ -361,6 +361,22 @@ class Gitg.DiffViewFileSelectable : Object
|
|||
}
|
||||
}
|
||||
|
||||
private void update_selection_hunk(Gtk.TextIter iter, bool select)
|
||||
{
|
||||
var end = iter;
|
||||
|
||||
end.forward_line();
|
||||
|
||||
var buffer = source_view.buffer as Gtk.SourceBuffer;
|
||||
|
||||
if (!buffer.forward_iter_to_source_mark(ref end, "header"))
|
||||
{
|
||||
end.forward_to_end();
|
||||
}
|
||||
|
||||
update_selection_range(iter, end, select);
|
||||
}
|
||||
|
||||
private bool button_press_event_on_view(Gdk.EventButton event)
|
||||
{
|
||||
if (event.button != 1)
|
||||
|
@ -375,13 +391,21 @@ class Gitg.DiffViewFileSelectable : Object
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0)
|
||||
var select = (event.state & Gdk.ModifierType.MOD1_MASK) == 0;
|
||||
|
||||
if (get_line_is_hunk(iter))
|
||||
{
|
||||
d_selection_mode = DiffSelectionMode.DESELECTING;
|
||||
update_selection_hunk(iter, select);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (select)
|
||||
{
|
||||
d_selection_mode = DiffSelectionMode.SELECTING;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_selection_mode = DiffSelectionMode.SELECTING;
|
||||
d_selection_mode = DiffSelectionMode.DESELECTING;
|
||||
}
|
||||
|
||||
var buffer = source_view.buffer;
|
||||
|
@ -456,7 +480,7 @@ class Gitg.DiffViewFileSelectable : Object
|
|||
}
|
||||
else
|
||||
{
|
||||
something_selected = (buffer as Gtk.SourceBuffer).forward_iter_to_source_mark(iter, d_selection_category);
|
||||
something_selected = (buffer as Gtk.SourceBuffer).forward_iter_to_source_mark(ref iter, d_selection_category);
|
||||
}
|
||||
|
||||
if (something_selected != has_selection)
|
||||
|
|
|
@ -13,13 +13,13 @@ namespace Gtk {
|
|||
public class SourceBuffer : Gtk.TextBuffer {
|
||||
[CCode (has_construct_function = false)]
|
||||
public SourceBuffer (Gtk.TextTagTable? table);
|
||||
public bool backward_iter_to_source_mark (Gtk.TextIter iter, string? category);
|
||||
public bool backward_iter_to_source_mark (ref Gtk.TextIter iter, string? category);
|
||||
public void begin_not_undoable_action ();
|
||||
public void change_case (Gtk.SourceChangeCaseType case_type, Gtk.TextIter start, Gtk.TextIter end);
|
||||
public unowned Gtk.SourceMark create_source_mark (string? name, string category, Gtk.TextIter where);
|
||||
public void end_not_undoable_action ();
|
||||
public void ensure_highlight (Gtk.TextIter start, Gtk.TextIter end);
|
||||
public bool forward_iter_to_source_mark (Gtk.TextIter iter, string? category);
|
||||
public bool forward_iter_to_source_mark (ref Gtk.TextIter iter, string? category);
|
||||
[CCode (array_length = false, array_null_terminated = true)]
|
||||
public string[] get_context_classes_at_iter (Gtk.TextIter iter);
|
||||
public bool get_highlight_matching_brackets ();
|
||||
|
|
Loading…
Reference in New Issue
Block a user