mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 09:28:24 +02:00
eeshow/: option -N depth to limit history depth; -N-depth exits after parsing
This commit is contained in:
parent
02e4d6e071
commit
54922dc343
21
eeshow/gui.c
21
eeshow/gui.c
@ -996,7 +996,7 @@ struct add_hist_ctx {
|
|||||||
int n_args;
|
int n_args;
|
||||||
char **args;
|
char **args;
|
||||||
bool recurse;
|
bool recurse;
|
||||||
unsigned limit;
|
unsigned limit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1008,9 +1008,10 @@ static void add_hist(void *user, struct hist *h)
|
|||||||
const struct sheet *sch;
|
const struct sheet *sch;
|
||||||
unsigned age = 0;
|
unsigned age = 0;
|
||||||
|
|
||||||
if (!ahc->limit)
|
if (!ahc->limit)
|
||||||
return;
|
return;
|
||||||
ahc->limit--;
|
ahc->limit--;
|
||||||
|
|
||||||
for (anchor = &ctx->hist; *anchor; anchor = &(*anchor)->next)
|
for (anchor = &ctx->hist; *anchor; anchor = &(*anchor)->next)
|
||||||
age++;
|
age++;
|
||||||
*anchor = alloc_type(struct gui_hist);
|
*anchor = alloc_type(struct gui_hist);
|
||||||
@ -1024,7 +1025,7 @@ ahc->limit--;
|
|||||||
|
|
||||||
|
|
||||||
static void get_revisions(struct gui_ctx *ctx,
|
static void get_revisions(struct gui_ctx *ctx,
|
||||||
int n_args, char **args, bool recurse)
|
int n_args, char **args, bool recurse, int limit)
|
||||||
{
|
{
|
||||||
const char *sch_name = args[n_args - 1];
|
const char *sch_name = args[n_args - 1];
|
||||||
struct add_hist_ctx add_hist_ctx = {
|
struct add_hist_ctx add_hist_ctx = {
|
||||||
@ -1032,7 +1033,7 @@ static void get_revisions(struct gui_ctx *ctx,
|
|||||||
.n_args = n_args,
|
.n_args = n_args,
|
||||||
.args = args,
|
.args = args,
|
||||||
.recurse = recurse,
|
.recurse = recurse,
|
||||||
.limit = 30,
|
.limit = limit < 0 ? -limit : limit,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!vcs_git_try(sch_name)) {
|
if (!vcs_git_try(sch_name)) {
|
||||||
@ -1045,7 +1046,7 @@ static void get_revisions(struct gui_ctx *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int gui(unsigned n_args, char **args, bool recurse)
|
int gui(unsigned n_args, char **args, bool recurse, int limit)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
struct gui_ctx ctx = {
|
struct gui_ctx ctx = {
|
||||||
@ -1060,7 +1061,7 @@ int gui(unsigned n_args, char **args, bool recurse)
|
|||||||
.old_hist = NULL,
|
.old_hist = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
get_revisions(&ctx, n_args, args, recurse);
|
get_revisions(&ctx, n_args, args, recurse, limit);
|
||||||
for (ctx.new_hist = ctx.hist; ctx.new_hist && !ctx.new_hist->sheets;
|
for (ctx.new_hist = ctx.hist; ctx.new_hist && !ctx.new_hist->sheets;
|
||||||
ctx.new_hist = ctx.new_hist->next);
|
ctx.new_hist = ctx.new_hist->next);
|
||||||
if (!ctx.new_hist) {
|
if (!ctx.new_hist) {
|
||||||
@ -1107,7 +1108,9 @@ int gui(unsigned n_args, char **args, bool recurse)
|
|||||||
go_to_sheet(&ctx, ctx.new_hist->sheets);
|
go_to_sheet(&ctx, ctx.new_hist->sheets);
|
||||||
gtk_widget_show_all(window);
|
gtk_widget_show_all(window);
|
||||||
|
|
||||||
gtk_main();
|
/* for performance testing, use -N-depth */
|
||||||
|
if (limit >= 0)
|
||||||
|
gtk_main();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,6 @@
|
|||||||
* and there is no NULL at the end.
|
* and there is no NULL at the end.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int gui(unsigned n_args, char **args, bool recurse);
|
int gui(unsigned n_args, char **args, bool recurse, int limit);
|
||||||
|
|
||||||
#endif /* !GUI_H */
|
#endif /* !GUI_H */
|
||||||
|
@ -47,17 +47,18 @@ static struct gfx_ops const *ops_list[] = {
|
|||||||
void usage(const char *name)
|
void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [gtk_flags] [-r] [[rev:]file.lib ...] [rev:]file.sch\n"
|
"usage: %s [gtk_flags] [-r] [-N n] [[rev:]file.lib ...] [rev:]file.sch\n"
|
||||||
" %s [-r] [-v ...] [[rev:]file.lib ...] [rev:]file.sch\n"
|
" %s [-r] [-v ...] [[rev:]file.lib ...] [rev:]file.sch\n"
|
||||||
" %*s[-- driver_spec]\n"
|
" %*s[-- driver_spec]\n"
|
||||||
" %s [-v ...] -C [rev:]file\n"
|
" %s [-v ...] -C [rev:]file\n"
|
||||||
" %s [-v ...] -H path_into_repo\n"
|
" %s [-v ...] -H path_into_repo\n"
|
||||||
"\n"
|
"\n"
|
||||||
" rev git revision\n"
|
" rev git revision\n"
|
||||||
" -r recurse into sub-sheets\n"
|
" -r recurse into sub-sheets\n"
|
||||||
" -v increase verbosity of diagnostic output\n"
|
" -v increase verbosity of diagnostic output\n"
|
||||||
" -C 'cat' the file to standard output\n"
|
" -C 'cat' the file to standard output\n"
|
||||||
" -H show history of repository on standard output\n"
|
" -H show history of repository on standard output\n"
|
||||||
|
" -N n limit history to n revisions\n"
|
||||||
"\n"
|
"\n"
|
||||||
"No driver spec: enter GUI\n"
|
"No driver spec: enter GUI\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -96,6 +97,7 @@ int main(int argc, char **argv)
|
|||||||
const char *cat = NULL;
|
const char *cat = NULL;
|
||||||
const char *history = NULL;
|
const char *history = NULL;
|
||||||
const char *fmt = NULL;
|
const char *fmt = NULL;
|
||||||
|
int limit = 0;
|
||||||
char c;
|
char c;
|
||||||
int arg, dashdash;
|
int arg, dashdash;
|
||||||
bool have_dashdash = 0;
|
bool have_dashdash = 0;
|
||||||
@ -112,7 +114,7 @@ int main(int argc, char **argv)
|
|||||||
if (!have_dashdash)
|
if (!have_dashdash)
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
while ((c = getopt(dashdash, argv, "rvC:F:H:")) != EOF)
|
while ((c = getopt(dashdash, argv, "rvC:F:H:N:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'r':
|
case 'r':
|
||||||
recurse = 1;
|
recurse = 1;
|
||||||
@ -129,6 +131,9 @@ int main(int argc, char **argv)
|
|||||||
case 'H':
|
case 'H':
|
||||||
history = optarg;
|
history = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'N':
|
||||||
|
limit = atoi(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
}
|
}
|
||||||
@ -173,7 +178,7 @@ int main(int argc, char **argv)
|
|||||||
memcpy(args, argv + optind, sizeof(const char *) * n);
|
memcpy(args, argv + optind, sizeof(const char *) * n);
|
||||||
|
|
||||||
optind = 0; /* reset getopt */
|
optind = 0; /* reset getopt */
|
||||||
return gui(n, args, recurse);
|
return gui(n, args, recurse, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
sch_init(&sch_ctx, recurse);
|
sch_init(&sch_ctx, recurse);
|
||||||
|
Loading…
Reference in New Issue
Block a user