Skip to content

Commit

Permalink
Release 0.7.4.2
Browse files Browse the repository at this point in the history
Add Ignore annoying script error popups as Settings
Add ESC key closes Settings form dialog as Cancel
Add ESC key closes About form dialog
Change dockable title bar to match current filename
Set focus back to Notepad++ editor buffer when opening panel
Update README

Merge branch 'develop'
  • Loading branch information
VinsWorldcom committed Oct 26, 2023
2 parents 29db83c + dbd9b44 commit 8c8bc88
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 7 deletions.
4 changes: 2 additions & 2 deletions MarkdigWrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.4.1")]
[assembly: AssemblyFileVersion("0.7.4.1")]
[assembly: AssemblyVersion("0.7.4.2")]
[assembly: AssemblyFileVersion("0.7.4.2")]
1 change: 1 addition & 0 deletions NppMarkdownPanel/Entities/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Settings
public bool IsDarkModeEnabled { get; set; }
public bool ShowToolbar { get; set; }
public bool ShowStatusbar { get; set; }
public bool SuppressScriptErrors { get; set; }
public bool AutoShowPanel { get; set; }

public const int FILTERS = 10;
Expand Down
2 changes: 2 additions & 0 deletions NppMarkdownPanel/Forms/AboutForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions NppMarkdownPanel/Forms/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@ public AboutForm()
this.ActiveControl = btnOk;
}

private void cancelButton_Click(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.Close();
}
}

}
}
1 change: 1 addition & 0 deletions NppMarkdownPanel/Forms/MarkdownPreviewForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions NppMarkdownPanel/Forms/MarkdownPreviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void UpdateSettings(Settings settings)

tbPreview.Visible = settings.ShowToolbar;
statusStrip2.Visible = settings.ShowStatusbar;
webBrowserPreview.ScriptErrorsSuppressed = settings.SuppressScriptErrors;
}

private MarkdownService markdownService;
Expand Down
16 changes: 16 additions & 0 deletions NppMarkdownPanel/Forms/SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions NppMarkdownPanel/Forms/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class SettingsForm : Form
public string HtmlExtensions { get; set; }
public bool AutoShowPanel { get; set; }
public bool ShowStatusbar { get; set; }
public bool SuppressScriptErrors { get; set; }

public SettingsForm(Settings settings)
{
Expand All @@ -27,6 +28,7 @@ public SettingsForm(Settings settings)
HtmlExtensions = settings.HtmlExtensions;
AutoShowPanel = settings.AutoShowPanel;
ShowStatusbar = settings.ShowStatusbar;
SuppressScriptErrors = settings.SuppressScriptErrors;

InitializeComponent();

Expand All @@ -40,6 +42,7 @@ public SettingsForm(Settings settings)
tbHtmlExts.Text = HtmlExtensions;
cbAutoShowPanel.Checked = AutoShowPanel;
cbShowStatusbar.Checked = ShowStatusbar;
cbSuppressScriptErrors.Checked = SuppressScriptErrors;
}

private void trackBar1_ValueChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -74,6 +77,14 @@ private void btnSave_Click(object sender, EventArgs e)
}
}

private void cancelEsc_Click(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.DialogResult = DialogResult.Cancel;
}
}

private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
Expand Down Expand Up @@ -196,5 +207,10 @@ private void cbShowStatusbar_CheckedChanged(object sender, EventArgs e)
{
ShowStatusbar = cbShowStatusbar.Checked;
}

private void cbSuppressScriptErrors_CheckedChanged(object sender, EventArgs e)
{
SuppressScriptErrors = cbSuppressScriptErrors.Checked;
}
}
}
41 changes: 38 additions & 3 deletions NppMarkdownPanel/MarkdownPanelController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class MarkdownPanelController

private Settings settings;

private IntPtr _ptrNppTbData;

