[geany/geany] e06f47: Merge pull request #289 from mspacek/build_line_num
Colomban Wendling
git-noreply at xxxxx
Mon Jan 5 15:26:03 UTC 2015
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 05 Jan 2015 15:26:03 UTC
Commit: e06f47d774bd296ed406378c6748ff12d3bd0fb6
https://github.com/geany/geany/commit/e06f47d774bd296ed406378c6748ff12d3bd0fb6
Log Message:
-----------
Merge pull request #289 from mspacek/build_line_num
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(-)
===================================================================
@@ -3183,6 +3183,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"
@@ -713,8 +714,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;
@@ -722,6 +723,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);
@@ -745,6 +747,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 */
@@ -2188,7 +2196,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).
More information about the Commits
mailing list