diff --git a/data/geany.glade b/data/geany.glade index 1d9b211d..cb8cbd63 100644 --- a/data/geany.glade +++ b/data/geany.glade @@ -9029,6 +9029,22 @@ 0 + + + Line wrapping + True + True + False + 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. + True + True + + + False + False + 0 + + 2 diff --git a/src/editor.c b/src/editor.c index 779e0283..ea3354cc 100644 --- a/src/editor.c +++ b/src/editor.c @@ -375,6 +375,17 @@ static gboolean is_style_php(gint style) } +static gint editor_get_line_wrapping(void) +{ + if (app->project) + return app->project->priv->line_wrapping; + if (!editor_prefs.line_wrapping) + return 0; + else + return editor_prefs.line_wrapping; +} + + static gint editor_get_long_line_type(void) { if (app->project) @@ -415,6 +426,7 @@ 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(); return &eprefs; } @@ -5009,6 +5021,7 @@ void editor_apply_update_prefs(GeanyEditor *editor) sci_set_autoc_max_height(sci, editor_prefs.symbolcompletion_max_height); SSM(sci, SCI_AUTOCSETDROPRESTOFWORD, editor_prefs.completion_drops_rest_of_word, 0); + editor_set_line_wrapping(editor, editor_get_line_wrapping()); editor_set_indentation_guides(editor); sci_set_visible_white_spaces(sci, editor_prefs.show_white_space); diff --git a/src/project.c b/src/project.c index 7d203326..9802b5e0 100644 --- a/src/project.c +++ b/src/project.c @@ -684,6 +684,7 @@ static GeanyProject *create_project(void) project->priv->long_line_behaviour = 1 /* use global settings */; project->priv->long_line_column = editor_prefs.long_line_column; + project->priv->line_wrapping = editor_prefs.line_wrapping; app->project = project; return project; @@ -1063,6 +1064,8 @@ static gboolean load_config(const gchar *filename) "long_line_behaviour", 1 /* follow global */); p->priv->long_line_column = utils_get_setting_integer(config, "long line marker", "long_line_column", editor_prefs.long_line_column); + p->priv->line_wrapping = utils_get_setting_boolean(config, "line_wrapping", + "line_wrapping", editor_prefs.line_wrapping); apply_editor_prefs(); build_load_menu(config, GEANY_BCS_PROJ, (gpointer)p); @@ -1132,6 +1135,7 @@ static gboolean write_config(gboolean emit_signal) g_key_file_set_integer(config, "long line marker", "long_line_behaviour", p->priv->long_line_behaviour); g_key_file_set_integer(config, "long line marker", "long_line_column", p->priv->long_line_column); + g_key_file_set_boolean(config, "line_wrapping", "line_wrapping", p->priv->line_wrapping); /* store the session files into the project too */ if (project_prefs.project_session) configuration_save_session_files(config); @@ -1289,6 +1293,12 @@ static void init_stash_prefs(void) "strip_trailing_spaces", file_prefs.strip_trailing_spaces, "check_trailing_spaces1"); stash_group_add_toggle_button(group, &priv.replace_tabs, "replace_tabs", file_prefs.replace_tabs, "check_replace_tabs1"); + group = stash_group_new("file_prefs"); + add_stash_group(group); + + group = stash_group_new("line_wrapping"); + stash_group_add_toggle_button(group, &priv.line_wrapping, + "line_wrapping", editor_prefs.line_wrapping, "check_line_wrapping1"); add_stash_group(group); /* apply defaults */ kf = g_key_file_new(); diff --git a/src/projectprivate.h b/src/projectprivate.h index 2bdd9c75..c7f338f9 100644 --- a/src/projectprivate.h +++ b/src/projectprivate.h @@ -39,6 +39,7 @@ typedef struct GeanyProjectPrivate 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;