Skip to content

Commit

Permalink
FN RW - fix help paths, tweak RightWords
Browse files Browse the repository at this point in the history
RightWords:

- add and connect help file
- add CtrlC, CtrlIns to thesaurus
  • Loading branch information
nightroman committed Jan 8, 2021
1 parent 76d7ef1 commit dbc44a8
Show file tree
Hide file tree
Showing 15 changed files with 238 additions and 137 deletions.
4 changes: 2 additions & 2 deletions FarNet/FarNetMan/Far0.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ ref class Far0
static void ShowDrawersMenu();
static void ShowMenu(ModuleToolOptions from);
public:
static String^ FarNetRoot() { return Environment::GetEnvironmentVariable("FARHOME") + "\\FarNet"; }
static String^ HelpTopic() { return "<" + FarNetRoot() + "\\>"; }
static String^ FarNetManRoot() { return Environment::GetEnvironmentVariable("FARHOME") + "\\Plugins\\FarNet"; }
static String^ HelpTopic() { return "<" + FarNetManRoot() + "\\>"; }
static void InvalidateProxyCommand();
static void UnregisterProxyTool(IModuleTool^ tool);
private:
Expand Down
4 changes: 4 additions & 0 deletions FarNet/History.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
https://www.nuget.org/packages/FarNet
Far Manager 3.0.5505

= 5.4.18 =

Fix internal help paths.

= 5.4.17 =

Add IListMenu.TypeId assign the default.
Expand Down
2 changes: 1 addition & 1 deletion Get-Version.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$FarVersion = "3.0.5505"
$FarNetVersion = "5.4.17"
$FarNetVersion = "5.4.18"
$PowerShellFarVersion = "5.4.9"
13 changes: 12 additions & 1 deletion RightWords/.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ task build meta, {
exec { dotnet msbuild RightWords.csproj /p:FarHome=$FarHome /p:Configuration=Release }
}

task help @{
Inputs = 'README.md'
Outputs = "$ModuleHome\RightWords.hlf"
Jobs = {
exec { pandoc.exe README.md --output=z.htm --from=gfm }
exec { HtmlToFarHelp from=z.htm to=$ModuleHome\RightWords.hlf }
remove z.htm
}
}

# https://github.com/nightroman/PowerShelf/blob/master/Invoke-Environment.ps1
task resgen @{
Inputs = 'RightWords.restext', 'RightWords.ru.restext'
Expand All @@ -32,7 +42,7 @@ task resgen @{
}
}

task publish resgen
task publish help, resgen

task clean {
remove z, bin, obj, README.htm, *.nupkg
Expand Down Expand Up @@ -82,6 +92,7 @@ task package markdown, version, {
"LICENSE.txt"
"RightWords.macro.lua"
"$ModuleHome\RightWords.dll"
"$ModuleHome\RightWords.hlf"
"$ModuleHome\RightWords.resources"
"$ModuleHome\RightWords.ru.resources"
)
Expand Down
31 changes: 21 additions & 10 deletions RightWords/Actor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ static class Actor
public static readonly HashSet<string> IgnoreWords = new HashSet<string>();
static readonly IModuleManager Manager = Far.Api.GetModuleManager(Settings.ModuleName);
static readonly WeakReference CommonWords = new WeakReference(null);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
static readonly bool Initialized = Initialize();
static bool Initialize()
static Actor()
{
// home directory, for libraries and dictionaries
var home = Path.GetDirectoryName(typeof(Hunspell).Assembly.Location);
Expand All @@ -44,8 +42,6 @@ static bool Initialize()
}
}
}

return true;
}
public static HashSet<string> GetCommonWords()
{
Expand Down Expand Up @@ -80,8 +76,8 @@ public static Match MatchCaret(Regex regex, string input, int caret, bool next)
}
public static void CorrectWord()
{
ILine line = null;
IEditor editor = null;
ILine line;
IEditor editor;

var kind = Far.Api.Window.Kind;
if (kind == WindowKind.Editor)
Expand Down Expand Up @@ -164,6 +160,9 @@ public static void ShowThesaurus()

var menu = Far.Api.CreateMenu();
menu.Title = word;
menu.HelpTopic = Far.Api.GetHelpTopic("thesaurus-menu");
menu.AddKey(KeyCode.C, ControlKeyStates.LeftCtrlPressed);
menu.AddKey(KeyCode.Insert, ControlKeyStates.LeftCtrlPressed);

Far.Api.UI.SetProgressState(TaskbarProgressBarState.Indeterminate);
Far.Api.UI.WindowTitle = My.Searching;
Expand All @@ -187,10 +186,20 @@ public static void ShowThesaurus()
Far.Api.UI.SetProgressState(TaskbarProgressBarState.NoProgress);
}

if (!menu.Show())
if (!menu.Show() || menu.Selected < 0)
return;

