Apply patch from Jeff Pohlmeyer to add a preference for whether to

use 'smart' home key behaviour (thanks).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1695 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2007-07-12 15:44:13 +00:00
parent 8fe0974d8a
commit 8743d2f994
7 changed files with 45 additions and 2 deletions

View File

@ -4,6 +4,10 @@
Make Escape close the 'Grab Key' dialog. Make Escape close the 'Grab Key' dialog.
* src/keybindings.c, src/tools.c, src/dialogs.c, src/search.c * src/keybindings.c, src/tools.c, src/dialogs.c, src/search.c
Capitalize some dialog titles. Capitalize some dialog titles.
* src/interface.c, src/prefs.c, src/keyfile.c, src/document.c,
src/editor.h, geany.glade:
Apply patch from Jeff Pohlmeyer to add a preference for whether to
use 'smart' home key behaviour (thanks).
2007-07-11 Enrico Tröger <enrico.troeger@uvena.de> 2007-07-11 Enrico Tröger <enrico.troeger@uvena.de>

View File

@ -5483,6 +5483,26 @@ Advanced</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkCheckButton" id="check_smart_home">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">When &quot;smart&quot; home is enabled, the HOME key will move the caret to the first non-blank character of the line, unless it is already there, it moves to the very beginning of the line. When this feature is disabled, the HOME key always moves the caret to the start of the current line, regardless of its current position.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable &quot;smart&quot; home key</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<widget class="GtkCheckButton" id="check_disable_dnd"> <widget class="GtkCheckButton" id="check_disable_dnd">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -216,6 +216,10 @@ void document_apply_update_prefs(gint idx)
sci_set_folding_margin_visible(sci, editor_prefs.folding); sci_set_folding_margin_visible(sci, editor_prefs.folding);
doc_list[idx].auto_indent = (editor_prefs.indent_mode != INDENT_NONE); doc_list[idx].auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
sci_assign_cmdkey(sci, SCK_HOME,
editor_prefs.smart_home_key ? SCI_VCHOMEWRAP : SCI_HOMEWRAP);
sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP);
} }
@ -299,8 +303,6 @@ static gint document_create_new_sci(const gchar *filename)
//SSM(sci, SCI_SETWRAPSTARTINDENT, 4, 0); //SSM(sci, SCI_SETWRAPSTARTINDENT, 4, 0);
// disable scintilla provided popup menu // disable scintilla provided popup menu
sci_use_popup(sci, FALSE); sci_use_popup(sci, FALSE);
sci_assign_cmdkey(sci, SCK_HOME, SCI_VCHOMEWRAP);
sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP);
// disable some Scintilla keybinsings to be able to redefine it // disable some Scintilla keybinsings to be able to redefine it
sci_clear_cmdkey(sci, 'A' | (SCMOD_CTRL << 16)); // select all sci_clear_cmdkey(sci, 'A' | (SCMOD_CTRL << 16)); // select all
sci_clear_cmdkey(sci, 'T' | (SCMOD_CTRL << 16)); // line transpose sci_clear_cmdkey(sci, 'T' | (SCMOD_CTRL << 16)); // line transpose

View File

@ -67,6 +67,7 @@ typedef struct
gboolean replace_tabs; gboolean replace_tabs;
gboolean trail_space; gboolean trail_space;
gboolean disable_dnd; gboolean disable_dnd;
gboolean smart_home_key;
GHashTable *auto_completions; GHashTable *auto_completions;
} EditorPrefs; } EditorPrefs;

View File

