ide: Edits now shown in scrollbar

This commit is contained in:
Mirek Fidler 2022-10-24 10:08:09 +02:00
parent 4fb4baf57f
commit f866eda8d5
12 changed files with 104 additions and 156 deletions

View file

@ -1,3 +1,4 @@
- Report chrono issue
- debugger clang - nesting issues
@ -18,6 +19,12 @@ gtk3 warnings
visual C++ static libs
fix progress
macos UDH rect tracker
@ -79,6 +86,17 @@ DONE:
- Win32 menu checkbox
- Classic is broken
- ClassicCtrlsImg
- Ide: When dark editor in light theme, svn history is invisible (as text is white)
- Unknown layout type should have better visual
- LayDes menu background color
@ -182,6 +200,12 @@ gtk3 DONE:
- Ide split buttons look unexpected
- Issue with editfield text clipping in the right
- Possible issue with Capture (e.g. ide about box)
- WithDropChoice ch issue (again...)
- Problem with multibutton is back again
- Redmond scrollbars width

View file

@ -19,10 +19,13 @@ new/delete:
Allocator > 64KB
CoDo
Consider refactoring void VectorReAlloc_(void *v_, int newalloc, int sizeofT) to remove division.
oportunity &&
RawValueRep - PICK DEEP no more necessary, RawDeepToValue?
@ -47,6 +50,9 @@ String MD5Digest(const void *data, int length);
Remove ValueType uses
InVector::InsertN possibly incorrect (can create small blocks)
Stream& Stream::operator/(int& i) { dword w = 0; if(IsStoring()) w = i + 1; Pack(w); i = w - 1; return *this; }

View file

