From 14af846df5c01a8d5e6edc35e2ba6fa2e3011b56 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Mon, 5 Jun 2000 12:03:13 +0000 Subject: Passage en Tcl_Objs et compilation conditionnelle de GPC --- generic/Text.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'generic/Text.c') diff --git a/generic/Text.c b/generic/Text.c index 61e5020..0b6ac69 100644 --- a/generic/Text.c +++ b/generic/Text.c @@ -45,6 +45,7 @@ #include "Draw.h" #include "Types.h" #include "WidgetInfo.h" +#include "tkZinc.h" static const char rcsid[] = "$Imagine: Text.c,v 1.13 1997/05/15 11:35:46 lecoanet Exp $"; @@ -164,9 +165,9 @@ static ZnAttrConfig text_attrs[] = { ********************************************************************************** */ static int -Init(Item item, - int *argc, - Arg **args) +Init(Item item, + int *argc, + Tcl_Obj *CONST *args[]) { WidgetInfo *wi = item->wi; TextItem text = (TextItem) item; @@ -281,7 +282,7 @@ Destroy(Item item) static int Configure(Item item, int argc, - ZnAttrList argv, + Tcl_Obj *CONST argv[], int *flags) { Item old_connected; @@ -319,7 +320,7 @@ Configure(Item item, static int Query(Item item, int argc, - ZnAttrList argv) + Tcl_Obj *CONST argv[]) { if (ITEM_P.QueryAttribute((char *) item, -1, argv[0]) == ZN_ERROR) { return ZN_ERROR; @@ -577,9 +578,9 @@ Draw(Item item) int font_height; int num_lines, i, line_index, char_index; TextLineInfo lines, lines_ptr; - int underline_thickness, underline_pos, overstrike_pos; - int sel_first_line = -1, sel_last_line = -1, cursor_line = -1; - int sel_start_offset, sel_stop_offset, cursor_offset; + int underline_thickness, underline_pos=0, overstrike_pos=0; + int sel_first_line=-1, sel_last_line=-1, cursor_line=-1; + int sel_start_offset=0, sel_stop_offset=0, cursor_offset=0; lines = (TextLineInfo) ZnListArray(text->text_info); num_lines = ZnListSize(text->text_info); @@ -981,7 +982,7 @@ PointToChar(Item item, static int Index(Item item, - char *index_str, + Tcl_Obj *index_spec, int *index) { TextItem text = (TextItem) item; @@ -991,16 +992,17 @@ Index(Item item, double tmp; char *end, *p; - c = index_str[0]; - length = strlen(index_str); + p = Tcl_GetString(index_spec); + c = p[0]; + length = strlen(p); - if ((c == 'e') && (strncmp(index_str, "end", length) == 0)) { + if ((c == 'e') && (strncmp(p, "end", length) == 0)) { *index = text->num_chars; } - else if ((c == 'i') && (strncmp(index_str, "insert", length) == 0)) { + else if ((c == 'i') && (strncmp(p, "insert", length) == 0)) { *index = text->insert_index; } - else if ((c == 's') && (strncmp(index_str, "sel.first", length) == 0) && + else if ((c == 's') && (strncmp(p, "sel.first", length) == 0) && (length >= 5)) { if (wi->text_info.sel_item != item) { Tcl_AppendResult(wi->interp, "selection isn't in item", (char *) NULL); @@ -1008,7 +1010,7 @@ Index(Item item, } *index = wi->text_info.sel_first; } - else if ((c == 's') && (strncmp(index_str, "sel.last", length) == 0) && + else if ((c == 's') && (strncmp(p, "sel.last", length) == 0) && (length >= 5)) { if (wi->text_info.sel_item != item) { Tcl_AppendResult(wi->interp, "selection isn't in item", (char *) NULL); @@ -1017,7 +1019,7 @@ Index(Item item, *index = wi->text_info.sel_last; } else if (c == '@') { - p = index_str+1; + p++; tmp = strtod(p, &end); if ((end == p) || (*end != ',')) { goto badIndex; @@ -1034,7 +1036,7 @@ Index(Item item, *index = PointToChar(item, x-wi->inset, y-wi->inset); } - else if (Tcl_GetInt(wi->interp, index_str, index) == TCL_OK) { + else if (Tcl_GetIntFromObj(wi->interp, index_spec, index) == TCL_OK) { if (*index < 0){ *index = 0; } @@ -1044,7 +1046,7 @@ Index(Item item, } else { badIndex: - Tcl_AppendResult(wi->interp, "bad index \"", index_str, "\"", (char *) NULL); + Tcl_AppendResult(wi->interp, "bad index \"", p, "\"", (char *) NULL); return TCL_ERROR; } -- cgit v1.1