public MarkdownPanelController()
{
scintillaGatewayFactory = PluginBase.GetGatewayFactory();
Expand All @@ -68,6 +70,7 @@ private Settings LoadSettingsFromIni()
settings.HtmlFileName = Win32.ReadIniValue("Options", "HtmlFileName", iniFilePath);
settings.ShowToolbar = PluginUtils.ReadIniBool("Options", "ShowToolbar", iniFilePath);
settings.ShowStatusbar = PluginUtils.ReadIniBool("Options", "ShowStatusbar", iniFilePath);
settings.SuppressScriptErrors = PluginUtils.ReadIniBool("Options", "SuppressScriptErrors", iniFilePath);
settings.MkdnExtensions = Win32.ReadIniValue("Options", "MkdnExtensions", iniFilePath, Settings.DEFAULT_SUPPORTED_MKDN_EXT);
settings.HtmlExtensions = Win32.ReadIniValue("Options", "HtmlExtensions", iniFilePath, Settings.DEFAULT_SUPPORTED_HTML_EXT);
settings.IsDarkModeEnabled = IsDarkModeEnabled();
Expand Down Expand Up @@ -204,7 +207,34 @@ private void OnRenderTimerElapsed(object source, EventArgs e)

private void RenderMarkdownDirect(bool preserveVerticalScrollPosition = true)
{
viewerInterface.RenderMarkdown(GetCurrentEditorText(), notepadPPGateway.GetCurrentFilePath(), preserveVerticalScrollPosition);
string filepath = notepadPPGateway.GetCurrentFilePath();
if (_ptrNppTbData != IntPtr.Zero)
{
string caption = Main.PluginTitle;
caption += " - ";
caption += Path.GetFileName(filepath);
IntPtr pCaption = Marshal.ReadIntPtr(_ptrNppTbData, IntPtr.Size);
byte[] newCaption = new System.Text.UnicodeEncoding().GetBytes(caption);
int p = 0;
// We only have 48 characters to use (see line 379)
// But each character is 2 bytes (TCHAR / Unicode), so 96
// Copy as much and bail if still going to write the last 2 NULLs
for (; p < newCaption.Length; p++)
{
if (p >= 94)
break;
Marshal.WriteByte((pCaption + p), newCaption[p]);
}
Marshal.WriteInt16((pCaption + p), 0);
Marshal.WriteInt16((pCaption + (p+1)), 0);
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMUPDATEDISPINFO, 0, viewerInterface.Handle);
}

viewerInterface.RenderMarkdown(GetCurrentEditorText(), filepath, preserveVerticalScrollPosition);

// Set focus back to Notepad++ editor buffer
var scintillaGateway = scintillaGatewayFactory();
scintillaGateway.GrabFocus();
}

private string GetCurrentEditorText()
Expand Down Expand Up @@ -257,6 +287,7 @@ private void EditSettings()
settings.MkdnExtensions = settingsForm.MkdnExtensions;
settings.HtmlExtensions = settingsForm.HtmlExtensions;
settings.ShowStatusbar = settingsForm.ShowStatusbar;
settings.SuppressScriptErrors = settingsForm.SuppressScriptErrors;
settings.AutoShowPanel = settingsForm.AutoShowPanel;

settings.IsDarkModeEnabled = IsDarkModeEnabled();
Expand Down Expand Up @@ -332,6 +363,7 @@ private void SaveSettings()
Win32.WriteIniValue("Options", "HtmlFileName", settings.HtmlFileName, iniFilePath);
Win32.WriteIniValue("Options", "ShowToolbar", settings.ShowToolbar.ToString(), iniFilePath);
Win32.WriteIniValue("Options", "ShowStatusbar", settings.ShowStatusbar.ToString(), iniFilePath);
Win32.WriteIniValue("Options", "SuppressScriptErrors", settings.SuppressScriptErrors.ToString(), iniFilePath);
Win32.WriteIniValue("Options", "MkdnExtensions", settings.MkdnExtensions, iniFilePath);
Win32.WriteIniValue("Options", "HtmlExtensions", settings.HtmlExtensions, iniFilePath);
Win32.WriteIniValue("Options", "AutoShowPanel", settings.AutoShowPanel.ToString(), iniFilePath);
Expand All @@ -350,12 +382,15 @@ private void TogglePanelVisible()
{
NppTbData _nppTbData = new NppTbData();
_nppTbData.hClient = viewerInterface.Handle;
_nppTbData.pszName = Main.PluginTitle;
// Main.PluginTitle ("Markdown Panel") = 14 + 34 spaces = 48
string caption = Main.PluginTitle;
caption += " ";
_nppTbData.pszName = caption;
_nppTbData.dlgID = idMyDlg;
_nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR;
_nppTbData.hIconTab = (uint)ConvertBitmapToIcon(Properties.Resources.markdown_16x16_solid_bmp).Handle;
_nppTbData.pszModuleName = Main.ModuleName;
IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
_ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false);

Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);
Expand Down
4 changes: 2 additions & 2 deletions NppMarkdownPanel/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.4.1")]
[assembly: AssemblyFileVersion("0.7.4.1")]
[assembly: AssemblyVersion("0.7.4.2")]
[assembly: AssemblyFileVersion("0.7.4.2")]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ To open the settings for this plugin: Plugins -> Markdown Panel -> Settings
* #### Show Toolbar in Preview Window
Checking this box will enable the toolbar in the preview window. By default, this is unchecked.

* #### Suppress Script Errors
Suppress the annoying popups about script errors when this is really meant to be just a viewer, not a full-blown Browser. **HINT:** To see scripts "run properly", open in a real browser.

### Preview Window Toolbar

* #### Save As... (![save-btn](help/save-btn.png "Picture of the Save button on the preview panel toolbar"))
Expand Down

0 comments on commit 8c8bc88

Please sign in to comment.