⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tex2any.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    wxFprintf(CurrentOutput1, _T("%s"), s);  if (CurrentOutput2)    wxFprintf(CurrentOutput2, _T("%s"), s);}/* * Try to find a Latex macro, in one of the following forms: * (1) \begin{} ... \end{} * (2) \macroname{arg1}...{argn} * (3) {\bf arg1} */void ForbidWarning(TexMacroDef *def){  wxString informBuf;  switch (def->forbidden)  {    case FORBID_WARN:    {      informBuf.Printf(_T("Warning: it is recommended that command %s is not used."), def->name);      OnInform((const wxChar *)informBuf.c_str());      break;    }    case FORBID_ABSOLUTELY:    {      informBuf.Printf(_T("Error: command %s cannot be used and will lead to errors."), def->name);      OnInform((const wxChar *)informBuf.c_str());      break;    }    default:      break;  }}TexMacroDef *MatchMacro(wxChar *buffer, int *pos, wxChar **env, bool *parseToBrace){    *parseToBrace = true;    int i = (*pos);    TexMacroDef *def = NULL;    wxChar macroBuf[40];    // First, try to find begin{thing}    if (wxStrncmp(buffer+i, _T("begin{"), 6) == 0)    {        i += 6;        int j = i;        while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39))        {              macroBuf[j-i] = buffer[j];              j ++;        }        macroBuf[j-i] = 0;        def = (TexMacroDef *)MacroDefs.Get(macroBuf);        if (def)        {            *pos = j + 1;  // BUGBUG Should this be + 1???            *env = def->name;            ForbidWarning(def);            return def;        }        else        {            return NULL;        }    }    // Failed, so try to find macro from definition list    int j = i;    // First try getting a one-character macro, but ONLY    // if these TWO characters are not both alphabetical (could    // be a longer macro)    if (!(isalpha(buffer[i]) && isalpha(buffer[i+1])))    {        macroBuf[0] = buffer[i];        macroBuf[1] = 0;        def = (TexMacroDef *)MacroDefs.Get(macroBuf);        if (def) j ++;    }    if (!def)    {        while ((isalpha(buffer[j]) || buffer[j] == '*') && ((j - i) < 39))        {            macroBuf[j-i] = buffer[j];            j ++;        }        macroBuf[j-i] = 0;        def = (TexMacroDef *)MacroDefs.Get(macroBuf);    }    if (def)    {        i = j;        // We want to check whether this is a space-consuming macro        // (e.g. {\bf word})        // No brace, e.g. \input thing.tex instead of \input{thing};        // or a numeric argument, such as \parindent0pt        if ((def->no_args > 0) && ((buffer[i] == 32) || (buffer[i] == '=') || (isdigit(buffer[i]))))        {            if ((buffer[i] == 32) || (buffer[i] == '='))            i ++;            *parseToBrace = false;        }        *pos = i;        ForbidWarning(def);        return def;    }    return NULL;}void EatWhiteSpace(wxChar *buffer, int *pos){  int len = wxStrlen(buffer);  int j = *pos;  bool keepGoing = true;  bool moreLines = true;  while ((j < len) && keepGoing &&         (buffer[j] == 10 || buffer[j] == 13 || buffer[j] == ' ' || buffer[j] == 9))  {    j ++;    if (j >= len)    {      if (moreLines)      {        moreLines = read_a_line(buffer);        len = wxStrlen(buffer);        j = 0;      }      else        keepGoing = false;    }  }  *pos = j;}bool FindEndEnvironment(wxChar *buffer, int *pos, wxChar *env){  int i = (*pos);  // Try to find end{thing}  if ((wxStrncmp(buffer+i, _T("end{"), 4) == 0) &&      (wxStrncmp(buffer+i+4, env, wxStrlen(env)) == 0))  {    *pos = i + 5 + wxStrlen(env);    return true;  }  else return false;}bool readingVerbatim = false;bool readInVerbatim = false;  // Within a verbatim, but not nec. verbatiminput// Switched this off because e.g. \verb${$ causes it to fail. There is no// detection of \verb yet.// #define CHECK_BRACES 1unsigned long leftCurly = 0;unsigned long rightCurly = 0;static wxString currentFileName = wxEmptyString;bool read_a_line(wxChar *buf){  if (CurrentInputIndex < 0)  {    buf[0] = 0;    return false;  }  int ch = -2;  unsigned long bufIndex = 0;  buf[0] = 0;  int lastChar;  while (ch != EOF && ch != 10)  {    if (bufIndex >= MAX_LINE_BUFFER_SIZE)    {       wxString errBuf;       errBuf.Printf(_T("Line %lu of file %s is too long.  Lines can be no longer than %lu characters.  Truncated."),           LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(), MAX_LINE_BUFFER_SIZE);       OnError((wxChar *)errBuf.c_str());       return false;    }    if (((bufIndex == 14) && (wxStrncmp(buf, _T("\\end{verbatim}"), 14) == 0)) ||         ((bufIndex == 16) && (wxStrncmp(buf, _T("\\end{toocomplex}"), 16) == 0)))      readInVerbatim = false;    lastChar = ch;    ch = getc(Inputs[CurrentInputIndex]);    if (checkCurlyBraces)    {        if (ch == '{' && !readInVerbatim && lastChar != _T('\\'))           leftCurly++;        if (ch == '}' && !readInVerbatim && lastChar != _T('\\'))        {           rightCurly++;           if (rightCurly > leftCurly)           {               wxString errBuf;               errBuf.Printf(_T("An extra right Curly brace ('}') was detected at line %lu inside file %s"), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str());               OnError((wxChar *)errBuf.c_str());               // Reduce the count of right Curly braces, so the mismatched count               // isn't reported on every line that has a '}' after the first mismatch               rightCurly--;           }        }    }    if (ch != EOF)    {      // Check for 2 consecutive newlines and replace with \par      if (ch == 10 && !readInVerbatim)      {        int ch1 = getc(Inputs[CurrentInputIndex]);        if ((ch1 == 10) || (ch1 == 13))        {          // Eliminate newline (10) following DOS linefeed          if (ch1 == 13)            getc(Inputs[CurrentInputIndex]);          buf[bufIndex] = 0;          IncrementLineNumber();//          wxStrcat(buf, "\\par\n");//          i += 6;          if (bufIndex+5 >= MAX_LINE_BUFFER_SIZE)          {             wxString errBuf;             errBuf.Printf(_T("Line %lu of file %s is too long.  Lines can be no longer than %lu characters.  Truncated."),                 LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);             OnError((wxChar *)errBuf.c_str());             return false;          }          wxStrcat(buf, _T("\\par"));          bufIndex += 5;        }        else        {          ungetc(ch1, Inputs[CurrentInputIndex]);          if (bufIndex >= MAX_LINE_BUFFER_SIZE)          {             wxString errBuf;             errBuf.Printf(_T("Line %lu of file %s is too long.  Lines can be no longer than %lu characters.  Truncated."),                 LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE);             OnError((wxChar *)errBuf.c_str());             return false;          }          buf[bufIndex] = (wxChar)ch;          bufIndex ++;        }      }      else      {        // Convert embedded characters to RTF equivalents        switch(ch)        {        case 0xf6: // 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -