From 3ce25db632e7142159fc86081f36afefe9f317ce Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Fri, 27 Jun 2014 22:05:46 +0200 Subject: [PATCH] Remove line number zoom hack as it is no longer necessary Since cbf9813632d7ee921ffa1fda0d1f69128b2bc755 we have a proper solution for maintaining line number consistent with the editor zoom, so drop the old hack. This also allows to remove the now useless third argument of sci_set_line_numbers(). --- src/callbacks.c | 7 ------- src/document.c | 4 ++-- src/editor.c | 6 +++--- src/printing.c | 2 +- src/sciwrappers.c | 7 +------ src/sciwrappers.h | 2 +- src/ui_utils.c | 2 +- 7 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/callbacks.c b/src/callbacks.c index 41d47a073..bda084f5b 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -500,13 +500,9 @@ G_MODULE_EXPORT void on_hide_toolbar1_activate(GtkMenuItem *menuitem, gpointer u G_MODULE_EXPORT void on_zoom_in1_activate(GtkMenuItem *menuitem, gpointer user_data) { GeanyDocument *doc = document_get_current(); - static gint done = 1; g_return_if_fail(doc != NULL); - if (done++ % 3 == 0) - sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, - (sci_get_zoom(doc->editor->sci) / 2)); sci_zoom_in(doc->editor->sci); } @@ -518,8 +514,6 @@ G_MODULE_EXPORT void on_zoom_out1_activate(GtkMenuItem *menuitem, gpointer user_ g_return_if_fail(doc != NULL); - if (sci_get_zoom(doc->editor->sci) == 0) - sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0); sci_zoom_out(doc->editor->sci); } @@ -531,7 +525,6 @@ G_MODULE_EXPORT void on_normal_size1_activate(GtkMenuItem *menuitem, gpointer us g_return_if_fail(doc != NULL); sci_zoom_off(doc->editor->sci); - sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0); } diff --git a/src/document.c b/src/document.c index 6e734dcd8..00e9faf6e 100644 --- a/src/document.c +++ b/src/document.c @@ -791,7 +791,7 @@ GeanyDocument *document_new_file(const gchar *utf8_filename, GeanyFiletype *ft, document_set_text_changed(doc, FALSE); ui_document_show_hide(doc); /* update the document menu */ - sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0); + sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin); /* bring it in front, jump to the start and grab the focus */ editor_goto_pos(doc->editor, 0, FALSE); document_try_focus(doc, NULL); @@ -1247,7 +1247,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename /* update line number margin width */ doc->priv->line_count = sci_get_line_count(doc->editor->sci); - sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0); + sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin); if (! reload) { diff --git a/src/editor.c b/src/editor.c index d385c8a04..779e02836 100644 --- a/src/editor.c +++ b/src/editor.c @@ -934,7 +934,7 @@ static void auto_update_margin_width(GeanyEditor *editor) if (editor->document->priv->line_count != next_linecount) { doc->priv->line_count = next_linecount; - sci_set_line_numbers(editor->sci, TRUE, 0); + sci_set_line_numbers(editor->sci, TRUE); } } @@ -1127,7 +1127,7 @@ 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, 0); + sci_set_line_numbers(sci, editor_prefs.show_linenumber_margin); break; } /* we always return FALSE here to let plugins handle the event too */ @@ -5014,7 +5014,7 @@ void editor_apply_update_prefs(GeanyEditor *editor) sci_set_visible_white_spaces(sci, editor_prefs.show_white_space); sci_set_visible_eols(sci, editor_prefs.show_line_endings); sci_set_symbol_margin(sci, editor_prefs.show_markers_margin); - sci_set_line_numbers(sci, editor_prefs.show_linenumber_margin, 0); + sci_set_line_numbers(sci, editor_prefs.show_linenumber_margin); sci_set_folding_margin_visible(sci, editor_prefs.folding); diff --git a/src/printing.c b/src/printing.c index 8a3a9f534..d954da682 100644 --- a/src/printing.c +++ b/src/printing.c @@ -354,7 +354,7 @@ static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, scintilla_send_message(dinfo->sci, SCI_SETDOCPOINTER, 0, scintilla_send_message(dinfo->doc->editor->sci, SCI_GETDOCPOINTER, 0, 0)); highlighting_set_styles(dinfo->sci, dinfo->doc->file_type); - sci_set_line_numbers(dinfo->sci, printing_prefs.print_line_numbers, 0); + sci_set_line_numbers(dinfo->sci, printing_prefs.print_line_numbers); scintilla_send_message(dinfo->sci, SCI_SETVIEWWS, SCWS_INVISIBLE, 0); scintilla_send_message(dinfo->sci, SCI_SETVIEWEOL, FALSE, 0); scintilla_send_message(dinfo->sci, SCI_SETEDGEMODE, EDGE_NONE, 0); diff --git a/src/sciwrappers.c b/src/sciwrappers.c index 859e9ada2..c76f491e1 100644 --- a/src/sciwrappers.c +++ b/src/sciwrappers.c @@ -45,7 +45,7 @@ #define SSM(s, m, w, l) scintilla_send_message(s, m, w, l) /* line numbers visibility */ -void sci_set_line_numbers(ScintillaObject *sci, gboolean set, gint extra_width) +void sci_set_line_numbers(ScintillaObject *sci, gboolean set) { if (set) { @@ -55,11 +55,6 @@ void sci_set_line_numbers(ScintillaObject *sci, gboolean set, gint extra_width) g_snprintf(tmp_str, 15, "_%d", len); width = sci_text_width(sci, STYLE_LINENUMBER, tmp_str); - if (extra_width) - { - g_snprintf(tmp_str, 15, "%d", extra_width); - width += sci_text_width(sci, STYLE_LINENUMBER, tmp_str); - } SSM(sci, SCI_SETMARGINWIDTHN, 0, width); SSM(sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */ } diff --git a/src/sciwrappers.h b/src/sciwrappers.h index 9a93a4c88..19d227a56 100644 --- a/src/sciwrappers.h +++ b/src/sciwrappers.h @@ -31,7 +31,7 @@ G_BEGIN_DECLS gchar* sci_get_string (ScintillaObject *sci, guint msg, gulong wParam); -void sci_set_line_numbers (ScintillaObject *sci, gboolean set, gint extra_width); +void sci_set_line_numbers (ScintillaObject *sci, gboolean set); void sci_set_mark_long_lines (ScintillaObject *sci, gint type, gint column, const gchar *color); void sci_set_text (ScintillaObject *sci, const gchar *text); diff --git a/src/ui_utils.c b/src/ui_utils.c index e06ffbeb9..5bc04df33 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -1282,7 +1282,7 @@ void ui_toggle_editor_features(GeanyUIEditorFeatures feature) sci_set_symbol_margin(doc->editor->sci, editor_prefs.show_markers_margin); break; case GEANY_EDITOR_SHOW_LINE_NUMBERS: - sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin, 0); + sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin); break; case GEANY_EDITOR_SHOW_WHITE_SPACE: sci_set_visible_white_spaces(doc->editor->sci, editor_prefs.show_white_space); -- 2.11.4.GIT