From db4cf9e59f6b1e347d28e24ee5ee0df91fb3c082 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 1 Aug 2006 13:24:58 +0000 Subject: [PATCH] Apply the tab width setting for new documents git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@658 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 2 ++ src/document.c | 23 ++++++++++++++++++----- src/document.h | 4 ++++ src/prefs.c | 8 +------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index b11aceba..1ac8ff03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ * src/keyfile.c: Change default for removing trailing spaces to off. * src/callbacks.c: Clear search flags when using find toolbar entry. Removed some unnecessary static variables. + * document.c, document.h, prefs.c: + Apply the tab width setting for new documents. 2006-07-31 Enrico Tröger diff --git a/src/document.c b/src/document.c index 51119881..5d1006b5 100644 --- a/src/document.c +++ b/src/document.c @@ -199,6 +199,21 @@ void document_init_doclist(void) } +// Apply just the prefs that can change in the Preferences dialog +void document_apply_update_prefs(ScintillaObject *sci) +{ + sci_set_mark_long_lines(sci, app->long_line_type, app->long_line_column, app->long_line_color); + + sci_set_tab_width(sci, app->pref_editor_tab_width); + + sci_set_indentionguides(sci, app->pref_editor_show_indent_guide); + sci_set_visible_white_spaces(sci, app->pref_editor_show_white_space); + sci_set_visible_eols(sci, app->pref_editor_show_line_endings); + + sci_set_folding_margin_visible(sci, app->pref_editor_folding); +} + + /* creates a new tab in the notebook and does all related stuff * finally it returns the index of the created document */ gint document_create_new_sci(const gchar *filename) @@ -234,14 +249,12 @@ gint document_create_new_sci(const gchar *filename) sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP); // disable select all to be able to redefine it sci_clear_cmdkey(sci, 'A' | (SCMOD_CTRL << 16)); - sci_set_mark_long_lines(sci, app->long_line_type, app->long_line_column, app->long_line_color); + + document_apply_update_prefs(sci); + sci_set_symbol_margin(sci, app->show_markers_margin); - sci_set_folding_margin_visible(sci, app->pref_editor_folding); sci_set_line_numbers(sci, app->show_linenumber_margin, 0); sci_set_lines_wrapped(sci, app->pref_editor_line_breaking); - sci_set_indentionguides(sci, app->pref_editor_show_indent_guide); - sci_set_visible_white_spaces(sci, app->pref_editor_show_white_space); - sci_set_visible_eols(sci, app->pref_editor_show_line_endings); pfd = pango_font_description_from_string(app->editor_font); fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd)); document_set_font(new_idx, fname, pango_font_description_get_size(pfd) / PANGO_SCALE); diff --git a/src/document.h b/src/document.h index 244457ff..8cc5b53c 100644 --- a/src/document.h +++ b/src/document.h @@ -58,6 +58,10 @@ void document_set_text_changed(gint); void document_init_doclist(void); +// Apply just the prefs that can change in the Preferences dialog +void document_apply_update_prefs(ScintillaObject *sci); + + /* creates a new tab in the notebook and does all related stuff * finally it returns the index of the created document */ gint document_create_new_sci(const gchar*); diff --git a/src/prefs.c b/src/prefs.c index 6cd442ef..dba92e6b 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -622,13 +622,7 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat { if (doc_list[i].is_valid) { - sci_set_tab_width(doc_list[i].sci, app->pref_editor_tab_width); - sci_set_mark_long_lines(doc_list[i].sci, app->long_line_type, - app->long_line_column, app->long_line_color); - sci_set_visible_eols(doc_list[i].sci, app->pref_editor_show_line_endings); - sci_set_indentionguides(doc_list[i].sci, app->pref_editor_show_indent_guide); - sci_set_visible_white_spaces(doc_list[i].sci, app->pref_editor_show_white_space); - sci_set_folding_margin_visible(doc_list[i].sci, app->pref_editor_folding); + document_apply_update_prefs(doc_list[i].sci); if (! app->pref_editor_folding) document_unfold_all(i); } }