Far.Api.CopyToClipboard(menu.Items[menu.Selected].Text);
// copy
if (menu.Key.IsCtrl() && (menu.Key.VirtualKeyCode == KeyCode.C || menu.Key.VirtualKeyCode == KeyCode.Insert))
{
// get text and remove "(...)"
var text = menu.Items[menu.Selected].Text;
var index = text.IndexOf('(');
if (index >= 0)
text = text.Substring(0, index).Trim();

Far.Api.CopyToClipboard(text);
}
}
public static bool HasMatch(MatchCollection matches, Match match)
{
Expand All @@ -203,7 +212,7 @@ public static bool HasMatch(MatchCollection matches, Match match)
}
public static MatchCollection GetMatches(Regex regex, string text)
{
return regex == null ? null : regex.Matches(text);
return regex?.Matches(text);
}
public static Regex GetRegexSkip()
{
Expand Down Expand Up @@ -384,6 +393,7 @@ static string[] ShowMenuAddWord(string word)

var menu = Far.Api.CreateMenu();
menu.Title = My.AddToDictionary;
menu.HelpTopic = My.AddToDictionaryHelp;
menu.Add(word);
menu.Add(word + ", " + word2);
if (!menu.Show())
Expand All @@ -403,6 +413,7 @@ static void AddRightWord(HashSet<string> words, string word)
// dictionary menu
var menu = Far.Api.CreateMenu();
menu.Title = My.AddToDictionary;
menu.HelpTopic = My.AddToDictionaryHelp;
menu.AutoAssignHotkeys = true;
menu.Add(My.Common);
foreach (string name in languages)
Expand Down
3 changes: 1 addition & 2 deletions RightWords/Highlighter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

namespace FarNet.RightWords
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
[System.Runtime.InteropServices.Guid("bbed2ef1-97d1-4ba2-ac56-9de56bc8030c")]
[ModuleDrawer(Name = "Spelling mistakes", Mask = "*.hlf;*.htm;*.html;*.lng;*.restext", Priority = 1)]
[System.Runtime.InteropServices.Guid("bbed2ef1-97d1-4ba2-ac56-9de56bc8030c")]
public class Highlighter : ModuleDrawer
{
readonly MultiSpell Spell = MultiSpell.Get();
Expand Down
8 changes: 8 additions & 0 deletions RightWords/History.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
https://www.nuget.org/packages/FarNet.RightWords
FarNet 5.4.13

= 2.3.3 =

Add help and connect to user interface.

Thesaurus menu:
- Esc, Enter - close, do nothing
- CtrlC, CtrlIns - copy to clipboard

= 2.3.2 =

Update for FarNet 5.4.13
Expand Down
35 changes: 18 additions & 17 deletions RightWords/My.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@
// FarNet module RightWords
// Copyright (c) Roman Kuzmin

using System;

namespace FarNet.RightWords
{
static class My
{
public const string GuidString = "ca7ecdc0-f446-4bff-a99d-06c90fe0a3a9";
public readonly static Guid Guid = new Guid(GuidString);
#region private
static readonly IModuleManager Manager = Far.Api.GetModuleManager(Settings.ModuleName);
static string GetString(string name) { return Manager.GetString(name); }
static string GetString(string name) => Manager.GetString(name);
#endregion
#region help
public static string AddToDictionaryHelp => Far.Api.GetHelpTopic("add-to-dictionary");
#endregion
static public string AddToDictionary { get { return GetString("AddToDictionary"); } }
static public string DoIgnore { get { return GetString("DoIgnore"); } }
static public string DoIgnoreAll { get { return GetString("DoIgnoreAll"); } }
static public string DoAddToDictionary { get { return GetString("DoAddToDictionary"); } }
static public string Word { get { return GetString("Word"); } }
static public string Thesaurus { get { return GetString("Thesaurus"); } }
static public string DoCorrectWord { get { return GetString("DoCorrectWord"); } }
static public string DoCorrectText { get { return GetString("DoCorrectText"); } }
static public string DoThesaurus { get { return GetString("DoThesaurus"); } }
static public string Common { get { return GetString("Common"); } }
static public string Searching { get { return GetString("Searching"); } }
static public string NewWord { get { return GetString("NewWord"); } }
static public string ExampleStem { get { return GetString("ExampleStem"); } }
public static string AddToDictionary => GetString("AddToDictionary");
public static string DoIgnore => GetString("DoIgnore");
public static string DoIgnoreAll => GetString("DoIgnoreAll");
public static string DoAddToDictionary => GetString("DoAddToDictionary");
public static string Word => GetString("Word");
public static string Thesaurus => GetString("Thesaurus");
public static string DoCorrectWord => GetString("DoCorrectWord");
public static string DoCorrectText => GetString("DoCorrectText");
public static string DoThesaurus => GetString("DoThesaurus");
public static string Common => GetString("Common");
public static string Searching => GetString("Searching");
public static string NewWord => GetString("NewWord");
public static string ExampleStem => GetString("ExampleStem");
public static string ExampleStem2 => GetString("ExampleStem");
}
}
Loading

0 comments on commit dbc44a8

Please sign in to comment.