Add project prefs for line breaking column & multiline comments

This commit is contained in:
Nick Treleaven 2014-10-02 17:50:39 +01:00
parent 9eb865dab3
commit e566aae6b2
5 changed files with 161 additions and 36 deletions

View File

@ -8883,6 +8883,140 @@
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="spacing">10</property>
<child>
<object class="GtkFrame" id="frame11p">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment8p">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox56p">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="check_line_wrapping1">
<property name="label" translatable="yes">Line wrapping</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">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.</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox11p">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label209p">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Line breaking column:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin_line_break1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">1</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label8p">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Features&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkCheckButton" id="check_auto_multiline1">
<property name="label" translatable="yes">Automatic continuation of multi-line comments</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Continue automatically multi-line comments in languages like C, C++ and Java when a new line is entered inside such a comment</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label23">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Completions&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame40_project">
<property name="visible">True</property>
@ -9026,23 +9160,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_line_wrapping1">
<property name="label" translatable="yes">Line wrapping</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">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.</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="position">2</property>
</packing>
</child>
</object>

View File

@ -404,11 +404,8 @@ static gint editor_get_long_line_column(void)
}
static gboolean editor_get_line_wrapping(void)
{
return app->project ? app->project->priv->line_wrapping : editor_prefs.line_wrapping;
}
#define get_project_pref(id)\
(app->project ? app->project->priv->id : editor_prefs.id)
static const GeanyEditorPrefs *
get_default_prefs(void)
@ -421,7 +418,9 @@ get_default_prefs(void)
eprefs.indentation = (GeanyIndentPrefs*)editor_get_indent_prefs(NULL);
eprefs.long_line_type = editor_get_long_line_type();
eprefs.long_line_column = editor_get_long_line_column();
eprefs.line_wrapping = editor_get_line_wrapping();
eprefs.line_wrapping = get_project_pref(line_wrapping);
eprefs.line_break_column = get_project_pref(line_break_column);
eprefs.auto_continue_multiline = get_project_pref(auto_continue_multiline);
return &eprefs;
}
@ -560,11 +559,11 @@ static void check_line_breaking(GeanyEditor *editor, gint pos)
lstart = sci_get_position_from_line(sci, line);
/* use column instead of position which might be different with multibyte characters */
if (col < editor_prefs.line_break_column)
if (col < get_project_pref(line_break_column))
return;
/* look for the last space before line_break_column */
pos = MIN(pos, lstart + editor_prefs.line_break_column);
pos = MIN(pos, lstart + get_project_pref(line_break_column));
while (pos > lstart)
{
@ -1241,7 +1240,7 @@ static void on_new_line_added(GeanyEditor *editor)
insert_indent_after_line(editor, line - 1);
}
if (editor_prefs.auto_continue_multiline)
if (get_project_pref(auto_continue_multiline))
{ /* " * " auto completion in multiline C/C++/D/Java comments */
auto_multiline(editor, line);
}
@ -4850,7 +4849,7 @@ GeanyEditor *editor_create(GeanyDocument *doc)
doc->editor = editor; /* needed in case some editor functions/callbacks expect it */
editor->auto_indent = (iprefs->auto_indent_mode != GEANY_AUTOINDENT_NONE);
editor->line_wrapping = editor_get_line_wrapping();
editor->line_wrapping = get_project_pref(line_wrapping);
editor->scroll_percent = -1.0F;
editor->line_breaking = FALSE;

View File

@ -112,17 +112,15 @@ GeanyIndentPrefs;
/** Default prefs when creating a new editor window.
* Some of these can be overridden per document or per project. */
/* See editor_get_prefs(). */
/* @warning Use @c editor_get_prefs() instead to include project overrides. */
typedef struct GeanyEditorPrefs
{
GeanyIndentPrefs *indentation; /* Default indentation prefs. Use editor_get_indent_prefs(). */
gboolean show_white_space;
gboolean show_indent_guide;
gboolean show_line_endings;
/* 0 - line, 1 - background, 2 - disabled.
* This setting may be overridden when a project is opened. Use @c editor_get_prefs(). */
/* 0 - line, 1 - background, 2 - disabled. */
gint long_line_type;
/* This setting may be overridden when a project is opened. Use @c editor_get_prefs(). */
gint long_line_column;
gchar *long_line_color;
gboolean show_markers_margin; /* view menu */
@ -154,7 +152,6 @@ typedef struct GeanyEditorPrefs
gboolean completion_drops_rest_of_word;
gchar *color_scheme;
gint show_virtual_space;
/* This setting may be overridden when a project is opened. Use @c editor_get_prefs(). */
gboolean long_line_enabled;
gint autocompletion_update_freq;
}

View File

@ -1302,6 +1302,11 @@ static void init_stash_prefs(void)
group = stash_group_new("editor");
stash_group_add_toggle_button(group, &priv.line_wrapping,
"line_wrapping", editor_prefs.line_wrapping, "check_line_wrapping1");
stash_group_add_spin_button_integer(group, &priv.line_break_column,
"line_break_column", editor_prefs.line_break_column, "spin_line_break1");
stash_group_add_toggle_button(group, &priv.auto_continue_multiline,
"auto_continue_multiline", editor_prefs.auto_continue_multiline,
"check_auto_multiline1");
add_stash_group(group, TRUE);
}

View File

@ -31,15 +31,21 @@ G_BEGIN_DECLS
typedef struct GeanyProjectPrivate
{
struct GeanyIndentPrefs *indentation;
// file prefs
gboolean final_new_line;
gboolean strip_trailing_spaces;
gboolean replace_tabs;
gboolean ensure_convert_new_lines;
// editor prefs
struct GeanyIndentPrefs *indentation;
gboolean line_wrapping;
gint line_break_column;
gboolean auto_continue_multiline;
gint long_line_behaviour; /* 0 - disabled, 1 - follow global settings, 2 - enabled (custom) */
gint long_line_column; /* Long line marker position. */
GPtrArray *build_filetypes_list; /* Project has custom filetype builds for these. */
gint long_line_behaviour; /* 0 - disabled, 1 - follow global settings, 2 - enabled (custom) */
gint long_line_column; /* Long line marker position. */
gboolean line_wrapping;
}
GeanyProjectPrivate;