Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum Page {
ClipboardHistory,
}

/// The types of arrow keys
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub enum ArrowKey {
Expand All @@ -32,6 +33,7 @@ pub enum ArrowKey {
Right,
}

/// The ways the cursor can move when a key is pressed
#[derive(Debug, Clone)]
pub enum Move {
Back,
Expand Down
3 changes: 3 additions & 0 deletions src/app/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ impl Drop for ExtSender {
fn drop(&mut self) {}
}

/// All the indexed apps that rustcast can search for
#[derive(Clone, Debug)]
struct AppIndex {
by_name: BTreeMap<String, App>,
}

impl AppIndex {
/// Search for an element in the index that starts with the provided prefix
fn search_prefix<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item = &'a App> + 'a {
self.by_name
.range(prefix.to_string()..) // start at prefix
.take_while(move |(k, _)| k.starts_with(prefix))
.map(|(_, v)| v)
}

/// Factory function for creating
pub fn from_apps(options: Vec<App>) -> Self {
let mut bmap = BTreeMap::new();
for app in options {
Expand Down
3 changes: 3 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ pub(crate) fn get_installed_apps(dir: impl AsRef<Path>, store_icons: bool) -> Ve
.collect()
}

/// Open the settings file with the system default editor
pub fn open_settings() {
thread::spawn(move || {
NSWorkspace::new().openURL(&NSURL::fileURLWithPath(
Expand All @@ -188,6 +189,7 @@ pub fn open_settings() {
});
}

/// Open a provided URL (Platform specific)
pub fn open_url(url: &str) {
let url = url.to_owned();
thread::spawn(move || {
Expand All @@ -198,6 +200,7 @@ pub fn open_url(url: &str) {
});
}

/// Check if the provided string is a valid url
pub fn is_valid_url(s: &str) -> bool {
s.ends_with(".com")
|| s.ends_with(".net")
Expand Down