[FarGroup/FarManager] master: 1. new fields in EditorInfo: WindowArea and ClientArea. (2acff8e8e)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
9:00 AM (9 hours ago) 9:00 AM
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/2acff8e8eeaaf5c732dc482e15a89953c9462f37

>---------------------------------------------------------------

commit 2acff8e8eeaaf5c732dc482e15a89953c9462f37
Author: Vadim Yegorov <z...@bmg.lv>
Date: Fri Jan 16 15:59:47 2026 +0200

1. new fields in EditorInfo: WindowArea and ClientArea.


>---------------------------------------------------------------

2acff8e8eeaaf5c732dc482e15a89953c9462f37
far/changelog | 5 +++++
far/common/2d/rectangle.hpp | 7 +++++++
far/editor.cpp | 30 +++++++++++++++++++++++-------
far/editor.hpp | 2 ++
far/fileedit.cpp | 3 ++-
far/panel.cpp | 6 +-----
far/plugin.hpp | 26 ++++++++++++++++++++++++++
far/vbuild.m4 | 2 +-
8 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/far/changelog b/far/changelog
index 842c05bf3..44bd055ab 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,3 +1,8 @@
+--------------------------------------------------------------------------------
+zg 2026-01-16 15:52:07+02:00 - build 6632
+
+1. new fields in EditorInfo: WindowArea and ClientArea.
+
--------------------------------------------------------------------------------
drkns 2026-01-11 20:35:34+00:00 - build 6631

diff --git a/far/common/2d/rectangle.hpp b/far/common/2d/rectangle.hpp
index 929555b2c..9205648f6 100644
--- a/far/common/2d/rectangle.hpp
+++ b/far/common/2d/rectangle.hpp
@@ -94,6 +94,13 @@ struct rectangle_t
{
return in_closed_range(left, Point.x, right) && in_closed_range(top, Point.y, bottom);
}
+
+ template<typename Y>
+ [[nodiscard]]
+ Y const as() const
+ {
+ return Y{left,top,right,bottom};
+ }
};

using small_rectangle = rectangle_t<short>;
diff --git a/far/editor.cpp b/far/editor.cpp
index 054b1ad61..d486e8779 100644
--- a/far/editor.cpp
+++ b/far/editor.cpp
@@ -243,12 +243,9 @@ void Editor::ShowEditor()
Color = colors::PaletteColorToFarColor(COL_EDITORTEXT);
SelColor = colors::PaletteColorToFarColor(COL_EDITORSELECTEDTEXT);

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

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

case ECTL_GETINFO:
{
- const auto Info = static_cast<EditorInfo*>(Param2);
- if (!CheckStructSize(Info))
+ const auto InfoV1 = static_cast<EditorInfoV1*>(Param2);
+ if (!CheckStructSize(InfoV1))
return false;
+ const auto Info = static_cast<EditorInfo*>(Param2);

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

+ if (Info->StructSize > offsetof(EditorInfo, ClientArea))
+ {
+ Info->ClientArea = GetPosition().as<RECT>();
+ Info->ClientArea.left += LineNumbersWidth();
+ Info->ClientArea.right -= ScrollbalWidth();
+ }
return true;
}

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

+int Editor::LineNumbersWidth() const
+{
+ // Calculate line number column width if needed
+ // Minimum width of 3 for "1", "10", "100", etc. plus 1 for spacing
+ return EdOpt.ShowLineNumbers ? (std::max(3, static_cast<int>(std::log10(static_cast<double>(Lines.size()))) + 1) + 1) : 0;
+}
+
+int Editor::ScrollbalWidth() const
+{
+ return EdOpt.ShowScrollBar && ScrollBarRequired(ObjHeight(), Lines.size())? 1 : 0;
+}
+
#ifdef ENABLE_TESTS

#include "testing.hpp"
diff --git a/far/editor.hpp b/far/editor.hpp
index 40c763eba..86621642d 100644
--- a/far/editor.hpp
+++ b/far/editor.hpp
@@ -139,6 +139,8 @@ public:
bool IsLastLine(const Edit* Line) const;
void AutoDeleteColors();
int GetId() const { return EditorID; }
+ int LineNumbersWidth() const;
+ int ScrollbalWidth() const;

static eol GetDefaultEOL();

diff --git a/far/fileedit.cpp b/far/fileedit.cpp
index b55909f01..9de27694c 100644
--- a/far/fileedit.cpp
+++ b/far/fileedit.cpp
@@ -2646,7 +2646,8 @@ intptr_t FileEditor::EditorControl(int Command, intptr_t Param1, void *Param2)
Info->Options|=EOPT_SHOWTITLEBAR;
if (Global->Opt->EdOpt.ShowKeyBar)
Info->Options|=EOPT_SHOWKEYBAR;
-
+ if (Info->StructSize > offsetof(EditorInfo, WindowArea))
+ Info->WindowArea = GetPosition().as<RECT>();
}
return result;
}
diff --git a/far/panel.cpp b/far/panel.cpp
index b3eed7043..a1d17e857 100644
--- a/far/panel.cpp
+++ b/far/panel.cpp
@@ -576,11 +576,7 @@ int Panel::SetPluginCommand(int Command,int Param1,void* Param2)
break;
}

- const auto Rect = GetPosition();
- Info->PanelRect.left = Rect.left;
- Info->PanelRect.top = Rect.top;
- Info->PanelRect.right = Rect.right;
- Info->PanelRect.bottom = Rect.bottom;
+ Info->PanelRect = GetPosition().as<RECT>();
Info->ViewMode=GetViewMode();
Info->SortMode = static_cast<OPENPANELINFO_SORTMODES>(internal_sort_mode_to_plugin(GetSortMode()));

diff --git a/far/plugin.hpp b/far/plugin.hpp
index f8c6c8300..0948eac19 100644
--- a/far/plugin.hpp
+++ b/far/plugin.hpp
@@ -1976,6 +1976,30 @@ enum EDITOR_CURRENTSTATE
ECSTATE_LOCKED = 0x00000004,
};

+#ifdef FAR_USE_INTERNALS
+struct EditorInfoV1
+{
+ size_t StructSize;
+ intptr_t EditorID;
+ intptr_t WindowSizeX;
+ intptr_t WindowSizeY;
+ intptr_t TotalLines;
+ intptr_t CurLine;
+ intptr_t CurPos;
+ intptr_t CurTabPos;
+ intptr_t TopScreenLine;
+ intptr_t LeftPos;
+ intptr_t Overtype;
+ intptr_t BlockType;
+ intptr_t BlockStartLine;
+ uintptr_t Options;
+ intptr_t TabSize;
+ size_t BookmarkCount;
+ size_t SessionBookmarkCount;
+ uintptr_t CurState;
+ uintptr_t CodePage;
+};
+#endif // END FAR_USE_INTERNALS

struct EditorInfo
{
@@ -1998,6 +2022,8 @@ struct EditorInfo
size_t SessionBookmarkCount;
uintptr_t CurState;
uintptr_t CodePage;
+ RECT WindowArea;
+ RECT ClientArea;
};

struct EditorBookmarks
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index 8fa7a243e..50b4cb68c 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6631
+6632


Reply all
Reply to author
Forward
0 new messages