Add Document->Clone keybinding
This commit is contained in:
parent
83e7afc199
commit
6ca889c78b
@ -3627,6 +3627,8 @@ Document keybindings
|
||||
==================================== ==================== ==================================================
|
||||
Action Default shortcut Description
|
||||
==================================== ==================== ==================================================
|
||||
Clone See `Cloning documents`_.
|
||||
|
||||
Replace tabs by space Replaces all tabs with the right amount of spaces.
|
||||
|
||||
Replace spaces by tabs Replaces leading spaces with tab characters.
|
||||
|
||||
@ -2744,15 +2744,21 @@ GeanyDocument *document_index(gint idx)
|
||||
|
||||
/* create a new file and copy file content and properties */
|
||||
G_MODULE_EXPORT void on_clone1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||
{
|
||||
GeanyDocument *old_doc = document_get_current();
|
||||
|
||||
if (old_doc)
|
||||
document_clone(old_doc);
|
||||
}
|
||||
|
||||
|
||||
GeanyDocument *document_clone(GeanyDocument *old_doc)
|
||||
{
|
||||
gchar *text;
|
||||
GeanyDocument *doc;
|
||||
GeanyDocument *old_doc = document_get_current();
|
||||
ScintillaObject *old_sci;
|
||||
|
||||
if (!old_doc)
|
||||
return;
|
||||
|
||||
g_return_val_if_fail(old_doc, NULL);
|
||||
old_sci = old_doc->editor->sci;
|
||||
if (sci_has_selection(old_sci))
|
||||
text = sci_get_selection_contents(old_sci);
|
||||
@ -2777,6 +2783,7 @@ G_MODULE_EXPORT void on_clone1_activate(GtkMenuItem *menuitem, gpointer user_dat
|
||||
|
||||
/* update ui */
|
||||
ui_document_show_hide(doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -279,6 +279,8 @@ gint document_compare_by_tab_order_reverse(gconstpointer a, gconstpointer b);
|
||||
|
||||
void document_grab_focus(GeanyDocument *doc);
|
||||
|
||||
GeanyDocument *document_clone(GeanyDocument *old_doc);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@ -561,6 +561,8 @@ static void init_default_kb(void)
|
||||
0, 0, "menu_linewrap", _("Toggle Line wrapping"), "menu_line_wrapping1");
|
||||
add_kb(group, GEANY_KEYS_DOCUMENT_LINEBREAK, NULL,
|
||||
0, 0, "menu_linebreak", _("Toggle Line breaking"), "line_breaking1");
|
||||
add_kb(group, GEANY_KEYS_DOCUMENT_CLONE, NULL,
|
||||
0, 0, "menu_clone", _("_Clone"), "clone1");
|
||||
add_kb(group, GEANY_KEYS_DOCUMENT_REPLACETABS, NULL,
|
||||
0, 0, "menu_replacetabs", _("Replace tabs by space"), "menu_replace_tabs");
|
||||
add_kb(group, GEANY_KEYS_DOCUMENT_REPLACESPACES, NULL,
|
||||
@ -2348,6 +2350,9 @@ static gboolean cb_func_document_action(guint key_id)
|
||||
on_line_wrapping1_toggled(NULL, NULL);
|
||||
ui_document_show_hide(doc);
|
||||
break;
|
||||
case GEANY_KEYS_DOCUMENT_CLONE:
|
||||
document_clone(doc);
|
||||
break;
|
||||
case GEANY_KEYS_DOCUMENT_RELOADTAGLIST:
|
||||
document_update_tags(doc);
|
||||
break;
|
||||
|
||||
@ -246,6 +246,7 @@ enum GeanyKeyBindingID
|
||||
GEANY_KEYS_PROJECT_CLOSE, /**< Keybinding. */
|
||||
GEANY_KEYS_FORMAT_JOINLINES, /**< Keybinding. */
|
||||
GEANY_KEYS_GOTO_LINESTARTVISUAL, /**< Keybinding. */
|
||||
GEANY_KEYS_DOCUMENT_CLONE, /**< Keybinding. */
|
||||
GEANY_KEYS_COUNT /* must not be used by plugins */
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user