From b9329b09d2fac1b819d7ebdf18fc116f4dab2d7d Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 17 Aug 2016 21:00:02 -0300 Subject: [PATCH] eeshow/fmt-pango.c, fmt-pango.h: also move to gui/ --- eeshow/Makefile | 2 +- eeshow/git-hist.c | 6 +++--- eeshow/git-hist.h | 3 ++- eeshow/{ => gui}/fmt-pango.c | 4 ++-- eeshow/{ => gui}/fmt-pango.h | 8 ++++---- eeshow/gui/gui.c | 5 +++-- eeshow/gui/over.c | 2 +- eeshow/main.c | 2 +- 8 files changed, 17 insertions(+), 15 deletions(-) rename eeshow/{ => gui}/fmt-pango.c (97%) rename eeshow/{ => gui}/fmt-pango.h (81%) diff --git a/eeshow/Makefile b/eeshow/Makefile index 9c4f74e..05e9cf9 100644 --- a/eeshow/Makefile +++ b/eeshow/Makefile @@ -12,7 +12,7 @@ NAME = eeshow OBJS = main.o sch-parse.o sch-render.o lib-parse.o lib-render.o \ - gui/gui.o gui/over.o gui/style.o gui/aoi.o fmt-pango.o \ + gui/gui.o gui/over.o gui/style.o gui/aoi.o gui/fmt-pango.o \ file.o git-util.o git-file.o git-hist.o delta.o \ style.o fig.o record.o cro.o diff.o gfx.o dwg.o text.o misc.o diag.o diff --git a/eeshow/git-hist.c b/eeshow/git-hist.c index 03d02d4..6f18fa8 100644 --- a/eeshow/git-hist.c +++ b/eeshow/git-hist.c @@ -18,7 +18,6 @@ #include "util.h" #include "diag.h" -#include "fmt-pango.h" /* for vcs_long_for_pango */ #include "git-util.h" #include "git-file.h" #include "git-hist.h" @@ -211,7 +210,8 @@ const char *vcs_git_summary(struct hist *h) * the very specific constraints imposed by the markup format of Pango. */ -char *vcs_git_long_for_pango(struct hist *h) +char *vcs_git_long_for_pango(struct hist *h, + char *(*formatter)(const char *fmt, ...)) { const git_error *e; git_buf buf = { 0 }; @@ -225,7 +225,7 @@ char *vcs_git_long_for_pango(struct hist *h) goto fail; commit_time = git_commit_time(h->commit); sig = git_commit_committer(h->commit); - s = fmt_pango("%s %s%s <%s>\n%s", + s = formatter("%s %s%s <%s>\n%s", buf.ptr, ctime(&commit_time), sig->name, sig->email, git_commit_summary(h->commit)); git_buf_free(&buf); diff --git a/eeshow/git-hist.h b/eeshow/git-hist.h index 8caebfc..c26cf5d 100644 --- a/eeshow/git-hist.h +++ b/eeshow/git-hist.h @@ -35,7 +35,8 @@ bool vcs_git_try(const char *path); struct hist *vcs_git_hist(const char *path); char *vcs_git_get_rev(struct hist *h); const char *vcs_git_summary(struct hist *hist); -char *vcs_git_long_for_pango(struct hist *hist); +char *vcs_git_long_for_pango(struct hist *hist, + char *(*formatter)(const char *fmt, ...)); void hist_iterate(struct hist *h, void (*fn)(void *user, struct hist *h), void *user); void dump_hist(struct hist *h); diff --git a/eeshow/fmt-pango.c b/eeshow/gui/fmt-pango.c similarity index 97% rename from eeshow/fmt-pango.c rename to eeshow/gui/fmt-pango.c index d877b61..96deba4 100644 --- a/eeshow/fmt-pango.c +++ b/eeshow/gui/fmt-pango.c @@ -1,5 +1,5 @@ /* - * fmt-pango.c - Format strings for Pango markup + * gui/fmt-pango.c - Format strings for Pango markup * * Written 2016 by Werner Almesberger * Copyright 2016 by Werner Almesberger @@ -20,7 +20,7 @@ #include "util.h" #include "diag.h" -#include "fmt-pango.h" +#include "gui/fmt-pango.h" unsigned vsfmt_pango(char *buf, const char *fmt, va_list ap) diff --git a/eeshow/fmt-pango.h b/eeshow/gui/fmt-pango.h similarity index 81% rename from eeshow/fmt-pango.h rename to eeshow/gui/fmt-pango.h index 43628e4..cf4c315 100644 --- a/eeshow/fmt-pango.h +++ b/eeshow/gui/fmt-pango.h @@ -1,5 +1,5 @@ /* - * fmt-pango.h - Format strings for Pango markup + * gui/fmt-pango.h - Format strings for Pango markup * * Written 2016 by Werner Almesberger * Copyright 2016 by Werner Almesberger @@ -11,8 +11,8 @@ */ -#ifndef FMT_PANGO_H -#define FMT_PANGO_H +#ifndef GUI_FMT_PANGO_H +#define GUI_FMT_PANGO_H #include @@ -22,4 +22,4 @@ char *vfmt_pango(const char *fmt, va_list ap); char *fmt_pango(const char *fmt, ...) __attribute__((format(printf, 1, 2))); -#endif /* !FMT_PANGO_H */ +#endif /* !GUI_FMT_PANGO_H */ diff --git a/eeshow/gui/gui.c b/eeshow/gui/gui.c index 5ed3e82..8bde583 100644 --- a/eeshow/gui/gui.c +++ b/eeshow/gui/gui.c @@ -38,6 +38,7 @@ #include "delta.h" #include "diff.h" #include "dwg.h" +#include "gui/fmt-pango.h" #include "gui/aoi.h" #include "gui/style.h" #include "gui/over.h" @@ -489,7 +490,7 @@ static bool hover_history(void *user, bool on) char *s; if (on) { - s = vcs_git_long_for_pango(h->vcs_hist); + s = vcs_git_long_for_pango(h->vcs_hist, fmt_pango); overlay_text_raw(h->over, s); free(s); } else { @@ -680,7 +681,7 @@ static bool show_history_details(void *user, bool on) char *s; if (on) { - s = vcs_git_long_for_pango(h->vcs_hist); + s = vcs_git_long_for_pango(h->vcs_hist, fmt_pango); overlay_text_raw(h->over, s); free(s); } else { diff --git a/eeshow/gui/over.c b/eeshow/gui/over.c index 7ee7a91..aedfd92 100644 --- a/eeshow/gui/over.c +++ b/eeshow/gui/over.c @@ -31,7 +31,7 @@ #include #include "util.h" -#include "fmt-pango.h" +#include "gui/fmt-pango.h" #include "gui/aoi.h" #include "gui/style.h" #include "gui/over.h" diff --git a/eeshow/main.c b/eeshow/main.c index d6ff527..e88f0f1 100644 --- a/eeshow/main.c +++ b/eeshow/main.c @@ -28,7 +28,7 @@ #include "file.h" #include "lib.h" #include "sch.h" -#include "fmt-pango.h" +#include "gui/fmt-pango.h" #include "git-hist.h" #include "gui/gui.h" #include "main.h"