@ -74,10 +74,8 @@ void CodeEditor::DirtyFrom(int line) {
if(syntax_cache[i].line >= line)
syntax_cache[i].Clear();
if(check_edited) {
bar.ClearErrors(line);
if(check_edited)
bar.Refresh();
}
}
inline bool IsComment(int a, int b) {
@ -130,6 +128,7 @@ void CodeEditor::PreRemove(int pos, int size) {
refresh_info = GetRefreshInfo(pos);
}
}
sbi.Refresh();
}
void CodeEditor::PostRemove(int pos, int size) {
@ -139,10 +138,12 @@ void CodeEditor::PostRemove(int pos, int size) {
EditorBarLayout();
if(GetRefreshInfo(pos) != refresh_info)
Refresh();
sbi.Refresh();
}
void CodeEditor::ClearLines() {
bar.ClearLines();
sbi.Refresh();
}
void CodeEditor::InsertLines(int line, int count) {
@ -1200,10 +1201,22 @@ void CodeEditor::ScrollBarItems::Paint(Draw& w)
w.DrawImage(sr.CenterPoint().x - isz.cx / 2, sr.top + y - isz.cy / 2, m, x.Get<Color>());
}
}
Color bg = IsDarkTheme() ? GrayColor(70) : SColorLtFace();
for(int i = 0; i < editor.bar.li.GetCount(); i++) {
int edit = editor.bar.li[i].edited;
if(edit) {
int age = (int)(log((double)(editor.GetUndoCount() + 1 - edit)) * 30);
int y = sb.GetSliderPos(i);
if(!IsNull(y))
w.DrawRect(sr.left + DPI(2), sr.top + y, DPI(2),
max(sb.GetTotal() / sr.GetHeight(), DPI(4)),
Blend(SLtBlue(), bg, min(220, age)));
}
}
}
CodeEditor::ScrollBarItems::ScrollBarItems(ScrollBar& sb)
: sb(sb) {
CodeEditor::ScrollBarItems::ScrollBarItems(ScrollBar& sb, CodeEditor& e)
: sb(sb), editor(e) {
sb.Add(SizePos());
Transparent();
IgnoreMouse();
@ -1215,7 +1228,7 @@ void CodeEditor::Errors(Vector<Point>&& errs)
Refresh();
sbi.pos.Clear();
for(Point p : errors)
sbi.pos.Add({ p.y, CodeEditorImg::dot(), Red() });
sbi.pos.Add({ p.y, CodeEditorImg::dot(), LtRed() });
sbi.Refresh();
}
@ -1226,7 +1239,7 @@ void CodeEditor::Layout()
}
CodeEditor::CodeEditor()
: sbi(sb.y) {
: sbi(sb.y, *this) {
bracket_flash = false;
highlight_bracket_pos0 = 0;
bracket_start = 0;

View file

@ -22,17 +22,14 @@ struct LineInfoRecord {
int lineno;
String breakpoint;
int count;
int error;
int firstedited;
int edited;
LineInfoRecord() { error = 0; edited = 0; }
LineInfoRecord() { edited = 0; }
};
typedef Array<LineInfoRecord> LineInfo;
void ClearErrors(LineInfo& li);
struct LineInfoRemRecord : Moveable<LineInfoRemRecord> {
int firstedited;
int edited;
@ -58,15 +55,12 @@ public:
private:
struct LnInfo : Moveable<LnInfo> {
int lineno;
int lineno = -1;
String breakpoint;
int error;
int firstedited;
int edited;
int firstedited = 0;
int edited = 0;
Image icon;
String annotation;
LnInfo() { lineno = -1; error = 0; firstedited = 0; edited = 0; }
};
Vector<LnInfo> li;
@ -87,6 +81,8 @@ private:
String& PointBreak(int& y);
void sPaintImage(Draw& w, int y, int fy, const Image& img);
friend class CodeEditor;
public:
Event<int> WhenBreakpoint;
@ -110,8 +106,6 @@ public:
void SetBreakpoint(int ln, const String& s);
void SetEdited(int ln, int count = 1);
void ClearEdited();
void SetError(int ln, int err);
void ClearErrors(int ln);
void SetEditor(CodeEditor *e) { editor = e; }
@ -309,12 +303,13 @@ protected:
struct ScrollBarItems : Ctrl {
ScrollBar& sb;
CodeEditor& editor;
void Paint(Draw& w);
Vector<Tuple<int, Image, Color>> pos;
ScrollBarItems(ScrollBar& sb);
ScrollBarItems(ScrollBar& sb, CodeEditor& e);
};
ScrollBarItems sbi;
@ -484,8 +479,6 @@ public:
void HidePtr() { bar.HidePtr(); }
String GetBreakpoint(int line) { return bar.GetBreakpoint(line); }
void SetBreakpoint(int line, const String& b) { bar.SetBreakpoint(line, b); }
void SetError(int line, int err) { bar.SetError(line, err); }
void ClearErrors(int line = -1) { bar.ClearErrors(line); }
void ClearEdited() { bar.ClearEdited(); }
int GetUndoCount() { return undo.GetCount(); }
void GotoLine(int line);

View file

@ -11,20 +11,18 @@ void Renumber(LineInfo& lf)
t.breakpoint = lf[0].breakpoint;
t.lineno = 0;
t.count = lf[0].count;
t.error = lf[0].error;
t.firstedited = lf[0].firstedited;
t.edited = lf[0].edited;
l += t.count;
}
for(int i = 1; i < lf.GetCount(); i++) {
LineInfoRecord& r = lf[i];
if(r.breakpoint.IsEmpty() && r.error == 0 && r.edited == 0 &&
tf.Top().breakpoint.IsEmpty() && tf.Top().error == 0 && tf.Top().edited == 0)
if(r.breakpoint.IsEmpty() && r.edited == 0 &&
tf.Top().breakpoint.IsEmpty() && tf.Top().edited == 0)
tf.Top().count += r.count;
else {
LineInfoRecord& t = tf.Add();
t.breakpoint = r.breakpoint;
t.error = r.error;
t.firstedited = r.firstedited;
t.edited = r.edited;
t.count = r.count;
@ -84,7 +82,6 @@ void EditorBar::Paint(Draw& w)
if(i < li.GetCount()) {
const LnInfo& l = li[i];
b = l.breakpoint;
err = l.error;
edit = l.edited;
icon = l.icon;
ann = l.annotation;
@ -288,12 +285,11 @@ LineInfo EditorBar::GetLineInfo() const
int l = -2;
for(int i = 0; i < li.GetCount(); i++) {
const LnInfo& ln = li[i];
if(!ln.breakpoint.IsEmpty() || ln.error || ln.edited) {
if(!ln.breakpoint.IsEmpty() || ln.edited) {
LineInfoRecord& r = lf.Add();
r.lineno = ln.lineno;
r.count = 1;
r.breakpoint = ln.breakpoint;
r.error = ln.error;
r.firstedited = ln.firstedited;
r.edited = ln.edited;
l = -2;
@ -326,7 +322,6 @@ void EditorBar::SetLineInfo(const LineInfo& lf, int total)
LnInfo& ln = li.Add();
ln.lineno = l;
ln.breakpoint = r.breakpoint;
ln.error = r.error;
ln.firstedited = r.firstedited;
ln.edited = r.edited;
if(l >= 0) l++;
@ -434,28 +429,6 @@ void EditorBar::ClearEdited()
Refresh();
}
void EditorBar::SetError(int ln, int err)
{
li.At(ln).error = err;
}
void EditorBar::ClearErrors(int line)
{
int count;
if(line < 0) {
line = 0;
count = li.GetCount();
}
else
if(line >= li.GetCount())
return;
else
count = line + 1;
for(int i = line; i < count; i++)
li[i].error = 0;
}
int EditorBar::GetLineNo(int lineno) const {
for(int i = 0; i < li.GetCount(); i++) {
if(lineno <= li[i].lineno)
@ -540,15 +513,4 @@ EditorBar::~EditorBar()
{
}
void ClearErrors(LineInfo& li)
{
for(int i = 0; i < li.GetCount(); i++)
li[i].error = 0;
}
void SetError(LineInfo& li, int line, int err)
{
li.At(line).error = err;
}
}

View file

@ -132,7 +132,7 @@ void Ide::FileCompile()
{
if(editfile.IsEmpty())
return;
ClearErrorEditor(editfile);
linking = false;
SwitchHeader();
BeginBuilding(true);
const Workspace& wspc = IdeWorkspace();

View file

@ -429,7 +429,6 @@ bool MakeBuild::Build(const Workspace& wspc, String mainparam, String outfile, b
start_time = GetFileTime(hfile); // Defensive way to get correct filetime of start
DeleteFile(hfile);
ClearErrorEditor();
BeginBuilding(clear_console);
bool ok = true;
main_conf.Clear();

View file

@ -35,10 +35,9 @@ public:
virtual void SetupDefaultMethod() = 0;
virtual Vector<String> PickErrors() = 0; //console.PickErrors()
virtual void BeginBuilding(bool clear_console) = 0;
virtual void EndBuilding(bool ok) = 0;
virtual void ClearErrorEditor() = 0;
virtual void DoProcessEvents() = 0;
virtual void SetErrorEditor() = 0;
virtual void EndBuilding(bool ok) = 0;
virtual void DoProcessEvents() = 0;
virtual String GetMain() = 0;
struct TransferFileInfo

View file

@ -226,32 +226,6 @@ void Ide::FindPrevError() {
if(FindLineError(l)) return;
}
void Ide::ClearErrorEditor()
{
if(!mark_lines)
return;
for(int i = 0; i < filedata.GetCount(); i++) {
ClearErrorEditor(filedata.GetKey(i));
}
SetErrorFiles(Vector<String>());
}
void Ide::ClearErrorEditor(String file)
{
linking = false;
if(!mark_lines)
return;
if(file == editfile)
editor.ClearErrors();
else {
FileData& fd = Filedata(file);
ClearErrors(fd.lineinfo);
}
}
void Ide::SetErrorEditor()
{
if(error.GetCount()) {
@ -260,12 +234,7 @@ void Ide::SetErrorEditor()
// error.GoBegin();
}
if(!mark_lines)
return;
bool refresh = false;
String hfile;
EditorBar hbar;
Vector<String> errorfiles;
FindLineErrorCache cache;
for(int i = 0; i < console.GetLineCount(); i++) {
@ -277,23 +246,8 @@ void Ide::SetErrorEditor()
#else
errorfiles.Add(file);
#endif
if(editfile == file) {
editor.SetError(f.lineno - 1, f.kind);
refresh = true;
}
else {
if(hfile != file) {
if(hfile.GetCount())
Filedata(hfile).lineinfo = hbar.GetLineInfo();
hbar.SetLineInfo(Filedata(file).lineinfo, -1);
hfile = file;
}
hbar.SetError(f.lineno - 1, f.kind);
}
}
}
if(hfile.GetCount())
Filedata(hfile).lineinfo = hbar.GetLineInfo();
if(refresh)
editor.RefreshFrame();
SetErrorFiles(errorfiles);

View file

@ -23,7 +23,7 @@ Font WorkspaceWork::ListFont()
void WorkspaceWork::SetErrorFiles(const Vector<String>& files)
{
errorfiles <<= Index<String>(files, 1);
errorfiles = clone(files);
int i = filelist.GetCursor();
int s = filelist.GetSbPos();
SaveLoadPackage(false);

View file

@ -86,7 +86,7 @@ protected:
int msecs;
int raw_msecs;
};
struct Finisher {
int serial;
Event<> cb;
@ -137,7 +137,7 @@ public:
Vector<String> PickErrors() { Vector<String> e = pick(error_keys); error_keys.Clear(); return pick(e); }
void Wait(int slot);
bool Wait();
void OnFinish(Event<> cb);
void WrapText(bool w) { wrap_text = w; }
@ -184,11 +184,11 @@ private:
DropList lang;
bool internal;
bool showwords, all;
VectorMap<String, VectorMap<String, Index<String> > > map;
Index<String> lang_list;
Vector<int> spos;
static Index<String> idelink;
void OpenTopic();
@ -323,12 +323,12 @@ struct FindInFilesDlg : WithFindInFilesLayout<TopWindow> {
WString itext;
virtual bool Key(dword key, int count);
void Setup(bool replace);
void Sync();
typedef FindInFilesDlg CLASSNAME;
FindInFilesDlg();
};
@ -340,7 +340,7 @@ struct WebSearchTab : WithSetupWebSearchTabLayout<ParentCtrl> {
void Sync();
void Edit();
void Default();
WebSearchTab();
};
@ -350,7 +350,7 @@ struct CursorInfoCtrl : Ctrl {
void Paint(Draw& w) override;
void Set(const String& s) { text = s; Refresh(); }
CursorInfoCtrl();
};
@ -443,7 +443,6 @@ public:
virtual Vector<String> PickErrors();
virtual void BeginBuilding(bool clear_console);
virtual void EndBuilding(bool ok);
virtual void ClearErrorEditor();
virtual void DoProcessEvents();
virtual void SetErrorEditor();
virtual String GetMain();
@ -462,7 +461,7 @@ public:
int idestate;
int debuglock;
int hydra1_threads;
int chstyle;
One<IdeDesigner> designer;
@ -477,7 +476,7 @@ public:
StaticRect bottom;
Splitter editor_bottom;
Console console;
ArrayCtrl ffound[3];
int ffoundi_next = 0;
@ -555,7 +554,7 @@ public:
ArrayMap<String, FileData> filedata;
Index<String> editastext;
Index<String> editashex;
Vector<String> difflru;
DropList mainconfiglist;
@ -625,7 +624,7 @@ public:
bool header_guards;
int filetabs;
bool auto_enclose;
bool mark_lines;
bool mark_lines = true;
bool find_pick_sel;
bool find_pick_text;
bool deactivate_save;
@ -667,7 +666,7 @@ public:
bool astyle_EmptyLineFill;
bool astyle_TabSpaceConversionMode;
WString astyle_TestBox;
// Formats a string of code with a given formatter
WString FormatCodeString(WString const &Src, astyle::ASFormatter &Formatter);
@ -704,17 +703,17 @@ public:
TopicCtrl windoc;
int state_icon;
String export_dir;
VectorMap<String, String> abbr;
int issaving;
int isscanning;
String current_builder;
bool hlstyle_is_default = true; // default style reacts to dark / light theme settings
int animate_current_file = 0, animate_current_file_dir = 0;
int animate_autocomplete = 0, animate_autocomplete_dir = 0;
int animate_indexer = 0, animate_indexer_dir = 0;
@ -742,7 +741,7 @@ public:
void EditorEdit();
void GotoBookmark(const Bookmark& b);
bool IsHistDiff(int i);
void IdePaste(String& s);
bool HasFileData(const String& file);
@ -782,7 +781,7 @@ public:
String IncludesMD5();
void AKEditor();
void PackageMenu(Bar& menu);
void UscFile(const String& file);
@ -805,7 +804,7 @@ public:
void GotoPos(Point pos);
void GotoPos(String path, int line);
void GotoPos(String path, Point pos);
void LoadAbbr();
void SaveAbbr();
@ -880,7 +879,7 @@ public:
bool Next(ArrayCtrl& ctrl, int d);
void FindNextError();
void FindPrevError();
void EditSpecial(Bar& menu);
void TranslateString();
void SwapChars() { editor.SwapChars(); }
@ -961,13 +960,13 @@ public:
void DoMacroManager();
void UpgradeTheIDE();
void InstallDesktop();
void SetupMobilePlatforms(Bar& bar);
void SetupAndroidMobilePlatform(Bar& bar, const AndroidSDK& androidSDK);
void LaunchAndroidSDKManager(const AndroidSDK& androidSDK);
void LaunchAndroidAVDManager(const AndroidSDK& androidSDK);
void LauchAndroidDeviceMonitor(const AndroidSDK& androidSDK);
void BrowseMenu(Bar& menu);
void QueryId();
void OpenTopic(const String& topic, const String& create_id, bool before);
@ -1037,15 +1036,15 @@ public:
void CycleFiles();
void Renumber();
String GetTargetLogPath();
String GetIdeLogPath();
void OpenLog(const String& logFilePath);
String include_path; // cached value of include path, GetIncludePath
virtual void LaunchTerminal(const char *dir);
// Console& GetConsole();
struct FindLineErrorCache {
@ -1054,7 +1053,7 @@ public:
String upp;
bool is_java;
bool init;
void Clear() { init = false; file.Clear(); wspc_paths.Clear(); }
};
@ -1066,10 +1065,10 @@ public:
int kind;
String message;
String error_pos;
ErrorInfo() { lineno = linepos = kind = len = 0; }
};
FindLineErrorCache error_cache;
void ConsoleLine(const String& line, bool assist = false);
void ConsoleRunEnd();
@ -1088,7 +1087,7 @@ public:
void ClearErrorsPane();
WString FormatErrorLine(const String& text, int& linecy);
WString FormatErrorLineEP(const String& text, const char *ep, int& linecy);
struct FoundDisplay : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
};
@ -1101,14 +1100,13 @@ public:
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
virtual Size GetStdSize(const Value& q) const;
};
bool FindLineError(int l);
void GoToError(const ErrorInfo& f);
void GoToError(ArrayCtrl& a);
bool FindLineError(const String& ln, FindLineErrorCache& cache, ErrorInfo& f);
void FindError();
void ClearErrorEditor(String file);
void FindWildcard();
void FindFolder();
@ -1153,8 +1151,8 @@ public:
void SetMenuBar();
void SetToolBar();
TimeCallback delayed_toolbar;
void UpdateFormat(CodeEditor& editor);
void UpdateFormat();
void ReadHlStyles(ArrayCtrl& hlstyle);
@ -1230,7 +1228,7 @@ public:
void MacroPackageFiles(EscEscape& e);
void MacroAllPackages(EscEscape& e);
void MacroTarget(EscEscape& e);
String GetAndroidSdkPath();
void TriggerIndexer0();
@ -1260,4 +1258,4 @@ void UppHubAuto(const String& s);
#include "urepo.h"
#endif
#endif

View file

@ -591,7 +591,7 @@ LAYOUT(SetupAssistLayout, 544, 312)
ITEM(Upp::EditIntSpin, parsed_files, LeftPosZ(248, 64).TopPosZ(88, 19))
ITEM(Upp::Option, commentdp, SetLabel(t_("Comment out default parameters in \"Copy as declaration\"")).Tip(t_("Comment out default parameters when converting declaration to definition instead of removing them")).LeftPosZ(4, 304).TopPosZ(112, 16))
ITEM(Upp::Option, auto_enclose, SetLabel(t_("[ { ( \" / * enclose selection")).LeftPosZ(4, 252).TopPosZ(132, 16))
ITEM(Upp::Option, mark_lines, SetLabel(t_("Mark lines with errors, warnings and changes")).LeftPosZ(4, 252).TopPosZ(152, 16))
ITEM(Upp::Option, mark_lines, SetLabel(t_("Mark lines with changes")).LeftPosZ(4, 252).TopPosZ(152, 16))
ITEM(Upp::Option, barline, SetLabel(t_("Highlight line in the left bar")).LeftPosZ(4, 252).TopPosZ(172, 16))
ITEM(Upp::Option, qtfsel, SetLabel(t_("QTF designer edits selection")).LeftPosZ(4, 252).TopPosZ(192, 16))
ITEM(Upp::Option, navigator_right, SetLabel(t_("Place navigator to the right")).LeftPosZ(4, 252).TopPosZ(212, 16))