mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-25 10:16:15 +02:00
add experimental reload feature
This is a first crude attempt at allowing reloading without exiting fped. This should be useful when writing a design as text and using the GUI only to visualize it. Reload is only enabled (in the File menu) if the file doesn't have the "MACHINE-GENERATED" header. Known bugs: - exits on parse errors - leaks memory badly - current frame is reset to root
This commit is contained in:
parent
7c037ae78a
commit
8982d09474
1
fpd.h
1
fpd.h
@ -26,6 +26,7 @@ extern struct value *var_value_list;
|
|||||||
int dbg_print(const struct expr *expr, const struct frame *frame);
|
int dbg_print(const struct expr *expr, const struct frame *frame);
|
||||||
|
|
||||||
void scan_empty(void);
|
void scan_empty(void);
|
||||||
|
void scan_file(void);
|
||||||
void scan_expr(const char *s);
|
void scan_expr(const char *s);
|
||||||
void scan_var(const char *s);
|
void scan_var(const char *s);
|
||||||
void scan_values(const char *s);
|
void scan_values(const char *s);
|
||||||
|
6
fpd.l
6
fpd.l
@ -35,6 +35,12 @@ void scan_empty(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void scan_file(void)
|
||||||
|
{
|
||||||
|
start_token = START_FPD;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void scan_expr(const char *s)
|
void scan_expr(const char *s)
|
||||||
{
|
{
|
||||||
start_token = START_EXPR;
|
start_token = START_EXPR;
|
||||||
|
15
fped.c
15
fped.c
@ -64,6 +64,21 @@ static void load_file(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void reload(void)
|
||||||
|
{
|
||||||
|
struct frame *old_frames;
|
||||||
|
|
||||||
|
/* @@@ this needs more work */
|
||||||
|
purge();
|
||||||
|
old_frames = frames;
|
||||||
|
scan_file();
|
||||||
|
load_file(save_file_name);
|
||||||
|
if (!instantiate())
|
||||||
|
frames = old_frames;
|
||||||
|
change_world();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
7
fped.h
7
fped.h
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* fped.h - Things fped.c exports
|
* fped.h - Things fped.c exports
|
||||||
*
|
*
|
||||||
* Written 2010 by Werner Almesberger
|
* Written 2010, 2012 by Werner Almesberger
|
||||||
* Copyright 2010 by Werner Almesberger
|
* Copyright 2010, 2012 by Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,4 +17,7 @@
|
|||||||
extern char *save_file_name;
|
extern char *save_file_name;
|
||||||
extern int no_save;
|
extern int no_save;
|
||||||
|
|
||||||
|
|
||||||
|
void reload(void);
|
||||||
|
|
||||||
#endif /* !FPED_H */
|
#endif /* !FPED_H */
|
||||||
|
5
gui.c
5
gui.c
@ -102,6 +102,8 @@ static GtkItemFactoryEntry menu_entries[] = {
|
|||||||
{ "/File/Write Postscript",
|
{ "/File/Write Postscript",
|
||||||
NULL, write_ps, 0, "<Item>" },
|
NULL, write_ps, 0, "<Item>" },
|
||||||
{ "/File/sep2", NULL, NULL, 0, "<Separator>" },
|
{ "/File/sep2", NULL, NULL, 0, "<Separator>" },
|
||||||
|
{ "/File/Reload", NULL, reload, 0, "<Item>" },
|
||||||
|
{ "/File/sep3", NULL, NULL, 0, "<Separator>" },
|
||||||
{ "/File/Quit", NULL, gtk_main_quit, 0, "<Item>" },
|
{ "/File/Quit", NULL, gtk_main_quit, 0, "<Item>" },
|
||||||
{ "/View", NULL, NULL, 0, "<Branch>" },
|
{ "/View", NULL, NULL, 0, "<Branch>" },
|
||||||
{ "/View/Zoom in", NULL, zoom_in_center, 0, "<Item>" },
|
{ "/View/Zoom in", NULL, zoom_in_center, 0, "<Item>" },
|
||||||
@ -127,6 +129,9 @@ static void make_menu_bar(GtkWidget *hbox)
|
|||||||
|
|
||||||
gtk_widget_set_sensitive(
|
gtk_widget_set_sensitive(
|
||||||
gtk_item_factory_get_item(factory, "/File/Save"), !no_save);
|
gtk_item_factory_get_item(factory, "/File/Save"), !no_save);
|
||||||
|
gtk_widget_set_sensitive(
|
||||||
|
gtk_item_factory_get_item(factory, "/File/Reload"),
|
||||||
|
no_save && !!save_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user