Skip to content

Commit

Permalink
Merge pull request #614 from gkatev/master
Browse files Browse the repository at this point in the history
addons/markword: Deselect when the selection changes
  • Loading branch information
frlan committed Oct 10, 2017
2 parents 8f54bdf + fc6db18 commit 0cdd61a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addons/src/addons.c
Expand Up @@ -178,6 +178,8 @@ gboolean ao_editor_notify_cb(GObject *object, GeanyEditor *editor,
SCNotification *nt, gpointer data)
{
ao_bookmark_list_update_marker(ao_info->bookmarklist, editor, nt);

ao_mark_editor_notify(ao_info->markword, editor, nt);

return FALSE;
}
Expand Down
25 changes: 25 additions & 0 deletions addons/src/ao_markword.c
Expand Up @@ -171,6 +171,31 @@ static gboolean on_editor_button_press_event(GtkWidget *widget, GdkEventButton *
return FALSE;
}

void ao_mark_editor_notify(AoMarkWord *mw, GeanyEditor *editor, SCNotification *nt)
{
// If something is about to be deleted and there is selected text clear the markers
if(nt->nmhdr.code == SCN_MODIFIED &&
((nt->modificationType & SC_MOD_BEFOREDELETE) == SC_MOD_BEFOREDELETE) &&
sci_has_selection(editor->sci))
{
AoMarkWordPrivate *priv = AO_MARKWORD_GET_PRIVATE(mw);

if(priv->enable_markword && priv->enable_single_click_deselect)
clear_marker();
}

// In single click deselect mode, clear the markers when the cursor moves
else if(nt->nmhdr.code == SCN_UPDATEUI &&
nt->updated == SC_UPDATE_SELECTION &&
!sci_has_selection(editor->sci))
{
AoMarkWordPrivate *priv = AO_MARKWORD_GET_PRIVATE(mw);

if(priv->enable_markword && priv->enable_single_click_deselect)
clear_marker();
}
}


void ao_mark_document_new(AoMarkWord *mw, GeanyDocument *document)
{
Expand Down
2 changes: 2 additions & 0 deletions addons/src/ao_markword.h
Expand Up @@ -44,6 +44,8 @@ AoMarkWord* ao_mark_word_new (gboolean enable, gboolean single_click_deselect
void ao_mark_document_new (AoMarkWord *mw, GeanyDocument *document);
void ao_mark_document_open (AoMarkWord *mw, GeanyDocument *document);
void ao_mark_document_close (AoMarkWord *mw, GeanyDocument *document);
void ao_mark_editor_notify (AoMarkWord *mw, GeanyEditor *editor,
SCNotification *nt);

G_END_DECLS

Expand Down

0 comments on commit 0cdd61a

Please sign in to comment.