spellyer.h

来自「语法检查程序」· C头文件 代码 · 共 63 行

H
63
字号
/***************************************************************************/
/* NOTE:                                                                   */
/* This document is copyright (c) by Oz Solomon and Yonat Sharon, and is   */
/* bound by the MIT open source license.                                   */ 
/* See License.txt or visit www.opensource.org/licenses/mit-license.html   */
/***************************************************************************/

#ifndef SPELLYER_H
#define SPELLYER_H

#pragma warning (disable : 4786)

#include "Spelly.h"
#include <map>

class CodeParser;
class SpellyParserContext;

class Spellyer
{
public:
    Spellyer();
    ~Spellyer();
    void Spell(
        I_TEXT_DOC* inDoc,
        bool inCheckAll); // not only comments and strings
private:
    CComQIPtr<I_TEXT_SELECTION, &IID_I_TEXT_SELECTION>  itsSelection;
    CPoint  itsStartPoint;  // where to start checking
    CPoint  itsEndPoint;    // where to stop checking
    CPoint  itsCurrPoint;   // current checking point
    CPoint  itsOrgPoint;    // used if nothing was selected. Otherwise == (0,0)
    bool    itsRestoreSelection; // restore original selection when finished
    SIZE    itsDlgOffset;   // for the CSuggestDlg
    std::map<CString,CString>   itsReplacements; // for Replace All

    // to check only strings and comments
    CodeParser*             itsCodeParser;
    SpellyParserContext*    itsParserContext;

    void InitCodeParser(I_TEXT_DOC* inDoc);
    void InitSelection(I_TEXT_DOC* inDoc); // find area to check and go to its start
    bool SpellCurrLine(); // returns: continue to next line
    void Cleanup(); // restore the original selection/position

    void Parse(char c); // using itsCodeParser
    bool InSpellZone(char c); // c is still in area to check

    bool FindNextWord(
        const char* inText,
        unsigned&   outWordStartPos,
        unsigned&   outWordLen);
    
    bool Misspelled(const CString& inWord);

    CString SpellWord( // returns: ""=no replacement, "!"=stop, else=replace
        const CString& inWord);
    
    void ReportError(const CString& error);
};

#endif // SPELLYER_H

⌨️ 快捷键说明

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