38PLUGIN_SET_INFO(
_(
"HTML Characters"),
_(
"Inserts HTML character entities like '&'."), VERSION,
39 _(
"The Geany developer team"))
73 {
N_(
"HTML characters"),
NULL },
79 {
N_(
"ISO 8859-1 characters"),
NULL },
177 {
N_(
"Greek characters"),
NULL },
187 {
"Ε",
"Ε" },
188 {
"ε",
"ε" },
207 {
"Ο",
"Ο" },
208 {
"ο",
"ο" },
218 {
"Υ",
"Υ" },
219 {
"υ",
"υ" },
228 {
"ϑ",
"ϑ" },
232 {
N_(
"Mathematical characters"),
NULL },
273 {
N_(
"Technical characters"),
NULL },
281 {
N_(
"Arrow characters"),
NULL },
294 {
N_(
"Punctuation characters"),
NULL },
310 {
N_(
"Miscellaneous characters"),
NULL },
321 {
"ℵ",
"ℵ" },
350 GKeyFile *config = g_key_file_new();
352 gchar *config_dir = g_path_get_dirname(
config_file);
358 g_key_file_set_boolean(config,
"general",
"replacement_on_typing_active",
361 if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR)
365 _(
"Plugin configuration directory could not be created."));
370 data = g_key_file_to_data(config,
NULL,
NULL);
375 g_key_file_free(config);
390 (GtkDialog *
dialog, gint response, gpointer user_data);
392 (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data);
394static gboolean
sc_insert(GtkTreeModel *model, GtkTreeIter *iter);
403 len = G_N_ELEMENTS(
chars);
406 for (i = 7; i < len; i++)
425 g_return_val_if_fail(editor !=
NULL, FALSE);
439 len = g_unichar_to_utf8(nt->
ch, buf);
481 GtkCellRenderer *renderer;
482 GtkTreeViewColumn *column;
483 GtkWidget *swin, *vbox, *
label;
486 _(
"Special Characters"), GTK_WINDOW(
geany->main_widgets->window),
487 GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
488 _(
"_Insert"), GTK_RESPONSE_OK,
NULL);
490 gtk_box_set_spacing(GTK_BOX(vbox), 6);
491 gtk_widget_set_name(
sc_dialog,
"GeanyDialog");
494 gtk_window_set_default_size(GTK_WINDOW(
sc_dialog), height * 8 / 10, height);
495 gtk_dialog_set_default_response(GTK_DIALOG(
sc_dialog), GTK_RESPONSE_CANCEL);
497 label = gtk_label_new(
_(
"Choose a special character from the list below and double click on it or use the button to insert it at the current cursor position."));
498 gtk_label_set_line_wrap(GTK_LABEL(
label), TRUE);
499 gtk_misc_set_alignment(GTK_MISC(
label), 0, 0.5);
500 gtk_box_pack_start(GTK_BOX(vbox),
label, FALSE, FALSE, 0);
502 sc_tree = GTK_TREE_VIEW(gtk_tree_view_new());
505 gtk_tree_view_set_model(GTK_TREE_VIEW(
sc_tree),
509 renderer = gtk_cell_renderer_text_new();
510 column = gtk_tree_view_column_new_with_attributes(
512 gtk_tree_view_column_set_resizable(column, TRUE);
513 gtk_tree_view_append_column(GTK_TREE_VIEW(
sc_tree), column);
515 renderer = gtk_cell_renderer_text_new();
516 column = gtk_tree_view_column_new_with_attributes(
518 gtk_tree_view_column_set_resizable(column, TRUE);
519 gtk_tree_view_append_column(GTK_TREE_VIEW(
sc_tree), column);
521 swin = gtk_scrolled_window_new(
NULL,
NULL);
522 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC,
523 GTK_POLICY_AUTOMATIC);
525 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin), GTK_SHADOW_IN);
527 gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0);
534 g_signal_connect(
sc_dialog,
"delete-event", G_CALLBACK(gtk_widget_hide_on_delete),
NULL);
550 GtkTreeIter *parent_iter =
NULL;
553 len = G_N_ELEMENTS(
chars);
554 for (i = 0; i < len; i++)
558 gtk_tree_store_append(store, &iter,
NULL);
560 if (parent_iter !=
NULL) gtk_tree_iter_free(parent_iter);
561 parent_iter = gtk_tree_iter_copy(&iter);
565 gtk_tree_store_append(store, &iter, parent_iter);
575static gboolean
sc_insert(GtkTreeModel *model, GtkTreeIter *iter)
578 gboolean result = FALSE;
600 if (response == GTK_RESPONSE_OK)
602 GtkTreeSelection *selection;
606 selection = gtk_tree_view_get_selection(
sc_tree);
608 if (gtk_tree_selection_get_selected(selection, &model, &iter))
612 gtk_widget_hide(GTK_WIDGET(
dialog));
616 gtk_widget_hide(GTK_WIDGET(
dialog));
621 GtkTreeViewColumn *col, gpointer user_data)
624 GtkTreeModel *model = GTK_TREE_MODEL(
sc_store);
626 if (gtk_tree_model_get_iter(model, &iter, path))
633 if (gtk_tree_view_row_expanded(
sc_tree, path))
634 gtk_tree_view_collapse_row(
sc_tree, path);
636 gtk_tree_view_expand_row(
sc_tree, path, FALSE);
651 GString *replacement = g_string_new(
NULL);
654 const gchar *entity =
NULL;
660 selection_len = strlen(selection);
661 for (i = 0; i < selection_len; i++)
663 len = g_unichar_to_utf8(g_utf8_get_char(selection + i), buf);
664 i = (guint)len - 1 + i;
671 replacement = g_string_append(replacement, entity);
675 replacement = g_string_append(replacement, buf);
678 new = g_string_free(replacement, FALSE);
716 GKeyFile *config = g_key_file_new();
720 "plugins", G_DIR_SEPARATOR_S,
721 "htmchars", G_DIR_SEPARATOR_S,
"general.conf",
NULL);
727 "replacement_on_typing_active", FALSE);
735 GtkWidget *menu_item;
736 const gchar *menu_text =
_(
"_Insert Special HTML Characters...");
742 menu_item = gtk_menu_item_new_with_mnemonic(menu_text);
743 gtk_widget_show(menu_item);
751 main_menu = gtk_menu_item_new_with_mnemonic(
_(
"_HTML Replacement"));
758 menu_htmltoggle = gtk_check_menu_item_new_with_mnemonic(
_(
"_Auto-replace Special Characters"));
767 _(
"_Replace Characters in Selection"));
783 _(
"Insert Special HTML Characters"), menu_item);
786 _(
"Replace special characters"),
NULL);
Interface to the added lexer functions in the SciLexer version of the edit control.
void dialogs_show_msgbox(GtkMessageType type, const gchar *text,...)
Shows a message box of the type type with text.
GeanyDocument * document_get_current(void)
Finds the current document.
#define GEANY_DEFAULT_DIALOG_HEIGHT
Single include for plugins.
static GtkWidget * main_menu_submenu
static void sc_on_tools_show_dialog_insert_special_chars_response(GtkDialog *dialog, gint response, gpointer user_data)
static GtkWidget * sc_dialog
static void init_configuration(void)
static void tools_show_dialog_insert_special_chars(void)
static const gchar * get_entity(gchar *letter)
static void sc_fill_store(GtkTreeStore *store)
static GtkTreeView * sc_tree
GeanyPlugin * geany_plugin
static void kb_special_chars_replacement(G_GNUC_UNUSED guint key_id)
static gchar * config_file
void plugin_cleanup(void)
Called before unloading the plugin.
PluginCallback plugin_callbacks[]
static gboolean plugin_active
static GtkWidget * menu_htmltoggle
static void replace_special_character_activated(GtkMenuItem *menuitem, gpointer gdata)
static void kbhtmltoggle_toggle(G_GNUC_UNUSED guint key_id)
static void replace_special_character(void)
static GtkWidget * main_menu
@ KB_REPLACE_HTML_ENTITIES
static GtkWidget * main_menu_item
static void toggle_status(G_GNUC_UNUSED GtkMenuItem *menuitem)
static void set_status(gboolean new_status)
void plugin_init(GeanyData *data)
Called after loading the plugin.
static GtkWidget * menu_bulk_replace
static GtkTreeStore * sc_store
static void sc_on_tree_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
static void item_activate(GtkMenuItem *menuitem, gpointer gdata)
static void kb_activate(G_GNUC_UNUSED guint key_id)
static gboolean ht_editor_notify_cb(GObject *object, GeanyEditor *editor, SCNotification *nt, gpointer data)
static gboolean sc_insert(GtkTreeModel *model, GtkTreeIter *iter)
GeanyKeyBinding * keybindings_set_item(GeanyKeyGroup *group, gsize key_id, GeanyKeyCallback callback, guint key, GdkModifierType mod, const gchar *kf_name, const gchar *label, GtkWidget *menu_item)
<simplesect kind="geany:skip"></simplesect> Fills a GeanyKeyBinding struct item.
#define GEANY_API_VERSION
The Application Programming Interface (API) version, incremented whenever any plugin data types are m...
#define PLUGIN_SET_INFO(p_name, p_description, p_version, p_author)
Sets the plugin name and some other basic information about a plugin.
#define PLUGIN_VERSION_CHECK(api_required)
Defines a function to check the plugin is safe to load.
#define geany
Simple macro for geany_data that reduces typing.
GeanyKeyGroup * plugin_set_key_group(GeanyPlugin *plugin, const gchar *section_name, gsize count, GeanyKeyGroupCallback callback)
<simplesect kind="geany:skip"></simplesect> Sets up or resizes a keybinding group for the plugin.
gchar * sci_get_selection_contents(ScintillaObject *sci)
Gets selected text.
gint sci_get_current_position(ScintillaObject *sci)
Gets the cursor position.
void sci_set_selection_start(ScintillaObject *sci, gint position)
Sets the selection start position.
void sci_replace_sel(ScintillaObject *sci, const gchar *text)
Replaces selection.
gint sci_get_lexer(ScintillaObject *sci)
Gets the currently used lexer.
gboolean sci_has_selection(ScintillaObject *sci)
Checks if there's a selection.
void sci_insert_text(ScintillaObject *sci, gint pos, const gchar *text)
Inserts text.
void sci_set_selection_end(ScintillaObject *sci, gint position)
Sets the selection end position.
gtk_container_add(GTK_CONTAINER(dialog->vbox), check_button)
gtk_widget_show_all(dialog)
This contains pointers to global variables owned by Geany for plugins to use.
Structure for representing an open tab with all its properties.
GeanyEditor * editor
The editor associated with the document.
Editor-owned fields for each document.
ScintillaObject * sci
The Scintilla editor GtkWidget.
Basic information for the plugin and identification.
Callback array entry type used with the plugin_callbacks symbol.
void ui_add_document_sensitive(GtkWidget *widget)
Adds a widget to the list of widgets that should be set sensitive/insensitive when some documents are...
GtkWidget * ui_dialog_vbox_new(GtkDialog *dialog)
Makes a fixed border for dialogs without increasing the button box border.
gint utils_write_file(const gchar *filename, const gchar *text)
Writes text into a file named filename.
gboolean utils_get_setting_boolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean default_value)
Wraps g_key_file_get_boolean() to add a default value argument.
gint utils_mkdir(const gchar *path, gboolean create_parent_dirs)
Creates a directory if it doesn't already exist.
gboolean utils_str_equal(const gchar *a, const gchar *b)
NULL-safe string comparison.
#define EMPTY(ptr)
Returns TRUE if ptr is NULL or *ptr is FALSE.