Date:2015-01-09 04:57:36 (3 years 11 months ago)
Author:Werner Almesberger
Commit:73389fba76766394f0fa11c9e48f68b5913099af
Message:sanitize show var/code handling; switch to enum for future changes

Files: gui.c (3 diffs)
gui.html (1 diff)
gui_canvas.c (3 diffs)
gui_frame.c (3 diffs)
gui_frame.h (2 diffs)

Change Details

gui.c
11/*
22 * gui.c - Editor GUI core
33 *
4 * Written 2009-2012 by Werner Almesberger
5 * Copyright 2009-2012 by Werner Almesberger
4 * Written 2009-2012, 2015 by Werner Almesberger
5 * Copyright 2009-2012, 2015 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
...... 
8181/* ----- view callbacks ---------------------------------------------------- */
8282
8383
84static void swap_var_code(void)
84static void show_var(void)
8585{
86    extern int show_vars;
86    sidebar = sidebar_var;
87    change_world();
88}
8789
88    show_vars = !show_vars;
90
91static void show_code(void)
92{
93    sidebar = sidebar_code;
8994    change_world();
9095}
9196
...... 
111116    { "/View/Zoom all", NULL, zoom_to_extents,0, "<Item>" },
112117    { "/View/Zoom frame", NULL, zoom_to_frame, 0, "<Item>" },
113118    { "/View/sep1", NULL, NULL, 0, "<Separator>" },
114    { "/View/Swap var&code",NULL, swap_var_code, 0, "<Item>" },
119    { "/View/Show variables",
120                NULL, show_var, 0, "<RadioItem>" },
121    { "/View/Show code", NULL, show_code, 0,
122                        "/View/Show variables" },
115123};
116124
117125
gui.html
149149somewhere.
150150<P>
151151If the location of the error is not obvious, the list of objects can be
152shown by selecting "Swap var&amp;code" from the View menu. The object
152shown by selecting "Show code" from the View menu. The object
153153in which the error occurred is shown in red. If the error occurred in a
154154loop variable, the variable name is shown in red.
155155
gui_canvas.c
11/*
22 * gui_canvas.c - GUI, canvas
33 *
4 * Written 2009, 2010, 2012 by Werner Almesberger
5 * Copyright 2009, 2010, 2012 by Werner Almesberger
4 * Written 2009, 2010, 2012, 2015 by Werner Almesberger
5 * Copyright 2009, 2010, 2012, 2015 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
...... 
2525#include "gui_tool.h"
2626#include "gui.h"
2727#include "gui_frame_drag.h"
28#include "gui_frame.h"
2829#include "gui_canvas.h"
2930
3031
...... 
450451            change_world();
451452        break;
452453    case '/':
453{
454/* @@@ find a better place for this */
455extern int show_vars;
456        show_vars = !show_vars;
457change_world();
458}
454        sidebar = sidebar == sidebar_var ? sidebar_code : sidebar_var;
455        change_world();
456        break;
459457    }
460458    return TRUE;
461459}
gui_frame.c
11/*
22 * gui_frame.c - GUI, frame window
33 *
4 * Written 2009, 2010, 2012 by Werner Almesberger
5 * Copyright 2009, 2010, 2012 by Werner Almesberger
4 * Written 2009, 2010, 2012, 2015 by Werner Almesberger
5 * Copyright 2009, 2010, 2012, 2015 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
...... 
3131#include "gui_frame.h"
3232
3333
34int show_vars = 1;
34enum sidebar sidebar = sidebar_var;
3535
3636
3737/* ----- add elements, shared ---------------------------------------------- */
...... 
18511851        gtk_table_attach_defaults(GTK_TABLE(tab), refs,
18521852            1, 2, n*2+1, n*2+2);
18531853
1854        if (show_vars) {
1854        switch (sidebar) {
1855        case sidebar_var:
18551856            vars = build_vars(frame, wrap_width);
18561857            gtk_table_attach_defaults(GTK_TABLE(tab), vars,
18571858                1, 2, n*2+2, n*2+3);
18581859            dont_build_items(frame);
1859        } else {
1860            break;
1861        case sidebar_code:
18601862            items = build_items(frame);
18611863            gtk_table_attach_defaults(GTK_TABLE(tab), items,
18621864                1, 2, n*2+2, n*2+3);
1865            break;
1866        default:
1867            abort();
18631868        }
18641869
18651870        n++;
18661871    }
18671872
1868    if (!show_vars) {
1873    if (sidebar == sidebar_code) {
18691874        meas = build_meas(frames);
18701875        gtk_table_attach_defaults(GTK_TABLE(tab), meas,
18711876            1, 2, n*2+2, n*2+3);
gui_frame.h
11/*
22 * gui_frame.h - GUI, frame window
33 *
4 * Written 2009, 2010, 2012 by Werner Almesberger
5 * Copyright 2009, 2010, 2012 by Werner Almesberger
4 * Written 2009, 2010, 2012, 2015 by Werner Almesberger
5 * Copyright 2009, 2010, 2012, 2015 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
...... 
1919#include "obj.h"
2020
2121
22extern int show_vars;
22enum sidebar {
23    sidebar_var, /* show variables */
24    sidebar_code, /* show code */
25};
26
27
28extern enum sidebar sidebar;
2329
2430
2531void reselect_var(struct var *var);

Archive Download the corresponding diff file

Branches:
master



interactive