static BOOL GetFragments(CCFUNCDATA *funcs, int funcpos, int curarg, char **fragments) { char buf[2048], *last= funcs->fullname,*p; int n = GetFuncCount(funcs); int i, nesting = 0; for (i=0; i < funcpos && funcs; i++) funcs = funcs->next; if (!funcs) return FALSE; p = funcs->fullname; while (*p) { switch(*p) { case '@': if (!nesting) last = p; break; case '#': nesting++; break; case '~': if (nesting) nesting--; break; } p++; } if (last != p) { while (*last && *last != '$') last ++; * last = 0; } sprintf(buf, "%d of %d", funcpos+1, n); fragments[0] = strdup(buf); unmangle(buf, funcs->fullname); if (last != p) *last = '$'; strcat(buf, "("); for (i=0; i < curarg && i < funcs->args->argCount; i++) { GetArgData(buf + strlen(buf), &funcs->args->data[i]); if (i < funcs->args->argCount-1) strcat(buf, ", "); } fragments[1] = strdup(buf); fragments[2] = NULL; if (i < funcs->args->argCount) { GetArgData(buf, &funcs->args->data[i]); if (i < funcs->args->argCount-1) strcat(buf, ", "); i++; fragments[2] = strdup(buf); } fragments[3] = NULL; buf[0] = 0; for (;i < funcs->args->argCount; i++) { GetArgData(buf + strlen(buf), &funcs->args->data[i]); if (i < funcs->args->argCount-1) strcat(buf, ", "); } strcat(buf, ")"); fragments[3] = strdup(buf); return TRUE; }
bool XLPOnArgument(int macroId, int arg_no, bool start) { wxChar buf[300]; switch (macroId) { case ltCHAPTER: case ltCHAPTERSTAR: case ltCHAPTERHEADING: case ltSECTION: case ltSECTIONSTAR: case ltSECTIONHEADING: case ltSUBSECTION: case ltSUBSECTIONSTAR: case ltSUBSUBSECTION: case ltSUBSUBSECTIONSTAR: case ltGLOSS: case ltMEMBERSECTION: case ltFUNCTIONSECTION: { if (!start && (arg_no == 1)) currentSection = GetArgChunk(); return false; } case ltFUNC: { if (!start && (arg_no == 1)) TexOutput(_T(" "), true); if (start && (arg_no == 3)) TexOutput(_T("("), true); if (!start && (arg_no == 3)) TexOutput(_T(")"), true); break; } case ltPFUNC: { if (!start && (arg_no == 1)) TexOutput(_T(" "), true); if (start && (arg_no == 2)) TexOutput(_T("(*"), true); if (!start && (arg_no == 2)) TexOutput(_T(")"), true); if (start && (arg_no == 3)) TexOutput(_T("("), true); if (!start && (arg_no == 3)) TexOutput(_T(")"), true); break; } case ltCLIPSFUNC: { if (!start && (arg_no == 1)) TexOutput(_T(" "), true); if (start && (arg_no == 2)) { TexOutput(_T("("), true); long id = NewBlockId(); wxSnprintf(buf, sizeof(buf), _T("\\hy-%d{%ld}{"), hyBLOCK_BOLD, id); TexOutput(buf); } if (!start && (arg_no == 2)) { TexOutput(_T("}")); } if (!start && (arg_no == 3)) TexOutput(_T(")"), true); break; } case ltPARAM: { if (start && (arg_no == 2)) { long id = NewBlockId(); wxSnprintf(buf, sizeof(buf), _T(" \\hy-%d{%ld}{"), hyBLOCK_BOLD, id); TexOutput(buf); } if (!start && (arg_no == 2)) { TexOutput(_T("}")); } break; } case ltCPARAM: { if (start && (arg_no == 2)) { long id = NewBlockId(); wxSnprintf(buf, sizeof(buf), _T(" \\hy-%d{%ld}{"), hyBLOCK_BOLD, id); TexOutput(buf); } if (!start && (arg_no == 2)) { TexOutput(_T("}")); } break; } case ltMEMBER: { if (!start && (arg_no == 1)) TexOutput(_T(" "), true); break; } case ltLABEL: { return false; } case ltREF: { if (start) { wxChar *sec = NULL; wxChar *refName = GetArgData(); if (refName) { TexRef *texRef = FindReference(refName); if (texRef) { sec = texRef->sectionNumber; } } if (sec) { TexOutput(sec); } return false; } break; } case ltHELPREF: case ltHELPREFN: case ltPOPREF: { if (arg_no == 1) { if (start) { currentBlockId = NewBlockId(); wxSnprintf(buf, sizeof(buf), _T("\\hy-%d{%ld}{"), hyBLOCK_RED_ITALIC, currentBlockId); TexOutput(buf); } else TexOutput(_T("}")); } if (arg_no == 2) { if (start) { wxChar *label = GetArgData(); hyperLinks.Append(currentBlockId, (wxObject *)copystring(label)); } return false; } break; } case ltURLREF: { if (arg_no == 1) { return true; } else if (arg_no == 2) { if (start) TexOutput(_T(" (")); else TexOutput(_T(")")); return true; } break; } case ltITEM: { if (start && IsArgOptional()) { descriptionItemArg = GetArgChunk(); return false; } break; } case ltTABULAR: case ltSUPERTABULAR: { if (arg_no == 1) { if (start) { inTable = true; tableVerticalLineLeft = false; tableVerticalLineRight = false; wxChar *alignString = copystring(GetArgData()); // Count the number of columns noColumns = 0; int len = wxStrlen(alignString); if (len > 0) { if (alignString[0] == '|') tableVerticalLineLeft = true; if (alignString[len-1] == '|') tableVerticalLineRight = true; } for (int i = 0; i < len; i++) if (isalpha(alignString[i])) noColumns ++; /* // Experimental TexOutput(_T("\\brdrt\\brdrs")); if (tableVerticalLineLeft) TexOutput(_T("\\brdrl\\brdrs")); if (tableVerticalLineRight) TexOutput(_T("\\brdrr\\brdrs")); */ // Calculate a rough size for each column // int tabPos = 80/noColumns; currentTab = 0; return false; } } else if (arg_no == 2 && !start) { inTable = false; } else if (arg_no == 2 && start) return true; break; } case ltMARGINPAR: case ltMARGINPAREVEN: case ltMARGINPARODD: case ltNORMALBOX: case ltNORMALBOXD: { if (start) { TexOutput(_T("----------------------------------------------------------------------\n"), true); return true; } else TexOutput(_T("\n----------------------------------------------------------------------\n"), true); break; } case ltBIBITEM: { wxChar buf[100]; if (arg_no == 1 && start) { wxChar *citeKey = GetArgData(); TexRef *ref = (TexRef *)TexReferences.Get(citeKey); if (ref) { if (ref->sectionNumber) delete[] ref->sectionNumber; wxSnprintf(buf, sizeof(buf), _T("[%d]"), citeCount); ref->sectionNumber = copystring(buf); } wxSnprintf(buf, sizeof(buf), _T("\\hy-%d{%ld}{[%d]} "), hyBLOCK_BOLD, NewBlockId(), citeCount); TexOutput(buf); citeCount ++; return false; } return true; } case ltTHEBIBLIOGRAPHY: { if (start && (arg_no == 1)) { citeCount = 1; SetCurrentOutput(Chapters); SetCurrentOutputs(Contents, Chapters); long id1 = NewBlockId(); long id2 = NewBlockId(); wxFprintf(Contents, _T("\\hy-%d{%ld}{%s}\n"), hyBLOCK_SMALL_HEADING, id1, ReferencesNameString); wxFprintf(Chapters, _T("\\hy-%d{%ld}{%s}\n\n\n"), hyBLOCK_LARGE_VISIBLE_SECTION, id2, ReferencesNameString); wxFprintf(Index, _T("%ld %ld\n"), id1, id2); SetCurrentOutput(Chapters); return false; } if (!start && (arg_no == 2)) { } return true; } case ltTWOCOLITEM: case ltTWOCOLITEMRULED: { if (start && (arg_no == 2)) TexOutput(_T("\n ")); if (!start && (arg_no == 2)) TexOutput(_T("\n")); return true; } /* * Accents * */ case ltACCENT_GRAVE: { if (start) { wxChar *val = GetArgData(); if (val) { switch (val[0]) { case _T('a'): TexOutput(_T("a")); break; case _T('e'): TexOutput(_T("e")); break; case _T('i'): TexOutput(_T("i")); break; case _T('o'): TexOutput(_T("o")); break; case _T('u'): TexOutput(_T("u")); break; case _T('A'): TexOutput(_T("a")); break; case _T('E'): TexOutput(_T("E")); break; case _T('I'): TexOutput(_T("I")); break; case _T('O'): TexOutput(_T("O")); break; case _T('U'): TexOutput(_T("U")); break; default: break; } } } return false; } case ltACCENT_ACUTE: { if (start) { wxChar *val = GetArgData(); if (val) { switch (val[0]) { case _T('a'): TexOutput(_T("a")); break; case _T('e'): TexOutput(_T("e")); break; case _T('i'): TexOutput(_T("i")); break; case _T('o'): TexOutput(_T("o")); break; case _T('u'): TexOutput(_T("u")); break; case _T('y'): TexOutput(_T("y")); break; case _T('A'): TexOutput(_T("A")); break; case _T('E'): TexOutput(_T("E")); break; case _T('I'): TexOutput(_T("I")); break; case _T('O'): TexOutput(_T("O")); break; case _T('U'): TexOutput(_T("U")); break; case _T('Y'): TexOutput(_T("Y")); break; default: break; } } } return false; } case ltACCENT_CARET: { if (start) { wxChar *val = GetArgData(); if (val) { switch (val[0]) { case _T('a'): TexOutput(_T("a")); break; case _T('e'): TexOutput(_T("e")); break; case _T('i'): TexOutput(_T("i")); break; case _T('o'): TexOutput(_T("o")); break; case _T('u'): TexOutput(_T("u")); break; case _T('A'): TexOutput(_T("A")); break; case _T('E'): TexOutput(_T("E")); break; case _T('I'): TexOutput(_T("I")); break; case _T('O'): TexOutput(_T("O")); break; case _T('U'): TexOutput(_T("U")); break; default: break; } } } return false; } case ltACCENT_TILDE: { if (start) { wxChar *val = GetArgData(); if (val) { switch (val[0]) { case _T('a'): TexOutput(_T("a")); break; case _T(' '): TexOutput(_T("~")); break; case _T('n'): TexOutput(_T("n")); break; case _T('o'): TexOutput(_T("o")); break; case _T('A'): TexOutput(_T("A")); break; case _T('N'): TexOutput(_T("N")); break; case _T('O'): TexOutput(_T("O")); break; default: break; } } } return false; } case ltACCENT_UMLAUT: { if (start) { wxChar *val = GetArgData(); if (val) { switch (val[0]) { case _T('a'): TexOutput(_T("a")); break; case _T('e'): TexOutput(_T("e")); break; case _T('i'): TexOutput(_T("i")); break; case _T('o'): TexOutput(_T("o")); break; case _T('u'): TexOutput(_T("u")); break; case _T('y'): TexOutput(_T("y")); break; case _T('A'): TexOutput(_T("A")); break; case _T('E'): TexOutput(_T("E")); break; case _T('I'): TexOutput(_T("I")); break; case _T('O'): TexOutput(_T("O")); break; case _T('U'): TexOutput(_T("U")); break; case _T('Y'): TexOutput(_T("Y")); break; default: break; } } } return false; } case ltACCENT_DOT: { if (start) { wxChar *val = GetArgData(); if (val) { switch (val[0]) { case _T('a'): TexOutput(_T("a")); break; case _T('A'): TexOutput(_T("A")); break; default: break; } } } return false; } case ltACCENT_CADILLA: { if (start) { wxChar *val = GetArgData(); if (val) { switch (val[0]) { case _T('c'): TexOutput(_T("c")); break; case _T('C'): TexOutput(_T("C")); break; default: break; } } } return false; } default: { return DefaultOnArgument(macroId, arg_no, start); } } return true; }