Skip to content
Myr

match.h

This file

Path

match.h

81 lines · 2.9 KiB · C

Last changed by

match: fzf: prioritize matches at word boundary, like fzfMark Stosbergbefore adoption6554dbe

History of this file

Take it

1#pragma once23#include <stdbool.h>4#include <unistd.h>56#include "application.h"7#include "config.h"8#include "fdm.h"9#include "prompt.h"1011enum matched_type {12    MATCHED_NONE,13    MATCHED_EXACT,14    MATCHED_FUZZY,15};1617struct match_substring {18    ssize_t start;19    size_t len;20};2122struct match {23    enum matched_type matched_type;24    struct application *application;25    struct match_substring *pos;26    size_t pos_count;27    size_t score;28    bool word_boundary;  /* True if match starts at word boundary */29};3031struct wayland;32struct matches;33struct matches *matches_init(struct fdm *fdm, const struct prompt *prompt,34                             enum match_fields fields, enum match_mode mode,35                             bool sort_result,36                             size_t fuzzy_min_length,37                             size_t fuzzy_max_length_discrepancy,38                             size_t fuzzy_max_distance, uint16_t workers,39                             size_t delay_ms, size_t delay_limit);40void matches_destroy(struct matches *matches);4142void matches_set_wayland(struct matches *matches, struct wayland *wayl);43void matches_set_applications(44    struct matches *matches, struct application_list *applications);45void matches_all_applications_loaded(struct matches *matches);46void matches_icons_loaded(struct matches *matches);47bool matches_have_icons(const struct matches *matches);48void matches_lock(struct matches *matches);49void matches_unlock(struct matches *matches);5051size_t matches_max_matches_per_page(const struct matches *matches);52void matches_max_matches_per_page_set(53    struct matches *matches, size_t max_matches);5455void matches_update(struct matches *matches);56void matches_update_no_delay(struct matches *matches);57void matches_update_incremental(struct matches *matches);5859size_t matches_get_page_count(const struct matches *matches);60size_t matches_get_page(const struct matches *matches);6162const struct match *matches_get(const struct matches *matches, size_t idx);63const struct match *matches_get_match(const struct matches *matches);64size_t matches_get_application_visible_count(const struct matches *matches);65size_t matches_get_count(const struct matches *matches); /* Matches on current page */66size_t matches_get_total_count(const struct matches *matches);67size_t matches_get_match_index(const struct matches *matches);6869bool matches_selected_select(struct matches *matches, const char *string);70bool matches_idx_select(struct matches *matches, size_t idx);7172bool matches_selected_set(struct matches *matches, const size_t idx);7374bool matches_selected_first(struct matches *matches);75bool matches_selected_last(struct matches *matches);7677bool matches_selected_prev(struct matches *matches, bool wrap);78bool matches_selected_next(struct matches *matches, bool wrap);7980bool matches_selected_prev_page(struct matches *matches, bool scrolling);81bool matches_selected_next_page(struct matches *matches, bool scrolling);