*** attr.c.orig Mon Mar 22 17:20:51 1999 --- attr.c Mon Mar 22 17:20:51 1999 *************** *** 1860,1865 **** ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("OK", BUTTON_OK); ! NamesAddButton("CANCEL", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(BUTTON_OK, INVALID); --- 1860,1865 ---- ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("Ok", BUTTON_OK); ! NamesAddButton("Cancel", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(BUTTON_OK, INVALID); *** choose.c.orig Mon Mar 22 17:20:54 1999 --- choose.c Mon Mar 22 17:20:54 1999 *************** *** 340,343 **** --- 340,345 ---- } + #include "xbm/check.xbm" + static void DrawCheckbox(dpy, win, gc, x, y, w, h, checked) *************** *** 347,354 **** int x, y, w, h, checked; { ! XDrawRectangle(dpy, win, gc, x, y, w, h); if (checked) { ! XDrawLine(dpy, win, gc, x, y, x+w, y+h); ! XDrawLine(dpy, win, gc, x, y+h, x+w, y); } } --- 349,382 ---- int x, y, w, h, checked; { ! if (threeDLook) { ! struct BBRec bbox; ! ! SetBBRec(&bbox, x, y, x+w+1, y+h+1); ! TgDrawThreeDButton(dpy, win, textMenuGC, &bbox, TGBS_LOWRED, 2, FALSE); ! } else { ! XDrawRectangle(dpy, win, gc, x, y, w, h); ! } if (checked) { ! if (threeDLook) { ! XGCValues values; ! ! values.fill_style = FillStippled; ! values.stipple = checkBitmap; ! values.ts_x_origin = x+2; ! values.ts_y_origin = y+2; ! XChangeGC(dpy, gc, ! GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, ! &values); ! XFillRectangle(dpy, win, gc, values.ts_x_origin, ! values.ts_y_origin, check_width, check_height); ! values.fill_style = FillSolid; ! values.ts_x_origin = 0; ! values.ts_y_origin = 0; ! XChangeGC(dpy, gc, ! GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin, &values); ! } else { ! XDrawLine(dpy, win, gc, x, y, x+w, y+h); ! XDrawLine(dpy, win, gc, x, y+h, x+w, y); ! } } } *************** *** 507,515 **** /* draw a frame around the window */ if (threeDLook) { ! struct BBRec bbox; ! SetBBRec(&bbox, 0, 0, pni->base_win_w, pni->base_win_h); ! TgDrawThreeDButton(mainDisplay, pni->base_win, textMenuGC, &bbox, ! TGBS_RAISED, 2, FALSE); } else { XDrawRectangle(mainDisplay, pni->base_win, nameGC, 0, 0, --- 535,545 ---- /* draw a frame around the window */ if (threeDLook) { ! if (dialogboxUse3DBorder) { ! struct BBRec bbox; ! SetBBRec(&bbox, 0, 0, pni->base_win_w, pni->base_win_h); ! TgDrawThreeDButton(mainDisplay, pni->base_win, textMenuGC, &bbox, ! TGBS_RAISED, 2, FALSE); ! } } else { XDrawRectangle(mainDisplay, pni->base_win, nameGC, 0, 0, *** cutpaste.c.orig Mon Mar 22 17:20:56 1999 --- cutpaste.c Mon Mar 22 17:20:56 1999 *************** *** 2165,2170 **** switch (nWhich) { case COPY_PROP: ! NamesAddButton("COPY", COPY_BUTTON); ! NamesAddButton("CANCEL", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(COPY_BUTTON, INVALID); --- 2165,2170 ---- switch (nWhich) { case COPY_PROP: ! NamesAddButton("Copy", COPY_BUTTON); ! NamesAddButton("Cancel", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(COPY_BUTTON, INVALID); *************** *** 2177,2182 **** break; case SAVE_PROP: ! NamesAddButton("SAVE", SAVE_BUTTON); ! NamesAddButton("CANCEL", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(SAVE_BUTTON, INVALID); --- 2177,2182 ---- break; case SAVE_PROP: ! NamesAddButton("Save", SAVE_BUTTON); ! NamesAddButton("Cancel", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(SAVE_BUTTON, INVALID); *************** *** 2189,2194 **** break; case PASTE_PROP: ! NamesAddButton("PASTE", PASTE_BUTTON); ! NamesAddButton("CANCEL", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(PASTE_BUTTON, INVALID); --- 2189,2194 ---- break; case PASTE_PROP: ! NamesAddButton("Paste", PASTE_BUTTON); ! NamesAddButton("Cancel", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(PASTE_BUTTON, INVALID); *************** *** 2201,2206 **** break; case RESTORE_PROP: ! NamesAddButton("RESTORE", RESTORE_BUTTON); ! NamesAddButton("CANCEL", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(RESTORE_BUTTON, INVALID); --- 2201,2206 ---- break; case RESTORE_PROP: ! NamesAddButton("Restore", RESTORE_BUTTON); ! NamesAddButton("Cancel", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(RESTORE_BUTTON, INVALID); *************** *** 2500,2505 **** NamesSetTitle(pszTitle); ! NamesAddButton("OK", BUTTON_OK); ! NamesAddButton("CANCEL", BUTTON_CANCEL); NamesSetDefaultBtnId(BUTTON_OK, BUTTON_OK); NamesSetEntries(NULL, NULL, 0, NULL, TRUE, INVALID, 0); --- 2500,2505 ---- NamesSetTitle(pszTitle); ! NamesAddButton("Ok", BUTTON_OK); ! NamesAddButton("Cancel", BUTTON_CANCEL); NamesSetDefaultBtnId(BUTTON_OK, BUTTON_OK); NamesSetEntries(NULL, NULL, 0, NULL, TRUE, INVALID, 0); *************** *** 2645,2650 **** ResetNamesInfo(); NamesSetTitle(psz_title); ! NamesAddButton("OK", BUTTON_OK); ! NamesAddButton("CANCEL", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(BUTTON_OK, INVALID); --- 2645,2650 ---- ResetNamesInfo(); NamesSetTitle(psz_title); ! NamesAddButton("Ok", BUTTON_OK); ! NamesAddButton("Cancel", BUTTON_CANCEL); /* ignore double-click and */ NamesSetDefaultBtnId(BUTTON_OK, INVALID); *** dialog.c.orig Mon Mar 22 17:20:59 1999 --- dialog.c Mon Mar 22 17:20:59 1999 *************** *** 60,63 **** --- 60,65 ---- char gszMsgBox[2048]; + int dialogboxUse3DBorder=TRUE; + unsigned int CornerLoop(OrigX, OrigY) int *OrigX, *OrigY; *************** *** 229,233 **** static char extraBtnChar='q'; static char *btnStr[] = { ! "INVALID", "OK", "CANCEL", "YES", "NO", "Extra", NULL }; --- 231,235 ---- static char extraBtnChar='q'; static char *btnStr[] = { ! "INVALID", "Ok", "Cancel", "Yes", "No", "Extra", NULL }; *************** *** 1154,1158 **** while (XCheckWindowEvent(mainDisplay,MBInfoPtr->btn_win,ExposureMask,&ev)) ; ! if (threeDLook) { struct BBRec bbox; --- 1156,1160 ---- while (XCheckWindowEvent(mainDisplay,MBInfoPtr->btn_win,ExposureMask,&ev)) ; ! if (threeDLook && dialogboxUse3DBorder) { struct BBRec bbox; *** exec.c.orig Mon Mar 22 17:21:02 1999 --- exec.c Mon Mar 22 17:21:02 1999 *************** *** 86,89 **** --- 86,93 ---- #include "xprtfltr.e" + #ifdef _TANGRAM_II + #include "tangram2.e" + #endif /* _TANGRAM_II */ + int execAnimating=FALSE; int execAnimateRedraw=FALSE; *************** *** 123,154 **** static int gnAbortExec=FALSE; - typedef int (ExecFunc)ARGS_DECL((char **argv, struct ObjRec *obj_ptr, - char *orig_cmd)); - typedef int (RawExecFunc)ARGS_DECL((char **argv, char **raw_argv, - struct ObjRec *obj_ptr, char *orig_cmd)); - typedef void (SimpleExecFunc)ARGS_DECL((struct ObjRec *obj_ptr, - char *orig_cmd)); - - typedef struct ExecInfoRec { - NLFN *pfunc; - char *func_name; - int func_argc; - /* - * if (func_argc == 0) { - * pfunc is (SimpleExecFunc)(); - * } else if (func_argc < 0) { - * pfunc is (RawExecFunc)(); - * } else { - * pfunc is (ExecFunc)(); - * } - */ - int double_quotes_for_null; - /* - * If TRUE, then if $(foo) evaluates to the empty string, "" is - * passed. This is mainly used by commands with expression - * evaluations. - */ - } * ExecInfoPtr; - int ExecLaunch ARGS_DECL((char**, struct ObjRec *, char*)); int ExecExec ARGS_DECL((char**, struct ObjRec *, char*)); --- 127,130 ---- *************** *** 269,275 **** int ExecSetXpmOutputVersion ARGS_DECL((char**, struct ObjRec *, char*)); int ExecEditIniSection ARGS_DECL((char**, struct ObjRec *, char*)); static ! struct ExecInfoRec gExecInfo[] = { { (NLFN*)ExecLaunch, "launch", 1, 0}, { (NLFN*)ExecExec, "exec", 1, 0}, --- 245,254 ---- int ExecSetXpmOutputVersion ARGS_DECL((char**, struct ObjRec *, char*)); int ExecEditIniSection ARGS_DECL((char**, struct ObjRec *, char*)); + int ExecAppendLineIntoAttr ARGS_DECL((char**, struct ObjRec *, char*)); + int ExecInsertLineIntoAttr ARGS_DECL((char**, struct ObjRec *, char*)); + int ExecClearAttr ARGS_DECL((char**, struct ObjRec *, char*)); static ! ExecInfo gExecInfo[] = { { (NLFN*)ExecLaunch, "launch", 1, 0}, { (NLFN*)ExecExec, "exec", 1, 0}, *************** *** 390,393 **** --- 369,375 ---- { (NLFN*)ExecSetXpmOutputVersion, "set_xpm_output_version", 1, 0}, { (NLFN*)ExecEditIniSection, "edit_ini_section", 4, 0}, + { (NLFN*)ExecAppendLineIntoAttr, "append_line_into_attr", 2, 0}, + { (NLFN*)ExecInsertLineIntoAttr, "insert_line_into_attr", 3, 0}, + { (NLFN*)ExecClearAttr, "clear_attr", 1, 0}, { NULL, NULL, 0, 0 } }; *************** *** 729,734 **** while (*inbuf != '\0') { struct AttrRec *attr_ptr; ! int null_string=FALSE, n; char *c_ptr=inbuf, *new_c_ptr=NULL, *cp, *cp1; while (new_c_ptr == NULL) { --- 711,718 ---- while (*inbuf != '\0') { struct AttrRec *attr_ptr; ! int null_string=FALSE, n, need_to_free_tmp_buf=FALSE; char *c_ptr=inbuf, *new_c_ptr=NULL, *cp, *cp1; + char *tmp_buf=NULL, *attr_value=NULL; + MiniLineInfo *pMiniLine=NULL; while (new_c_ptr == NULL) { *************** *** 793,797 **** return NULL; } ! count = attr_ptr->attr_value.sz-1; if (count == 0 && double_quotes_for_null && !inside_quote) { null_string = TRUE; --- 777,789 ---- return NULL; } ! pMiniLine = attr_ptr->obj->detail.t->minilines.first; ! tmp_buf = ConvertMiniLineToString(pMiniLine, &need_to_free_tmp_buf); ! attr_value = UtilStrDup(tmp_buf); ! if (attr_value == NULL) FailAllocMessage(); ! ParseAttrStr(tmp_buf, NULL, 0, attr_value, strlen(attr_value)+1); ! if (need_to_free_tmp_buf) UtilFree(tmp_buf); ! need_to_free_tmp_buf = TRUE; ! ! count = strlen(attr_value); if (count == 0 && double_quotes_for_null && !inside_quote) { null_string = TRUE; *************** *** 808,813 **** return_ptr[2] = '\0'; } else { ! strcpy(return_ptr, attr_ptr->attr_value.s); } if ((cp=strstr(return_ptr, "//")) != NULL) { *cp = '\0'; --- 800,807 ---- return_ptr[2] = '\0'; } else { ! strcpy(return_ptr, attr_value); } + UtilFree(attr_value); + if ((cp=strstr(return_ptr, "//")) != NULL) { *cp = '\0'; *************** *** 1210,1214 **** } ! void ReplaceAttrFirstValue(obj_ptr, attr_ptr, new_value) struct ObjRec *obj_ptr; struct AttrRec *attr_ptr; --- 1204,1208 ---- } ! int ReplaceAttrFirstValue(obj_ptr, attr_ptr, new_value) struct ObjRec *obj_ptr; struct AttrRec *attr_ptr; *************** *** 1242,1246 **** MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); gnAbortExec = TRUE; ! return; } if (topSel == NULL || topSel != botSel || topSel->obj != obj_ptr) { --- 1236,1240 ---- MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); gnAbortExec = TRUE; ! return FALSE; } if (topSel == NULL || topSel != botSel || topSel->obj != obj_ptr) { *************** *** 1296,1302 **** SetFileModified(TRUE); } } ! void ReplaceAttrAllValues(obj_ptr, attr_ptr, ppTopStr, ppBotStr) struct ObjRec *obj_ptr; struct AttrRec *attr_ptr; --- 1290,1297 ---- SetFileModified(TRUE); } + return (!same); } ! int ReplaceAttrAllValues(obj_ptr, attr_ptr, ppTopStr, ppBotStr) struct ObjRec *obj_ptr; struct AttrRec *attr_ptr; *************** *** 1346,1350 **** MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); gnAbortExec = TRUE; ! return; } if (topSel == NULL || topSel != botSel || topSel->obj != obj_ptr) { --- 1341,1345 ---- MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); gnAbortExec = TRUE; ! return FALSE; } if (topSel == NULL || topSel != botSel || topSel->obj != obj_ptr) { *************** *** 1395,1398 **** --- 1390,1394 ---- SetFileModified(TRUE); } + return need_to_change; } *************** *** 2202,2208 **** } ! /* RedrawAnArea (botObj, obj_ptr->bbox.ltx-GRID_ABS_SIZE(1), ! obj_ptr->bbox.lty-GRID_ABS_SIZE(1), obj_ptr->bbox.rbx+GRID_ABS_SIZE(1), ! obj_ptr->bbox.rby+GRID_ABS_SIZE(1)); */ cur_obj = obj_ptr->detail.r->first; --- 2198,2204 ---- } ! /* RedrawAnArea(botObj, obj_ptr->bbox.ltx-GRID_ABS_SIZE(1), ! obj_ptr->bbox.lty-GRID_ABS_SIZE(1), obj_ptr->bbox.rbx+GRID_ABS_SIZE(1), ! obj_ptr->bbox.rby+GRID_ABS_SIZE(1)); */ cur_obj = obj_ptr->detail.r->first; *************** *** 6900,6903 **** --- 6896,7084 ---- } + int ExecAppendLineIntoAttr(argv, obj_ptr, orig_cmd) + char **argv, *orig_cmd; + struct ObjRec *obj_ptr; + /* append_line_into_attr(attr_name,str); */ + { + char *attr_name=argv[0], *the_str=argv[1]; + MiniLineInfo *pFirstMiniLine=NULL, *pLastMiniLine=NULL; + struct AttrRec *attr_ptr=NULL; + struct ObjRec *attr_owner_obj=NULL; + struct TextRec *text_ptr=NULL; + + UtilRemoveQuotes(attr_name); + UtilRemoveQuotes(the_str); + + sprintf(execDummyStr, "%s=", attr_name); + attr_ptr = FindAttrWithName(obj_ptr, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) return BadAttr(execDummyStr, orig_cmd); + + PrepareToReplaceAnObj(attr_owner_obj); + + text_ptr = attr_ptr->obj->detail.t; + CreateMiniLineFromString(the_str, &pFirstMiniLine, &pLastMiniLine); + text_ptr->minilines.last->next = pFirstMiniLine; + pFirstMiniLine->prev = text_ptr->minilines.last; + text_ptr->minilines.last = pLastMiniLine; + text_ptr->lines++; + RecalcTextMetrics(text_ptr, attr_ptr->obj->x, text_ptr->baseline_y); + UpdTextBBox(attr_ptr->obj); + AdjObjBBox(attr_owner_obj); + + RecordReplaceAnObj(attr_owner_obj); + RedrawAnArea(botObj, attr_ptr->obj->bbox.ltx-GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.lty-GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.rbx+GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.rby+GRID_ABS_SIZE(1)); + + SetFileModified(TRUE); + return TRUE; + } + + int ExecInsertLineIntoAttr(argv, obj_ptr, orig_cmd) + char **argv, *orig_cmd; + struct ObjRec *obj_ptr; + /* insert_line_into_attr(attr_name,str,line_number); */ + { + char *attr_name=argv[0], *the_str=argv[1]; + char *line_number_str=argv[2]; + int count=0, line_number=(-1), ltx=0, lty=0, rbx=0, rby=0, found=FALSE; + MiniLineInfo *pMiniLine=NULL, *pFirstMiniLine=NULL, *pLastMiniLine=NULL; + struct AttrRec *attr_ptr=NULL; + struct ObjRec *attr_owner_obj=NULL; + struct TextRec *text_ptr=NULL; + + UtilRemoveQuotes(attr_name); + UtilRemoveQuotes(the_str); + UtilRemoveQuotes(line_number_str); + + sprintf(execDummyStr, "%s=", attr_name); + attr_ptr = FindAttrWithName(obj_ptr, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) return BadAttr(execDummyStr, orig_cmd); + + if (!IntExpression(line_number_str, &line_number, orig_cmd)) { + return FALSE; + } + if (line_number <= 0) { + if (line_number == 0) { + sprintf(gszMsgBox, "%s '%s' %s.", + "0 is not a valid line number for the", orig_cmd, "command"); + } else { + sprintf(gszMsgBox, "%s '%d' (too small) %s '%s' %s.", + "Invalid line number", line_number, + "specified while executing the", orig_cmd, "command"); + } + MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); + return FALSE; + } + ltx = attr_ptr->obj->bbox.ltx; lty = attr_ptr->obj->bbox.lty; + rbx = attr_ptr->obj->bbox.rbx; rby = attr_ptr->obj->bbox.rby; + PrepareToReplaceAnObj(attr_owner_obj); + + text_ptr = attr_ptr->obj->detail.t; + + count = 0; + for (pMiniLine=attr_ptr->obj->detail.t->minilines.first; + pMiniLine != NULL; pMiniLine=pMiniLine->next, count++) { + if (count == line_number) { + CreateMiniLineFromString(the_str, &pFirstMiniLine, &pLastMiniLine); + pMiniLine->prev->next = pFirstMiniLine; + pFirstMiniLine->prev = pMiniLine->prev; + pFirstMiniLine->next = pMiniLine; + pMiniLine->prev = pFirstMiniLine; + text_ptr->lines++; + found = TRUE; + break; + } + } + while (!found) { + if (count++ == line_number) { + CreateMiniLineFromString(the_str, &pFirstMiniLine, &pLastMiniLine); + text_ptr->minilines.last->next = pFirstMiniLine; + pFirstMiniLine->prev = text_ptr->minilines.last; + text_ptr->minilines.last = pLastMiniLine; + found = TRUE; + } else { + CreateMiniLineFromString("", &pFirstMiniLine, &pLastMiniLine); + text_ptr->minilines.last->next = pFirstMiniLine; + pFirstMiniLine->prev = text_ptr->minilines.last; + text_ptr->minilines.last = pLastMiniLine; + pFirstMiniLine = pLastMiniLine = NULL; + } + text_ptr->lines++; + } + RecalcTextMetrics(text_ptr, attr_ptr->obj->x, text_ptr->baseline_y); + UpdTextBBox(attr_ptr->obj); + AdjObjBBox(attr_owner_obj); + + RecordReplaceAnObj(attr_owner_obj); + RedrawAreas(botObj, ltx-GRID_ABS_SIZE(1), lty-GRID_ABS_SIZE(1), + rbx+GRID_ABS_SIZE(1), rby+GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.ltx-GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.lty-GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.rbx+GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.rby+GRID_ABS_SIZE(1)); + + SetFileModified(TRUE); + return TRUE; + } + + int ExecClearAttr(argv, obj_ptr, orig_cmd) + char **argv, *orig_cmd; + struct ObjRec *obj_ptr; + /* clear_attr(attr_name); */ + { + char *attr_name=argv[0]; + struct AttrRec *attr_ptr=NULL; + struct ObjRec *attr_owner_obj=NULL; + struct TextRec *text_ptr=NULL; + int changed=FALSE, ltx=0, lty=0, rbx=0, rby=0; + + UtilRemoveQuotes(attr_name); + + sprintf(execDummyStr, "%s=", attr_name); + attr_ptr = FindAttrWithName(obj_ptr, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) return BadAttr(execDummyStr, orig_cmd); + + ltx = attr_ptr->obj->bbox.ltx; lty = attr_ptr->obj->bbox.lty; + rbx = attr_ptr->obj->bbox.rbx; rby = attr_ptr->obj->bbox.rby; + + StartCompositeCmd(); + + text_ptr = attr_ptr->obj->detail.t; + if (text_ptr->minilines.first->next != NULL) { + MiniLinesInfo *minilines=(&text_ptr->minilines); + MiniLineInfo *pMiniLine=NULL, *pNextMiniLine=NULL; + + PrepareToReplaceAnObj(attr_owner_obj); + for (pMiniLine=text_ptr->minilines.first->next; pMiniLine != NULL; + pMiniLine=pNextMiniLine) { + pNextMiniLine = pMiniLine->next; + UnlinkMiniLine(pMiniLine); + FreeMiniLine(pMiniLine); + } + RecordReplaceAnObj(attr_owner_obj); + changed = TRUE; + } + replaceAttrFirstValueRedraw = FALSE; + if (ReplaceAttrFirstValue(attr_owner_obj, attr_ptr, "")) { + changed = TRUE; + } + replaceAttrFirstValueRedraw = TRUE; + + if (changed) { + RedrawAreas(botObj, ltx-GRID_ABS_SIZE(1), lty-GRID_ABS_SIZE(1), + rbx+GRID_ABS_SIZE(1), rby+GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.ltx-GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.lty-GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.rbx+GRID_ABS_SIZE(1), + attr_ptr->obj->bbox.rby+GRID_ABS_SIZE(1)); + SetFileModified(TRUE); + } + EndCompositeCmd(); + + return TRUE; + } + /* --------------------- End of Exec Routines --------------------- */ *************** *** 6962,6966 **** struct ObjRec * obj_ptr; { ! struct ExecInfoRec *pei; int i, tok_type, rc=TRUE, func_argc=0, need_raw_argv=FALSE; char buf[MAXSTRING<<2], **argv=NULL, **raw_argv=NULL; --- 7143,7147 ---- struct ObjRec * obj_ptr; { ! ExecInfo *pei=NULL; int i, tok_type, rc=TRUE, func_argc=0, need_raw_argv=FALSE; char buf[MAXSTRING<<2], **argv=NULL, **raw_argv=NULL; *************** *** 6974,6978 **** --- 7155,7164 ---- } } + #ifdef _TANGRAM_II if (pei->pfunc == NULL) { + pei = Tangram2GetExecInfo(buf); + } + #endif /* _TANGRAM_II */ + if (pei == NULL || pei->pfunc == NULL) { int len=strlen(buf); *** file.c.orig Mon Mar 22 17:21:09 1999 --- file.c Mon Mar 22 17:21:10 1999 *************** *** 788,792 **** writeFileFailed = TRUE; } ! if (BotObjPtr != NULL && !copyInDrawTextMode) { if (fprintf(FP, "%%\n") == EOF) { writeFileFailed = TRUE; --- 788,792 ---- writeFileFailed = TRUE; } ! if ((BotObjPtr != NULL || tgifObj != NULL) && !copyInDrawTextMode) { if (fprintf(FP, "%%\n") == EOF) { writeFileFailed = TRUE; *** font.c.orig Mon Mar 22 17:21:15 1999 --- font.c Mon Mar 22 17:21:15 1999 *************** *** 518,523 **** static ! struct FontSizeRec *FindFontInfo(font_index, style_index, sz_unit) ! int font_index, style_index, sz_unit; { struct FontSizeRec *fs_ptr, *prev_fs=NULL, *new_fs_ptr; --- 518,523 ---- static ! struct FontSizeRec *FindFontInfo(font_index, style_index, sz_unit, must_find) ! int font_index, style_index, sz_unit, must_find; { struct FontSizeRec *fs_ptr, *prev_fs=NULL, *new_fs_ptr; *************** *** 543,546 **** --- 543,548 ---- if (xfs == NULL) { + if (must_find) return NULL; + canvasFontIsFaked = TRUE; xfs = fontFamilies[font_index].fr[style_index].xfs; *************** *** 1598,1602 **** int vert=FALSE, rc=TRUE; ! fs_ptr = FindFontInfo(curFont, curStyle, curSzUnit); if (allowFontFaceSubstitution && fs_ptr == NULL) { --- 1600,1604 ---- int vert=FALSE, rc=TRUE; ! fs_ptr = FindFontInfo(curFont, curStyle, curSzUnit, FALSE); if (allowFontFaceSubstitution && fs_ptr == NULL) { *************** *** 1605,1609 **** #endif /* _TGIF_DBG */ fs_ptr = FindFontInfo(defaultCurFont, defaultCurStyle, ! defaultCurSzUnit); } if (!allowFontFaceSubstitution && fs_ptr == NULL) { --- 1607,1611 ---- #endif /* _TGIF_DBG */ fs_ptr = FindFontInfo(defaultCurFont, defaultCurStyle, ! defaultCurSzUnit, FALSE); } if (!allowFontFaceSubstitution && fs_ptr == NULL) { *************** *** 2326,2330 **** } if (defaultFontPtr == NULL) { ! fs_ptr = FindFontInfo(curFont, curStyle, curSzUnit); if (fs_ptr == NULL) { sprintf(gszMsgBox, "Cannot open the Default(Msg)Font '%s'! Abort!", --- 2328,2332 ---- } if (defaultFontPtr == NULL) { ! fs_ptr = FindFontInfo(curFont, curStyle, curSzUnit, TRUE); if (fs_ptr == NULL) { sprintf(gszMsgBox, "Cannot open the Default(Msg)Font '%s'! Abort!", *************** *** 2370,2374 **** if (rulerFontPtr == NULL) { fs_ptr = FindFontInfo(curFont, curStyle, ! FontSizeToSzUnit(ruler_font_size)); if (fs_ptr == NULL) { sprintf(gszMsgBox, "Cannot open the RulerFont '%s'! Abort!", --- 2372,2376 ---- if (rulerFontPtr == NULL) { fs_ptr = FindFontInfo(curFont, curStyle, ! FontSizeToSzUnit(ruler_font_size), TRUE); if (fs_ptr == NULL) { sprintf(gszMsgBox, "Cannot open the RulerFont '%s'! Abort!", *************** *** 2766,2770 **** return TRUE; } ! if (FindFontInfo(font, style, sz_unit) != NULL) { switch (which) { case PUSH_STYLE: pStrSeg->style = style; break; --- 2768,2772 ---- return TRUE; } ! if (FindFontInfo(font, style, sz_unit, TRUE) != NULL) { switch (which) { case PUSH_STYLE: pStrSeg->style = style; break; *** import.c.orig Mon Mar 22 17:21:18 1999 --- import.c Mon Mar 22 17:21:18 1999 *************** *** 890,895 **** ResetNamesInfo(); NamesSetTitle(top_str); ! NamesAddButton("OK", BUTTON_OK); ! NamesAddButton("CANCEL", BUTTON_CANCEL); NamesSetEntries(NULL, entries, num_entries, NULL, TRUE, INVALID, 0); NamesSetStyle(NAMES_COMPLEX_SELECT_NAME, NAMES_LOOP_ONCE); --- 890,895 ---- ResetNamesInfo(); NamesSetTitle(top_str); ! NamesAddButton("Ok", BUTTON_OK); ! NamesAddButton("Cancel", BUTTON_CANCEL); NamesSetEntries(NULL, entries, num_entries, NULL, TRUE, INVALID, 0); NamesSetStyle(NAMES_COMPLEX_SELECT_NAME, NAMES_LOOP_ONCE); *** mainloop.c.orig Mon Mar 22 17:21:20 1999 --- mainloop.c Mon Mar 22 17:21:20 1999 *************** *** 641,648 **** tmp_remote_fname) != FALSE) { unlink(tmp_remote_fname); if (remote_buf != NULL) FreeRemoteBuf(remote_buf); - if (tmp_remote_fname != NULL) { - FreeRemoteBuf(tmp_remote_fname); - } remote_buf = tmp_remote_fname = NULL; file_is_remote = FALSE; --- 641,646 ---- tmp_remote_fname) != FALSE) { unlink(tmp_remote_fname); + FreeRemoteBuf(tmp_remote_fname); if (remote_buf != NULL) FreeRemoteBuf(remote_buf); remote_buf = tmp_remote_fname = NULL; file_is_remote = FALSE; *************** *** 670,675 **** unlink(tmp_remote_fname); - FreeRemoteBuf(remote_buf); FreeRemoteBuf(tmp_remote_fname); remote_buf = tmp_remote_fname = NULL; file_is_remote = FALSE; --- 668,673 ---- unlink(tmp_remote_fname); FreeRemoteBuf(tmp_remote_fname); + FreeRemoteBuf(remote_buf); remote_buf = tmp_remote_fname = NULL; file_is_remote = FALSE; *************** *** 818,823 **** if (file_is_remote) { unlink(tmp_remote_fname); - if (remote_buf != NULL) FreeRemoteBuf(remote_buf); if (tmp_remote_fname != NULL) FreeRemoteBuf(tmp_remote_fname); remote_buf = tmp_remote_fname = NULL; CommitNavigate(); --- 816,821 ---- if (file_is_remote) { unlink(tmp_remote_fname); if (tmp_remote_fname != NULL) FreeRemoteBuf(tmp_remote_fname); + if (remote_buf != NULL) FreeRemoteBuf(remote_buf); remote_buf = tmp_remote_fname = NULL; CommitNavigate(); *** menu.c.orig Mon Mar 22 17:21:22 1999 --- menu.c Mon Mar 22 17:21:22 1999 *************** *** 101,104 **** --- 101,105 ---- static struct BBRec excludeMenubarWinBBox; + static int excludeMenubarIndex=INVALID; static int gnNumMenubarItems=0; *************** *** 2278,2281 **** --- 2279,2318 ---- } + static + void HighLightMenubarString(item_str, bbox, highlight) + char *item_str; + struct BBRec *bbox; + int highlight; + { + if (threeDLook) { + struct BBRec real_bbox; + + real_bbox.ltx = bbox->ltx-2; + real_bbox.lty = bbox->lty; + real_bbox.rbx = bbox->rbx+2; + real_bbox.rby = bbox->rby+1; + if (highlight) { + TgDrawThreeDButton(mainDisplay, menubarWindow, textMenuGC, &real_bbox, + TGBS_RAISED, 1, FALSE); + } else { + TgClearThreeDButton(mainDisplay, menubarWindow, textMenuGC, &real_bbox, + 1); + } + } else { + int fg_pixel=(highlight ? myBgPixel : myFgPixel); + int bg_pixel=(highlight ? myFgPixel : + (threeDLook?myLtGryPixel:myBgPixel)); + + XSetForeground(mainDisplay, textMenuGC, bg_pixel); + XFillRectangle(mainDisplay, menubarWindow, textMenuGC, + bbox->ltx-2, bbox->lty, bbox->rbx-bbox->ltx+4, bbox->rby-bbox->lty); + XSetForeground(mainDisplay, textMenuGC, fg_pixel); + XDrawString(mainDisplay, menubarWindow, textMenuGC, + bbox->ltx+(menuFontPtr==NULL ? 0 : (menuFontWidth>>1)), + (menuFontPtr==NULL ? defaultFontAsc : menuFontAsc)+bbox->lty, + item_str, strlen(item_str)); + } + } + void RedrawMenubarWindow() { *************** *** 2332,2370 **** TGBS_RAISED, 1, FALSE); } ! } ! static ! void HighLightMenubarString(item_str, bbox, highlight) ! char *item_str; ! struct BBRec *bbox; ! int highlight; ! { ! if (threeDLook) { ! struct BBRec real_bbox; ! ! real_bbox.ltx = bbox->ltx-2; ! real_bbox.lty = bbox->lty; ! real_bbox.rbx = bbox->rbx+2; ! real_bbox.rby = bbox->rby+1; ! if (highlight) { ! TgDrawThreeDButton(mainDisplay, menubarWindow, textMenuGC, &real_bbox, ! TGBS_RAISED, 1, FALSE); ! } else { ! TgClearThreeDButton(mainDisplay, menubarWindow, textMenuGC, &real_bbox, ! 1); ! } ! } else { ! int fg_pixel=(highlight ? myBgPixel : myFgPixel); ! int bg_pixel=(highlight ? myFgPixel : ! (threeDLook?myLtGryPixel:myBgPixel)); ! ! XSetForeground(mainDisplay, textMenuGC, bg_pixel); ! XFillRectangle(mainDisplay, menubarWindow, textMenuGC, ! bbox->ltx-2, bbox->lty, bbox->rbx-bbox->ltx+4, bbox->rby-bbox->lty); ! XSetForeground(mainDisplay, textMenuGC, fg_pixel); ! XDrawString(mainDisplay, menubarWindow, textMenuGC, ! bbox->ltx+(menuFontPtr==NULL ? 0 : (menuFontWidth>>1)), ! (menuFontPtr==NULL ? defaultFontAsc : menuFontAsc)+bbox->lty, ! item_str, strlen(item_str)); } } --- 2369,2384 ---- TGBS_RAISED, 1, FALSE); } ! if (excludeMenubarIndex != INVALID) { ! struct BBRec text_bbox; ! int exclude_gap=(menuFontPtr==NULL ? (defaultFontWidth<<1) : ! (menuFontWidth<<1)); ! SetBBRec(&text_bbox, ! excludeMenubarWinBBox.ltx+2+windowPadding, ! excludeMenubarWinBBox.lty+2+windowPadding, ! excludeMenubarWinBBox.rbx-2-windowPadding-exclude_gap, ! excludeMenubarWinBBox.rby-2-windowPadding); ! HighLightMenubarString(gpMenubarItemInfos[excludeMenubarIndex].menu_str, ! &text_bbox, TRUE); } } *************** *** 2387,2390 **** --- 2401,2405 ---- excludeMenubarWinBBox.rbx = text_bbox->rbx+exclude_gap+2+windowPadding; excludeMenubarWinBBox.rby = text_bbox->rby+2+windowPadding; + excludeMenubarIndex = index; } switch (gpMenubarItemInfos[index].cmdid) { *************** *** 2511,2514 **** --- 2526,2530 ---- SetMouseStatus(NULL, NULL, NULL); SetBBRec(&excludeMenubarWinBBox, -1, -1, -1, -1); + excludeMenubarIndex = INVALID; } if (threeDLook) { *** names.c.orig Mon Mar 22 17:21:26 1999 --- names.c Mon Mar 22 17:21:26 1999 *************** *** 819,825 **** ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("OK", BUTTON_OK); ! NamesAddButton("SETDIR", BUTTON_SETDIR); ! NamesAddButton("CANCEL", BUTTON_CANCEL); NamesSetEntries(NULL, NULL, 0, NULL, TRUE, INVALID, 0); NamesSetStyle(NAMES_SELECT_FILE, NAMES_LOOP_MANY); --- 819,825 ---- ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("Ok", BUTTON_OK); ! NamesAddButton("SetDir", BUTTON_SETDIR); ! NamesAddButton("Cancel", BUTTON_CANCEL); NamesSetEntries(NULL, NULL, 0, NULL, TRUE, INVALID, 0); NamesSetStyle(NAMES_SELECT_FILE, NAMES_LOOP_MANY); *************** *** 878,883 **** ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("OK", BUTTON_OK); ! NamesAddButton("CANCEL", BUTTON_CANCEL); NamesSetEntries(NULL, entries, num_entries, NULL, TRUE, marked_index, 0); NamesSetStyle(NAMES_COMPLEX_SELECT_NAME, NAMES_LOOP_ONCE); --- 878,883 ---- ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("Ok", BUTTON_OK); ! NamesAddButton("Cancel", BUTTON_CANCEL); NamesSetEntries(NULL, entries, num_entries, NULL, TRUE, marked_index, 0); NamesSetStyle(NAMES_COMPLEX_SELECT_NAME, NAMES_LOOP_ONCE); *** page.c.orig Mon Mar 22 17:21:27 1999 --- page.c Mon Mar 22 17:21:28 1999 *************** *** 540,545 **** ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("OK", BUTTON_OK); ! NamesAddButton("CANCEL", BUTTON_CANCEL); NamesSetEntries(NULL, entries, num_entries, NULL, TRUE, marked_index, leadingChars); --- 540,545 ---- ResetNamesInfo(); NamesSetTitle(TopStr); ! NamesAddButton("Ok", BUTTON_OK); ! NamesAddButton("Cancel", BUTTON_CANCEL); NamesSetEntries(NULL, entries, num_entries, NULL, TRUE, marked_index, leadingChars); *** remote.c.orig Mon Mar 22 17:21:30 1999 --- remote.c Mon Mar 22 17:21:30 1999 *************** *** 545,550 **** int buf_sz; { ! char *tmp_fname; ! int fd; tmp_fname = (char*)malloc((strlen(TMP_DIR)+20)*sizeof(char)); --- 545,550 ---- int buf_sz; { ! char *tmp_fname=NULL; ! int fd=(-1); tmp_fname = (char*)malloc((strlen(TMP_DIR)+20)*sizeof(char)); *************** *** 1955,1958 **** --- 1955,1959 ---- { char *viewer=NULL; + int rc=FALSE; int url_is_html=UrlIsHtml(psz_url); *************** *** 1959,1965 **** if (url_is_html || !is_html) { if (UseViewer(psz_url, psz_content_type, tmp_fname) != FALSE) { ! unlink(tmp_fname); ! free(tmp_fname); ! return TRUE; } } else if (is_html && (viewer=GetViewer("html")) != NULL) { --- 1960,1964 ---- if (url_is_html || !is_html) { if (UseViewer(psz_url, psz_content_type, tmp_fname) != FALSE) { ! rc = TRUE; } } else if (is_html && (viewer=GetViewer("html")) != NULL) { *************** *** 1971,1976 **** INVALID) { free(viewer); - unlink(tmp_fname); - free(tmp_fname); return INVALID; } --- 1970,1973 ---- *************** *** 1985,2004 **** FailAllocMessage(); free(viewer); ! unlink(tmp_fname); ! free(tmp_fname); ! return INVALID; } - LaunchViewer(launch_remote_file, viewer, cmd, psz_url, new_file_name); - free(viewer); - free(cmd); - unlink(tmp_fname); - free(tmp_fname); - return TRUE; } else if (UseMimeViewer(psz_url, psz_content_type, tmp_fname) != FALSE) { ! unlink(tmp_fname); ! free(tmp_fname); ! return TRUE; } ! return FALSE; } --- 1982,1996 ---- FailAllocMessage(); free(viewer); ! rc = INVALID; ! } else { ! LaunchViewer(launch_remote_file, viewer, cmd, psz_url, new_file_name); ! free(viewer); ! free(cmd); ! rc = TRUE; } } else if (UseMimeViewer(psz_url, psz_content_type, tmp_fname) != FALSE) { ! rc = TRUE; } ! return rc; } *** setup.c.orig Mon Mar 22 17:21:32 1999 --- setup.c Mon Mar 22 17:21:32 1999 *************** *** 1345,1348 **** --- 1345,1353 ---- threeDLook = FALSE; } + dialogboxUse3DBorder = threeDLook; + if (threeDLook && (c_ptr=XGetDefault(mainDisplay, TOOL_NAME, + "DialogboxUse3DBorder")) != NULL && UtilStrICmp(c_ptr, "false") == 0) { + dialogboxUse3DBorder = FALSE; + } if (threeDLook) { windowPadding = WINDOW_PADDING; *** stream.c.orig Mon Mar 22 17:21:34 1999 --- stream.c Mon Mar 22 17:21:34 1999 *************** *** 63,66 **** --- 63,146 ---- static struct ObjRec *gpVideoObj=NULL; + static char **gaszFilterForContentType=NULL; + static int gnMaxStreamFilters=0; + + static + void CleanUpFilter() + { + if (gaszFilterForContentType != NULL) { + int i=0; + + for (i=0; i < gnMaxStreamFilters; i++) { + UtilFree(gaszFilterForContentType[i]); + UtilFree(gaszFilterForContentType[++i]); + } + free(gaszFilterForContentType); + } + gaszFilterForContentType = NULL; + gnMaxStreamFilters = 0; + } + + static + void InitFilter() + { + char *c_ptr=NULL; + int max_filters=0; + + if ((c_ptr=XGetDefault(mainDisplay,TOOL_NAME,"MaxStreamFilters")) != NULL) { + max_filters = atoi(c_ptr); + if (max_filters <= 0) { + sprintf(gszMsgBox, "Invalid %s*%s: '%s'.\n\nValue must be > 0.", + TOOL_NAME, "MaxStreamFilters", c_ptr); + MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); + } + } + gnMaxStreamFilters = 0; + if (max_filters > 0) { + int i=0; + + gaszFilterForContentType = + (char**)malloc(((max_filters<<1)+1)*sizeof(char*)); + if (gaszFilterForContentType == NULL) FailAllocMessage(); + memset(gaszFilterForContentType, 0, ((max_filters<<1)+1)*sizeof(char*)); + for (i=0; i < max_filters; i++) { + char buf[80]; + + sprintf(buf, "StreamFilter%1d", i); + if ((c_ptr=XGetDefault(mainDisplay,TOOL_NAME,buf)) == NULL) { + sprintf(gszMsgBox, "Cannot find %s*%s.", TOOL_NAME, buf); + MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); + max_filters = i; + break; + } else { + char *psz=strchr(c_ptr, ':'); + int index=(i<<1); + + if (psz == NULL) { + sprintf(gszMsgBox, "Invalid %s*%s: '%s'.", TOOL_NAME, buf, + c_ptr); + MsgBox(gszMsgBox, TOOL_NAME, INFO_MB); + max_filters = i; + break; + } + *psz++ = '\0'; + gaszFilterForContentType[index] = UtilStrDup(c_ptr); + gaszFilterForContentType[index+1] = UtilStrDup(psz); + if (gaszFilterForContentType[index] == NULL || + gaszFilterForContentType[index+1] == NULL) { + FailAllocMessage(); + } + UtilTrimBlanks(gaszFilterForContentType[index]); + UtilTrimBlanks(gaszFilterForContentType[index+1]); + } + } + if (max_filters == 0) { + free(gaszFilterForContentType); + gaszFilterForContentType = NULL; + } + } + gnMaxStreamFilters = max_filters; + } + void CleanUpMime() { *************** *** 75,78 **** --- 155,159 ---- } gpVideoObj = NULL; + CleanUpFilter(); } *************** *** 84,87 **** --- 165,169 ---- gpszBoundary = NULL; gpVideoObj = NULL; + InitFilter(); } *************** *** 179,183 **** if (psz_copy == NULL) FailAllocMessage(); UtilTrimBlanks(psz_copy); ! for (ppsz=gppszValidImageContentType; *ppsz != NULL; ppsz++) { if (UtilStrICmp(*ppsz, psz_copy) == 0) { if (ppsz_filter != NULL) *ppsz_filter = ppsz[1]; --- 261,267 ---- if (psz_copy == NULL) FailAllocMessage(); UtilTrimBlanks(psz_copy); ! ppsz = (gaszFilterForContentType==NULL ? gppszValidImageContentType: ! gaszFilterForContentType); ! for ( ; *ppsz != NULL; ppsz++) { if (UtilStrICmp(*ppsz, psz_copy) == 0) { if (ppsz_filter != NULL) *ppsz_filter = ppsz[1]; *************** *** 431,438 **** UtilTrimBlanks(pici->sz_content_type); if (!ValidImageContentType(&colon_ptr[1], &pici->psz_filter)) { - #ifdef _TGIF_DBG fprintf(stderr, "%s Content-Type: %s\n", "Does not know how to handle frame", &colon_ptr[1]); - #endif /* _TGIF_DBG */ } if (psz != NULL) *psz++ = ';'; --- 515,520 ---- *************** *** 476,479 **** --- 558,562 ---- } unlink(tmp_fname); + free(tmp_fname); /* now we need to shrink the buffer */ left_over = *pn_buf_len - *** tangram2.c.orig Mon Mar 22 17:21:36 1999 --- tangram2.c Mon Mar 22 17:21:36 1999 *************** *** 37,42 **** --- 37,45 ---- #include "dialog.e" + #include "exec.e" #include "menu.e" #include "msg.e" + #include "obj.e" + #include "select.e" #include "tangram2.e" #include "util.e" *************** *** 175,178 **** --- 178,525 ---- } + /* ======================= Tangram2 Internal Commands ======================= */ + + void ExecStartSimulator ARGS_DECL((struct ObjRec *, char*)); + void ExecSimulateStep ARGS_DECL((struct ObjRec *, char*)); + void ExecEndSimulator ARGS_DECL((struct ObjRec *, char*)); + + static + ExecInfo gTangram2ExecInfo[] = { + { (NLFN*)ExecStartSimulator, "start_simulator", 0, 0}, + { (NLFN*)ExecSimulateStep, "simulate_step", 0, 0}, + { (NLFN*)ExecEndSimulator, "end_simulator", 0, 0}, + { NULL, NULL, 0, 0 } + }; + + ExecInfo *Tangram2GetExecInfo(func_name) + char *func_name; + { + ExecInfo *pei=NULL; + + for (pei=gTangram2ExecInfo; pei->pfunc != NULL; pei++) { + if (strcmp(pei->func_name, func_name) == 0) { + return pei; + } + } + return NULL; + } + + /* --------------- Tangram2 Internal Commands Implementation --------------- */ + + #define MAXVARS 20 + #define MAXVARNAME 250 + #define MAXCONNECTTRIES 10 + #define PORT 6743 + + #define END_OF_SIMULATION 1 + #define STEP_SIMULATION 2 + + #define D printf ("Msg de Debug!\n"); + + typedef struct tagT_statevar { + char name[MAXVARNAME]; + int value; + } T_statevar; + + typedef struct tagT_Packet { + int code; + int step; + double elapsed_time; + int varcount; + T_statevar vars[MAXVARS]; + } T_Packet; + + static int simulator_socket=INVALID; + + static + int BadAttr_Simulator(attr_name, cmd_name) + char *attr_name, *cmd_name; + { + char msg[MAXSTRING+1]; + + sprintf(msg, "Can not find the '%s' %s '%s' command.", + attr_name, "attribute while executing the", cmd_name); + MsgBox(msg, TOOL_NAME, INFO_MB); + return FALSE; + } + + void ExecStartSimulator(obj_ptr, orig_cmd) + char *orig_cmd; + struct ObjRec *obj_ptr; + /* start_simulator(); */ + { + char servidor[80]; + struct sockaddr_in endereco; + struct hostent *hptr; + int i; + + memset((char*)(&endereco), 0, sizeof(endereco)); + + /* get the local host information - use localhost (127.0.0.1) */ + /* gethostname(servidor, 80); */ + strcpy(servidor, "localhost"); + if ((hptr=gethostbyname(servidor)) != NULL) { + memcpy((char*)&endereco.sin_addr, hptr->h_addr, hptr->h_length); + } else { + perror("gethostbyname"); + return; + } + + endereco.sin_family = AF_INET; + endereco.sin_port = htons((u_short)PORT); + + if ((simulator_socket=socket(AF_INET, SOCK_STREAM, 0)) < 0) { + perror("socket creation"); + return; + } + + /* connect to server. Try for MAXCONNECTTRIES times */ + i = 0; + while (i < MAXCONNECTTRIES) + if ((connect(simulator_socket, (struct sockaddr *)(&endereco), + sizeof(endereco))) < 0) { + perror("connect"); + printf("Still trying... (%d)\n",MAXCONNECTTRIES-i); + close(simulator_socket); + if ((simulator_socket=socket(AF_INET, SOCK_STREAM, 0)) < 0) { + perror("socket creation"); + return; + } + sleep(3); + i++; + } else { + break; + } + if (i == MAXCONNECTTRIES) { + perror("connect"); + printf("Bailing out... after %d tries\n", MAXCONNECTTRIES); + return; + } + + printf("Cliente Conectado.\n"); + } + + void ExecEndSimulator(obj_ptr, orig_cmd) + char *orig_cmd; + struct ObjRec *obj_ptr; + /* end_simulator(); */ + { + T_Packet pack_out; + int bywrite; + + if (simulator_socket == INVALID) { + perror("invalid simulator_socket"); + return; + } + /* monta o pacote */ + memset((char *)&pack_out, 0, sizeof(T_Packet)); + pack_out.code = END_OF_SIMULATION; + + /* envia o pacote ao simulador */ + bywrite = write(simulator_socket, &pack_out, sizeof(T_Packet)); + if (bywrite < 0) { + perror("write"); + return; + } + close(simulator_socket); + printf("TGIF: Simulation finished.\n"); + } + + static + int monta_buffer(char *buffer, T_Packet pack) + { + int i; + char temp[MAXSTRING+1]; + + memset(buffer, 0, sizeof(buffer)); + for (i=0; i < pack.varcount; i++) { + strcat(buffer, pack.vars[i].name); + sprintf(temp, "=%d@", pack.vars[i].value); + strcat(buffer, temp); + } + + /* printf("monta: %s\n", buffer); */ + } + + static + int recv_packet(int soc, T_Packet *pack_in) + { + int byread, status; /* bytes read from the socket */ + char buffer[sizeof(T_Packet)]; + + /* clear and receive the packet */ + memset(buffer, 0, sizeof(T_Packet)); + byread = read(soc, buffer, sizeof(T_Packet)); + if (byread > 0) { + while (byread < sizeof(T_Packet)) { + status = read(soc, &(buffer[byread]), sizeof(T_Packet) - byread); + if (status > 0) { + byread += status; + } else { + byread = status; + break; + } + } + } + memcpy((char*)pack_in, buffer, sizeof(T_Packet)); + + if (byread <= 0) { + perror("read"); + return(-1); + } else { + return(1); + } + } + + static + int send_packet(int soc, T_Packet pack_out) + { + int bywrite, status; + char buffer[sizeof(T_Packet)]; + + memcpy(buffer, (char*)&pack_out, sizeof(T_Packet)); + bywrite = write(soc, buffer, sizeof(T_Packet)); + if (bywrite > 0) { + while (bywrite < sizeof(T_Packet)) { + status = write(soc, &(buffer[bywrite]), sizeof(T_Packet) - bywrite); + if (status > 0) { + bywrite += status; + } else { + bywrite = status; + break; + } + } + } + if (bywrite <= 0) { + perror("write"); + return(-1); + } else { + return(1); + } + } + + + static + int desmonta_buffer(char *buffer, T_Packet *pack) + { + int i; + char *token; + + /* printf("desmonta: %s\n", buffer); */ + + i = 0; + token = strtok(buffer, "="); + strcpy(pack->vars[i].name, token); + while (token != NULL) { + token = strtok(NULL, "@"); + pack->vars[i].value = atoi(token); + i++; + token = strtok(NULL, "="); + if (token == NULL) { + break; + } + strcpy(pack->vars[i].name, token); + } + + pack->varcount = i; + } + + void ExecSimulateStep(obj_ptr, orig_cmd) + char *orig_cmd; + struct ObjRec *obj_ptr; + /* simulate_step(); */ + { + char buffer[MAXVARS*sizeof(T_statevar)]; + + struct AttrRec *attr_ptr; + struct ObjRec *attr_owner_obj=NULL; + static char execDummyStr[MAXSTRING+1]; + + struct ObjRec *owner_obj=NULL, *named_obj; + static char obj_name[MAXSTRING+1]; + + T_Packet pack_in, pack_out; + + static int transitions = 0; + static double tempo = 0; + int step = 1; + + int i; + + if (simulator_socket == INVALID) { + perror("invalid simulator_socket"); + return; + } + /* pega o valor do atributo buffer */ + strcpy(execDummyStr, "buffer="); + attr_ptr = FindAttrWithName(obj_ptr, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) {BadAttr_Simulator(execDummyStr, orig_cmd); return; } + strcpy(buffer, attr_ptr->attr_value.s); + + /* pega o valor do atributo step */ + strcpy(execDummyStr, "Step="); + attr_ptr = FindAttrWithName(obj_ptr, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) { BadAttr_Simulator(execDummyStr, orig_cmd); return; } + step = atoi(attr_ptr->attr_value.s); + + /* + * step nao pode ser menor do que zero (se for zero entao esta com play_mode) + */ + if (step <= 0) { + step = 1; + } + /* monta o pacote */ + memset((char *)&pack_out, 0, sizeof(T_Packet)); + pack_out.code = STEP_SIMULATION; + pack_out.step = step; + desmonta_buffer(buffer, &pack_out); + + /* envia o pacote ao simulador */ + if (send_packet(simulator_socket, pack_out) < 0) { + return; + } + /* recebe pacote de resposta do simulador */ + if (recv_packet(simulator_socket, &pack_in) < 0) { + return; + } + /* desmonta o pacote */ + tempo = pack_in.elapsed_time; + transitions = step; + monta_buffer(buffer, pack_in); + + /* seta o valor do atributo buffer */ + strcpy(execDummyStr, "buffer="); + attr_ptr = FindAttrWithName(obj_ptr, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) { BadAttr_Simulator(execDummyStr, orig_cmd); return; } + ReplaceAttrFirstValue(attr_owner_obj, attr_ptr, buffer); + + /* set o valor do step_time (tempo de duracao deste step) */ + strcpy(execDummyStr, "step_time="); + attr_ptr = FindAttrWithName(obj_ptr, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) { BadAttr_Simulator(execDummyStr, orig_cmd); return; } + sprintf(execDummyStr, "%.3f", tempo); + ReplaceAttrFirstValue(attr_owner_obj, attr_ptr, execDummyStr); + + /* atualiza o valor do atributo Time do objeto "__START_SIMULATOR__" */ + strcpy(obj_name, "__START_SIMULATOR__"); + named_obj = FindObjWithName(botObj, obj_ptr, obj_name, FALSE, FALSE, + &owner_obj, NULL); + + strcpy(execDummyStr, "Time="); + attr_ptr = FindAttrWithName(named_obj, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) { BadAttr_Simulator(execDummyStr, orig_cmd); return; } + tempo += atof(attr_ptr->attr_value.s); + sprintf(execDummyStr, "%.3f", tempo); + ReplaceAttrFirstValue(attr_owner_obj, attr_ptr, execDummyStr); + + /* atualiza o valor do atributo Transitions do mesmo objeto */ + strcpy(execDummyStr, "Transitions="); + attr_ptr = FindAttrWithName(named_obj, execDummyStr, &attr_owner_obj); + if (attr_ptr == NULL) { BadAttr_Simulator(execDummyStr, orig_cmd); return; } + transitions += atof(attr_ptr->attr_value.s); + sprintf(execDummyStr, "%d", transitions); + ReplaceAttrFirstValue(attr_owner_obj, attr_ptr, execDummyStr); + } + /* ======================= Tangram2 Menu ======================= */ *** dialog.e.orig Mon Mar 22 17:21:37 1999 --- dialog.e Mon Mar 22 17:21:37 1999 *************** *** 38,41 **** --- 38,43 ---- extern char gszMsgBox[2048]; + extern int dialogboxUse3DBorder; + #ifdef _INCLUDE_FROM_DIALOG_C_ #undef extern *** exec.e.orig Mon Mar 22 17:21:38 1999 --- exec.e Mon Mar 22 17:21:38 1999 *************** *** 66,72 **** extern int DoLaunch ARGS_DECL((struct AttrRec *, struct ObjRec *)); ! extern void ReplaceAttrFirstValue ARGS_DECL((struct ObjRec *, struct AttrRec *, char *)); ! extern void ReplaceAttrAllValues ARGS_DECL((struct ObjRec *, struct AttrRec *, struct StrRec **ppTopStr, --- 66,72 ---- extern int DoLaunch ARGS_DECL((struct AttrRec *, struct ObjRec *)); ! extern int ReplaceAttrFirstValue ARGS_DECL((struct ObjRec *, struct AttrRec *, char *)); ! extern int ReplaceAttrAllValues ARGS_DECL((struct ObjRec *, struct AttrRec *, struct StrRec **ppTopStr, *** tangram2.e.orig Mon Mar 22 17:21:39 1999 --- tangram2.e Mon Mar 22 17:21:39 1999 *************** *** 70,73 **** --- 70,77 ---- extern int DoTangram2ShortCut ARGS_DECL((int index, char *args)); + /* ======================= Tangram2 Internal Commands ======================= */ + + extern ExecInfo *Tangram2GetExecInfo ARGS_DECL((char *func_name)); + /* ======================= Tangram2 Menu ======================= */ *** patchlvl.h.orig Mon Mar 22 17:21:40 1999 --- patchlvl.h Mon Mar 22 17:21:40 1999 *************** *** 35,39 **** #define _TGIF_PATCHLEVEL_H_ ! #define TGIF_PATCHLEVEL 2 #endif /*_TGIF_PATCHLEVEL_H_*/ --- 35,39 ---- #define _TGIF_PATCHLEVEL_H_ ! #define TGIF_PATCHLEVEL 3 #endif /*_TGIF_PATCHLEVEL_H_*/ *** types.h.orig Mon Mar 22 17:21:41 1999 --- types.h Mon Mar 22 17:21:41 1999 *************** *** 747,749 **** --- 747,779 ---- } ScrollBtnCallbackInfo; + /* ------------------ exec stuff ------------------ */ + + typedef int (ExecFunc)ARGS_DECL((char **argv, struct ObjRec *obj_ptr, + char *orig_cmd)); + typedef int (RawExecFunc)ARGS_DECL((char **argv, char **raw_argv, + struct ObjRec *obj_ptr, char *orig_cmd)); + typedef void (SimpleExecFunc)ARGS_DECL((struct ObjRec *obj_ptr, + char *orig_cmd)); + + typedef struct tagExecInfoRec { + NLFN *pfunc; + char *func_name; + int func_argc; + /* + * if (func_argc == 0) { + * pfunc is (SimpleExecFunc)(); + * } else if (func_argc < 0) { + * pfunc is (RawExecFunc)(); + * } else { + * pfunc is (ExecFunc)(); + * } + */ + int double_quotes_for_null; + /* + * If TRUE, then if $(foo) evaluates to the empty string, "" is + * passed. This is mainly used by commands with expression + * evaluations. + */ + } ExecInfo; + #endif /*_TGIF_TYPES_H_*/ *** Imakefile.orig Mon Mar 22 17:21:42 1999 --- Imakefile Mon Mar 22 17:21:42 1999 *************** *** 53,57 **** $(MOREDEFINES) ! TGIFVERSION = 4.1.2 XCOMM Things to try to add to the DEFINES line above: --- 53,57 ---- $(MOREDEFINES) ! TGIFVERSION = 4.1.3 XCOMM Things to try to add to the DEFINES line above: *** tgif.man.orig Mon Mar 22 17:21:44 1999 --- tgif.man Mon Mar 22 17:21:44 1999 *************** *** 9,13 **** .\" .\" ! .TH tgif n "Version 4.1 Patchlevel 2 and Above" "Tgif" .\" .SH NAME --- 9,13 ---- .\" .\" ! .TH tgif n "Version 4.1 Patchlevel 3 and Above" "Tgif" .\" .SH NAME *************** *** 2047,2050 **** --- 2047,2067 ---- CANCEL button in the dialogbox, the file is unmodified, and "CANCEL" is placed in the attribute specified by . + .TP + .I append_line_into_attr(,) + This command appends the line specified by to the attribute + specified by . + .TP + .I insert_line_into_attr(,,) + This command inserts the line specified by as the + \fIn\fRth line of the attribute specified by , where + \fIn\fR is a zero-based index specified by . + \fIn\fR must be at least 1. + If \fIn\fR is larger the number of lines in the attribute, blank + lines are automatically inserted. + .TP + .I clear_attr() + This command clears the attribute value of the attribute + specified by and deletes all other lines of the attribute + if the attribute contains multiple lines. .\" .SH ARITHMETIC EXPRESSIONS *************** *** 3955,3958 **** --- 3972,3979 ---- The default is "ps2pdf %s". .TP + .I Tgif.3DLook: [true,false] + If set to ``false'', no 3D decoration of windows and buttons will be used. + The default is true. + .TP .I Tgif.XpmDeckToGifAnim: STRING The STRING specifies a command used to convert a list of GIF file to a *************** *** 4062,4065 **** --- 4083,4092 ---- will be obtained from the actual image pixels for a TrueColor visual. The default is false. + .TP + .I Tgif.DialogboxUse3DBorder: [true,false] + If set to ``false'', dialogboxes will not have 3D borders. This should + be used with X servers such as X-Win32 because dialogboxes already have + 3D borders. + The default is true. .\" .SH ENVIRONMENT VARIABLE *** HISTORY.orig Mon Mar 22 17:21:49 1999 --- HISTORY Mon Mar 22 17:21:49 1999 *************** *** 1,2 **** --- 1,13 ---- + -----------------------> tgif-4.1.2 => tgif-4.1.3 <----------------------- + Here's a short list of added features/bug fixes. + + 1) Fix a bug with opening files in a non-existent directory. Thanks to + Andreas Scherbaum for pointing out the problem. + 2) Add the following internal commands: + + append_line_into_attr(,) + insert_line_into_attr(,,) + clear_attr() + -----------------------> tgif-4.1.1 => tgif-4.1.2 <----------------------- Here's a short list of added features/bug fixes. *** tgif.Xdefaults.orig Mon Mar 22 17:21:50 1999 --- tgif.Xdefaults Mon Mar 22 17:21:50 1999 *************** *** 325,328 **** --- 325,329 ---- Tgif.PdfFileExtension: pdf Tgif.PsToPdf: ps2pdf %s + Tgif.3DLook: true Tgif.XpmDeckToGifAnim: gifsicle -lforever --delay 10 !Tgif.XpmDeckToGifAnim: whirlgif -loop -time 10 *************** *** 399,400 **** --- 400,402 ---- !Tgif.DefaultObjectBackground: white Tgif.UseImagePixelsForTrueColorExport: false + Tgif.DialogboxUse3DBorder: true