Skip to content

Commit

Permalink
geanypg: Update because of Scintilla 5.1.5 SCI_GETSELTEXT change
Browse files Browse the repository at this point in the history
The SCI_GETSELTEXT method of Scintilla changed so it returns a smaller
number of bytes than before. Instead, use the sci_ wrappers which are
independent of Geany version and should behave the same way regardless
of Geany version.
  • Loading branch information
techee committed Jan 13, 2022
1 parent 2cbca34 commit b8d8689
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions geanypg/src/helper_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,17 @@ void geanypg_load_buffer(gpgme_data_t * buffer)
{
/* gpgme_data_new_from_mem(buffer, text, size, 0); */
GeanyDocument * doc = document_get_current();
char * data = NULL;
unsigned long size = 0;
char * data;
if (sci_has_selection(doc->editor->sci))
{
size = scintilla_send_message(doc->editor->sci, SCI_GETSELTEXT, 0, 0) - 1;
data = (char *) malloc(size + 1);
scintilla_send_message(doc->editor->sci, SCI_GETSELTEXT, 0, (sptr_t)data);
gpgme_data_new_from_mem(buffer, data, size, 1);
data = sci_get_selection_contents(doc->editor->sci);
}
else
{
size = scintilla_send_message(doc->editor->sci, SCI_GETLENGTH, 0, 0);
data = (char *) malloc(size + 1);
scintilla_send_message(doc->editor->sci, SCI_GETTEXT, (uptr_t)(size + 1), (sptr_t)data);
gpgme_data_new_from_mem(buffer, data, size, 1);
data = sci_get_contents(doc->editor->sci);
}
if (data) /* if there is no text data may still be NULL */
free(data);
gpgme_data_new_from_mem(buffer, data, strlen(data), 1);
free(data);
gpgme_data_set_encoding(*buffer, GPGME_DATA_ENCODING_BINARY);
}

Expand Down

0 comments on commit b8d8689

Please sign in to comment.