Comments (2)
Yes, me too. Notepad++ 7.8.6 64-bit. Looking at the code:
NppMarkdownPanel\NppMarkdownPanel\MarkdownPanelController.cs
49: public void OnNotification(ScNotification notification)
traps some events, in fact, you trap the right event:
NppMarkdownPanel\NppMarkdownPanel\MarkdownPanelController.cs
66: else if (notification.Header.Code == (uint)SciMsg.SCN_MODIFIED)
But the checking for SC_MOD_INSERTTEXT or SC_MOD_DELETETEXT seems to always turn up false as it never gets to
74: RenderMarkdown();
I commented out:
NppMarkdownPanel\NppMarkdownPanel\MarkdownPanelController.cs
68: // bool isInsert = (notification.ModificationType & (uint)SciMsg.SC_MOD_INSERTTEXT) != 0;
69: // bool isDelete = (notification.ModificationType & (uint)SciMsg.SC_MOD_DELETETEXT) != 0;
70: // // Any modifications made ?
71: // if (isInsert || isDelete)
72: // {
73: lastTickCount = Environment.TickCount;
74: RenderMarkdown();
75: // }
and it started automatically refreshing as I typed!
I also added a bit of scrolling buffer so that the Markdown preview doesn't sync it's top line with the N++ buffer with "Synchronize viewer with caret position" enabled. Basically, I just adjust down 10 lines, but it's configurable in the .INI file (maybe you want to expose that in your settings dialogue?).
C# is not my language; I was very lucky this compiled with no errors on VS2017. The following is a patch including my only changes:
--------
diff --git a/NppMarkdownPanel/MarkdownPanelController.cs b/NppMarkdownPanel/MarkdownPanelController.cs
index fe87cf5..30ef5d9 100644
--- a/NppMarkdownPanel/MarkdownPanelController.cs
+++ b/NppMarkdownPanel/MarkdownPanelController.cs
@@ -35,6 +35,7 @@ namespace NppMarkdownPanel
private int lastCaretPosition;
private string iniFilePath;
private bool syncViewWithCaretPosition;
+ private int ScrollBuffer;
public MarkdownPanelController()
{
@@ -55,7 +56,7 @@ namespace NppMarkdownPanel
if (syncViewWithCaretPosition && lastCaretPosition != scintillaGateway.GetCurrentPos().Value)
{
lastCaretPosition = scintillaGateway.GetCurrentPos().Value;
- ScrollToElementAtLineNo(scintillaGateway.GetCurrentLineNumber());
+ ScrollToElementAtLineNo(scintillaGateway.GetCurrentLineNumber() - ScrollBuffer);
}
}
else
@@ -65,14 +66,14 @@ namespace NppMarkdownPanel
}
else if (notification.Header.Code == (uint)SciMsg.SCN_MODIFIED)
{
- bool isInsert = (notification.ModificationType & (uint)SciMsg.SC_MOD_INSERTTEXT) != 0;
- bool isDelete = (notification.ModificationType & (uint)SciMsg.SC_MOD_DELETETEXT) != 0;
- // Any modifications made ?
- if (isInsert || isDelete)
- {
+ // bool isInsert = (notification.ModificationType & (uint)SciMsg.SC_MOD_INSERTTEXT) != 0;
+ // bool isDelete = (notification.ModificationType & (uint)SciMsg.SC_MOD_DELETETEXT) != 0;
+ // // Any modifications made ?
+ // if (isInsert || isDelete)
+ // {
lastTickCount = Environment.TickCount;
RenderMarkdown();
- }
+ // }
}
}
}
@@ -117,7 +118,8 @@ namespace NppMarkdownPanel
SetIniFilePath();
syncViewWithCaretPosition = (Win32.GetPrivateProfileInt("Options", "SyncViewWithCaretPosition", 0, iniFilePath) != 0);
markdownPreviewForm.CssFileName = Win32.ReadIniValue("Options", "CssFileName", iniFilePath, "style.css");
- markdownPreviewForm.ZoomLevel = Win32.GetPrivateProfileInt("Options", "ZoomLevel", 130, iniFilePath);
+ markdownPreviewForm.ZoomLevel = Win32.GetPrivateProfileInt("Options", "ZoomLevel", 100, iniFilePath);
+ ScrollBuffer = Win32.GetPrivateProfileInt("Options", "ScrollBuffer", 10, iniFilePath);
PluginBase.SetCommand(0, "About", ShowAboutDialog, new ShortcutKey(false, false, false, Keys.None));
PluginBase.SetCommand(1, "Toggle Markdown Panel", TogglePanelVisible);
PluginBase.SetCommand(2, "Synchronize viewer with caret position", SyncViewWithCaret, syncViewWithCaretPosition);
@@ -169,6 +171,7 @@ namespace NppMarkdownPanel
public void PluginCleanUp()
{
Win32.WritePrivateProfileString("Options", "SyncViewWithCaretPosition", syncViewWithCaretPosition ? "1" : "0", iniFilePath);
+ Win32.WriteIniValue("Options", "ScrollBuffer", ScrollBuffer.ToString(), iniFilePath);
SaveSettings();
}
--------
Cheers.
from nppmarkdownpanel.
this is fixed in release 0.6.1
from nppmarkdownpanel.
Related Issues (20)
- [Feature Request] Is it possible to add Markdeep to the viewer? HOT 3
- [Future request] The MarkdownViewer++ does not render the latex equation HOT 2
- [Feature Request] Pandoc post-processing via Save As... HOT 1
- Table of Contents (TOC) option HOT 1
- Local relative path not working with img tag HOT 2
- Error on execution in Markdown Panel. HOT 1
- Feature Request: Links whitin the same document HOT 2
- Auto update Markdownviewer preview panel not working anymore HOT 4
- Dark-mode .css anchor color is ignored when rendered in Notepad++ but displayed correctly in exported HTML
- Unable to display special characters HOT 4
- `NppTbData.pszModuleName` is not properly assigned when Markdown panel is docked
- The keyboard shortcuts are not working on the Markdown Panel. HOT 1
- Deprecated...
- Deprecated...
- Proposal - ID as combination of tag name and id number HOT 1
- Local images preview has dont work HOT 1
- preview scroll position is not preserved when switching to another file then back to markdown file
- Undocking the viewer from its default position crashes NotePad++
- Always render fenced code blocks (solved) HOT 3
- Limiting to particular file extensions is too limiting HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nppmarkdownpanel.