2
#include "textcutter.h"
4
TextCutter::TextCutter(const wxString& allText, FortranSourceForm fsForm)
7
m_TextLen = m_Text.length();
8
m_CurSourceForm = fsForm;
13
TextCutter::~TextCutter()
17
void TextCutter::GetChunk(wxString& chunk, bool& isWord)
20
chunk = wxEmptyString;
24
unsigned int start = m_CurIdx;
25
if (isalpha(CurrentChar()) || CurrentChar() == '_')
28
(isalnum(CurrentChar()) || CurrentChar() == '_'))
30
chunk = m_Text.Mid(start, m_CurIdx - start);
37
if (start != m_CurIdx)
39
chunk = m_Text.Mid(start, m_CurIdx - start);
43
if (isdigit(CurrentChar()))
46
while (!IsEOF() && CharInString(CurrentChar(), "0123456789.abcdefABCDEFXxLl"))
50
else if (CurrentChar() == '"' ||
51
CurrentChar() == '\'')
54
wxChar match = CurrentChar();
55
MoveToNextChar(); // skip starting ' or "
57
MoveToNextChar(); // skip ending ' or "
63
chunk = m_Text.Mid(start, m_CurIdx - start);
68
bool TextCutter::SkipWhiteSpace()
72
while (!IsEOF() && isspace(CurrentChar()))
77
bool TextCutter::MoveToNextChar()
87
void TextCutter::AdjustColumn()
89
if (CurrentChar() == '\n')
93
wxChar TextCutter::CurrentChar()
95
return m_Text.GetChar(m_CurIdx);
98
wxChar TextCutter::NextChar()
100
if (m_CurIdx+1 >= m_TextLen)
102
return m_Text.GetChar(m_CurIdx+1);
105
void TextCutter::SkipUnwanted()
109
while (CurrentChar() == '#' ||
110
CurrentChar() == '!' ||
111
((CurrentChar() == 'c' || CurrentChar() == 'C' || CurrentChar() == '*') && m_CurColumn == 1 && m_CurSourceForm == fsfFixed))
120
void TextCutter::SkipToChar(const wxChar& ch)
122
// skip everything until we find ch
125
while (!IsEOF() && CurrentChar() != ch && CurrentChar() != '\n')
131
bool TextCutter::CharInString(const char ch, const char* chars)
133
int len = strlen(chars);
134
for (int i = 0; i < len; ++i)
142
void TextCutter::SkipToEOL()
144
while (!IsEOF() && CurrentChar() != '\n')