Skip to content

Commit 2acff8e

Browse files
committed
1. new fields in EditorInfo: WindowArea and ClientArea.
1 parent 065df55 commit 2acff8e

8 files changed

Lines changed: 67 additions & 14 deletions

File tree

far/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
--------------------------------------------------------------------------------
2+
zg 2026-01-16 15:52:07+02:00 - build 6632
3+
4+
1. new fields in EditorInfo: WindowArea and ClientArea.
5+
16
--------------------------------------------------------------------------------
27
drkns 2026-01-11 20:35:34+00:00 - build 6631
38

far/common/2d/rectangle.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ struct rectangle_t
9494
{
9595
return in_closed_range(left, Point.x, right) && in_closed_range(top, Point.y, bottom);
9696
}
97+
98+
template<typename Y>
99+
[[nodiscard]]
100+
Y const as() const
101+
{
102+
return Y{left,top,right,bottom};
103+
}
97104
};
98105

99106
using small_rectangle = rectangle_t<short>;

far/editor.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,9 @@ void Editor::ShowEditor()
243243
Color = colors::PaletteColorToFarColor(COL_EDITORTEXT);
244244
SelColor = colors::PaletteColorToFarColor(COL_EDITORSELECTEDTEXT);
245245

246-
// Calculate line number column width if needed
247-
// Minimum width of 3 for "1", "10", "100", etc. plus 1 for spacing
248-
const auto LineNumWidth = EdOpt.ShowLineNumbers ?
249-
(std::max(3, static_cast<int>(std::log10(static_cast<double>(Lines.size()))) + 1) + 1) : 0;
246+
const auto LineNumWidth = LineNumbersWidth();
250247

251-
XX2 = m_Where.right - (EdOpt.ShowScrollBar && ScrollBarRequired(ObjHeight(), Lines.size())? 1 : 0);
248+
XX2 = m_Where.right - ScrollbalWidth();
252249
/* 17.04.2002 skv
253250
Что б курсор не бегал при Alt-F9 в конце длинного файла.
254251
Если на экране есть свободное место, и есть текст сверху,
@@ -5578,9 +5575,10 @@ int Editor::EditorControl(int Command, intptr_t Param1, void *Param2)
55785575

55795576
case ECTL_GETINFO:
55805577
{
5581-
const auto Info = static_cast<EditorInfo*>(Param2);
5582-
if (!CheckStructSize(Info))
5578+
const auto InfoV1 = static_cast<EditorInfoV1*>(Param2);
5579+
if (!CheckStructSize(InfoV1))
55835580
return false;
5581+
const auto Info = static_cast<EditorInfo*>(Param2);
55845582

55855583
Info->EditorID = EditorID;
55865584
Info->WindowSizeX=ObjWidth();
@@ -5646,6 +5644,12 @@ int Editor::EditorControl(int Command, intptr_t Param1, void *Param2)
56465644
Info->CurState |= m_Flags.Check(FEDITOR_MODIFIED)? 0 : ECSTATE_SAVED;
56475645
Info->CodePage = GetCodePage();
56485646

5647+
if (Info->StructSize > offsetof(EditorInfo, ClientArea))
5648+
{
5649+
Info->ClientArea = GetPosition().as<RECT>();
5650+
Info->ClientArea.left += LineNumbersWidth();
5651+
Info->ClientArea.right -= ScrollbalWidth();
5652+
}
56495653
return true;
56505654
}
56515655

@@ -7144,6 +7148,18 @@ void Editor::AutoDeleteColors()
71447148
m_AutoDeletedColors.clear();
71457149
}
71467150

7151+
int Editor::LineNumbersWidth() const
7152+
{
7153+
// Calculate line number column width if needed
7154+
// Minimum width of 3 for "1", "10", "100", etc. plus 1 for spacing
7155+
return EdOpt.ShowLineNumbers ? (std::max(3, static_cast<int>(std::log10(static_cast<double>(Lines.size()))) + 1) + 1) : 0;
7156+
}
7157+
7158+
int Editor::ScrollbalWidth() const
7159+
{
7160+
return EdOpt.ShowScrollBar && ScrollBarRequired(ObjHeight(), Lines.size())? 1 : 0;
7161+
}
7162+
71477163
#ifdef ENABLE_TESTS
71487164

71497165
#include "testing.hpp"

far/editor.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ class Editor final: public SimpleScreenObject
139139
bool IsLastLine(const Edit* Line) const;
140140
void AutoDeleteColors();
141141
int GetId() const { return EditorID; }
142+
int LineNumbersWidth() const;
143+
int ScrollbalWidth() const;
142144

143145
static eol GetDefaultEOL();
144146

far/fileedit.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,8 @@ intptr_t FileEditor::EditorControl(int Command, intptr_t Param1, void *Param2)
26462646
Info->Options|=EOPT_SHOWTITLEBAR;
26472647
if (Global->Opt->EdOpt.ShowKeyBar)
26482648
Info->Options|=EOPT_SHOWKEYBAR;
2649-
2649+
if (Info->StructSize > offsetof(EditorInfo, WindowArea))
2650+
Info->WindowArea = GetPosition().as<RECT>();
26502651
}
26512652
return result;
26522653
}

far/panel.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,7 @@ int Panel::SetPluginCommand(int Command,int Param1,void* Param2)
576576
break;
577577
}
578578

579-
const auto Rect = GetPosition();
580-
Info->PanelRect.left = Rect.left;
581-
Info->PanelRect.top = Rect.top;
582-
Info->PanelRect.right = Rect.right;
583-
Info->PanelRect.bottom = Rect.bottom;
579+
Info->PanelRect = GetPosition().as<RECT>();
584580
Info->ViewMode=GetViewMode();
585581
Info->SortMode = static_cast<OPENPANELINFO_SORTMODES>(internal_sort_mode_to_plugin(GetSortMode()));
586582

far/plugin.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,30 @@ enum EDITOR_CURRENTSTATE
19761976
ECSTATE_LOCKED = 0x00000004,
19771977
};
19781978

1979+
#ifdef FAR_USE_INTERNALS
1980+
struct EditorInfoV1
1981+
{
1982+
size_t StructSize;
1983+
intptr_t EditorID;
1984+
intptr_t WindowSizeX;
1985+
intptr_t WindowSizeY;
1986+
intptr_t TotalLines;
1987+
intptr_t CurLine;
1988+
intptr_t CurPos;
1989+
intptr_t CurTabPos;
1990+
intptr_t TopScreenLine;
1991+
intptr_t LeftPos;
1992+
intptr_t Overtype;
1993+
intptr_t BlockType;
1994+
intptr_t BlockStartLine;
1995+
uintptr_t Options;
1996+
intptr_t TabSize;
1997+
size_t BookmarkCount;
1998+
size_t SessionBookmarkCount;
1999+
uintptr_t CurState;
2000+
uintptr_t CodePage;
2001+
};
2002+
#endif // END FAR_USE_INTERNALS
19792003

19802004
struct EditorInfo
19812005
{
@@ -1998,6 +2022,8 @@ struct EditorInfo
19982022
size_t SessionBookmarkCount;
19992023
uintptr_t CurState;
20002024
uintptr_t CodePage;
2025+
RECT WindowArea;
2026+
RECT ClientArea;
20012027
};
20022028

20032029
struct EditorBookmarks

far/vbuild.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6631
1+
6632

0 commit comments

Comments
 (0)