ide: Filetime tip when mouse is over editor filename (or just coordinates)

This commit is contained in:
Mirek Fidler 2025-10-22 01:06:51 +02:00
parent 1056486e73
commit 66d9cade58
4 changed files with 52 additions and 1 deletions

View file

@ -638,6 +638,40 @@ void Ide::SetIcon()
#endif
}
Rect Ide::GetFileInfoRect()
{
Rect r = display.GetScreenRect();
r.top = r.bottom;
r.bottom = r.top + GetStdFontCy() + DPI(2);
return r - GetScreenRect().TopLeft();
}
void Ide::PaintFileInfo(Draw& w)
{
if(fileinfo_visible) {
Time tm(edittime);
String qtf = "[g ";
qtf << AsString(Format(" %d-%02d-%02d %02d:%02d:%02d",
(int)tm.year, (int)tm.month, (int)tm.day,
(int)tm.hour, (int)tm.minute, (int)tm.second));
qtf << ", Size " << FormatFileSize(editfile_length);
RichText txt = ParseQTF(qtf);
txt.ApplyZoom(GetRichTextStdScreenZoom());
Size tsz(txt.GetWidth(), txt.GetHeight(INT_MAX));
Rect r = GetFileInfoRect();
r.left = r.right - tsz.cx - DPI(4);
DrawFrame(w, r, SBlack());
r.Deflate(1, 1);
w.DrawRect(r, SColorPaper());
Size sz = r.GetSize();
txt.Paint(w, DPI(2) + r.left, (sz.cy - tsz.cy) / 2 + r.top, INT_MAX / 2);
}
}
void Ide::Periodic()
{
CheckFileUpdate();
@ -645,6 +679,12 @@ void Ide::Periodic()
if(debugger && debugger->IsFinished() && !IdeIsDebugLock())
IdeEndDebug();
SyncClang();
bool b = display.GetScreenRect().Contains(GetMousePos());
if(fileinfo_visible != b) {
Refresh(GetFileInfoRect());
Refresh();
fileinfo_visible = b;
}
}
struct IndexerProgress : ImageMaker {

View file

@ -528,8 +528,8 @@ public:
int editfile_repo;
bool editfile_isfolder;
bool replace_in_files = false; // Find in files replace or Replace found items mode - do not update things
String editfile2;
int64 editfile_length = 0;
String scratch_back; // to get back from Alt-M scratchfile
@ -688,6 +688,7 @@ public:
ParentCtrl barrect; // to do custom caption clipping
CursorInfoCtrl display, display_main;
ImageCtrl indeximage, indeximage2;
bool fileinfo_visible = false; // show file time when cursor points to display
byte hilite_scope;
int hilite_bracket;
@ -1169,6 +1170,9 @@ public:
void Periodic();
void SyncClang();
Rect GetFileInfoRect();
void PaintFileInfo(Draw& w);
void PassEditor(AssistEditor& editor2);
void PassEditor();
void SyncEditorSplit();

View file

@ -391,6 +391,7 @@ void Ide::SaveFile0(bool always)
FindFile ff(editfile);
fd.filetime = edittime = ff.GetLastWriteTime();
editfile_length = ff.GetLength();
if(!file_exists)
TriggerIdeBackgroundThread(2000);
@ -549,6 +550,7 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
bool tfile = GetFileExt(editfile) == ".t";
if(ff) {
edittime = ff.GetLastWriteTime();
editfile_length = ff.GetLength();
view_file.SetBufferSize(256*1024);
view_file.Open(editfile);
if(view_file) {

View file

@ -752,6 +752,11 @@ Ide::Ide()
});
};
#endif
InstallPaintHook([](Ctrl *ctrl, Draw& draw, const Rect&) {
if(ctrl == TheIde())
TheIde()->PaintFileInfo(draw);
});
}
Ide::~Ide()