This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
forked from Wox-launcher/Wox
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into release_branch
- Loading branch information
Showing
23 changed files
with
398 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Wox.Plugin; | ||
|
||
namespace Wox.Core.Plugin | ||
{ | ||
public static class QueryBuilder | ||
{ | ||
public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalPlugins) | ||
{ | ||
// replace multiple white spaces with one white space | ||
var terms = text.Split(new[] { Query.TermSeperater }, StringSplitOptions.RemoveEmptyEntries); | ||
if (terms.Length == 0) | ||
{ // nothing was typed | ||
return null; | ||
} | ||
|
||
var rawQuery = string.Join(Query.TermSeperater, terms); | ||
string actionKeyword, search; | ||
string possibleActionKeyword = terms[0]; | ||
List<string> actionParameters; | ||
if (nonGlobalPlugins.TryGetValue(possibleActionKeyword, out var pluginPair) && !pluginPair.Metadata.Disabled) | ||
{ // use non global plugin for query | ||
actionKeyword = possibleActionKeyword; | ||
actionParameters = terms.Skip(1).ToList(); | ||
search = rawQuery.Substring(actionKeyword.Length + 1); | ||
} | ||
else | ||
{ // non action keyword | ||
actionKeyword = string.Empty; | ||
actionParameters = terms.ToList(); | ||
search = rawQuery; | ||
} | ||
|
||
var query = new Query | ||
{ | ||
Terms = terms, | ||
RawQuery = rawQuery, | ||
ActionKeyword = actionKeyword, | ||
Search = search, | ||
// Obsolete value initialisation | ||
ActionName = actionKeyword, | ||
ActionParameters = actionParameters | ||
}; | ||
|
||
return query; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.