Branch: refs/heads/master Author: Martin Spacek git@mspacek.mm.st Committer: Martin Spacek git@mspacek.mm.st Date: Wed, 02 Jul 2014 22:07:21 UTC Commit: fd5ac727cbb687cc66c2de596f1dde8d957af051 https://github.com/geany/geany/commit/fd5ac727cbb687cc66c2de596f1dde8d957af0...
Log Message: ----------- Add %l current line number substitution to build commands
Modified Paths: -------------- doc/geany.txt src/build.c
Modified: doc/geany.txt 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -3127,6 +3127,7 @@ before the command is run. * %e - substituted by the name of the current file without the extension or path. * %f - substituted by the name of the current file without the path. * %p - if a project is open, substituted by the base path from the project. +* %l - substituted by the line number at the current cursor position.
.. note:: If the basepath set in the project preferences is not an absolute path , then it is
Modified: src/build.c 14 lines changed, 11 insertions(+), 3 deletions(-) =================================================================== @@ -43,6 +43,7 @@ #include "msgwindow.h" #include "prefs.h" #include "projectprivate.h" +#include "sciwrappers.h" #include "support.h" #include "toolbar.h" #include "ui_utils.h" @@ -712,8 +713,8 @@ static void parse_build_output(const gchar **output, gint status) #endif
-/* Replaces occurences of %e and %p with the appropriate filenames, - * %d and %p replacements should be in UTF8 */ +/* Replaces occurences of %e and %p with the appropriate filenames and + * %l with current line number. %d and %p replacements should be in UTF8 */ static gchar *build_replace_placeholder(const GeanyDocument *doc, const gchar *src) { GString *stack; @@ -721,6 +722,7 @@ static gchar *build_replace_placeholder(const GeanyDocument *doc, const gchar *s gchar *replacement; gchar *executable = NULL; gchar *ret_str; /* to be freed when not in use anymore */ + gint line_num;
g_return_val_if_fail(doc == NULL || doc->is_valid, NULL);
@@ -744,6 +746,12 @@ static gchar *build_replace_placeholder(const GeanyDocument *doc, const gchar *s replacement = g_path_get_basename(executable); utils_string_replace_all(stack, "%e", replacement); g_free(replacement); + + /* replace %l with the current 1-based line number */ + line_num = sci_get_current_line(doc->editor->sci) + 1; + replacement = g_strdup_printf("%i", line_num); + utils_string_replace_all(stack, "%l", replacement); + g_free(replacement); }
/* replace %p with the current project's (absolute) base directory */ @@ -2187,7 +2195,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT ++row; label = gtk_label_new(NULL); ui_label_set_markup(GTK_LABEL(label), "<i>%s</i>", - _("%d, %e, %f, %p are substituted in command and directory fields, see manual for details.")); + _("%d, %e, %f, %p, %l are substituted in command and directory fields, see manual for details.")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(table, label, 0, DC_N_COL, row, row + 1, GTK_FILL, GTK_FILL | GTK_EXPAND, entry_x_padding, entry_y_padding);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).