Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 8452a45

Browse files
author
Savas Ziplies
committed
Added: Example output information of the current row and scroll information
1 parent 0eddd88 commit 8452a45

File tree

1 file changed

+19
-0
lines changed
  • Demo Plugin/NppManagedPluginDemo

1 file changed

+19
-0
lines changed

Demo Plugin/NppManagedPluginDemo/Demo.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Runtime.InteropServices;
1010
using System.Text.RegularExpressions;
1111
using Kbg.NppPluginNET.PluginInfrastructure;
12+
using static Kbg.NppPluginNET.PluginInfrastructure.Win32;
1213

1314
namespace Kbg.NppPluginNET
1415
{
@@ -126,6 +127,24 @@ static internal void CommandMenuInit()
126127
PluginBase.SetCommand(14, "---", null);
127128

128129
PluginBase.SetCommand(15, "Dockable Dialog Demo", DockableDlgDemo); idFrmGotToLine = 15;
130+
131+
PluginBase.SetCommand(16, "---", null);
132+
133+
PluginBase.SetCommand(17, "Print Scroll and Row Information", PrintScrollInformation);
134+
}
135+
136+
/// <summary>
137+
///
138+
/// </summary>
139+
static void PrintScrollInformation()
140+
{
141+
ScrollInfo scrollInfo = editor.GetScrollInfo(ScrollInfoMask.SIF_RANGE | ScrollInfoMask.SIF_TRACKPOS | ScrollInfoMask.SIF_PAGE, ScrollInfoBar.SB_VERT);
142+
var scrollRatio = (double)scrollInfo.nTrackPos / (scrollInfo.nMax - scrollInfo.nPage);
143+
var scrollPercentage = Math.Min(scrollRatio, 1) * 100;
144+
editor.ReplaceSel($@"The maximum row in the current document was {scrollInfo.nMax+1}.
145+
A maximum of {scrollInfo.nPage} rows is visible at a time.
146+
The current scroll ratio is {Math.Round(scrollPercentage, 2)}%.
147+
");
129148
}
130149

131150
static internal void SetToolBarIcon()

0 commit comments

Comments
 (0)