:class:`Settings` provides a way to define and access settings in a hierarchical fashion. The value of a setting can \ be defined for each hierarchical level, where each level overrides the preceding level. The backing-store for setting \ values at each level is also configurable. This allows fo
| 29 | from typing import List, Optional, Union |
| 30 | |
| 31 | class Settings: |
| 32 | """ |
| 33 | :class:`Settings` provides a way to define and access settings in a hierarchical fashion. The value of a setting can \ |
| 34 | be defined for each hierarchical level, where each level overrides the preceding level. The backing-store for setting \ |
| 35 | values at each level is also configurable. This allows for ephemeral or platform-independent persistent settings storage \ |
| 36 | for components within Binary Ninja or consumers of the Binary Ninja API. |
| 37 | |
| 38 | Each :class:`Settings` instance has an ``instance_id`` which identifies a schema. The schema defines the settings contents \ |
| 39 | and the way in which settings are retrieved and manipulated. A new :class:`Settings` instance defaults to using a value of *'default'* \ |
| 40 | for the ``instance_id``. The *'default'* settings schema defines all of the settings available for the active Binary Ninja components \ |
| 41 | which include at a minimum, the settings defined by the Binary Ninja core. The *'default'* schema may additionally define settings \ |
| 42 | for the UI and/or installed plugins. Extending existing schemas, or defining new ones is accomplished by calling :func:`register_group` \ |
| 43 | and :func:`register_setting` methods, or by deserializing an existing schema with :func:`deserialize_schema`. |
| 44 | |
| 45 | .. note:: All settings in the *'default'* settings schema are rendered with UI elements in the Settings View of Binary Ninja UI. |
| 46 | |
| 47 | Allowing setting overrides is an important feature and Binary Ninja accomplishes this by allowing one to override a setting at various \ |
| 48 | levels. The levels and their associated storage are shown in the following table. Default setting values are optional, and if specified, \ |
| 49 | saved in the schema itself. |
| 50 | |
| 51 | ================= ========================== ============== ============================================== |
| 52 | Setting Level Settings Scope Preference Storage |
| 53 | ================= ========================== ============== ============================================== |
| 54 | Default SettingsDefaultScope Lowest Settings Schema |
| 55 | User SettingsUserScope - <User Directory>/settings.json |
| 56 | Project SettingsProjectScope - <Project Directory>/settings.json |
| 57 | Resource SettingsResourceScope Highest Raw BinaryView (Storage in BNDB) |
| 58 | ================= ========================== ============== ============================================== |
| 59 | |
| 60 | Settings are identified by a key, which is a string in the form of **'<group>.<name>'** or **'<group>.<subGroup>.<name>'**. Groups provide \ |
| 61 | a simple way to categorize settings. Sub-groups are optional and multiple sub-groups are allowed. When defining a settings group, the \ |
| 62 | :func:`register_group` method allows for specifying a UI friendly title for use in the Binary Ninja UI. Defining a new setting requires a \ |
| 63 | unique setting key and a JSON string of property, value pairs. The following table describes the available properties and values. |
| 64 | |
| 65 | =================== ====================================== ================== ======== ======================================================================= |
| 66 | Property JSON Data Type Prerequisite Optional {Allowed Values} and Notes |
| 67 | =================== ====================================== ================== ======== ======================================================================= |
| 68 | "title" string None No Concise Setting Title |
| 69 | "type" string None No {"array", "boolean", "number", "string", "object"} |
| 70 | "sorted" boolean "type" is "array" Yes Automatically sort list items (default is false) |
| 71 | "isSerialized" boolean "type" is "string" Yes Treat the string as a serialized JSON object |
| 72 | "enum" array : {string} "type" is "string" Yes Enumeration definitions |
| 73 | "enumDescriptions" array : {string} "type" is "string" Yes Enumeration descriptions that match "enum" array |
| 74 | "minValue" number "type" is "number" Yes Specify 0 to infer unsigned (default is signed) |
| 75 | "maxValue" number "type" is "number" Yes Values less than or equal to INT_MAX result in a QSpinBox UI element |
| 76 | "precision" number "type" is "number" Yes Specify precision for a QDoubleSpinBox |
| 77 | "default" {array, boolean, number, string, null} None Yes Specify optimal default value |
| 78 | "aliases" array : {string} None Yes Array of deprecated setting key(s) |
| 79 | "description" string None No Detailed setting description |
| 80 | "ignore" array : {string} None Yes {"SettingsUserScope", "SettingsProjectScope", "SettingsResourceScope"} |
| 81 | "message" string None Yes An optional message with additional emphasis |
| 82 | "readOnly" boolean None Yes Only enforced by UI elements |
| 83 | "optional" boolean None Yes Indicates setting can be null |
| 84 | "hidden" bool "type" is "string" Yes Indicates the UI should conceal the content. The "ignore" property is required to specify the applicable storage scopes |
| 85 | "requiresRestart boolean None Yes Enable restart notification in the UI upon change |
| 86 | "uiSelectionAction" string "type" is "string" Yes {"file", "directory", <Registered UIAction Name>} Informs the UI to add a button to open a selection dialog or run a registered UIAction |
| 87 | =================== ====================================== ================== ======== ======================================================================= |
| 88 |
no outgoing calls
no test coverage detected