HudSettings

HudSettings — tunable parameters

Synopsis

struct              HudSettings;
extern HudSettings  hud_settings;
void                hud_settings_init                   (void);

Description

HudSettings is a structure that contains the value of several tunable parameters that affect the behaviour of various components of the HUD.

This structure exists for two reasons.

The first reason is that caching these values in local variables eliminates the need to look them up from GSettings on each use. This vastly improves the performance of the matching algorithms (as many of these values are used quite a lot from within them).

The second reason is to improve testability. The testcases are able to hardcode sane values for the settings without worrying about changes that the user may have made to their local configuration (which could otherwise cause spurious test failures).

Details

struct HudSettings

struct HudSettings {
  gboolean store_usage_data;

  guint indicator_penalty;
  guint max_distance;

  guint add_penalty;
  guint drop_penalty;
  guint end_drop_penalty;
  guint swap_penalty;
};

This structure contains the value of several tunable parameters that affect the behaviour of various components of the HUD.

gboolean store_usage_data;

if usage tracking should be performed

guint indicator_penalty;

the percentage by which to increase the distance of indicators when sorting the results list

guint max_distance;

the maximum distance value we consider as being a matching result

guint add_penalty;

the penalty incurred by a character in the search term that does not exist in the item being matched

guint drop_penalty;

the penalty incurred by a character missing from the search string as compared to the item being matched

guint end_drop_penalty;

the penalty incurred by a character missing from the search string as compared to the item being matched when the character is at the end of the item (ie: the search term is a prefix of the item)

guint swap_penalty;

the penalty incurred for the substitution of one character for another

hud_settings

extern HudSettings hud_settings;

The HudSettings in effect.

hud_settings_init() can be used to keep these values in sync with GSettings. For testing, it may make sense to set these values directly.


hud_settings_init ()

void                hud_settings_init                   (void);

Initialises the HudSettings using GSettings and keeps it in sync.

If GSettings indicates that the settings have changed, they will be updated.