Skip to content

Conversation

@TheRGuy9201
Copy link
Contributor

Summary

Array Indices Display Configuration Feature

Description

This PR adds functionality to the Randomness plugin to allow users to configure how array indices are displayed when generating arrays of schemes or templates. This pull request solves the problem related to issue #582. Users can now:

  1. Enable or disable index display
  2. Configure the format of indices using a template
  3. Use tuple-style indices for multi-dimensional arrays

Implementation Details

New Properties in ArrayDecorator

  • showIndices: Boolean to control if indices are displayed (default: false)
  • indicesFormat: String template for formatting indices (default: "{index}: {value}")
  • useTupleIndices: Boolean to enable tuple-style indices (default: false)

UI Changes in ArrayDecoratorEditor

  • Added "Show indices" checkbox
  • Added dropdown for selecting index format with predefined templates
  • Added "Use tuple indices" checkbox for multi-dimensional arrays
  • Added help text explaining format placeholders

Localization

  • Added appropriate bundle properties in randomness.properties
  • Added help text explaining the format template options

Example Outputs

With this feature, users can generate arrays in different formats, like:

  1. Default array (no indices):
    ["foo", "bar", "quz"]
  2. With standard indices:
    [0: "foo", 1: "bar", 2: "quz"]
  3. With JSON-style indices:
    ["0": "foo", "1": "bar", "2": "quz"]
  4. With tuple indices:
    [(0,0): "foo", (0,1): "bar", (0,2): "quz"]
  5. Custom formats (e.g., {index}={value}):
    [0="foo", 1="bar", 2="quz"]

Testing

  • Added unit tests for standard indices display
  • Added unit tests for the tuple indices display
  • Added tests for various format templates
  • Added UI tests for the new controls

@fwdekker
Copy link
Owner

Note: Superseded by #585.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants