DynamicLineNumbers.diff
CodeEditor/CodeEditor.cpp (kopia robocza) | ||
---|---|---|
623 | 623 |
LineEdit::MouseLeave(); |
624 | 624 |
} |
625 | 625 | |
626 |
int CodeEditor::Load(Stream& s, byte charset) |
|
627 |
{ |
|
628 |
int status = LineEdit::Load(s, charset); |
|
629 |
EditorBarLayout(); |
|
630 |
return status; |
|
631 |
} |
|
632 | ||
626 | 633 |
WString CodeEditor::GetI() |
627 | 634 |
{ |
628 | 635 |
int l, h; |
... | ... | |
765 | 772 | |
766 | 773 |
bool CodeEditor::Key(dword code, int count) { |
767 | 774 |
Time key_time = GetSysTime(); |
775 |
const int lineCount = GetLineCount(); |
|
768 | 776 |
double diff; |
769 | 777 |
if(!IsNull(last_key_time) && (diff = int(key_time - last_key_time)) <= 3) |
770 | 778 |
stat_edit_time += diff; |
... | ... | |
781 | 789 |
return true; |
782 | 790 |
case K_CTRL_BACKSPACE: |
783 | 791 |
DeleteWordBack(); |
792 |
SyncEditorBarLineNumbers(lineCount); |
|
784 | 793 |
return true; |
785 | 794 |
case K_BACKSPACE: |
786 | 795 |
if(!IsReadOnly() && !IsAnySelection() && indent_spaces) { |
... | ... | |
808 | 817 |
Action(); |
809 | 818 |
return true; |
810 | 819 |
} |
820 |
SyncEditorBarLineNumbers(lineCount); |
|
811 | 821 |
} |
812 | 822 |
break; |
813 | 823 |
case K_SHIFT_CTRL_TAB: |
814 | 824 |
return LineEdit::Key(K_TAB, count); |
815 | 825 |
case K_ENTER: |
816 | 826 |
IndentInsert('\n', count); |
827 |
SyncEditorBarLineNumbers(lineCount); |
|
817 | 828 |
return true; |
818 | 829 |
} |
819 | 830 |
bool sel = code & K_SHIFT; |
... | ... | |
899 | 910 |
if(GetCharset() != CHARSET_UTF8) |
900 | 911 |
if(code >= 128 && code < 65536 && FromUnicode((wchar)code, GetCharset()) == DEFAULTCHAR) |
901 | 912 |
return true; |
902 |
return LineEdit::Key(code, count); |
|
913 |
|
|
914 |
bool status = LineEdit::Key(code, count); |
|
915 |
SyncEditorBarLineNumbers(lineCount); |
|
916 |
return status; |
|
903 | 917 |
} |
904 | 918 | |
905 | 919 |
void CodeEditor::ForwardWhenBreakpoint(int i) { |
... | ... | |
953 | 967 |
<<= THISBACK1(SetI, &edit); |
954 | 968 |
} |
955 | 969 | |
970 |
void CodeEditor::SyncEditorBarLineNumbers(int previousLineCount) |
|
971 |
{ |
|
972 |
if (bar.IsLineNumbers() && |
|
973 |
IntStr(previousLineCount).GetCount() != IntStr(GetLineCount()).GetCount()) |
|
974 |
EditorBarLayout(); |
|
975 |
} |
|
976 | ||
956 | 977 |
CodeEditor::CodeEditor() { |
957 | 978 |
bracket_flash = false; |
958 | 979 |
highlight_bracket_pos0 = 0; |
CodeEditor/CodeEditor.h (kopia robocza) | ||
---|---|---|
134 | 134 |
void Annotations(int width); |
135 | 135 |
|
136 | 136 |
bool IsHiliteIfEndif() const { return hilite_if_endif; } |
137 |
bool IsLineNumbers() const { return line_numbers; } |
|
137 | 138 |
|
138 | 139 |
int GetActiveAnnotationLine() const { return active_annotation; } |
139 | 140 | |
... | ... | |
188 | 189 |
virtual Image CursorImage(Point p, dword keyflags); |
189 | 190 |
virtual void Serialize(Stream& s); |
190 | 191 |
virtual void MouseLeave(); |
191 | ||
192 |
|
|
193 |
virtual int Load(Stream& s, byte charset = CHARSET_DEFAULT); |
|
194 |
|
|
192 | 195 |
protected: |
193 | 196 |
virtual void HighlightLine(int line, Vector<LineEdit::Highlight>& h, int pos); |
194 | 197 |
virtual void PreInsert(int pos, const WString& s); |
... | ... | |
315 | 318 |
void Make(Callback1<String&> op); |
316 | 319 |
void TabsOrSpaces(String& out, bool maketabs); |
317 | 320 |
void LineEnds(String& out); |
318 | ||
321 |
|
|
322 |
void SyncEditorBarLineNumbers(int oldLineNumbersCount); |
|
323 |
|
|
319 | 324 |
enum { |
320 | 325 |
TIMEID_PERIODIC = Ctrl::TIMEID_COUNT, |
321 | 326 |
TIMEID_COUNT, |
CodeEditor/EditorBar.cpp (kopia robocza) | ||
---|---|---|
88 | 88 |
if(editor->GetCaret().top == y && editor->barline) |
89 | 89 |
w.DrawRect(0, y, sz.cx, fy, Blend(SColorHighlight(), SColorLtFace(), 200)); |
90 | 90 |
if(line_numbers && i < editor->GetLineCount()) { |
91 |
String n = AsString((i + 1) % 10000); |
|
91 |
String n = AsString((i + 1) % 1000000);
|
|
92 | 92 |
Font fnt = editor->GetFont(); |
93 | 93 |
Size tsz = GetTextSize(n, fnt); |
94 |
w.DrawText(sz.cx - 8 - 12 - tsz.cx, y + (fy - tsz.cy) / 2, n, fnt, Brown);
|
|
94 |
w.DrawText(sz.cx - 4 - 12 - tsz.cx, y + (fy - tsz.cy) / 2, n, fnt, Brown);
|
|
95 | 95 |
} |
96 | 96 |
if(hi_if) { |
97 | 97 |
Vector<IfState> nextif; |
... | ... | |
476 | 476 | |
477 | 477 |
void EditorBar::SyncWidth() |
478 | 478 |
{ |
479 |
Width((line_numbers && editor ? editor->GetFont()['0'] * 4 + 12 : 12) + annotations); |
|
479 |
int digits = 1; |
|
480 |
if (editor) |
|
481 |
digits = IntStr(editor->GetLineCount()).GetLength(); |
|
482 |
Width((line_numbers && editor ? editor->GetFont()['0'] * digits + 12 + 4 : 12 + 4) + annotations); |
|
480 | 483 |
Refresh(); |
481 | 484 |
} |
482 | 485 |