From 2d298f25240349fad751a0d51b7822b4cce18c1f Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 20 Dec 2017 12:10:24 +0000 Subject: [PATCH] CtrlLib: TextCtrl, LineEdit, CodeEditor: view mode git-svn-id: svn://ultimatepp.org/upp/trunk@11592 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/CHighlight.cpp | 4 +- uppsrc/CodeEditor/CLogic.cpp | 46 +- uppsrc/CodeEditor/CSyntax.h | 14 +- uppsrc/CodeEditor/CodeEditor.cpp | 179 ++++---- uppsrc/CodeEditor/CodeEditor.h | 44 +- uppsrc/CodeEditor/CodeEditor.upp | 2 +- uppsrc/CodeEditor/DiffSyntax.cpp | 4 +- uppsrc/CodeEditor/DiffSyntax.h | 4 +- uppsrc/CodeEditor/EditorBar.cpp | 3 +- uppsrc/CodeEditor/FindReplace.cpp | 114 +++-- uppsrc/CodeEditor/Lang.cpp | 42 +- uppsrc/CodeEditor/LogSyntax.cpp | 2 +- uppsrc/CodeEditor/LogSyntax.h | 2 +- uppsrc/CodeEditor/PythonSyntax.cpp | 2 +- uppsrc/CodeEditor/PythonSyntax.h | 2 +- uppsrc/CodeEditor/Syntax.cpp | 6 +- uppsrc/CodeEditor/Syntax.h | 6 +- uppsrc/CodeEditor/TagSyntax.cpp | 16 +- uppsrc/CodeEditor/TagSyntax.h | 10 +- uppsrc/Core/String.h | 1 + uppsrc/CtrlLib/DocEdit.cpp | 86 ++-- uppsrc/CtrlLib/EditCtrl.h | 14 +- uppsrc/CtrlLib/EditField.cpp | 34 +- uppsrc/CtrlLib/LineEdit.cpp | 222 +++++----- uppsrc/CtrlLib/Text.cpp | 488 ++++++++++++++++------ uppsrc/CtrlLib/TextEdit.h | 154 ++++--- uppsrc/CtrlLib/src.tpp/TextCtrl_en-us.tpp | 123 ++++-- uppsrc/RichEdit/Cursor.cpp | 4 +- uppsrc/RichEdit/Mouse.cpp | 4 +- uppsrc/RichEdit/RichEdit.h | 3 + uppsrc/ide/Annotations.cpp | 2 +- uppsrc/ide/Assist.cpp | 48 ++- uppsrc/ide/Browser/Base.cpp | 11 +- uppsrc/ide/Browser/Browser.h | 2 + uppsrc/ide/Build.cpp | 4 +- uppsrc/ide/Calc.cpp | 12 +- uppsrc/ide/Console.cpp | 6 +- uppsrc/ide/ContextGoto.cpp | 17 +- uppsrc/ide/DCopy.cpp | 12 +- uppsrc/ide/Errors.cpp | 2 +- uppsrc/ide/FindInFiles.cpp | 7 +- uppsrc/ide/GoToLine.cpp | 2 +- uppsrc/ide/MacroManager.cpp | 2 +- uppsrc/ide/ParamInfo.cpp | 10 +- uppsrc/ide/Qtf.cpp | 16 +- uppsrc/ide/Swaps.cpp | 2 +- uppsrc/ide/Thisbacks.cpp | 2 +- uppsrc/ide/Virtuals.cpp | 2 +- uppsrc/ide/Xml.cpp | 2 +- uppsrc/ide/ide.cpp | 27 +- uppsrc/ide/ide.h | 6 +- uppsrc/ide/idebar.cpp | 9 +- uppsrc/ide/idefile.cpp | 104 ++++- uppsrc/ide/idetool.cpp | 10 +- uppsrc/ide/t.cpp | 2 +- 55 files changed, 1240 insertions(+), 714 deletions(-) diff --git a/uppsrc/CodeEditor/CHighlight.cpp b/uppsrc/CodeEditor/CHighlight.cpp index 0f74edc91..830b62cba 100644 --- a/uppsrc/CodeEditor/CHighlight.cpp +++ b/uppsrc/CodeEditor/CHighlight.cpp @@ -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(); diff --git a/uppsrc/CodeEditor/CLogic.cpp b/uppsrc/CodeEditor/CLogic.cpp index fd5af483e..da40f77a0 100644 --- a/uppsrc/CodeEditor/CLogic.cpp +++ b/uppsrc/CodeEditor/CLogic.cpp @@ -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 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; diff --git a/uppsrc/CodeEditor/CSyntax.h b/uppsrc/CodeEditor/CSyntax.h index 92cdd79f2..0f23e1dca 100644 --- a/uppsrc/CodeEditor/CSyntax.h +++ b/uppsrc/CodeEditor/CSyntax.h @@ -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 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[]); diff --git a/uppsrc/CodeEditor/CodeEditor.cpp b/uppsrc/CodeEditor/CodeEditor.cpp index 4cebb39d4..2f7adbefb 100644 --- a/uppsrc/CodeEditor/CodeEditor.cpp +++ b/uppsrc/CodeEditor/CodeEditor.cpp @@ -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 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& hl, int pos) +void CodeEditor::HighlightLine(int line, Vector& hl, int64 pos) { CTIMING("HighlightLine"); HighlightOutput hls(hl); diff --git a/uppsrc/CodeEditor/CodeEditor.h b/uppsrc/CodeEditor/CodeEditor.h index 5ea94603b..e171d3bd2 100644 --- a/uppsrc/CodeEditor/CodeEditor.h +++ b/uppsrc/CodeEditor/CodeEditor.h @@ -195,7 +195,7 @@ public: virtual void MouseWheel(Point p, int zdelta, dword keyFlags); protected: - virtual void HighlightLine(int line, Vector& h, int pos); + virtual void HighlightLine(int line, Vector& 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 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 WhenTip; Event<> WhenLeftDown; - Event WhenCtrlClick; + Event WhenCtrlClick; Event<> WhenAnnotationMove; Event<> WhenAnnotationClick; Event<> WhenAnnotationRightClick; @@ -356,7 +366,7 @@ public: Event WhenPaste; Event<> WhenUpdate; - Event>&> WhenFindAll; + Event>&> WhenFindAll; FrameTop