@ -2536,6 +2536,7 @@ create_prefs_dialog (void)
GtkWidget *alignment17; GtkWidget *alignment17;
GtkWidget *vbox17; GtkWidget *vbox17;
GtkWidget *check_line_wrapping; GtkWidget *check_line_wrapping;
GtkWidget *check_smart_home;
GtkWidget *check_disable_dnd; GtkWidget *check_disable_dnd;
GtkWidget *check_folding; GtkWidget *check_folding;
GtkWidget *check_unfold_children; GtkWidget *check_unfold_children;
@ -3456,6 +3457,12 @@ create_prefs_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox17), check_line_wrapping, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox17), check_line_wrapping, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_line_wrapping, _("Wrap the line at the window border and continue it on the next line. Note: line wrapping has a high performance cost for large documents so should be disabled on slow machines."), NULL); gtk_tooltips_set_tip (tooltips, check_line_wrapping, _("Wrap the line at the window border and continue it on the next line. Note: line wrapping has a high performance cost for large documents so should be disabled on slow machines."), NULL);
check_smart_home = gtk_check_button_new_with_mnemonic (_("Enable \"smart\" home key"));
gtk_widget_show (check_smart_home);
gtk_box_pack_start (GTK_BOX (vbox17), check_smart_home, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_smart_home, _("When \"smart\" home is enabled, the HOME key will move the caret to the first non-blank character of the line, unless it is already there, it moves to the very beginning of the line. When this feature is disabled, the HOME key always moves the caret to the start of the current line, regardless of its current position."), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_smart_home), FALSE);
check_disable_dnd = gtk_check_button_new_with_mnemonic (_("Disable Drag and Drop")); check_disable_dnd = gtk_check_button_new_with_mnemonic (_("Disable Drag and Drop"));
gtk_widget_show (check_disable_dnd); gtk_widget_show (check_disable_dnd);
gtk_box_pack_start (GTK_BOX (vbox17), check_disable_dnd, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox17), check_disable_dnd, FALSE, FALSE, 0);
@ -4247,6 +4254,7 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment17, "alignment17"); GLADE_HOOKUP_OBJECT (prefs_dialog, alignment17, "alignment17");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox17, "vbox17"); GLADE_HOOKUP_OBJECT (prefs_dialog, vbox17, "vbox17");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_line_wrapping, "check_line_wrapping"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_line_wrapping, "check_line_wrapping");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_smart_home, "check_smart_home");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_disable_dnd, "check_disable_dnd"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_disable_dnd, "check_disable_dnd");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_folding, "check_folding"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_folding, "check_folding");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_unfold_children, "check_unfold_children"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_unfold_children, "check_unfold_children");

View File

@ -268,6 +268,7 @@ void configuration_save()
g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", editor_prefs.replace_tabs); g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", editor_prefs.replace_tabs);
g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", editor_prefs.trail_space); g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", editor_prefs.trail_space);
g_key_file_set_boolean(config, PACKAGE, "pref_editor_disable_dnd", editor_prefs.disable_dnd); g_key_file_set_boolean(config, PACKAGE, "pref_editor_disable_dnd", editor_prefs.disable_dnd);
g_key_file_set_boolean(config, PACKAGE, "pref_editor_smart_home_key", editor_prefs.smart_home_key);
g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[editor_prefs.default_new_encoding].charset); g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[editor_prefs.default_new_encoding].charset);
if (editor_prefs.default_open_encoding == -1) if (editor_prefs.default_open_encoding == -1)
g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", "none"); g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", "none");
@ -538,6 +539,7 @@ gboolean configuration_load()
editor_prefs.new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE); editor_prefs.new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE);
editor_prefs.trail_space = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE); editor_prefs.trail_space = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE);
editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE); editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE);
editor_prefs.smart_home_key = utils_get_setting_boolean(config, PACKAGE, "pref_editor_smart_home_key", TRUE);
tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_MAKE); tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_MAKE);
app->tools_make_cmd = utils_get_setting_string(config, "tools", "make_cmd", tmp_string); app->tools_make_cmd = utils_get_setting_string(config, "tools", "make_cmd", tmp_string);

View File

@ -289,6 +289,9 @@ void prefs_init_dialog(void)
widget = lookup_widget(app->prefs_dialog, "check_disable_dnd"); widget = lookup_widget(app->prefs_dialog, "check_disable_dnd");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.disable_dnd); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.disable_dnd);
widget = lookup_widget(app->prefs_dialog, "check_smart_home");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.smart_home_key);
widget = lookup_widget(app->prefs_dialog, "check_use_tabs"); widget = lookup_widget(app->prefs_dialog, "check_use_tabs");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.use_tabs); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.use_tabs);
@ -644,6 +647,9 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
widget = lookup_widget(app->prefs_dialog, "check_disable_dnd"); widget = lookup_widget(app->prefs_dialog, "check_disable_dnd");
editor_prefs.disable_dnd = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); editor_prefs.disable_dnd = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_smart_home");
editor_prefs.smart_home_key = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_use_tabs"); widget = lookup_widget(app->prefs_dialog, "check_use_tabs");
editor_prefs.use_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); editor_prefs.use_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));