mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
CtrlLib: TextCtrl, LineEdit, CodeEditor: view mode
git-svn-id: svn://ultimatepp.org/upp/trunk@11592 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
fe56d7c2cc
commit
3d0e1db02f
55 changed files with 1240 additions and 714 deletions
|
|
@ -35,7 +35,7 @@ Color CSyntax::BlockColor(int level)
|
|||
return GetHlStyle(PAPER_NORMAL).color;
|
||||
}
|
||||
|
||||
void CSyntax::Bracket(int pos, HighlightOutput& hls, CodeEditor *editor) // TODO:SYNTAX: Cleanup passing bracket info
|
||||
void CSyntax::Bracket(int64 pos, HighlightOutput& hls, CodeEditor *editor) // TODO:SYNTAX: Cleanup passing bracket info
|
||||
{
|
||||
if(!editor)
|
||||
return;
|
||||
|
|
@ -113,7 +113,7 @@ const wchar *CSyntax::DoComment(HighlightOutput& hls, const wchar *p, const wcha
|
|||
return p + n;
|
||||
}
|
||||
|
||||
void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
|
||||
void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls, CodeEditor *editor, int line, int64 pos)
|
||||
{
|
||||
ONCELOCK {
|
||||
InitKeywords();
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void CSyntax::IndentInsert0(CodeEditor& e, int chr, int count, bool reformat)
|
|||
WString dummy;
|
||||
int cp = GetCommentPos(e, l, dummy);
|
||||
if(cp >= 0) {
|
||||
int wl = e.GetGPos(l, limit) - lp0;
|
||||
int wl = (int)e.GetGPos(l, limit) - lp0;
|
||||
while(wl > cp && ln[wl - 1] != '\n' && ln[wl - 1] != ' ')
|
||||
wl--;
|
||||
int sl = wl - 1;
|
||||
|
|
@ -162,7 +162,7 @@ void CSyntax::ReformatComment(CodeEditor& e)
|
|||
{
|
||||
if(!e.IsWordwrapComments())
|
||||
return;
|
||||
int first_line = e.GetLine(e.GetCursor());
|
||||
int first_line = e.GetLine(e.GetCursor64());
|
||||
WString ch;
|
||||
if(GetCommentPos(e, first_line, ch) < 0)
|
||||
return;
|
||||
|
|
@ -188,13 +188,13 @@ void CSyntax::ReformatComment(CodeEditor& e)
|
|||
e.FinishPut();
|
||||
}
|
||||
|
||||
bool NotEscape(int pos, const WString& s)
|
||||
bool NotEscape(int64 pos, const WString& s)
|
||||
{
|
||||
return pos == 0 || s[pos - 1] != '\\' ? true : !NotEscape(pos - 1, s);
|
||||
return pos == 0 || s[(int)pos - 1] != '\\' ? true : !NotEscape(pos - 1, s);
|
||||
}
|
||||
|
||||
bool CSyntax::CheckBracket(CodeEditor& e, int li, int pos, int ppos, int pos0, WString ln, int d, int limit,
|
||||
int& bpos0, int& bpos)
|
||||
bool CSyntax::CheckBracket(CodeEditor& e, int li, int64 pos, int64 ppos, int64 pos0, WString ln,
|
||||
int d, int limit, int64& bpos0, int64& bpos)
|
||||
{
|
||||
int lvl = 1;
|
||||
pos += d;
|
||||
|
|
@ -213,13 +213,13 @@ bool CSyntax::CheckBracket(CodeEditor& e, int li, int pos, int ppos, int pos0, W
|
|||
pos = d < 0 ? ln.GetLength() - 1 : 0;
|
||||
ppos += d;
|
||||
}
|
||||
c = ln[pos];
|
||||
if((c == '\"' || c == '\'') && (pos > 0 && NotEscape(pos, ln) && ln[pos - 1] != '\'')) {
|
||||
c = ln[(int)pos];
|
||||
if((c == '\"' || c == '\'') && (pos > 0 && NotEscape(pos, ln) && ln[(int)pos - 1] != '\'')) {
|
||||
pos += d;
|
||||
ppos += d;
|
||||
int lc = c;
|
||||
while(pos < ln.GetLength() && pos > 0) {
|
||||
if(ln[pos] == lc && NotEscape(pos, ln)) {
|
||||
if(ln[(int)pos] == lc && NotEscape(pos, ln)) {
|
||||
pos += d;
|
||||
ppos += d;
|
||||
break;
|
||||
|
|
@ -246,31 +246,31 @@ bool CSyntax::CheckBracket(CodeEditor& e, int li, int pos, int ppos, int pos0, W
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CSyntax::CheckLeftBracket(CodeEditor& e, int pos, int& bpos0, int& bpos)
|
||||
bool CSyntax::CheckLeftBracket(CodeEditor& e, int64 pos, int64& bpos0, int64& bpos)
|
||||
{
|
||||
if(pos < 0 || pos >= e.GetLength())
|
||||
if(pos < 0 || pos >= e.GetLength64())
|
||||
return false;
|
||||
int ppos = pos;
|
||||
int li = e.GetLinePos(pos);
|
||||
int64 ppos = pos;
|
||||
int li = e.GetLinePos64(pos);
|
||||
WString ln = e.GetWLine(li);
|
||||
return islbrkt(ln[pos]) &&
|
||||
return islbrkt(ln[(int)pos]) &&
|
||||
CheckBracket(e, li, pos, ppos, ppos, ln, 1, min(li + 3000, e.GetLineCount()), bpos0, bpos);
|
||||
}
|
||||
|
||||
bool CSyntax::CheckRightBracket(CodeEditor& e, int pos, int& bpos0, int& bpos)
|
||||
bool CSyntax::CheckRightBracket(CodeEditor& e, int64 pos, int64& bpos0, int64& bpos)
|
||||
{
|
||||
if(pos < 0 || pos >= e.GetLength())
|
||||
if(pos < 0 || pos >= e.GetLength64())
|
||||
return false;
|
||||
int ppos = pos;
|
||||
int li = e.GetLinePos(pos);
|
||||
int64 ppos = pos;
|
||||
int li = e.GetLinePos64(pos);
|
||||
WString ln = e.GetWLine(li);
|
||||
return isrbrkt(ln[pos]) &&
|
||||
return isrbrkt(ln[(int)pos]) &&
|
||||
CheckBracket(e, li, pos, ppos, ppos, ln, -1, max(li - 3000, 0), bpos0, bpos);
|
||||
}
|
||||
|
||||
bool CSyntax::CheckBrackets(CodeEditor& e, int& bpos0, int& bpos)
|
||||
bool CSyntax::CheckBrackets(CodeEditor& e, int64& bpos0, int64& bpos)
|
||||
{
|
||||
int c = e.GetCursor();
|
||||
int64 c = e.GetCursor64();
|
||||
return CheckLeftBracket(e, c, bpos0, bpos) ||
|
||||
CheckRightBracket(e, c, bpos0, bpos) ||
|
||||
CheckLeftBracket(e, c - 1, bpos0, bpos) ||
|
||||
|
|
@ -287,7 +287,7 @@ Vector<IfState> CSyntax::PickIfStack()
|
|||
return pick(ifstack);
|
||||
}
|
||||
|
||||
void CSyntax::CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text)
|
||||
void CSyntax::CheckSyntaxRefresh(CodeEditor& e, int64 pos, const WString& text)
|
||||
{
|
||||
for(const wchar *s = text; *s; s++) {
|
||||
if(*s == '{' || *s == '(' || *s == '[' || *s == '/' || *s == '*' ||
|
||||
|
|
@ -300,7 +300,7 @@ void CSyntax::CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text)
|
|||
if(s.StartsWith("#if") || s.StartsWith("#e"))
|
||||
e.Refresh();
|
||||
|
||||
WString h = e.GetWLine(e.GetLinePos(pos)); // block highlighting changes if start of line is changed
|
||||
WString h = e.GetWLine(e.GetLinePos64(pos)); // block highlighting changes if start of line is changed
|
||||
for(int i = 0; i < pos; i++)
|
||||
if(findarg(h[i], ' ', '\t') < 0)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ public:
|
|||
virtual void ScanSyntax(const wchar *ln, const wchar *e, int line, int tab_size);
|
||||
virtual void Serialize(Stream& s);
|
||||
virtual void IndentInsert(CodeEditor& editor, int chr, int count);
|
||||
virtual bool CheckBrackets(CodeEditor& e, int& bpos0, int& bpos);
|
||||
virtual bool CheckBrackets(CodeEditor& e, int64& bpos0, int64& bpos);
|
||||
virtual bool CanAssist() const;
|
||||
virtual void Highlight(const wchar *s, const wchar *end, HighlightOutput& hls,
|
||||
CodeEditor *editor, int line, int pos);
|
||||
virtual void CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text);
|
||||
CodeEditor *editor, int line, int64 pos);
|
||||
virtual void CheckSyntaxRefresh(CodeEditor& e, int64 pos, const WString& text);
|
||||
virtual Vector<IfState> PickIfStack(); // TODO: Refactor?
|
||||
virtual void ReformatComment(CodeEditor& e);
|
||||
|
||||
|
|
@ -56,15 +56,15 @@ protected:
|
|||
WString GetCommentHdr(CodeEditor& e, int l) const { WString h; GetCommentPos(e, l, h); return h; }
|
||||
void IndentInsert0(CodeEditor& e, int chr, int count, bool reformat);
|
||||
|
||||
void Bracket(int pos, HighlightOutput& hls, CodeEditor *editor);
|
||||
void Bracket(int64 pos, HighlightOutput& hls, CodeEditor *editor);
|
||||
|
||||
void ClearBraces();
|
||||
|
||||
void Grounding(const wchar *ln, const wchar *e);
|
||||
|
||||
bool CheckBracket(CodeEditor& e, int li, int pos, int ppos, int pos0, WString ln, int d, int limit, int& bpos0, int& bpos);
|
||||
bool CheckLeftBracket(CodeEditor& e, int pos, int& bpos0, int& bpos);
|
||||
bool CheckRightBracket(CodeEditor& e, int pos, int& bpos0, int& bpos);
|
||||
bool CheckBracket(CodeEditor& e, int li, int64 pos, int64 ppos, int64 pos0, WString ln, int d, int limit, int64& bpos0, int64& bpos);
|
||||
bool CheckLeftBracket(CodeEditor& e, int64 pos, int64& bpos0, int64& bpos);
|
||||
bool CheckRightBracket(CodeEditor& e, int64 pos, int64& bpos0, int64& bpos);
|
||||
|
||||
public:
|
||||
static int LoadSyntax(const char *keywords[], const char *names[]);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ inline bool RBR(int c) {
|
|||
return isbrkt(c);
|
||||
}
|
||||
|
||||
void CodeEditor::CheckSyntaxRefresh(int pos, const WString& text)
|
||||
void CodeEditor::CheckSyntaxRefresh(int64 pos, const WString& text)
|
||||
{
|
||||
GetSyntax(GetLine(pos))->CheckSyntaxRefresh(*this, pos, text);
|
||||
}
|
||||
|
|
@ -135,6 +135,8 @@ void CodeEditor::ClearLines() {
|
|||
}
|
||||
|
||||
void CodeEditor::InsertLines(int line, int count) {
|
||||
if(IsView())
|
||||
return;
|
||||
bar.InsertLines(line, count);
|
||||
if(line <= line2.GetCount())
|
||||
line2.Insert(line, GetLine2(line), count);
|
||||
|
|
@ -150,6 +152,8 @@ void CodeEditor::RemoveLines(int line, int count) {
|
|||
|
||||
void CodeEditor::Renumber2()
|
||||
{
|
||||
if(IsView())
|
||||
return;
|
||||
line2.SetCount(GetLineCount());
|
||||
for(int i = 0; i < GetLineCount(); i++)
|
||||
line2[i] = i;
|
||||
|
|
@ -171,12 +175,12 @@ String CodeEditor::GetPasteText()
|
|||
return h;
|
||||
}
|
||||
|
||||
bool CodeEditor::IsCursorBracket(int pos) const
|
||||
bool CodeEditor::IsCursorBracket(int64 pos) const
|
||||
{
|
||||
return pos == highlight_bracket_pos0 && hilite_bracket;
|
||||
}
|
||||
|
||||
bool CodeEditor::IsMatchingBracket(int pos) const
|
||||
bool CodeEditor::IsMatchingBracket(int64 pos) const
|
||||
{
|
||||
return pos == highlight_bracket_pos && (hilite_bracket == 1 || hilite_bracket == 2 && bracket_flash);
|
||||
}
|
||||
|
|
@ -196,14 +200,14 @@ void CodeEditor::CheckBrackets()
|
|||
}
|
||||
|
||||
void CodeEditor::CopyWord() {
|
||||
int p = GetCursor();
|
||||
int64 p = GetCursor64();
|
||||
if(iscidl(GetChar(p)) || (p > 0 && iscidl(GetChar(--p)))) {
|
||||
int e = GetLength();
|
||||
int f = p;
|
||||
int64 e = GetLength64();
|
||||
int64 f = p;
|
||||
while(--p >= 0 && iscidl(GetChar(p))) {}
|
||||
++p;
|
||||
while(++f < e && iscidl(GetChar(f)));
|
||||
WString txt = GetW(p, f - p);
|
||||
WString txt = GetW(p, LimitSize(f - p));
|
||||
WriteClipboardUnicodeText(txt);
|
||||
AppendClipboardText(txt.ToString());
|
||||
}
|
||||
|
|
@ -213,7 +217,7 @@ void CodeEditor::DuplicateLine()
|
|||
{
|
||||
if(IsReadOnly()) return;
|
||||
int i = GetLine(cursor);
|
||||
int pos = GetPos(i);
|
||||
int pos = GetPos32(i);
|
||||
int len = GetLineLength(i);
|
||||
Insert(pos + len, "\n" + GetW(pos, len));
|
||||
}
|
||||
|
|
@ -221,9 +225,9 @@ void CodeEditor::DuplicateLine()
|
|||
void CodeEditor::SwapChars() {
|
||||
if(IsReadOnly()) return;
|
||||
int i = GetLine(cursor);
|
||||
int j = GetPos(i);
|
||||
if (j < cursor && (cursor-j) < line[i].GetLength()) {
|
||||
int p = cursor;
|
||||
int j = GetPos32(i);
|
||||
if (j < cursor && cursor - j < GetLineLength(i)) {
|
||||
int p = (int)cursor;
|
||||
WString txt(GetChar(p-1),1);
|
||||
Remove(p-1,1);
|
||||
Insert(p, txt, true);
|
||||
|
|
@ -233,7 +237,7 @@ void CodeEditor::SwapChars() {
|
|||
|
||||
void CodeEditor::Put(int chr)
|
||||
{
|
||||
Insert(cursor++, WString(chr, 1), true);
|
||||
Insert((int)cursor++, WString(chr, 1), true);
|
||||
}
|
||||
|
||||
void CodeEditor::FinishPut()
|
||||
|
|
@ -249,7 +253,7 @@ void CodeEditor::ReformatComment()
|
|||
GetSyntax(GetLine(cursor))->ReformatComment(*this);
|
||||
}
|
||||
|
||||
void CodeEditor::CancelBracketHighlight(int& pos)
|
||||
void CodeEditor::CancelBracketHighlight(int64& pos)
|
||||
{
|
||||
if(pos >= 0) {
|
||||
RefreshLine(GetLine(pos));
|
||||
|
|
@ -271,12 +275,12 @@ void CodeEditor::Periodic()
|
|||
|
||||
void CodeEditor::SelectionChanged()
|
||||
{
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
WString nilluminated;
|
||||
bool sel = GetSelection(l, h);
|
||||
bool ill = false;
|
||||
if(sel && h - l < 128) {
|
||||
for(int i = l; i < h; i++) {
|
||||
for(int64 i = l; i < h; i++) {
|
||||
int c = GetChar(i);
|
||||
if(c == '\n') {
|
||||
nilluminated.Clear();
|
||||
|
|
@ -325,18 +329,18 @@ void CodeEditor::IndentInsert(int chr, int count) {
|
|||
void CodeEditor::Make(Event<String&> op)
|
||||
{
|
||||
if(IsReadOnly()) return;
|
||||
Point cursor = GetColumnLine(GetCursor());
|
||||
Point cursor = GetColumnLine(GetCursor32());
|
||||
Point scroll = GetScrollPos();
|
||||
int l, h;
|
||||
bool is_sel = GetSelection(l, h);
|
||||
if(!is_sel) { l = 0; h = GetLength(); }
|
||||
bool is_sel = GetSelection32(l, h);
|
||||
if(!is_sel) { l = 0; h = GetLength32(); }
|
||||
if(h <= l)
|
||||
{
|
||||
BeepExclamation();
|
||||
return;
|
||||
}
|
||||
l = GetPos(GetLine(l));
|
||||
h = GetPos(GetLine(h - 1) + 1);
|
||||
l = GetPos32(GetLine(l));
|
||||
h = GetPos32(GetLine(h - 1) + 1);
|
||||
String substring = Get(l, h - l);
|
||||
String out = substring;
|
||||
op(out);
|
||||
|
|
@ -429,8 +433,8 @@ void CodeEditor::MakeLineEnds()
|
|||
}
|
||||
|
||||
void CodeEditor::MoveNextWord(bool sel) {
|
||||
int p = GetCursor();
|
||||
int e = GetLength();
|
||||
int64 p = GetCursor64();
|
||||
int64 e = GetLength64();
|
||||
if(iscidl(GetChar(p)))
|
||||
while(p < e && iscidl(GetChar(p))) p++;
|
||||
else
|
||||
|
|
@ -439,7 +443,7 @@ void CodeEditor::MoveNextWord(bool sel) {
|
|||
}
|
||||
|
||||
void CodeEditor::MovePrevWord(bool sel) {
|
||||
int p = GetCursor();
|
||||
int64 p = GetCursor64();
|
||||
if(p == 0) return;
|
||||
if(iscidl(GetChar(p - 1)))
|
||||
while(p > 0 && iscidl(GetChar(p - 1))) p--;
|
||||
|
|
@ -449,8 +453,8 @@ void CodeEditor::MovePrevWord(bool sel) {
|
|||
}
|
||||
|
||||
void CodeEditor::MoveNextBrk(bool sel) {
|
||||
int p = GetCursor();
|
||||
int e = GetLength();
|
||||
int64 p = GetCursor64();
|
||||
int64 e = GetLength64();
|
||||
if(!islbrkt(GetChar(p)))
|
||||
while(p < e && !islbrkt(GetChar(p))) p++;
|
||||
else {
|
||||
|
|
@ -467,10 +471,10 @@ void CodeEditor::MoveNextBrk(bool sel) {
|
|||
}
|
||||
|
||||
void CodeEditor::MovePrevBrk(bool sel) {
|
||||
int p = GetCursor();
|
||||
int64 p = GetCursor64();
|
||||
if(p < 2) return;
|
||||
if(!isrbrkt(GetChar(p - 1))) {
|
||||
if(p < GetLength() - 1 && isrbrkt(GetChar(p)))
|
||||
if(p < GetLength64() - 1 && isrbrkt(GetChar(p)))
|
||||
p++;
|
||||
else {
|
||||
while(p > 0 && !isrbrkt(GetChar(p - 1))) p--;
|
||||
|
|
@ -496,8 +500,8 @@ bool isspctab(int c) {
|
|||
|
||||
void CodeEditor::DeleteWord() {
|
||||
if(IsReadOnly() || RemoveSelection()) return;
|
||||
int p = GetCursor();
|
||||
int e = GetLength();
|
||||
int p = GetCursor32();
|
||||
int e = GetLength32();
|
||||
int c = GetChar(p);
|
||||
if(iscidl(c))
|
||||
while(p < e && iscidl(GetChar(p))) p++;
|
||||
|
|
@ -508,12 +512,12 @@ void CodeEditor::DeleteWord() {
|
|||
DeleteChar();
|
||||
return;
|
||||
}
|
||||
Remove(GetCursor(), p - GetCursor());
|
||||
Remove(GetCursor32(), p - GetCursor32());
|
||||
}
|
||||
|
||||
void CodeEditor::DeleteWordBack() {
|
||||
if(IsReadOnly() || RemoveSelection()) return;
|
||||
int p = GetCursor();
|
||||
int p = GetCursor32();
|
||||
if(p < 1) return;
|
||||
int c = GetChar(p - 1);
|
||||
if(iscidl(GetChar(p - 1)))
|
||||
|
|
@ -525,20 +529,20 @@ void CodeEditor::DeleteWordBack() {
|
|||
Backspace();
|
||||
return;
|
||||
}
|
||||
Remove(p, GetCursor() - p);
|
||||
Remove(p, GetCursor32() - p);
|
||||
PlaceCaret(p);
|
||||
}
|
||||
|
||||
void CodeEditor::SetLineSelection(int l, int h) {
|
||||
SetSelection(GetPos(l), GetPos(h));
|
||||
SetSelection(GetPos64(l), GetPos64(h));
|
||||
}
|
||||
|
||||
bool CodeEditor::GetLineSelection(int& l, int& h) {
|
||||
if(!GetSelection(l, h)) return false;
|
||||
l = GetLine(l);
|
||||
int pos = h;
|
||||
h = GetLinePos(pos);
|
||||
if(pos && h < GetLineCount()) h++;
|
||||
int64 ll, hh;
|
||||
if(!GetSelection(ll, hh)) return false;
|
||||
l = GetLine(ll);
|
||||
h = GetLinePos64(hh);
|
||||
if(hh && h < GetLineCount()) h++;
|
||||
SetLineSelection(l, h);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -550,7 +554,7 @@ void CodeEditor::TabRight() {
|
|||
int ll = l;
|
||||
String tab(indent_spaces ? ' ' : '\t', indent_spaces ? GetTabSize() : 1);
|
||||
while(l < h)
|
||||
Insert(GetPos(l++), tab);
|
||||
Insert(GetPos32(l++), tab);
|
||||
SetLineSelection(ll, h);
|
||||
}
|
||||
|
||||
|
|
@ -564,12 +568,12 @@ void CodeEditor::TabLeft() {
|
|||
int spc = 0;
|
||||
while(spc < tabsize && ln[spc] == ' ') spc++;
|
||||
if(spc < tabsize && ln[spc] == '\t') spc++;
|
||||
Remove(GetPos(l++), spc);
|
||||
Remove(GetPos32(l++), spc);
|
||||
}
|
||||
SetLineSelection(ll, h);
|
||||
}
|
||||
|
||||
bool CodeEditor::GetWordPos(int pos, int& l, int& h) {
|
||||
bool CodeEditor::GetWordPos(int64 pos, int64& l, int64& h) {
|
||||
l = h = pos;
|
||||
if(!iscidl(GetChar(pos))) return false;
|
||||
while(l > 0 && iscidl(GetChar(l - 1))) l--;
|
||||
|
|
@ -577,11 +581,11 @@ bool CodeEditor::GetWordPos(int pos, int& l, int& h) {
|
|||
return true;
|
||||
}
|
||||
|
||||
String CodeEditor::GetWord(int pos)
|
||||
String CodeEditor::GetWord(int64 pos)
|
||||
{
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
GetWordPos(pos, l, h);
|
||||
return Get(l, h - l);
|
||||
return Get(l, LimitSize(h - l));
|
||||
}
|
||||
|
||||
String CodeEditor::GetWord()
|
||||
|
|
@ -590,8 +594,8 @@ String CodeEditor::GetWord()
|
|||
}
|
||||
|
||||
void CodeEditor::LeftDouble(Point p, dword keyflags) {
|
||||
int l, h;
|
||||
int pos = GetMousePos(p);
|
||||
int64 l, h;
|
||||
int64 pos = GetMousePos(p);
|
||||
if(GetWordPos(pos, l, h))
|
||||
SetSelection(l, h);
|
||||
else
|
||||
|
|
@ -655,14 +659,14 @@ void CodeEditor::SyncTip()
|
|||
|
||||
bool CodeEditor::MouseSelSpecial(Point p, dword flags) {
|
||||
if((flags & K_MOUSELEFT) && HasFocus() && HasCapture() && !(flags & K_ALT) && selkind != SEL_CHARS) {
|
||||
int c = GetMousePos(p);
|
||||
int l, h;
|
||||
int64 c = GetMousePos(p);
|
||||
int64 l, h;
|
||||
|
||||
if(selkind == SEL_LINES) {
|
||||
l = c;
|
||||
int i = GetLinePos(l);
|
||||
int i = GetLinePos64(l);
|
||||
l = c - l;
|
||||
h = min(l + GetLineLength(i) + 1, GetLength() - 1);
|
||||
h = min(l + GetLineLength(i) + 1, GetLength64() - 1);
|
||||
c = c < anchor ? l : h;
|
||||
}
|
||||
else
|
||||
|
|
@ -683,7 +687,8 @@ void CodeEditor::MouseMove(Point p, dword flags) {
|
|||
if(!MouseSelSpecial(p, flags))
|
||||
LineEdit::MouseMove(p, flags);
|
||||
if(IsSelection()) return;
|
||||
tippos = GetMousePos(p);
|
||||
int64 h = GetMousePos(p);
|
||||
tippos = h < INT_MAX ? (int)h : -1;
|
||||
SyncTip();
|
||||
}
|
||||
|
||||
|
|
@ -704,9 +709,9 @@ void CodeEditor::MouseLeave()
|
|||
|
||||
WString CodeEditor::GetI()
|
||||
{
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
WString ft;
|
||||
if((GetSelection(l, h) || GetWordPos(GetCursor(), l, h)) && h - l < 60)
|
||||
if((GetSelection(l, h) || GetWordPos(GetCursor64(), l, h)) && h - l < 60)
|
||||
while(l < h) {
|
||||
int c = GetChar(l++);
|
||||
if(c == '\n')
|
||||
|
|
@ -731,7 +736,7 @@ void CodeEditor::SetI(Ctrl *edit)
|
|||
void CodeEditor::Goto() {
|
||||
String line = AsString(GetCursorLine());
|
||||
if(EditText(line, t_("Go to"), t_("Line:")))
|
||||
SetCursor(GetPos(atoi(line) - 1));
|
||||
SetCursor(GetPos64(atoi(line) - 1));
|
||||
}
|
||||
|
||||
bool CodeEditor::ToggleSimpleComment(int &start_line, int &end_line, bool usestars)
|
||||
|
|
@ -739,12 +744,12 @@ bool CodeEditor::ToggleSimpleComment(int &start_line, int &end_line, bool usesta
|
|||
if(IsReadOnly()) return true;
|
||||
|
||||
int l, h;
|
||||
if(!GetSelection(l, h))
|
||||
if(!GetSelection32(l, h))
|
||||
return true;
|
||||
|
||||
int pos = h;
|
||||
start_line = GetLine(l);
|
||||
end_line = GetLinePos(pos);
|
||||
end_line = GetLinePos32(pos);
|
||||
|
||||
if(usestars && start_line == end_line) {
|
||||
Enclose("/*", "*/", l, h);
|
||||
|
|
@ -770,36 +775,36 @@ void CodeEditor::ToggleLineComments(bool usestars)
|
|||
bool is_commented = true;
|
||||
|
||||
if(usestars) {
|
||||
is_commented &= GetChar(GetPos(start_line) + 0) == '/' &&
|
||||
GetChar(GetPos(start_line) + 1) == '*';
|
||||
is_commented &= GetChar(GetPos64(start_line) + 0) == '/' &&
|
||||
GetChar(GetPos64(start_line) + 1) == '*';
|
||||
|
||||
is_commented &= GetChar(GetPos(end_line - 1) + 1) == '*' &&
|
||||
GetChar(GetPos(end_line - 1) + 2) == '/';
|
||||
is_commented &= GetChar(GetPos64(end_line - 1) + 1) == '*' &&
|
||||
GetChar(GetPos64(end_line - 1) + 2) == '/';
|
||||
}
|
||||
|
||||
for(int line = start_line + us; is_commented && (line < end_line - us * 2); ++line)
|
||||
is_commented &= GetChar(GetPos(line)) == (usestars ? ' ' : '/') &&
|
||||
GetChar(GetPos(line)+1) == (usestars ? '*' : '/');
|
||||
is_commented &= GetChar(GetPos64(line)) == (usestars ? ' ' : '/') &&
|
||||
GetChar(GetPos64(line)+1) == (usestars ? '*' : '/');
|
||||
|
||||
if(!is_commented) {
|
||||
|
||||
if(usestars) {
|
||||
Insert(GetPos(end_line)," */\n");
|
||||
Insert(GetPos(start_line),"/*\n");
|
||||
Insert(GetPos32(end_line)," */\n");
|
||||
Insert(GetPos32(start_line),"/*\n");
|
||||
}
|
||||
|
||||
for(int line = start_line + us; line < end_line + us; ++line)
|
||||
Insert(GetPos(line), usestars ? " * " : "//");
|
||||
Insert(GetPos32(line), usestars ? " * " : "//");
|
||||
}
|
||||
else
|
||||
{
|
||||
int line = start_line;
|
||||
if(usestars)
|
||||
Remove(GetPos(start_line), 3);
|
||||
Remove(GetPos32(start_line), 3);
|
||||
for(; line < end_line - us * 2; ++line)
|
||||
Remove(GetPos(line), 2 + us);
|
||||
Remove(GetPos32(line), 2 + us);
|
||||
if(usestars)
|
||||
Remove(GetPos(line), 4);
|
||||
Remove(GetPos32(line), 4);
|
||||
}
|
||||
|
||||
if(usestars)
|
||||
|
|
@ -817,22 +822,22 @@ void CodeEditor::ToggleStarComments()
|
|||
return;
|
||||
|
||||
bool is_commented =
|
||||
GetChar(GetPos(start_line)) == '/' &&
|
||||
GetChar(GetPos(start_line)+1) == '*' &&
|
||||
GetChar(GetPos(start_line)+2) == '\n' &&
|
||||
GetChar(GetPos(end_line-1)) == '*' &&
|
||||
GetChar(GetPos(end_line-1)+1) == '/' &&
|
||||
GetChar(GetPos(end_line-1)+2) == '\n';
|
||||
GetChar(GetPos64(start_line)) == '/' &&
|
||||
GetChar(GetPos64(start_line)+1) == '*' &&
|
||||
GetChar(GetPos64(start_line)+2) == '\n' &&
|
||||
GetChar(GetPos64(end_line-1)) == '*' &&
|
||||
GetChar(GetPos64(end_line-1)+1) == '/' &&
|
||||
GetChar(GetPos64(end_line-1)+2) == '\n';
|
||||
|
||||
if(!is_commented) {
|
||||
// Backwards because inserting changes the end line #
|
||||
Insert(GetPos(end_line),"*/\n");
|
||||
Insert(GetPos(start_line),"/*\n");
|
||||
Insert(GetPos32(end_line),"*/\n");
|
||||
Insert(GetPos32(start_line),"/*\n");
|
||||
SetLineSelection(start_line, end_line+2);
|
||||
} else {
|
||||
// Backwards because inserting changes the end line #
|
||||
Remove(GetPos(end_line-1),3);
|
||||
Remove(GetPos(start_line),3);
|
||||
Remove(GetPos32(end_line-1),3);
|
||||
Remove(GetPos32(start_line),3);
|
||||
SetLineSelection(start_line, end_line-2);
|
||||
}
|
||||
}
|
||||
|
|
@ -841,7 +846,7 @@ void CodeEditor::Enclose(const char *c1, const char *c2, int l, int h)
|
|||
{
|
||||
if(IsReadOnly()) return;
|
||||
|
||||
if((l < 0 || h < 0) && !GetSelection(l, h))
|
||||
if((l < 0 || h < 0) && !GetSelection32(l, h))
|
||||
return;
|
||||
Insert(l, WString(c1));
|
||||
Insert(h + (int)strlen(c1), WString(c2));
|
||||
|
|
@ -870,7 +875,7 @@ bool CodeEditor::Key(dword code, int count) {
|
|||
return true;
|
||||
case K_BACKSPACE:
|
||||
if(!IsReadOnly() && !IsAnySelection() && indent_spaces) {
|
||||
int c = GetCursor();
|
||||
int c = GetCursor32();
|
||||
Point ixln = GetIndexLine(c);
|
||||
WString ln = GetWLine(ixln.y);
|
||||
bool white = true;
|
||||
|
|
@ -947,7 +952,7 @@ bool CodeEditor::Key(dword code, int count) {
|
|||
return true;
|
||||
}
|
||||
if(!sel && indent_spaces) {
|
||||
int x = GetColumnLine(GetCursor()).x;
|
||||
int x = GetColumnLine(GetCursor64()).x;
|
||||
int add = GetTabSize() - x % GetTabSize();
|
||||
InsertChar(' ', add, false);
|
||||
return true;
|
||||
|
|
@ -989,13 +994,13 @@ bool CodeEditor::Key(dword code, int count) {
|
|||
}
|
||||
if(wordwrap && code > 0 && code < 65535) {
|
||||
int limit = GetBorderColumn();
|
||||
int pos = GetCursor();
|
||||
int pos = GetCursor32();
|
||||
int lp = pos;
|
||||
int l = GetLinePos(lp);
|
||||
int l = GetLinePos32(lp);
|
||||
if(limit > 10 && GetColumnLine(pos).x >= limit && lp == GetLineLength(l)) {
|
||||
int lp0 = GetPos(l);
|
||||
int lp0 = GetPos32(l);
|
||||
WString ln = GetWLine(l);
|
||||
int wl = GetGPos(l, limit) - lp0;
|
||||
int wl = (int)GetGPos(l, limit) - lp0;
|
||||
while(wl > 0 && ln[wl - 1] != ' ')
|
||||
wl--;
|
||||
int sl = wl - 1;
|
||||
|
|
@ -1036,7 +1041,7 @@ void CodeEditor::ForwardWhenBreakpoint(int i) {
|
|||
|
||||
void CodeEditor::GotoLine(int line)
|
||||
{
|
||||
SetCursor(GetPos(GetLineNo(line)));
|
||||
SetCursor(GetPos64(GetLineNo(line)));
|
||||
}
|
||||
|
||||
void CodeEditor::Serialize(Stream& s) {
|
||||
|
|
@ -1050,7 +1055,7 @@ void CodeEditor::SetLineInfo(const LineInfo& lf)
|
|||
bar.SetLineInfo(lf, GetLineCount());
|
||||
}
|
||||
|
||||
void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int pos)
|
||||
void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int64 pos)
|
||||
{
|
||||
CTIMING("HighlightLine");
|
||||
HighlightOutput hls(hl);
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public:
|
|||
virtual void MouseWheel(Point p, int zdelta, dword keyFlags);
|
||||
|
||||
protected:
|
||||
virtual void HighlightLine(int line, Vector<LineEdit::Highlight>& h, int pos);
|
||||
virtual void HighlightLine(int line, Vector<LineEdit::Highlight>& h, int64 pos);
|
||||
virtual void PreInsert(int pos, const WString& s);
|
||||
virtual void PostInsert(int pos, const WString& s);
|
||||
virtual void PreRemove(int pos, int size);
|
||||
|
|
@ -226,10 +226,10 @@ protected:
|
|||
// EditorSyntax rm_ins;
|
||||
|
||||
char rmb;
|
||||
int highlight_bracket_pos0;
|
||||
int highlight_bracket_pos;
|
||||
int64 highlight_bracket_pos0;
|
||||
int64 highlight_bracket_pos;
|
||||
bool bracket_flash;
|
||||
int bracket_start;
|
||||
int64 bracket_start;
|
||||
|
||||
bool barline;
|
||||
double stat_edit_time;
|
||||
|
|
@ -264,7 +264,8 @@ protected:
|
|||
WString foundtext;
|
||||
bool foundsel;
|
||||
bool found, notfoundfw, notfoundbk;
|
||||
int foundpos, foundsize;
|
||||
int64 foundpos;
|
||||
int foundsize;
|
||||
|
||||
enum { SEL_CHARS, SEL_WORDS, SEL_LINES };
|
||||
int selkind;
|
||||
|
|
@ -291,12 +292,16 @@ protected:
|
|||
int tippos;
|
||||
|
||||
int replacei;
|
||||
|
||||
bool search_canceled;
|
||||
int search_time0;
|
||||
One<Progress> search_progress;
|
||||
|
||||
struct HlSt;
|
||||
|
||||
bool MouseSelSpecial(Point p, dword flags);
|
||||
void InitFindReplace();
|
||||
void CancelBracketHighlight(int& pos);
|
||||
void CancelBracketHighlight(int64& pos);
|
||||
void FindPrevNext(bool prev);
|
||||
void CheckBrackets();
|
||||
void OpenNormalFindReplace0(bool replace);
|
||||
|
|
@ -308,7 +313,7 @@ protected:
|
|||
void IncrementalFind();
|
||||
void NotFound();
|
||||
void NoFindError();
|
||||
void CheckSyntaxRefresh(int pos, const WString& text);
|
||||
void CheckSyntaxRefresh(int64 pos, const WString& text);
|
||||
|
||||
void SetFound(int fi, int type, const WString& text);
|
||||
|
||||
|
|
@ -337,6 +342,11 @@ protected:
|
|||
|
||||
void Periodic();
|
||||
|
||||
void StartSearchProgress(int64 l, int64 h);
|
||||
bool SearchProgress(int line);
|
||||
bool SearchCanceled();
|
||||
void EndSearchProgress();
|
||||
|
||||
public:
|
||||
struct MouseTip {
|
||||
int pos;
|
||||
|
|
@ -348,7 +358,7 @@ public:
|
|||
Event<> WhenSelection;
|
||||
Gate<MouseTip&> WhenTip;
|
||||
Event<> WhenLeftDown;
|
||||
Event<int> WhenCtrlClick;
|
||||
Event<int64> WhenCtrlClick;
|
||||
Event<> WhenAnnotationMove;
|
||||
Event<> WhenAnnotationClick;
|
||||
Event<> WhenAnnotationRightClick;
|
||||
|
|
@ -356,7 +366,7 @@ public:
|
|||
Event<String&> WhenPaste;
|
||||
Event<> WhenUpdate;
|
||||
|
||||
Event<const Vector<Tuple<int, int>>&> WhenFindAll;
|
||||
Event<const Vector<Tuple<int64, int>>&> WhenFindAll;
|
||||
|
||||
FrameTop<Button> topsbbutton;
|
||||
FrameTop<Button> topsbbutton1;
|
||||
|
|
@ -374,14 +384,14 @@ public:
|
|||
void CloseFindReplace();
|
||||
void FindReplace(bool pick_selection, bool pick_text, bool replace);
|
||||
void FindAll();
|
||||
bool FindFrom(int pos, bool back, bool block);
|
||||
bool RegExpFind(int pos, bool block);
|
||||
bool FindFrom(int64 pos, bool back, bool block);
|
||||
bool RegExpFind(int64 pos, bool block);
|
||||
bool Find(bool back, bool block);
|
||||
bool Find(bool back, bool blockreplace, bool replace);
|
||||
void FindNext();
|
||||
void FindPrev();
|
||||
bool GetStringRange(int cursor, int& b, int &e) const;
|
||||
bool GetStringRange(int& b, int &e) const { return GetStringRange(GetCursor(), b, e); }
|
||||
bool GetStringRange(int64 cursor, int64& b, int64& e) const;
|
||||
bool GetStringRange(int64& b, int64& e) const { return GetStringRange(GetCursor64(), b, e); }
|
||||
bool FindString(bool back);
|
||||
bool FindLangString(bool back);
|
||||
void Replace();
|
||||
|
|
@ -416,10 +426,10 @@ public:
|
|||
void MoveNextBrk(bool sel);
|
||||
void MovePrevBrk(bool sel);
|
||||
|
||||
String GetWord(int pos);
|
||||
String GetWord(int64 pos);
|
||||
String GetWord();
|
||||
|
||||
bool GetWordPos(int pos, int& l, int& h);
|
||||
bool GetWordPos(int64 pos, int64& l, int64& h);
|
||||
|
||||
void DeleteWord();
|
||||
void DeleteWordBack();
|
||||
|
|
@ -506,8 +516,8 @@ public:
|
|||
void Illuminate(const WString& text) { illuminated = text; Refresh(); }
|
||||
|
||||
One<EditorSyntax> GetSyntax(int line);
|
||||
bool IsCursorBracket(int pos) const;
|
||||
bool IsMatchingBracket(int pos) const;
|
||||
bool IsCursorBracket(int64 pos) const;
|
||||
bool IsMatchingBracket(int64 pos) const;
|
||||
|
||||
// TODO: Do we really need this ?
|
||||
Vector<IfState> GetIfStack(int line) { return GetSyntax(line)->PickIfStack(); }
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ file
|
|||
HighlightOut.cpp,
|
||||
Syntax.cpp,
|
||||
Style.cpp,
|
||||
RegisterSyntax.cpp,
|
||||
CSyntax readonly separator,
|
||||
CSyntax.h,
|
||||
CSyntax.cpp,
|
||||
CInit.cpp,
|
||||
CHighlight.cpp,
|
||||
CLogic.cpp,
|
||||
RegisterSyntax.cpp,
|
||||
DiffSyntax readonly separator,
|
||||
DiffSyntax.h,
|
||||
DiffSyntax.cpp,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ DiffSyntax::DiffSyntax()
|
|||
hout = NULL;
|
||||
}
|
||||
|
||||
void DiffSyntax::Highlight(const wchar *start, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
|
||||
void DiffSyntax::Highlight(const wchar *start, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int64 pos)
|
||||
{
|
||||
hout = &hls;
|
||||
Do(start, end, editor, line, editor ? editor->GetTabSize() : 4, pos);
|
||||
|
|
@ -20,7 +20,7 @@ void DiffSyntax::Put(int ink, int n, int paper)
|
|||
hout->Put(n, hl_style[ink], hl_style[paper]);
|
||||
}
|
||||
|
||||
void DiffSyntax::Do(const wchar *ln, const wchar *end, CodeEditor *editor, int line, int tabsize, int pos)
|
||||
void DiffSyntax::Do(const wchar *ln, const wchar *end, CodeEditor *editor, int line, int tabsize, int64 pos)
|
||||
{
|
||||
const int lineLength = FindTheNumberOfCharsToLineEnd(ln, end);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ public:
|
|||
DiffSyntax();
|
||||
|
||||
virtual void Highlight(const wchar *start, const wchar *end, HighlightOutput& hls,
|
||||
CodeEditor *editor, int line, int pos);
|
||||
CodeEditor *editor, int line, int64 pos);
|
||||
|
||||
protected:
|
||||
void Put(int ink, int n = 1, int paper = PAPER_NORMAL);
|
||||
void Do(const wchar *s, const wchar *end, CodeEditor *editor, int line, int tabsize, int pos);
|
||||
void Do(const wchar *s, const wchar *end, CodeEditor *editor, int line, int tabsize, int64 pos);
|
||||
|
||||
int FindTheNumberOfCharsToLineEnd(const wchar *current, const wchar *end) const;
|
||||
bool IsPattern(const wchar *current, const wchar *end, String pattern) const;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,8 @@ String& EditorBar::PointBreak(int& y)
|
|||
{
|
||||
y = minmax(y / editor->GetFont().Info().GetHeight()
|
||||
+ editor->GetScrollPos().y, 0, editor->GetLineCount());
|
||||
return li.At(y).breakpoint;
|
||||
static String e;
|
||||
return y < 100000 ? li.At(y).breakpoint : e;
|
||||
}
|
||||
|
||||
void EditorBar::LeftDouble(Point p, dword flags)
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ bool CodeEditor::Find(bool back, bool block)
|
|||
if(notfoundfw) MoveTextBegin();
|
||||
if(notfoundbk) MoveTextEnd();
|
||||
foundsel = false;
|
||||
int cursor, pos;
|
||||
int64 cursor, pos;
|
||||
if(found)
|
||||
GetSelection(pos, cursor);
|
||||
else
|
||||
|
|
@ -207,20 +207,19 @@ bool CodeEditor::Find(bool back, bool block)
|
|||
return b;
|
||||
}
|
||||
|
||||
bool CodeEditor::RegExpFind(int pos, bool block)
|
||||
bool CodeEditor::RegExpFind(int64 pos, bool block)
|
||||
{
|
||||
RegExp regex((String)~findreplace.find);
|
||||
|
||||
int line = GetLinePos(pos);
|
||||
int linecount = GetLineCount();
|
||||
String ln = ToUtf8(GetWLine(line).Mid(pos));
|
||||
int line = GetLinePos64(pos);
|
||||
String ln = ToUtf8(GetWLine(line).Mid(LimitSize(pos)));
|
||||
for(;;) {
|
||||
if(regex.Match(ln)) {
|
||||
for(int i = 0; i < regex.GetCount(); i++)
|
||||
SetFound(i, WILDANY, regex.GetString(i).ToWString());
|
||||
int off = regex.GetOffset();
|
||||
int len = utf8len(~ln + off, regex.GetLength());
|
||||
pos = GetPos(line, utf8len(~ln, off) + pos);
|
||||
pos = GetPos64(line, utf8len(~ln, off) + (int)pos);
|
||||
foundtext = GetW(pos, len);
|
||||
if(!block) {
|
||||
foundsel = true;
|
||||
|
|
@ -233,16 +232,21 @@ bool CodeEditor::RegExpFind(int pos, bool block)
|
|||
found = true;
|
||||
return true;
|
||||
}
|
||||
if(++line >= linecount)
|
||||
return false;
|
||||
if(++line >= GetLineCount()) {
|
||||
WaitView(line);
|
||||
if(line >= GetLineCount())
|
||||
return false;
|
||||
}
|
||||
ln = GetUtf8Line(line);
|
||||
pos = 0;
|
||||
if(!SearchProgress(line))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEditor::FindAll()
|
||||
{
|
||||
Vector<Tuple<int, int>> found;
|
||||
Vector<Tuple<int64, int>> found;
|
||||
foundpos = 0;
|
||||
while(FindFrom(foundpos, false, true)) {
|
||||
found.Add(MakeTuple(foundpos, foundsize));
|
||||
|
|
@ -255,7 +259,7 @@ void CodeEditor::FindAll()
|
|||
WhenFindAll(found);
|
||||
}
|
||||
|
||||
bool CodeEditor::FindFrom(int pos, bool back, bool block)
|
||||
bool CodeEditor::FindFrom(int64 pos, bool back, bool block)
|
||||
{
|
||||
notfoundbk = notfoundfw = false;
|
||||
if(findreplace.regexp) {
|
||||
|
|
@ -302,8 +306,7 @@ bool CodeEditor::FindFrom(int pos, bool back, bool block)
|
|||
bool we = findreplace.wholeword ? iscidl(*ft.Last()) : false;
|
||||
if(ft.IsEmpty()) return false;
|
||||
foundwild.Clear();
|
||||
int line = GetLinePos(pos);
|
||||
int linecount = GetLineCount();
|
||||
int line = GetLinePos64(pos);
|
||||
WString ln = GetWLine(line);
|
||||
const wchar *l = ln;
|
||||
s = l + pos;
|
||||
|
|
@ -313,7 +316,7 @@ bool CodeEditor::FindFrom(int pos, bool back, bool block)
|
|||
if(!wb || (s == l || !iscidl(s[-1]))) {
|
||||
int n = Match(ft, s, line, we, ignorecase);
|
||||
if(n >= 0) {
|
||||
int pos = GetPos(line, int(s - l));
|
||||
int64 pos = GetPos64(line, int(s - l));
|
||||
foundtext = GetW(pos, n);
|
||||
if(!back || pos + n < cursor) {
|
||||
if(!block) {
|
||||
|
|
@ -342,10 +345,16 @@ bool CodeEditor::FindFrom(int pos, bool back, bool block)
|
|||
s = ln.End();
|
||||
}
|
||||
else {
|
||||
if(++line >= linecount) break;
|
||||
if(++line >= GetLineCount()) {
|
||||
WaitView(line);
|
||||
if(line >= GetLineCount())
|
||||
break;
|
||||
}
|
||||
ln = GetWLine(line);
|
||||
l = s = ln;
|
||||
}
|
||||
if(!SearchProgress(back ? GetLineCount() - line : line))
|
||||
break;
|
||||
}
|
||||
if(back)
|
||||
notfoundbk = true;
|
||||
|
|
@ -535,21 +544,18 @@ int CodeEditor::BlockReplace()
|
|||
NextUndo();
|
||||
Refresh(); // Setting full-refresh here avoids Pre/Post Remove/Insert costs
|
||||
int l, h;
|
||||
if(!GetSelection(l, h)) return 0;
|
||||
if(!GetSelection32(l, h)) return 0;
|
||||
PlaceCaret(l);
|
||||
int count = 0;
|
||||
foundpos = l;
|
||||
Index<int> ln;
|
||||
Progress pi("Searching...");
|
||||
StartSearchProgress(l, h);
|
||||
while(FindFrom(foundpos, false, true) && foundpos + foundsize <= h) {
|
||||
pi.Set(foundpos - l, h - l);
|
||||
if(pi.Canceled())
|
||||
return count;
|
||||
CachePos(foundpos);
|
||||
if(~findreplace.mode == 0) {
|
||||
Remove(foundpos, foundsize);
|
||||
Remove((int)foundpos, foundsize);
|
||||
WString rt = GetReplaceText();
|
||||
Insert(foundpos, rt);
|
||||
Insert((int)foundpos, rt);
|
||||
foundpos += rt.GetCount();
|
||||
h = h - foundsize + rt.GetCount();
|
||||
count++;
|
||||
|
|
@ -559,12 +565,15 @@ int CodeEditor::BlockReplace()
|
|||
foundpos += foundsize;
|
||||
}
|
||||
}
|
||||
if(SearchCanceled())
|
||||
return count;
|
||||
EndSearchProgress();
|
||||
Progress pi("Removing lines");
|
||||
if(~findreplace.mode != 0) {
|
||||
pi.SetText("Removing lines");
|
||||
ClearSelection();
|
||||
int ll = GetLine(l);
|
||||
int lh = GetLine(h);
|
||||
if(GetPos(lh) == h)
|
||||
if(GetPos64(lh) == h)
|
||||
lh--;
|
||||
bool mm = ~findreplace.mode == 1;
|
||||
String replace;
|
||||
|
|
@ -578,8 +587,8 @@ int CodeEditor::BlockReplace()
|
|||
count++;
|
||||
}
|
||||
}
|
||||
int pos = GetPos(ll);
|
||||
Remove(pos, GetPos(GetLine(h)) - pos);
|
||||
int pos = GetPos32(ll);
|
||||
Remove(pos, GetPos32(GetLine(h)) - pos);
|
||||
SetSelection(pos, pos + Insert(pos, replace));
|
||||
}
|
||||
else
|
||||
|
|
@ -589,7 +598,7 @@ int CodeEditor::BlockReplace()
|
|||
|
||||
void CodeEditor::OpenNormalFindReplace0(bool replace)
|
||||
{
|
||||
findreplace.incremental.Enable(GetLength() < 2000000);
|
||||
findreplace.incremental.Enable(GetLength64() < 2000000);
|
||||
findreplace.Setup(replace);
|
||||
findreplace.find_all.Show(!replace && WhenFindAll);
|
||||
findreplace.itext = GetI();
|
||||
|
|
@ -617,7 +626,7 @@ void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace)
|
|||
if(findreplace.IsOpen())
|
||||
CloseFindReplace();
|
||||
|
||||
ff_start_pos = GetCursor();
|
||||
ff_start_pos = GetCursor32();
|
||||
|
||||
replacei = 0;
|
||||
WString find_text;
|
||||
|
|
@ -629,7 +638,7 @@ void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace)
|
|||
{
|
||||
if(IsSelection()) {
|
||||
int l, h;
|
||||
GetSelection(l, h);
|
||||
GetSelection32(l, h);
|
||||
if(h - l < 100) {
|
||||
find_text = GetSelectionW();
|
||||
if(find_text.Find('\n') >= 0)
|
||||
|
|
@ -639,10 +648,10 @@ void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace)
|
|||
else
|
||||
if(pick_text) {
|
||||
int l, h;
|
||||
l = h = GetCursor();
|
||||
l = h = GetCursor32();
|
||||
while(l > 0 && CharFilterCIdent(GetChar(l - 1)))
|
||||
l--;
|
||||
while(h < GetLength() && CharFilterCIdent(GetChar(h)))
|
||||
while(h < GetLength64() && CharFilterCIdent(GetChar(h)))
|
||||
h++;
|
||||
find_text = Get(l, h - l).ToWString();
|
||||
find_pos = h;
|
||||
|
|
@ -684,10 +693,10 @@ void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace)
|
|||
void CodeEditor::ReplaceAll(bool rest)
|
||||
{
|
||||
int l, h;
|
||||
GetSelection(l, h);
|
||||
GetSelection32(l, h);
|
||||
int c = min(l, h);
|
||||
findreplace.mode <<= 0;
|
||||
SetSelection(rest * c, GetLength());
|
||||
SetSelection(rest * c, GetLength64());
|
||||
BlockReplace();
|
||||
SetCursor(c);
|
||||
}
|
||||
|
|
@ -794,7 +803,7 @@ void CodeEditor::CloseFindReplace()
|
|||
void CodeEditor::EscapeFindReplace()
|
||||
{
|
||||
CloseFindReplace();
|
||||
if(ff_start_pos >= 0 && ff_start_pos < GetLength() && findreplace.IsIncremental() && do_ff_restore_pos) {
|
||||
if(ff_start_pos >= 0 && ff_start_pos < GetLength64() && findreplace.IsIncremental() && do_ff_restore_pos) {
|
||||
SetCursor(ff_start_pos);
|
||||
ff_start_pos = -1;
|
||||
}
|
||||
|
|
@ -806,8 +815,8 @@ void CodeEditor::IncrementalFind()
|
|||
findreplace.Sync();
|
||||
if(!findreplace.IsIncremental() || findreplace.GetTopCtrl() == &findreplace) // || we are block replace
|
||||
return;
|
||||
bool b = FindFrom(ff_start_pos >= 0 && ff_start_pos < GetLength()
|
||||
&& findreplace.incremental_from_cursor ? ff_start_pos : 0, false, false);
|
||||
bool b = FindFrom(ff_start_pos >= 0 && ff_start_pos < GetLength64()
|
||||
&& findreplace.incremental_from_cursor ? ff_start_pos : 0, false, false);
|
||||
findreplace.amend.Enable(b);
|
||||
if(!b)
|
||||
NotFound();
|
||||
|
|
@ -884,11 +893,12 @@ void CodeEditor::SetFindReplaceData(const FindReplaceData& r)
|
|||
|
||||
void CodeEditor::FindPrevNext(bool prev)
|
||||
{
|
||||
StartSearchProgress(-1, -1);
|
||||
if(!findreplace.IsOpen()) {
|
||||
WString find_text;
|
||||
if(IsSelection()) {
|
||||
int l, h;
|
||||
GetSelection(l, h);
|
||||
GetSelection32(l, h);
|
||||
if(h - l < 100) {
|
||||
find_text = GetSelectionW();
|
||||
if(find_text.Find('\n') >= 0)
|
||||
|
|
@ -903,6 +913,7 @@ void CodeEditor::FindPrevNext(bool prev)
|
|||
NoFindError();
|
||||
else
|
||||
NotFound();
|
||||
EndSearchProgress();
|
||||
}
|
||||
|
||||
void CodeEditor::FindNext()
|
||||
|
|
@ -915,4 +926,35 @@ void CodeEditor::FindPrev()
|
|||
FindPrevNext(true);
|
||||
}
|
||||
|
||||
void CodeEditor::StartSearchProgress(int64, int64)
|
||||
{
|
||||
search_canceled = false;
|
||||
search_time0 = msecs();
|
||||
}
|
||||
|
||||
bool CodeEditor::SearchProgress(int line)
|
||||
{
|
||||
if(!search_canceled && msecs(search_time0) > 20) {
|
||||
search_time0 = msecs();
|
||||
if(!search_progress) {
|
||||
search_progress.Create().Create();
|
||||
search_progress->SetText("Scanning the file");
|
||||
}
|
||||
search_canceled = IsView() ? search_progress->SetCanceled(int(GetPos64(line) >> 8), int(GetViewSize() >> 8))
|
||||
: search_progress->SetCanceled(line, GetLineCount());
|
||||
}
|
||||
return !search_canceled;
|
||||
}
|
||||
|
||||
bool CodeEditor::SearchCanceled()
|
||||
{
|
||||
return search_canceled;
|
||||
}
|
||||
|
||||
void CodeEditor::EndSearchProgress()
|
||||
{
|
||||
search_progress.Clear();
|
||||
search_canceled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,10 +77,10 @@ Vector<Point> GetLineString(const wchar *wline, bool& is_begin, bool& is_end)
|
|||
return out;
|
||||
}
|
||||
|
||||
bool CodeEditor::GetStringRange(int cursor, int& b, int &e) const
|
||||
bool CodeEditor::GetStringRange(int64 cursor, int64& b, int64& e) const
|
||||
{
|
||||
int cl = GetLine(cursor);
|
||||
cursor -= GetPos(cl);
|
||||
cursor -= GetPos64(cl);
|
||||
bool is_begin, is_end; //@@@@@@
|
||||
Vector<Point> list = GetLineString(GetWLine(cl), is_begin, is_end);
|
||||
int i = list.GetCount();
|
||||
|
|
@ -106,17 +106,19 @@ bool CodeEditor::GetStringRange(int cursor, int& b, int &e) const
|
|||
el++;
|
||||
ep = list[0].y;
|
||||
}
|
||||
b = GetPos(bl, bp);
|
||||
e = GetPos(el, ep);
|
||||
b = GetPos64(bl, bp);
|
||||
e = GetPos64(el, ep);
|
||||
return b < e;
|
||||
}
|
||||
|
||||
bool CodeEditor::FindString(bool back)
|
||||
{
|
||||
int l, h;
|
||||
if(!GetSelection(l, h)) h = GetCursor();
|
||||
else h = (back ? l : h);
|
||||
h -= GetPos(l = GetLine(h));
|
||||
int64 ll, hh;
|
||||
hh = GetSelection(ll, hh) ? back ? ll : hh
|
||||
: GetCursor64();
|
||||
int l = GetLine(hh);
|
||||
int h = LimitSize(hh - GetPos64(l));
|
||||
|
||||
while(l >= 0 && l < GetLineCount())
|
||||
{
|
||||
bool is_begin, is_end;
|
||||
|
|
@ -148,8 +150,8 @@ bool CodeEditor::FindString(bool back)
|
|||
++l;
|
||||
}
|
||||
}
|
||||
int b, e;
|
||||
if(l < 0 || l >= GetLineCount() || !GetStringRange(GetPos(l, h), b, e))
|
||||
int64 b, e;
|
||||
if(l < 0 || l >= GetLineCount() || !GetStringRange(GetPos64(l, h), b, e))
|
||||
return false;
|
||||
SetSelection(b, e);
|
||||
return true;
|
||||
|
|
@ -157,14 +159,16 @@ bool CodeEditor::FindString(bool back)
|
|||
|
||||
bool CodeEditor::FindLangString(bool back)
|
||||
{
|
||||
int l, h;
|
||||
if(!GetSelection(l, h)) h = GetCursor();
|
||||
else h = (back ? l : h);
|
||||
h -= GetPos(l = GetLine(h));
|
||||
int64 ll, hh;
|
||||
hh = GetSelection(ll, hh) ? back ? ll : hh
|
||||
: GetCursor64();
|
||||
int l = GetLine(hh);
|
||||
int h = LimitSize(hh - GetPos64(l));
|
||||
|
||||
for(;;)
|
||||
{
|
||||
Array<IdentPos> list = GetLineIdent(GetUtf8Line(l));
|
||||
int b, e;
|
||||
int64 b, e;
|
||||
if(back)
|
||||
{
|
||||
int i = list.GetCount();
|
||||
|
|
@ -177,8 +181,8 @@ bool CodeEditor::FindLangString(bool back)
|
|||
break;
|
||||
continue;
|
||||
}
|
||||
b = GetPos(l, list[i].begin);
|
||||
e = GetPos(l, list[i].end);
|
||||
b = GetPos64(l, list[i].begin);
|
||||
e = GetPos64(l, list[i].end);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -192,8 +196,8 @@ bool CodeEditor::FindLangString(bool back)
|
|||
break;
|
||||
continue;
|
||||
}
|
||||
b = GetPos(l, list[i].begin);
|
||||
e = GetPos(l, list[i].end);
|
||||
b = GetPos64(l, list[i].begin);
|
||||
e = GetPos64(l, list[i].end);
|
||||
}
|
||||
SetSelection(b, e);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ inline bool Is3(const wchar *s, int c)
|
|||
return s[0] == c && s[1] == c && s[2] == c;
|
||||
}
|
||||
|
||||
void LogSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
|
||||
void LogSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int64 pos)
|
||||
{
|
||||
const HlStyle& ink = hl_style[INK_NORMAL];
|
||||
HlStyle err = hl_style[INK_ERROR];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class LogSyntax : public EditorSyntax {
|
||||
public:
|
||||
virtual void Highlight(const wchar *s, const wchar *end, HighlightOutput& hls,
|
||||
CodeEditor *editor, int line, int pos);
|
||||
CodeEditor *editor, int line, int64 pos);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Upp {
|
|||
|
||||
PythonSyntax::PythonSyntax() {}
|
||||
|
||||
void PythonSyntax::Highlight(const wchar *start, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
|
||||
void PythonSyntax::Highlight(const wchar *start, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int64 pos)
|
||||
{
|
||||
InitKeywords();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
PythonSyntax();
|
||||
|
||||
virtual void Highlight(const wchar *start, const wchar *end, HighlightOutput& hls,
|
||||
CodeEditor *editor, int line, int pos);
|
||||
CodeEditor *editor, int line, int64 pos);
|
||||
virtual void IndentInsert(CodeEditor& e, int chr, int count);
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ void EditorSyntax::IndentInsert(CodeEditor& editor, int chr, int count)
|
|||
editor.InsertChar(chr, count);
|
||||
}
|
||||
|
||||
bool EditorSyntax::CheckBrackets(CodeEditor& e, int& bpos0, int& bpos)
|
||||
bool EditorSyntax::CheckBrackets(CodeEditor& e, int64& bpos0, int64& bpos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ void EditorSyntax::ReformatComment(CodeEditor& e)
|
|||
{
|
||||
}
|
||||
|
||||
void EditorSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
|
||||
void EditorSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int64 pos)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ Color EditorSyntax::IfColor(char c)
|
|||
}
|
||||
}
|
||||
|
||||
void EditorSyntax::CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text)
|
||||
void EditorSyntax::CheckSyntaxRefresh(CodeEditor& e, int64 pos, const WString& text)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,11 +111,11 @@ public:
|
|||
virtual void ScanSyntax(const wchar *ln, const wchar *e, int line, int tab_size);
|
||||
virtual void Serialize(Stream& s);
|
||||
virtual void IndentInsert(CodeEditor& editor, int chr, int count);
|
||||
virtual bool CheckBrackets(CodeEditor& e, int& bpos0, int& bpos); // TODO: Replace with generic mechanism
|
||||
virtual void CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text);
|
||||
virtual bool CheckBrackets(CodeEditor& e, int64& bpos0, int64& bpos); // TODO: Replace with generic mechanism
|
||||
virtual void CheckSyntaxRefresh(CodeEditor& e, int64 pos, const WString& text);
|
||||
virtual bool CanAssist() const;
|
||||
virtual void Highlight(const wchar *s, const wchar *end, HighlightOutput& hls,
|
||||
CodeEditor *editor, int line, int pos);
|
||||
CodeEditor *editor, int line, int64 pos);
|
||||
virtual Vector<IfState> PickIfStack();
|
||||
virtual void ReformatComment(CodeEditor& e);
|
||||
virtual ~EditorSyntax();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const wchar *TagSyntax::Spaces(const wchar *s, const wchar *e)
|
|||
return s;
|
||||
}
|
||||
|
||||
void TagSyntax::DoScript(const wchar *s, const wchar *e, CodeEditor *editor, int line, int tabsize, int pos)
|
||||
void TagSyntax::DoScript(const wchar *s, const wchar *e, CodeEditor *editor, int line, int tabsize, int64 pos)
|
||||
{
|
||||
if(hout)
|
||||
script.Highlight(s, e, *hout, editor, line, pos);
|
||||
|
|
@ -99,7 +99,7 @@ const wchar *IsScriptEnd(const wchar *s, const wchar *e, bool script)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void TagSyntax::Do(const wchar *s, const wchar *e, CodeEditor *editor, int line, int tabsize, int pos)
|
||||
void TagSyntax::Do(const wchar *s, const wchar *e, CodeEditor *editor, int line, int tabsize, int64 pos)
|
||||
{
|
||||
doscript:
|
||||
if(status == SCRIPT) {
|
||||
|
|
@ -245,7 +245,7 @@ doscript:
|
|||
}
|
||||
}
|
||||
|
||||
void TagSyntax::CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text)
|
||||
void TagSyntax::CheckSyntaxRefresh(CodeEditor& e, int64 pos, const WString& text)
|
||||
{
|
||||
script.CheckSyntaxRefresh(e, pos, text);
|
||||
for(const wchar *s = text; *s; s++)
|
||||
|
|
@ -253,13 +253,13 @@ void TagSyntax::CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text)
|
|||
e.Refresh();
|
||||
return;
|
||||
}
|
||||
int l = max(pos - 6, 0);
|
||||
int h = min(pos + text.GetLength() + 6, e.GetLength());
|
||||
int64 l = max(pos - 6, (int64)0);
|
||||
int64 h = min(pos + text.GetLength() + 6, e.GetLength64());
|
||||
if(h - l > 200) {
|
||||
e.Refresh();
|
||||
return;
|
||||
}
|
||||
WString w = ToLower(e.GetW(l, h - l));
|
||||
WString w = ToLower(e.GetW(l, e.LimitSize(h - l)));
|
||||
if(w.Find("style") >= 0 || w.Find("script") >= 0)
|
||||
e.Refresh();
|
||||
}
|
||||
|
|
@ -269,7 +269,7 @@ void TagSyntax::ScanSyntax(const wchar *s, const wchar *e, int line, int tabsize
|
|||
Do(s, e, NULL, line, tabsize, 0);
|
||||
}
|
||||
|
||||
void TagSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
|
||||
void TagSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int64 pos)
|
||||
{
|
||||
hout = &hls;
|
||||
Do(s, end, editor, line, editor ? editor->GetTabSize() : 4, pos);
|
||||
|
|
@ -284,7 +284,7 @@ void TagSyntax::IndentInsert(CodeEditor& editor, int chr, int count)
|
|||
editor.InsertChar(chr, count);
|
||||
}
|
||||
|
||||
bool TagSyntax::CheckBrackets(CodeEditor& e, int& bpos0, int& bpos)
|
||||
bool TagSyntax::CheckBrackets(CodeEditor& e, int64& bpos0, int64& bpos)
|
||||
{
|
||||
if(status == SCRIPT)
|
||||
return script.CheckBrackets(e, bpos0, bpos);
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ public:
|
|||
virtual void ScanSyntax(const wchar *ln, const wchar *e, int line, int tab_size);
|
||||
virtual void Serialize(Stream& s);
|
||||
virtual void Highlight(const wchar *s, const wchar *end, HighlightOutput& hls,
|
||||
CodeEditor *editor, int line, int pos);
|
||||
virtual void CheckSyntaxRefresh(CodeEditor& e, int pos, const WString& text);
|
||||
CodeEditor *editor, int line, int64 pos);
|
||||
virtual void CheckSyntaxRefresh(CodeEditor& e, int64 pos, const WString& text);
|
||||
virtual void IndentInsert(CodeEditor& editor, int chr, int count);
|
||||
virtual bool CheckBrackets(CodeEditor& e, int& bpos0, int& bpos);
|
||||
virtual bool CheckBrackets(CodeEditor& e, int64& bpos0, int64& bpos);
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -27,8 +27,8 @@ private:
|
|||
HighlightOutput *hout;
|
||||
|
||||
const wchar *Spaces(const wchar *s, const wchar *e);
|
||||
void DoScript(const wchar *s, const wchar *e, CodeEditor *editor, int line, int tabsize, int pos);
|
||||
void Do(const wchar *ln, const wchar *e, CodeEditor *editor, int line, int tabsize, int pos);
|
||||
void DoScript(const wchar *s, const wchar *e, CodeEditor *editor, int line, int tabsize, int64 pos);
|
||||
void Do(const wchar *s, const wchar *e, CodeEditor *editor, int line, int tabsize, int64 pos);
|
||||
void Put0(int ink, int n = 1, int paper = PAPER_NORMAL);
|
||||
|
||||
void Set(int ink, int paper = PAPER_NORMAL) { hl_ink = ink; hl_paper = paper; }
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ class String0 : Moveable<String0> {
|
|||
friend class String;
|
||||
friend class StringBuffer;
|
||||
friend class Value;
|
||||
friend class TextCtrl;
|
||||
|
||||
protected:
|
||||
// void Zero() { q[0] = q[1] = 0; Dsyn(); }
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ void DocEdit::MouseWheel(Point p, int zdelta, dword keyflags)
|
|||
void DocEdit::ClearLines()
|
||||
{
|
||||
para.Clear();
|
||||
ASSERT(this->line.GetCount() == para.GetCount());
|
||||
ASSERT(GetLineCount() == para.GetCount());
|
||||
}
|
||||
|
||||
void DocEdit::InsertLines(int line, int count)
|
||||
{
|
||||
para.Insert(line, Para(), count);
|
||||
ASSERT(this->line.GetCount() == para.GetCount());
|
||||
ASSERT(GetLineCount() == para.GetCount());
|
||||
}
|
||||
|
||||
void DocEdit::RemoveLines(int line, int count)
|
||||
{
|
||||
para.Remove(line, count);
|
||||
ASSERT(this->line.GetCount() == para.GetCount());
|
||||
ASSERT(GetLineCount() == para.GetCount());
|
||||
}
|
||||
|
||||
DocEdit::Fmt DocEdit::Format(const WString& text) const
|
||||
|
|
@ -72,7 +72,7 @@ DocEdit::Fmt DocEdit::Format(const WString& text) const
|
|||
int DocEdit::GetHeight(int i) {
|
||||
Para& p = para[i];
|
||||
if(p.cx == cx) return p.cy;
|
||||
Fmt fmt = Format(line[i]);
|
||||
Fmt fmt = Format(GetWLine(i));
|
||||
p.cx = cx;
|
||||
p.cy = fmt.line.GetCount() * (fmt.fi.GetHeight()) + after;
|
||||
return p.cy;
|
||||
|
|
@ -113,11 +113,11 @@ void DocEdit::Paint(Draw& w) {
|
|||
int y = -sb + 1;
|
||||
int pos = 0;
|
||||
int sell, selh;
|
||||
GetSelection(sell, selh);
|
||||
GetSelection32(sell, selh);
|
||||
for(int i = 0; i < para.GetCount() && y < sz.cy; i++) {
|
||||
int h = GetHeight(i);
|
||||
if(y + h >= 0) {
|
||||
WString text = line[i];
|
||||
WString text = GetWLine(i);
|
||||
Fmt fmt = Format(text);
|
||||
int p = pos;
|
||||
for(int i = 0; i < fmt.line.GetCount(); i++) {
|
||||
|
|
@ -148,7 +148,7 @@ void DocEdit::Paint(Draw& w) {
|
|||
}
|
||||
else
|
||||
y += h;
|
||||
pos += line[i].GetLength() + 1;
|
||||
pos += GetLineLength(i) + 1;
|
||||
}
|
||||
w.DrawRect(0, -sb, sz.cx, 1, bg);
|
||||
w.DrawRect(0, 0, 1, sz.cy, bg);
|
||||
|
|
@ -176,8 +176,8 @@ void DocEdit::Layout()
|
|||
}
|
||||
|
||||
Point DocEdit::GetCaret(int pos) {
|
||||
int i = GetLinePos(pos);
|
||||
Fmt fmt = Format(line[i]);
|
||||
int i = GetLinePos32(pos);
|
||||
Fmt fmt = Format(GetWLine(i));
|
||||
int l;
|
||||
for(l = 0; l < fmt.line.GetCount(); l++)
|
||||
if(pos < fmt.line[l])
|
||||
|
|
@ -196,7 +196,7 @@ int DocEdit::GetCursorPos(Point p) {
|
|||
for(int i = 0; i < para.GetCount(); i++) {
|
||||
int h = GetHeight(i);
|
||||
if(p.y < h) {
|
||||
WString text = line[i];
|
||||
WString text = GetWLine(i);
|
||||
Fmt fmt = Format(text);
|
||||
int x = 0;
|
||||
int l = p.y / fmt.fi.GetHeight();
|
||||
|
|
@ -217,16 +217,16 @@ int DocEdit::GetCursorPos(Point p) {
|
|||
return p + pos;
|
||||
}
|
||||
p.y -= h;
|
||||
pos += line[i].GetLength() + 1;
|
||||
pos += GetLineLength(i) + 1;
|
||||
}
|
||||
return GetLength();
|
||||
return GetLength32();
|
||||
}
|
||||
|
||||
void DocEdit::PlaceCaret(bool scroll) {
|
||||
Point cr = GetCaret(cursor);
|
||||
Point cr = GetCaret((int)cursor);
|
||||
int fy = font.Info().GetLineHeight();
|
||||
if(scroll) {
|
||||
if(cursor == total)
|
||||
if(cursor == GetLength32())
|
||||
sb.End();
|
||||
else
|
||||
sb.ScrollInto(cr.y, fy + 2);
|
||||
|
|
@ -235,9 +235,9 @@ void DocEdit::PlaceCaret(bool scroll) {
|
|||
WhenSel();
|
||||
}
|
||||
|
||||
void DocEdit::PlaceCaret(int newpos, bool select) {
|
||||
if(newpos > GetLength())
|
||||
newpos = GetLength();
|
||||
void DocEdit::PlaceCaret(int64 newpos, bool select) {
|
||||
if(newpos > GetLength32())
|
||||
newpos = GetLength32();
|
||||
int z = GetLine(newpos);
|
||||
if(select) {
|
||||
if(anchor < 0) {
|
||||
|
|
@ -266,7 +266,7 @@ void DocEdit::LeftDown(Point p, dword flags) {
|
|||
SetFocus();
|
||||
int c = GetMousePos(p);
|
||||
int l, h;
|
||||
if(GetSelection(l, h) && c >= l && c < h) {
|
||||
if(GetSelection32(l, h) && c >= l && c < h) {
|
||||
selclick = true;
|
||||
return;
|
||||
}
|
||||
|
|
@ -292,16 +292,16 @@ void DocEdit::MouseMove(Point p, dword flags) {
|
|||
|
||||
void DocEdit::LeftDouble(Point, dword)
|
||||
{
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(GetWordSelection(cursor, l, h))
|
||||
SetSelection(l, h);
|
||||
}
|
||||
|
||||
void DocEdit::LeftTriple(Point, dword)
|
||||
{
|
||||
int q = cursor;
|
||||
int i = GetLinePos(q);
|
||||
q = cursor - q;
|
||||
int q = (int)cursor;
|
||||
int i = GetLinePos32(q);
|
||||
q = (int)cursor - q;
|
||||
SetSelection(q, q + GetLineLength(i) + 1);
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ void DocEdit::LostFocus() {
|
|||
|
||||
void DocEdit::VertMove(int delta, bool select, bool scs) {
|
||||
int hy = GetY(para.GetCount());
|
||||
Point p = GetCaret(cursor);
|
||||
Point p = GetCaret((int)cursor);
|
||||
int yy = p.y;
|
||||
for(;;) {
|
||||
p.y += delta;
|
||||
|
|
@ -331,18 +331,18 @@ void DocEdit::VertMove(int delta, bool select, bool scs) {
|
|||
break;
|
||||
}
|
||||
if(p.y == 0 || p.y >= hy - 1) {
|
||||
PlaceCaret(delta > 0 ? total : 0, select);
|
||||
PlaceCaret(delta > 0 ? GetLength32() : 0, select);
|
||||
break;
|
||||
}
|
||||
delta = sgn(delta) * 4;
|
||||
}
|
||||
if(scs)
|
||||
sb = GetCaret(cursor).y - (yy - sb);
|
||||
sb = GetCaret((int)cursor).y - (yy - sb);
|
||||
PlaceCaret(true);
|
||||
}
|
||||
|
||||
void DocEdit::HomeEnd(int x, bool select) {
|
||||
Point p = GetCaret(cursor);
|
||||
Point p = GetCaret((int)cursor);
|
||||
p.x = x;
|
||||
PlaceCaret(GetCursorPos(p), select);
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ bool DocEdit::Key(dword key, int cnt)
|
|||
break;
|
||||
case K_CTRL_END:
|
||||
case K_CTRL_PAGEDOWN:
|
||||
PlaceCaret(total, select);
|
||||
PlaceCaret(GetLength32(), select);
|
||||
break;
|
||||
case K_UP:
|
||||
if(GetCursor() == 0)
|
||||
|
|
@ -381,7 +381,7 @@ bool DocEdit::Key(dword key, int cnt)
|
|||
VertMove(-8, select, false);
|
||||
return true;
|
||||
case K_DOWN:
|
||||
if(GetCursor() == GetLength())
|
||||
if(GetCursor32() == GetLength32())
|
||||
return !updownleave;
|
||||
VertMove(8, select, false);
|
||||
return true;
|
||||
|
|
@ -396,7 +396,7 @@ bool DocEdit::Key(dword key, int cnt)
|
|||
PlaceCaret(cursor - 1, select);
|
||||
break;
|
||||
case K_RIGHT:
|
||||
if(cursor < total)
|
||||
if(cursor < GetLength32())
|
||||
PlaceCaret(cursor + 1, select);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -407,30 +407,30 @@ bool DocEdit::Key(dword key, int cnt)
|
|||
if(RemoveSelection()) break;
|
||||
if(cursor == 0) return true;
|
||||
cursor--;
|
||||
Remove(cursor, 1);
|
||||
Remove((int)cursor, 1);
|
||||
break;
|
||||
case K_CTRL_BACKSPACE:
|
||||
if(RemoveSelection()) break;
|
||||
if(cursor <= 0) return true;
|
||||
q = cursor - 1;
|
||||
q = (int)cursor - 1;
|
||||
h = IsLetter(GetChar(q));
|
||||
while(q > 0 && IsLetter(GetChar(q - 1)) == h) q--;
|
||||
Remove(q, cursor - q);
|
||||
Remove(q, (int)cursor - q);
|
||||
SetCursor(q);
|
||||
break;
|
||||
case K_DELETE:
|
||||
if(RemoveSelection()) break;
|
||||
if(cursor >= total) return true;
|
||||
if(cursor < total)
|
||||
Remove(cursor, 1);
|
||||
if(cursor >= GetLength32()) return true;
|
||||
if(cursor < GetLength32())
|
||||
Remove((int)cursor, 1);
|
||||
break;
|
||||
case K_CTRL_DELETE:
|
||||
if(RemoveSelection()) break;
|
||||
if(cursor >= total) return true;
|
||||
q = cursor;
|
||||
if(cursor >= GetLength32()) return true;
|
||||
q = (int)cursor;
|
||||
h = IsLetter(GetChar(q));
|
||||
while(IsLetter(GetChar(q)) == h && q < total) q++;
|
||||
Remove(cursor, q - cursor);
|
||||
while(IsLetter(GetChar(q)) == h && q < GetLength32()) q++;
|
||||
Remove((int)cursor, q - (int)cursor);
|
||||
break;
|
||||
case K_ENTER:
|
||||
if(!processenter)
|
||||
|
|
@ -446,7 +446,7 @@ bool DocEdit::Key(dword key, int cnt)
|
|||
&& FromUnicode((wchar)key, charset) == DEFAULTCHAR)
|
||||
return true;
|
||||
RemoveSelection();
|
||||
Insert(cursor, WString(key == K_SHIFT_SPACE ? ' ' : key, cnt), true);
|
||||
Insert((int)cursor, WString(key == K_SHIFT_SPACE ? ' ' : key, cnt), true);
|
||||
cursor += cnt;
|
||||
break;
|
||||
}
|
||||
|
|
@ -486,7 +486,7 @@ void DocEdit::RightDown(Point p, dword w)
|
|||
SetFocus();
|
||||
int c = GetMousePos(p);
|
||||
int l, h;
|
||||
if(!GetSelection(l, h) || c < l || c >= h)
|
||||
if(!GetSelection32(l, h) || c < l || c >= h)
|
||||
PlaceCaret(c, false);
|
||||
MenuBar::Execute(WhenBar);
|
||||
}
|
||||
|
|
@ -519,7 +519,7 @@ void DocEdit::DragAndDrop(Point p, PasteClip& d)
|
|||
int a = sb;
|
||||
int sell, selh;
|
||||
WString txt = GetWString(d);
|
||||
if(GetSelection(sell, selh)) {
|
||||
if(GetSelection32(sell, selh)) {
|
||||
if(c >= sell && c < selh) {
|
||||
if(!IsReadOnly())
|
||||
RemoveSelection();
|
||||
|
|
@ -585,7 +585,7 @@ void DocEdit::LeftDrag(Point p, dword flags)
|
|||
{
|
||||
int c = GetMousePos(p);
|
||||
int l, h;
|
||||
if(!HasCapture() && GetSelection(l, h) && c >= l && c < h) {
|
||||
if(!HasCapture() && GetSelection32(l, h) && c >= l && c < h) {
|
||||
WString sample = GetW(l, min(h - l, 3000));
|
||||
Size ssz = StdSampleSize();
|
||||
ImageDraw iw(ssz);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
struct TextArrayOps {
|
||||
virtual int GetLength() const = 0;
|
||||
virtual int GetChar(int i) const = 0;
|
||||
virtual int64 GetTotal() const = 0;
|
||||
virtual int GetCharAt(int64 i) const = 0;
|
||||
|
||||
bool GetWordSelection(int c, int& sell, int& selh);
|
||||
int GetNextWord(int c);
|
||||
int GetPrevWord(int c);
|
||||
bool GetWordSelection(int64 c, int64& sell, int64& selh);
|
||||
int64 GetNextWord(int64 c);
|
||||
int64 GetPrevWord(int64 c);
|
||||
|
||||
virtual ~TextArrayOps() {}
|
||||
};
|
||||
|
|
@ -166,10 +166,12 @@ protected:
|
|||
|
||||
protected:
|
||||
virtual void HighlightText(Vector<Highlight>& hl);
|
||||
virtual int64 GetTotal() const { return text.GetLength(); }
|
||||
virtual int GetCharAt(int64 pos) const { return text[(int)pos]; }
|
||||
|
||||
public:
|
||||
Event<Bar&> WhenBar;
|
||||
Event<> WhenEnter;
|
||||
Event<> WhenEnter;
|
||||
Event<WString&> WhenPasteFilter;
|
||||
Event<Vector<Highlight>&> WhenHighlight;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,41 +26,41 @@ bool IsWCh(int c)
|
|||
return IsLeNum(c) || c == '_';
|
||||
}
|
||||
|
||||
bool TextArrayOps::GetWordSelection(int c, int& l, int& h)
|
||||
bool TextArrayOps::GetWordSelection(int64 c, int64& l, int64& h)
|
||||
{
|
||||
if(IsWCh(GetChar(c))) {
|
||||
if(IsWCh(GetCharAt(c))) {
|
||||
l = h = c;
|
||||
while(l > 0 && IsWCh(GetChar(l - 1)))
|
||||
while(l > 0 && IsWCh(GetCharAt(l - 1)))
|
||||
l--;
|
||||
while(h < GetLength() && IsWCh(GetChar(h)))
|
||||
while(h < GetTotal() && IsWCh(GetCharAt(h)))
|
||||
h++;
|
||||
if(h != c)
|
||||
while(h < GetLength() && GetChar(h) == ' ')
|
||||
while(h < GetTotal() && GetCharAt(h) == ' ')
|
||||
h++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int TextArrayOps::GetNextWord(int cursor)
|
||||
int64 TextArrayOps::GetNextWord(int64 cursor)
|
||||
{
|
||||
bool a = IsWCh(GetChar(cursor));
|
||||
bool a = IsWCh(GetCharAt(cursor));
|
||||
int n = 0;
|
||||
int c = cursor;
|
||||
while(c <= GetLength() && IsWCh(GetChar(c)) == a) {
|
||||
int64 c = cursor;
|
||||
while(c <= GetTotal() && IsWCh(GetCharAt(c)) == a) {
|
||||
if(++n > 10000) return cursor;
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int TextArrayOps::GetPrevWord(int cursor)
|
||||
int64 TextArrayOps::GetPrevWord(int64 cursor)
|
||||
{
|
||||
int n = 0;
|
||||
int c = cursor;
|
||||
int64 c = cursor;
|
||||
if(c == 0) return 0;
|
||||
bool a = IsWCh(GetChar(c - 1));
|
||||
while(c > 0 && IsWCh(GetChar(c - 1)) == a) {
|
||||
bool a = IsWCh(GetCharAt(c - 1));
|
||||
while(c > 0 && IsWCh(GetCharAt(c - 1)) == a) {
|
||||
if(++n > 10000) return cursor;
|
||||
c--;
|
||||
}
|
||||
|
|
@ -540,9 +540,9 @@ void EditField::LeftUp(Point p, dword flags)
|
|||
|
||||
void EditField::LeftDouble(Point p, dword flags)
|
||||
{
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(GetWordSelection(cursor, l, h))
|
||||
SetSelection(l, h);
|
||||
SetSelection((int)l, (int)h);
|
||||
}
|
||||
|
||||
void EditField::LeftTriple(Point p, dword keyflags)
|
||||
|
|
@ -894,10 +894,10 @@ bool EditField::Key(dword key, int rep)
|
|||
Move(cursor - 1, select);
|
||||
return true;
|
||||
case K_CTRL_LEFT:
|
||||
Move(GetPrevWord(cursor), select);
|
||||
Move((int)GetPrevWord(cursor), select);
|
||||
return true;
|
||||
case K_CTRL_RIGHT:
|
||||
Move(GetNextWord(cursor), select);
|
||||
Move((int)GetNextWord(cursor), select);
|
||||
return true;
|
||||
case K_RIGHT:
|
||||
Move(cursor + 1, select);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ Size LineEdit::GetFontSize() const {
|
|||
return Size(max(fi['M'], fi['W']), fi.GetHeight());
|
||||
}
|
||||
|
||||
void LineEdit::SetRectSelection(int anchor, int cursor)
|
||||
void LineEdit::SetRectSelection(int64 anchor, int64 cursor)
|
||||
{
|
||||
dorectsel = true;
|
||||
SetSelection(anchor, cursor);
|
||||
|
|
@ -89,7 +89,7 @@ void LineEdit::SetRectSelection(const Rect& rect)
|
|||
Rect LineEdit::GetRectSelection() const
|
||||
{
|
||||
if(IsRectSelection()) {
|
||||
int sell, selh;
|
||||
int64 sell, selh;
|
||||
GetSelection(sell, selh);
|
||||
Rect r(GetColumnLine(sell), GetColumnLine(selh));
|
||||
if(r.left > r.right)
|
||||
|
|
@ -99,7 +99,7 @@ Rect LineEdit::GetRectSelection() const
|
|||
return Null;
|
||||
}
|
||||
|
||||
bool LineEdit::GetRectSelection(const Rect& rect, int line, int& l, int &h)
|
||||
bool LineEdit::GetRectSelection(const Rect& rect, int line, int64& l, int64& h)
|
||||
{
|
||||
if(line >= rect.top && line <= rect.bottom) {
|
||||
l = GetGPos(line, rect.left);
|
||||
|
|
@ -114,33 +114,33 @@ int LineEdit::RemoveRectSelection()
|
|||
Rect rect = GetRectSelection();
|
||||
WString txt;
|
||||
for(int i = rect.top; i <= rect.bottom; i++) {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
CacheLinePos(i);
|
||||
GetRectSelection(rect, i, l, h);
|
||||
WString s = GetWLine(i);
|
||||
s.Remove(l - GetPos(i), h - l);
|
||||
s.Remove(int(l - GetPos64(i)), int(h - l));
|
||||
txt.Cat(s);
|
||||
txt.Cat('\n');
|
||||
}
|
||||
int l = GetPos(rect.top);
|
||||
int h = GetPos(rect.bottom) + GetLineLength(rect.bottom);
|
||||
if(h < GetLength())
|
||||
int l = GetPos32(rect.top);
|
||||
int h = GetPos32(rect.bottom) + GetLineLength(rect.bottom);
|
||||
if(h < GetLength32())
|
||||
h++;
|
||||
Remove(l, h - l);
|
||||
Insert(l, txt);
|
||||
return GetGPos(rect.bottom, rect.left);
|
||||
Remove((int)l, int(h - l));
|
||||
Insert((int)l, txt);
|
||||
return (int)GetGPos(rect.bottom, rect.left);
|
||||
}
|
||||
|
||||
WString LineEdit::CopyRectSelection()
|
||||
{
|
||||
WString txt;
|
||||
Rect rect = GetRectSelection();
|
||||
for(int i = rect.top; i <= rect.bottom; i++) {
|
||||
int l, h;
|
||||
for(int i = rect.top; i <= rect.bottom && txt.GetCount() < max_total; i++) {
|
||||
int64 l, h;
|
||||
CacheLinePos(i);
|
||||
int pos = GetPos(i);
|
||||
int64 pos = GetPos64(i);
|
||||
GetRectSelection(rect, i, l, h);
|
||||
txt.Cat(GetWLine(i).Mid(l - pos, h - l));
|
||||
txt.Cat(GetWLine(i).Mid(int(l - pos), int(h - l)));
|
||||
#ifdef PLATFORM_WIN32
|
||||
txt.Cat('\r');
|
||||
#endif
|
||||
|
|
@ -153,14 +153,14 @@ int LineEdit::PasteRectSelection(const WString& s)
|
|||
{
|
||||
Vector<WString> cl = Split(s, '\n', false);
|
||||
Rect rect = GetRectSelection();
|
||||
int pos = cursor;
|
||||
int64 pos = cursor;
|
||||
int n = 0;
|
||||
for(int i = 0; i < cl.GetCount() && rect.top + i <= rect.bottom; i++) {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
CacheLinePos(i);
|
||||
GetRectSelection(rect, i + rect.top, l, h);
|
||||
Remove(l, h - l);
|
||||
int nn = Insert(l, cl[i]);
|
||||
Remove((int)l, int(h - l));
|
||||
int nn = Insert((int)l, cl[i]);
|
||||
n += nn;
|
||||
pos = l + nn;
|
||||
}
|
||||
|
|
@ -180,27 +180,27 @@ void LineEdit::PasteColumn(const WString& text)
|
|||
Rect t = GetRectSelection();
|
||||
RemoveSelection();
|
||||
Point p = t.TopLeft();
|
||||
pos = cursor;
|
||||
pos = (int)cursor;
|
||||
for(int i = 0; i < t.bottom - t.top + 1; i++) {
|
||||
CacheLinePos(i + p.y);
|
||||
int l = GetGPos(i + p.y, p.x);
|
||||
int l = (int)GetGPos(i + p.y, p.x);
|
||||
pos = l + Insert(l, cl[i % cl.GetCount()]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
RemoveSelection();
|
||||
Point p = GetColumnLine(cursor);
|
||||
pos = cursor;
|
||||
pos = (int)cursor;
|
||||
for(int i = 0; i < cl.GetCount(); i++) {
|
||||
CacheLinePos(i + p.y);
|
||||
int li = p.y + i;
|
||||
if(li < line.GetCount()) {
|
||||
int l = GetGPos(i + p.y, p.x);
|
||||
if(li < GetLineCount()) {
|
||||
int l = (int)GetGPos(i + p.y, p.x);
|
||||
pos = l + Insert(l, cl[i]);
|
||||
}
|
||||
else {
|
||||
Insert(GetLength(), cl[i] + "\n");
|
||||
pos = GetLength();
|
||||
Insert(GetLength32(), cl[i] + "\n");
|
||||
pos = GetLength32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -230,13 +230,13 @@ void LineEdit::Sort()
|
|||
Vector<WString> key;
|
||||
Vector<WString> ln;
|
||||
for(int i = rect.top; i <= rect.bottom; i++) {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
GetRectSelection(rect, i, l, h);
|
||||
key.Add(GetW(l, h - l));
|
||||
ln.Add(line[i]);
|
||||
key.Add(GetW((int)l, int(h - l)));
|
||||
ln.Add(GetWLine(i));
|
||||
}
|
||||
int sell = GetPos(rect.top);
|
||||
int selh = rect.bottom + 1 < line.GetCount() ? GetPos(rect.bottom + 1) : GetLength();
|
||||
int sell = GetPos32(rect.top);
|
||||
int selh = rect.bottom + 1 < GetLineCount() ? GetPos32(rect.bottom + 1) : GetLength32();
|
||||
IndexSort(key, ln, sSortLineOrder);
|
||||
Remove(sell, selh - sell);
|
||||
Insert(sell, Join(ln, "\n"));
|
||||
|
|
@ -385,7 +385,8 @@ void sOptimizedTextRenderer::DrawChar(int _x, int _y, int chr, int width, Font _
|
|||
|
||||
void LineEdit::Paint0(Draw& w) {
|
||||
LTIMING("LineEdit::Paint0");
|
||||
int sell, selh;
|
||||
GuiLock __;
|
||||
int64 sell, selh;
|
||||
GetSelection(sell, selh);
|
||||
if(!IsEnabled())
|
||||
sell = selh = 0;
|
||||
|
|
@ -396,14 +397,14 @@ void LineEdit::Paint0(Draw& w) {
|
|||
Size sz = GetSize();
|
||||
Size fsz = GetFontSize();
|
||||
Point sc = sb;
|
||||
int ll = min(line.GetCount(), sz.cy / fsz.cy + sc.y + 1);
|
||||
int ll = min(GetLineCount(), sz.cy / fsz.cy + sc.y + 1);
|
||||
int y = 0;
|
||||
sc.y = minmax(sc.y, 0, line.GetCount() - 1);
|
||||
cpos = GetPos(sc.y);
|
||||
sc.y = minmax(sc.y, 0, GetLineCount() - 1);
|
||||
cpos = GetPos64(sc.y);
|
||||
cline = sc.y;
|
||||
sell -= cpos;
|
||||
selh -= cpos;
|
||||
int pos = cpos;
|
||||
int64 pos = cpos;
|
||||
int fascent = font.Info().GetAscent();
|
||||
int cursorline = GetLine(cursor);
|
||||
Highlight ih;
|
||||
|
|
@ -415,11 +416,11 @@ void LineEdit::Paint0(Draw& w) {
|
|||
ih.chr = 0;
|
||||
for(int i = sc.y; i < ll; i++) {
|
||||
Color showcolor = color[WHITESPACE];
|
||||
WString tx = line[i];
|
||||
WString tx = GetWLine(i);
|
||||
bool warn_whitespace = false;
|
||||
if(warnwhitespace && !IsSelection()) {
|
||||
int pos = GetCursor();
|
||||
int linei = GetLinePos(pos);
|
||||
int64 pos = GetCursor64();
|
||||
int linei = GetLinePos64(pos);
|
||||
if(linei != i || pos < tx.GetCount()) {
|
||||
int wkind = 0;
|
||||
bool empty = true;
|
||||
|
|
@ -650,11 +651,11 @@ void LineEdit::Layout() {
|
|||
SetHBar();
|
||||
}
|
||||
|
||||
int LineEdit::GetGPos(int ln, int cl) const {
|
||||
ln = minmax(ln, 0, line.GetCount() - 1);
|
||||
const String& stxt = line[ln].text;
|
||||
const char *s = stxt;
|
||||
const char *e = stxt.End();
|
||||
int64 LineEdit::GetGPos(int ln, int cl) const {
|
||||
ln = minmax(ln, 0, GetLineCount() - 1);
|
||||
String h = GetUtf8Line(ln);
|
||||
const char *s = h.begin();
|
||||
const char *e = h.end();
|
||||
const char *b = s;
|
||||
int gl = 0;
|
||||
int wpos = 0;
|
||||
|
|
@ -684,15 +685,15 @@ int LineEdit::GetGPos(int ln, int cl) const {
|
|||
s++;
|
||||
}
|
||||
|
||||
return GetPos(ln, int(s - b) + wpos);
|
||||
return GetPos64(ln, int(s - b) + wpos);
|
||||
}
|
||||
|
||||
Point LineEdit::GetColumnLine(int pos) const {
|
||||
Point LineEdit::GetColumnLine(int64 pos) const {
|
||||
Point p;
|
||||
if(pos > total) pos = total;
|
||||
p.y = GetLinePos(pos);
|
||||
if(pos > GetLength64()) pos = GetLength64();
|
||||
p.y = GetLinePos64(pos);
|
||||
p.x = 0;
|
||||
WString txt = line[p.y];
|
||||
WString txt = GetWLine(p.y);
|
||||
const wchar *s = txt;
|
||||
while(pos--) {
|
||||
if(*s == '\t')
|
||||
|
|
@ -704,22 +705,22 @@ Point LineEdit::GetColumnLine(int pos) const {
|
|||
return p;
|
||||
}
|
||||
|
||||
Point LineEdit::GetIndexLine(int pos) const
|
||||
Point LineEdit::GetIndexLine(int64 pos) const
|
||||
{
|
||||
Point p;
|
||||
if(pos > total) pos = total;
|
||||
p.y = GetLinePos(pos);
|
||||
p.x = minmax(pos, 0, line[p.y].GetLength());
|
||||
if(pos > GetLength64()) pos = GetLength64();
|
||||
p.y = GetLinePos64(pos);
|
||||
p.x = minmax((int)pos, 0, GetLineLength(p.y));
|
||||
return p;
|
||||
}
|
||||
|
||||
int LineEdit::GetIndexLinePos(Point pos) const
|
||||
int64 LineEdit::GetIndexLinePos(Point pos) const
|
||||
{
|
||||
if(pos.y < 0)
|
||||
return 0;
|
||||
if(pos.y >= GetLineCount())
|
||||
return total;
|
||||
return GetPos(pos.y, minmax(pos.x, 0, line[pos.y].GetLength()));
|
||||
return GetLength64();
|
||||
return GetPos64(pos.y, minmax(pos.x, 0, GetLineLength(pos.y)));
|
||||
}
|
||||
|
||||
void LineEdit::RefreshLine(int i) {
|
||||
|
|
@ -736,15 +737,15 @@ Rect LineEdit::GetLineScreenRect(int line) const {
|
|||
}
|
||||
|
||||
void LineEdit::SetSb() {
|
||||
sb.SetTotalY(line.GetCount());
|
||||
sb.SetTotalY(GetLineCount());
|
||||
SetHBar();
|
||||
}
|
||||
|
||||
void LineEdit::NewScrollPos() {}
|
||||
void LineEdit::HighlightLine(int line, Vector<Highlight>& h, int pos) {}
|
||||
void LineEdit::HighlightLine(int line, Vector<Highlight>& h, int64 pos) {}
|
||||
|
||||
void LineEdit::AlignChar() {
|
||||
int c = GetCursor();
|
||||
int c = GetCursor32();
|
||||
if(c == 0)
|
||||
return;
|
||||
Point pos = GetColumnLine(c);
|
||||
|
|
@ -753,7 +754,7 @@ void LineEdit::AlignChar() {
|
|||
for(int d = 1; d <= pos.y && d < 100; d++) {
|
||||
int lny = pos.y - d;
|
||||
WString above = GetWLine(lny);
|
||||
int offset = GetGPos(lny, pos.x) - GetPos(lny);
|
||||
int offset = int(GetGPos(lny, pos.x) - GetPos64(lny));
|
||||
int end = offset;
|
||||
char ch = GetChar(c - 1);
|
||||
if(ch == ' ')
|
||||
|
|
@ -787,8 +788,8 @@ void LineEdit::PlaceCaret0(Point p) {
|
|||
SetCaret(caretpos.x, caretpos.y, 2, fsz.cy);
|
||||
}
|
||||
|
||||
int LineEdit::PlaceCaretNoG(int newcursor, bool sel) {
|
||||
if(newcursor > total) newcursor = total;
|
||||
int LineEdit::PlaceCaretNoG(int64 newcursor, bool sel) {
|
||||
if(newcursor > GetLength64()) newcursor = GetLength64();
|
||||
Point p = GetColumnLine(newcursor);
|
||||
if(sel) {
|
||||
if(anchor < 0) {
|
||||
|
|
@ -822,7 +823,7 @@ int LineEdit::PlaceCaretNoG(int newcursor, bool sel) {
|
|||
return p.x;
|
||||
}
|
||||
|
||||
void LineEdit::PlaceCaret(int newcursor, bool sel) {
|
||||
void LineEdit::PlaceCaret(int64 newcursor, bool sel) {
|
||||
gcolumn = PlaceCaretNoG(newcursor, sel);
|
||||
}
|
||||
|
||||
|
|
@ -834,7 +835,7 @@ void LineEdit::TopCursor(int lines)
|
|||
void LineEdit::CenterCursor() {
|
||||
int cy = sb.GetPage().cy;
|
||||
if(cy > 4)
|
||||
sb.SetY(max(min(GetLine(cursor) - cy / 2, line.GetCount() - cy), 0));
|
||||
sb.SetY(max(min(GetLine(cursor) - cy / 2, GetLineCount() - cy), 0));
|
||||
}
|
||||
|
||||
void LineEdit::Scroll() {
|
||||
|
|
@ -844,7 +845,7 @@ void LineEdit::Scroll() {
|
|||
NewScrollPos();
|
||||
}
|
||||
|
||||
int LineEdit::GetMousePos(Point p) const {
|
||||
int64 LineEdit::GetMousePos(Point p) const {
|
||||
Size fsz = GetFontSize();
|
||||
p = (p + fsz.cx / 2 + fsz * (Size)sb.Get()) / fsz;
|
||||
return GetGPos(p.y, p.x);
|
||||
|
|
@ -852,7 +853,7 @@ int LineEdit::GetMousePos(Point p) const {
|
|||
|
||||
void LineEdit::LeftDown(Point p, dword flags) {
|
||||
mpos = GetMousePos(p);
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(GetSelection(l, h) && mpos >= l && mpos < h) {
|
||||
selclick = true;
|
||||
return;
|
||||
|
|
@ -879,7 +880,7 @@ void LineEdit::RightDown(Point p, dword flags)
|
|||
{
|
||||
mpos = GetMousePos(p);
|
||||
SetFocus();
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
GetSelection(l, h);
|
||||
if(!IsAnySelection() || !(mpos >= l && mpos < h))
|
||||
PlaceCaret(mpos, false);
|
||||
|
|
@ -888,22 +889,22 @@ void LineEdit::RightDown(Point p, dword flags)
|
|||
|
||||
void LineEdit::LeftDouble(Point, dword)
|
||||
{
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(GetWordSelection(cursor, l, h))
|
||||
SetSelection(l, h);
|
||||
}
|
||||
|
||||
void LineEdit::LeftTriple(Point, dword)
|
||||
{
|
||||
int q = cursor;
|
||||
int i = GetLinePos(q);
|
||||
int64 q = cursor;
|
||||
int i = GetLinePos64(q);
|
||||
q = cursor - q;
|
||||
SetSelection(q, q + GetLineLength(i) + 1);
|
||||
}
|
||||
|
||||
void LineEdit::MouseMove(Point p, dword flags) {
|
||||
if((flags & K_MOUSELEFT) && HasFocus() && HasCapture()) {
|
||||
int c = GetMousePos(p);
|
||||
int64 c = GetMousePos(p);
|
||||
dorectsel = flags & K_ALT;
|
||||
PlaceCaret(c, mpos != c || HasCapture());
|
||||
dorectsel = false;
|
||||
|
|
@ -912,7 +913,7 @@ void LineEdit::MouseMove(Point p, dword flags) {
|
|||
|
||||
void LineEdit::LeftRepeat(Point p, dword flags) {
|
||||
if(HasCapture()) {
|
||||
int c = GetMousePos(p);
|
||||
int64 c = GetMousePos(p);
|
||||
if(mpos != c) {
|
||||
dorectsel = flags & K_ALT;
|
||||
PlaceCaret(c, true);
|
||||
|
|
@ -926,9 +927,11 @@ Image LineEdit::CursorImage(Point, dword) {
|
|||
}
|
||||
|
||||
void LineEdit::MoveUpDown(int n, bool sel) {
|
||||
int cl = cursor;
|
||||
int ln = GetLinePos(cl);
|
||||
ln = minmax(ln + n, 0, line.GetCount() - 1);
|
||||
int64 cl = cursor;
|
||||
int ln = GetLinePos64(cl);
|
||||
if(ln + n >= GetLineCount())
|
||||
WaitView(ln + n);
|
||||
ln = minmax(ln + n, 0, GetLineCount() - 1);
|
||||
PlaceCaretNoG(GetGPos(ln, gcolumn), sel);
|
||||
}
|
||||
|
||||
|
|
@ -938,7 +941,7 @@ void LineEdit::MoveLeft(bool sel) {
|
|||
}
|
||||
|
||||
void LineEdit::MoveRight(bool sel) {
|
||||
if(cursor < total)
|
||||
if(cursor < GetLength64())
|
||||
PlaceCaret(cursor + 1, sel);
|
||||
}
|
||||
|
||||
|
|
@ -967,18 +970,18 @@ void LineEdit::MovePageDown(bool sel) {
|
|||
inline bool sTabSpace(int c) { return c == '\t' || c == ' '; }
|
||||
|
||||
void LineEdit::MoveHome(bool sel) {
|
||||
int cl = cursor;
|
||||
int li = GetLinePos(cl);
|
||||
int64 cl = cursor;
|
||||
int li = GetLinePos64(cl);
|
||||
int i = 0;
|
||||
WString l = line[li];
|
||||
WString l = GetWLine(li);
|
||||
while(sTabSpace(l[i]))
|
||||
i++;
|
||||
PlaceCaret(GetPos(li, cl == i ? 0 : i), sel);
|
||||
PlaceCaret(GetPos64(li, cl == i ? 0 : i), sel);
|
||||
}
|
||||
|
||||
void LineEdit::MoveEnd(bool sel) {
|
||||
int i = GetLine(cursor);
|
||||
PlaceCaret(GetPos(i, line[i].GetLength()), sel);
|
||||
PlaceCaret(GetPos64(i, GetLineLength(i)), sel);
|
||||
}
|
||||
|
||||
void LineEdit::MoveTextBegin(bool sel) {
|
||||
|
|
@ -986,7 +989,8 @@ void LineEdit::MoveTextBegin(bool sel) {
|
|||
}
|
||||
|
||||
void LineEdit::MoveTextEnd(bool sel) {
|
||||
PlaceCaret(total, sel);
|
||||
WaitView(INT_MAX, true);
|
||||
PlaceCaret(GetLength64(), sel);
|
||||
}
|
||||
|
||||
bool LineEdit::InsertChar(dword key, int count, bool canow) {
|
||||
|
|
@ -1000,13 +1004,13 @@ bool LineEdit::InsertChar(dword key, int count, bool canow) {
|
|||
&& FromUnicode((wchar)key, charset) == DEFAULTCHAR)
|
||||
return true;
|
||||
if(!RemoveSelection() && overwrite && key != '\n' && key != K_ENTER && canow) {
|
||||
int q = cursor;
|
||||
int i = GetLinePos(q);
|
||||
int64 q = cursor;
|
||||
int i = GetLinePos64(q);
|
||||
if(q + count - 1 < GetLineLength(i))
|
||||
Remove(cursor, count);
|
||||
Remove((int)cursor, (int)count);
|
||||
}
|
||||
WString text(key == K_ENTER ? '\n' : key == K_SHIFT_SPACE ? ' ' : key, count);
|
||||
Insert(cursor, text, true);
|
||||
Insert((int)cursor, text, true);
|
||||
PlaceCaret(cursor + count);
|
||||
Action();
|
||||
return true;
|
||||
|
|
@ -1019,8 +1023,8 @@ void LineEdit::DeleteChar() {
|
|||
Action();
|
||||
return;
|
||||
}
|
||||
if(cursor < total) {
|
||||
Remove(cursor, 1);
|
||||
if(cursor < GetLength32()) {
|
||||
Remove((int)cursor, 1);
|
||||
Action();
|
||||
}
|
||||
}
|
||||
|
|
@ -1034,14 +1038,14 @@ void LineEdit::Backspace() {
|
|||
|
||||
void LineEdit::DeleteLine()
|
||||
{
|
||||
int b, e;
|
||||
int64 b, e;
|
||||
if(GetSelection(b, e) && GetLine(b) != GetLine(e)) {
|
||||
RemoveSelection();
|
||||
return;
|
||||
}
|
||||
int i = GetLine(cursor);
|
||||
int p = GetPos(i);
|
||||
Remove(p, line[i].GetLength() + 1);
|
||||
int p = GetPos32(i);
|
||||
Remove((int)p, GetLineLength(i) + 1);
|
||||
PlaceCaret(p);
|
||||
Action();
|
||||
}
|
||||
|
|
@ -1049,14 +1053,14 @@ void LineEdit::DeleteLine()
|
|||
void LineEdit::CutLine()
|
||||
{
|
||||
if(IsReadOnly()) return;
|
||||
int b, e;
|
||||
int64 b, e;
|
||||
if(GetSelection(b, e) && GetLine(b) != GetLine(e)) {
|
||||
Cut();
|
||||
return;
|
||||
}
|
||||
int i = GetLine(cursor);
|
||||
int p = GetPos(i);
|
||||
WString txt = Get(p, line[i].GetLength() + 1).ToWString();
|
||||
int p = GetPos32(i);
|
||||
WString txt = Get(p, GetLineLength(i) + 1).ToWString();
|
||||
WriteClipboardUnicodeText(txt);
|
||||
AppendClipboardText(txt.ToString());
|
||||
ClearSelection();
|
||||
|
|
@ -1064,9 +1068,15 @@ void LineEdit::CutLine()
|
|||
}
|
||||
|
||||
void LineEdit::EditPos::Serialize(Stream& s) {
|
||||
int version = 0;
|
||||
int version = 1;
|
||||
s / version;
|
||||
s % sby % cursor;
|
||||
if(version >= 1)
|
||||
s % sby % cursor;
|
||||
else {
|
||||
int c = (int)cursor;
|
||||
s % sby % c;
|
||||
cursor = c;
|
||||
}
|
||||
}
|
||||
|
||||
LineEdit::EditPos LineEdit::GetEditPos() const {
|
||||
|
|
@ -1077,23 +1087,23 @@ LineEdit::EditPos LineEdit::GetEditPos() const {
|
|||
}
|
||||
|
||||
void LineEdit::SetEditPos(const LineEdit::EditPos& pos) {
|
||||
sb.SetY(minmax(pos.sby, 0, line.GetCount() - 1));
|
||||
sb.SetY(minmax(pos.sby, 0, GetLineCount() - 1));
|
||||
SetCursor(pos.cursor);
|
||||
}
|
||||
|
||||
void LineEdit::SetEditPosSb(const LineEdit::EditPos& pos) {
|
||||
SetCursor(pos.cursor);
|
||||
sb.SetY(minmax(pos.sby, 0, line.GetCount() - 1));
|
||||
sb.SetY(minmax(pos.sby, 0, GetLineCount() - 1));
|
||||
}
|
||||
|
||||
void LineEdit::SetHBar()
|
||||
{
|
||||
int mpos = 0;
|
||||
if(!nohbar && !isdrag) {
|
||||
int m = min(sb.y + sb.GetPage().cy + 2, line.GetCount());
|
||||
int m = min(sb.y + sb.GetPage().cy + 2, GetLineCount());
|
||||
for(int i = sb.y; i < m; i++) {
|
||||
int pos = 0;
|
||||
WString l = line[i];
|
||||
WString l = GetWLine(i);
|
||||
const wchar *s = l;
|
||||
const wchar *e = l.End();
|
||||
while(s < e) {
|
||||
|
|
@ -1111,7 +1121,7 @@ void LineEdit::SetHBar()
|
|||
|
||||
void LineEdit::ScrollIntoCursor()
|
||||
{
|
||||
Point p = GetColumnLine(GetCursor());
|
||||
Point p = GetColumnLine(GetCursor64());
|
||||
sb.ScrollInto(p);
|
||||
SetHBar();
|
||||
sb.ScrollInto(p);
|
||||
|
|
@ -1221,13 +1231,13 @@ bool LineEdit::Key(dword key, int count) {
|
|||
void LineEdit::DragAndDrop(Point p, PasteClip& d)
|
||||
{
|
||||
if(IsReadOnly()) return;
|
||||
int c = GetMousePos(p);
|
||||
int c = GetMousePos32(p);
|
||||
if(AcceptText(d)) {
|
||||
NextUndo();
|
||||
int a = sb.y;
|
||||
int sell, selh;
|
||||
WString text = GetWString(d);
|
||||
if(GetSelection(sell, selh)) {
|
||||
if(GetSelection32(sell, selh)) {
|
||||
if(c >= sell && c < selh) {
|
||||
if(!IsReadOnly())
|
||||
RemoveSelection();
|
||||
|
|
@ -1296,10 +1306,10 @@ void LineEdit::DragLeave()
|
|||
|
||||
void LineEdit::LeftDrag(Point p, dword flags)
|
||||
{
|
||||
int c = GetMousePos(p);
|
||||
int l, h;
|
||||
int64 c = GetMousePos(p);
|
||||
int64 l, h;
|
||||
if(!HasCapture() && GetSelection(l, h) && c >= l && c < h) {
|
||||
WString sample = GetW(l, min(h - l, 3000));
|
||||
WString sample = GetW(l, (int)min(h - l, (int64)3000));
|
||||
Size sz = StdSampleSize();
|
||||
ImageDraw iw(sz);
|
||||
iw.DrawRect(sz, Black());
|
||||
|
|
|
|||
|
|
@ -63,13 +63,16 @@ void TextCtrl::CancelMode()
|
|||
|
||||
void TextCtrl::Clear()
|
||||
{
|
||||
cline = cpos = 0;
|
||||
GuiLock __;
|
||||
view = NULL;
|
||||
viewlines = 0;
|
||||
cline = 0;
|
||||
cpos = 0;
|
||||
total = 0;
|
||||
truncated = false;
|
||||
line.Clear();
|
||||
line.Shrink();
|
||||
lin.Clear();
|
||||
ClearLines();
|
||||
line.Add();
|
||||
lin.Add();
|
||||
InsertLines(0, 1);
|
||||
DirtyFrom(0);
|
||||
undo.Clear();
|
||||
|
|
@ -95,23 +98,25 @@ void TextCtrl::PostRemove(int pos, int size) {}
|
|||
void TextCtrl::RefreshLine(int i) {}
|
||||
void TextCtrl::InvalidateLine(int i) {}
|
||||
void TextCtrl::SetSb() {}
|
||||
void TextCtrl::PlaceCaret(int newcursor, bool sel) {}
|
||||
void TextCtrl::PlaceCaret(int64 newcursor, bool sel) {}
|
||||
|
||||
int TextCtrl::RemoveRectSelection() { return 0; }
|
||||
WString TextCtrl::CopyRectSelection() { return Null; }
|
||||
int TextCtrl::PasteRectSelection(const WString& s) { return 0; }
|
||||
|
||||
void TextCtrl::CachePos(int pos)
|
||||
void TextCtrl::CachePos(int64 pos)
|
||||
{
|
||||
int p = pos;
|
||||
cline = GetLinePos(p);
|
||||
GuiLock __;
|
||||
int64 p = pos;
|
||||
cline = GetLinePos64(p);
|
||||
cpos = pos - p;
|
||||
}
|
||||
|
||||
void TextCtrl::CacheLinePos(int linei)
|
||||
{
|
||||
GuiLock __;
|
||||
if(linei >= 0 && linei < GetLineCount()) {
|
||||
cpos = GetPos(linei);
|
||||
cpos = GetPos64(linei);
|
||||
cline = linei;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,15 +127,25 @@ bool TextCtrl::IsUnicodeCharset(byte charset)
|
|||
CHARSET_UTF16_LE_BOM, CHARSET_UTF16_BE_BOM) >= 0;
|
||||
}
|
||||
|
||||
int TextCtrl::Load(Stream& in, byte charset) {
|
||||
int TextCtrl::Load0(Stream& in, byte charset, bool view) {
|
||||
GuiLock __;
|
||||
Clear();
|
||||
line.Clear();
|
||||
lin.Clear();
|
||||
ClearLines();
|
||||
StringBuffer ln;
|
||||
total = 0;
|
||||
SetCharset(charset);
|
||||
charset = ResolveCharset(charset);
|
||||
truncated = false;
|
||||
viewlines = 0;
|
||||
this->view = NULL;
|
||||
view_all = false;
|
||||
offset256.Clear();
|
||||
total256.Clear();
|
||||
view_cache[0].blk = view_cache[1].blk = -1;
|
||||
if(view) {
|
||||
this->view = ∈
|
||||
SetReadOnly();
|
||||
}
|
||||
if(charset == CHARSET_UTF8_BOM && in.GetLeft() >= 3) {
|
||||
int64 pos = in.GetPos();
|
||||
byte h[3];
|
||||
|
|
@ -146,16 +161,41 @@ int TextCtrl::Load(Stream& in, byte charset) {
|
|||
in.Seek(pos);
|
||||
charset = be16 ? CHARSET_UTF16_BE : CHARSET_UTF16_LE;
|
||||
}
|
||||
|
||||
if(view) {
|
||||
view_loading_pos = in.GetPos();
|
||||
view_loading_lock = 0;
|
||||
ViewLoading();
|
||||
PlaceCaret(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int m = LoadLines(lin, INT_MAX, total, in, charset, max_line_len, max_total, truncated);
|
||||
|
||||
InsertLines(0, lin.GetCount());
|
||||
Update();
|
||||
SetSb();
|
||||
PlaceCaret(0);
|
||||
return m;
|
||||
}
|
||||
|
||||
int TextCtrl::LoadLines(Vector<Ln>& ls, int n, int64& total, Stream& in, byte charset, int max_line_len, int max_total, bool& truncated) const
|
||||
{
|
||||
StringBuffer ln;
|
||||
bool cr = false;
|
||||
byte b8 = 0;
|
||||
if(charset == CHARSET_UTF16_LE || charset == CHARSET_UTF16_BE) {
|
||||
WStringBuffer wln;
|
||||
auto put_wln = [&]() {
|
||||
Ln& ln = ls.Add();
|
||||
ln.len = wln.GetCount();
|
||||
ln.text = ToUtf8(~wln, ln.len);
|
||||
};
|
||||
for(;;) {
|
||||
int c = charset == CHARSET_UTF16_LE ? in.Get16le() : in.Get16be();
|
||||
if(c < 0) {
|
||||
WString l = wln;
|
||||
line.Add(l);
|
||||
total += l.GetCount();
|
||||
total += wln.GetCount();
|
||||
put_wln();
|
||||
goto finish;
|
||||
}
|
||||
if(c == '\r')
|
||||
|
|
@ -163,9 +203,10 @@ int TextCtrl::Load(Stream& in, byte charset) {
|
|||
else
|
||||
if(c == '\n') {
|
||||
truncate_line:
|
||||
WString l = wln;
|
||||
line.Add(l);
|
||||
total += l.GetCount() + 1;
|
||||
total += wln.GetCount() + 1;
|
||||
put_wln();
|
||||
if(ls.GetCount() >= n)
|
||||
goto finish;
|
||||
wln.Clear();
|
||||
}
|
||||
else {
|
||||
|
|
@ -175,10 +216,11 @@ int TextCtrl::Load(Stream& in, byte charset) {
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
for(;;) {
|
||||
byte h[200];
|
||||
int size;
|
||||
int64 pos = in.GetPos();
|
||||
const byte *s = in.GetSzPtr(size);
|
||||
if(size == 0) {
|
||||
size = in.Get(h, 200);
|
||||
|
|
@ -186,6 +228,7 @@ int TextCtrl::Load(Stream& in, byte charset) {
|
|||
if(size == 0)
|
||||
break;
|
||||
}
|
||||
const byte *posptr = s;
|
||||
const byte *e = s + size;
|
||||
while(s < e) {
|
||||
const byte *b = s;
|
||||
|
|
@ -206,32 +249,37 @@ int TextCtrl::Load(Stream& in, byte charset) {
|
|||
ln.Cat((const char *)b, (const char *)s);
|
||||
}
|
||||
auto put_ln = [&]() -> bool {
|
||||
int len = charset == CHARSET_UTF8 && (b8 & 0x80) ? utf8len(~ln, ln.GetCount()) : ln.GetCount();
|
||||
if(total + len + 1 > max_total) {
|
||||
Ln& l = ls.Add();
|
||||
if(charset == CHARSET_UTF8) {
|
||||
l.len = CHARSET_UTF8 && (b8 & 0x80) ? utf8len(~ln, ln.GetCount()) : ln.GetCount();
|
||||
l.text = ln;
|
||||
}
|
||||
else {
|
||||
l.len = ln.GetCount();
|
||||
l.text = ToCharset(CHARSET_UTF8, ln, charset);
|
||||
}
|
||||
if(total + l.len + 1 > max_total) {
|
||||
ls.Drop();
|
||||
truncated = true;
|
||||
return false;
|
||||
}
|
||||
total += len + 1;
|
||||
Ln& l = line.Add();
|
||||
l.len = len;
|
||||
if(charset == CHARSET_UTF8)
|
||||
l.text = ln;
|
||||
else {
|
||||
String h = ln;
|
||||
l.text = ToCharset(CHARSET_UTF8, h, charset);
|
||||
}
|
||||
total += l.len + 1;
|
||||
return true;
|
||||
};
|
||||
while(ln.GetCount() >= max_line_len) {
|
||||
int ei = max_line_len;
|
||||
if(charset == CHARSET_UTF8)
|
||||
while(ei > 0 && ei > max_line_len - 6 && !((byte)ln[ei] < 128 || IsUtf8Lead((byte)ln[ei]))) // break line at whole utf8 codepoint if possible
|
||||
while(ei > 0 && ei > max_line_len - 6 && !((byte)ln[ei] < 128 || IsUtf8Lead((byte)ln[ei]))) // break lse at whole utf8 codepoint if possible
|
||||
ei--;
|
||||
String nln(~ln + ei, ln.GetCount() - ei);
|
||||
ln.SetCount(ei);
|
||||
truncated = true;
|
||||
if(!put_ln())
|
||||
goto out_of_limit;
|
||||
if(ls.GetCount() >= n) {
|
||||
in.Seek(s - posptr + pos);
|
||||
goto finish;
|
||||
}
|
||||
ln = nln;
|
||||
}
|
||||
if(s < e && *s == '\r') {
|
||||
|
|
@ -241,27 +289,156 @@ int TextCtrl::Load(Stream& in, byte charset) {
|
|||
if(s < e && *s == '\n') {
|
||||
if(!put_ln())
|
||||
goto out_of_limit;
|
||||
s++;
|
||||
if(ls.GetCount() >= n) {
|
||||
in.Seek(s - posptr + pos);
|
||||
goto finish;
|
||||
}
|
||||
ln.Clear();
|
||||
b8 = 0;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out_of_limit:
|
||||
{
|
||||
WString w = ToUnicode(~ln, ln.GetCount(), charset);
|
||||
if(total + w.GetLength() <= max_total) {
|
||||
line.Add(w);
|
||||
total += w.GetLength();
|
||||
Ln& ln = ls.Add();
|
||||
ln.len = w.GetCount();
|
||||
ln.text = ToUtf8(~w, ln.len);
|
||||
total += ln.len;
|
||||
}
|
||||
}
|
||||
finish:
|
||||
InsertLines(0, line.GetCount());
|
||||
Update();
|
||||
return ls.GetCount() > 1 ? cr ? LE_CRLF : LE_LF : LE_DEFAULT;
|
||||
}
|
||||
|
||||
void TextCtrl::ViewLoading()
|
||||
{
|
||||
GuiLock __;
|
||||
if(view_all || !view)
|
||||
return;
|
||||
int start = msecs();
|
||||
view->Seek(view_loading_pos);
|
||||
int lines0 = viewlines;
|
||||
for(;;) {
|
||||
offset256.Add(view->GetPos());
|
||||
Vector<Ln> l;
|
||||
bool b;
|
||||
int64 t = 0;
|
||||
|
||||
LoadLines(l, 256, t, *view, charset, 10000, INT_MAX, b);
|
||||
viewlines += l.GetCount();
|
||||
total += t;
|
||||
total256.Add((int)t);
|
||||
|
||||
#ifdef CPU_32
|
||||
enum { MAX_LINES = 128000000 };
|
||||
#else
|
||||
enum { MAX_LINES = INT_MAX - 512 };
|
||||
#endif
|
||||
|
||||
if(view->IsEof() || viewlines > INT_MAX - 512) {
|
||||
WhenViewMapping(view->GetPos());
|
||||
view_all = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(view_loading_lock) {
|
||||
view_loading_pos = view->GetPos();
|
||||
WhenViewMapping(view_loading_pos);
|
||||
break;
|
||||
}
|
||||
|
||||
if(msecs(start) > 20) {
|
||||
view_loading_pos = view->GetPos();
|
||||
PostCallback([=] { ViewLoading(); });
|
||||
WhenViewMapping(view_loading_pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
InsertLines(lines0, viewlines - lines0);
|
||||
SetSb();
|
||||
PlaceCaret(0);
|
||||
return line.GetCount() > 1 ? cr ? LE_CRLF : LE_LF : LE_DEFAULT;
|
||||
Update();
|
||||
}
|
||||
|
||||
void TextCtrl::UnlockViewMapping()
|
||||
{
|
||||
view_loading_lock--;
|
||||
ViewLoading();
|
||||
}
|
||||
|
||||
void TextCtrl::WaitView(int line, bool progress)
|
||||
{
|
||||
if(view)
|
||||
if(progress) {
|
||||
LockViewMapping();
|
||||
Progress pi("Scanning the file");
|
||||
pi.Delay(1000);
|
||||
while(view && !view_all && viewlines < line) {
|
||||
if(pi.SetCanceled(int(view_loading_pos >> 10), int(view->GetSize()) >> 10))
|
||||
break;
|
||||
ViewLoading();
|
||||
}
|
||||
UnlockViewMapping();
|
||||
}
|
||||
else
|
||||
while(view && !view_all && viewlines <= line)
|
||||
ViewLoading();
|
||||
}
|
||||
|
||||
void TextCtrl::SerializeViewMap(Stream& s)
|
||||
{
|
||||
GuiLock __;
|
||||
int version = 0;
|
||||
s / version;
|
||||
s.Magic(327845692);
|
||||
s % view_loading_pos
|
||||
% total
|
||||
% viewlines
|
||||
% view_all
|
||||
% total256
|
||||
% offset256
|
||||
;
|
||||
if(s.IsLoading()) {
|
||||
SetSb();
|
||||
Update();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
const TextCtrl::Ln& TextCtrl::GetLn(int i) const
|
||||
{
|
||||
if(view) {
|
||||
GuiLock __;
|
||||
int blk = i >> 8;
|
||||
if(view_cache[0].blk != blk)
|
||||
Swap(view_cache[0], view_cache[1]); // trivial LRU
|
||||
if(view_cache[0].blk != blk) {
|
||||
Swap(view_cache[0], view_cache[1]); // trivial LRU
|
||||
view->Seek(offset256[blk]);
|
||||
int64 t = 0;
|
||||
bool b;
|
||||
view_cache[0].line.Clear();
|
||||
view_cache[0].blk = blk;
|
||||
LoadLines(view_cache[0].line, 256, t, *view, charset, 5000, INT_MAX, b);
|
||||
}
|
||||
return view_cache[0].line[i & 255];
|
||||
}
|
||||
else
|
||||
return lin[i];
|
||||
}
|
||||
|
||||
const String& TextCtrl::GetUtf8Line(int i) const
|
||||
{
|
||||
return GetLn(i).text;
|
||||
}
|
||||
|
||||
int TextCtrl::GetLineLength(int i) const
|
||||
{
|
||||
return GetLn(i).len;
|
||||
}
|
||||
|
||||
void TextCtrl::Save(Stream& s, byte charset, int line_endings) const {
|
||||
|
|
@ -296,10 +473,10 @@ void TextCtrl::Save(Stream& s, byte charset, int line_endings) const {
|
|||
if(!be16)
|
||||
wle.Cat(0);
|
||||
}
|
||||
for(int i = 0; i < line.GetCount(); i++) {
|
||||
for(int i = 0; i < GetLineCount(); i++) {
|
||||
if(i)
|
||||
s.Put(wle);
|
||||
WString txt = line[i];
|
||||
WString txt = GetWLine(i);
|
||||
const wchar *e = txt.End();
|
||||
if(be16)
|
||||
for(const wchar *w = txt; w != e; w++)
|
||||
|
|
@ -310,13 +487,13 @@ void TextCtrl::Save(Stream& s, byte charset, int line_endings) const {
|
|||
}
|
||||
return;
|
||||
}
|
||||
for(int i = 0; i < line.GetCount(); i++) {
|
||||
for(int i = 0; i < GetLineCount(); i++) {
|
||||
if(i)
|
||||
s.Put(le);
|
||||
if(charset == CHARSET_UTF8)
|
||||
s.Put(line[i].text);
|
||||
s.Put(GetUtf8Line(i));
|
||||
else {
|
||||
String txt = FromUnicode(line[i], charset);
|
||||
String txt = FromUnicode(GetWLine(i), charset);
|
||||
const char *e = txt.End();
|
||||
for(const char *w = txt; w != e; w++)
|
||||
s.Put(*w == DEFAULTCHAR ? '?' : *w);
|
||||
|
|
@ -340,8 +517,8 @@ int TextCtrl::GetInvalidCharPos(byte charset) const
|
|||
{
|
||||
int q = 0;
|
||||
if(!IsUnicodeCharset(charset))
|
||||
for(int i = 0; i < line.GetCount(); i++) {
|
||||
WString txt = line[i];
|
||||
for(int i = 0; i < GetLineCount(); i++) {
|
||||
WString txt = GetWLine(i);
|
||||
WString ctxt = ToUnicode(FromUnicode(txt, charset), charset);
|
||||
for(int w = 0; w < txt.GetLength(); w++)
|
||||
if(txt[w] != ctxt[w])
|
||||
|
|
@ -394,17 +571,17 @@ Value TextCtrl::GetData() const
|
|||
String TextCtrl::GetEncodedLine(int i, byte charset) const
|
||||
{
|
||||
charset = ResolveCharset(charset);
|
||||
if(charset == CHARSET_UTF8)
|
||||
return line[i].text;
|
||||
return FromUnicode(FromUtf8(line[i].text), charset);
|
||||
String h = GetUtf8Line(i);
|
||||
return charset == CHARSET_UTF8 ? h : FromUnicode(FromUtf8(h), charset);
|
||||
}
|
||||
|
||||
int TextCtrl::GetLinePos(int& pos) const {
|
||||
if(pos < cpos && cpos - pos < pos) {
|
||||
int TextCtrl::GetLinePos64(int64& pos) const {
|
||||
GuiLock __;
|
||||
if(pos < cpos && cpos - pos < pos && !view) {
|
||||
int i = cline;
|
||||
int ps = cpos;
|
||||
int64 ps = cpos;
|
||||
for(;;) {
|
||||
ps -= line[--i].GetLength() + 1;
|
||||
ps -= GetLineLength(--i) + 1;
|
||||
if(ps <= pos) {
|
||||
pos = pos - ps;
|
||||
return i;
|
||||
|
|
@ -413,59 +590,83 @@ int TextCtrl::GetLinePos(int& pos) const {
|
|||
}
|
||||
else {
|
||||
int i = 0;
|
||||
if(view) {
|
||||
GuiLock __;
|
||||
int blk = 0;
|
||||
for(;;) {
|
||||
int n = total256[blk];
|
||||
if(pos < n)
|
||||
break;
|
||||
pos -= n;
|
||||
blk++;
|
||||
if(blk >= total256.GetCount()) {
|
||||
pos = GetLineLength(GetLineCount() - 1);
|
||||
return GetLineCount() - 1;
|
||||
}
|
||||
}
|
||||
i = blk << 8;
|
||||
}
|
||||
else
|
||||
if(pos >= cpos) {
|
||||
pos -= cpos;
|
||||
i = cline;
|
||||
}
|
||||
for(;;) {
|
||||
int n = line[i].GetLength() + 1;
|
||||
int n = GetLineLength(i) + 1;
|
||||
if(pos < n) return i;
|
||||
pos -= n;
|
||||
i++;
|
||||
if(i >= line.GetCount()) {
|
||||
pos = line.Top().GetLength();
|
||||
return line.GetCount() - 1;
|
||||
if(i >= GetLineCount()) {
|
||||
pos = GetLineLength(GetLineCount() - 1);
|
||||
return GetLineCount() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TextCtrl::GetPos(int ln, int lpos) const {
|
||||
ln = minmax(ln, 0, line.GetCount() - 1);
|
||||
int i, pos;
|
||||
if(ln < cline && cline - ln < ln) {
|
||||
int64 TextCtrl::GetPos64(int ln, int lpos) const {
|
||||
GuiLock __;
|
||||
ln = minmax(ln, 0, GetLineCount() - 1);
|
||||
int i;
|
||||
int64 pos;
|
||||
if(ln < cline && cline - ln < ln && !view) {
|
||||
pos = cpos;
|
||||
i = cline;
|
||||
while(i > ln)
|
||||
pos -= line[--i].GetLength() + 1;
|
||||
pos -= GetLineLength(--i) + 1;
|
||||
}
|
||||
else {
|
||||
pos = 0;
|
||||
i = 0;
|
||||
if(view) {
|
||||
for(int j = 0; j < ln >> 8; j++) {
|
||||
pos += total256[j];
|
||||
i += 256;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(ln >= cline) {
|
||||
pos = cpos;
|
||||
i = cline;
|
||||
}
|
||||
else {
|
||||
pos = 0;
|
||||
i = 0;
|
||||
}
|
||||
while(i < ln)
|
||||
pos += line[i++].GetLength() + 1;
|
||||
pos += GetLineLength(i++) + 1;
|
||||
}
|
||||
return pos + min(line[ln].GetLength(), lpos);
|
||||
return pos + min(GetLineLength(ln), lpos);
|
||||
}
|
||||
|
||||
WString TextCtrl::GetW(int pos, int size) const
|
||||
WString TextCtrl::GetW(int64 pos, int size) const
|
||||
{
|
||||
int i = GetLinePos(pos);
|
||||
int i = GetLinePos64(pos);
|
||||
WStringBuffer r;
|
||||
for(;;) {
|
||||
if(i >= line.GetCount()) break;
|
||||
WString ln = line[i++];
|
||||
int sz = min(ln.GetLength() - pos, size);
|
||||
if(i >= GetLineCount()) break;
|
||||
WString ln = GetWLine(i++);
|
||||
int sz = min(LimitSize(ln.GetLength() - pos), size);
|
||||
if(pos == 0 && sz == ln.GetLength())
|
||||
r.Cat(ln);
|
||||
else
|
||||
r.Cat(ln.Mid(pos, sz));
|
||||
r.Cat(ln.Mid((int)pos, sz));
|
||||
size -= sz;
|
||||
if(size == 0) break;
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
|
@ -479,19 +680,22 @@ WString TextCtrl::GetW(int pos, int size) const
|
|||
return r;
|
||||
}
|
||||
|
||||
String TextCtrl::Get(int pos, int size, byte charset) const
|
||||
String TextCtrl::Get(int64 pos, int size, byte charset) const
|
||||
{
|
||||
if(charset == CHARSET_UTF8) {
|
||||
int i = GetLinePos(pos);
|
||||
int i = GetLinePos64(pos);
|
||||
StringBuffer r;
|
||||
for(;;) {
|
||||
if(i >= line.GetCount()) break;
|
||||
int sz = min(line[i].GetLength() - pos, size);
|
||||
const String& ln = line[i++].text;
|
||||
if(pos == 0 && sz == ln.GetLength())
|
||||
r.Cat(ln);
|
||||
if(i >= GetLineCount()) break;
|
||||
int sz = min(LimitSize(GetLineLength(i) - pos), size);
|
||||
const String& h = GetUtf8Line(i);
|
||||
const char *s = h;
|
||||
int n = h.GetCount();
|
||||
i++;
|
||||
if(pos == 0 && sz == n)
|
||||
r.Cat(s, n);
|
||||
else
|
||||
r.Cat(ln.ToWString().Mid(pos, sz).ToString());
|
||||
r.Cat(FromUtf8(s, n).Mid((int)pos, sz).ToString());
|
||||
size -= sz;
|
||||
if(size == 0) break;
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
|
@ -507,26 +711,58 @@ String TextCtrl::Get(int pos, int size, byte charset) const
|
|||
return FromUnicode(GetW(pos, size), charset);
|
||||
}
|
||||
|
||||
int TextCtrl::GetChar(int pos) const {
|
||||
if(pos < 0 || pos >= GetLength())
|
||||
int TextCtrl::GetChar(int64 pos) const {
|
||||
if(pos < 0 || pos >= GetLength64())
|
||||
return 0;
|
||||
int i = GetLinePos(pos);
|
||||
WString ln = line[i];
|
||||
int c = ln.GetLength() == pos ? '\n' : ln[pos];
|
||||
int i = GetLinePos64(pos);
|
||||
WString ln = GetWLine(i);
|
||||
int c = ln.GetLength() == pos ? '\n' : ln[(int)pos];
|
||||
return c;
|
||||
}
|
||||
|
||||
int TextCtrl::Insert0(int pos, const WString& txt) {
|
||||
int TextCtrl::GetLinePos32(int& pos) const
|
||||
{
|
||||
int64 p = pos;
|
||||
int l = GetLinePos64(p);
|
||||
pos = (int)p;
|
||||
return l;
|
||||
}
|
||||
|
||||
bool TextCtrl::GetSelection32(int& l, int& h) const
|
||||
{
|
||||
int64 ll, hh;
|
||||
bool b = GetSelection(ll, hh);
|
||||
if(hh >= INT_MAX)
|
||||
return false;
|
||||
l = (int)ll;
|
||||
h = (int)hh;
|
||||
return b;
|
||||
}
|
||||
|
||||
int TextCtrl::GetCursor32() const
|
||||
{
|
||||
int64 h = GetCursor64();
|
||||
return h < INT_MAX ? (int)h : 0;
|
||||
}
|
||||
|
||||
int TextCtrl::GetLength32() const
|
||||
{
|
||||
int64 h = GetLength64();
|
||||
return h < INT_MAX ? (int)h : 0;
|
||||
}
|
||||
|
||||
int TextCtrl::Insert0(int pos, const WString& txt) { // TODO: Do this with utf8
|
||||
GuiLock __;
|
||||
int inspos = pos;
|
||||
PreInsert(inspos, txt);
|
||||
if(pos < cpos)
|
||||
cpos = cline = 0;
|
||||
int i = GetLinePos(pos);
|
||||
int i = GetLinePos32(pos);
|
||||
DirtyFrom(i);
|
||||
int size = 0;
|
||||
|
||||
WStringBuffer lnb;
|
||||
Vector<Ln> iln;
|
||||
Vector<WString> iln;
|
||||
const wchar *s = txt;
|
||||
while(s < txt.End())
|
||||
if(*s >= ' ') {
|
||||
|
|
@ -545,7 +781,7 @@ int TextCtrl::Insert0(int pos, const WString& txt) {
|
|||
}
|
||||
else
|
||||
if(*s == '\n') {
|
||||
iln.Add(WString(lnb));
|
||||
iln.Add(lnb);
|
||||
size++;
|
||||
lnb.Clear();
|
||||
s++;
|
||||
|
|
@ -553,19 +789,20 @@ int TextCtrl::Insert0(int pos, const WString& txt) {
|
|||
else
|
||||
s++;
|
||||
WString ln = lnb;
|
||||
|
||||
WString l = line[i];
|
||||
WString l = GetWLine(i);
|
||||
if(iln.GetCount()) {
|
||||
iln[0] = l.Mid(0, pos) + WString(iln[0]);
|
||||
iln[0] = l.Mid(0, pos) + iln[0];
|
||||
ln.Cat(l.Mid(pos));
|
||||
line[i] = ln;
|
||||
SetLine(i, ln);
|
||||
InvalidateLine(i);
|
||||
line.Insert(i, iln);
|
||||
LineInsert(i, iln.GetCount());
|
||||
for(int j = 0; j < iln.GetCount(); j++)
|
||||
SetLine(i + j, iln[j]);
|
||||
InsertLines(i, iln.GetCount());
|
||||
Refresh();
|
||||
}
|
||||
else {
|
||||
line[i] = l.Mid(0, pos) + ln + l.Mid(pos);
|
||||
SetLine(i, l.Mid(0, pos) + ln + l.Mid(pos));
|
||||
InvalidateLine(i);
|
||||
RefreshLine(i);
|
||||
}
|
||||
|
|
@ -577,18 +814,19 @@ int TextCtrl::Insert0(int pos, const WString& txt) {
|
|||
}
|
||||
|
||||
void TextCtrl::Remove0(int pos, int size) {
|
||||
GuiLock __;
|
||||
int rmpos = pos, rmsize = size;
|
||||
PreRemove(rmpos, rmsize);
|
||||
total -= size;
|
||||
if(pos < cpos)
|
||||
cpos = cline = 0;
|
||||
int i = GetLinePos(pos);
|
||||
int i = GetLinePos32(pos);
|
||||
DirtyFrom(i);
|
||||
WString ln = line[i];
|
||||
int sz = min(ln.GetLength() - pos, size);
|
||||
WString ln = GetWLine(i);
|
||||
int sz = min(LimitSize(ln.GetLength() - pos), size);
|
||||
ln.Remove(pos, sz);
|
||||
size -= sz;
|
||||
line[i] = ln;
|
||||
SetLine(i, ln);
|
||||
if(size == 0) {
|
||||
InvalidateLine(i);
|
||||
RefreshLine(i);
|
||||
|
|
@ -597,16 +835,16 @@ void TextCtrl::Remove0(int pos, int size) {
|
|||
size--;
|
||||
int j = i + 1;
|
||||
for(;;) {
|
||||
int sz = line[j].GetLength() + 1;
|
||||
int sz = GetLineLength(j) + 1;
|
||||
if(sz > size) break;
|
||||
j++;
|
||||
size -= sz;
|
||||
}
|
||||
WString p1 = line[i];
|
||||
WString p2 = line[j];
|
||||
WString p1 = GetWLine(i);
|
||||
WString p2 = GetWLine(j);
|
||||
p1.Insert(p1.GetLength(), p2.Mid(size, p2.GetLength() - size));
|
||||
line[i] = p1;
|
||||
line.Remove(i + 1, j - i);
|
||||
SetLine(i, p1);
|
||||
LineRemove(i + 1, j - i);
|
||||
RemoveLines(i + 1, j - i);
|
||||
InvalidateLine(i);
|
||||
Refresh();
|
||||
|
|
@ -685,7 +923,7 @@ void TextCtrl::RemoveU(int pos, int size) {
|
|||
u.serial = undoserial;
|
||||
u.pos = pos;
|
||||
u.size = 0;
|
||||
u.text = Get(pos, size, CHARSET_UTF8);
|
||||
u.SetText(Get(pos, size, CHARSET_UTF8));
|
||||
u.typing = false;
|
||||
}
|
||||
Remove0(pos, size);
|
||||
|
|
@ -730,11 +968,11 @@ void TextCtrl::Undo() {
|
|||
CachePos(r.pos);
|
||||
if(u.size) {
|
||||
r.size = 0;
|
||||
r.text = Get(u.pos, u.size, CHARSET_UTF8);
|
||||
r.SetText(Get(u.pos, u.size, CHARSET_UTF8));
|
||||
Remove0(u.pos, u.size);
|
||||
}
|
||||
else {
|
||||
WString text = FromUtf8(u.text);
|
||||
WString text = FromUtf8(u.GetText());
|
||||
r.size = Insert0(u.pos, text);
|
||||
nc += r.size;
|
||||
}
|
||||
|
|
@ -761,7 +999,7 @@ void TextCtrl::Redo() {
|
|||
if(r.size)
|
||||
RemoveU(r.pos, r.size);
|
||||
else
|
||||
nc += InsertU(r.pos, FromUtf8(r.text));
|
||||
nc += InsertU(r.pos, FromUtf8(r.GetText()));
|
||||
redo.DropTail();
|
||||
IncDirty();
|
||||
}
|
||||
|
|
@ -777,16 +1015,16 @@ void TextCtrl::ClearSelection() {
|
|||
WhenSel();
|
||||
}
|
||||
|
||||
void TextCtrl::SetSelection(int l, int h) {
|
||||
void TextCtrl::SetSelection(int64 l, int64 h) {
|
||||
if(l != h) {
|
||||
PlaceCaret(minmax(l, 0, total), false);
|
||||
PlaceCaret(minmax(h, 0, total), true);
|
||||
PlaceCaret(minmax(l, (int64)0, total), false);
|
||||
PlaceCaret(minmax(h, (int64)0, total), true);
|
||||
}
|
||||
else
|
||||
SetCursor(l);
|
||||
}
|
||||
|
||||
bool TextCtrl::GetSelection(int& l, int& h) const {
|
||||
bool TextCtrl::GetSelection(int64& l, int64& h) const {
|
||||
if(anchor < 0) {
|
||||
l = h = cursor;
|
||||
return false;
|
||||
|
|
@ -799,27 +1037,27 @@ bool TextCtrl::GetSelection(int& l, int& h) const {
|
|||
}
|
||||
|
||||
String TextCtrl::GetSelection(byte charset) const {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(GetSelection(l, h))
|
||||
return Get(l, h - l, charset);
|
||||
return Get(l, LimitSize(h - l), charset);
|
||||
return String();
|
||||
}
|
||||
|
||||
WString TextCtrl::GetSelectionW() const {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(GetSelection(l, h))
|
||||
return GetW(l, h - l);
|
||||
return GetW(l, LimitSize(h - l));
|
||||
return WString();
|
||||
}
|
||||
|
||||
bool TextCtrl::RemoveSelection() {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(anchor < 0) return false;
|
||||
if(IsRectSelection())
|
||||
l = RemoveRectSelection();
|
||||
else {
|
||||
GetSelection(l, h);
|
||||
Remove(l, h - l);
|
||||
Remove((int)l, int(h - l));
|
||||
}
|
||||
anchor = -1;
|
||||
Refresh();
|
||||
|
|
@ -842,17 +1080,17 @@ void TextCtrl::Cut() {
|
|||
}
|
||||
|
||||
void TextCtrl::Copy() {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(!GetSelection(l, h) && !IsAnySelection()) {
|
||||
int i = GetLine(cursor);
|
||||
l = GetPos(i);
|
||||
h = l + line[i].GetLength() + 1;
|
||||
l = GetPos64(i);
|
||||
h = l + GetLineLength(i) + 1;
|
||||
}
|
||||
WString txt;
|
||||
if(IsRectSelection())
|
||||
txt = CopyRectSelection();
|
||||
else
|
||||
txt = GetW(l, h - l);
|
||||
txt = GetW(l, LimitSize(h - l));
|
||||
ClearClipboard();
|
||||
AppendClipboardUnicodeText(txt);
|
||||
AppendClipboardText(txt.ToString());
|
||||
|
|
@ -869,7 +1107,7 @@ int TextCtrl::Paste(const WString& text) {
|
|||
n = PasteRectSelection(text);
|
||||
else {
|
||||
RemoveSelection();
|
||||
n = Insert(cursor, text);
|
||||
n = Insert((int)cursor, text);
|
||||
PlaceCaret(cursor + n);
|
||||
}
|
||||
Refresh();
|
||||
|
|
@ -927,7 +1165,7 @@ void TextCtrl::StdBar(Bar& menu) {
|
|||
t_("Erase"), CtrlImg::remove(), THISBACK(DoRemoveSelection))
|
||||
.Key(K_DELETE);
|
||||
menu.Separator();
|
||||
menu.Add(GetLength(),
|
||||
menu.Add(GetLength64(),
|
||||
t_("Select all"), CtrlImg::select_all(), THISBACK(SelectAll))
|
||||
.Key(K_CTRL_A);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,11 @@ public:
|
|||
int serial;
|
||||
int pos;
|
||||
int size;
|
||||
String text;
|
||||
String data;
|
||||
bool typing;
|
||||
|
||||
void SetText(const String& text) { data = FastCompress(text); }
|
||||
String GetText() const { return FastDecompress(data); }
|
||||
};
|
||||
|
||||
struct UndoData {
|
||||
|
|
@ -36,6 +39,9 @@ public:
|
|||
};
|
||||
|
||||
protected:
|
||||
virtual int64 GetTotal() const { return total; }
|
||||
virtual int GetCharAt(int64 i) const { return GetChar(i); }
|
||||
|
||||
virtual void DirtyFrom(int line);
|
||||
virtual void SelectionChanged();
|
||||
virtual void ClearLines();
|
||||
|
|
@ -46,7 +52,7 @@ protected:
|
|||
virtual void PreRemove(int pos, int size);
|
||||
virtual void PostRemove(int pos, int size);
|
||||
virtual void SetSb();
|
||||
virtual void PlaceCaret(int newcursor, bool sel = false);
|
||||
virtual void PlaceCaret(int64 newcursor, bool sel = false);
|
||||
virtual void InvalidateLine(int i);
|
||||
virtual int RemoveRectSelection();
|
||||
virtual WString CopyRectSelection();
|
||||
|
|
@ -57,17 +63,15 @@ protected:
|
|||
int len;
|
||||
String text;
|
||||
|
||||
int GetLength() const { return len; }
|
||||
operator WString() const { return FromUtf8(text); }
|
||||
|
||||
Ln(const WString& wtext) { text = ToUtf8(wtext); len = wtext.GetLength(); }
|
||||
Ln() { len = 0; }
|
||||
};
|
||||
|
||||
Vector<Ln> line;
|
||||
int total;
|
||||
int cline, cpos;
|
||||
int cursor, anchor;
|
||||
Vector<Ln> lin;
|
||||
int64 total;
|
||||
|
||||
int64 cpos;
|
||||
int cline;
|
||||
int64 cursor, anchor;
|
||||
int undoserial;
|
||||
bool rectsel;
|
||||
bool incundoserial;
|
||||
|
|
@ -89,6 +93,20 @@ protected:
|
|||
bool nobg;
|
||||
int max_total;
|
||||
int max_line_len;
|
||||
|
||||
mutable Stream *view;
|
||||
struct ViewCache {
|
||||
int blk;
|
||||
Vector<Ln> line;
|
||||
};
|
||||
mutable ViewCache view_cache[2];
|
||||
mutable int viewlines;
|
||||
|
||||
Vector<int64> offset256;
|
||||
Vector<int> total256;
|
||||
int view_loading_lock;
|
||||
int64 view_loading_pos;
|
||||
bool view_all;
|
||||
|
||||
void IncDirty();
|
||||
void DecDirty();
|
||||
|
|
@ -103,67 +121,88 @@ protected:
|
|||
void RefreshLines(int l1, int l2);
|
||||
static bool IsUnicodeCharset(byte charset);
|
||||
|
||||
int Load0(Stream& in, byte charset, bool view);
|
||||
int LoadLines(Vector<Ln>& ls, int n, int64& total, Stream& in, byte charset,
|
||||
int max_line_len, int max_total, bool& truncated) const;
|
||||
void ViewLoading();
|
||||
|
||||
void SetLine(int i, const String& txt, int len) { lin[i].text = txt; lin[i].len = len; }
|
||||
void SetLine(int i, const WString& w) { SetLine(i, ToUtf8(w), w.GetCount()); }
|
||||
void LineRemove(int i, int n) { lin.Remove(i, n); }
|
||||
void LineInsert(int i, int n) { lin.InsertN(i, n); }
|
||||
const Ln& GetLn(int i) const;
|
||||
|
||||
int GetLinePos32(int& pos) const;
|
||||
bool GetSelection32(int& l, int& h) const;
|
||||
int GetPos32(int line, int column = 0) const { return (int)GetPos64(line, column); }
|
||||
int GetLength32() const;
|
||||
int GetCursor32() const;
|
||||
|
||||
public:
|
||||
virtual void RefreshLine(int i);
|
||||
|
||||
Event<Bar&> WhenBar;
|
||||
Event<> WhenState;
|
||||
Event<> WhenSel;
|
||||
Event<Bar&> WhenBar;
|
||||
Event<> WhenState;
|
||||
Event<> WhenSel;
|
||||
Event<int64> WhenViewMapping;
|
||||
|
||||
void CachePos(int pos);
|
||||
void CachePos(int64 pos);
|
||||
void CacheLinePos(int linei);
|
||||
|
||||
enum CS { CHARSET_UTF8_BOM = 250, CHARSET_UTF16_LE, CHARSET_UTF16_BE, CHARSET_UTF16_LE_BOM, CHARSET_UTF16_BE_BOM };
|
||||
enum LE { LE_DEFAULT, LE_CRLF, LE_LF };
|
||||
|
||||
int Load(Stream& s, byte charset = CHARSET_DEFAULT);
|
||||
int Load(Stream& s, byte charset = CHARSET_DEFAULT) { return Load0(s, charset, false); }
|
||||
bool IsTruncated() const { return truncated; }
|
||||
void Save(Stream& s, byte charset = CHARSET_DEFAULT, int line_endings = LE_DEFAULT) const;
|
||||
|
||||
int GetInvalidCharPos(byte charset = CHARSET_DEFAULT) const;
|
||||
bool CheckCharset(byte charset = CHARSET_DEFAULT) const { return GetInvalidCharPos(charset) < 0; }
|
||||
|
||||
int LimitSize(int64 size) const { return int(view ? min((int64)max_total, size) : size); }
|
||||
|
||||
int GetLinePos(int& pos) const { return GetLinePos32(pos); }
|
||||
int GetPos(int line, int column = 0) const { return GetPos32(line, column); }
|
||||
|
||||
void Set(const WString& s);
|
||||
void Set(const String& s, byte charset = CHARSET_DEFAULT);
|
||||
String Get(byte charset = CHARSET_DEFAULT) const;
|
||||
String Get(int pos, int size, byte charset = CHARSET_DEFAULT) const;
|
||||
WString GetW(int pos, int size) const;
|
||||
WString GetW() const { return GetW(0, GetLength()); }
|
||||
String Get(int64 pos, int size, byte charset = CHARSET_DEFAULT) const;
|
||||
WString GetW(int64 pos, int size) const;
|
||||
WString GetW() const { return GetW(0, LimitSize(GetLength64())); }
|
||||
|
||||
void ClearDirty();
|
||||
bool IsDirty() const { return dirty; }
|
||||
|
||||
void Clear();
|
||||
|
||||
int GetLinePos(int& pos) const;
|
||||
int GetPos(int line, int column) const;
|
||||
int GetPos(int line) const { return GetPos(line, 0); }
|
||||
int GetLine(int pos) const { return GetLinePos(pos); }
|
||||
int GetLine(int64 pos) const { return GetLinePos64(pos); }
|
||||
|
||||
const String& GetUtf8Line(int i) const { return line[i].text; }
|
||||
WString GetWLine(int i) const { return FromUtf8(line[i].text); }
|
||||
const String& GetUtf8Line(int i) const;
|
||||
WString GetWLine(int i) const { return FromUtf8(GetUtf8Line(i)); }
|
||||
String GetEncodedLine(int i, byte charset = CHARSET_DEFAULT) const;
|
||||
int GetLineLength(int i) const { return line[i].GetLength(); }
|
||||
int GetLineLength(int i) const;
|
||||
|
||||
int GetLineCount() const { return line.GetCount(); }
|
||||
int GetChar(int pos) const;
|
||||
int GetChar() const { return cursor < total ? GetChar(cursor) : 0; }
|
||||
int operator[](int pos) const { return GetChar(pos); }
|
||||
int GetLength() const { return total; }
|
||||
int GetLength() const { return GetLength32(); }
|
||||
int GetLineCount() const { return view ? viewlines : lin.GetCount(); }
|
||||
int GetChar(int64 pos) const;
|
||||
int GetChar() const { return cursor < GetLength64() ? GetChar(cursor) : 0; }
|
||||
int operator[](int64 pos) const { return GetChar(pos); }
|
||||
|
||||
int GetCursor() const { return cursor; }
|
||||
int GetCursorLine() { return GetLine(GetCursor()); }
|
||||
int GetCursor() const { return GetCursor32(); }
|
||||
int GetCursorLine() const { return GetLine(GetCursor64()); }
|
||||
|
||||
void SetSelection(int anchor = 0, int cursor = INT_MAX);
|
||||
void SetSelection(int64 anchor = 0, int64 cursor = INT_MAX);
|
||||
bool IsSelection() const { return IsAnySelection() && !rectsel; }
|
||||
bool IsRectSelection() const { return IsAnySelection() && rectsel; }
|
||||
bool IsAnySelection() const { return anchor >= 0 && anchor != cursor; }
|
||||
bool GetSelection(int& l, int& h) const;
|
||||
bool GetSelection(int& l, int& h) const{ return GetSelection32(l, h); }
|
||||
bool GetSelection(int64& l, int64& h) const;
|
||||
String GetSelection(byte charset = CHARSET_DEFAULT) const;
|
||||
WString GetSelectionW() const;
|
||||
void ClearSelection();
|
||||
bool RemoveSelection();
|
||||
void SetCursor(int cursor) { PlaceCaret(cursor); }
|
||||
void SetCursor(int64 cursor) { PlaceCaret(cursor); }
|
||||
int Paste(const WString& text);
|
||||
|
||||
int Insert(int pos, const WString& txt) { return Insert(pos, txt, false); }
|
||||
|
|
@ -195,6 +234,19 @@ public:
|
|||
void SetColor(int i, Color c) { color[i] = c; Refresh(); }
|
||||
Color GetColor(int i) const { return color[i]; }
|
||||
|
||||
int View(Stream& s, byte charset = CHARSET_DEFAULT) { return Load0(s, charset, true); }
|
||||
void WaitView(int line = INT_MAX, bool progress = false);
|
||||
void LockViewMapping() { view_loading_lock++; }
|
||||
void UnlockViewMapping();
|
||||
void SerializeViewMap(Stream& s);
|
||||
bool IsView() const { return view; }
|
||||
int64 GetViewSize() const { return view ? view->GetSize() : 0; }
|
||||
|
||||
int GetLinePos64(int64& pos) const;
|
||||
int64 GetPos64(int line, int column = 0) const;
|
||||
int64 GetLength64() const { return total; }
|
||||
int64 GetCursor64() const { return cursor; }
|
||||
|
||||
TextCtrl& UndoSteps(int n) { undosteps = n; Undodo(); return *this; }
|
||||
int GetUndoSteps() const { return undosteps; }
|
||||
TextCtrl& ProcessTab(bool b = true) { processtab = b; return *this; }
|
||||
|
|
@ -235,7 +287,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void SetSb();
|
||||
virtual void PlaceCaret(int newcursor, bool sel = false);
|
||||
virtual void PlaceCaret(int64 newcursor, bool sel = false);
|
||||
virtual int RemoveRectSelection();
|
||||
virtual WString CopyRectSelection();
|
||||
virtual int PasteRectSelection(const WString& s);
|
||||
|
|
@ -261,8 +313,8 @@ public:
|
|||
};
|
||||
|
||||
struct EditPos : Moveable<EditPos> {
|
||||
int sby;
|
||||
int cursor;
|
||||
int sby;
|
||||
int64 cursor;
|
||||
|
||||
void Serialize(Stream& s);
|
||||
void Clear() { sby = 0; cursor = 0; }
|
||||
|
|
@ -270,12 +322,12 @@ public:
|
|||
};
|
||||
|
||||
protected:
|
||||
virtual void HighlightLine(int line, Vector<Highlight>& h, int pos);
|
||||
virtual void HighlightLine(int line, Vector<Highlight>& h, int64 pos);
|
||||
virtual void NewScrollPos();
|
||||
|
||||
ScrollBars sb;
|
||||
int gcolumn;
|
||||
int mpos;
|
||||
int64 mpos;
|
||||
|
||||
|
||||
Font font;
|
||||
|
|
@ -303,7 +355,7 @@ protected:
|
|||
void MovePage(int dir, bool sel);
|
||||
|
||||
void PlaceCaret0(Point p);
|
||||
int PlaceCaretNoG(int newcursor, bool sel = false);
|
||||
int PlaceCaretNoG(int64 newcursor, bool sel = false);
|
||||
|
||||
void Scroll();
|
||||
void SetHBar();
|
||||
|
|
@ -314,19 +366,21 @@ protected:
|
|||
struct RefreshDraw;
|
||||
friend class TextCtrl;
|
||||
|
||||
int GetMousePos32(Point p) const { return (int)GetMousePos(p); }
|
||||
|
||||
public:
|
||||
Size GetFontSize() const;
|
||||
int GetGPos(int ln, int cl) const;
|
||||
int GetMousePos(Point p) const;
|
||||
Point GetColumnLine(int pos) const;
|
||||
int GetColumnLinePos(Point pos) const { return GetGPos(pos.y, pos.x); }
|
||||
Point GetIndexLine(int pos) const;
|
||||
int GetIndexLinePos(Point pos) const;
|
||||
int64 GetGPos(int ln, int cl) const;
|
||||
int64 GetMousePos(Point p) const;
|
||||
Point GetColumnLine(int64 pos) const;
|
||||
int64 GetColumnLinePos(Point pos) const { return GetGPos(pos.y, pos.x); }
|
||||
Point GetIndexLine(int64 pos) const;
|
||||
int64 GetIndexLinePos(Point pos) const;
|
||||
|
||||
void SetRectSelection(int l, int h);
|
||||
void SetRectSelection(int64 l, int64 h);
|
||||
void SetRectSelection(const Rect& rect);
|
||||
Rect GetRectSelection() const;
|
||||
bool GetRectSelection(const Rect& rect, int line, int& l, int &h);
|
||||
bool GetRectSelection(const Rect& rect, int line, int64& l, int64& h);
|
||||
|
||||
void ScrollUp() { sb.LineUp(); }
|
||||
void ScrollDown() { sb.LineDown(); }
|
||||
|
|
@ -443,7 +497,7 @@ protected:
|
|||
virtual void ClearLines();
|
||||
virtual void InsertLines(int line, int count);
|
||||
virtual void RemoveLines(int line, int count);
|
||||
virtual void PlaceCaret(int pos, bool select = false);
|
||||
virtual void PlaceCaret(int64 pos, bool select = false);
|
||||
virtual void InvalidateLine(int i);
|
||||
|
||||
struct Para : Moveable<Para> {
|
||||
|
|
|
|||
|
|
@ -107,6 +107,12 @@ from not`-modified to modified (`"dirty`") or back.&]
|
|||
[s2;%% Called when cursor or selection changes.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:WhenViewLoading: [_^Upp`:`:Event^ Event]<[_^Upp`:`:int64^ int64]>
|
||||
_[* WhenViewMapping]&]
|
||||
[s2;%% Called during mapping view stream with current position in
|
||||
the stream.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:CachePos`(int`): [@(0.0.255) void]_[* CachePos]([@(0.0.255) int]_[*@3 pos])&]
|
||||
[s2;%% This is specific optimization hint to the widget saying that
|
||||
following operations will be performed near [%-*@3 pos]. Unlikely
|
||||
|
|
@ -171,14 +177,14 @@ _CHARSET`_DEFAULT)_[@(0.0.255) const]&]
|
|||
[s2;%% Gets the text in the widget.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:Get`(int`,int`,byte`)const: [_^String^ String]_[* Get]([@(0.0.255) int]_[*@3 p
|
||||
os], [@(0.0.255) int]_[*@3 size], [_^byte^ byte]_[*@3 charset]_`=_CHARSET`_DEFAULT)_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:Get`(Upp`:`:int64`,int`,Upp`:`:byte`)const: [_^Upp`:`:String^ S
|
||||
tring]_[* Get]([_^Upp`:`:int64^ int64]_[*@3 pos], [@(0.0.255) int]_[*@3 size],
|
||||
[_^Upp`:`:byte^ byte]_[*@3 charset]_`=_CHARSET`_DEFAULT)_[@(0.0.255) const]&]
|
||||
[s2;%% Gets the part of text in the widget.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetW`(int`,int`)const: [_^WString^ WString]_[* GetW]([@(0.0.255) int]_[*@3 p
|
||||
os], [@(0.0.255) int]_[*@3 size])_[@(0.0.255) const]&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetW`(Upp`:`:int64`,int`)const: [_^Upp`:`:WString^ WString]_[* Ge
|
||||
tW]([_^Upp`:`:int64^ int64]_[*@3 pos], [@(0.0.255) int]_[*@3 size])_[@(0.0.255) const]&]
|
||||
[s2;%% Gets the part of text in the widget in UNICODE.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
|
|
@ -202,6 +208,11 @@ setting it or at ClearDirty).&]
|
|||
[s2;%% Empties the text.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetLine`(Upp`:`:int64`)const: [@(0.0.255) int]_[* GetLine]([_^Upp`:`:int64^ i
|
||||
nt64]_[*@3 pos])_[@(0.0.255) const]&]
|
||||
[s2;%% Similar to GetLinePos, but does not alter [%-*@3 pos] parameter.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetLinePos`(int`&`)const: [@(0.0.255) int]_[* GetLinePos]([@(0.0.255) int`&
|
||||
]_[*@3 pos])_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the line where character at offset [%-*@3 pos] resides;
|
||||
|
|
@ -219,11 +230,6 @@ _[@(0.0.255) const]&]
|
|||
[s2;%% Same as GetPos([%-*@3 line], 0).&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetLine`(int`)const: [@(0.0.255) int]_[* GetLine]([@(0.0.255) int]_[*@3 pos])
|
||||
_[@(0.0.255) const]&]
|
||||
[s2;%% Similar to GetLinePos, but does not alter [%-*@3 pos] parameter.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetUtf8Line`(int`)const: [@(0.0.255) const]_[_^String^ String][@(0.0.255) `&
|
||||
]_[* GetUtf8Line]([@(0.0.255) int]_[*@3 i])_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the line [%-*@3 i] in UTF`-8 encoding.&]
|
||||
|
|
@ -250,20 +256,19 @@ st]&]
|
|||
[s2;%% Returns the number of lines.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetChar`(int`)const: [@(0.0.255) virtual] [@(0.0.255) int]_[* GetChar]([@(0.0.255) i
|
||||
nt]_[*@3 pos])_[@(0.0.255) const]&]
|
||||
[s5;:TextCtrl`:`:operator`[`]`(int`)const: [@(0.0.255) int]_[* operator`[`]]([@(0.0.255) in
|
||||
t]_[*@3 pos])_[@(0.0.255) const]&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetChar`(Upp`:`:int64`)const: [@(0.0.255) int]_[* GetChar]([_^Upp`:`:int64^ i
|
||||
nt64]_[*@3 pos])_[@(0.0.255) const]&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:operator`[`]`(Upp`:`:int64`)const: [@(0.0.255) int]_[* operator`[
|
||||
`]]([_^Upp`:`:int64^ int64]_[*@3 pos])_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the UNICODE character at [%-*@3 pos] offset.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetChar`(`)const: [@(0.0.255) int]_[* GetChar]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns UNICODE character at cursor, or 0 if cursor is behind
|
||||
the last character.&]
|
||||
[s3; &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetLength`(`)const: [@(0.0.255) virtual] [@(0.0.255) int]_[* GetLength]()_
|
||||
[@(0.0.255) const]&]
|
||||
[s5;:TextCtrl`:`:GetLength`(`)const: [@(0.0.255) int]_[* GetLength]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the total number of characters in the text.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
|
|
@ -271,12 +276,14 @@ the last character.&]
|
|||
[s2;%% Returns the position of cursor.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetCursorLine`(`): [@(0.0.255) int]_[* GetCursorLine]()&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetCursorLine`(`)const: [@(0.0.255) int]_[* GetCursorLine]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2;%% Same as GetLine(GetCursor).&]
|
||||
[s3;%% &]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:SetSelection`(int`,int`): [@(0.0.255) void]_[* SetSelection]([@(0.0.255) i
|
||||
nt]_[*@3 anchor]_`=_[@3 0], [@(0.0.255) int]_[*@3 cursor]_`=_INT`_MAX)&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:SetSelection`(Upp`:`:int64`,Upp`:`:int64`): [@(0.0.255) void]_[* S
|
||||
etSelection]([_^Upp`:`:int64^ int64]_[*@3 anchor]_`=_[@3 0], [_^Upp`:`:int64^ int64]_[*@3 c
|
||||
ursor]_`=_[@3 2147483647]_)&]
|
||||
[s2;%% Sets the selection. If [%-*@3 anchor] or [%-*@3 cursor] are out
|
||||
of range, they are `"fixed`". If they are equal, method changes
|
||||
the position of cursor.&]
|
||||
|
|
@ -295,11 +302,16 @@ onst]&]
|
|||
[s5;:TextCtrl`:`:IsAnySelection`(`)const: [@(0.0.255) bool]_[* IsAnySelection]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2;%% Returns true if there is either rectangular or normal selection.&]
|
||||
[s3; &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetSelection`(int`&`,int`&`)const: [@(0.0.255) bool]_[* GetSelection]([@(0.0.255) i
|
||||
nt`&]_[*@3 l], [@(0.0.255) int`&]_[*@3 h])_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the selection lower and upper bounds.&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetSelection`(Upp`:`:int64`&`,Upp`:`:int64`&`)const: [@(0.0.255) b
|
||||
ool]_[* GetSelection]([_^Upp`:`:int64^ int64][@(0.0.255) `&]_[*@3 l],
|
||||
[_^Upp`:`:int64^ int64][@(0.0.255) `&]_[*@3 h])_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the selection lower and upper bounds. int64 version
|
||||
is only useful in view mode. In view mode, 32 bit version returns
|
||||
false if the range is larger than 2GB.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:GetSelection`(byte`)const: [_^String^ String]_[* GetSelection]([_^byte^ by
|
||||
|
|
@ -320,8 +332,8 @@ onst]&]
|
|||
[s2;%% Deletes the selection text.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:SetCursor`(int`): [@(0.0.255) void]_[* SetCursor]([@(0.0.255) int]_[*@3 curs
|
||||
or])&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:SetCursor`(Upp`:`:int64`): [@(0.0.255) void]_[* SetCursor]([_^Upp`:`:int64^ i
|
||||
nt64]_[*@3 cursor])&]
|
||||
[s2;%% Places cursor at new position.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
|
|
@ -392,9 +404,9 @@ records with the text. Must be followed by either SetPickUndoData
|
|||
or ClearUndo before performing any text altering operation.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:SetPickUndoData`(pick`_ TextCtrl`:`:UndoData`&`): [@(0.0.255) void]_[* S
|
||||
etPickUndoData]([@(0.128.128) pick`_]_[_^TextCtrl`:`:UndoData^ UndoData][@(0.0.255) `&]_
|
||||
[*@3 data])&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:SetPickUndoData`(Upp`:`:TextCtrl`:`:UndoData`&`&`): [@(0.0.255) v
|
||||
oid]_[* SetPickUndoData]([_^Upp`:`:TextCtrl`:`:UndoData^ TextCtrl`::UndoData][@(0.0.255) `&
|
||||
`&]_[*@3 data])&]
|
||||
[s2;%% Sets the undo/redo records. [%-@3 data] is picked (destroyed)
|
||||
during the operation.&]
|
||||
[s3;%% &]
|
||||
|
|
@ -456,6 +468,61 @@ _[@(0.0.255) const]&]
|
|||
[s2;%% Gets the color used to display the text.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:View`(Upp`:`:Stream`&`,Upp`:`:byte`): [@(0.0.255) int]_[* View]([_^Upp`:`:Stream^ S
|
||||
tream][@(0.0.255) `&]_[*@3 s], [_^Upp`:`:byte^ byte]_[*@3 charset]_`=_CHARSET`_DEFAULT)&]
|
||||
[s2;%% Initiates the view mode. In view mode, file is not loaded,
|
||||
but displayed while loading it from the stream as necessary.
|
||||
TextCtrl retains a reference to [%-*@3 s] so it must exist for
|
||||
the whole time it is displayed in TextCtrl. TextCtrl is in read`-only
|
||||
mode for view operations. View allows viewing of files >2GB,
|
||||
therefore some functions have 64`-bit counterparts working in
|
||||
view mode only. View actually needs to scan the file to create
|
||||
a map of file; this operation is performed in background (via
|
||||
PostCallbacks), application can use SerializeViewMap to store
|
||||
cache this map for particular file.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:WaitView`(int`,bool`): [@(0.0.255) void]_[* WaitView]([@(0.0.255) i
|
||||
nt]_[*@3 line], [@(0.0.255) bool]_[*@3 progress])&]
|
||||
[s2;%% While mapping of file for view is in progress, makes sure
|
||||
that the file is mapped up to [%-*@3 line] or EOF. If [%-*@3 progress]
|
||||
is true, progress is displayed.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:LockViewMapping`(`): [@(0.0.255) void]_[* LockViewMapping]()&]
|
||||
[s2;%% Stops background mapping of file for view.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:UnlockViewMapping`(`): [@(0.0.255) void]_[* UnlockViewMapping]()&]
|
||||
[s2; Continues mapping of file for view.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:SerializeViewMap`(Upp`:`:Stream`&`): [@(0.0.255) void]_[* Seriali
|
||||
zeViewMap]([_^Upp`:`:Stream^ Stream][@(0.0.255) `&]_[*@3 s])&]
|
||||
[s2;%% Serializes the file view map.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:IsView`(`)const: [@(0.0.255) bool]_[* IsView]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns true if TextCtrl is in view mode.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetViewSize`(`)const: [_^Upp`:`:int64^ int64]_[* GetViewSize]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2;%% Returns GetSize of view stream.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetLinePos64`(Upp`:`:int64`&`)const: [@(0.0.255) int]_[* GetLineP
|
||||
os64]([_^Upp`:`:int64^ int64][@(0.0.255) `&]_[*@3 pos])_[@(0.0.255) const]&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetPos64`(int`,int`)const: [_^Upp`:`:int64^ int64]_[* GetPos64]([@(0.0.255) i
|
||||
nt]_[*@3 ln], [@(0.0.255) int]_[*@3 lpos])_[@(0.0.255) const]&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetLength64`(`)const: [_^Upp`:`:int64^ int64]_[* GetLength64]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s5;:Upp`:`:TextCtrl`:`:GetCursor64`(`)const: [_^Upp`:`:int64^ int64]_[* GetCursor64]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2;%% These are variants of GetLinePos, GetPos, GetLength and GetCursor64
|
||||
for view mode (where values > INT`_MAX are possible).&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:TextCtrl`:`:UndoSteps`(int`): [_^TextCtrl^ TextCtrl][@(0.0.255) `&]_[* UndoSteps]([@(0.0.255) i
|
||||
nt]_[*@3 n])&]
|
||||
[s2;%% Sets the maximum number of undo steps.&]
|
||||
|
|
|
|||
|
|
@ -176,12 +176,12 @@ bool RichEdit::IsW(int c)
|
|||
|
||||
void RichEdit::MoveWordRight(bool select)
|
||||
{
|
||||
Move(GetNextWord(cursor), select);
|
||||
Move((int)GetNextWord(cursor), select);
|
||||
}
|
||||
|
||||
void RichEdit::MoveWordLeft(bool select)
|
||||
{
|
||||
Move(GetPrevWord(cursor), select);
|
||||
Move((int)GetPrevWord(cursor), select);
|
||||
}
|
||||
|
||||
bool RichEdit::SelBeg(bool select)
|
||||
|
|
|
|||
|
|
@ -363,9 +363,9 @@ void RichEdit::LeftDouble(Point p, dword flags)
|
|||
Finish();
|
||||
}
|
||||
else {
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
if(GetWordSelection(c, l, h))
|
||||
SetSelection(l, h);
|
||||
SetSelection((int)l, (int)h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,6 +226,9 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
virtual int GetCharAt(int64 i) const { return GetChar((int)i); }
|
||||
virtual int64 GetTotal() const { return GetLength(); }
|
||||
|
||||
int viewborder;
|
||||
void *context;
|
||||
Size p_size;
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ void AssistEditor::EditAnnotation(bool fastedit)
|
|||
Vector<String> tl;
|
||||
if(!GetAnnotationRefs(tl, coderef))
|
||||
return;
|
||||
SetCursor(GetPos(GetActiveAnnotationLine()));
|
||||
SetCursor(GetPos64(GetActiveAnnotationLine()));
|
||||
if(tl.GetCount() > 1) {
|
||||
MenuBar bar;
|
||||
for(int i = 0; i < tl.GetCount(); i++)
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ String AssistEditor::ReadIdBackPos(int& pos, bool include)
|
|||
while(pos > 0 && (*test)(GetChar(pos - 1)))
|
||||
pos--;
|
||||
int q = pos;
|
||||
while(q < GetLength() && (*test)(GetChar(q)))
|
||||
while(q < GetLength64() && (*test)(GetChar(q)))
|
||||
id << (char)GetChar(q++);
|
||||
return id;
|
||||
}
|
||||
|
|
@ -160,11 +160,11 @@ void AssistEditor::DirtyFrom(int line)
|
|||
|
||||
int AssistEditor::Ch(int i)
|
||||
{
|
||||
if(i >= 0 && i < GetLength()) {
|
||||
if(i >= 0 && i < GetLength64()) {
|
||||
if(i < cachedpos || i - cachedpos > cachedline.GetCount()) {
|
||||
cachedln = GetLine(i);
|
||||
cachedline = GetWLine(cachedln);
|
||||
cachedpos = GetPos(cachedln);
|
||||
cachedpos = GetPos32(cachedln);
|
||||
}
|
||||
i -= cachedpos;
|
||||
return i < cachedline.GetCount() ? cachedline[i] : '\n';
|
||||
|
|
@ -207,7 +207,7 @@ String AssistEditor::IdBack(int& qq)
|
|||
q--;
|
||||
if(iscib(Ch(q))) {
|
||||
qq = q;
|
||||
while(q < GetLength() && iscid(Ch(q)))
|
||||
while(q < GetLength64() && iscid(Ch(q)))
|
||||
r.Cat(Ch(q++));
|
||||
}
|
||||
}
|
||||
|
|
@ -331,7 +331,7 @@ void AssistEditor::SyncAssist()
|
|||
{
|
||||
LTIMING("SyncAssist");
|
||||
bool destructor;
|
||||
String name = ReadIdBack(GetCursor(), include_assist, &destructor);
|
||||
String name = ReadIdBack(GetCursor32(), include_assist, &destructor);
|
||||
String uname = ToUpper(name);
|
||||
assist_item_ndx.Clear();
|
||||
int typei = type.GetCursor() - 1;
|
||||
|
|
@ -456,7 +456,7 @@ void AssistEditor::Assist()
|
|||
if(!assist_active)
|
||||
return;
|
||||
CloseAssist();
|
||||
int q = GetCursor();
|
||||
int q = GetCursor32();
|
||||
assist_cursor = q;
|
||||
assist_type.Clear();
|
||||
assist_item.Clear();
|
||||
|
|
@ -464,7 +464,7 @@ void AssistEditor::Assist()
|
|||
if(IncludeAssist())
|
||||
return;
|
||||
Parser parser;
|
||||
Context(parser, GetCursor());
|
||||
Context(parser, GetCursor32());
|
||||
Index<String> in_types;
|
||||
while(iscid(Ch(q - 1)) || Ch(q - 1) == '~')
|
||||
q--;
|
||||
|
|
@ -597,7 +597,7 @@ void AssistEditor::Complete()
|
|||
{
|
||||
CloseAssist();
|
||||
|
||||
int c = GetCursor();
|
||||
int c = GetCursor32();
|
||||
String q = IdBack(c);
|
||||
|
||||
Index<String> ids;
|
||||
|
|
@ -657,7 +657,7 @@ void AssistEditor::Complete()
|
|||
void AssistEditor::Abbr()
|
||||
{
|
||||
CloseAssist();
|
||||
int c = GetCursor();
|
||||
int c = GetCursor32();
|
||||
int ch;
|
||||
String s;
|
||||
while(IsAlpha(ch = Ch(c - 1))) {
|
||||
|
|
@ -672,13 +672,13 @@ void AssistEditor::Abbr()
|
|||
SetCursor(c);
|
||||
Remove(c, len);
|
||||
int linepos = c;
|
||||
int line = GetLinePos(linepos);
|
||||
int line = GetLinePos32(linepos);
|
||||
WString h = GetWLine(line).Mid(0, linepos);
|
||||
for(int i = 0; i < s.GetCount(); i++) {
|
||||
ch = s[i];
|
||||
switch(ch) {
|
||||
case '@':
|
||||
c = GetCursor();
|
||||
c = GetCursor32();
|
||||
break;
|
||||
case '\n':
|
||||
InsertChar('\n');
|
||||
|
|
@ -708,8 +708,8 @@ void AssistEditor::AssistInsert()
|
|||
}
|
||||
const CppItemInfo& f = assist_item[ii];
|
||||
if(include_assist) {
|
||||
int ln = GetLine(GetCursor());
|
||||
int pos = GetPos(ln);
|
||||
int ln = GetLine(GetCursor32());
|
||||
int pos = GetPos32(ln);
|
||||
Remove(pos, GetLineLength(ln));
|
||||
SetCursor(pos);
|
||||
String h;
|
||||
|
|
@ -745,7 +745,7 @@ void AssistEditor::AssistInsert()
|
|||
int pl = txt.GetCount();
|
||||
if(!thisback && f.kind >= FUNCTION && f.kind <= INLINEFRIEND)
|
||||
txt << "()";
|
||||
int cl = GetCursor();
|
||||
int cl = GetCursor32();
|
||||
int ch = cl;
|
||||
while(iscid(Ch(cl - 1)))
|
||||
cl--;
|
||||
|
|
@ -769,16 +769,16 @@ void AssistEditor::AssistInsert()
|
|||
txt << "()";
|
||||
int n = Paste(ToUnicode(txt, CHARSET_WIN1250));
|
||||
if(!thisback && f.kind >= FUNCTION && f.kind <= INLINEFRIEND) {
|
||||
SetCursor(GetCursor() - 1);
|
||||
SetCursor(GetCursor32() - 1);
|
||||
StartParamInfo(f, cl);
|
||||
int x = f.natural.ReverseFind('(');
|
||||
if(x >= 0 && f.natural[x + 1] == ')')
|
||||
SetCursor(GetCursor() + 1);
|
||||
SetCursor(GetCursor32() + 1);
|
||||
}
|
||||
else
|
||||
if(thisback) {
|
||||
if(thisbackn)
|
||||
SetCursor(GetCursor() - 1);
|
||||
SetCursor(GetCursor32() - 1);
|
||||
}
|
||||
else
|
||||
if(!inbody)
|
||||
|
|
@ -796,8 +796,8 @@ void AssistEditor::AssistInsert()
|
|||
|
||||
bool AssistEditor::InCode()
|
||||
{
|
||||
int pos = GetCursor();
|
||||
int line = GetLinePos(pos);
|
||||
int pos = GetCursor32();
|
||||
int line = GetLinePos32(pos);
|
||||
One<EditorSyntax> st = GetSyntax(line);
|
||||
WString l = GetWLine(line);
|
||||
st->ScanSyntax(l, ~l + pos, line, GetTabSize());
|
||||
|
|
@ -840,12 +840,14 @@ bool AssistEditor::Key(dword key, int count)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
int c = GetCursor();
|
||||
int c = GetCursor32();
|
||||
int cc = GetChar(c);
|
||||
int bcc = c > 0 ? GetChar(c - 1) : 0;
|
||||
bool b = CodeEditor::Key(key, count);
|
||||
if(b && search.HasFocus())
|
||||
SetFocus();
|
||||
if(IsReadOnly())
|
||||
return b;
|
||||
if(assist.IsOpen()) {
|
||||
bool (*test)(int c) = include_assist ? isincludefnchar : isaid;
|
||||
if(!(*test)(key) &&
|
||||
|
|
@ -863,12 +865,12 @@ bool AssistEditor::Key(dword key, int count)
|
|||
else
|
||||
if(auto_assist) {
|
||||
if(InCode()) {
|
||||
if(key == '.' || key == '>' && Ch(GetCursor() - 2) == '-' ||
|
||||
key == ':' && Ch(GetCursor() - 2) == ':')
|
||||
if(key == '.' || key == '>' && Ch(GetCursor32() - 2) == '-' ||
|
||||
key == ':' && Ch(GetCursor32() - 2) == ':')
|
||||
Assist();
|
||||
else
|
||||
if(key == '(') {
|
||||
int q = GetCursor() - 1;
|
||||
int q = GetCursor32() - 1;
|
||||
String id = IdBack(q);
|
||||
if(id == "THISBACK" || id == "THISBACK1" || id == "THISBACK2" || id == "THISBACK3" || id == "THISBACK4")
|
||||
Assist();
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ struct RCB_FileInfo {
|
|||
bool operator<(const RCB_FileInfo& a) const { return time > a.time; }
|
||||
};
|
||||
|
||||
void ReduceCodeBaseCache()
|
||||
void ReduceCacheFolder(const char *path, int max_total)
|
||||
{
|
||||
Array<RCB_FileInfo> file;
|
||||
FindFile ff(AppendFileName(CodeBaseCacheDir(), "*.*"));
|
||||
FindFile ff(AppendFileName(path, "*.*"));
|
||||
int64 total = 0;
|
||||
while(ff) {
|
||||
if(ff.IsFile()) {
|
||||
|
|
@ -69,13 +69,18 @@ void ReduceCodeBaseCache()
|
|||
ff.Next();
|
||||
}
|
||||
Sort(file);
|
||||
while(total > 256000000 && file.GetCount()) {
|
||||
while(total > max_total && file.GetCount()) {
|
||||
DeleteFile(file.Top().path);
|
||||
total -= file.Top().length;
|
||||
file.Drop();
|
||||
}
|
||||
}
|
||||
|
||||
void ReduceCodeBaseCache()
|
||||
{
|
||||
ReduceCacheFolder(CodeBaseCacheDir(), 256000000);
|
||||
}
|
||||
|
||||
String CodeBaseCacheFile()
|
||||
{
|
||||
return AppendFileName(CodeBaseCacheDir(), GetVarsName() + '.' + GetCurrentMainPackage() + '.' + GetCurrentBuildMethod() + ".codebase");
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
class Browser;
|
||||
|
||||
void ReduceCacheFolder(const char *path, int max_total);
|
||||
|
||||
CppBase& CodeBase();
|
||||
|
||||
struct SourceFileInfo {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ void Ide::FileCompile()
|
|||
|
||||
void Ide::PreprocessInternal()
|
||||
{
|
||||
if(editor.GetLength() >= 1000000) // Sanity...
|
||||
if(editor.GetLength64() >= 1000000) // Sanity...
|
||||
return;
|
||||
int l = editor.GetCurrentLine();
|
||||
PPSync(GetIncludePath());
|
||||
|
|
@ -169,7 +169,7 @@ void Ide::PreprocessInternal()
|
|||
EditAsText();
|
||||
if(!editor.IsReadOnly())
|
||||
ToggleReadOnly();
|
||||
editor.SetCursor(editor.GetPos(l));
|
||||
editor.SetCursor(editor.GetPos64(l));
|
||||
}
|
||||
|
||||
void Ide::Preprocess(bool asmout) {
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ void IdeCalc::Execute()
|
|||
if(IsSelection()) {
|
||||
String s = GetSelection();
|
||||
if(s.GetLength() < 80) {
|
||||
SetCursor(GetLength());
|
||||
SetCursor(GetLength64());
|
||||
Paste(Filter(s, LfToSpaceFilter).ToWString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(GetLine(GetCursor()) != li) {
|
||||
WString s = GetWLine(GetLine(GetCursor()));
|
||||
if(GetLine(GetCursor64()) != li) {
|
||||
WString s = GetWLine(GetLine(GetCursor64()));
|
||||
if(s[0] == '$') s = s.Mid(1);
|
||||
SetCursor(GetLength());
|
||||
SetCursor(GetLength64());
|
||||
Paste(s);
|
||||
return;
|
||||
}
|
||||
|
|
@ -46,9 +46,9 @@ void IdeCalc::Execute()
|
|||
const char *x = strchr(e, ':');
|
||||
txt << "ERROR: " << (x ? x + 1 : ~e);
|
||||
}
|
||||
SetCursor(GetPos(li));
|
||||
SetCursor(GetPos64(li));
|
||||
Paste("$");
|
||||
SetCursor(GetLength());
|
||||
SetCursor(GetLength64());
|
||||
Paste("\n");
|
||||
Paste(FromUtf8(txt));
|
||||
Paste("\n");
|
||||
|
|
|
|||
|
|
@ -51,15 +51,15 @@ void Console::Append(const String& s) {
|
|||
return;
|
||||
}
|
||||
int l, h;
|
||||
GetSelection(l, h);
|
||||
if(GetCursor() == GetLength()) l = -1;
|
||||
GetSelection32(l, h);
|
||||
if(GetCursor32() == GetLength32()) l = -1;
|
||||
EditPos p = GetEditPos();
|
||||
SetEditable();
|
||||
MoveTextEnd();
|
||||
WString t = Filter(s, sAppf).ToWString();
|
||||
int mg = sb.GetReducedViewSize().cx / GetFont().GetAveWidth();
|
||||
if(wrap_text && mg > 4) {
|
||||
int x = GetColumnLine(GetCursor()).x;
|
||||
int x = GetColumnLine(GetCursor32()).x;
|
||||
WStringBuffer tt;
|
||||
const wchar *q = t;
|
||||
while(*q) {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ void Ide::ContextGoto0(int pos)
|
|||
}
|
||||
}
|
||||
AddHistory();
|
||||
editor.SetCursor(editor.GetPos(li));
|
||||
editor.SetCursor(editor.GetPos64(li));
|
||||
return;
|
||||
}
|
||||
if(IsPendif(l)) {
|
||||
|
|
@ -126,7 +126,7 @@ void Ide::ContextGoto0(int pos)
|
|||
lvl++;
|
||||
}
|
||||
AddHistory();
|
||||
editor.SetCursor(editor.GetPos(li));
|
||||
editor.SetCursor(editor.GetPos64(li));
|
||||
return;
|
||||
}
|
||||
int cr = editor.Ch(pos);
|
||||
|
|
@ -300,7 +300,7 @@ void Ide::ContextGoto0(int pos)
|
|||
q = parser.local.Find(id);
|
||||
if(q >= 0) { // Try locals
|
||||
AddHistory();
|
||||
editor.SetCursor(editor.GetPos(parser.local[q].line - 1));
|
||||
editor.SetCursor(editor.GetPos64(parser.local[q].line - 1));
|
||||
FindId(id);
|
||||
return;
|
||||
}
|
||||
|
|
@ -363,9 +363,10 @@ void Ide::ContextGoto()
|
|||
ContextGoto0(editor.GetCursor());
|
||||
}
|
||||
|
||||
void Ide::CtrlClick(int pos)
|
||||
void Ide::CtrlClick(int64 pos)
|
||||
{
|
||||
ContextGoto0(pos);
|
||||
if(pos < INT_MAX)
|
||||
ContextGoto0((int)pos);
|
||||
}
|
||||
|
||||
bool Ide::GotoDesignerFile(const String& path, const String& scope, const String& name, int line)
|
||||
|
|
@ -382,7 +383,7 @@ bool Ide::GotoDesignerFile(const String& path, const String& scope, const String
|
|||
l->FindLayout(name.Mid(10), Null);
|
||||
}
|
||||
else {
|
||||
editor.SetCursor(editor.GetPos(line - 1));
|
||||
editor.SetCursor(editor.GetPos64(line - 1));
|
||||
editor.TopCursor(4);
|
||||
editor.SetFocus();
|
||||
}
|
||||
|
|
@ -444,13 +445,13 @@ void Ide::GotoFileAndId(const String& path, const String& id)
|
|||
AddHistory();
|
||||
EditFile(path);
|
||||
WString wid = id.ToWString();
|
||||
if(editor.GetLength() < 100000) {
|
||||
if(editor.GetLength64() < 100000) {
|
||||
for(int i = 0; i < editor.GetLineCount(); i++) {
|
||||
WString ln = editor.GetWLine(i);
|
||||
int q = ln.Find(wid);
|
||||
while(q >= 0) {
|
||||
if(q == 0 || !iscid(ln[q - 1]) && !iscid(ln[q + wid.GetCount()])) {
|
||||
editor.SetCursor(editor.GetPos(i, q));
|
||||
editor.SetCursor(editor.GetPos64(i, q));
|
||||
editor.CenterCursor();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ void AssistEditor::DCopy()
|
|||
String r;
|
||||
int l, h;
|
||||
bool decla = false;
|
||||
if(!GetSelection(l, h)) {
|
||||
int i = GetLine(GetCursor());
|
||||
l = GetPos(i);
|
||||
if(!GetSelection32(l, h)) {
|
||||
int i = GetLine(GetCursor32());
|
||||
l = GetPos32(i);
|
||||
h = l;
|
||||
while(h < GetLength() && h - l < 1000) {
|
||||
while(h < GetLength32() && h - l < 1000) {
|
||||
int c = GetChar(h);
|
||||
if(c == ';') {
|
||||
decla = true;
|
||||
|
|
@ -29,12 +29,12 @@ void AssistEditor::DCopy()
|
|||
break;
|
||||
h++;
|
||||
if(c == '\"') {
|
||||
while(h < GetLength()) {
|
||||
while(h < GetLength32()) {
|
||||
int c = GetChar(h);
|
||||
if(c == '\"' || c == '\n')
|
||||
break;
|
||||
h++;
|
||||
if(c == '\\' && h < GetLength())
|
||||
if(c == '\\' && h < GetLength32())
|
||||
h++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ bool Ide::FindLineError(int l) {
|
|||
FindLineErrorCache cache;
|
||||
if(FindLineError(console.GetUtf8Line(l), cache, f)) {
|
||||
GoToError(f);
|
||||
console.SetSelection(console.GetPos(l), console.GetPos(l + 1));
|
||||
console.SetSelection(console.GetPos64(l), console.GetPos64(l + 1));
|
||||
if(btabs.GetCursor() != BCONSOLE && btabs.GetCursor() != BFINDINFILES)
|
||||
ShowConsole();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -305,16 +305,15 @@ void Ide::FindInFiles(bool replace) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Ide::FindFileAll(const Vector<Tuple<int, int>>& f)
|
||||
void Ide::FindFileAll(const Vector<Tuple<int64, int>>& f)
|
||||
{
|
||||
ShowConsole2();
|
||||
ffound.Clear();
|
||||
for(auto pos : f) {
|
||||
editor.CachePos(pos.a);
|
||||
int linei = editor.GetLinePos(pos.a);
|
||||
int linei = editor.GetLinePos64(pos.a);
|
||||
WString ln = editor.GetWLine(linei);
|
||||
AddFoundFile(editfile, linei + 1, ln.ToString(), lenAsUtf8(~ln, pos.a), lenAsUtf8(~ln + pos.a, pos.b));
|
||||
AddFoundFile(editfile, linei + 1, ln.ToString(), lenAsUtf8(~ln, (int)pos.a), lenAsUtf8(~ln + pos.a, pos.b));
|
||||
}
|
||||
ffound.HeaderTab(2).SetText(Format("Source line (%d)", ffound.GetCount()));
|
||||
ffound.Add(Null, Null, AsString(f.GetCount()) + " occurrence(s) have been found.");
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void Ide::GoToLine()
|
|||
return;
|
||||
|
||||
AddHistory();
|
||||
editor.SetCursor(editor.GetPos(newLine - 1));
|
||||
editor.SetCursor(editor.GetPos64(newLine - 1));
|
||||
editor.SetFocus();
|
||||
AddHistory();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ void Ide::DoMacroManager()
|
|||
MacroManagerWindow manager(IdeWorkspace(), editor.StoreHlStyles());
|
||||
manager.WhenEdit = [=](String fileName, int line) {
|
||||
EditFile(fileName);
|
||||
editor.SetCursor(editor.GetPos(line));
|
||||
editor.SetCursor(editor.GetPos64(line));
|
||||
editor.CenterCursor();
|
||||
};
|
||||
manager.Execute();
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ void AssistEditor::SyncParamInfo()
|
|||
int i = GetCursorLine();
|
||||
if(m.line >= 0 && m.line < GetLineCount() && i >= m.line && i < m.line + 10
|
||||
&& m.editfile == theide->editfile && GetWLine(m.line).StartsWith(m.test)) {
|
||||
int c = GetCursor();
|
||||
i = GetPos(m.line) + m.test.GetCount();
|
||||
int c = GetCursor32();
|
||||
i = GetPos32(m.line) + m.test.GetCount();
|
||||
if(c >= i) {
|
||||
int par = 0;
|
||||
int pari = 0;
|
||||
|
|
@ -77,9 +77,9 @@ void AssistEditor::SyncParamInfo()
|
|||
|
||||
void AssistEditor::StartParamInfo(const CppItem& m, int pos)
|
||||
{
|
||||
int x = GetCursor();
|
||||
int x = GetCursor32();
|
||||
ParamInfo& f = param[parami];
|
||||
f.line = GetLinePos(x);
|
||||
f.line = GetLinePos32(x);
|
||||
f.test = GetWLine(f.line).Mid(0, x);
|
||||
f.item = m;
|
||||
f.editfile = theide->editfile;
|
||||
|
|
@ -97,5 +97,5 @@ void AssistEditor::State(int reason)
|
|||
|
||||
int AssistEditor::GetCurrentLine()
|
||||
{
|
||||
return GetLine(GetCursor());
|
||||
return GetLine(GetCursor64());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void QtfDlg::Copy()
|
|||
struct QtfDlgEditor : TopWindow {
|
||||
RichEditWithToolBar editor;
|
||||
|
||||
void Serialize(Stream& s);
|
||||
void Serialize(Stream& s);
|
||||
|
||||
QtfDlgEditor();
|
||||
};
|
||||
|
|
@ -123,16 +123,16 @@ void Ide::Qtf()
|
|||
{
|
||||
QtfDlg dlg;
|
||||
LoadFromGlobal(dlg, "QTF-designer");
|
||||
int l,h;
|
||||
bool sel=editor.GetSelection(l,h);
|
||||
if(qtfsel && sel){
|
||||
dlg.qtfText.text<<=(~editor).ToString().Mid(l,h-l);
|
||||
int l, h;
|
||||
bool sel = editor.GetSelection(l,h);
|
||||
if(qtfsel && sel) {
|
||||
dlg.qtfText.text <<= (~editor).ToString().Mid(l, h - l);
|
||||
dlg.qtfText.copy.SetLabel("Apply and close");
|
||||
dlg.Run();
|
||||
editor.Remove(l,h-l);
|
||||
editor.Insert(l,(~dlg.qtfText.text).ToString());
|
||||
editor.Remove(l, h - l);
|
||||
editor.Insert(l, (~dlg.qtfText.text).ToString());
|
||||
}
|
||||
else{
|
||||
else {
|
||||
dlg.qtfText.copy.SetLabel("Copy and close");
|
||||
dlg.Run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
void AssistEditor::SwapSContext(Parser& p)
|
||||
{
|
||||
int i = GetCursor();
|
||||
int i = GetCursor32();
|
||||
if(Ch(i - 1) == ';')
|
||||
i--;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ INITBLOCK
|
|||
void AssistEditor::Thisbacks()
|
||||
{
|
||||
Parser ctx;
|
||||
Context(ctx, GetCursor());
|
||||
Context(ctx, GetCursor32());
|
||||
if(IsNull(ctx.current_scope) || !ctx.IsInBody())
|
||||
return;
|
||||
ThisbacksDlg dlg(ctx.current_scope);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ INITBLOCK
|
|||
void AssistEditor::Virtuals()
|
||||
{
|
||||
Parser ctx;
|
||||
Context(ctx, GetCursor());
|
||||
Context(ctx, GetCursor32());
|
||||
if(IsNull(ctx.current_scope) || ctx.current_scope == "::" || ctx.IsInBody())
|
||||
return;
|
||||
VirtualsDlg dlg(ctx.current_scope);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ void XmlView::Load(const String& txt)
|
|||
AddFrame(errorbg);
|
||||
view.Show();
|
||||
view <<= txt;
|
||||
view.SetCursor(view.GetPos(p.GetLine() - 1, p.GetColumn() - 1));
|
||||
view.SetCursor(view.GetPos64(p.GetLine() - 1, p.GetColumn() - 1));
|
||||
view.SetFocus();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,25 +16,26 @@ void Ide::MakeTitle()
|
|||
title << " - ";
|
||||
title << "TheIDE";
|
||||
if(designer) {
|
||||
title << " - [" << designer->GetFileName();
|
||||
title << " - " << designer->GetFileName();
|
||||
int cs = designer->GetCharset();
|
||||
if(cs >= 0)
|
||||
title << " " << CharsetName(cs);
|
||||
title << "]";
|
||||
}
|
||||
else
|
||||
if(!editfile.IsEmpty()) {
|
||||
title << " - [" << editfile;
|
||||
title << " - " << editfile;
|
||||
int chrset = editor.GetCharset();
|
||||
title << " " << IdeCharsetName(chrset)
|
||||
<< " " << (findarg(Nvl(editfile_line_endings, line_endings), LF, DETECT_LF) >= 0 ? "LF" : "CRLF");
|
||||
if(editor.IsTruncated())
|
||||
title << " (Truncated)";
|
||||
title << " [Truncated]";
|
||||
if(editor.IsView())
|
||||
title << " [View]";
|
||||
else
|
||||
if(editor.IsReadOnly())
|
||||
title << " (Read Only)";
|
||||
title << " [Read Only]";
|
||||
if(editor.IsDirty())
|
||||
title << " *";
|
||||
title << "]";
|
||||
}
|
||||
if(!IsNull(editfile))
|
||||
for(int i = 0; i < 10; i++)
|
||||
|
|
@ -75,7 +76,7 @@ void Ide::MakeIcon() {
|
|||
|
||||
bool Ide::CanToggleReadOnly()
|
||||
{
|
||||
return NormalizePath(GetActiveFilePath()) == NormalizePath(editfile);
|
||||
return NormalizePath(GetActiveFilePath()) == NormalizePath(editfile) && !editor.IsView();
|
||||
}
|
||||
|
||||
void Ide::ToggleReadOnly()
|
||||
|
|
@ -367,7 +368,7 @@ void Ide::CycleFiles()
|
|||
|
||||
void Ide::DeactivateBy(Ctrl *new_focus)
|
||||
{
|
||||
if(deactivate_save && issaving == 0 && !new_focus && editor.GetLength() < 1000000) {
|
||||
if(deactivate_save && issaving == 0 && !new_focus && editor.GetLength64() < 1000000) {
|
||||
DeactivationSave(true);
|
||||
SaveFile();
|
||||
DeactivationSave(false);
|
||||
|
|
@ -463,7 +464,7 @@ bool Ide::IsHistDiff(int i)
|
|||
if(i < 0 || i >= history.GetCount())
|
||||
return false;
|
||||
Bookmark& b = history[i];
|
||||
return b.file != editfile || abs(editor.GetCursor() - b.pos.cursor) > 20;
|
||||
return b.file != editfile || abs(editor.GetCursor64() - b.pos.cursor) > 20;
|
||||
}
|
||||
|
||||
void Ide::IdePaste(String& data)
|
||||
|
|
@ -530,10 +531,10 @@ void Ide::BookKey(int key)
|
|||
|
||||
void Ide::DoDisplay()
|
||||
{
|
||||
Point p = editor.GetColumnLine(editor.GetCursor());
|
||||
Point p = editor.GetColumnLine(editor.GetCursor64());
|
||||
String s;
|
||||
s << "Ln " << p.y + 1 << ", Col " << p.x + 1;
|
||||
int l, h;
|
||||
int64 l, h;
|
||||
editor.GetSelection(l, h);
|
||||
if(h > l)
|
||||
s << ", Sel " << h - l;
|
||||
|
|
@ -643,14 +644,14 @@ int Ide::GetPackageIndex()
|
|||
void Ide::GotoDiffLeft(int line, DiffDlg *df)
|
||||
{
|
||||
EditFile(df->editfile);
|
||||
editor.SetCursor(editor.GetPos(line));
|
||||
editor.SetCursor(editor.GetPos64(line));
|
||||
editor.SetFocus();
|
||||
}
|
||||
|
||||
void Ide::GotoDiffRight(int line, FileDiff *df)
|
||||
{
|
||||
EditFile(df->GetExtPath());
|
||||
editor.SetCursor(editor.GetPos(line));
|
||||
editor.SetCursor(editor.GetPos64(line));
|
||||
editor.SetFocus();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -434,7 +434,9 @@ public:
|
|||
|
||||
One<IdeDesigner> designer;
|
||||
AssistEditor editor;
|
||||
FileIn view_file;
|
||||
AssistEditor editor2; // no edits happen in editor2, just view
|
||||
FileIn view_file2;
|
||||
EditorTabBar tabs;
|
||||
EscValue macro_api;
|
||||
#ifdef PLATFORM_POSIX
|
||||
|
|
@ -799,7 +801,7 @@ public:
|
|||
void FindString(bool back);
|
||||
void ClearEditedFile();
|
||||
void ClearEditedAll();
|
||||
void FindFileAll(const Vector<Tuple<int, int>>& f);
|
||||
void FindFileAll(const Vector<Tuple<int64, int>>& f);
|
||||
void InsertColor();
|
||||
void InsertLay(const String& fn);
|
||||
void InsertIml(const String& fn, String classname);
|
||||
|
|
@ -932,7 +934,7 @@ public:
|
|||
void ContextGoto0(int pos);
|
||||
void ContextGoto();
|
||||
void GoToLine();
|
||||
void CtrlClick(int pos);
|
||||
void CtrlClick(int64 pos);
|
||||
void Qtf();
|
||||
void Xml();
|
||||
void Json();
|
||||
|
|
|
|||
|
|
@ -216,7 +216,12 @@ void Ide::Edit(Bar& menu)
|
|||
}
|
||||
else {
|
||||
bool selection = editor.IsAnySelection();
|
||||
|
||||
|
||||
if(editor.IsView()) {
|
||||
menu.Add(AK_EDITASTEXT, THISBACK(EditAsText))
|
||||
.Help("Edit file");
|
||||
menu.MenuSeparator();
|
||||
}
|
||||
if(GetFileExt(editfile) == ".t") {
|
||||
if(editastext.Find(editfile) >= 0)
|
||||
menu.Add(AK_DESIGNER, THISBACK(EditUsingDesigner))
|
||||
|
|
@ -229,7 +234,7 @@ void Ide::Edit(Bar& menu)
|
|||
else
|
||||
if(editastext.Find(editfile) >= 0/* && IsDesignerFile(editfile)*/) {
|
||||
menu.Add(AK_DESIGNER, THISBACK(EditUsingDesigner))
|
||||
.Help("Edit using the designer (not as text)");
|
||||
.Help(editor.GetLength() > 256*1024*1024 ? "View file" : "Edit using the designer (not as text)");
|
||||
menu.MenuSeparator();
|
||||
}
|
||||
menu.Add(b, "Undo", CtrlImg::undo(), callback(&editor, &LineEdit::Undo))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,41 @@
|
|||
#include "ide.h"
|
||||
|
||||
String ViewCache()
|
||||
{
|
||||
return ConfigFile("view_maps");
|
||||
}
|
||||
|
||||
String ViewFileHash(const String& path)
|
||||
{
|
||||
Sha1Stream s;
|
||||
FindFile ff(path);
|
||||
if(ff) {
|
||||
Sha1Stream sha;
|
||||
sha << path << ';' << Time(ff.GetLastWriteTime()) << ';' << ff.GetLength();
|
||||
return AppendFileName(ViewCache(), sha.FinishString());
|
||||
}
|
||||
return Null;
|
||||
}
|
||||
|
||||
void ViewFile(LineEdit& edit, Stream& view_file, const String& path)
|
||||
{
|
||||
edit.View(view_file);
|
||||
String f = ViewFileHash(path);
|
||||
if(f.GetCount())
|
||||
LoadFromFile([&](Stream& s) { edit.SerializeViewMap(s); }, f);
|
||||
}
|
||||
|
||||
void CacheViewFile(LineEdit& edit, const String& path)
|
||||
{
|
||||
if(edit.IsView()) {
|
||||
ReduceCacheFolder(ViewCache(), 20000000);
|
||||
String f = ViewFileHash(path);
|
||||
RealizePath(f);
|
||||
if(f.GetCount())
|
||||
StoreToFile([&](Stream& s) { edit.SerializeViewMap(s); }, f);
|
||||
}
|
||||
}
|
||||
|
||||
void Ide::SetupEditor(int f, String hl, String path)
|
||||
{
|
||||
if(IsNull(hl)) {
|
||||
|
|
@ -327,6 +363,8 @@ void Ide::SaveFile0(bool always)
|
|||
fd.editpos = editor.GetEditPos();
|
||||
fd.columnline = editor.GetColumnLine(fd.editpos.cursor);
|
||||
fd.filetime = edittime;
|
||||
if(editor.IsView())
|
||||
return;
|
||||
if(!editor.IsDirty() && !always)
|
||||
return;
|
||||
TouchFile(editfile);
|
||||
|
|
@ -371,6 +409,7 @@ void Ide::SaveFile0(bool always)
|
|||
void Ide::FlushFile() {
|
||||
editor.CloseAssist();
|
||||
SaveFile();
|
||||
CacheViewFile(editor, editfile);
|
||||
editor.assist_active = false;
|
||||
if(designer) {
|
||||
designer->SaveEditPos();
|
||||
|
|
@ -387,8 +426,10 @@ void Ide::FlushFile() {
|
|||
repo_dirs = RepoDirs(true).GetCount(); // Perhaps not the best place, but should be ok
|
||||
editor.Clear();
|
||||
editor.Disable();
|
||||
editor.SetEditable();
|
||||
editorsplit.Ctrl::Remove();
|
||||
designer.Clear();
|
||||
view_file.Close();
|
||||
SetBar();
|
||||
}
|
||||
|
||||
|
|
@ -469,7 +510,7 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
|
|||
editor.SyncNavigatorShow();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tabs.SetAddFile(editfile);
|
||||
tabs.SetSplitColor(editfile2, Yellow);
|
||||
editor.Enable();
|
||||
|
|
@ -484,13 +525,13 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
|
|||
edittime = ff.GetLastWriteTime();
|
||||
if(edittime != fd.filetime || IsNull(fd.filetime))
|
||||
fd.undodata.Clear();
|
||||
FileIn in(editfile);
|
||||
if(in) {
|
||||
view_file.Open(editfile);
|
||||
if(view_file) {
|
||||
if(tfile && editastext.Find(editfile) < 0) {
|
||||
String f;
|
||||
String ln;
|
||||
for(;;) {
|
||||
int c = in.Get();
|
||||
int c = view_file.Get();
|
||||
if(c < 0) {
|
||||
f.Cat(ConvertTLine(ln, 0));
|
||||
break;
|
||||
|
|
@ -507,7 +548,7 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
|
|||
editor.SetCharset(CHARSET_UTF8);
|
||||
}
|
||||
else {
|
||||
String s = in.Get(3);
|
||||
String s = view_file.Get(3);
|
||||
if(s.GetCount() >= 2) {
|
||||
if((byte)s[0] == 0xff && (byte)s[1] == 0xfe)
|
||||
charset = CHARSET_UTF16_LE_BOM;
|
||||
|
|
@ -516,8 +557,24 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
|
|||
}
|
||||
if(s.GetCount() >= 3 && (byte)s[0] == 0xef && (byte)s[1] == 0xbb && (byte)s[2] == 0xbf)
|
||||
charset = CHARSET_UTF8_BOM;
|
||||
in.Seek(0);
|
||||
int le = editor.Load(in, charset);
|
||||
view_file.Seek(0);
|
||||
int le = Null;
|
||||
#ifdef CPU_64
|
||||
const int64 max_size = (int64)4096*1024*1024;
|
||||
#else
|
||||
const int64 max_size = 768*1024*1024;
|
||||
#endif
|
||||
const int view_limit = 256*1024*1024;
|
||||
DDUMP(view_file.GetSize());
|
||||
DDUMP(editastext.Find(editfile));
|
||||
DDUMP(editor.IsReadOnly());
|
||||
if(view_file.GetSize() < 256*1024*1024 || editastext.Find(editfile) >= 0 && view_file.GetSize() < max_size) {
|
||||
le = editor.Load(view_file, charset);
|
||||
view_file.Close();
|
||||
}
|
||||
else
|
||||
ViewFile(editor, view_file, editfile);
|
||||
|
||||
editfile_line_endings = le == TextCtrl::LE_CRLF ? CRLF : le == TextCtrl::LE_LF ? LF : (int)Null;
|
||||
}
|
||||
}
|
||||
|
|
@ -526,15 +583,22 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
|
|||
editor.SetEditPos(fd.editpos);
|
||||
if(!IsNull(fd.columnline) && fd.columnline.y >= 0 && fd.columnline.y < editor.GetLineCount())
|
||||
editor.SetCursor(editor.GetColumnLinePos(fd.columnline));
|
||||
editor.SetPickUndoData(pick(fd.undodata));
|
||||
editor.SetLineInfo(fd.lineinfo);
|
||||
editor.SetLineInfoRem(pick(fd.lineinforem));
|
||||
if(ff.IsReadOnly() || IsNestReadOnly(editfile) || editor.IsTruncated()) {
|
||||
if(!editor.IsView()) {
|
||||
editor.SetPickUndoData(pick(fd.undodata));
|
||||
editor.SetLineInfo(fd.lineinfo);
|
||||
editor.SetLineInfoRem(pick(fd.lineinforem));
|
||||
}
|
||||
DDUMP(ff.IsReadOnly());
|
||||
DDUMP(IsNestReadOnly(editfile));
|
||||
DDUMP(editor.IsTruncated());
|
||||
DDUMP(editor.IsView());
|
||||
if(ff.IsReadOnly() || IsNestReadOnly(editfile) || editor.IsTruncated() || editor.IsView()) {
|
||||
editor.SetReadOnly();
|
||||
editor.NoShowReadOnly();
|
||||
}
|
||||
fd.ClearP();
|
||||
PosSync();
|
||||
editor.ClearDirty();
|
||||
}
|
||||
else {
|
||||
RealizePath(editfile);
|
||||
|
|
@ -547,11 +611,11 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
|
|||
s << "\r\n";
|
||||
s << "#endif\r\n";
|
||||
editor <<= s;
|
||||
editor.SetCursor(editor.GetPos(2));
|
||||
editor.SetCursor(editor.GetPos64(2));
|
||||
}
|
||||
if(IsCSourceFile(editfile) && !IsNull(headername)) {
|
||||
editor <<= "#include \"" + headername + "\"\r\n";
|
||||
editor.SetCursor(editor.GetPos(1));
|
||||
editor.SetCursor(editor.GetPos64(1));
|
||||
}
|
||||
editor.SetCharset(tfile ? CHARSET_UTF8 : charset);
|
||||
}
|
||||
|
|
@ -592,7 +656,7 @@ void Ide::EditFileAssistSync()
|
|||
|
||||
void Ide::TriggerAssistSync()
|
||||
{
|
||||
if(auto_rescan && editor.GetLength() < 500000) // Sanity
|
||||
if(auto_rescan && editor.GetLength64() < 500000) // Sanity
|
||||
text_updated.KillSet(1000, THISBACK(EditFileAssistSync));
|
||||
}
|
||||
|
||||
|
|
@ -808,7 +872,7 @@ void Ide::ReloadFile()
|
|||
EditFile0(fn, editor.GetCharset(), editor.GetSpellcheckComments());
|
||||
filelist.SetSbPos(sc);
|
||||
int l = LocateLine(data, ln, ~editor);
|
||||
editor.SetCursor(editor.GetPos(l));
|
||||
editor.SetCursor(editor.GetPos64(l));
|
||||
}
|
||||
|
||||
void Ide::EditAnyFile() {
|
||||
|
|
@ -887,9 +951,16 @@ void Ide::PassEditor()
|
|||
editor2.SetFont(editor.GetFont());
|
||||
editor2.Highlight(editor.GetHighlight());
|
||||
editor2.LoadHlStyles(editor.StoreHlStyles());
|
||||
editor2.NoShowReadOnly();
|
||||
byte charset = editor.GetCharset();
|
||||
editor2.CheckEdited(false);
|
||||
editor2.Set(editor.Get(charset), charset);
|
||||
view_file2.Close();
|
||||
if(editor.IsView()) {
|
||||
view_file2.Open(editfile2);
|
||||
ViewFile(editor2, view_file2, editfile2);
|
||||
}
|
||||
else
|
||||
editor2.Set(editor.Get(charset), charset);
|
||||
editor2.SetEditPosSb(editor.GetEditPos());
|
||||
editor2.CheckEdited();
|
||||
editor.SetFocus();
|
||||
|
|
@ -956,6 +1027,7 @@ void Ide::CloseSplit()
|
|||
{
|
||||
editorsplit.Vert(editor, editor2);
|
||||
editorsplit.Zoom(0);
|
||||
view_file2.Close();
|
||||
editfile2.Clear();
|
||||
tabs.ClearSplitColor();
|
||||
SyncEditorSplit();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ void Ide::ResolveUvsConflict() {
|
|||
ln != "END REPOSITORY INSERT" &&
|
||||
ln != "PENDING CONFLICT") {
|
||||
Exclamation("Cannot resolve uvs conflict -&conflicting modifications found");
|
||||
editor.SetCursor(editor.GetPos(i));
|
||||
editor.SetCursor(editor.GetPos64(i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ void Ide::GotoPos(String path, int line)
|
|||
DoEditAsText(path);
|
||||
EditFile(path);
|
||||
}
|
||||
editor.SetCursor(editor.GetPos(line - 1));
|
||||
editor.SetCursor(editor.GetPos64(line - 1));
|
||||
editor.TopCursor(4);
|
||||
editor.SetFocus();
|
||||
AddHistory();
|
||||
|
|
@ -296,7 +296,7 @@ void Ide::AlterText(WString (*op)(const WString& in))
|
|||
editor.RemoveSelection();
|
||||
int l = editor.GetCursor();
|
||||
editor.Paste((*op)(w));
|
||||
editor.SetSelection(l, editor.GetCursor());
|
||||
editor.SetSelection(l, editor.GetCursor64());
|
||||
}
|
||||
|
||||
void Ide::TextToUpper()
|
||||
|
|
@ -457,14 +457,14 @@ void Ide::SyncRepoDir(const String& working)
|
|||
void Ide::GotoDirDiffLeft(int line, DirDiffDlg *df)
|
||||
{
|
||||
EditFile(df->GetLeftFile());
|
||||
editor.SetCursor(editor.GetPos(line));
|
||||
editor.SetCursor(editor.GetPos64(line));
|
||||
editor.SetFocus();
|
||||
}
|
||||
|
||||
void Ide::GotoDirDiffRight(int line, DirDiffDlg *df)
|
||||
{
|
||||
EditFile(df->GetRightFile());
|
||||
editor.SetCursor(editor.GetPos(line));
|
||||
editor.SetCursor(editor.GetPos64(line));
|
||||
editor.SetFocus();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ void Ide::SyncT(int kind)
|
|||
case IDYES:
|
||||
if(dlg.source.IsCursor()) {
|
||||
EditFile(dlg.source.Get(0));
|
||||
editor.SetCursor(editor.GetPos(editor.GetLineNo((int)dlg.source.Get(1) - 1)));
|
||||
editor.SetCursor(editor.GetPos64(editor.GetLineNo((int)dlg.source.Get(1) - 1)));
|
||||
editor.CenterCursor();
|
||||
editor.SetFocus();
|
||||
StoreToWorkspace(dlg, "Tdlg");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue