mirror of
git://projects.qi-hardware.com/fped.git
synced 2025-04-21 12:27:27 +03:00
Columns and loops can now be entered in one step as var = val, val, ...
- moved definition of expr_result from expr.c to fpd.y - new header file fpd.h with all the things fpd.l and fpd.y export - edit_var already calls edit_nothing, so there's no need to call it before - added rapid entry option for loops, variables, and columns: var = val, ... git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5459 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
73
gui_status.c
73
gui_status.c
@@ -15,6 +15,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
@@ -341,6 +342,78 @@ void edit_unique_null(const char **s,
|
||||
}
|
||||
|
||||
|
||||
/* ----- unique field (variable) optionally followed by values ------------- */
|
||||
|
||||
|
||||
struct edit_unique_with_values_ctx {
|
||||
const char **s;
|
||||
int (*validate)(const char *s, void *ctx);
|
||||
void *ctx;
|
||||
void (*set_values)(void *user, const struct value *values,
|
||||
int n_values);
|
||||
void *user;
|
||||
int max_values;
|
||||
};
|
||||
|
||||
|
||||
static enum edit_status unique_with_values_status(const char *s, void *ctx)
|
||||
{
|
||||
const struct edit_unique_with_values_ctx *unique_ctx = ctx;
|
||||
const char *id;
|
||||
int n;
|
||||
|
||||
if (!strcmp(s, *unique_ctx->s))
|
||||
return es_unchanged;
|
||||
status_begin_reporting();
|
||||
n = parse_var(s, &id, NULL, unique_ctx->max_values);
|
||||
if (n < 0)
|
||||
return es_bad;
|
||||
return !unique_ctx->validate ||
|
||||
unique_ctx->validate(id, unique_ctx->ctx) ? es_good : es_bad;
|
||||
}
|
||||
|
||||
|
||||
static void unique_with_values_store(const char *s, void *ctx)
|
||||
{
|
||||
const struct edit_unique_with_values_ctx *unique_ctx = ctx;
|
||||
struct value *values;
|
||||
int n;
|
||||
|
||||
status_begin_reporting();
|
||||
n = parse_var(s, unique_ctx->s, &values, unique_ctx->max_values);
|
||||
if (!n)
|
||||
return;
|
||||
assert(n >= 0);
|
||||
assert(unique_ctx->max_values == -1 || n <= unique_ctx->max_values);
|
||||
unique_ctx->set_values(unique_ctx->user, values, n);
|
||||
free_values(values, 1);
|
||||
}
|
||||
|
||||
|
||||
static struct edit_ops edit_ops_unique_with_values = {
|
||||
.retrieve = unique_retrieve,
|
||||
.status = unique_with_values_status,
|
||||
.store = unique_with_values_store,
|
||||
};
|
||||
|
||||
|
||||
void edit_unique_with_values(const char **s,
|
||||
int (*validate)(const char *s, void *ctx), void *ctx,
|
||||
void (*set_values)(void *user, const struct value *values, int n_values),
|
||||
void *user, int max_values)
|
||||
{
|
||||
static struct edit_unique_with_values_ctx unique_ctx;
|
||||
|
||||
unique_ctx.s = s;
|
||||
unique_ctx.validate = validate;
|
||||
unique_ctx.ctx = ctx;
|
||||
unique_ctx.set_values = set_values;
|
||||
unique_ctx.user = user;
|
||||
unique_ctx.max_values = max_values;
|
||||
setup_edit(status_entry, &edit_ops_unique_with_values, &unique_ctx);
|
||||
}
|
||||
|
||||
|
||||
/* ----- string fields ----------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user