summaryrefslogtreecommitdiff
path: root/Userland/Applications/Assistant/Providers.h
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-07-01 10:15:53 -0400
committerGunnar Beutner <gunnar@beutner.name>2021-07-03 15:41:35 +0200
commitd69691a26b8833a56aeccd23e6e4b75b0b8a0798 (patch)
tree70aeb754767b966f72c391d665d4bce352b9e831 /Userland/Applications/Assistant/Providers.h
parentd5dfc255edf3f67d32cd83cb63445fab76f451f8 (diff)
downloadserenity-d69691a26b8833a56aeccd23e6e4b75b0b8a0798.zip
Assistant: Add provider to run a command in a terminal
Prefix text with "$" in the Assistant text box to run a command in a forked terminal. For example, "$ top" or "$ top -s pid".
Diffstat (limited to 'Userland/Applications/Assistant/Providers.h')
-rw-r--r--Userland/Applications/Assistant/Providers.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/Userland/Applications/Assistant/Providers.h b/Userland/Applications/Assistant/Providers.h
index edc1af19f6..e8be8deb1b 100644
--- a/Userland/Applications/Assistant/Providers.h
+++ b/Userland/Applications/Assistant/Providers.h
@@ -85,6 +85,16 @@ public:
void activate() const override;
};
+class TerminalResult : public Result {
+public:
+ explicit TerminalResult(String command)
+ : Result(GUI::Icon::default_icon("app-terminal").bitmap_for_size(16), move(command), "Run command in Terminal"sv, 100)
+ {
+ }
+ ~TerminalResult() override = default;
+ void activate() const override;
+};
+
class URLResult : public Result {
public:
explicit URLResult(const URL& url)
@@ -99,31 +109,36 @@ class Provider {
public:
virtual ~Provider() = default;
- virtual void query(const String&, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) = 0;
+ virtual void query(const String&, Function<void(NonnullRefPtrVector<Result>)> on_complete) = 0;
};
class AppProvider : public Provider {
public:
- void query(String const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
+ void query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
};
class CalculatorProvider : public Provider {
public:
- void query(String const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
+ void query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
};
class FileProvider : public Provider {
public:
- void query(String const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;
+ void query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
void build_filesystem_cache();
private:
- RefPtr<Threading::BackgroundAction<Vector<NonnullRefPtr<Result>>>> m_fuzzy_match_work;
+ RefPtr<Threading::BackgroundAction<NonnullRefPtrVector<Result>>> m_fuzzy_match_work;
bool m_building_cache { false };
Vector<String> m_full_path_cache;
Queue<String> m_work_queue;
};
+class TerminalProvider : public Provider {
+public:
+ void query(String const& query, Function<void(NonnullRefPtrVector<Result>)> on_complete) override;
+};
+
class URLProvider : public Provider {
public:
void query(String const& query, Function<void(Vector<NonnullRefPtr<Result>>)> on_complete) override;