From b1b6143a46e49d73f505a31a5390d4cdf5e57045 Mon Sep 17 00:00:00 2001 From: andy5995 Date: Wed, 1 May 2019 04:59:45 -0500 Subject: [PATCH 1/5] start on issue #2068 --- data/filedefs/filetypes.common | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/filedefs/filetypes.common b/data/filedefs/filetypes.common index f0992e326e..0f37622c89 100644 --- a/data/filedefs/filetypes.common +++ b/data/filedefs/filetypes.common @@ -176,3 +176,6 @@ entity=default line_added=0x34b034;0xffffff;false;false line_removed=0xff2727;0xffffff;false;false line_changed=0x7f007f;0xffffff;false;false + +[scintilla_settings] +sci_symbol_folding_margin_width=16 From db9ab8e78c855b5d0c3ca10eef58f07355e1019a Mon Sep 17 00:00:00 2001 From: andy5995 Date: Wed, 1 May 2019 05:09:18 -0500 Subject: [PATCH 2/5] add more code to work with --- src/highlighting.c | 6 +++++- src/sciwrappers.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/highlighting.c b/src/highlighting.c index 65d15164b4..b90a9d3a90 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -96,7 +96,8 @@ enum /* Geany common styling */ GCS_LINE_HEIGHT, GCS_CALLTIPS, GCS_INDICATOR_ERROR, - GCS_MAX + GCS_MAX, + SCI_SYMBOL_FOLDING_MARGIN_WIDTH }; static struct @@ -581,6 +582,9 @@ static void styleset_common_init(GKeyFile *config, GKeyFile *config_home) get_keyfile_wordchars(config, config_home, &common_style_set.wordchars, GEANY_WORDCHARS); g_free(whitespace_chars); whitespace_chars = get_keyfile_whitespace_chars(config, config_home); + + get_keyfile_int(config, config_home, "scintilla_settings", "sci_symbol_folding_margin_width", + 0, 0, &common_style_set.styling[SCI_SYMBOL_FOLDING_MARGIN_WIDTH]); } diff --git a/src/sciwrappers.c b/src/sciwrappers.c index 52e7346ec3..50454d8681 100644 --- a/src/sciwrappers.c +++ b/src/sciwrappers.c @@ -149,7 +149,7 @@ void sci_set_symbol_margin(ScintillaObject *sci, gboolean set) { if (set) { - SSM(sci, SCI_SETMARGINWIDTHN, 1, 16); + SSM(sci, SCI_SETMARGINWIDTHN, 1, common_style_set.styling[SCI_SYMBOL_FOLDING_MARGIN_WIDTH]); SSM(sci, SCI_SETMARGINSENSITIVEN, 1, TRUE); } else From a3f99d3e633e11993aabeb1bf34f96a6d6f58a7a Mon Sep 17 00:00:00 2001 From: andy5995 Date: Sun, 23 Jun 2019 01:03:17 -0500 Subject: [PATCH 3/5] use code similar to "caret_width" (#2068) --- src/highlighting.c | 10 ++++++---- src/sciwrappers.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/highlighting.c b/src/highlighting.c index b90a9d3a90..bbb955346e 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -96,8 +96,8 @@ enum /* Geany common styling */ GCS_LINE_HEIGHT, GCS_CALLTIPS, GCS_INDICATOR_ERROR, - GCS_MAX, - SCI_SYMBOL_FOLDING_MARGIN_WIDTH + GCS_SYMBOL_FOLDING_MARGIN_WIDTH, + GCS_MAX }; static struct @@ -583,8 +583,8 @@ static void styleset_common_init(GKeyFile *config, GKeyFile *config_home) g_free(whitespace_chars); whitespace_chars = get_keyfile_whitespace_chars(config, config_home); - get_keyfile_int(config, config_home, "scintilla_settings", "sci_symbol_folding_margin_width", - 0, 0, &common_style_set.styling[SCI_SYMBOL_FOLDING_MARGIN_WIDTH]); + get_keyfile_ints(config, config_home, "scintilla_settings", "sci_symbol_folding_margin_width", + 1, 0, &common_style_set.styling[GCS_SYMBOL_FOLDING_MARGIN_WIDTH].background, NULL); } @@ -683,6 +683,8 @@ static void styleset_common(ScintillaObject *sci, guint ft_id) SSM(sci, SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL); SSM(sci, SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS); + SSM(sci, SCI_SETMARGINWIDTHN, common_style_set.styling[GCS_SYMBOL_FOLDING_MARGIN_WIDTH].background, 0); + /* drawing a horizontal line when text if folded */ switch (common_style_set.fold_draw_line) { diff --git a/src/sciwrappers.c b/src/sciwrappers.c index 50454d8681..52e7346ec3 100644 --- a/src/sciwrappers.c +++ b/src/sciwrappers.c @@ -149,7 +149,7 @@ void sci_set_symbol_margin(ScintillaObject *sci, gboolean set) { if (set) { - SSM(sci, SCI_SETMARGINWIDTHN, 1, common_style_set.styling[SCI_SYMBOL_FOLDING_MARGIN_WIDTH]); + SSM(sci, SCI_SETMARGINWIDTHN, 1, 16); SSM(sci, SCI_SETMARGINSENSITIVEN, 1, TRUE); } else From fa79e6217ee14be1071256969492864714e1bb60 Mon Sep 17 00:00:00 2001 From: andy5995 Date: Tue, 9 Jul 2019 23:39:42 -0500 Subject: [PATCH 4/5] soft-code setting for width of folding margin --- data/filedefs/filetypes.common | 6 +++--- src/editor.c | 2 -- src/highlighting.c | 27 +++++++++++++++++++++------ src/sciwrappers.c | 16 ---------------- src/sciwrappers.h | 1 - 5 files changed, 24 insertions(+), 28 deletions(-) diff --git a/data/filedefs/filetypes.common b/data/filedefs/filetypes.common index 0f37622c89..6770579914 100644 --- a/data/filedefs/filetypes.common +++ b/data/filedefs/filetypes.common @@ -19,6 +19,9 @@ margin_linenumber=margin_line_number margin_folding=margin_folding fold_symbol_highlight=fold_symbol_highlight +# width of the folding margin on the right of the line numbers +folding_margin_width=12 + # background colour of the current line, only the second and third argument is interpreted # use the third argument to enable or disable the highlighting of the current line (has to be true/false) current_line=current_line @@ -176,6 +179,3 @@ entity=default line_added=0x34b034;0xffffff;false;false line_removed=0xff2727;0xffffff;false;false line_changed=0x7f007f;0xffffff;false;false - -[scintilla_settings] -sci_symbol_folding_margin_width=16 diff --git a/src/editor.c b/src/editor.c index df25c88083..e2473c4c6c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -5189,8 +5189,6 @@ void editor_apply_update_prefs(GeanyEditor *editor) sci_set_symbol_margin(sci, editor_prefs.show_markers_margin); sci_set_line_numbers(sci, editor_prefs.show_linenumber_margin); - sci_set_folding_margin_visible(sci, editor_prefs.folding); - /* virtual space */ SSM(sci, SCI_SETVIRTUALSPACEOPTIONS, editor_prefs.show_virtual_space, 0); diff --git a/src/highlighting.c b/src/highlighting.c index bbb955346e..ad52725804 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -96,7 +96,7 @@ enum /* Geany common styling */ GCS_LINE_HEIGHT, GCS_CALLTIPS, GCS_INDICATOR_ERROR, - GCS_SYMBOL_FOLDING_MARGIN_WIDTH, + GCS_FOLDING_MARGIN_WIDTH, GCS_MAX }; @@ -565,6 +565,8 @@ static void styleset_common_init(GKeyFile *config, GKeyFile *config_home) 1, 1, &common_style_set.fold_marker, &common_style_set.fold_lines); get_keyfile_ints(config, config_home, "styling", "folding_horiz_line", 2, 0, &common_style_set.fold_draw_line, NULL); + get_keyfile_ints(config, config_home, "styling", "folding_margin_width", + 1, 0, &common_style_set.styling[GCS_FOLDING_MARGIN_WIDTH].background, NULL); get_keyfile_ints(config, config_home, "styling", "caret_width", 1, 0, &common_style_set.styling[GCS_CARET].background, NULL); /* caret.foreground used earlier */ get_keyfile_int(config, config_home, "styling", "line_wrap_visuals", @@ -582,9 +584,6 @@ static void styleset_common_init(GKeyFile *config, GKeyFile *config_home) get_keyfile_wordchars(config, config_home, &common_style_set.wordchars, GEANY_WORDCHARS); g_free(whitespace_chars); whitespace_chars = get_keyfile_whitespace_chars(config, config_home); - - get_keyfile_ints(config, config_home, "scintilla_settings", "sci_symbol_folding_margin_width", - 1, 0, &common_style_set.styling[GCS_SYMBOL_FOLDING_MARGIN_WIDTH].background, NULL); } @@ -683,8 +682,6 @@ static void styleset_common(ScintillaObject *sci, guint ft_id) SSM(sci, SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL); SSM(sci, SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS); - SSM(sci, SCI_SETMARGINWIDTHN, common_style_set.styling[GCS_SYMBOL_FOLDING_MARGIN_WIDTH].background, 0); - /* drawing a horizontal line when text if folded */ switch (common_style_set.fold_draw_line) { @@ -811,6 +808,22 @@ static void styleset_common(ScintillaObject *sci, guint ft_id) } +/* folding margin visibility */ +static void sci_set_folding_margin_visible(ScintillaObject *sci, gboolean set) +{ + if (set) + { + SSM(sci, SCI_SETMARGINWIDTHN, 2, common_style_set.styling[GCS_FOLDING_MARGIN_WIDTH].background); + SSM(sci, SCI_SETMARGINSENSITIVEN, 2, TRUE); + } + else + { + SSM(sci, SCI_SETMARGINSENSITIVEN, 2, FALSE); + SSM(sci, SCI_SETMARGINWIDTHN, 2, 0); + } +} + + /* Merge & assign global typedefs and user secondary keywords. * keyword_idx is used for both style_sets[].keywords and scintilla keyword style number */ static void merge_type_keywords(ScintillaObject *sci, guint ft_id, guint keyword_idx) @@ -886,6 +899,8 @@ static void styleset_from_mapping(ScintillaObject *sci, guint ft_id, guint lexer } } + sci_set_folding_margin_visible(sci, editor_prefs.folding); + /* keywords */ foreach_range(i, n_keywords) { diff --git a/src/sciwrappers.c b/src/sciwrappers.c index 52e7346ec3..65eb72d605 100644 --- a/src/sciwrappers.c +++ b/src/sciwrappers.c @@ -160,22 +160,6 @@ void sci_set_symbol_margin(ScintillaObject *sci, gboolean set) } -/* folding margin visibility */ -void sci_set_folding_margin_visible(ScintillaObject *sci, gboolean set) -{ - if (set) - { - SSM(sci, SCI_SETMARGINWIDTHN, 2, 12); - SSM(sci, SCI_SETMARGINSENSITIVEN, 2, TRUE); - } - else - { - SSM(sci, SCI_SETMARGINSENSITIVEN, 2, FALSE); - SSM(sci, SCI_SETMARGINWIDTHN, 2, 0); - } -} - - /* end of lines */ void sci_set_visible_eols(ScintillaObject *sci, gboolean set) { diff --git a/src/sciwrappers.h b/src/sciwrappers.h index f74e23221b..da8afb3006 100644 --- a/src/sciwrappers.h +++ b/src/sciwrappers.h @@ -157,7 +157,6 @@ void sci_toggle_fold (ScintillaObject *sci, gint line); gint sci_get_fold_level (ScintillaObject *sci, gint line); gint sci_get_fold_parent (ScintillaObject *sci, gint start_line); -void sci_set_folding_margin_visible (ScintillaObject *sci, gboolean set); gboolean sci_get_fold_expanded (ScintillaObject *sci, gint line); void sci_colourise (ScintillaObject *sci, gint start, gint end); From 880b929317b338e1350e5758e0df0430c0fec03a Mon Sep 17 00:00:00 2001 From: andy5995 Date: Sun, 21 Jun 2020 21:33:57 -0500 Subject: [PATCH 5/5] remove sci_ prefix from function --- src/highlighting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/highlighting.c b/src/highlighting.c index ad52725804..30e897587a 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -809,7 +809,7 @@ static void styleset_common(ScintillaObject *sci, guint ft_id) /* folding margin visibility */ -static void sci_set_folding_margin_visible(ScintillaObject *sci, gboolean set) +static void set_folding_margin_visible(ScintillaObject *sci, gboolean set) { if (set) { @@ -899,7 +899,7 @@ static void styleset_from_mapping(ScintillaObject *sci, guint ft_id, guint lexer } } - sci_set_folding_margin_visible(sci, editor_prefs.folding); + set_folding_margin_visible(sci, editor_prefs.folding); /* keywords */ foreach_range(i, n_keywords)