bool GAFMovieClip::hasCtx() { if (m_ctxDirty) updateCtx(); return _glProgramState == m_programBase; }
void Editor::load(wchar_t const* name) { File* file = File::wopen(name); if (file) { file->seek(0, SEEK_END); int length = file->tell(); char* text = new char[length]; file->seek(0, SEEK_SET); file->read(text, length); running = NULL; lines.clear(); selStart = caret = 0; history.clear(); historyPos = 0; origHistory = 0; scrollPos.x = 0; scrollPos.y = 0; char* str = text; int curpos = 0; while (curpos <= length) { if (curpos >= length || str[curpos] == '\r' || str[curpos] == '\n') { lines.push().text = WideString(str, curpos++); if (curpos < length && (str[curpos] == '\r' || str[curpos] == '\n') && str[curpos] != str[curpos - 1]) curpos++; str += curpos; length -= curpos; curpos = 0; } else curpos++; } delete[] text; if (lines.length() == 0) lines.push(); updateCtx(0, lines.length() - 1); delete file; updateExtent(); getParent()->notify(EN_MODIFIED, (uint32) this, 0); } }
int Editor::replace(int ibegin, int iend, WideString cstr, HistoryItem* mod, bool glue) { if (running || settings->mode) return iend; wchar_t const* str = cstr.c_str(); if (ibegin > iend) { int tmp = ibegin; ibegin = iend; iend = tmp; } POINT begin = toPoint(ibegin); POINT end = toPoint(iend); POINT oldEnd = end; if (mod) { mod->begin = ibegin; mod->end = ibegin + getlength(str); mod->text = substring(ibegin, iend); } else { HistoryItem h; h.begin = ibegin; h.end = ibegin + getlength(str); h.text = substring(ibegin, iend); h.glue = glue; bool push = true; if (historyPos < history.length()) history.resize(historyPos); else if (historyPos > 0 && h.text.empty() && h.end == h.begin + 1 && !h.glue) { HistoryItem& p = history[historyPos - 1]; if (p.text.empty() && h.begin == p.end) { push = false; p.end = h.end; } } if (push) { if (history.length() >= 256) { for (int i = 1; i < history.length(); i++) history[i - 1] = history[i]; history[history.length() - 1] = h; if (origHistory >= 0) origHistory--; } else history.push(h); } historyPos = history.length(); if (historyPos < origHistory) origHistory = -1; } if (begin.y == end.y) { Line ln = lines[begin.y]; lines.insert(begin.y + 1, ln); end.y = begin.y + 1; } lines[begin.y].text.resize(begin.x); int curLine = begin.y; int curPos = 0; while (str[curPos]) { if (str[curPos] == '\r' || str[curPos] == '\n') { if (curLine == begin.y) lines[curLine].text.append(str, curPos); else if (curLine < end.y) lines[curLine].text = WideString(str, curPos); else { Line& ln = lines.insert(curLine); ln.text = WideString(str, curPos); end.y++; } untabify(lines[curLine].text); if ((str[curPos + 1] == '\r' || str[curPos + 1] == '\n') && str[curPos] != str[curPos + 1]) curPos++; str = str + curPos + 1; curPos = 0; curLine++; } else curPos++; } if (curLine < end.y) { if (curLine == begin.y) lines[curLine].text += str; else lines[curLine].text = str; untabify(lines[curLine].text); int ex = lines[curLine].text.length(); lines[curLine].text += lines[end.y].text.substring(end.x); if (lines[end.y].breakpoint > 0) lines[curLine].breakpoint = 1; lines.remove(curLine + 1, end.y - curLine); end.y = curLine; end.x = ex; } else { lines[end.y].text.replace(0, end.x, str); end.x = wcslen(str); untabify(lines[end.y].text); } caret = selStart = fromPoint(end); updateCtx(begin.y, end.y); updateExtent(); updateCaret(); getParent()->notify(EN_MODIFIED, (uint32) this, 0); return caret; }