[geany/geany] 6673ea: Size symbols and fold margins proportional to line height

Colomban Wendling git-noreply at xxxxx
Sun Oct 25 09:50:08 UTC 2020


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 25 Oct 2020 09:50:08 UTC
Commit:      6673ea5b49260beffe2c258889f9bd1427f33bac
             https://github.com/geany/geany/commit/6673ea5b49260beffe2c258889f9bd1427f33bac

Log Message:
-----------
Size symbols and fold margins proportional to line height

This makes those margin better adapt larger font sizes and zooms.

Fixes #1733.


Modified Paths:
--------------
    src/editor.c
    src/sciwrappers.c

Modified: src/editor.c
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -1187,6 +1187,8 @@ static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *edi
 		case SCN_ZOOM:
 			/* recalculate line margin width */
 			sci_set_line_numbers(sci, editor_prefs.show_linenumber_margin);
+			sci_set_symbol_margin(sci, editor_prefs.show_markers_margin);
+			sci_set_folding_margin_visible(sci, editor_prefs.folding);
 			break;
 	}
 	/* we always return FALSE here to let plugins handle the event too */


Modified: src/sciwrappers.c
25 lines changed, 23 insertions(+), 2 deletions(-)
===================================================================
@@ -144,12 +144,31 @@ void sci_set_mark_long_lines(ScintillaObject *sci, gint type, gint column, const
 }
 
 
+/* compute margin width based on ratio of line height */
+static gint margin_width_from_line_height(ScintillaObject *sci, gdouble ratio, gint threshold)
+{
+	const gint line_height = SSM(sci, SCI_TEXTHEIGHT, 0, 0);
+	gint width;
+
+	width = line_height * ratio;
+	/* round down to an even size */
+	width = width - (width % 2);
+	/* if under threshold, just use the line height */
+	if (width < threshold)
+		width = MIN(threshold, line_height);
+
+	return width;
+}
+
+
 /* symbol margin visibility */
 void sci_set_symbol_margin(ScintillaObject *sci, gboolean set)
 {
 	if (set)
 	{
-		SSM(sci, SCI_SETMARGINWIDTHN, 1, 16);
+		const gint width = margin_width_from_line_height(sci, 0.88, 16);
+
+		SSM(sci, SCI_SETMARGINWIDTHN, 1, width);
 		SSM(sci, SCI_SETMARGINSENSITIVEN, 1, TRUE);
 	}
 	else
@@ -165,7 +184,9 @@ void sci_set_folding_margin_visible(ScintillaObject *sci, gboolean set)
 {
 	if (set)
 	{
-		SSM(sci, SCI_SETMARGINWIDTHN, 2, 12);
+		const gint width = margin_width_from_line_height(sci, 0.66, 12);
+
+		SSM(sci, SCI_SETMARGINWIDTHN, 2, width);
 		SSM(sci, SCI_SETMARGINSENSITIVEN, 2, TRUE);
 	}
 	else



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list