📄 dot.c
字号:
#include "error.h"#include "linkedList.h"#include "mystdlib.h"#include "triple.h"#include "file.h"#include "str.h"#include "control.h"#include "dot.h"struct dot{ linkedList list;};dot newDot (){ dot d = checkedMalloc (sizeof (*d)); d->list = newLinkedList (); return d;}void dotInsert (str from, str to, str info, dot d){ str newInfo = newStr (""); if (info) { str s1 = newStr ("[label = \""); str s2 = newStr ("\"]"); str s3 = strConcat (s1, info); newInfo = strConcat (s3, s2); strFree (s1); strFree (s2); strFree (s3); } else; triple t = newTriple (from, to, newInfo); linkedListInsertHead (d->list, t); return;}str dotToString (dot d){ linkedList p = linkedListGetFirst (d->list); str s = newStr ("\n\n"); str temp1, temp2, temp3, temp4, temp5, temp6; str t; if (p); else return newStr (""); temp4 = newStr ("\""); temp5 = newStr ("->"); temp6 = newStr (";\n"); while (p) { triple tr = p->data; temp1 = tripleFirst (tr); temp2 = tripleSecond (tr); temp3 = tripleThird (tr); t = s; s = strConcat (s, temp4); strFree (t); t = s; s = strConcat (s, temp1); strFree (t); t = s; s = strConcat (s, temp4); strFree (t); t = s; s = strConcat (s, temp5); strFree (t); t = s; s = strConcat (s, temp4); strFree (t); t = s; s = strConcat (s, temp2); strFree (t); t = s; s = strConcat (s, temp4); strFree (t); t = s; s = strConcat (s, temp3); strFree (t); t = s; s = strConcat (s, temp6); strFree (t); p = p->next; } return s;}void dotToJpg (dot d, char *fname){ str strFname = newStr (fname); str dotFname = strConcat (strFname, newStr (".dot")); str jpgFname = strConcat (strFname, newStr (".jpg ")); char *dotFname2 = strToCharStar (dotFname); //printf (newFileName2); file fp = fileOpen (dotFname2, "w+"); str all = strConcat (newStr ("digraph g{\n"), newStr ("\tsize = \"10, 10\";\n")); all = strConcat (all, newStr ("\tnode [color=lightblue2, style=filled];\n")); str strDot = dotToString (d); all = strConcat (all, strDot); all = strConcat (all, newStr ("}\n\n")); filePuts (all, fp); fileClose (fp); str command = strConcat (newStr ("dot -Tjpg -o "), jpgFname); command = strConcat (command, dotFname); char *sss = strToCharStar (command); // strOutput2 ("now executing: \n");// strOutput2 (sss);// strOutput2 ("\n"); checkedSystem (sss); if (!controlKeepDot) { str s = strConcat (newStr ("del "), dotFname); checkedSystem (strToCharStar (s)); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -