aboutsummaryrefslogtreecommitdiff
path: root/generic/Tabular.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Tabular.c')
-rw-r--r--generic/Tabular.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/generic/Tabular.c b/generic/Tabular.c
index 00bd019..8f179e0 100644
--- a/generic/Tabular.c
+++ b/generic/Tabular.c
@@ -33,6 +33,9 @@
#include "Geo.h"
#include "tkZinc.h"
+#include <ctype.h>
+#include <stdlib.h>
+
static const char rcsid[] = "$Id$";
static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " $";
@@ -495,6 +498,52 @@ Coords(Item item,
/*
**********************************************************************************
*
+ * Part --
+ * Convert a private part from/to symbolic representation.
+ *
+ **********************************************************************************
+ */
+static int
+Part(Item item,
+ Tcl_Obj **part_spec,
+ int *part)
+{
+ char *part_str;
+ char *end;
+
+ if (*part_spec) {
+ part_str = Tcl_GetString(*part_spec);
+ if (strlen(part_str) == 0) {
+ *part = ZN_NO_PART;
+ }
+ else if (isdigit(part_str[0])) {
+ *part = strtol(part_str, &end, 0);
+ if ((*end != 0) || (*part < 0) ||
+ (*part >= ((TabularItem) item)->field_set.num_fields)) {
+ goto part_error;
+ }
+ }
+ else {
+ part_error:
+ Tcl_AppendResult(item->wi->interp, " invalid item part specification", NULL);
+ return ZN_ERROR;
+ }
+ }
+ else {
+ if (*part >= 0) {
+ *part_spec = Tcl_NewIntObj(*part);
+ }
+ else {
+ *part_spec = NewStringObj("");
+ }
+ }
+ return ZN_OK;
+}
+
+
+/*
+ **********************************************************************************
+ *
* Exported functions structs --
*
**********************************************************************************
@@ -502,7 +551,7 @@ Coords(Item item,
static ItemClassStruct TABULAR_ITEM_CLASS = {
sizeof(TabularItemStruct),
True, /* has_fields */
- False, /* has_parts */
+ 0, /* num_parts */
True, /* has_anchors */
"tabular",
tabular_attrs,
@@ -519,6 +568,7 @@ static ItemClassStruct TABULAR_ITEM_CLASS = {
NULL, /* DeleteChars */
NULL, /* Cursor */
NULL, /* Index */
+ Part,
NULL, /* Selection */
NULL, /* Contour */
ComputeCoordinates,