Fix callbacks to scintilla functions to work with splitwindow
* Use Scintilla focus object instead of notebook document to fix splitwindow behaviour for cut, copy, paste and delete callbacks. * move else-if to same line (style)
This commit is contained in:
parent
3f89d8d6a3
commit
c214056ea1
@ -228,16 +228,13 @@ void on_redo1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
|
|
||||||
void on_cut1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
void on_cut1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
GeanyDocument *doc = document_get_current();
|
|
||||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||||
|
|
||||||
if (GTK_IS_EDITABLE(focusw))
|
if (GTK_IS_EDITABLE(focusw))
|
||||||
gtk_editable_cut_clipboard(GTK_EDITABLE(focusw));
|
gtk_editable_cut_clipboard(GTK_EDITABLE(focusw));
|
||||||
else
|
else if (IS_SCINTILLA(focusw))
|
||||||
if (IS_SCINTILLA(focusw) && doc != NULL)
|
sci_cut(SCINTILLA(focusw));
|
||||||
sci_cut(doc->editor->sci);
|
else if (GTK_IS_TEXT_VIEW(focusw))
|
||||||
else
|
|
||||||
if (GTK_IS_TEXT_VIEW(focusw))
|
|
||||||
{
|
{
|
||||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
||||||
GTK_TEXT_VIEW(focusw));
|
GTK_TEXT_VIEW(focusw));
|
||||||
@ -248,16 +245,13 @@ void on_cut1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
|
|
||||||
void on_copy1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
void on_copy1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
GeanyDocument *doc = document_get_current();
|
|
||||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||||
|
|
||||||
if (GTK_IS_EDITABLE(focusw))
|
if (GTK_IS_EDITABLE(focusw))
|
||||||
gtk_editable_copy_clipboard(GTK_EDITABLE(focusw));
|
gtk_editable_copy_clipboard(GTK_EDITABLE(focusw));
|
||||||
else
|
else if (IS_SCINTILLA(focusw))
|
||||||
if (IS_SCINTILLA(focusw) && doc != NULL)
|
sci_copy(SCINTILLA(focusw));
|
||||||
sci_copy(doc->editor->sci);
|
else if (GTK_IS_TEXT_VIEW(focusw))
|
||||||
else
|
|
||||||
if (GTK_IS_TEXT_VIEW(focusw))
|
|
||||||
{
|
{
|
||||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
||||||
GTK_TEXT_VIEW(focusw));
|
GTK_TEXT_VIEW(focusw));
|
||||||
@ -268,18 +262,13 @@ void on_copy1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
|
|
||||||
void on_paste1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
void on_paste1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
GeanyDocument *doc = document_get_current();
|
|
||||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||||
|
|
||||||
if (GTK_IS_EDITABLE(focusw))
|
if (GTK_IS_EDITABLE(focusw))
|
||||||
gtk_editable_paste_clipboard(GTK_EDITABLE(focusw));
|
gtk_editable_paste_clipboard(GTK_EDITABLE(focusw));
|
||||||
else
|
else if (IS_SCINTILLA(focusw))
|
||||||
if (IS_SCINTILLA(focusw) && doc != NULL)
|
sci_paste(SCINTILLA(focusw));
|
||||||
{
|
else if (GTK_IS_TEXT_VIEW(focusw))
|
||||||
sci_paste(doc->editor->sci);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (GTK_IS_TEXT_VIEW(focusw))
|
|
||||||
{
|
{
|
||||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
||||||
GTK_TEXT_VIEW(focusw));
|
GTK_TEXT_VIEW(focusw));
|
||||||
@ -291,16 +280,13 @@ void on_paste1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
|
|
||||||
void on_delete1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
void on_delete1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
GeanyDocument *doc = document_get_current();
|
|
||||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||||
|
|
||||||
if (GTK_IS_EDITABLE(focusw))
|
if (GTK_IS_EDITABLE(focusw))
|
||||||
gtk_editable_delete_selection(GTK_EDITABLE(focusw));
|
gtk_editable_delete_selection(GTK_EDITABLE(focusw));
|
||||||
else
|
else if (IS_SCINTILLA(focusw) && sci_has_selection(SCINTILLA(focusw)))
|
||||||
if (IS_SCINTILLA(focusw) && doc != NULL && sci_has_selection(doc->editor->sci))
|
sci_clear(SCINTILLA(focusw));
|
||||||
sci_clear(doc->editor->sci);
|
else if (GTK_IS_TEXT_VIEW(focusw))
|
||||||
else
|
|
||||||
if (GTK_IS_TEXT_VIEW(focusw))
|
|
||||||
{
|
{
|
||||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
||||||
GTK_TEXT_VIEW(focusw));
|
GTK_TEXT_VIEW(focusw));
|
||||||
@ -1200,10 +1186,10 @@ void on_print1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|||||||
|
|
||||||
void on_menu_select_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
void on_menu_select_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
GeanyDocument *doc = document_get_current();
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||||
g_return_if_fail(doc != NULL);
|
g_return_if_fail(IS_SCINTILLA(focusw));
|
||||||
|
|
||||||
sci_select_all(doc->editor->sci);
|
sci_select_all(SCINTILLA(focusw));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1831,10 +1831,7 @@ static void goto_matching_brace(GeanyDocument *doc)
|
|||||||
|
|
||||||
static gboolean cb_func_clipboard_action(guint key_id)
|
static gboolean cb_func_clipboard_action(guint key_id)
|
||||||
{
|
{
|
||||||
GeanyDocument *doc = document_get_current();
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||||
|
|
||||||
if (doc == NULL)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
switch (key_id)
|
switch (key_id)
|
||||||
{
|
{
|
||||||
@ -1848,10 +1845,12 @@ static gboolean cb_func_clipboard_action(guint key_id)
|
|||||||
on_paste1_activate(NULL, NULL);
|
on_paste1_activate(NULL, NULL);
|
||||||
break;
|
break;
|
||||||
case GEANY_KEYS_CLIPBOARD_COPYLINE:
|
case GEANY_KEYS_CLIPBOARD_COPYLINE:
|
||||||
sci_send_command(doc->editor->sci, SCI_LINECOPY);
|
if (IS_SCINTILLA(focusw))
|
||||||
|
sci_send_command(SCINTILLA(focusw), SCI_LINECOPY);
|
||||||
break;
|
break;
|
||||||
case GEANY_KEYS_CLIPBOARD_CUTLINE:
|
case GEANY_KEYS_CLIPBOARD_CUTLINE:
|
||||||
sci_send_command(doc->editor->sci, SCI_LINECUT);
|
if (IS_SCINTILLA(focusw))
|
||||||
|
sci_send_command(SCINTILLA(focusw), SCI_LINECUT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user