Date:2012-08-21 06:59:46 (7 years 3 months ago)
Author:Werner Almesberger
Commit:8982d094747b5a0f09704b02d5e273123f4a827e
Message: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
Files: fpd.h (1 diff)
fpd.l (1 diff)
fped.c (1 diff)
fped.h (2 diffs)
gui.c (2 diffs)

Change Details

fpd.h
2626int dbg_print(const struct expr *expr, const struct frame *frame);
2727
2828void scan_empty(void);
29void scan_file(void);
2930void scan_expr(const char *s);
3031void scan_var(const char *s);
3132void scan_values(const char *s);
fpd.l
3535}
3636
3737
38void scan_file(void)
39{
40    start_token = START_FPD;
41}
42
43
3844void scan_expr(const char *s)
3945{
4046    start_token = START_EXPR;
fped.c
6464}
6565
6666
67void reload(void)
68{
69    struct frame *old_frames;
70
71    /* @@@ this needs more work */
72    purge();
73    old_frames = frames;
74    scan_file();
75    load_file(save_file_name);
76    if (!instantiate())
77        frames = old_frames;
78    change_world();
79}
80
81
6782static void usage(const char *name)
6883{
6984    fprintf(stderr,
fped.h
11/*
22 * fped.h - Things fped.c exports
33 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 by Werner Almesberger
4 * Written 2010, 2012 by Werner Almesberger
5 * Copyright 2010, 2012 by Werner Almesberger
66 *
77 * This program is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
...... 
1717extern char *save_file_name;
1818extern int no_save;
1919
20
21void reload(void);
22
2023#endif /* !FPED_H */
gui.c
102102        { "/File/Write Postscript",
103103                NULL, write_ps, 0, "<Item>" },
104104        { "/File/sep2", NULL, NULL, 0, "<Separator>" },
105        { "/File/Reload", NULL, reload, 0, "<Item>" },
106        { "/File/sep3", NULL, NULL, 0, "<Separator>" },
105107        { "/File/Quit", NULL, gtk_main_quit, 0, "<Item>" },
106108    { "/View", NULL, NULL, 0, "<Branch>" },
107109    { "/View/Zoom in", NULL, zoom_in_center, 0, "<Item>" },
...... 
127129
128130    gtk_widget_set_sensitive(
129131        gtk_item_factory_get_item(factory, "/File/Save"), !no_save);
132    gtk_widget_set_sensitive(
133        gtk_item_factory_get_item(factory, "/File/Reload"),
134        no_save && !!save_file_name);
130135}
131136
132137

Archive Download the corresponding diff file

Branches:
master



interactive