mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add documents for Flow.Launcher.Plugin
This commit is contained in:
parent
a29ed64f3c
commit
65ae342bca
10 changed files with 141 additions and 11 deletions
|
|
@ -51,6 +51,9 @@ namespace Flow.Launcher.Plugin
|
||||||
(WinPressed ? ModifierKeys.Windows : ModifierKeys.None);
|
(WinPressed ? ModifierKeys.Windows : ModifierKeys.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default <see cref="SpecialKeyState"/> object with all keys not pressed.
|
||||||
|
/// </summary>
|
||||||
public static readonly SpecialKeyState Default = new () {
|
public static readonly SpecialKeyState Default = new () {
|
||||||
CtrlPressed = false,
|
CtrlPressed = false,
|
||||||
ShiftPressed = false,
|
ShiftPressed = false,
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,42 @@ using System.Threading;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin
|
namespace Flow.Launcher.Plugin
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for plugins that want to manually update their results
|
||||||
|
/// </summary>
|
||||||
public interface IResultUpdated : IFeatures
|
public interface IResultUpdated : IFeatures
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is triggered when the results are updated
|
||||||
|
/// </summary>
|
||||||
event ResultUpdatedEventHandler ResultsUpdated;
|
event ResultUpdatedEventHandler ResultsUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for the ResultsUpdated event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e);
|
public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event arguments for the ResultsUpdated event
|
||||||
|
/// </summary>
|
||||||
public class ResultUpdatedEventArgs : EventArgs
|
public class ResultUpdatedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// List of results that should be displayed
|
||||||
|
/// </summary>
|
||||||
public List<Result> Results;
|
public List<Result> Results;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Query that triggered the update
|
||||||
|
/// </summary>
|
||||||
public Query Query;
|
public Query Query;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Token that can be used to cancel the update
|
||||||
|
/// </summary>
|
||||||
public CancellationToken Token { get; init; }
|
public CancellationToken Token { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,15 @@
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin
|
namespace Flow.Launcher.Plugin
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This interface is used to create settings panel for .Net plugins
|
||||||
|
/// </summary>
|
||||||
public interface ISettingProvider
|
public interface ISettingProvider
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Create settings panel control for .Net plugins
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
Control CreateSettingPanel();
|
Control CreateSettingPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,18 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginInitContext
|
public class PluginInitContext
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Default constructor.
|
||||||
|
/// </summary>
|
||||||
public PluginInitContext()
|
public PluginInitContext()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="currentPluginMetadata"></param>
|
||||||
|
/// <param name="api"></param>
|
||||||
public PluginInitContext(PluginMetadata currentPluginMetadata, IPublicAPI api)
|
public PluginInitContext(PluginMetadata currentPluginMetadata, IPublicAPI api)
|
||||||
{
|
{
|
||||||
CurrentPluginMetadata = currentPluginMetadata;
|
CurrentPluginMetadata = currentPluginMetadata;
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,37 @@
|
||||||
namespace Flow.Launcher.Plugin
|
namespace Flow.Launcher.Plugin
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Plugin instance and plugin metadata
|
||||||
|
/// </summary>
|
||||||
public class PluginPair
|
public class PluginPair
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Plugin instance
|
||||||
|
/// </summary>
|
||||||
public IAsyncPlugin Plugin { get; internal set; }
|
public IAsyncPlugin Plugin { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Plugin metadata
|
||||||
|
/// </summary>
|
||||||
public PluginMetadata Metadata { get; internal set; }
|
public PluginMetadata Metadata { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert to string
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Metadata.Name;
|
return Metadata.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compare by plugin metadata ID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
PluginPair r = obj as PluginPair;
|
if (obj is PluginPair r)
|
||||||
if (r != null)
|
|
||||||
{
|
{
|
||||||
return string.Equals(r.Metadata.ID, Metadata.ID);
|
return string.Equals(r.Metadata.ID, Metadata.ID);
|
||||||
}
|
}
|
||||||
|
|
@ -25,6 +41,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get hash coode
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
var hashcode = Metadata.ID?.GetHashCode() ?? 0;
|
var hashcode = Metadata.ID?.GetHashCode() ?? 0;
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin
|
namespace Flow.Launcher.Plugin
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a query that is sent to a plugin.
|
||||||
|
/// </summary>
|
||||||
public class Query
|
public class Query
|
||||||
{
|
{
|
||||||
public Query() { }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raw query, this includes action keyword if it has
|
/// Raw query, this includes action keyword if it has
|
||||||
/// We didn't recommend use this property directly. You should always use Search property.
|
/// We didn't recommend use this property directly. You should always use Search property.
|
||||||
|
|
@ -55,13 +56,13 @@ namespace Flow.Launcher.Plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ActionKeyword { get; init; }
|
public string ActionKeyword { get; init; }
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Splits <see cref="SearchTerms"/> by spaces and returns the first item.
|
/// Splits <see cref="SearchTerms"/> by spaces and returns the first item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// returns an empty string when <see cref="SearchTerms"/> does not have enough items.
|
/// returns an empty string when <see cref="SearchTerms"/> does not have enough items.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[JsonIgnore]
|
||||||
public string FirstSearch => SplitSearch(0);
|
public string FirstSearch => SplitSearch(0);
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -13,7 +12,6 @@ namespace Flow.Launcher.Plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Result
|
public class Result
|
||||||
{
|
{
|
||||||
|
|
||||||
private string _pluginDirectory;
|
private string _pluginDirectory;
|
||||||
|
|
||||||
private string _icoPath;
|
private string _icoPath;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ using System.Linq;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.SharedCommands
|
namespace Flow.Launcher.Plugin.SharedCommands
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains methods to open a search in a new browser window or tab.
|
||||||
|
/// </summary>
|
||||||
public static class SearchWeb
|
public static class SearchWeb
|
||||||
{
|
{
|
||||||
private static string GetDefaultBrowserPath()
|
private static string GetDefaultBrowserPath()
|
||||||
|
|
@ -106,4 +109,4 @@ namespace Flow.Launcher.Plugin.SharedCommands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,26 @@ using Windows.Win32.Foundation;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.SharedCommands
|
namespace Flow.Launcher.Plugin.SharedCommands
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains methods for running shell commands
|
||||||
|
/// </summary>
|
||||||
public static class ShellCommand
|
public static class ShellCommand
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for EnumThreadWindows
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwnd"></param>
|
||||||
|
/// <param name="lParam"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam);
|
public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam);
|
||||||
|
|
||||||
private static bool containsSecurityWindow;
|
private static bool containsSecurityWindow;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs a windows command using the provided ProcessStartInfo
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="processStartInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Process RunAsDifferentUser(ProcessStartInfo processStartInfo)
|
public static Process RunAsDifferentUser(ProcessStartInfo processStartInfo)
|
||||||
{
|
{
|
||||||
processStartInfo.Verb = "RunAsUser";
|
processStartInfo.Verb = "RunAsUser";
|
||||||
|
|
@ -65,6 +79,15 @@ namespace Flow.Launcher.Plugin.SharedCommands
|
||||||
return buffer[..length].ToString();
|
return buffer[..length].ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs a windows command using the provided ProcessStartInfo
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <param name="workingDirectory"></param>
|
||||||
|
/// <param name="arguments"></param>
|
||||||
|
/// <param name="verb"></param>
|
||||||
|
/// <param name="createNoWindow"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static ProcessStartInfo SetProcessStartInfo(this string fileName, string workingDirectory = "",
|
public static ProcessStartInfo SetProcessStartInfo(this string fileName, string workingDirectory = "",
|
||||||
string arguments = "", string verb = "", bool createNoWindow = false)
|
string arguments = "", string verb = "", bool createNoWindow = false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,29 @@
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.SharedModels
|
namespace Flow.Launcher.Plugin.SharedModels
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the result of a match operation.
|
||||||
|
/// </summary>
|
||||||
public class MatchResult
|
public class MatchResult
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="MatchResult"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="success"></param>
|
||||||
|
/// <param name="searchPrecision"></param>
|
||||||
public MatchResult(bool success, SearchPrecisionScore searchPrecision)
|
public MatchResult(bool success, SearchPrecisionScore searchPrecision)
|
||||||
{
|
{
|
||||||
Success = success;
|
Success = success;
|
||||||
SearchPrecision = searchPrecision;
|
SearchPrecision = searchPrecision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="MatchResult"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="success"></param>
|
||||||
|
/// <param name="searchPrecision"></param>
|
||||||
|
/// <param name="matchData"></param>
|
||||||
|
/// <param name="rawScore"></param>
|
||||||
public MatchResult(bool success, SearchPrecisionScore searchPrecision, List<int> matchData, int rawScore)
|
public MatchResult(bool success, SearchPrecisionScore searchPrecision, List<int> matchData, int rawScore)
|
||||||
{
|
{
|
||||||
Success = success;
|
Success = success;
|
||||||
|
|
@ -18,6 +33,9 @@ namespace Flow.Launcher.Plugin.SharedModels
|
||||||
RawScore = rawScore;
|
RawScore = rawScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the match operation was successful.
|
||||||
|
/// </summary>
|
||||||
public bool Success { get; set; }
|
public bool Success { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -30,6 +48,9 @@ namespace Flow.Launcher.Plugin.SharedModels
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _rawScore;
|
private int _rawScore;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The raw calculated search score without any search precision filtering applied.
|
||||||
|
/// </summary>
|
||||||
public int RawScore
|
public int RawScore
|
||||||
{
|
{
|
||||||
get { return _rawScore; }
|
get { return _rawScore; }
|
||||||
|
|
@ -45,8 +66,15 @@ namespace Flow.Launcher.Plugin.SharedModels
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<int> MatchData { get; set; }
|
public List<int> MatchData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The search precision score used to filter the search results.
|
||||||
|
/// </summary>
|
||||||
public SearchPrecisionScore SearchPrecision { get; set; }
|
public SearchPrecisionScore SearchPrecision { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the search precision score is met.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public bool IsSearchPrecisionScoreMet()
|
public bool IsSearchPrecisionScoreMet()
|
||||||
{
|
{
|
||||||
return IsSearchPrecisionScoreMet(_rawScore);
|
return IsSearchPrecisionScoreMet(_rawScore);
|
||||||
|
|
@ -63,10 +91,24 @@ namespace Flow.Launcher.Plugin.SharedModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the search precision score used to filter search results.
|
||||||
|
/// </summary>
|
||||||
public enum SearchPrecisionScore
|
public enum SearchPrecisionScore
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The highest search precision score.
|
||||||
|
/// </summary>
|
||||||
Regular = 50,
|
Regular = 50,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The medium search precision score.
|
||||||
|
/// </summary>
|
||||||
Low = 20,
|
Low = 20,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The lowest search precision score.
|
||||||
|
/// </summary>
|
||||||
None = 0
|
None = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue