Apply patch from Catalin Marinas to add a 'newline strips trailing
spaces' pref (thanks). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1956 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
6da493990e
commit
5f688c6294
1
THANKS
1
THANKS
@ -37,6 +37,7 @@ Shiv <shivakumar(dot)gn(at)gmail(dot)com> - Sun Studio compiler compatibility pa
|
||||
Jean-François Wauthy <pollux(at)xfce(dot)org> - Symbol list icons patch
|
||||
blackdog <blackdog(at)ipowerhouse(dot)com> - Haxe filetype patch
|
||||
Sebastian Kraft <kraft(dot)sebastian(at)googlemail(dot)com> - new Geany icon
|
||||
Catalin Marinas <catalin(dot)marinas(at)gmail(dot)com> - newline strips trailing spaces patch
|
||||
|
||||
Translators:
|
||||
------------
|
||||
|
20
geany.glade
20
geany.glade
@ -5890,6 +5890,26 @@ Match braces</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="check_newline_strip">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Enable newline to strip the trailing spaces on the previous line.</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Newline strips trailing spaces</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>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -2074,6 +2074,27 @@ void document_replace_tabs(gint idx)
|
||||
}
|
||||
|
||||
|
||||
void document_strip_line_trailing_spaces(gint idx, gint line)
|
||||
{
|
||||
gint line_start = sci_get_position_from_line(doc_list[idx].sci, line);
|
||||
gint line_end = sci_get_line_end_position(doc_list[idx].sci, line);
|
||||
gint i = line_end - 1;
|
||||
gchar ch = sci_get_char_at(doc_list[idx].sci, i);
|
||||
|
||||
while ((i >= line_start) && ((ch == ' ') || (ch == '\t')))
|
||||
{
|
||||
i--;
|
||||
ch = sci_get_char_at(doc_list[idx].sci, i);
|
||||
}
|
||||
if (i < (line_end-1))
|
||||
{
|
||||
sci_target_start(doc_list[idx].sci, i + 1);
|
||||
sci_target_end(doc_list[idx].sci, line_end);
|
||||
sci_target_replace(doc_list[idx].sci, "", FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void document_strip_trailing_spaces(gint idx)
|
||||
{
|
||||
gint max_lines = sci_get_line_count(doc_list[idx].sci);
|
||||
@ -2083,22 +2104,7 @@ void document_strip_trailing_spaces(gint idx)
|
||||
|
||||
for (line = 0; line < max_lines; line++)
|
||||
{
|
||||
gint line_start = sci_get_position_from_line(doc_list[idx].sci, line);
|
||||
gint line_end = sci_get_line_end_position(doc_list[idx].sci, line);
|
||||
gint i = line_end - 1;
|
||||
gchar ch = sci_get_char_at(doc_list[idx].sci, i);
|
||||
|
||||
while ((i >= line_start) && ((ch == ' ') || (ch == '\t')))
|
||||
{
|
||||
i--;
|
||||
ch = sci_get_char_at(doc_list[idx].sci, i);
|
||||
}
|
||||
if (i < (line_end-1))
|
||||
{
|
||||
sci_target_start(doc_list[idx].sci, i + 1);
|
||||
sci_target_end(doc_list[idx].sci, line_end);
|
||||
sci_target_replace(doc_list[idx].sci, "", FALSE);
|
||||
}
|
||||
document_strip_line_trailing_spaces(idx, line);
|
||||
}
|
||||
sci_end_undo_action(doc_list[idx].sci);
|
||||
}
|
||||
|
@ -191,6 +191,8 @@ void document_print(gint idx);
|
||||
|
||||
void document_replace_tabs(gint idx);
|
||||
|
||||
void document_strip_line_trailing_spaces(gint idx, gint line);
|
||||
|
||||
void document_strip_trailing_spaces(gint idx);
|
||||
|
||||
void document_ensure_final_newline(gint idx);
|
||||
|
@ -396,6 +396,7 @@ static void on_new_line_added(gint idx)
|
||||
{
|
||||
ScintillaObject *sci = doc_list[idx].sci;
|
||||
gint pos = sci_get_current_position(sci);
|
||||
gint line = sci_get_current_line(sci);
|
||||
|
||||
// simple indentation
|
||||
if (doc_list[idx].auto_indent)
|
||||
@ -425,6 +426,12 @@ static void on_new_line_added(gint idx)
|
||||
|
||||
editor_auto_latex(idx, pos);
|
||||
}
|
||||
|
||||
if (editor_prefs.newline_strip)
|
||||
{
|
||||
// strip the trailing spaces on the previous line
|
||||
document_strip_line_trailing_spaces(idx, line - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,6 +66,7 @@ typedef struct EditorPrefs
|
||||
IndentMode indent_mode;
|
||||
gboolean disable_dnd;
|
||||
gboolean smart_home_key;
|
||||
gboolean newline_strip;
|
||||
gboolean auto_complete_symbols;
|
||||
gboolean auto_close_xml_tags;
|
||||
gboolean auto_complete_constructs;
|
||||
|
@ -2579,6 +2579,7 @@ create_prefs_dialog (void)
|
||||
GtkWidget *check_folding;
|
||||
GtkWidget *check_unfold_children;
|
||||
GtkWidget *check_indicators;
|
||||
GtkWidget *check_newline_strip;
|
||||
GtkWidget *label172;
|
||||
GtkWidget *frame18;
|
||||
GtkWidget *alignment21;
|
||||
@ -3612,6 +3613,12 @@ create_prefs_dialog (void)
|
||||
gtk_tooltips_set_tip (tooltips, check_indicators, _("Whether to use indicators (a squiggly underline) to highlight the lines where the compiler found a warning or an error."), NULL);
|
||||
gtk_button_set_focus_on_click (GTK_BUTTON (check_indicators), FALSE);
|
||||
|
||||
check_newline_strip = gtk_check_button_new_with_mnemonic (_("Newline strips trailing spaces"));
|
||||
gtk_widget_show (check_newline_strip);
|
||||
gtk_box_pack_start (GTK_BOX (vbox17), check_newline_strip, FALSE, FALSE, 0);
|
||||
gtk_tooltips_set_tip (tooltips, check_newline_strip, _("Enable newline to strip the trailing spaces on the previous line."), NULL);
|
||||
gtk_button_set_focus_on_click (GTK_BUTTON (check_newline_strip), FALSE);
|
||||
|
||||
label172 = gtk_label_new (_("<b>Features</b>"));
|
||||
gtk_widget_show (label172);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame14), label172);
|
||||
@ -4372,6 +4379,7 @@ create_prefs_dialog (void)
|
||||
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_indicators, "check_indicators");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, check_newline_strip, "check_newline_strip");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, label172, "label172");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, frame18, "frame18");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment21, "alignment21");
|
||||
|
@ -195,6 +195,7 @@ static void save_dialog_prefs(GKeyFile *config)
|
||||
g_key_file_set_boolean(config, PACKAGE, "pref_editor_use_tabs", editor_prefs.use_tabs);
|
||||
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_boolean(config, PACKAGE, "pref_editor_newline_strip", editor_prefs.newline_strip);
|
||||
|
||||
// files
|
||||
g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[prefs.default_new_encoding].charset);
|
||||
@ -469,6 +470,7 @@ static void load_dialog_prefs(GKeyFile *config)
|
||||
editor_prefs.use_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_use_tabs", TRUE);
|
||||
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);
|
||||
editor_prefs.newline_strip = utils_get_setting_boolean(config, PACKAGE, "pref_editor_newline_strip", FALSE);
|
||||
editor_prefs.use_gtk_word_boundaries = utils_get_setting_boolean(config, PACKAGE, "use_gtk_word_boundaries", TRUE);
|
||||
editor_prefs.auto_complete_whilst_editing = utils_get_setting_boolean(config, PACKAGE, "auto_complete_whilst_editing", FALSE);
|
||||
|
||||
|
@ -70,13 +70,13 @@
|
||||
|
||||
|
||||
/* The API version should be incremented whenever any plugin data types below are
|
||||
* modified. */
|
||||
static const gint api_version = 23;
|
||||
* modified or appended to. */
|
||||
static const gint api_version = 24;
|
||||
|
||||
/* The ABI version should be incremented whenever existing fields in the plugin
|
||||
* data types below have to be changed or reordered. It should stay the same if fields
|
||||
* are only appended, as this doesn't affect existing fields. */
|
||||
static const gint abi_version = 12;
|
||||
static const gint abi_version = 13;
|
||||
|
||||
/* This performs runtime checks that try to ensure:
|
||||
* 1. Geany ABI data types are compatible with this plugin.
|
||||
|
@ -315,6 +315,9 @@ void prefs_init_dialog(void)
|
||||
widget = lookup_widget(ui_widgets.prefs_dialog, "check_smart_home");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.smart_home_key);
|
||||
|
||||
widget = lookup_widget(ui_widgets.prefs_dialog, "check_newline_strip");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.newline_strip);
|
||||
|
||||
if (editor_prefs.use_tabs)
|
||||
widget = lookup_widget(ui_widgets.prefs_dialog, "radio_indent_tabs");
|
||||
else
|
||||
@ -695,6 +698,9 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
widget = lookup_widget(ui_widgets.prefs_dialog, "check_smart_home");
|
||||
editor_prefs.smart_home_key = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
|
||||
widget = lookup_widget(ui_widgets.prefs_dialog, "check_newline_strip");
|
||||
editor_prefs.newline_strip = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
|
||||
widget = lookup_widget(ui_widgets.prefs_dialog, "radio_indent_tabs");
|
||||
{
|
||||
gboolean use_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
|
Loading…
x
Reference in New Issue
Block a user