aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2017-03-05 22:08:37 +0100
committerThomas White <taw@bitwiz.org.uk>2017-03-05 22:08:37 +0100
commit4b0854d62b4b4e7ce0c721a6f9f43df595aacd72 (patch)
treecb918ad22fe1299c09f2b172f8fd955a05860fdb /src
parent4caa9d3984c8f1a50a9c787416ca5b6c73b6711a (diff)
Track whether selection is active or not
Diffstat (limited to 'src')
-rw-r--r--src/frame.c10
-rw-r--r--src/frame.h2
-rw-r--r--src/sc_editor.c2
3 files changed, 14 insertions, 0 deletions
diff --git a/src/frame.c b/src/frame.c
index 5a7da8e..866ae31 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -603,6 +603,16 @@ static size_t text_para_pos(Paragraph *para, double x, double y, int *ptrail)
}
+
+int positions_equal(struct edit_pos a, struct edit_pos b)
+{
+ if ( a.para != b.para ) return 0;
+ if ( a.pos != b.pos ) return 0;
+ if ( a.trail != b.trail ) return 0;
+ return 1;
+}
+
+
void sort_positions(struct edit_pos *a, struct edit_pos *b)
{
if ( a->para > b->para ) {
diff --git a/src/frame.h b/src/frame.h
index 787a2ec..b6ae617 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -157,6 +157,8 @@ extern int find_cursor_2(struct frame *fr, double x, double y,
extern void sort_positions(struct edit_pos *a, struct edit_pos *b);
+extern int positions_equal(struct edit_pos a, struct edit_pos b);
+
extern int get_para_highlight(struct frame *fr, int cursor_para,
double *cx, double *cy, double *cw, double *ch);
diff --git a/src/sc_editor.c b/src/sc_editor.c
index ddaaedc..a3754a6 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -1022,6 +1022,7 @@ static void unset_selection(SCEditor *e)
a = e->sel_end.para;
b = e->sel_start.para;
}
+ e->sel_active = 0;
rewrap_paragraph_range(e->top, a, b, e->sel_start, e->sel_end, 0);
}
@@ -1185,6 +1186,7 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
e->sel_start, e->sel_end, 1);
find_cursor(fr, x-fr->x, y-fr->y, &e->cursor_para,
&e->cursor_pos, &e->cursor_trail);
+ e->sel_active = !positions_equal(e->sel_start, e->sel_end);
sc_editor_redraw(e);
break;